Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'capybara'
require 'capybara/dsl'
# Yeah Capybara is overkill... YEAH!
Capybara.run_server = false
Capybara.current_driver = :selenium
class Numeric
def add y
@plehoux
plehoux / gist:5580089
Last active December 17, 2015 08:29
Small rake task for a better customer support chat experience with HipChat. Hide link to your support chat room if nobody is there to help. No CHAT ROOM is better than an empty one.
desc 'Update Chat Status'
namespace :scheduler do
task :update_chat_status => :environment do
begin
# Connect to HipChat
hc = HipChat::API.new(HIPCHAT_API_KEY)
# Fetch your support chat room id
room_id = hc.rooms_list['rooms'].find{|r| r['name'] =~ /conferencebadge\.com/i}['room_id']
# Fetch users in room
@plehoux
plehoux / cachemire.rb
Last active December 24, 2015 00:09
ActiveRecord extension to cache the result of a compute-intensive method inside a store.
module Cachemire
extend ActiveSupport::Concern
module ClassMethods
def cache_method(name, &block)
store_accessor :cache, name
instance_eval do
define_method name, &cache_wrap(&block)
end
end

Assuming this SMS:

From: +1555666777
TO: +1222333444
Body: Nice to meet you.
Received at: 03 April 2024, 2:12:13

The body of the POST request to /posts should be: