Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View shad's full-sized avatar

Shad Reynolds shad

View GitHub Profile
@shad
shad / parse_date.rb
Created May 20, 2009 11:02
Ruby helper for parsing dates of an unknown format.
# ParseDate
#
# A helper for parsing dates of an unknown format.
#
# Takes a randomly formatted date and makes a best guess at the date, or throws and exception if
# there's no best guess. Will take international dates into account if you pass in a 'short form' date
# to help suggest a starting point for the search.
# Will also try Chronic parsing to get relative dates (yesterday, tomorrow, in 3 days, etc.)
#
# Examples:
(function () {
var mylib = {};
window.MYLIB = mylib;
});
@shad
shad / language_codes.js
Created October 13, 2009 15:28
Two letter language codes.
// from http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
(function () {
if (typeof LANGUAGE_CODES === 'undefined') {
window.LANGUAGE_CODES = [
{code:'aa', name:'Afar'},
{code:'ab', name:'Abkhazian'},
{code:'ae', name:'Avestan'},
{code:'af', name:'Afrikaans'},
{code:'ak', name:'Akan'},
{code:'am', name:'Amharic'},
@shad
shad / better-textmate-rspec-puts.rb
Created March 5, 2010 22:34
An Improved puts for rspec in Textmate.
# Improved "puts" in Textmate's version of rspec
if ENV['TM_MODE'] == 'RSpec'
alias :orig_puts :puts
def puts(str)
str = '[nil]' if str.nil?
str = '' if str.blank?
url, line = caller[0].split(":")
md = caller[0].match(/[\\\/]([^\\\/]*:\d+):(.*)/)
link_text = md[1]
title = md[2]
@shad
shad / jquery.setTimeout.js
Created December 15, 2010 03:53
Sometimes, it's useful to quickly set/clear a timeout that's attached to an element.
/*
* setTimeout
*
* Sometimes, we want to set a timeout and associate the timeout with
* an element. This is essential for operations that open menus, popups
* flyovers, etc.
*
* Shad Reynolds
* http://shad.github.com
*/
@shad
shad / app.js
Created March 8, 2011 05:32
Modal + NavGroup + TableView + Complex Rows = Crash
// Log info about the window and memory on close
function logClose(event) {
var closingWindow = event.source;
Ti.API.info('close window (' + closingWindow.title +') : ' + Ti.Platform.availableMemory);
}
// Create a row with a couple of subviews
function createRow(spec) {
var row = Ti.UI.createTableViewRow({
hasChild: true,
className:'foo'
@shad
shad / titanium-1.7.3.output
Created October 19, 2011 16:16
What I get when I try to build my app with Titanium 1.7.3
~/Library/Application\ Support/Titanium/mobilesdk/osx/1.7.3/iphone/builder.py simulator "4.2" "." 554UNEM399 "Meal Planning by Food on the Table" iphone | grep -v "^$"
File "/Users/shad/Library/Application Support/Titanium/mobilesdk/osx/1.7.3/iphone/builder.py", line 1325
if command in ['simulator', 'build']:
^
IndentationError: expected an indented block
rake aborted!
Command failed with status (1): [~/Library/Application\ Support/Titanium/mo...]
@shad
shad / gist:1367540
Created November 15, 2011 16:38
builder.py error
$~/Library/Application\ Support/Titanium/mobilesdk/osx/1.7.5/iphone/builder.py simulator "4.2" "." <MY-APP-ID> "My Cool App" iphone
...lines ommitted...
[INFO] Performing clean build
[ERROR] Error: Traceback (most recent call last):
File "/Users/shad/Library/Application Support/Titanium/mobilesdk/osx/1.7.5/iphone/builder.py", line 1093, in main
recompile = copy_tiapp_properties(project_dir)
File "/Users/shad/Library/Application Support/Titanium/mobilesdk/osx/1.7.5/iphone/builder.py", line 408, in copy_tiapp_properties
shutil.copy(os.path.join(project_dir, 'tiapp.xml'), assets_tiappxml)
@shad
shad / Rakefile
Created March 7, 2013 15:46
Simulate a really poor network connection on your mac (with support for pow.cx backend). Ex. If you expect your users to use your app in a place with poor network (like the meat department of your local grocery store), then this is a way for you to test that sort of connection. This is not scientific in anyway, just a guess.
# Simulate a really poor network connection on your mac (with support for pow.cx backend)
namespace :network do
task :status do
sh 'sudo ipfw show'
end
task :bad => [:good] do
# Add a new pipe
sh 'sudo ipfw add pipe 1 all from any to any'
# Configure the pipe to only do 50Kbit/s, with typical delays of 2000ms and 90% packet drop rate!
sh 'sudo ipfw pipe 1 config bw 50Kbit/s delay 2000ms plr 0.9'

Keybase proof

I hereby claim:

  • I am shad on github.
  • I am shadr (https://keybase.io/shadr) on keybase.
  • I have a public key whose fingerprint is 7CBC 5E71 1662 E5AE D322 9809 DC8A 9DF7 BA30 351F

To claim this, I am signing this object: