Marius van Witzenburg "Learned my lesson in life, now setting my action to stay in life."

23Jul/100

iMac / Macbook (Pro), Self Assigned IP Address problem with Wifi / Airport connections

I was having an issue with my Macbook Pro lately that the DHCP client couldn't get an IP from the DHCP server. This happened on different networks and it didn't happened every time. The message in the network settings was: "Self Assigned IP Address". After a while I really wanted to have a solution for this so I started spitting in the logs first...

I ended with no result at all, but suddenly I remembered that other programs might behave weird when their preference files are corrupted or if there are mistakes in them.

Then I found the following file:

/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist

I first turned off my airport before doing any action to this file.

I opened the file to sniff around and there it was, a missing close tag in the XML. I first fixed this, without no result as expected. Then I moved the file to my desktop, compressed it, trashed the original file and cleared my trash. Then I turned back on the Airport and clicked my network... It connected, since then my wireless problems are solved :-)

13Jul/100

Update Mac OS X Finder Workflows to Service, rename files to lowercase

As some of you might have noticed, the folder actions submenu where you could add your own workflows isn't there anymore in Mac OS X 10.6 (Snow Leopard).
Apple decided to move this to the service menu instead, which is in my opinion a good step since you can now add a service action to almost every program on your Mac.

On my Mac I had a workflow to easily rename all selected files form a UpPeRcaseD name to a lowercase name.
The first thing I noticed when I needed this workflow that it wasn't there... So I looked around a bit and when opening the workflow in Automator it gave an error that it was an old workflow that needs to be updated to a new version.

Since the workflow is quite simple I decided to make a new one. While doing this I found the service option.
Fist I thought I didn't need that but after about 2 minutes I noticed that it was the new way of adding your workflows to Finder or other applications.

Well, lets get started... Fire up Automator!

Create a new service
Screen shot 2010 06 22 at 10.03.16 512x476 Update Mac OS X Finder Workflows to Service, rename files to lowercase

Search for Finder and drag "Get Selected Finder Items" to the right
Screen shot 2010 06 22 at 10.03.45 512x426 Update Mac OS X Finder Workflows to Service, rename files to lowercase

You might get this warning, simply click Don't Add
Screen shot 2010 06 22 at 10.04.31 Update Mac OS X Finder Workflows to Service, rename files to lowercase

Search for "Rename" and drag "Rename Finder items" to the right
Screen shot 2010 06 22 at 10.04.56 512x426 Update Mac OS X Finder Workflows to Service, rename files to lowercase

In the above image you can also see the right settings. Change case of the Full name to lowercase.

Save the service
Screen shot 2010 06 22 at 10.05.18 Update Mac OS X Finder Workflows to Service, rename files to lowercase

You will end up with this screen, quit Automator
Screen shot 2010 06 22 at 10.06.47 512x426 Update Mac OS X Finder Workflows to Service, rename files to lowercase

Now your ready to test your service.
Goto a folder where you want to lowercase your files and select the items you want to rename to lowercase. Goto the "Finder" menu and click your newly created service.

Good luck :-)

27Jun/100

iPhone 4 finally there. Things I like of how it gets promoted.

If you watch the new iPhone 4 promotion clip on apple.com you see a lot of things that weren't in the promotion clips this advanced.

We all know the Unibody of Apple was in the promotion of the new Macbook Pro computers.

What I like about this new way of showing things is that they show the factory where the iPhones get produced.
I must say that the people who do this job earn some credit too for their work. Showing their work gives away some credit in my point of view.

Over all I find it a great piece of gadget to get soon to work with and review. Now only I need to figure out a way to get one soon ;-)

24May/106

Add week numbers to iCal on Mac OS X

To make Mac OS X show week numbers in iCal is actually not that difficult.
You simply need to add the week number to the full date notation and your done.

Goto the System preferences
0 Add week numbers to iCal on Mac OS X
Path:  » System Preferences...

Goto Language & Text
1 511x489 Add week numbers to iCal on Mac OS X
Path:  » System Preferences... » Language & Text

Goto the tab Formats and then click Customize...
2 511x451 Add week numbers to iCal on Mac OS X
Path:  » System Preferences... » Language & Text » Formats

