Skip to content

Instantly share code, notes, and snippets.

@padde
padde / git-svn.sh
Created November 16, 2011 11:19
Commit to SVN via Git
# in case there is no first commit
svn co $SVN_PATH
svn add .
svn commit
# now the git-svn part
git svn init $SVN_PATH
git svn fetch
# commit from git
@padde
padde / gist:1400075
Created November 28, 2011 11:32
Show interesting methods of an object in Ruby
# please only interesting methods!
class Object
# return only the methods not present on basic objects
def interesting_methods
(self.methods - Object.new.methods).sort
end
end
@padde
padde / gist:1400077
Created November 28, 2011 11:32
Quick benchmarking in Ruby
def quick_benchmark(repetitions=100, &block)
require 'benchmark'
Benchmark.bmbm do |b|
b.report {repetitions.times &block}
end
nil
end
@padde
padde / .gitignore
Created December 2, 2011 18:58
LaTeX .gitignore
*.aux
*.glo
*.idx
*.log
*.toc
*.ist
*.acn
*.acr
*.alg
*.bbl
@padde
padde / gist:2021777
Created March 12, 2012 13:08
Git: remove deleted files from stage
git add -u
@padde
padde / install_tomato.sh
Created April 1, 2012 18:28
Install Tomato Firmware via TFTP from *NIX system
#!/bin/bash
echo "==================================================================="
echo "This bash script will upload tomato.trx in the current directory to"
echo "192.168.11.1 during the router's bootup."
echo
echo "* Set your ethernet card's settings to:"
echo " IP: 192.168.11.2"
echo " Mask: 255.255.255.0"
echo " Gateway: 192.168.11.1."
@padde
padde / chained-comparison.rb
Created April 20, 2012 15:45
chained comparison in Ruby
# Chained comparisons in Ruby
# inspired by http://coffeescript.org/#comparisons
# as well as http://refactormycode.com/codes/1284
[:<, :>, :<=, :>=].each do |operator|
[Float, Fixnum, Rational, Comparable].each do |klass|
klass.class_eval do
alias_method "_#{operator}", operator
define_method operator do |rhs|
send("_#{operator}", rhs) && rhs
@padde
padde / zshrc
Created May 5, 2012 09:06
oh-my-zsh workaround for loading themes from $ZSH_CUSTOM
# your other stuff…
# set ZSH_THEME above this line!
# TODO: remove this when bug is fixed in oh-my-zsh
# Workaround for loading theme from $ZSH_CUSTOM
# Github issue: https://github.com/robbyrussell/oh-my-zsh/pull/1107
MY_ZSH_THEME=$ZSH_THEME; ZSH_THEME=''
# OH MY ZSH!
@padde
padde / gist:2623647
Created May 6, 2012 18:23
Convert video for PowerPoint with ffmpeg
ffmpeg -i INFILE -r 25 -f mpeg -vcodec mpeg1video -ar 48000 -b 1500k -acodec mp2 -ar 44100 -ac 1 -y OUTFILE.mpg
@padde
padde / gist:2628262
Created May 7, 2012 15:05
Ruby Fixnum each_bit
class Fixnum
def each_bit
8.times do |p|
yield (self & 1 << p) >> p
end
end
end