Skip to content

Instantly share code, notes, and snippets.

Jon Kinney jondkinney

Block or report user

Report or block jondkinney

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:8759068
MyExceptions = [RangeError, RegexpError, IOError].freeze
begin
raise IOError, "should be rescued"
rescue *MyExceptions => e
puts e
end
View auto_annotate_models.rake
# Run annotate task after db:migrate
# and db:rollback tasks
Rake::Task['db:migrate'].enhance do
Rake::Task['annotate'].invoke
Rake::Task['db:test:prepare'].invoke
end
Rake::Task['db:rollback'].enhance do
Rake::Task['annotate'].invoke
Rake::Task['db:test:prepare'].invoke
View digitalocean.md

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

View placeholder_behavior.js
// To get this code to work, simply add a placeholder attribute to any of your inputs.
// This code requires no-conflict jQuery (var $j = jQuery.noConflict();) and Modernizr.
// Also you should add something similar to the following to your stylesheets.
//
// .placeholder{
// color: #666;
// }
jQuery.fn.set_placeholder = function() {
if ($j(this).attr('placeholder') && ($j(this).val() == '' || $j(this).val() == $j(this).attr('placeholder'))) {
@jondkinney
jondkinney / will_paginate_init.rb
Created Apr 19, 2010
Allows will_paginate to work with the row_number function for both normal pagination and when passed custom sql through the paginate_by_sql method
View will_paginate_init.rb
module ActiveRecord
module Associations
module ClassMethods
def construct_finder_sql_for_association_limiting(options, join_dependency)
scope = scope(:find)
# Only join tables referenced in order or conditions since this is particularly slow on the pre-query.
tables_from_conditions = conditions_tables(options)
tables_from_order = order_tables(options)
all_tables = tables_from_conditions + tables_from_order
View will_paginate_by_sql_initializer.rb
#NOTE: jonk (04/14/2010) => monkey patching will_paginate for when paginate_by_sql is specified
require 'will_paginate/core_ext'
module WillPaginate
module Finder
module ClassMethods
def find_table_primary_key_columns(table_name)
@find_table_primary_key_columns_cache ||= {}
if @find_table_primary_key_columns_cache[table_name].nil?
table_name = table_name.split('.').last.delete("[]")
View webrat_open_page.rb
After do |scenario|
if scenario.status == :failed
save_and_open_page
end
end
module Webrat
module SaveAndOpenPage
def save_and_open_page
return unless File.exist?(Webrat.configuration.saved_pages_dir)
@jondkinney
jondkinney / presonus_uc_cleanup
Created Feb 16, 2011
Delete PreSonus UC Files on OS X 10.5 and 10.6
View presonus_uc_cleanup
on run {input, parameters}
-- Setup the list of the main files to be deleted
set searchList to {¬
POSIX file ("/Applications/Universal Control.app") as text, ¬
POSIX file ("/Applications/FireStudio Control Console.app") as text, ¬
POSIX file ("/Applications/FireControl.app") as text, ¬
POSIX file ("/Applications/FireStudio Lightpipe Mixer.app") as text, ¬
POSIX file ("/Applications/StudioLive.app") as text, ¬
POSIX file ("/Library/Application Support/PaeFireStudio") as text, ¬
@jondkinney
jondkinney / gist:828864
Created Feb 16, 2011
PreSonus UC Cleanup
View gist:828864
on run {input, parameters}
-- Setup the list of the main files to be deleted
set searchList to
POSIX file ("/Applications/Universal Control.app") as text, ¬
POSIX file ("/Applications/FireStudio Control Console.app") as text, ¬
POSIX file ("/Applications/FireControl.app") as text, ¬
POSIX file ("/Applications/FireStudio Lightpipe Mixer.app") as text, ¬
POSIX file ("/Applications/StudioLive.app") as text, ¬
POSIX file ("/Library/Application Support/PaeFireStudio") as text, ¬
@jondkinney
jondkinney / setup_textmate_rails_dev.md
Created Jun 16, 2011
Setup Textmate for Rails Dev on OS X
View setup_textmate_rails_dev.md

##Setup Textmate for Rails Dev on OS X

This guide was written by Jon Kinney for the Green Bay Ruby User Group. Jon works at Intridea and they graciously sponsor the Green Bay RUG meetings.

These guides were also partially completed using time from Intridea's SparkTime initiative which aims to give employees "outside projects" to work on during their normal work week.

If you find any issues with these suggestions please let me know. I've amassed these tips/tricks over several years of full time Rails development using Textmate but just because it works on my system doesn't always mean it will be problem free universally. Thanks to all the blog authors whose articles helped me learn Textmate over the years but whose links/posts I've lost or forgotten over time. If you have a cool Textmate tip or trick please post it in the comments!

You can’t perform that action at this time.