You will see a window where you can modify your notation format for date and time.
Now you have to put the week number of the year in the right place. Follow the red arrows :-)

Drag the week number to the full date field
31 Add week numbers to iCal on Mac OS X
Path:  » System Preferences... » Language & Text » Formats » Customize...

Finally close all windows and check the clock on the top right.
4 Add week numbers to iCal on Mac OS X

Now start your iCal and check the date bar at the top.
5 Add week numbers to iCal on Mac OS X

As you see, its really simple to get this done :-)

NOTE: Offset in the week number
Be sure you have the right country selected for your formats. Else you might end up with a week number with an offset. In my case the week number would be one week ahead. This cause my main country is The Netherlands and I have my system on United Kingdom. The thing you have to do is first select Dutch -> Nederlands and then change the week number. It might show weird having Dutch day names in iCal but hey... Apple made it work like this out of the box ;-)

13Apr/100

iPhone OS 4 multitasking great, but closing needs some work.

The multitasking system of the new iPhone OS 4 works quite well.

photo1 iPhone OS 4 multitasking great, but closing needs some work.

When you press the Home button twice it popups at the bottom of your screen and you can scroll between the running applications and switch to it by tapping on it.

In case you want to close an application, simply hold your finger on the icon until you see the 'remove' button, then tap the remove button and the application will be stopped.
photo 1 iPhone OS 4 multitasking great, but closing needs some work.

One thing I would like to see in this tiny popup is the ability to close multiple applications in a row. Maybe not at the same time but at least it would be nice to not have to hold your finger on the icon over and over.
My idea would be adding a circle with a plus sign in it just as you have on the Dashboard on Mac OS X and when you tap that, it holds the closing feature to be able to close multiple programs a bit faster.

Here some images I made with Photoshop to just show how it could look.

Inactive close view:photo 2 iPhone OS 4 multitasking great, but closing needs some work.

Active multi close view:photo 31 iPhone OS 4 multitasking great, but closing needs some work.

Update
Apple changed the way how you close the applications, instead of being able to close one application at the time the close feature remains open with multiple close icons until you press the home button.

11Apr/100

Having fun on April 1st with SSH and Mac OS X

Contributed by: momerath

Inspired by the latest MacAddict's April Fools' pranks, here are some very handy commands to remotely control a computer of which you are an administrator. These are most useful in a family environment where you own and administer the others' computers. They also work well over AirPort.

First, you need to ssh to the computer using your admin account. Then, you can type in any or all of the following commands.

[robg adds: Read the rest of the article for the pranks. Please note that some of these are quite nasty! Using your power as Admin to remotely reboot someone's machine, for example, is a simply horrendous thing to do. With that said, however, some of the following would be quite fun to do to someone with a good sense of humor...]

Note: Commands that are shown on two lines have the second line indented by two spaces. Enter the command on one line, removing all but one space between the end of the first displayed line and the start of the second...

Absolutely nasty:

sudo kill [program id learned from top] 
sudo halt
sudo reboot
sudo osascript -e 'tell app "[name of an open program]" to quit'

Note: using 'sudo open' over ssh does not give the user super-user privileges for the opened application.

Power:

sudo osascript -e 'tell app "Finder" to sleep'
sudo osascript -e 'tell app "Finder" to shut down'

General:

sudo open /Applications/iChat.app
sudo osascript -e "set volume 0"
sudo osascript -e "beep"
sudo osascript -e 'display dialog "Did you know that you are annoying?" buttons "Yes" with icon note'
sudo osascript -e 'tell app "Finder" to quit'
sudo open [path to an application]

Speech:

sudo osascript -e 'say "[whatever]" using "Zarvox"'
sudo osascript -e 'say "Dum dum dum dum dum dum dum he he he ho ho ho fa lah lah lah lah lah lah fa lah full hoo hoo hoo" using "Cellos"'

iTunes Control:

sudo open /Applications/iTunes.app; sudo osascript -e 'say "Play some music. Go on.  I dare you." using "Zarvox"'
sudo osascript -e 'tell app "iTunes" to stop' -e 'say "Please stop playing your annoying music" using "Zarvox"'
sudo osascript -e 'tell app "iTunes" to next track' -e 'say "I did not like that song very much" using "Zarvox"'
sudo osascript -e 'tell app "iTunes" to fast forward' -e 'say "This song is boring" using "Zarvox"'
sudo osascript -e 'tell app "iTunes" to quit'

Have fun, but not too much fun!

~ source ~

3Apr/100

Easy rating in iTunes with ‘I Love Stars’ in your extra menu

You ever wanted to have your iTunes song rating to be a bit more accessable ?

Well, use this plugin! You get a nice tool at your extramenu where you can easy rank your songs how you like without having to click 3 times to get the job done :-)

