Skip to content

Instantly share code, notes, and snippets.

View idyll's full-sized avatar
👾
pushing bits.

Mark Madsen idyll

👾
pushing bits.
View GitHub Profile
@kennethkalmer
kennethkalmer / daemon-kit-engine.rb
Created July 10, 2009 22:19
Example for using ruote & daemon-kit together
#
# Requirements:
# * ruote-2.1.10 or later
# * ruote-amqp-2.1.10 or later
# * daemon-kit-0.1.8rc3 or later
#
require 'rubygems'
require 'ruote'
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@shripadk
shripadk / gist:652819
Created October 29, 2010 03:10
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
@aeden
aeden / api_steps.rb
Created November 30, 2010 12:47
Steps for testing API endpoints with Cucumber
# Requires nokogiri and jsonpath
# Only works with rack test
World(Rack::Test::Methods)
# Feel free to customize this for whatever API auth scheme you use
Given /^I am a valid API user$/ do
user = Factory(:user)
authorize(user.email, user.password)
end
@zapnap
zapnap / iam_fog.rb
Created March 2, 2011 20:24
Using Amazon IAM with Fog (example)
require 'fog'
username = 'testuser'
bucket = 'uniquebucketname1234'
aws_credentials = {
:aws_access_key_id => 'YOUR-ACCESS-KEY-ID',
:aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY'
}
@mattetti
mattetti / fsevents.rb
Created March 18, 2011 07:19
FSEvents API implementation in MacRuby
if RUBY_ENGINE == 'macruby'
framework 'CoreServices'
WATCHED_EXTS = "rb,builder,erb,nokogiri"
PASSENGER_RESTART_FILE = File.expand_path(File.join(File.dirname(__FILE__), "..", "tmp", "restart.txt"))
DELAY = 3
def modified_files(path)
Dir.glob("#{File.expand_path(path)}/*.{#{WATCHED_EXTS}}").map do |filename|
begin
@rdj
rdj / active_admin.rb
Created July 1, 2011 06:39
active_admin custom filter
# config/initializers/active_admin.rb
require 'active_admin_custom_filter'
ActiveAdmin.setup do |config|
# ...
end
require 'pdf-reader'
#doc = PDF::Reader.new(File.expand_path('~/Desktop/note-example.pdf'))
doc = PDF::Reader.new(File.expand_path('./book-mw-read-thru.pdf'))
$objects = doc.objects
def is_note?(object)
object[:Type] == :Annot && object[:Subtype] == :Text
end
@josevalim
josevalim / 1_README.md
Created December 13, 2011 09:30
FSSM based FileWatcher for Rails

Rails 3.2 ships with a simple FileWatcher that only reloads your app if any of the files changed.

Besides, it also provides a mechanism to hook up your own file watcher mechanism, so we can use tools like FSSM that hooks into Mac OS X fsevents. This is an example on how to hook your own mechanism (you need Rails master, soon to be Rails 3.2):

  1. Copy the 2_file_watcher.rb file below to lib/file_watcher.rb

  2. Add the following inside your Application in config/application.rb

if Rails.env.development?

@alloy
alloy / heroku.rake
Created February 1, 2012 15:36
Some simple Heroku deploy rake tasks.
namespace :heroku do
namespace :deploy do
task :tag do
rev = `git rev-parse HEAD`.strip
if `git describe --contains #{rev} 2>&1`.include?('cannot describe')
version = Time.new.strftime("%Y%m%d%H%M%S")
sh "git tag -a heroku-#{version} -m 'Deploy version to Heroku: #{version}'"
sh "git push origin master"
sh "git push origin master --tags"
else