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
class Time | |
def self.parse(string) | |
date_formatter = NSDateFormatter.alloc.init | |
date_formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'" | |
date_formatter.dateFromString string | |
end | |
def self.ago_in_words(seconds) | |
return "" unless seconds | |
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
λ ruby notifier.rb | |
DEPRECATION WARNING: Yajl::HttpStream is going to be removed in 2.0 | |
- Listening room 543389 | |
- Listening room 543383 | |
D, [2012-12-19T15:31:03.438930 #12265] DEBUG -- : Terminating 6 actors... | |
{"room_id"=>543389, "created_at"=>"2012/12/19 14:30:00 +0000", "body"=>nil, "starred"=>false, "id"=>763740860, "user_id"=>nil, "type"=>"TimestampMessage"} | |
{"room_id"=>543389, "created_at"=>"2012/12/19 14:31:38 +0000", "body"=>"j'ai une piste Étienne Barrié", "starred"=>false, "id"=>763740861, "user_id"=>1320888, "type"=>"TextMessage"} | |
{"room_id"=>543389, "created_at"=>"2012/12/19 14:32:03 +0000", "body"=>"pour l'upload", "starred"=>false, "id"=>763741181, "user_id"=>1320888, "type"=>"TextMessage"} | |
{"room_id"=>543389, "created_at"=>"2012/12/19 14:32:10 +0000", "body"=>"yes", "starred"=>false, "id"=>763741282, "user_id"=>1320885, "type"=>"TextMessage"} | |
{"room_id"=>543389, "created_at"=>"2012/12/19 14:32:17 +0000", "body"=>"faudrait bootstraper ça ou changer de plugin", "starred"=>false, "id"=>763741371, "u |
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 "uri" | |
require "yajl/http_stream" | |
require "terminal-notifier" | |
require "celluloid" | |
class Stream | |
include Celluloid | |
def initialize(room, token) | |
@room = room |
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 "uri" | |
require "yajl/http_stream" | |
require "terminal-notifier" | |
token = TOKEN | |
room_id = ID | |
url = URI.parse("http://#{token}:x@streaming.campfirenow.com/room/#{room_id}/live.json") | |
regexp = Regexp.new('julien', true) |
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 'url) | |
(require 'json) | |
(defvar url-http-end-of-headers) | |
(defun github-response (buf) | |
"Extract the JSON response from BUF." | |
(with-current-buffer buf | |
(goto-char url-http-end-of-headers) | |
(prog1 (json-read) |
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
Running all specs | |
No DRb server is running. Running in local process instead ... | |
/Users/julien/Code/resque-waiting-room/lib | |
/Users/julien/Code/resque-waiting-room/spec | |
/Users/julien/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/resque-1.19.0/lib | |
/Users/julien/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/vegas-0.1.11/lib | |
/Users/julien/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sinatra-1.3.2/lib | |
/Users/julien/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/lib | |
/Users/julien/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/redis-namespace-1.0.3/lib | |
/Users/julien/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/redis-2.2.2/lib |
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
#!/bin/bash | |
for (( c=1; c<=1500; c++ )) | |
do | |
echo "$c..." | |
resp=`curl -s "https://graph.facebook.com/10376464573_10150506967464574?access_token=AAAEZAOdBVBEMBALFr4vf4peDD040epZClBXPqP0cZC2yvYx0BGQ0tAng7unxu4bzJ10zNzVM7VqdAIxYftZByv0vUafyZAGJ4RryFZCkPDX1UCgi4kpZA2s&fields=shares"` | |
echo $resp | |
done |
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
Ruby 1.9.3 & Rails 3.1.2 | |
before: | |
script/rails runner "Segment" 5,79s user 1,02s system 53% cpu 12,712 total | |
script/rails runner "Person" 6,11s user 0,88s system 94% cpu 7,364 total | |
after: | |
script/rails runner "Segment" 5,51s user 0,89s system 91% cpu 6,998 total | |
script/rails runner "Person" 5,24s user 0,79s system 99% cpu 6,068 total |
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
MAP_FUNCTION = <<EOF | |
function(){ | |
for(like in this.fb_likes){ | |
var domainRegExp = new RegExp(/^http(?:s)?\:\/\/([a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3})\/\S*?$/); | |
if(like.fb_url){ var domain = domainRegExp.exec(like.fb_url); } | |
if(domain && domain != 'www.facebook.com'){ | |
emit(domain, {count: 1}); | |
} | |
} | |
} |
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 'eventmachine' | |
require 'em-http' | |
require 'json' | |
require 'bson' | |
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db("bieber") | |
end |