Thursday, 6 December 2012

Printing from the Linux command line

To print a file from the Linux command line, use the simple command:
It's that easy!

I came across this while trying to print all pdf files in a directory. To do this, the simple bash script you need is:
 for file in *.pdf; do  
   /usr/bin/lpr "$file"  

Save this into a file - I called mine Then make it executable using
 chmod +x  

Copy it to the directory you want to run it in, then execute with

For an additional challenge, can anyone adapt the above script to print all .pdfs from directories recursively? Answers in the comments below!

[References] Bash script adapted from a LinuxForums post.

Wednesday, 5 December 2012

Notes on using Heroku

These are a few common things I find myself looking up when working with Heroku - I update this post if I find myself repeated searching for how to do the same tasks.

Running commands from a folder not linked to Heroku

Simply append --app APP_NAME to any relevant Heroku command:


If trying to push to Heroku:
 git push heroku master  
but get a publickey error:
 Permission denied (publickey).  
 fatal: The remote end hung up unexpectedly  
You need to add your public key to Heroku.
 heroku keys:add path_to_publickey  
If you don't have a public key, Heroku can prompt and generate one for you - simply use the command:
 heroku keys:add  

Resetting the application database

 heroku pg:reset DATABASE_URL  
To reset the database without a validation prompt, use:
 heroku pg:reset DATABASE_URL --confirm APP_NAME  


To run a rake task on Heroku, create the task in app/lib/tasks (Rails), test locally then deploy. To run, use:
 heroku run rake TASK_NAME

If you have any useful commands you regularly use while working with Heroku, let me know in the comments below!

Tuesday, 4 December 2012

How to add a menu item for SPSS in Linux

I keep forgetting where SPSS installs itself - this .desktop file may be of help to others too.

Create .desktop file for SPSS:
 sudo leafpad /usr/share/applications/spss.desktop  

Add this text to that file:
 [Desktop Entry]  
 Comment=Statistics program  

Save, then log out and back in again, or restart the desktop using
 xfdesktop --reload  
if using an XFCE desktop.

 SPSS will now be available under Applications -> Education.