Skip to content

Instantly share code, notes, and snippets.

Before:
new_user_registration GET /signup(.:format) {:action=>"new", :controller=>"invited_registrations"}
user_registration POST /signup(.:format) {:action=>"create", :controller=>"invited_registrations"}
complete_signup GET /signup/complete(.:format) {:action=>"new", :controller=>"registrations"}
complete_signup POST /signup/complete(.:format) {:action=>"create", :controller=>"registrations"}
After:
@hinke
hinke / Email worker
Created March 11, 2011 14:57
Our worker task for emails
desc 'Work email queue'
task :emails => :environment do
`if [ ! -d "pids" ]; then mkdir pids; fi; echo "#{Process.pid}" > #{Rails.root}/pids/emails.pid`
Minion.job "emails" do |args|
logger.info "[#{Time.now}] Recieved queued item"
begin
UserMailer.deliver(args)
rescue Exception => exception
logger.info "Error, #{exception}"
raise exception
@hinke
hinke / Yammerstrano.rb
Created August 11, 2011 11:00
A capistrano extension for sending deploy messages to yammer
Capistrano::Configuration.instance(:must_exist).load do
require 'httparty'
before "deploy", "yammer:notify_deploy_start"
after "deploy", "yammer:notify_deploy_success"
after "deploy:rollback", "yammer:notify_deploy_fail"
namespace :yammer do
desc "Notify a Yammer account that a deploy just started"
task :notify_deploy_start do
@hinke
hinke / send.js
Created August 2, 2012 09:20
Readmill send script
aavunction(window) {
var WIDGET_BASE_DOMAIN = 'https://widgets.readmill.com',
PLATFORM_BASE_DOMAIN = 'https://platform.readmill.com',
hasAutoTriggerProcessMarkersFired = false, doc = window.document;
/*
* Select most suitable method for getting all elements by tag name
* to support browsers that does not have getElementsByClassName
*/
function getElementsByClassName(clsName) {
@hinke
hinke / gist:3823496
Created October 2, 2012 21:43
Fetch headers from build image and do something
get '/travis/:id/status' do |id|
token = "token!!"
http = Net::HTTP.new('magnum.travis-ci.com', 443)
http.use_ssl = true
path = "/Readmill/#{id}.png?token=#{token}"
response = http.head(path, nil)
if response['Content-Disposition'].include?('failing')
@message = "The build failed."
@hinke
hinke / gist:4172534
Created November 29, 2012 23:06
Ruby Readmill oAuth methods
get '/auth/readmill' do
redirect "http://readmill.com/oauth/authorize?response_type=code&client_id=#{settings.readmill_client_id}&redirect_uri=#{settings.readmill_redirect}&scope=non-expiring"
end
get '/callback/readmill' do
token_params = {
:grant_type => 'authorization_code',
:client_id => settings.readmill_client_id,
:client_secret => settings.readmill_client_secret,
:redirect_uri => settings.readmill_redirect,
@hinke
hinke / gist:5070864
Last active December 14, 2015 10:18
A template to get started with OAuth 2.0 authentication with Readmill
set :readmill_client_id, "xxx"
set :readmill_client_secret, "xxx"
get '/auth' do
callback = "http://myapp.com/callback"
redirect "https://readmill.com/oauth/authorize?response_type=code&client_id=#{settings.readmill_client_id}&redirect_uri=#{callback}&scope=non-expiring"
end
get '/callback' do