Skip to content

Instantly share code, notes, and snippets.

View gerhard's full-sized avatar

Gerhard Lazu gerhard

View GitHub Profile
@gerhard
gerhard / aa_instructions.md
Created May 23, 2012 10:38 — forked from NZKoz/aa_instructions.md
Back Up All Your Gmail
  • Install getmail (aptitude install getmail4)
  • Set Up Your Imap Server (tl;dr)
  • getmail
  • ruby date_based_archive.rb ~/Maildir/.Archive
@gerhard
gerhard / speedtest.bash
Created May 21, 2012 23:07
Bash script to continuously speedtest ISP connectivity, saves graphs to Librato Metrics
#!/usr/bin/env bash
######################################################################### CONFIG #
isp="VirginMedia"
run_every=1800 # in seconds
run_every_human="$(($run_every / 60)) minutes"
ovh="http://proof.ovh.net/files/10Mio.dat"
leaseweb="http://mirror.leaseweb.net/speedtest/10mb.bin"
@gerhard
gerhard / versionless.sh
Created May 18, 2012 16:16
Find all gems in your Gemfile without a version
#!/usr/bin/env bash
LOCAL_PATH="$(pwd)"
GEMS_WITHOUT_VERSION=$(cat $LOCAL_PATH/Gemfile | awk -F"['\"]" '! /[0-9].[0-9]/ && ! /source|group|end/ { print $2 }')
BUNDLED_GEMS=$(bundle list)
if [ ! $? = 0 ]
then
bundle
exit $?
@gerhard
gerhard / dry_run.sh
Created May 17, 2012 23:14
bash dry-run mode
init_app_remotely() {
ssh $APP_USER@$SERVER "ls"
}
run() {
__run 'init_app_remotely' "Initializing"
}
__run() {
case "${MODE}" in
@gerhard
gerhard / gist:2593557
Created May 4, 2012 09:24
hostnames in this example is a non-daemonizing ruby script
description "Hostnames sync"
start on runlevel [2345]
stop on runlevel [!2345]
console output
script
while true; do
su -c '. /root/.profile && hostnames'
@gerhard
gerhard / gist:2517250
Created April 28, 2012 08:43 — forked from kyledrake/gist:2120107
Rainbows! config file for use with EventMachine
# This is a configuration script for using Rainbows with EventMachine. I'm providing it incase somebody finds it useful. But honestly, you
# should stop using EventMachine and use threads instead. The ThreadPool version of this is also in my gist list, and I recommend taking a look at that instead.
# NO, SERIOUSLY, STOP USING EVENTMACHINE.
Rainbows! do
name = 'yourappname'
use :EventMachine
client_max_body_size nil # This is set in nginx
# keepalive_timeout 1
@gerhard
gerhard / Gemfile
Created April 25, 2012 11:01
guard-mocha
source 'http://rubygems.org'
gem 'guard'
gem 'guard-shell'
@gerhard
gerhard / total_rss.sh
Created March 22, 2012 17:09
Find total RSS memory used by all ruby processes
$ ps aux | awk '/[0-9] ruby/ { print $0; rss += $6 } END { print "TOTAL RSS: " rss/1024 " MB" }'
# Don't forget about resque ones
$ ps aux | awk '/[0-9] ruby|[0-9] resque/ { print $0; rss += $6 } END { print "TOTAL RSS: " rss/1024 " MB" }'
@gerhard
gerhard / gist:1852864
Created February 17, 2012 11:37
Deliver vs git-hooks

Why not just use git hooks?

  1. They run in the background, thus there is no visibility as to whether they succeed or fail.

  2. Deploying an app from start to finish involves multiple users, and if done right requires sudo privileges. The system user under which the app runs must not have sudo privileges, but the app itself would use Foreman ideally. If you export to Sys V or Upstart, you will need sudo privileges.

if has("gui_macvim")
" Full screen
set fuoptions=maxvert,maxhorz
set go-=T
set go-=l
set go-=L
set go-=r
set go-=R