Skip to content

Instantly share code, notes, and snippets.

View mrb's full-sized avatar
🍕
Helping companies market and sell more software

Michael Bernstein mrb

🍕
Helping companies market and sell more software
View GitHub Profile
@mrb
mrb / searchable.rb
Created August 23, 2010 18:15 — forked from quirkey/snippet.txt
module Searchable
def self.searchable_fields
[]
end
def self.included(klass)
klass.named_scope :by_search, lambda {|q, options|
if q.present?
search_text = [klass.searchable_fields].flatten.collect {|f|
@tj
tj / error
Created September 21, 2010 05:11
if foo
if bar
something
else
something_else
else
baz
anonymous
anonymous / gist:610665
Created October 4, 2010 23:41
be careful with method empty?
class Cart < ActiveRecord::Base
has_many :line_items
delegate :empty?, :to => :line_items
end
class User < ActiveRecord::Base
has_one :cart
end
@user = User.new
We couldn’t find that file to show.
@jamis
jamis / Basic Oi (Cucumber) Kimchi
Created November 6, 2010 20:07
Basic Oi (Cucumber) Kimchi
BASIC OI (CUCUMBER) KIMCHI
--------------------------------------------------------------------------
Oi (cucumber) kimchi is a delicious, refreshing variation on the
traditional Korean kimchi recipe.
This particular recipe is a modified version of the recipe posted by Dr.
Ben Kim, at http://www.drbenkim.com/how-to-make-cucumber-kim-chi.htm.
--------------------------------------------------------------------------
@schacon
schacon / ruby_c_ext.txt
Created December 19, 2010 06:46
Ruby C Extension Articles
README.ext
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_6/README.EXT?revision=12055
Extending Ruby - Pickaxe
http://ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html
Extending Ruby on O'Reilly
http://onlamp.com/pub/a/onlamp/2004/11/18/extending_ruby.html
Ruby C Extensions - Mark Volkman
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <assert.h>
#include "hiredis.h"
#include "async.h"
#include "adapters/libev.h"
void message(redisAsyncContext *c, redisReply *reply, void *privdata) {
@bryanl
bryanl / campfire-emoji.txt
Created January 27, 2011 16:34
campfire emoji
Surround these with : e.g. :calling:
+1
-1
bulb
calling
clap
cop
email
feet
def daemonize(name = File.basename($0), options = {})
pid_path = options[:pid_path] || File.expand_path("tmp/pids/#{name}.pid")
# If the pid file exists, check that the process is actually still running.
begin
if File.exists?(pid_path) && Process.kill(0, File.read(pid_path).to_i)
$stderr.puts "Already running."
exit 1
end
rescue Errno::ESRCH
@funny-falcon
funny-falcon / patch-1.9.2-gc.patch
Created March 5, 2011 11:11
GC tunning simple patch ruby 1.9.2 p180
diff --git a/gc.c b/gc.c
--- a/gc.c
+++ b/gc.c
@@ -77,6 +77,41 @@ void *alloca ();
#ifndef GC_MALLOC_LIMIT
#define GC_MALLOC_LIMIT 8000000
#endif
+#define HEAP_MIN_SLOTS 10000
+#define FREE_MIN 4096
+