Get Growl Notifications on VNC connections, SSH attempts, and HTTP logs [solved]

Use this script to monitor VNC connections with Vine Server:
nice -n 100 tail -n 0 -f /Users/jordan/Library/Logs/VineServer.log | php -r 'while ($m = fgets(STDIN)) shell_exec("growlnotify -p 0 Vine Server -m ". escapeshellarg($m));'

Change “jordan” to your username (home directory), or the whole path of the log if you’re monitoring something else. “Vine Server” is the alert title, which could be anything (“Hello World”).

Save this as a file such as vncnotify.sh. Run
chmod 755 vncnotify.sh
and then you can run the command by typing ./vinenotify.sh.

Duplicate this file and name it vinenotify.command.
Finally, in System Preferences > Accounts > Start up items, add vinenotify.command, and make it hidden, and it will run when you log in.

Things I’m still working on: preventing a string of notifications when you launch VNC; hiding the terminal window when you log in; and grepping for only connect/disconnect/login failures.
Thanks to drewish.com for the growl tail code.

Check for open logs running on OS X, unix or linux [solved]

Use this command to find the log you’re looking for:
lsof | grep -i log

On OS X, typical directories I look in are /var/log/, $HOME/Library/Logs/, and /private/var/log/.

Make Google Maps actually geo locate you in Firefox 3.5 [soved]

One of the most exciting features about Firefox 3.5 is its geo-location capabilities. But when I installed 3.5 and went to google maps, it didn’t automatically geo-locate me nor was there any option to.
This blog has a bookmarklet you can place on your toolbar to click to geo-locate you in google maps. Create a new toolbar bookmark, edit it, rename it “locate me” and paste in this code for the address:

javascript:function sv(s){document.querySelector("#q_d").value=s};sv("Checking...");navigator.geolocation.getCurrentPosition(function(a){c=a.coords;sv(c.latitude+"%20"+c.longitude);document.forms.q_form.submit();},function(){sv("Rejected!")});

Then when you go to google maps and click “locate me”, you can search for businesses near you wherever you are.

Thanks, John Ath!

Dual boot Windows 7 and Ubuntu, fix Windows MBR issue [solved]

I went through a heck of a time getting Windows 7 and Ubuntu (actually eeebuntu) to dual boot on my new Asus Eee PC. Either would work fine alone but liked to overwrite the other’s boot loader.

I’ve read that it’s easier to install Windows first and Ubuntu later, but even though I installed Ubuntu later, Windows failed to boot after I installed it.

My first lesson through all of this: Don’t customize, save any documents, or install any software until both OS’s are installed and dual booting. I went through two windows installs and 3 ubuntu installs to get it all to work.

You can use either Windows or Ubuntu’s installer to partition the drive. I formatted 40 GB in NTFS for Windows 7, 10 GB as ext3 for Eeebuntu, 2 GB for Eeebuntu swap, and 5 GB in Fat32 for a shared partition between the two drives.

Even though I was careful not to format, resize or overwrite the windows drive, Windows 7 booted into a startup repair, and failed with the message “startup repair cannot repair this computer automatically”. My additional info was StartuprepairOffline and CorruptRegistry. I ended up having to reinstall Windows.

In hindsight, I would have installed Ubuntu first and then Windows. Windows is more picky when its boot record is overwritten, and ubuntu’s is easier to fix.

I tried a couple of solutions first – this article, “How to fix your windows MBR with an ubuntu live CD”, has been mirrored everywhere, and no longer works. ms-sys is no longer included with Ubuntu, is not available in the Ubuntu software repositories, and when I tried downloading and compiling from source I got missing libraries errors.

My efforts to use Super Grub Disk also failed. Supposedly Super Grub Disk makes it easy to edit your master boot records and boot menu, but it only runs from windows. After I reinstalled windows, and installed Auto Super Grub Disk, when I tried booting and chose it as an option, I simply got to a DOS-based menu screen saying Windows cannot start normally. I’m also finding it hard to uninstall super grub disk.

What finally worked was installing Ubuntu, installing Windows, booting from an Ubuntu live disk, reinstalling grub, booting into Ubuntu, and editing the Grub menu to make Windows 7 active (“makeactive”) again. No special software required, just some command line editing. This tutorial from the Ubuntu site walked me through it.

Finally, the steps:

1. Install Ubuntu (partition the drives first)
2. Install Windows into one of the partitions (format it as NTFS)
3. Boot into the Ubuntu live CD. In terminal (Accessories > Terminal) run these commands:

sudo grub
find /boot/grub/stage1
root (hd0,0) [or whatever the find command listed]
setup (hd0)
quit

4. Reboot back into Ubuntu (not the live CD)
5. Open terminal again, and edit your boot menu:

sudo gedit /boot/grub/menu.lst

Add an entry for Windows 7 above this line:

### BEGIN AUTOMAGIC KERNELS LIST

Here is my entry:

title Windows 7
rootnoverify (hd0,0)
makeactive
chainloader +1

Your (hd0,0) may be different.

Towards the top of the file, I also changed my timeout from 10 to 5, so that it only takes 5 seconds to choose a custom default OS to boot.

I also deleted the other entry at the end of the file, below the lines:

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.

because that entry didn’t work anyway. It’s similar to the Windows entry we added but uses savedefault instead of makeactive; I believe makeactive is what Windows needed to make it work correctly.

That’s it! Now you should be able to boot into both OSes.

Edit: I got super grub disk to stop showing in my boot menu in Windows by running this in a command prompt:

