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|
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.
#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) {
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
require 'rubygems'
require "./nolate"
require "erb"
require "bench"
module FastERB
def self.new(*args)
o = Object.new
erb = ERB.new(*args)
o.extend erb.def_module("render(myfield)")
(master)⚡)% ls
Gemfile foo.rb
(master)⚡)% cat foo.rb
require 'sinatra'
require 'pp'
get '/' do
"<pre>#{ENV.pretty_inspect}</pre>"
end
(master)⚡)% vmc runtimes
diff --git a/Makefile.in b/Makefile.in
index a01faae..ff05dae 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -297,6 +297,10 @@ enc/unicode/name2ctype.h: enc/unicode/name2ctype.kwd
@$(ECHO) preprocessing $<
$(Q) $(CPP) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -E $< > $@
+probes.h:
+ @$(ECHO) translating probes $<
#include <stdio.h>
#include <sys/mman.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include <unistd.h>
static volatile int done = 0;
sasha:rubinius brian$ rbx -Xagent.start
irb(main):001:0>