Skip to content

Instantly share code, notes, and snippets.

View safarista's full-sized avatar

Nelson Kelem safarista

View GitHub Profile
@siddharthbhagwan
siddharthbhagwan / Gemfile
Created February 4, 2014 11:02
Sample Implementation of Action Controller Live
source 'https://rubygems.org'
gem 'rails', '4.0.2'
gem "redis-rails", "~> 4.0.0"
gem 'puma'
gem 'unicorn'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
@ehoch
ehoch / Full Site SSL.md
Last active December 11, 2015 17:49
Full Site SSL in Spree

Curious how Alarm Grid went full site-wide SSL using Spree? Just create the one decorator below and you're good to go!

Note: This gist will not redirect .xml files so that our feeds do not error out on iPhones which do not support RSS feeds in https.

@runemadsen
runemadsen / app.rb
Created September 28, 2012 01:09
Creating a blog in Sinatra and Datamapper
require 'sinatra'
require 'dm-core'
DataMapper::setup(:default, {:adapter => 'yaml', :path => 'db'})
class BlogPost
include DataMapper::Resource
property :id, Serial
property :title, String
property :body, Text
@ryanb
ryanb / abilities.rb
Created September 15, 2012 19:23
How you can break up large Ability class in CanCan
module Abilities
def self.ability_for(user)
if user.admin?
AdminAbility.new(user)
else user
MemberAbility.new(user)
else
GuestAbility.new
end
end
@peterhellberg
peterhellberg / kick.rb
Created September 3, 2012 20:49
Tiny File System Event kicker
#!/usr/bin/env ruby
require 'rubygems'
require 'rb-fsevent'
cmd, *paths = ARGV
if cmd && paths.any?
system cmd
fsevent = FSEvent.new
fsevent.watch(paths) { system cmd }
fsevent.run
@peterhellberg
peterhellberg / Gemfile
Created April 10, 2012 11:51
Sinatra acceptance testing, using minitest/spec and capybara-webkit
source :rubygems
gem "sinatra", "~> 1.3.2"
group :test do
gem "minitest", "~> 2.10"
gem "rack-test", "~> 0.6.1"
gem "capybara", "~> 1.1"
gem "capybara-webkit", "~> 0.11"
gem "capybara_minitest_spec", "~> 0.2"
require "rubygems"
require "bundler/setup"
require "sinatra"
require "base64"
get "/" do
Base64.encode64(File.binread("image"))
end
@abevoelker
abevoelker / gist:2123152
Created March 19, 2012 18:32
concrete table inheritance
# app/models/wizard.rb
class Wizard
# shared instance methods go here
def self.all_visible_subwizards
descendants.entries.select{|d| d.visible?}.sort
end
end
# lib/wizard_fields.rb
@tomoconnor
tomoconnor / script.md
Created February 27, 2012 17:25 — forked from lucasmazza/script.md
Redis 2.2 Install on Ubuntu 10.04

Installation commands:

$ wget http://redis.googlecode.com/files/redis-2.2.2.tar.gz
$ tar xvfz redis-2.2.2.tar.gz 
$ cd redis-2.2.2/
$ mkdir -p /opt/redis
$ make PREFIX=/opt/redis install
$ cp redis.conf /opt/redis/redis.conf
$ sudo useradd redis
@peterc
peterc / irb3.rb
Created September 19, 2011 14:17
irb3 - Run an IRB-esque prompt over multiple Ruby implementations at once using RVM
#!/usr/bin/env ruby
# encoding: utf-8
# irb3 - Runs an IRB-esque prompt (but it's NOT really IRB!) over multiple
# versions of Ruby at once (using RVM)
#
# By Peter Cooper, BSD licensed
#
# Main dependency is term-ansicolor for each impl:
# rvm exec gem install term-ansicolor