Skip to content

Instantly share code, notes, and snippets.

View nowk's full-sized avatar

Yung Hwa Kwon nowk

  • damncarousel
  • New York, NY
View GitHub Profile
locals: &locals
host: localhost
adapter: mysql
username: <username>
password: <password>
pool: 5
timeout: 5000
# socket: /Application/MAMP/tmp/mysql/mysql.sock
development:
@nowk
nowk / .rvmrc
Created April 18, 2012 18:12
Foreman Upstarting some Rubies
# server user ~/.rvmrc
export rvm_path="/path/to/users/.rvm"
export rvm_trust_rvmrcs_flag=1
@nowk
nowk / capistrano_database_yml.rb
Created April 17, 2012 21:31 — forked from weppos/capistrano_database_yml.rb
Provides a couple of tasks for creating the database.yml configuration file dynamically when deploy:setup is run.
#
# = Capistrano database.yml task
#
# Provides a couple of tasks for creating the database.yml
# configuration file dynamically when deploy:setup is run.
#
# Category:: Capistrano
# Package:: Database
# Author:: Simone Carletti <[email protected]>
# Copyright:: 2007-2010 The Authors
(1..100).each do |n|
puts case
when (n % 3) == 0
"Fizz"
when (n % 5) == 0
"Buzz"
when (n % 3) == 0 && (n % 5) == 0
"FizzBuzz"
else
n
@nowk
nowk / email_matchers.rb
Created March 21, 2012 23:56
Email matchers
RSpec::Matchers.define :be_from do |expected|
match do |actual|
actual.from_addrs.include?(expected)
end
failure_message_for_should do |actual|
%{expected to be from #{expected} but was from #{actual.from_addrs.join(', ')}}
end
failure_message_for_should_not do |actual|
@nowk
nowk / application.js
Created March 18, 2012 22:24
Formtastic errors w/ ajax + knockout.js and responds_to :json
$.ajax({
error: function(jqXHR, textStatus, errorThrown) {
// reset
$('.formtastic li').removeClass("error");
$('.formtastic li .inline-errors').remove();
// set the errors
// TODO turn into dynamic
// TODO include errors for :base and #semantic_errors
var errors = ko.mapping.toJS(ko.mapping.fromJSON(jqXHR.responseText));
@nowk
nowk / .vimrc
Created March 12, 2012 15:33
my (ugly) vimrc files
set shell=bash
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
@nowk
nowk / gist:1903463
Created February 24, 2012 20:16
Resource naming solutions
# Rails < 3
class CustomerLocation < ActiveRecord::Base
def self.model_name
ActiveSupport::ModelName.new("Location")
end
end
# ActiveSupport::ModelName is moved or deprecated after 3
@nowk
nowk / Gemfile
Created February 24, 2012 00:16
Most basic test gems
gem 'chronic'
group :development, :test do
gem "foreman"
# group :test do
# Pretty printed test output
gem 'turn', '0.8.2', :require => false
gem "capybara"
@nowk
nowk / email_matchers.rb
Created February 23, 2012 20:12
Simple custom matcher for emails against a "user" model
RSpec::Matchers.define :have_received_an_email do |expected|
def last_email
@last_email ||= ActionMailer::Base.deliveries.last
end
def inbox_size
ActionMailer::Base.deliveries.size
end
def to