Skip to content

Instantly share code, notes, and snippets.

View syntaxritual's full-sized avatar

Travis Anderson syntaxritual

View GitHub Profile
@syntaxritual
syntaxritual / gist:5489417
Created April 30, 2013 15:20
usage: `harvest syntaxritual` optional: give it a starting date `harvest syntaxritual 2013-04-20`
harvest() {
dow=$(date "+%u")
if [ -n "$2" ]; then
date=$2
else
if [ $dow = "1" ]; then
date=$(date -v-mon -v -1w "+%Y-%m-%d 00:00:00")
else
date=$(date -v-mon "+%Y-%m-%d 00:00:00")
fi
user app;
worker_processes 2;
error_log /home/app/logs/nginx.error.log info;
events {
worker_connections 1024;
}
# Deploying a Sinatra app to Heroku
## Database
The location of the database Heroku provides can be found in the environment
variable DATABASE_URL. Check the configure-block of toodeloo.rb for an example
on how to use this.
## Server
Heroku is serving your apps with thin, with means you have all your thin goodness available,
such as EventMachine.
def partial(template, locals={})
haml("_#{template}".to_sym, :locals => locals, :layout => false)
end
def errors_on(object, field)
return "" unless errors = object.errors.on(field)
errors.map {|e| e.gsub(/#{field} /i, "") }.join(", ")
end
def error_class(object, field)
# gem install eventmachine
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/opt/rubyenterprise/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... no
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
# gem install eventmachine
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/opt/rubyenterprise/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... no
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
## Pseudo auto-respond-to in Sinatra.
module Sinatra
module AutoRespondTo
def self.registered(app)
app.after do
case request.accept.first
when "application/json"
body { body.to_json }
when "application/xml"
-bash-3.00$ ruby -rrbconfig -e' puts Config::CONFIG.values.grep /-l/'
-lruby-static
-ldl -lcrypt -lm
-lruby-static
-lc
-DTEXT_DOMAIN="" -l/usr/sfw/include -l/usr/include
-bash-3.00$ gem install eventmachine -- --with-opt-lib=/lib
WARNING: Installing to ~/.gem since /usr/local/lib/ruby/gems/1.8 and
/usr/local/bin aren't both writable.
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb --with-opt-lib=/lib
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... no
require 'rubygems'
require 'eventmachine'
require 'socket'
module RPCServer
include EM::P::ObjectProtocol
def post_init
@obj = Hash.new
end
def receive_object method