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 / 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 ){
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 / 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
@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 / 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: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 / 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: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
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@mech
mech / gist:856362
Created March 5, 2011 13:46 — forked from sco/gist:832499
// UITextFieldDelegate method, called when the "Return" key is pressed.
// Either advance the cursor to the next empty field, or submit the form.
//
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if([usernameField.text length] == 0) {
[usernameField becomeFirstResponder];
} else if ([passwordField.text length] == 0) {
[passwordField becomeFirstResponder];
} else {