Skip to content

Instantly share code, notes, and snippets.

@rgo
rgo / Rakefile
Created February 27, 2014 01:04
# change foo to your library name
# change Foo::Database to your Sequel database
namespace :bundler do
task :setup do
require 'rubygems'
require 'bundler/setup'
end
end
@rgo
rgo / sshd_config
Created September 5, 2013 09:15 — forked from knoopx/sshd_config
# This prevents capistrano from hanging when executing long tasks
# /etc/ssh/sshd_config
TCPKeepAlive yes
ClientAliveInterval 15
ClientAliveCountMax 5
# Restart sshd
@rgo
rgo / cronjobs_by_user.sh
Created July 9, 2013 14:26
List all cronjobs for all users
# From http://stackoverflow.com/questions/134906/how-do-i-list-all-cron-jobs-for-all-users
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
@rgo
rgo / gist:3371771
Created August 16, 2012 17:15
Replace "url('../images/*.*)" by "url(<%= asset_path '*.* %>)"
" Replace "url('../images/*.*)" by "url(<%= asset_path '*.* %>)"
"
" Useful when you need to change a css file to be converted in a css.erb file
"
%s/url(\(\.\.\/images\/\)\(.\+\))/url\(<%= asset_path '\2' %>\)/gc
%s/url('\(\.\.\/images\/\)\(.\+\)')/url\(<%= asset_path '\2' %>\)/gc
@rgo
rgo / gist:2025990
Created March 13, 2012 01:16
Gnome-shell dual monitor separate workspaces
# By default the behavior is:
# Primary monitor work as always and second monitor only have one and fixed workspace
# I.e. you change to next workspace, primary monitor change to this workspace and second monitor remain as is.
# The desired behaviour is:
# Primary monitor and secondary monitor are linked workspace.
# I.e. you change to next workspace, primary monitor change to this workspace and second monitor too.
$ gconf-editor
# Look for /desktop/gnome/shell/windows/workspaces_only_on_primary and set to false
@rgo
rgo / compile_image_magick.txt
Created March 8, 2012 10:27
Compile latest ImageMagick version (useful for old distros)
## From http://johannes.jarolim.com/blog/2011/11/21/extreme-slow-imagemagick-on-vps-with-ubuntu/
#
# Execute as root
apt-get update
apt-get install build-essential
apt-get build-dep imagemagick
cd /usr/local/src
@rgo
rgo / gist:1714364
Created February 1, 2012 01:20
MySQL backup (saving engine used for table creation)
# I'm using --create-options to get all the info about table creation (i.e. engine=InnoDB)
$ mysqldump -u foobar -p --single-transaction --create-options <database> > file.sql
@rgo
rgo / gist:1714339
Created February 1, 2012 01:14
Convert MyISAM tables to InnoDB
## Copied from: http://technotes.twosmallcoins.com/?p=356
# Get table listing and generate ALTER sql file
$ mysql -u foobar -p -e "show tables in <database> ;" | tail --lines=+2 | xargs -i echo "ALTER TABLE {} ENGINE=INNODB;" > alter_table.sql
# Execute ALTER sql queries generated to convert from MyISAM to InnoDB:
$ mysql -u foobar -p <database> < alter_table.sql
@rgo
rgo / unixodbc-configuration-example.sh
Created January 19, 2012 12:15
Unixodbc configuration example with cli
#
# COPIED FROM http://www.1stbyte.com/2011/06/28/unixodbc-example-setup-on-ubuntu-lucid-with-mysql-and-postgresql/
#
# Do the obvious, install mysql an postgresql first. :)
# install unixodbc
apt-get install unixodbc unixodbc-dev libmyodbc odbc-postgresql
cd to /etc/ODBCDataSources
@rgo
rgo / bandwidth_summary.sh
Created December 23, 2011 18:42
Calculates bandwith with netstat
#!/bin/bash
#
## Calomel.org calomel_interface_stats.sh
#
IF=eth0
SECS=`uptime | awk '{ if ($3 ~ /:/) { split($3,a,":"); print (a[1]*60+a[2])*60} else { split($3,b,":"); split($5,a,":"); print b[1]*86400+(a[1]*60+a[2])*60} }'`
EXT_IN=`netstat -n -i $IF | grep $IF | tail -1 | awk '{print $4}'`
EXT_OUT=`netstat -n -i $IF | grep $IF | tail -1 | awk '{print $8}'`
echo " "