This file contains hidden or 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
// Where 'fruits_field' is the id of the autocomplete field | |
// Note: Place this code after the smartAutoComplete() function | |
$('input#fruits_field').bind({ | |
lostFocus: function(e) { | |
// Grab any highlighted results | |
results = $('.smart_autocomplete_highlight'); | |
if (results && $(results[0]).text() != '') { | |
// Set the input's value to the selected result |
This file contains hidden or 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
@git_repo = "https://github.com/uhhuhyeah/rails3_template" | |
# Remove unwanted files | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "rm public/javascripts/rails.js" | |
run "rm app/views/layouts/application.html.erb" | |
# Grab standards gems | |
run "wget --no-check-certificate '#{@git_repo}/raw/master/Gemfile' -O Gemfile" |
This file contains hidden or 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
# Instructions for setting up a remote repo on Dropbox | |
# Assuming project/repo called 'myrepo' | |
cd ~/Dropbox | |
mkdir -p git/myrepo.git | |
cd !$ | |
git --bare init | |
cd ~/development/uhy/myrepo | |
git remote add dropbox file://$HOME/Dropbox/git/myrepo.git |
This file contains hidden or 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
// {section index, row index} | |
unsigned indexes[2] = {0,0}; | |
NSIndexPath *ip = [[[NSIndexPath alloc] initWithIndexes:indexes length:2] autorelease]; |
This file contains hidden or 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/indexer --config /data/loc/current/config/production.sphinx.conf --rotate --all |
This file contains hidden or 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
ps -ef | grep " process or pid " | grep -v grep |
This file contains hidden or 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
- (NSString *)ordinalize:(NSInteger)number{ | |
if (number >= 11 && number <= 13) | |
return [NSString stringWithFormat:@"%dth",number]; | |
switch (number % 10) { | |
case 1: | |
return [NSString stringWithFormat:@"%dst",number]; | |
case 2: | |
return [NSString stringWithFormat:@"%dnd",number]; | |
case 3: | |
return [NSString stringWithFormat:@"%drd",number]; |
This file contains hidden or 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 User < ActiveRecord::Base | |
def to_xml(options={}) | |
options[:only] = [:id, :name, :other_attr] | |
super(options) | |
end | |
end |
This file contains hidden or 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
# lives in config/initializers/ | |
def recursive_symbolize_keys!(hash) | |
hash.symbolize_keys! | |
hash.values.select{|v| v.is_a? Hash}.each{|h| recursive_symbolize_keys!(h)} | |
end | |
AppSettings = YAML.load_file("#{Rails.root}/config/settings.yml")[Rails.env] | |
recursive_symbolize_keys!(AppSettings) |
This file contains hidden or 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
NSString *tz = [[NSTimeZone localTimeZone] name]; | |
// Or ... | |
NSString *tz = [[NSTimeZone localTimeZone] localizedName:NSTimeZoneNameStyleShortDaylightSaving locale:[NSLocale currentLocale]]; // Returns @"PST" etc |