6/27/2012

Printing from the command line...

If you're like me (i.e. a neophyte college student), at the end of a semester you have folder for each class, with various sub-folders for hw, lectures, etc. Each folder has a number of files (say, lecture notes), and you'd like to print all of them with a single command (rather than opening each in some program, selecting print, and so forth).

If so, then you're in luck! Via the wonders of the command line (and BASH scripting), the following line of code when run from a terminal (both  OSX and Linux) will do exactly that:

find . -name '*.pdf' -exec lpr {} \;

What the command does:

find . -name '*.pdf'

-searches the directory you are currently in (as well as all sub-directories) for all files ending in .pdf (you can change this to whatever you are trying to print. For instance, if you had some Word files you would change this to .doc)

This is then passed as an input (via the -exec) to the lpr function, which sends a print request for each file found by the 'find' command. The '{}' symbol is what sends the results from find to lpr. Finally, \; ends and executes the line. 

Note: Make sure to only run this script from the directory you want to start searching from, otherwise you'll probably print more than you intended (See some of the stories about golems for further reference).

3/01/2012

Emacs and Latex...

Recently a friend asked me if I could send him some links on Emacs and Latex. After sending it to him, thought it might prove useful to others, so I'm reposting it here.


Preliminaries:

http://kieranhealy.org/emacs-starter-kit.html (Setting up Emacs and
latex in Windows, Mac, or Linux)
http://www.kieranhealy.org/files/misc/workflow-apps.pdf (overview of
what's in the kit, and why you might want to use it - targeted at graduate students in the social sciences, but still fairly general)


Emacs (Note: After setting up, use the built in tutorial first):

http://www.gnu.org/software/emacs/manual/html_node/emacs/index.html
(Reference manual - is built into the editor as well)
http://home.uchicago.edu/gan/file/emacs.pdf (cheat sheet)

Latex:

http://www.techscribe.co.uk/ta/latex-introduction.pdf ( One page overview)
http://ctan.tug.org/tex-archive/info/lshort/english/lshort.pdf (main reference)
http://www.andy-roberts.net/misc/latex/ (tutorials for various levels)
http://en.wikibooks.org/wiki/LaTeX (Wikipedia's unfinished book on latex)

1/18/2012

Bypass SOPA/PIPA Blackout on Wikipedia

SOPA and PIPA are both horrid bills whose passage leads to the Internet being broken. To try and prevent their passage, Wikipedia (and many other organisations/businesses) have blacked-out their websites (or placed anti-SOPA banners) so as to raise awareness. Given the importance of stopping these bills, you should stop reading this tutorial and fill out one of the various petitions or contact your congress-critter.

Done that? Good, now here's how to bypass Wikipedia's blackout:

On Firefox: Open your options/preference menu (should be under edit or tools, depending on your operating system) and disable javascript. Congratulations, you've now bypassed the blackout. (Alternatively, you could install the add-on NoScript)

On Safari or IE: Open your options/preference/settings menu (should be under edit or tools, depending on your operating system/browser) Congratulations, you've now bypassed the blackout.

Note that you cannot edit pages, however you can still view them.