Search Results 

Results tagged “mac” from Nothing new here

As a heavy-user of Firefox, the biggest annoyance in Safari for me was the missing shortcuts for directly accessing tabs. In Firefox you can access the tabs by pressing Cmd+<number of tab>. For example, if you want to jump to your third tab you would press Cmd + 3 (⌘ + 3), however in Safari this loads the third bookmark from the bookmark toolbar - very annoying if you are used to a different behavior.

Luckily there is a way to change this behavior and make Safari (4, not sure about 3) behave like Firefox with the help of this innocent looking piece of AppleScript:

tell front window of application "Safari" to set current tab to tab 3

Simple, isn't it? Now, all we need to do is to figure out how to combine this script with the shortcuts. Thankfully there's a small and free application called FastScripts Lite (hidden on the bottom of that page), it's limited to ten shortcuts, but all we want are nine (since Cmd + 0 is assigned to a somewhat useful "Actual Size" function), so it's perfect. If you need more shortcuts, you can purchase the full version.

Let's review that AppleScript above to ignore any errors caused by non-existing tabs:

try
	tell front window of application "Safari" to set current tab to tab 3
on error
	tell front window of application "Safari" to set current tab to last tab
end try

Open Script Editor and create nine files from 1-9 in ~/Library/Scripts/Applications/Safari, let's call them Tab1.scpt to Tab9.scpt and paste in each file the script from above, changing the 3 at the end of the long line to the current number. I have prepared a Zip with all nine files (SafariTabs.zip), so you don't need to do this by yourself. Simply extract this file in ~/Library/Scripts/Applications/.

Next, launch FastScripts, click on the icon in the toolbar at the top of the screen and go to FastScripts->Preferences:

1. We want FastScripts to start when we log in.
FastScripts1.jpg

2. Assign Cmd+1 - Cmd+9 (or any other combinations) to the proper Tab-scripts
FastScripts2.jpg

Go back to Safari, and see the magic at work!

As a follow up to my earlier teredo howto, here i want to show you how to use the Tunnelbroker provided by Hurricane Electric on OS X 10.5, Leopard, behind a NAT Router that passes protocol41 (e.g. Fritz!box Fon WLAN 7170).

I did not want to make rocket-science out of this, so i did the easiest and simpliest possible way to achieve my goal, which means that it might not be the 100% correct way to do things. Also, it's not going in to details about IPv6, so if you are new to this topic, the tutorial may be a bit difficult for you.

How all this will work: Once you have finished this tutorial, you will have a Launchd script checking every 30 mins for IP changes, if your IP has changed, it will reset your IPv6 configuration. That means, in worst case, your IPv6 will be down for 30 minutes, but in best case you won't notice the script at all.

Step 1, Register with Hurricane Electric's tunnelbroker.net
Just go to http://tunnelbroker.net and get your free account.

Step 2, Create a new tunnel

Click on Create Regular Tunnel, and enter your current public IPv4 there (see You are viewing from IP: <that's your ip>)

Next, pick the closest location to you. You can also ping each of the IPs shown there and pick the fastest one, since - at least in Germany - the closest geographical location not always is the fastest one.

When you are finished, you will get your tunnel details displayed, which should be similar to the screenshot below. You will need some values from this screen and the account overview screen in the script in the next step.

Tunnel Details.jpgStep 3, The IPv6 Script

This is the IPv6 script, it is documented inside, so follow the steps there and then come back here :-)

#!/bin/bash
#######################################################################
# Update the HE (Hurricane Electric) ipv6-tunnel
#######################################################################
# Interface to use: en1 = Airport, en0 = Ethernet
MYIF="en1"

# leave as is
IPCACHE="/Library/Caches/ipv6scriptIP"

# Your Tunnel settings start here
# 1. get HEUSER hash from the website, "UserID"
# 2. get HEPASS hash: echo -n YourPass|md5
# 3. get HETUNNEL from the website, "Global Tunnel ID"
# 4. get other settings from the website

