Skip to content

Instantly share code, notes, and snippets.

View neophiliac's full-sized avatar

Kurt Sussman neophiliac

View GitHub Profile
#!/usr/bin/env bash
version="1.7.7"
pcre_version="8.36"
openssl_version="1.0.1j"
libressl_version="2.1.1"
pagespeed_version="1.9.32.1"
set -e

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

/home/vagrant/.rbenv/versions/1.9.3-p429/bin/ruby -S rspec ./spec/controllers/home_controller_spec.rb ./spec/helpers/application_helper_spec.rb ./spec/models/comment_spec.rb ./spec/models/email_parser_spec.rb ./spec/models/message_spec.rb ./spec/models/stories_paginator_spec.rb ./spec/models/story_repository_spec.rb ./spec/models/story_spec.rb ./spec/models/user_spec.rb ./spec/models/vote_spec.rb
/home/vagrant/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/activesupport-4.1.12/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- awesome_print (LoadError)
from /home/vagrant/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/active from /home/vagrant/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `block in load_spec_files'
from /home/vagrant/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `each'
from /home/vagrant/.rbenv/versio