Skip to content

Instantly share code, notes, and snippets.

View mech's full-sized avatar
🏠
Working from home

mech mech

🏠
Working from home
  • Career Pacific / Jobline
  • Singapore, Tampines
View GitHub Profile
@mech
mech / gist:1016766
Created June 9, 2011 13:53 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@mech
mech / pre-commit
Created September 6, 2011 04:56 — forked from UnderpantsGnome/pre-commit
My pre-commit hook
#!/bin/bash
debug=`git diff --cached | grep -C 2 -E '+\s*And (open|show me the page)'`
conflicts=`git diff --cached | grep -C 2 -E '<<<|>>>'`
if [ -n "$debug" ]; then
echo "debugging statements added in this commit"
echo $debug
fi
@mech
mech / gist:1228660
Created September 20, 2011 08:43 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@mech
mech / rails_test_engine_cucumber.markdown
Created September 22, 2011 06:10 — forked from chrisgaunt/rails_test_engine_cucumber.markdown
Rails 3.1: Test engine with Cucumber & test/dummy app

Run from the root of the engine project:

rails generate cucumber:install --capybara

Edit features/support/env.rb and add to the top:

ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../../../test/dummy/config/environment.rb",  __FILE__)
ENV["RAILS_ROOT"] ||= File.dirname(__FILE__) + "../../../test/dummy"
@mech
mech / gist:1422318
Created December 2, 2011 08:22 — forked from maccman/gist:1232164
Mobile Safari viewport sizes on iOS 4.3 and 5
iPad
1024 × 690 In landscape on iOS 4.3
1024 × 672 In landscape on iOS 5
768 × 946 In portrait on iOS 4.3
768 × 928 In portrait on iOS 5
1024 × 660 Always showing bookmarks bar in landscape on iOS 4.3
1024 × 644 Always showing bookmarks bar in landscape on iOS 5
768 × 916 Always showing bookmarks bar in portrait on iOS 4.3
@mech
mech / mobile.coffee
Created December 6, 2011 09:36
Mobile application inspired by Spine Mobile, SproutCore, Backbone.js and iOS
class Jobline extends UI.Application
constructor: ->
new NavigationController()
@start
start: ->
class UI.NavigationController
headerLeftButton: nil
module Archives
module Callbacks
def self.included(base)
base.send :include, Archives::Callbacks::InstanceMethods
base.before_create :do_something_awesome
end
module InstanceMethods
private
@mech
mech / hideaddrbar.js
Created January 23, 2012 07:02 — forked from scottjehl/hideaddrbar.js
Normalized hide address bar for iOS & Android
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){
@mech
mech / anonymizer_source.rake
Created February 26, 2012 11:56 — forked from adarsh/anonymizer_source.rake
Code from blog post on anonymizing sensitive user data
task :env_checker do
unless Rails.env.development?
puts "Not in development environment, exiting!"
exit 1
end
end
namespace :app_name do
desc 'Anonymize user, company, and location information'
task :anonymize => [:environment, :env_checker] do
@mech
mech / gist:1936785
Created February 29, 2012 01:22 — forked from metaskills/gist:1932882
Custom Sass Mixin To Supplement Compass' Transition Tools
@mixin animation (
$name: false,
$duration: false,
$timing_function: false,
$delay: false,
$iteration_count: false,
$direction: false
) {
@if $name { -webkit-animation-name: $name; -moz-animation-name: $name; -ms-animation-name: $name; }
@if $duration { -webkit-animation-duration: $duration; -moz-animation-duration: $duration; -ms-animation-duration: $duration; }