Skip to content

Instantly share code, notes, and snippets.

@deadkarma
deadkarma / test.rb
Last active August 29, 2015 14:22 — forked from jamiehodge/test.rb
require "sinatra/base"
require "puma"
require "rack/handler/puma"
require "minitest/autorun"
require "net/http"
require "slim"
class App < Sinatra::Base
post "/" do
require 'zeus/rails'
class CustomPlan < Zeus::Rails
def sidekiq
# Based on bin/sidekiq
require 'sidekiq/cli'
begin
cli = Sidekiq::CLI.instance
cli.parse
@deadkarma
deadkarma / gist:3068841
Created July 8, 2012 01:07 — forked from jordan-brough/gist:1684779
Decode Rails session cookie
cookie = 'XXX--YYY'
ActiveSupport::MessageVerifier.new(Rails.application.config.secret_token).verify(cookie)
@deadkarma
deadkarma / default.rb
Created March 20, 2012 20:45 — forked from emachnic/default.rb
Chef recipe to write redis.yml on Engine Yard Cloud
# ey-cloud-recipes/cookbooks/redis-yml/recipes/default.rb
if ['app_master', 'app'].include?(node[:instance_role])
redis_instance = node['utility_instances'].find { |instance| instance['name'] == 'redis' }
if redis_instance
node[:applications].each do |app, data|
template "/data/#{app}/shared/config/redis.yml"do
source 'redis.yml.erb'
owner node[:owner_name]
@deadkarma
deadkarma / gist:1989808
Created March 6, 2012 23:39 — forked from rails/gist:58761
Calculate time_ago_in_words for javascript
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
// Takes a timestamp and converts it to a relative time
// DateHelper.time_ago_in_words(1331079503000)