Thursday, 6 December 2012

Printing from the Linux command line

To print a file from the Linux command line, use the simple command:
 lpr FILENAME  
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:
 #!/bin/bash  
 for file in *.pdf; do  
   /usr/bin/lpr "$file"  
 done  

Save this into a file - I called mine print-all-pdfs.sh. Then make it executable using
 chmod +x print-all-pdfs.sh  

Copy it to the directory you want to run it in, then execute with
 ./print-all-pdfs.sh  

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:
HEROKU_COMMAND --app APP_NAME  

Deployment

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  

Rake

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]  
 Name=SPSS  
 GenericName=SPSS  
 Comment=Statistics program  
 Exec=/opt/IBM/SPSS/Statistics/19/bin/stats  
 Icon=gnome-monitor  
 Terminal=false  
 Type=Application  
 Categories=Application;Education;  

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.