You can download it at:

See a preview here:
ilovestars 20080516102551 Easy rating in iTunes with I Love Stars in your extra menu

24Mar/100

Test-driven development (TDD)

When I was googling for development flows I found the following page which almost describes completely how I work in my development projects.

A flowchart of how this goes:

Test driven development 512x367 Test driven development (TDD)

For more info see: http://en.wikipedia.org/wiki/Test-driven_development

13Mar/100

Rewrote Western Digital Sharespace to Sharespace synchronisation

For a script running from a FreeBSD server check this script.
~~~
I earlier wrote a script to sync two Western Digital ShareSpace drives. Since that was written in a hurry I thought lets have another good look at it...

I changed the checks for USB drives and sync the complete the shares directory instead of only the shares.

The following script is a new rewritten version of the old script which works faster for my use.

You may modify it to suit your situation but please leave the credits in the file :-)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/sh
# WD ShareSpace sync script v1.1
# By Marius van Witzenburg <info@mariusvw.com>
# http://mariusvw.com
#
# Works with busybox 1.1.1 and newer versions.
#
 
# Settings
src_ip="172.20.20.22"
mailto="marius@persc.nl"
mailfrom="noreply@persc.nl"
daemon="yes"
force="no"
waittime=5
maxlogs=48
 
#
# DO NOT CHANGE BELOW!
#
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin
PID=$$
 
pwd=`pwd`
root=`dirname $0`
logdir=${root}/logs
logfile=`basename $0`
cd ${root}
 
cleanup() {
    #rm -f ${log}
    return $?
}
s_hup() {
    logger -s -p daemon.notice -t ${logfile} "*** SIGHUP! Exiting... ***"
    cleanup
    #exit $?
}
s_int() {
    logger -s -p daemon.notice -t ${logfile} "*** SIGINT! Exiting... ***"
    echo -e "From: ${mailfrom}\nTo: ${mailto}\nSubject: ShareSpace backup.\n\nSIGINT! Exiting..." | /usr/sbin/msmtp ${mailto}
    kill ${JOB}
    exit $?
}
s_term() {
    logger -s -p daemon.notice -t ${logfile} "*** SIGTERM! Exiting... ***"
    echo -e "From: ${mailfrom}\nTo: ${mailto}\nSubject: ShareSpace backup.\n\nSIGTERM! Exiting..." | /usr/sbin/msmtp ${mailto}
    kill ${JOB}
    exit $?
}
 
trap s_hup SIGHUP
trap s_int SIGINT
trap s_term SIGTERM
 
if [ "${daemon}" = "yes" ]
then
    logger -s -p daemon.notice -t ${logfile} "Having a rest for the first run..."
    sleep 30 &
    JOB=$!
    wait ${JOB}
fi
 
