I recently came up against a bit of an issue whilst working on my MacBook Pro in the office, due to the environment we work in access to the outside world is tightly controlled by our firewall, and although I love to spend countless hours adding and tweaking rules (not strictly true) – I wanted to find a better solution for routing traffic to certain sources over certain connections.
Now – there’s a couple of fairly major caveats on this ‘how-to’ and that is that a second network needs to be available and that the gateway addresses are different.
For the purposes of this tutorial, my wired lan connections IP address is 10.0.0.1 and my wireless connections IP address 192.168.2.2.
The tutorial was born from my laptop’s need to communicate with Stanford Universities Folding@Home client, which needed to communicate with its job server 184.108.40.206* to upload and download new work packages. (*This is one IP address of many used)
Knowing I had my unrestricted wireless connection available I knew I wouldn’t have any issues, however as my MacBook’s service order is always set to use the cabled connection first – the client would always try sending over that and then fail.
Working around this is however, fairly straight forward and easy to achieve. All I needed to do was to direct all the network traffic to Stanford’s servers over my wireless connections gateway.
To do this, all you need to do is fire up a terminal session and type the following:
Sudo route add 220.127.116.11 192.168.2.1
Upon hitting return you should be prompted for your ‘sudo’ password, once added the route will then be added to the routing table. Thus forcing all traffic to that address to ignore my service order, and default to the wireless connection to send/receive traffic. Obviously – this is a pretty unique situation, and outside of that network traffic will then start failing. To rectify that, and remove the entry from the routing table you will again need a terminal session, and to type the following:
Sudo route delete 18.104.22.168
Obviously you will need to replace the IP Addresses where appropriate.
If you’ve a better way of dealing with such issues I would really be interested to hear them – let me know using the comments section below.
By default the ‘Library’ folder is a hidden folder in OS X Finder. However, if you need temporary (GUI) access you can use this simple AppleScript below to remove the ‘hidden’ flag from the folder.
tell application "System Events" set libvis to (get visible of folder "~/Library") end tell if libvis = false then --~/Library is currently invisible tell application "System Events" to set visible of folder "~/Library/" to true else --~/Library is visible tell application "System Events" to set visible of folder "~/Library/" to false end if
This script could also be easily amended to show and hide any folder of your choice, simply by replacing the ~/Library/ with the path of the folder you’d like to toggle.
By default the library menu option in the go menu is hidden. Although I’ve never quite understood why it needs hiding, this quick tip will show you how to unhide it with just a quick keyboard click.
- Make sure you have a finder window active and focused
- Click on the Go menu at the top of the screen
- Press and hold the ‘Option/Alt’ key on your Mac’s keyboard
- The library icon should now appear. Upon releasing the keyboard key the icon will disappear again
Last night one of my twitter friends (Ben Casablancas) asked me an interesting question, he wanted to grab his OS X login screen ‘avatar’ for use on twitter. Now, on first appearances the image file seemed to be well hidden away in the deep dark depths of the OS X file system.
However using this little snippet of code in a terminal window made it much easier to find:
dscl . -read /Users/`id -un` JPEGPhoto | tail -1 | xxd -r -p > ~/Desktop/MyAccountPic.jpg
Now if you check your desktop, you should see a JPG labelled MyAccountPic.jpg. That’s right… That’s the picture seen in the login window. But wait… I hear you cry, what about the ‘halo’ ring! Well don’t you worry, we’ve got that covered too!
Back in terminal, paste in this line:
cp /System/Library/PrivateFrameworks/LoginUIKit.framework/Versions/A/Frameworks/LoginUICore.framework/Versions/A/Resources/avatarWhiteRing.png ~/Desktop/MyRing.png
You should now find another image on your desktop – this one labelled MyRing.png. This is the ‘halo’ circle from around your avatar. Now last but not least, you’ll be wanting the mask to go with that:
Back in terminal, paste in this line:
cp /System/Library/PrivateFrameworks/LoginUIKit.framework/Versions/A/Frameworks/LoginUICore.framework/Versions/A/Resources/avatarMask.png ~/Desktop/MyMask.png
You’ve guessed it! You will now also have an image on your desktop labelled MyMask.png.
So although it’s hidden away, using the extremely powerful terminal it can easily be retrieved.
For reference, all the code above does is create copies of the graphics, and is in no way dangerous. If your stuck looking for something in OS X drop me a line and maybe I can help you too.