Skip to content

Instantly share code, notes, and snippets.

View jhurliman's full-sized avatar
🐨

John Hurliman jhurliman

🐨
View GitHub Profile
@jhurliman
jhurliman / microevent.js
Last active August 29, 2015 13:56
Micro EventEmitter-like library for JS, based on https://github.com/jeromeetienne/microevent.js/blob/master/microevent.js#L12-31 but with method names more closely matching node.js EventEmitter
window.MicroEvent = function() {};
MicroEvent.prototype = {
on: function(event, listener) {
this._events = this._events || {};
this._events[event] = this._events[event] || [];
this._events[event].push(listener);
},
removeListener: function(event, listener) {
this._events = this._events || {};
@jhurliman
jhurliman / ios-exif-timestamp-bug.json
Last active August 29, 2015 13:57
Broken EXIF timestamp in iPhone 5 (iOS 7.1) camera photo
{
"{Exif}": {
"ExposureTime": 0.06666666666666667,
"LensMake": "Apple",
"Flash": 16,
"ColorSpace": 1,
"SubjectArea": [1210, 1108, 509, 509],
"ExifVersion": [2, 2, 1],
"FocalLenIn35mmFilm": 33,
"SceneCaptureType": 0,
@jhurliman
jhurliman / famous-slidepanel.js
Created April 10, 2014 07:04
famo.us Slide Panel
/*globals define*/
define(function(require, exports, module) {
'use strict';
// import dependencies
var Engine = require('famous/core/Engine');
var Surface = require('famous/core/Surface');
var Modifier = require('famous/core/Modifier');
var Transform = require('famous/core/Transform');
var Utility = require('famous/utilities/Utility');
@jhurliman
jhurliman / famous-scrollview-nodechange.js
Last active August 29, 2015 13:59
famo.us - Emit an event from Scrollview when the current node changes
myScrollView.render = function() {
_tickScrollViewRender() {
var prevNode = this._node;
var retValue = Scrollview.prototype.render.call(this);
var node = this._node;
if (node !== prevNode)
this._eventOutput.emit('sequenceChange', { node: node, prevNode: prevNode });
@jhurliman
jhurliman / RenderPool.js
Created April 17, 2014 08:29
famo.us RenderPool. Work in progres...
define(function(require, exports, module) {
var RenderNode = require('famous/core/RenderNode');
var Modifier = require('famous/core/Modifier');
var Surface = require('famous/core/Surface');
function RenderPool() {
this._node = new RenderNode();
this._children = {};
this._unusedChildren = [];
@jhurliman
jhurliman / famous-sleepOnIdle.js
Last active August 29, 2015 14:01
famo.us - Sleep after n milliseconds of no touch/mouse movement
var Engine = require('famous/core/Engine');
/**
* Sleep after n milliseconds of no touch/mouse movement
*/
function sleepOnIdle(idleMS) {
var lastMoveMS = Date.now();
window.addEventListener('mousemove', _handleMovement, true);
window.addEventListener('touchmove', _handleMovement, true);
import UIKit
import CoreLocation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {
var window: UIWindow?
let locationManager: CLLocationManager = CLLocationManager()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
@jhurliman
jhurliman / singleton.m
Created June 28, 2014 07:57
Singleton pattern in Objective-C
+ (instancetype)sharedInstance {
static id instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[self alloc] init];
});
return instance;
}
@jhurliman
jhurliman / init.m
Created June 28, 2014 08:00
init method in Objective-C
- (id)init
{
if (self = [super init]) {
}
return self;
}
@jhurliman
jhurliman / compileconcatenation.m
Created June 28, 2014 08:04
Compile-time string concatenation in Objective-C
#ifdef DEBUG
#define kAPIEndpointHost @"http://example.dev"
#else
#define kAPIEndpointHost @"http://www.example.com"
#endif
#define kAPIEndpointLatest (kAPIEndpointHost @"/api/latest_content")
#define kAPIEndpointMostPopular (kAPIEndpointHost @"/api/most_popular")