# Loop and loop and loop...
while [ "true" ]
do
    # Check if ssh host is up and running.
    alive=`ssh -ax -c blowfish -q -q -o "BatchMode=yes" -o "ConnectTimeout 5" root@${src_ip} "echo 2>&1" && return 0 || echo 1`
    if [ "${alive}" -eq 0 ]
    then
        # Change the \1 to 1-3 depending on which load you want
        #loadavg=`ssh -ax -c blowfish root@${src_ip} uptime | sed -e "s/.*load average: \(.*\...\), \(.*\...\), \(.*\...\)/\1/" -e "s/ //g"`
        loadavg=`ssh -ax -c blowfish root@${src_ip} uptime | sed 's/.*average: \([0-9]\).*/\1/g'`
 
        if [ "${loadavg}" -eq 0 ] || [ "${force}" = "yes" ]
        then
            # Be sure we have a log dir
            test -d ${logdir} || mkdir ${logdir}
 
            # Shift logs
            test -f ${logdir}/${logfile}.${maxlogs} && rm -f ${logdir}/${logfile}.${maxlogs}
            lcur=${maxlogs}
            while [ ${lcur} -gt 1 ]
            do
                lpre=${lcur}
                lcur=`expr ${lcur} - 1`
                test -f ${logdir}/${logfile}.${lcur}.gz && mv ${logdir}/${logfile}.${lcur}.gz ${logdir}/${logfile}.${lpre}.gz
            done
            test -f ${logdir}/${logfile} && mv ${logdir}/${logfile} ${logdir}/${logfile}.1
            test -f ${logdir}/${logfile}.1 && gzip ${logdir}/${logfile}.1
 
            logger -s -p daemon.notice -t ${logfile} "Starting backup from '${src_ip}'"
 
            # Sync internal shares and exclude usb shares
            logger -s -p daemon.notice -t ${logfile} "Syncing internal shares..."
            rsync -e 'ssh -ax -c blowfish -l root' -aWvz --timeout=30 --exclude="/usb[1-3]-1share1" --delete --stats ${src_ip}:/shares/ /shares/ > ${logdir}/${logfile} 2>&1 &
            JOB=$!
            wait ${JOB}
 
            # Sync usb shares if connected
            for x in `ssh -ax -c blowfish root@${src_ip} ls -l /shares/| grep "^d" | awk '{ print $9 }'`
            do
                if [ ! -z "`expr ${x} : '\(usb[0-9]-[0-9]share[0-9]\)'`" ]
                then
                    if [ -d "/shares/${x}/" ]
                        then
                        logger -s -p daemon.notice -t ${logfile} "Syncing ${x}..."
                        rsync -e 'ssh -ax -c blowfish -l root' -aWvz --timeout=30 --delete --stats ${src_ip}:/shares/${x}/ /shares/${x}/ >> ${logdir}/${logfile} 2>&1 &
                        JOB=$!
                        wait ${JOB}
                    fi
                fi
            done
 
            tail -2 ${logdir}/${logfile} | logger -s -p daemon.info -t ${logfile}
        else
            logger -s -p daemon.notice -t ${logfile} "Load average on '${src_ip}' is ${loadavg} - aborting"
        fi
    else
        logger -s -p daemon.notice -t ${logfile} "No access to '${src_ip}' - aborting"
    fi
 
    if [ "${daemon}" != "yes" ]
    then
        logger -s -p daemon.notice -t ${logfile} "Backup finished"
        break
    fi
 
    logger -s -p daemon.notice -t ${logfile} "Waiting for cycle (${waittime} minutes)..."
    sleep `expr ${waittime} \* 60` &
    JOB=$!
    wait ${JOB}
    logger -s -p daemon.notice -t ${logfile} "Running cycle..."
done
 
# Go back to old location
cd ${pwd}
 
# EOF
13Mar/100

Snow Leopard and Samba

I was searching for a way to get rid of my Finder problems...
I stumbled upon this blog post, this solved Finder crashes and hookups for me.

Thanks for this info!
~~~
I did a fresh install of Snow Leopard on my Macbook and soon realized my Samba shares were broken through finder - but still worked from the CLI.

Worse still once I tried to access the shares Finder would basically be dead, you'd need to Force Quit it to make it work again.

Eventually I reached for tcpdump and wireshark and found it's the pesky .DS_Store files again, seems my QNAP is denying access to them, Finder did not cope well with this.

A quick bit of hackery of my smb.conf solved it:

veto files = /.AppleDB/.AppleDouble/.AppleDesktop/.DS_Store/:2eDS_Store/Network Trash Folder/Temporary Items/TheVolumeSettingsFolder/.@__thumb/.@__desc/
delete veto files = yes

Once I got this removed and samba restarted my shares were working again in Snow Leopard. A bit annoying but not too hard in the end.

Page 1 of 3123