Skip to content

Instantly share code, notes, and snippets.

View neophiliac's full-sized avatar

Kurt Sussman neophiliac

View GitHub Profile

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?

create_table "permits", :force => true do |t|
t.string "number", :null => false
t.string "name", :null => false
t.string "agency_project"
t.integer "contact_id"
t.string "category"
t.string "when_req"
t.string "owner"
permit_data:
#!/usr/bin/env ruby
#
# Originally written by http://redartisan.com/tags/csv
# Added and minor changes by Gavin Laking
# more changes by Kurt Sussman (don't expect 'id' in col#1, no attribute if no data)
#
# "id","name","mime_type","extensions","icon_url"
# "1","unknown","unknown/unknown","||","/images/icon/file_unknown.gif"
# "2","image/tiff","image/tiff","|tiff|tif|","/images/icon/blank.png"
#
def extract_model_name(controller_class); controller_class.to_s.match(/(.+)Controller/)[1]; end
def model(controller_class); extract_model_name(controller_class).singularize.constantize; end
def symbol_for_model(controller_class, options = {})
tablename = extract_model_name(controller_class).tableize
options[:pluralize] ? tablename.to_sym : tablename.singularize.to_sym
end
describe "an ordinary 'show' action", :shared => true do
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'
@neophiliac
neophiliac / gist:1069992
Created July 7, 2011 17:05
CSV link in Rails
View:
#block
%h3 Export
%ul{:class=>"horizontal"}
%li
- if controller.action_name == 'show'
= link_to "Open this Permit in Excel", permit_path(@item, :format => :csv)
- if controller.action_name == 'index'
= link_to "Open the list of Permits in Excel", permits_path(:format => :csv)
@neophiliac
neophiliac / build-nginx
Created October 2, 2011 17:18
build nginx with passenger and ssl
# run from inside nginx directory
./configure --prefix='/opt/nginx' --with-pcre='../pcre-8.12' \
--add-module='/usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.8/ext/nginx' \
--without-http_autoindex_module \
--without-http_ssi_module \
--with-openssl=../openssl-1.0.0d/ \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
@neophiliac
neophiliac / TechDecisions.md
Created November 30, 2011 19:43
Choices to make in a new Rails project. Would love to see this forked with other's opinions.

Team Support

Source Code Control

git (private server)
Alternative: github

Time Tracking

Cashboard

@neophiliac
neophiliac / .rubyconfig
Created July 9, 2012 05:57
Rails Dev Setup Ubuntu 11.10 rbenv
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=1000000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000
# in .bashrc:
#
# if [ -f ~/.rubyconfig ] ; then
# . ~/.rubyconfig
+auto.master
/net /etc/auto.nfs --ghost, --timeout=30