Skip to content

Instantly share code, notes, and snippets.

require 'active_record'
require 'benchmark/ips'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => ':memory:')
ActiveRecord::Base.connection.create_table('posts') do |t|
t.string :name
t.timestamps
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

anonymous
anonymous / minimal_todo.sh
Created January 14, 2012 13:21
Minimally Awesome Todos for Mac OS X
# Reference: http://blog.jerodsanto.net/2010/12/minimally-awesome-todos/
#
# Improvements:
#
# *) It now supports tracking multiple projects/todo files.
# *) Use 'cat -b' to get task order instead of hard-coding line number in files.
#
# 3 actions available:
# - Create a new task in project "prj": td prj task
# - Delete third task: tddone prj 3
@databyte
databyte / ruby-debug19-install.sh
Created December 14, 2011 04:17
Install ruby-debug19 for ruby-1-9-3
wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
gem install linecache19-0.5.13.gem
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$HOME/.rvm/src/ruby-1.9.3-p194
rm linecache19-0.5.13.gem
rm ruby-debug-base19-0.11.26.gem
@madrobby
madrobby / i18n.coffee
Created November 14, 2011 15:45
Backbone i18n with CoffeeScript
# before this file is loaded, a locale should be set:
#
# In a browser environment, you can use:
# ```<script>__locale='en';</script>```
#
# In a server environment (specifically node.js):
# ```global.__locale = 'en';```
# normalize in-app locale string to "en" or "de-AT"
parts = @__locale.split('-')
@wtaysom
wtaysom / where_is.rb
Created September 23, 2011 08:57
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
import java.awt.*;
import javax.swing.*;
public class AnimatedScreenCapture extends JFrame {
JLabel label;
Robot robot;
Rectangle screenRect;
int scaleX;
@michaelfeathers
michaelfeathers / methodshark.rb
Created March 9, 2011 15:58
Output the complexity trend of an individual method across its history
#!/usr/bin/env ruby
# Print the complexity over time for a Ruby method in a
# git repository.
#
# Requires: >= bash ?.?
# >= git 1.7.1
# >= ruby 1.9.2
# >= flog 2.5.0
#
@plukevdh
plukevdh / RubyBenchmarks
Created January 30, 2011 01:36
A quick benchmark of the different flavors of ruby.
$ rvm 1.8.7,1.9.2,ree,rbx,macruby-0.8,jruby benchmark_haversine.rb
## 1.8.7-p330
Rehearsal ---------------------------------------------------
ruby-1.8.7-p330 11.870000 0.030000 11.900000 ( 12.120409)
----------------------------------------- total: 11.900000sec
user system total real
ruby-1.8.7-p330 12.020000 0.040000 12.060000 ( 12.556268)
@desandro
desandro / jquery.imagesloaded.js
Created January 26, 2011 18:01 — forked from paulirish/README.md
$.fn.imagesLoaded jQuery plugin
// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images
// Modified with a two-pass approach to changing image
// src. First, the proxy imagedata is set, which leads
// to the first callback being triggered, which resets
// imagedata to the original src, which fires the final,
// user defined callback.