HEUSER=fb3f06c821388858cafe95cea24895d3
HEPASS=420cc447758fe38e9df69a3a17c77c33
HETUNNEL=123456

HETUNEND=216.66.00.00
HEYOUR6END=2001:0123:123a:1234::2
HETHEIR6END=2001:0123:123a:1234::1
HEPREFIX=64

# This is some IP from the "Routed /64" pool, used for outgoing connections from your Mac.
# Should it get blocked by anyone, you can simply change it to any other IP from the pool
# without having to apply for a new tunnel. e.g. if your Routed /64 pool is
# 2001:0123:123b:1234::/64, you can use this for your IP:

HEMY64IP=2001:0123:123b:1234::0bad:cafe

#######################################################################
# Config end
#######################################################################
# sometimes this script will get executed twice at the same time, not good, so:
if [ -f $IPCACHE.lock ] ; then
echo A copy already running!
exit 0
else
touch $IPCACHE.lock
fi
# This is faster if your router sets a dyndns entry:
#NEW_IP=`dig mycomp.myvnc.com|grep "^mycomp"| grep -Eo "\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>"`
NEW_IP=`curl -s "http://www.networksecuritytoolkit.org/nst/cgi-bin/ip.cgi"`

# Wait for the network...
while [ ! -n "$NEW_IP" ]
do
sleep 10
#NEW_IP=`dig mycomp.myvnc.com|grep "^mycomp"| grep -Eo "\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>"`
NEW_IP=`curl -s "http://www.networksecuritytoolkit.org/nst/cgi-bin/ip.cgi"`
done


OLD_IP=`cat $IPCACHE`
if [ "$NEW_IP" = "$OLD_IP" ] ; then
CURCONF=`ifconfig |grep $HETUNEND`
if [ -n "$CURCONF" ] ; then
echo Nothing to do
rm $IPCACHE.lock
exit 0
fi
fi

echo -n $NEW_IP > $IPCACHE

# if you need to use your public ip address, use LOCAL_IP=$NEW_IP instead
LOCAL_IP=`ifconfig $MYIF |grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}'`

# let's delete a pre-existing gif0, ignore any errors
ifconfig gif0 deletetunnel
ifconfig gif0 down
ifconfig gif0 inet6 delete $HEYOUR6END
ifconfig gif0 inet6 delete $HEMY64IP
route delete -inet6 default -interface gif0

# update the tunnel
curl -k -s "https://ipv4.tunnelbroker.net/ipv4_end.php?ipv4b=$NEW_IP&pass=$HEPASS&user_id=$HEUSER&tunnel_id=$HETUNNEL"
echo " "

sleep 1
ifconfig gif0 tunnel $LOCAL_IP $HETUNEND
ifconfig gif0 inet6 $HEMY64IP/64 alias
ifconfig gif0 inet6 $HEYOUR6END $HETHEIR6END prefixlen /$HEPREFIX
route -n add -inet6 default $HETHEIR6END

rm $IPCACHE.lock
exit 0
[download]

After adapting the values to your needs, you need to save it in the right place:
sudo vi /usr/local/bin/ipv6script
Paste your script, and save it with :wq

Make it executable by typing
sudo chmod +x /usr/local/bin/ipv6script

Step 4, Launchd

Now we need to create a LaunchDaemon in Launchd, to do so:
sudo vi /Library/LaunchDaemons/net.pugio.myipv6script.plist
Paste:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.pugio.myipv6script</string>
<key>ProgramArguments</key>
<array>
<string>/Users/pk/Applications/ipv6script</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>1800</integer>
<key>WatchPaths</key>
<array>
<string>/Library/Preferences/SystemConfiguration/com.apple.network.identification.plist</string>
</array>
</dict>
</plist>
[download]

This will tell Launchd to execute the script on Login, all network changes and every 30 minutes, in case your router gets a new IP. If you are on static IPs, you can remove that timer, just delete these two lines from the file:
<key>StartInterval</key>
<integer>1800</integer>


