View gist:3011108
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
redis-cli -n 1 KEYS "cache:property:offers*" | xargs redis-cli -n 1 DEL |
View newco-commit-msg
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 | |
message_file = ARGV[0] | |
message = File.read(message_file) | |
$regex = /^\[(Extranet|API|Consumer)\]/ | |
if !$regex.match(message) | |
puts "COMMIT FAILED: your message doesn't start with [Extranet], [API] or [Consumer]" | |
exit 1 | |
end |
View gist:787825
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
"filters": { | |
"pending": "function(doc, req) { if(doc.status != 'forwarded') { return true; } else { return false; }}" | |
} |
View gist:787765
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
"unprocessed" : { | |
"map" : "function(doc){ if(!doc.status) { emit(doc.requested_at, doc.text) } }" | |
} |
View gist:787763
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
def handle_notification(notification) | |
message = JSON.parse(notification)['doc'] | |
Fiber.new { | |
result = despatch(message) # non-blocking | |
@db.save_doc(message.merge(status: "forwarded", result: result)) # blocking | |
}.resume | |
end | |
def despatch(message) | |
http = http_request({id: message['_id'], broadcast: message['text']}) |
View gist:787759
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
def run | |
EventMachine.run { | |
opts = { query: {feed: 'continuous', since: update_seq, heartbeat: 5000, filter: 'app/pending', include_docs: true} } | |
http = EventMachine::HttpRequest.new("#{DB_URL}/_changes").get opts | |
http.stream { |chunk| handle_notification(chunk) unless chunk =~ /^\n/ } | |
} | |
end |
View gist:787757
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
db.get(id)[:status] |
View gist:787753
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
{ | |
"_id": "2c698404172067bf64c5be5daf5b4c4a", | |
"_rev": "1-5d0c994e3f4626e9e944977cc121b9d4", | |
"text": "first message", | |
"requested_at": "2011/01/17 09:54:17 +0000", | |
"priority": "medium" | |
} |
View gist:787751
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
CouchRest.database("http://localhost:5984/messages") | |
db.save_doc({text: "first message", requested_at: Time.now, priority: "medium"}) |
View gist:739583
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
# Ripped from cucumber-0.8.3/examples/watir/features/support/screenshots.rb | |
module Screenshots | |
if Cucumber::OS_X | |
def embed_screenshot(id) | |
`screencapture -t png reports/#{id}.png` | |
embed("#{id}.png", "image/png") | |
end | |
else | |
def embed_screenshot(id) | |
`import -window root reports/#{id}.png` |
NewerOlder