Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
echo "Bash version ${BASH_VERSION}..."
cd ~/.vim/bundle
for plugin in ~/.vim/bundle/*
do
echo "Updating $plugin"
( cd $plugin; git pull --rebase origin master )
echo "DONE!"
@aberant
aberant / 808-kick.rb
Created June 16, 2013 02:31
In case you ever wondered how to create an 808 kick in ruby
# consult the signal flow graph for a ringing digital filter at
# http://i.stack.imgur.com/49pxl.jpg
require 'wavefile'
Frequency = 50
SampleRate = 44_100
DecayFactor = 0.15
fc = 2 * Math.sin((Math::PI * Frequency)/SampleRate)
@aberant
aberant / gist:5474874
Created April 27, 2013 21:49
good thing i already know there is an encoding problem
expected: "/hi\0,f\0\0@I\x0F\xD0"
got: "/hi\0,f\0\0@I\x0F\xD0" (using ==)
r͞equ͟ire "f͠ile͝uţils҉"̷
requir͠e ͘"rb̴ćo͏n͠f̢i͝g"͢
́m͝ód͡u͘l̀e ͠Cap̢y͞b͏ar̕a͜W̴èb̢ḱi͘t͏B̨ui̶l͟d̵e͟r͡
̨ ̶ ext҉en̛d ͏self͞
̀ ͏ d͠e͜f ̨ḿa͘k͜e҉_bi͏n
̴ ̷ ͝ ́ĘNV͞['M̴AKE̕'͞]͝ ͘||͏ ҉'ma͡k͢e'
҉e͞nd̶
͢
@aberant
aberant / method_class_example.rb
Created November 21, 2012 16:52
method class example
# http://ruby-doc.org/core-1.9.3/Object.html#method-i-method
# http://ruby-doc.org/core-1.9.3/Method.html
> User.method(:first)
=> #<Method: Class(ActiveRecord::Querying)#first>
> User.method(:first).arity
=> -1
User.method(:first).source_location
=> ["/Users/aberant/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.2/lib/active_record/querying.rb",
4]
@aberant
aberant / horrible.rb
Created July 3, 2012 21:10
horrible.rb
# this only works in 1.8
module People
extend self
def self.base
Object
end
end
@aberant
aberant / example.js
Created March 13, 2012 13:58 — forked from redsquirrel/gist:2025533
A child sending a message to its parent.
var fork = require('child_process').fork;
if (process.argv[2] == 'son') {
setTimeout(function() {
process.send({ result: 'hi dad' });
process.exit(0);
}, 1000);
} else {
var child = fork(__filename, [ 'son' ]);
child.on('message', function(m) {
@aberant
aberant / mongostat.txt
Created June 23, 2011 15:43
mongostat
insert query update delete getmore command flushes mapped vsize res faults locked % idx miss % qr|qw ar|aw netIn netOut conn time
888 0 0 0 21 2 0 158g 160g 40.5g 8 22.4 0 0|0 0|0 627k 3k 81 10:31:35
495 0 0 0 16 2 0 158g 160g 40.5g 4 89.8 0 12|14 12|15 315k 2k 81 10:31:36
1451 0 0 0 19 2 0 158g 160g 40.5g 14 53.9 0 0|0 0|0 1m 3k 81 10:31:37
919 2 0 0 28 2 0 158g 160g 40.5g 9 23.4 0 13|5 13|6 645k 5k 81 10:31:39
1165 1 0 0 15 2 0 158g 160g 40.5g 11 74.9 0 9|12 9|13 825k 3k 81 10:31:40
102 3 0 0 9 2 0 158g 160g 40.5g 4 99.8 0 1|26 1|27 54k
@aberant
aberant / cant_freeze_constants.rb
Created June 1, 2011 20:51
you can't freeze constants in ruby
BOB = 3 #=> 3
BOB.freeze #=> 3
BOB = 4 # (irb):4: warning: already initialized constant BOB #=> 4
BOB #=> 4
@aberant
aberant / find_all_benchmark.rb
Created May 10, 2011 16:18
find_all_by_id is faster then exceptions
Benchmark.bm(10) do |x|
x.report("find all") {(1..10000).each { User.find_all_by_id( [99999])}}
x.report("find rescue") {(1..10000).each {User.find([9999]) rescue [] }}
end
user system total real
find all 3.200000 0.350000 3.550000 ( 4.630230)
find rescue 4.820000 0.380000 5.200000 ( 6.329360)