Skip to content

Instantly share code, notes, and snippets.

require 'net/http'
require 'uri'
module Rack
class Request
def spam?
env["rack-middleware.rakismet.spam"]
end
end
class Hash
def +(another)
h = self.clone
another.each do |k, v|
if h.has_key? k
h[k] += v
else
h[k] = v
end
end
@ml
ml / gist:189001
Created September 18, 2009 10:31
> a = true;
?> b = false;
?> x = a and b;
?> x
=> true
require 'rubygems'
require 'sinatra'
require File.join(File.dirname(__FILE__), '..', 'lib', 'rakismet.rb')
get '/' do
%{<html><head><title>Rakismet</title></head><body>
<form action="/posts" method="post">
<label for="comment_author">author</author>
moved to https://github.com/ml/rack-contrib/blob/master/lib/rack/contrib/superlogger.rb
DataMapper.setup(:default, :adapter => 'mysql', :database => "test", :username => "root")
DataMapper.setup(:dual, :adapter => "dual", :default => repository(:default), :redis => {:db => 1})
class DualAdapter < AbstractAdapter
def create(query)
@default.create query
end
def read(query)
query = simplify(query) if simplify_applies?(query)
Warning: You should upgrade to Xcode 3.1.4
==> Build Environment
PATH: /Users/lotus/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin
CFLAGS: -O3 -march=nocona -mfpmath=sse -w -pipe
MAKEFLAGS: -j2
CC: /usr/bin/cc
CXX: /usr/bin/c++
==> Downloading http://google-perftools.googlecode.com/files/google-perftools-1.4.tar.gz
File already downloaded and cached to /Library/Caches/Homebrew
/usr/bin/tar xf /Library/Caches/Homebrew/google-perftools-1.4.tar.gz
Warning: You should upgrade to Xcode 3.1.4
==> Build Environment
PATH: /Users/lotus/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin
CFLAGS: -O3 -march=nocona -mfpmath=sse -w -pipe
MAKEFLAGS: -j2
CC: /usr/bin/cc
CXX: /usr/bin/c++
==> Downloading http://google-perftools.googlecode.com/files/google-perftools-1.4.tar.gz
File already downloaded and cached to /Library/Caches/Homebrew
/usr/bin/tar xf /Library/Caches/Homebrew/google-perftools-1.4.tar.gz
$ racksh 14:17
Rack::Shell v0.9.7 started in development environment.
irb(main):001:0> /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/racksh-0.9.7/bin/racksh:22:in `wait': Interrupt
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/racksh-0.9.7/bin/racksh:22
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/racksh-0.9.7/bin/racksh:16:in `loop'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/racksh-0.9.7/bin/racksh:16
from /opt/ruby-enterprise/bin/racksh:19:in `load'
from /opt/ruby-enterprise/bin/racksh:19
$ sudo /etc/init.d/redis start
mlotkowski@blip-redis-1c:/var/redis/blip/current$ ./redis-cli info | grep used_memory
used_memory:1549176
used_memory_human:1.48M
mlotkowski@blip-redis-1c:/var/redis/blip/current$ grep Vm /proc/`cat /var/run/redis.pid`/status
VmPeak: 10560 kB
VmSize: 10432 kB
VmLck: 0 kB
VmHWM: 2240 kB
VmRSS: 2236 kB