bcdedit /enum

That lists the identifiers in your menu. Then:

bcdedit /delete {super grub disk's super long identifier string with curly braces}

That got Windows to boot normally again.

Make Firefox’s URL Autofill Behave [solved]

I like to go to websites as quickly as possible. Firefox usually gets me to the site I want to go after I type two letters – ‘di’ autocompletes to digg.com, ‘li’ takes me to lifehacker.com, etc. But there were some sites that it would not autocomplete, no matter how many times I would arrow down and to go that site. If I typed ‘ny’, it would never take me to nytimes.com, and if I hit enter it would accidentally take me to a google search for NY. Likewise, if I typed ‘fa’, it would not take me to facebook.com.

For a while I was using this lifehacker tip to force autocompletion, but that wasn’t working well either – often it would try to force me to a sub-page of the site I wanted to go to. So when that was turned off in a firefox upgrade, I didn’t re-enable it.

Finally, I found a solution that worked. Facebook and nytimes.com tend to redirect to www.facebook.com/home.php and www.nytimes.com. It also turns out that I had bookmarked these two sites, with the www in the URLs because of the redirects. The first step was to delete these bookmarks – they were overriding my history.

Then, the next time I typed in ny, I hit down until I found www.nytimes.com. Then I hit shift-delete to delete this URL from my autocomplete.

Finally, I had to type ny again and arrow down to nytimes.com. I hit enter, and now whenever I type ‘ny’ and hit enter I go to http://nytimes.com. Finally! I did the same for facebook and my other sites.

Move Some Common OS X Apps Out of the Dock [solved]

There are some really nifty apps out there that I have set to run all the time, and they’ve been starting to crowd up my dock.

Jungledisk is better than Mozy and is my preferred online backup utility. It’s secure, it uses Amazon S3, it supports versioning, and allows online access. Anyway I noticed their latest version of the app allows you to show the app in the status bar instead of the dock. Update Jungle Disk and then go to Configure > Application Settings > Show application in: Status Bar.

QuickSilver is another great keyboard launcher app I use all the time. It also supports hiding the app from the dock. Go to Preferences > Application and uncheck Show icon in dock. It automatically shows in the status bar when you do this.

Growl is one of my favorite apps, as is HardwareGrowler. However HardwareGrowler has no user interface but still hangs out in the dock. You can fix this by following the instructions on this page. It took me a couple tries (I put the <key>LSUIElement</key><true/> in the wrong place the first time and had to start over…Also you touch the whole HardwareGrowler.app package in the finder), but now it’s hidden from the dock.

Now if only I could get VineServer working with Growl. VineServer does allow you to install a system server, but unlike the app, it does not notify when someone connects, which I prefer to know about. So for now, VineServer sits in my dock as a hidden application.

Back up iPhone SMS messages into an excel database without jailbreaking [solved]

So here’s a somewhat complicated but entirely graphical way of backing up your SMS messages from your iPhone into an excel spreadsheet. I couldn’t get Syphone to work so here is my solution.

The first thing you’ll need is iPhone Backup Extractor. It’s a mac program, but there are other cross platform backup decoders out there such as mobilesync-inspect. You’re looking for the SQLite SMS database (iPhone Backup Extractor calls it SMS.db). iPhone Backup Extractor is not compatible with iPhone OS 3.0 yet but it does work with 2.2.1. Hopefully 3.0 will work soon.

Run iPhone Backup Extractor and select your most recent backup. Scroll down to the bottom of the applications and choose iPhone OS. Choose a folder to save it in.

iPhone Extractor

Then, use an SQLite browser such as SQLite Manager (don’t know why this is a firefox addon, but it rocks) to view the database.

export

All of the SMSes are stored in the messages table – you can right click on it and export it as a CSV. Alternatively you could export the whole database as an SQL or XML file. But open up the CSV in excel and you’re done! Sweet!

SMSes in excel

Sync notes with iPhone 3.0 beta

I’m trying the new iPhone 3.0 OS because I’m a registered developer. So far it’s sweet! My only issues so far are that wifi had trouble connecting at first, and my notes apparently didn’t sync.
Turns out my notes were in mail. They didn’t show up in my left hand navigation bar at first, but I tried doing “new note” and just writing “test”, and then the rest of them all showed up from my iPhone. (no clue where windows would put them.)
Hurray!

Sync Firefox bookmarks to the iPhone with Foxmarks

I’ve tried a few browser bookmark syncing services in the past, but I’m really impressed with Foxmarks, for their Firefox, Safari, and IE support.
As a bonus, once I set up foxmarks for Safari, and then synced my iPhone, my firefox bookmarks transferred to my iPhone.
Lifehacker recommends an app, O-Marks, for using foxmarks to sync your bookmarks over the air:
http://lifehacker.com/5051271/o+marks-syncs-your-foxmarks-bookmarks-to-your-iphone
But I find just opening up Safari every once in a while and syncing the iPhone works well enough for me.

Choose a random winner or randomize a list with terminal and PHP [solved]

I wrote this for my class, which needed to have a randomized order of presentations:

php -r '$order = array("person1","person2","person3","person4","person5","person6","person7","person8","person9","person10");shuffle($order);foreach($order as $number=>$name){echo $number+1 . " $name\n";}'

To run it, open up terminal (in OS X) and paste it in.

I’ve also had to choose a random winner for gift certificates before:
php -r '$order = array("person1","person2","person3","person4","person5","person6","person7","person8","person9","person10");shuffle($order);echo "$order[0]\n";'

Next »