Skip to content

Instantly share code, notes, and snippets.

View JackDanger's full-sized avatar

Jack Danger JackDanger

View GitHub Profile
def a_little_recursion(n):
if n > 100:
print "all done!"
print "not done yet!"
return
a_little_recursion(n + 1)
a_little_recursion(0)
require 'csv'
def import(filename, out = $stdout, &block)
# Yes, there are gems that do progress bars.
# No, I'm not about to add another dependency for something this simple.
width = `tput cols`.to_i - 4
processed = 0
total = File.read(filename).lines.length.to_f - 1
label = File.basename(filename, '.csv')
out.puts "%11s:" % label
@JackDanger
JackDanger / 1.9.3-p545-railsexpress.diff
Last active August 29, 2015 14:02 — forked from xaviershay/require-performance-fix-r31758.patch
Xavier Shay's Kernel#require speedup
diff --git a/.gitignore b/.gitignore
index 57557c9..7955376 100644
--- a/.gitignore
+++ b/.gitignore
@@ -129,3 +129,4 @@ y.tab.c
# /win32/
/win32/*.ico
+ext/win32ole/.document
diff --git a/array.c b/array.c
%w(pry method_source coderay slop).each do |name|
Dir["#{$GEM_HOME}/gems/#{name}-*"].each do |g|
$LOAD_PATH << "#{g}/lib"
end
end
require 'pry'
#include <ruby.h>
struct my_malloc {
size_t size;
void *ptr;
};
static void
my_malloc_free(void *p) {
struct my_malloc *ptr = p;
def sql
/\A\s*(SELECT|INSERT|UPDATE|DELETE).*(FROM|JOIN)\s*`?(my_interesting|tables)`?/
end
def sql_frozen
/\A\s*(SELECT|INSERT|UPDATE|DELETE).*(FROM|JOIN)\s*`?(my_interesting|tables)`?/.freeze
end
SQLo = /\A\s*(SELECT|INSERT|UPDATE|DELETE).*(FROM|JOIN)\s*`?(my_interesting|tables)`?/o
SQL = /\A\s*(SELECT|INSERT|UPDATE|DELETE).*(FROM|JOIN)\s*`?(my_interesting|tables)`?/
SQLFrozen = /\A\s*(SELECT|INSERT|UPDATE|DELETE).*(FROM|JOIN)\s*`?(my_interesting|tables)`?/.freeze

Keybase proof

I hereby claim:

  • I am jackdanger on github.
  • I am danger (https://keybase.io/danger) on keybase.
  • I have a public key whose fingerprint is 8FDA 10D5 FF86 25DC F4F0 2DFC 8A21 AF91 518D A66B

To claim this, I am signing this object:

#!/usr/bin/env ruby
# ActiveSupport has a more modern syntax now. Pipe any old-style
# ActiveSupport::TestCase suites into this file and have the syntax
# updated. For when you can't use Shoulda or RSpec but you still
# want to look sexy.
#
# Before:
#
# def test_guy_can_do_stuff
@JackDanger
JackDanger / gist:71799
Created February 28, 2009 00:34
Play yourself some Archx
alias djgoatboy="curl -L `curl -s http://twitter.com/statuses/user_timeline/djgoatboy.rss | grep "title>djgoatboy:" | head -n 1 | cut -c 23-47` > djgoatboy.mp3; afplay djgoatboy.mp3"
#!/usr/bin/env ruby1.9
#
# In Javascript you can add a function to an object like so:
#
# obj.perform = function(){ ... stuff to do ...}
#
# But in Ruby 1.8 there's always been a problem where a method
# defined with `define_method` won't be able to take a block.
# So you'd never be able to do something like this: