Skip to content

Instantly share code, notes, and snippets.

@jbonney
jbonney / spotify_keybindings
Created June 9, 2013 13:22
Spotify - Linux key bindings. From XFCE / Ubuntu keyboard shortcuts configuration, assign the control command to their key. http://shkspr.mobi/blog/2011/12/linux-spotify-keybindings/
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious
@jbonney
jbonney / jar_through_proxy
Created June 18, 2013 19:56
Execute Java jar program through a socks proxy.
java -jar -DsocksProxyHost=localhost -DsocksProxyPort=8080 program.jar
@jbonney
jbonney / rotated-header.css
Created July 18, 2013 20:29
Rotate HTML header in table
.table-header-rotated th.row-header{
width: auto;
}
.table-header-rotated td{
width: 40px;
border-top: 1px solid #dddddd;
border-left: 1px solid #dddddd;
border-right: 1px solid #dddddd;
vertical-align: middle;
@jbonney
jbonney / deploy.rb
Created August 17, 2013 15:15
Mina deployment file to setup new host for Rails applications. Creates the folder structure, fill up the database.yml file, create the associated DB and user and set up new Apache virtual host file.
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
# Usually mina focuses on deploying to one host and the deploy options are therefore simple.
# In our case, there is a number of possible servers to deploy to, it is therefore necessary to
# specify the host that we are targeting.
server = ENV['server']
# Since the same host can have multiple applications running in parallel, it is necessary to
@jbonney
jbonney / .bash_profile
Created February 4, 2014 13:43
Run ssh-agent when you login, and kill it when you logout. Add code to ~/.bash_profile. Taken from http://blog.xk72.com/post/75565726956/ssh-agent
eval `/usr/bin/ssh-agent -s`
trap "kill $SSH_AGENT_PID" 0
@jbonney
jbonney / archive_git.sh
Created September 13, 2013 15:17
Create archive from git repository without git history information. From http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export
git archive master | bzip2 > source-tree.tar.bz2
@jbonney
jbonney / tunnel_monit.sh
Created October 18, 2013 13:41
Access remote monit server through SSH
ssh -L 8081:localhost:2812 user@server.com -f -N
#Encryption
openssl enc -in important_backups.tar.gz -aes-256-cbc -e > important_backups_encrypted.tar.gz
# Decryption
openssl enc -in important_backups_encrypted.tar.gz -aes-256-cbc -d > important_backups_decrypted.tar.gz
@jbonney
jbonney / related_articles_help.rb
Created August 18, 2013 14:50 — forked from owengriffin/related_articles_help.rb
Identify related articles based on similar tags in article tags sets
@jbonney
jbonney / mysqldump.sh
Created August 30, 2013 22:04
MySQL dump to export data only (no DB schema nor table instructions). Particularly useful when exporting a Rails DB to re-import it afterwards in a DB that has been created through `rake db:drop db:create db:migrate`.
mysqldump --user="username" --password="password" --skip-triggers --compact --no-create-info --ignore-table="database_name.schema_migrations" --ignore-table="database_name.table_populated_through_migration" "database_name" > "dump.sql"