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.
-
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 …