commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
Saves to a PDF with title and alt text of comic.
As asked for on http://bbs.archlinux.org/viewtopic.php?id=91100
Change xkcd.com to dynamic.xkcd.com/comics/random for a random comic.
There is 1 alternative - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.
Error:
convert: Non-conforming drawing primitive definition `s' @ draw.c/DrawImage/3123.
Result:
Alt text garbled
convert: unable to read font `/usr/share/fonts/default/TrueType/arial.ttf'.
convert: Non-conforming drawing primitive definition `m'.
convert: unable to read font `/usr/share/fonts/default/TrueType/arial.ttf'.
if you got this, try this:
add -font "helvetica" to the convert command
e.g.: ...| convert -font "helvetica" png:- ...
this:
convert: Non-conforming drawing primitive definition `m'.
is still coming up, but you'll see the text in the pdf
nice, but didn't work - same problem as comments above
I think I've fixed those problems please try it again.
Remember it saves to a pdf file so you should have an "xkcd.pdf" in your local directory.
It worked aces for me; I was the first to give it a thumbs up. :P
Something I've considered giving a go, but have yet to - converting it to vector and doubling (or tripling) in size before saving to pdf. Also it would be pretty sweet to name each pdf "comicNumber.pdf" rather than just xkcd.pdf. If I could do that, and successfully achieve the vector "zoom" effect, i'd totally make this a daily cron. :)
There is no need for the temp file. You can use convert on a URL. So the major thing might be
IMG=`curl -sL xkcd.com| grep '<img [^>]*/><br/>'|awk -F\" '{print $2}'`;convert $IMG -gravity south -draw "text 0,0 \"$IMG\"" pdf:- > xkcd.pdf@trench
Try this:
number=100; for a in $(seq 1 $number); do curl -sL xkcd.com/$a | grep '<img [^>]*/><br/>' | sed -r 's|<img src="(.*)" title="(.*)" alt="(.*)" /><br/>|\1\t\2\t\3|' > /tmp/a; curl -s $(cat /tmp/a | cut -f1) | convert - -gravity south -draw "text 0,0 \"$(cat /tmp/a | cut -f2)\"" pdf:- > /tmp/$a.pdf; done; gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=xkcd.pdf $(seq 1 $number | sed -r 's/(.*)/\/tmp\/\1.pdf/'); rm /tmp/a /tmp/*.pdf@houghi
The problem is it gives the URL of the xkcd comic not the alt text
@trench
Actually this is more what you want:
number=100; mkdir xkcd; for a in $(seq 1 $number); do curl -sL xkcd.com/$a | grep '<img [^>]*/><br/>' | sed -r 's|<img src="(.*)" title="(.*)" alt="(.*)" /><br/>|\1\t\2\t\3|' > /tmp/a; curl -s $(cat /tmp/a | cut -f1) | convert - -gravity south -draw "text 0,0 \"$(cat /tmp/a | cut -f2)\"" pdf:- > xkcd/$a.pdf; done