View gist:3011108
redis-cli -n 1 KEYS "cache:property:offers*" | xargs redis-cli -n 1 DEL |
View newco-commit-msg
#!/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
"filters": { | |
"pending": "function(doc, req) { if(doc.status != 'forwarded') { return true; } else { return false; }}" | |
} |
View gist:787765
"unprocessed" : { | |
"map" : "function(doc){ if(!doc.status) { emit(doc.requested_at, doc.text) } }" | |
} |
View gist:787763
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
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
db.get(id)[:status] |
View gist:787753
{ | |
"_id": "2c698404172067bf64c5be5daf5b4c4a", | |
"_rev": "1-5d0c994e3f4626e9e944977cc121b9d4", | |
"text": "first message", | |
"requested_at": "2011/01/17 09:54:17 +0000", | |
"priority": "medium" | |
} |
View gist:787751
CouchRest.database("http://localhost:5984/messages") | |
db.save_doc({text: "first message", requested_at: Time.now, priority: "medium"}) |
View gist:739583
# 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