Finally you have to activate your Lauchd Agent by executing following:
sudo launchctl load /Library/LaunchDaemons/net.pugio.myipv6script.plist

You should now be able to ping6 pugio.net - congratulations.

Bug hunting

Should something go wrong, execute the script by hand:
sudo /usr/local/bin/ipv6script

This should hopefully show you the error.

If you find this howto useful, or have anything to contribute to it, please leave a comment or link to this tutorial, thank you :-)

Jumpcut clipboard history mac os xThe most used application on my Mac must be Jumpcut. It's a no frills clipboard extension which saves your last x clipboards, where x is a user defined value (mine's at 40). There are two interfaces to your clipboard history, one in the menu bar through a drop down menu and one pop-up activated through a hot-key.

By setting the hotkey to Command + Option + v, you can cycle through your history by holding Command + Option and pressing v repeatedly until you find what you are looking for. You can also use the arrow keys and numbers at this point.

Best of all: it's open source and free.

SafeSleep is dangerous

If you are an happy macbook or macbook pro user, read on - this may save your hard drive!

head crashRemember your old iBook or Powerbook? You closed the lid, tossed the laptop into your bag and off you went to somewhere else. Do you still have this habit with your shiny new Apple hardware? WRONG! You can't do that! It will seriously bork up your hard drive, as for example discussed in this thread.

Here's the reason: On newer hardware, Apple enabled that fancy SafeSleep option per default. It will not immediately put your mac to sleep, but will first make a back up of your ram onto the hard drive, to protect your session in case your battery runs flat during sleep. It's a good thing to have, however the write process may take up to several minutes if you have a lot of ram (i have four gigs and it takes quite a while). Apple's manual mentions this:

"NOTICE: Wait a few seconds until the sleep indicator light starts pulsing (indicating that the computer is in sleep and the hard disk has stopped spinning) before moving your MacBook Pro. Moving your computer while the disk is spinning can damage the hard disk, causing loss of data or the inability to start up from the hard disk."

Good that nobody of us reads manuals. And really, who will stare at their lights to figure out if it's flashing, one is having hallucinations, or if it's lighted up continuously?

All experts agree, moving your Laptop during excessive write progress is not an good idea, and tossing your laptop into your bag during that time will seriously cause you several days of ache.

Luckily there's an easy way to fix this, without having to give up SafeSleep: SmartSleep

"SmartSleep let's you select each select sleep state. Additionaly the new SmartSleep state lets your notebook just sleep while the battery has a high level. If the battery level drops below a certain point ( default is less then 20% or 20 minutes ) it will switch to sleep and hibernate. So you have the best of both worlds."

That means you can close the lid, toss your laptop into the bag, and go home again, just like in the good old times. Should you forget your laptop somewhere over the weekend, your logged-in session is still save.
* Photo: "Hard Disc Crash" by barnoid

iPhone SDK out in June, who cares

What most news outlets in Europe seem to completely ignore is the fact that the iPhone SDK will be USA only for now. There's no way for international publishers to obtain signing certificates or get their software onto the iTunes shop.

Apple Developer Connection - iPhone Dev Center - iPhone Developer Program.jpg
It's typical for Apple's US-centric world view. I wonder how long it will take them to get the iTunes software shop working for international customers this time and at which rate; Apples dollar exchange rates are still from the golden years of the american economy.

P.S.: First screenshots of the iPhone SDK are up

Lock this mac

Lockmymac.jpg There was always one feature from Gnome that i missed in Mac OS X, the ability to quickly lock your Mac with a shortcut and go for lunch. Sure, there's that option to lock your mac every time your screensaver goes on, but the problem with that is that I do not want to enter my password every time. At home for example, there is no need to lock my Macbook. Besides this function has a lot of issues when waking up from sleep; Sometimes I would have to wait for a minute until i get a login box. After a long hunt on macosxhints.com, I found a command to show the fast user switching login box without actually having to enable fast user switching:

