Skip to content

Instantly share code, notes, and snippets.

View sleroux's full-sized avatar
:shipit:
on the loose

Stephan Leroux sleroux

:shipit:
on the loose
  • Shopify
  • Toronto, ON, Canada
View GitHub Profile
@sleroux
sleroux / gist:eb82bbbfb41e92747b09
Created May 21, 2015 17:55
To be lazy or not to be...
lazy var myLabel: UILabel = {
var temporaryLabel : UILabel = UILabel()
return temporaryLabel
}()
let testLabel: UILabel {
if !_testLabel {
_testLabel = UILabel()
}
return _testLabel!
@sleroux
sleroux / gist:5143923
Created March 12, 2013 15:36
iOS web debugginator
#!/bin/bash
# Open iPhone Simulator on default location for XCode 4.3 if found
[[ -d /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/ ]] &&
open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
# Open iPhone Simulator on default location for XCode 4.2 if found
[[ -d /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/ ]] &&
open /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
@sleroux
sleroux / gist:4568466
Created January 18, 2013 20:58
Using Fibers to write linear callback code
require 'eventmachine'
require 'em-http'
require 'fiber'
# Borrowed from http://www.igvita.com/2010/03/22/untangling-evented-code-with-ruby-fibers/
def async_fetch(url)
# Grab a reference to which fiber I am
f = Fiber.current
var data2xml = require("data2xml"),
key = 'splashScreen',
xmlObject = {},
imgPath = "dummyImage.png";
xmlObject[key] = {},
xmlObject[key]['image'] = [];
// Push 2 different images for each localization
xmlObject[key]["image"].push({