Skip to content

Instantly share code, notes, and snippets.

View jtoy's full-sized avatar

jtoy

View GitHub Profile
@jtoy
jtoy / gist:21816
Created November 3, 2008 06:48
macruby debugging!
#0 0x91745aa7 in CFStringGetLength ()
#1 0x00297ea8 in rb_str_split_m ()
#2 0x002be165 in call_cfunc ()
#3 0x002cea93 in vm_call_method ()
#4 0x002c432e in vm_eval ()
#5 0x002ca8ab in vm_eval_body ()
#6 0x002d386d in rb_yield ()
#7 0x001cdfd5 in rb_ary_each ()
#8 0x002cea93 in vm_call_method ()
#9 0x002c432e in vm_eval ()
= error_messages_for :grammar_rule, :id => "error"
- form_for(@grammar_rule) do |f|
%div
About Rule
= f.text_field :title
%div
About language
=f.select :language_id,@languages.map{|x| [t(x), x.id] }
- f.fields_for :explanations do |e|
%div
(defvar *emacs-load-start* (current-time))
(add-to-list 'load-path "~/lib/slime-2.0/") ; your SLIME directory
(setq inferior-lisp-program "/usr/local/bin/sbcl") ; your Lisp system
(require 'slime)
(slime-setup)
(add-to-list 'load-path "/opt/local/share/emacs/site-lisp/")
;(require 'ecb)
(require 'ecb-autoloads)
(add-to-list 'load-path "~/.emacs.d/fuzzy-find-in-project")
(require 'fuzzy-find-in-project)
@jtoy
jtoy / newpost.rb
Created August 20, 2009 02:20 — forked from al3x/newpost.rb
#!/usr/bin/env ruby
unless ARGV[0]
puts 'Usage: newpost "the post title"'
exit(-1)
end
date_prefix = Time.now.strftime("%Y-%m-%d")
postname = ARGV[0].strip.downcase.gsub(/ /, '-')
post = "#{Dir.pwd}/_posts/#{date_prefix}-#{postname}.textile"
require 'compass'
require 'ninesixty'
# If you have any compass plugins, require them here.
Sass::Plugin.on_updating_stylesheet do |template, css|
puts "Compiling #{template} to #{css}"
end
puts 'xxxx'
Compass.configuration do |config|
config.project_path = RAILS_ROOT
config.sass_dir = "app/stylesheets"
class Foo
def self.create(options = {})
if options[:queue]
self.instance_eval do
def queue
#{options[:queue].to_sym}
end
end
end
extract_data = Proc.new {|x| "path/#{x['description'].gsub(/[\r\n]+/," ")}\n" }
json['lists'].each do |x|
s = extract_data(x).call
puts s
end
@jtoy
jtoy / gist:839018
Created February 22, 2011 17:25
no reconnect?
class TwitterStream < EventMachine::Connection
def self.connect
EventMachine::HttpRequest.new("http://stream.twitter.com/1/statuses/filter.json").post({
:body =>{'track' => 'hello,world,how,are,you'},
:head => { 'Authorization' => [ 'user','pass' ] }
})
end
def on_error &block
puts "reconnecting"
reconnect
require 'em-http'
EM.run do
def dispatch(opts)
opts
puts opts
h = EM::HttpRequest.new(opts[:uri]).get
h.callback { |rep| opts[:cb].call(rep) if opts[:cb] }
@jtoy
jtoy / gist:1494874
Created December 19, 2011 00:00
kill em / redis / bloomfilter
require 'redis'
require 'redis/connection/synchrony'
require "em-synchrony/fiber_iterator"
require 'bloomfilter-rb'
max = 10_000
EM.synchrony do
LBF = BloomFilter::Redis.new(:size => max, :hashes => 2, :seed => 1,:namespace => "test")
process_queue = lambda do
Fiber.new{