This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(master)⚡)% ls | |
Gemfile foo.rb | |
(master)⚡)% cat foo.rb | |
require 'sinatra' | |
require 'pp' | |
get '/' do | |
"<pre>#{ENV.pretty_inspect}</pre>" | |
end | |
(master)⚡)% vmc runtimes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 $< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sasha:rubinius brian$ rbx -Xagent.start | |
irb(main):001:0> |
OlderNewer