Skip to content

Instantly share code, notes, and snippets.

@Epictetus
Epictetus / config.ru
Created March 1, 2012 22:27
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
# We are not loading Active Record, nor the Assets Pipeline, etc.
# This could also be in your Gemfile.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
require "rails"
@Epictetus
Epictetus / config.ru
Created March 1, 2012 22:24
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
# We are not loading Active Record, nor the Assets Pipeline, etc.
# This could also be in your Gemfile.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
require "rails"
@Epictetus
Epictetus / config.ru
Created March 1, 2012 12:01
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
require "rails"
# Let's load only action controller. If you want
# to use active record, just require it as well.
require "action_controller/railtie"
class MyApp < Rails::Application
module Core
def self.included(mod)
url = ENV['CORE_URL'] ? URI.parse(ENV['CORE_URL']) : URI.parse('postgres://postgres@localhost/heroku')
mod.establish_connection(
:adapter => "postgresql",
:host => url.host,
:username => url.userinfo.split(':')[0],
:password => url.userinfo.split(':')[1],
:database => url.path[1..-1]
)
@Epictetus
Epictetus / random_order.rb
Created February 27, 2012 18:51 — forked from willnet/random_order.rb
monkey patch to add random_order to ActiveRecord with multi DB driver
# for rails 3 or higher
module ActiveRecord
module Querying
delegate :random_order, :to => :scoped
end
module QueryMethods
def random_order
relation = clone

[ANN] Rails 3.2.2.rc1, 3.1.4.rc1, and 3.0.12.rc1 have been released!

Hi everyone,

I just released the following Rails release candidates:

  • 3.2.2.rc1
  • 3.1.4.rc1
  • 3.0.12.rc1
@Epictetus
Epictetus / ArduinoSide.c
Created February 12, 2012 20:35 — forked from hatone/ArduinoSide.c
Arduino+Ruby
int incomingByte = 0;
int ledPin = 13;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
@Epictetus
Epictetus / gist:1805192
Created February 11, 2012 23:53 — forked from novi/gist:1803875
Bundlerを使ってプロジェクトごとにGemを管理する
@Epictetus
Epictetus / Gemfile
Created February 11, 2012 01:22 — forked from gaygenius/Gemfile
Rails 3.2.1 Gemfile for Heroku with haml, rspec and backbone.js
source 'https://rubygems.org'
gem 'rails', '3.2.1'
gem 'haml-rails'
gem 'rails-backbone'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
#!/usr/bin/env ruby
# usage
# $ $(export_heroku_config.rb | grep OAUTH)
config = `heroku config`
config.split(/[\r\n]/).each do |line|
key, value = line.chomp.split(/\s+=>\s+/)
puts "export #{key}=#{value}"
end