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 go much lower though. The empty user-agent is required for wget to work.

pcregrep -hoM http://webcache\.googleusercontent\.com/search\\?q\\=cache:\(.+?\)\(?=[+]\(.+\)\"\(.*\)\>Cached\) searc*.html > cachelist.txt
wget --wait 15s --random-wait --user-agent="" -i cachelist.txt

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

edit: updated for new search output & lowered wait to 15s

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