Extract & mirror cache url's from google search pages

Saved search pages go in, cache links come out.
It’s handy for mirroring a dead site by using site:domain.com as the search parameter.

Notes: Without rate limiting I was blocked after request #169. However, there were no issues when using the limits below. The wait time can probably be much lower though. The empty useragent is required for wget to work.

To match the junk part of the filename (search?q=cache:4Ip_t8yQ-rL2:) use this regex: search\?q=cache:…………:

pcregrep -ho http://\\d\(.+?\)\(?=[+]\(.+\)\"\>Cached\\) search.html [search2.html etc.] > cachelist.txt
wget --wait 30s --random-wait --user-agent="" -i cachelist.txt

Set mp3 date tag as YYYY-MM-DD based on mtime

Particularly useful for large, poorly tagged radio archives mirrored with wget.
Processes files in the working directory matching the patters specified.

Requires: mutagen (for tagging)

for FILE in *.mp3;  do mid3v2 --date=$(perl -e '@d=localtime ((stat(shift))[9]); printf "%4d-%02d-%02d", $d[5]+1900,$d[4]+1,$d[3]' $FILE) $FILE; done

Time formatting in Haskell

showTime :: Int -> Int -> String
showTime hours minutes
    | hours == 0    = "12" ++ ":" ++ showMin ++ " am"
    | hours <= 11   = (show hours) ++ ":" ++ showMin ++ " am"
    | hours == 12   = (show hours) ++ ":" ++ showMin ++ " pm"
    | otherwise     = (show (hours - 12)) ++ ":" ++ showMin ++ " pm"
    where
    showMin
        | minutes < 10  = "0" ++ show minutes
        | otherwise     = show minutes
Main> showTime 13 37
"1:37 pm"

From Haskell for C Programmers.

“Command name is 25% fewer characters to type! Save days of free-time! Heck, it’s 50% shorter compared to grep -r.”

Disable the new look in Safari 4

The new tabs in Safari 4 are nice, but I prefer the old classic look. If you’re like me, like I know I am, use these commands in the terminal to disable the new look:

defaults write com.apple.Safari DebugSafari4TabBarIsOnTop -bool NO
defaults write com.apple.Safari DebugSafari4IncludeToolbarRedesign -bool NO
defaults write com.apple.Safari DebugSafari4LoadProgressStyle -bool NO