Skip to content

Instantly share code, notes, and snippets.

View uhhuhyeah's full-sized avatar

David A McClain uhhuhyeah

View GitHub Profile
@uhhuhyeah
uhhuhyeah / ie_hack.js
Created April 8, 2011 18:21
Work around for select not working in laktek / jQuery-Smart-Auto-Complete in IE browsers
// 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
@uhhuhyeah
uhhuhyeah / template.rb
Created February 26, 2011 03:58
Gemfile for template
@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"
@uhhuhyeah
uhhuhyeah / dropbox-and-git.sh
Created November 29, 2010 23:31
Use Dropbox as a remote git repo
# 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
@uhhuhyeah
uhhuhyeah / custom_nsindexpath.m
Created November 24, 2010 00:55
How to create an index path
// {section index, row index}
unsigned indexes[2] = {0,0};
NSIndexPath *ip = [[[NSIndexPath alloc] initWithIndexes:indexes length:2] autorelease];
@uhhuhyeah
uhhuhyeah / loc_searchd_kick.sh
Created November 19, 2010 23:55
Useful in giving search on LOC a kick
/usr/bin/indexer --config /data/loc/current/config/production.sphinx.conf --rotate --all
ps -ef | grep " process or pid " | grep -v grep
- (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];
class User < ActiveRecord::Base
def to_xml(options={})
options[:only] = [:id, :name, :other_attr]
super(options)
end
end
# 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)
NSString *tz = [[NSTimeZone localTimeZone] name];
// Or ...
NSString *tz = [[NSTimeZone localTimeZone] localizedName:NSTimeZoneNameStyleShortDaylightSaving locale:[NSLocale currentLocale]]; // Returns @"PST" etc