This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def presentAlert | |
alert = UIAlertView.new | |
# ... | |
textField = alert.textFieldAtIndex(0) | |
# *Only for this UITextField instance*, move the leftView 4 points to the right. | |
def textField.leftViewRectForBounds(bounds) | |
CGRectOffset(super, 4, 0) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backend.ApplicationSerializer = DS.RESTSerializer.extend({ | |
extractMeta: function(store, type, payload) { | |
store.metaForType(type, { | |
count: payload.count, | |
currentPage: payload.current_page, | |
pages: payload.pages | |
}); | |
delete payload.count; | |
delete payload.current_page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# A script to convert old Rails 1.x finder syntax, e.g. find(:all, ...) and find(:first, ...) | |
# to use where() and friends. | |
# gem install parser unparser | |
# cd path/to/rails_app | |
# ruby fix_find_by.rb | |
require 'parser/current' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Examples: | |
// | |
// button_to "Mark as unread", mark_as_unread_message_path(message), :method => :put, :class => "form_to_link" | |
// button_to "New Alert", new_alert | |
// | |
jQuery(document).ready(function($) { | |
jQuery('.form_to_link').each(function(el){ | |
var form = el.parents('form'); | |
form.after('<a href="' + form.attr('action') + '" class="button_link_to">' + form_to_link.attr('value') + '</a>'); | |
form.hide(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
# for a setup script see http://gist.github.com/32917 | |
PASSENGER=2.2.3 | |
REE="ruby-enterprise-1.8.6-20090610" | |
PREFIX=/opt/$REE | |
# git checkout of git://github.com/FooBarWidget/passenger.git | |
cd ~/passenger | |
git fetch origin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Three things to add: | |
# * before_filter call | |
# * action_has_layout? method (if you have one, combine them) | |
# * adjust_for_inline | |
# | |
class ApplicationController < ActionController::Base | |
# ... | |
before_filter :adjust_for_inline | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = Scott Chacon | |
email = schacon@gmail.com | |
[alias] | |
serve = !git daemon --reuseaddr --verbose --base-path=. --export-all ./.git | |
unstage = reset HEAD | |
lol = log --pretty=oneline --abbrev-commit --graph --decorate | |
branches = !git-branches | |
st = status | |
[gui] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~vp(master)> cat ~/.gitconfig | |
...SNIP... | |
[alias] | |
datetag = !git tag `date \"+%Y%m%d%H%M\"` | |
update = pull --rebase | |
commdiff = log --pretty=oneline --left-right | |
...SNIP... | |
~vp(master)> git commdiff master...staging | |
>bb569b9a8c70a61ecffd4def3ac5e460848e0f36 Merge branch 'master' into staging | |
>f95b7db13fb48b3b5e1c2c484d00909a89f468d5 bulk edit on search page is no longer experimental |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JsonHax | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
if env['CONTENT_TYPE'] == 'application/json' | |
env['CONTENT_TYPE'] = 'application/xml' | |
env['REQUEST_URI'].gsub!(/\.json/, '.xml') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias reload='. ~/.bashrc' | |
alias ea="$EDITOR ~/bin/dotfiles/bash/aliases && reload" | |
alias ee="$EDITOR ~/bin/dotfiles/bash/env && reload" | |
alias eh="$EDITOR ~/bin/dotfiles/bash/heroku && reload" | |
# Processes | |
alias tu='top -o cpu' | |
alias tm='top -o vsize' | |
# Projects |
OlderNewer