Skip to content

Instantly share code, notes, and snippets.

View mperham's full-sized avatar

Mike Perham mperham

View GitHub Profile
diff --git a/lib/starling/handler.rb b/lib/starling/handler.rb
index 4ab2960..1bde8ac 100644
--- a/lib/starling/handler.rb
+++ b/lib/starling/handler.rb
@@ -56,6 +56,7 @@ STAT queue_%s_age %d\r\n".freeze
SHUTDOWN_COMMAND = /\Ashutdown\r\n/m
+ QUIT_COMMAND = /\Aquit\r\n/m
diff --git a/vendor/plugins/geokit/lib/geo_kit/acts_as_mappable.rb b/vendor/plugins/geokit/lib/geo_kit/acts_as_mappable.rb
index c6c5eba..23dbab1 100644
--- a/vendor/plugins/geokit/lib/geo_kit/acts_as_mappable.rb
+++ b/vendor/plugins/geokit/lib/geo_kit/acts_as_mappable.rb
@@ -377,20 +377,22 @@ module GeoKit
lat = deg2rad(origin.lat)
lng = deg2rad(origin.lng)
multiplier = units_sphere_multiplier(units)
- case connection.adapter_name.downcase
- when "sqlite"
require 'rubygems'
gem 'rails', '2.2.2'
gem 'json', '1.1.3' # or json_pure, both break
# Switch these requires and it works
require 'json'
require 'activesupport'
data = { :a => [1,2,3] }
puts data.to_json
@mperham
mperham / gist:82548
Created March 20, 2009 19:59
Compile and run it. :-)
#include <stdio.h>
main(t,_,a)
char *a;
{
return!0<t?t<3?main(-79,-13,a+main(-87,1-_,main(-86,0,a+1)+a)):
1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?
main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l+,/n{n+,/+#n+,/#\
;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l\
q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;#\
def get_server_for_key(key)
raise ArgumentError, "illegal character in key #{key.inspect}" if key =~ /\s/
raise ArgumentError, "key too long #{key.inspect}" if key.length > 250
raise MemCacheError, "No servers available" if @servers.empty?
# Ignores server weights, oh well
srvs = self.servers.dup
srvs.size.times do |try|
n = rand(srvs.size)
server = srvs[n]
# Page scoring scenario
# Global Constants
page_link_e = 0.775
page_link_u = 0.1
entry_link_e = 0.65
entry_link_u = 0.2
atomicity = 0.1
page 'a' do
# define (e, u) for the entry link to this page
Running svn update with 1.6.1 OSX binary (http://www.open.collab.net/downloads/community/):
real 0m34.969s
user 0m0.627s
sys 0m0.257s
Running svn update with 1.4.4 (OSX Leopard stock):
real 0m17.813s
user 0m0.697s
# I assume this is valid UTF-8 encoded JSON
valid_json = '{
"status": "ok",
"articles": [
{
"url": "http://www.idiomag.com/peek/85310/pearl_jam",
"confidence": 0.018548,
"published_datetime": "2009-06-02T12:04:19Z",
"zemified": 0,
"title": " Pearl Jam Debut \u00e2\u0080\u009cBackspacer\u00e2\u0080\u009d Track, Cover Art on Conan O\u00e2\u0080\u0099Brien\u00e2\u0080\u0099s \u00e2\u0080\u009cTonight Show\u00e2\u0080\u009d "
>> foo? = 1
SyntaxError: compile error
(irb):1: syntax error, unexpected '=', expecting $end
foo? = 1
^
from (irb):1
>> def foo?
>> 1
>> end
=> nil
require 'net/http'
require 'cgi'
require 'json'
# The Bossman is in charge, mon.
class Bossman
def search(terms='iphone 3gs')
query = CGI::escape(terms)
path = "/ysearch/news/v1/#{query}"