Skip to content

Instantly share code, notes, and snippets.

View diegofigueroa's full-sized avatar

Diego Figueroa diegofigueroa

View GitHub Profile
module God
module Conditions
class RestartFileTouched < PollCondition
attr_accessor :restart_file
def initialize
super
end
def process_start_time
Time.parse(`ps -o lstart -p #{self.watch.pid} --no-heading`)
@wbailey
wbailey / databases.rake
Created February 11, 2011 08:58
ActiveRecord migrations outside of Rails
require 'yaml'
require 'logger'
require 'active_record'
namespace :db do
def create_database config
options = {:charset => 'utf8', :collation => 'utf8_unicode_ci'}
create_db = lambda do |config|
ActiveRecord::Base.establish_connection config.merge('database' => nil)
@lfborjas
lfborjas / proxy.ru
Created September 10, 2011 03:54
Simple proxy server for developing front-ends for APIs (using rack middleware)
require 'rack'
require 'rack/proxy' #gem install rack-proxy
class Proxy < Rack::Proxy
def rewrite_env(env)
env["HTTP_HOST"] = "my.host.com"
env["SERVER_PORT"] = "80"
env
end
end
@adelevie
adelevie / parse_resource.rb
Created December 16, 2011 21:27
parse_resource ORM adapter for Devise
#require 'orm_adapter/adapters/mongo_mapper'
module Devise
module Orm
module ParseResource
extend ActiveSupport::Concern
included do
extend Devise::Models
extend Devise::Orm::ParseResource::Hook
@bradrobertson
bradrobertson / Procfile
Created February 6, 2012 16:01
Less than ideal solution for launching different apps from one codebase on Heroku
web: bundle exec $APP
@ahoward
ahoward / tail-f.rb
Created March 7, 2012 16:44
completely k.i.s.s technique to do realtime log tailing in a live rails' app from the browser
### blogged @ http://dojo4.com/blog/easy-cheasy-realtime-log-tailing-in-a-rails-admin-view
### the su controller action
def logs
log = File.join(Rails.root, "log", "#{ Rails.env }.log")
@lines = `tail -1024 #{ log }`.split(/\n/).reverse
@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 24, 2024 17:56
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@tony4d
tony4d / p4merge4git.md
Created August 24, 2012 19:00
Setup p4merge as a visual diff and merge tool for git
@brobertsaz
brobertsaz / serversetup.md
Last active July 6, 2020 08:56
Ubuntu 12.04 Ruby, Rails, Nginx, Unicorn

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key