You could make a t-shirt design out of this, if you felt so inclined. I like the fact that it’s valid — if useless — Awk code.
Tag: awk
Awk day of the week function
Yet another in my series of awk functions no-one but me will ever use:
function dow(year, month, day) { # Modified from C Snippets "calsupp.c" public domain by Ray McVay # http://www8.cs.umu.se/~isak/snippets/calsupp.c # returns 0-6 where 0 == sunday # tested over 24000 days in range of unix timestamp, 1970-2035 day_of_week = 0; if (month <= 2) { month += 12; year--; } day_of_week = (day + month * 2 + int(((month + 1) * 6) / 10) + year + int(year / 4) - int(year / 100) + int(year / 400) + 2); day_of_week = day_of_week % 7; return ((day_of_week ? day_of_week : 7) - 1); }
Basically, all this does is calculate a Julian day number, then take its remainder modulo 7. I’d seen an example that parsed the output of ‘cal’. That’s one way of doing it; not necessarily mine.
ffms2m3u.sh – create playlist for all files on a Firefly Media Server
ffms2m3u – create playlist for all files on a Firefly Media Server.
If you run Firefly Media Server, you can run this script to create an M3U of all the tracks on your server. You can play this in most audio players; VLC likes it, as does iTunes (though big playlists take an age to load). Rhythmbox and the default Ubuntu Movie Player won’t touch my playlist of over 17,000 tracks.
To configure the script you need to edit three lines:
# where the Firefly database lives
DATABASE="/usr/var/cache/mt-daapd/songs3.db"
# server domain name or IP address
SERVER="server.example.com"
# Port to talk to server - don't leave blank
PORT="3689"
If you’re running Ubuntu, you’ll probably only need to change the SERVER line. It spits the M3U playlist, ordered by album, to stdout. Note that in the default Ubuntu install, regular users can’t read the database file.
If you’re running this from a cron job, it’s probably a good idea to fill in the real paths for sqlite3 and awk.
Lady Goosepelt Rides Again!
In case anyone wants them, the 600 dpi page images of What a Life! are stored in this PDF: what_a_life.pdf (16MB). If you merely wish to browse, all the images from the book are here.
I got a bit carried away with doing this. Instead of just smacking together all the 360 dpi TIFFs I scanned seven years ago, I had to scan a new set at a higher resolution, then crop them, then fix the page numbers, add chapter marks, and make the table of contents a set of live links.
I’ve got out of the way of thinking in PostScript, so I spent some time looking for tools that would do things graphically. Bah! These things’d cost a fortune, so armed only with netpbm, libtiff, ghostscript, the pdfmark reference, Aquamacs, awk to add content based on the DSC, and gimp to work out the link zones on the contents page, I made it all go. Even I’m impressed.
One thing that didn’t impress me, though:
I used to edit multi-gigabyte files with emacs on Suns. They never used to complain like this. They just loaded (admittedly fairly slowly) and let me do my thing. Real emacs don’t give warning messages.
in the running
Almost ‘Best of The Year’ time. In the running are:
A Hawk and a Hacksaw – The Way the Wind Blows
A.C. Newman – Souvenir of Canada – EP
Beck – The Information
Calexico – Garden Ruin
Casper & the Cookies – The Optimist’s Club
Colin Meloy – Colin Meloy Sings Shirley Collins
Eels with Strings – Live At Town Hall
Elf Power – Back To The Web
Erynn Marshall – Calico
Faun Fables – The Transit Rider
Grandaddy – Just Like The Fambly Cat
Grant-Lee Phillips – nineteeneighties
Hidden Cameras – Awoo
Joanna Newsom – Ys
Jolie Holland – Springtime Can Kill You
King Biscuit Time – Black Gold
Mayor McCa – Cue Are Es Tea You
Peter Stampfel – The Jig Is Up
Robyn Hitchcock & The Venus 3 – Olé! Tarantula
Sufjan Stevens – Songs For Christmas – Volume V: Peace
Sufjan Stevens – The Avalanche – Outtakes And Extras From The Illinois Album
The Be Good Tanyas – Hello Love
The Decemberists – The Crane Wife
The Essex Green – Cannibal Sea
The Flaming Lips – At War With The Mystics
The Handsome Family – Last Days of Wonder
The Instruments – Cast A Half Shadow
The Sadies – In Concert Vol. 1
The Wailin’ Jennys – Firecracker
Thom Yorke – The Eraser
Thomas Dolby – The Sole Inhabitant
Wendy Arrowsmith – Crying Out
Yo La Tengo – I Am Not Afraid Of You And I Will Beat Your Ass
Miraculously, all of them fit on my iPod Nano, so they’ll be in heavy rotation over the next week or so while I decide.
music of 2005
It’s getting towards the end of the year, so I’m thinking about what albums I enjoyed most. These are the 2005 albums I have in my collection:
- A Hawk And A Hacksaw — Darkness At Noon
- Aimee Mann — The Forgotten Arm
- Animal Collective — Feels
- Beck — Guero
- Bettye Lavette — I’ve Got My Own Hell To Raise
- Bright Eyes — Digital Ash In a Digital Urn
- Bright Eyes — I’m Wide Awake, It’s Morning
- Calexico / Iron & Wine — In the Reins
- Caribou — Marino Audio
- Dan Jones — Get Sounds Now
- The Decemberists — Picaresque
- Deerhoof — The Runners Four
- Devendra Banhart — Cripple Crow
- Dressy Bessy — Electrified
- The Duhks — The Duhks
- Eels — Blinking Lights And Other Revelations
- Fiona Apple — Extraordinary Machine
- Gorillaz — Demon Days
- Grandaddy — Excerpts From The Diary Of Todd Zilla
- Jennifer Gentle — Valende
- John Parish — Once Upon a Little Time
- Kate Bush — Aerial
- Kate Rusby — The Girl Who Couldn’t Fly
- Kimberley Rew — Essex Hideaway
- Lazerlove5 — Flicker Mask
- Lemon Jelly — ‘64–‘95
- The Lollipop People — We Need a New F-Word
- Malcolm Middleton — Into The Woods
- Marbles — Expo
- The Mountain Goats — The Sunset Tree
- My Morning Jacket — Z
- Of Montreal — The Sunlandic Twins
- Sigur Rós — Takk …
- Sleater-Kinney — The Woods
- Sufjan Stevens — Illinois
- The Vanity Project
- Wolf Parade — Apologies to the Queen Mary
I know there are some that won’t make my list (Aerial, for one) but the rest of them all have their moments.
sometimes I wish awk had a print-range operator
‘cos it gets tiring to do this:
awk -F, ‘(($13 > 202.5) && ($13 < = 247.5) && ($9 > 0.0)) {OFS=”,”; print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,($5/$9);}’ infile
Too many $$s …