/System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend

There are several convenient ways to execute it:

  • Create an Automator action which executes a shell script (slow to execute)
  • Create an AppleScript Application and put it in your Dock:
    do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend"
  • Run the shell script/ AppleScript from Quicksilver
  • Run the AppleScript in Launchbar:
    Put the AppleScript (.scpt) from above in ~/Library/Scripts and enable Home Library scripts in the Launchbar Configuration (I found this to be the fastest option)
Finally, if you have no idea what I am talking about, but you need this functionality, check out Lock My Mac.

Backing up your home folder with rsync

I have been looking for a way to mirror my home folder on my Macbook with a linux server (nslu2 with Unslung Linux in this case), this article describes how to do that with tools already available in Leopard.

nslu2.jpg
"Home Server v2" by Montini

I assume you have a valid SSH login on the server, I simply enabled my account on the NSLU2 and assigned the proper home and shell values to it. I also assume both computers have an working installation of rsync (run rsync --version to check)

For automatic, password-less logins, first we need to generate keys for SSH, if you have them already, skip this section. Run this command on your local computer:
$ ssh-keygen -d

Now copy your public key into ~/.ssh/authorized_keys2 on the server. If this file already exists on the server, you will have to edit it, if it does not (e.g. your account is fresh) first create the ~/.ssh directory on your server (mkdir ~/.ssh), then execute this command on your local computer:
$ scp ~/.ssh/id_dsa.pub yourname@yourserver:.ssh/authorized_keys2

Before we can start mirroring your home folder, we have to create a list of files we don't want to synchronize, this are the contents of my ~/.rsync/exclude file:

- .DS_Store
- Virtual Machines.localized
- Library/Mail Downloads
- Library/Caches
- Downloads/
- Applications/
- Books
- anthill_cache
- .Trash
- .localized

That's it, now all you need to do is to adapt this command to your environment,  run it and wait...
$ rsync -avzP --exclude-from=/Users/me/.rsync/exclude -4 --delete -e 'ssh -ax' ~/ you@yourserver:~/Backups/mymacbook/

you can also create a shell script so you don't need to remember the command everytime:
$ echo "rsync -avzP --exclude-from=/Users/me/.rsync/exclude -4 --delete -e 'ssh -ax' ~/ you@yourserver:~/Backups/mymacbook/" > ~/remotebackup; chmod +x ~/remotebackup
You can start the backup by executing ~/remotebackup


iPhones in China

400k Mobiles are on the China Mobile network and by the frequency one can spot these things in the wild (metro, bus, elevators, ...) that number may be very true. Yet Apple continues bricking the phones with every upgrade. Get a clue. One thing left to say is that 400k is a huge number for a quasi worthless brick for it's users, the iPhone has no Chinese input and needs to be "jail-broken" first so you can install 3rd party hacks to get chinese input working. That's a first: millions of customers want to get rid of their US$550-600 and that company does not want their money.

Also Interesting: Smugglers Return iPhones to China

...well not much to write. Basically i'm very busy with several projects right now, coz you know, all of them need to be finished ASAP, after nothing had happened for months. PHP, Java and Project Management all at once. Besides that i have some project running in my spare time, so not much time left for bullshitting on this blog.

But in case you did not notice... who cares, really... I am back to Apple Laptops, because the Wintel world still hasn't managed to make laptops function properly with linux. Or, you could say the Linuxguy* has no clue about laptops, but that may be considered as flamebait in the Linuxworld. Story in short: Fedora upgrade borked my setup, no hibernate, no suspend to ram. Installed Ubuntu, got everything running, upgraded and was left on the console with a borked hibernate and suspend to ram. Thanks ATI, thanks Linuxguy, but I have no time for this. Macintosh, it also crashes, but it does what i want it to do.

*Linuxguy as in whomever packaged my .deb/.rpm based distro.