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
| import UIKit | |
| import Security | |
| let serviceIdentifier = "com.company" | |
| let accessGroup = "com.company.app" | |
| let kSecClassValue = kSecClass as NSString | |
| let kSecAttrAccountValue = kSecAttrAccount as NSString | |
| let kSecValueDataValue = kSecValueData as NSString | |
| let kSecClassGenericPasswordValue = kSecClassGenericPassword as NSString |
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
| var params = _.extend({ | |
| api_key: MIXPANEL_KEY, | |
| expire: Math.ceil(Date.now() / 1000) + 5 * 60 | |
| }, | |
| args.params); | |
| var toSign = Object.keys(params) | |
| .sort() | |
| .map(function(key) { return key + '=' + params[key]; }) | |
| .join(''); |
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
| var request = require('request'), | |
| ENDPOINT = 'https://www.googleapis.com/'; | |
| exports.save = function(opt, cbk) { | |
| var auth = 'Bearer ' + opt.access_token; | |
| opt.mimeType = opt.mimeType || 'application/octet-stream'; | |
| request.post({ |
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
| exports.respond = function(req, res) { | |
| var responders = []; | |
| for (var i = 2, arg; arg = arguments[i]; i++) responders.push(arguments[i]); | |
| var next = function() { | |
| var responder = responders.shift(); | |
| if (typeof(responder) != 'function') return; | |
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
| // Deferreds are useful for chaining: doSomething().success(doSomethingElse).failure(stopStuff); | |
| function Deferred() { | |
| this._successCbk = function() {}, | |
| this._failureCbk = function() {}; | |
| return this; | |
| } | |
| Deferred.prototype.success = function(cbk) { | |
| this._successCbk = cbk; |
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
| function now() { | |
| return (new Date).getTime(); | |
| } | |
| var window = {}, | |
| jsc = now(), | |
| rscript = /<script(.|\s)*?\/script>/gi, | |
| rselectTextarea = /select|textarea/i, | |
| rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i, | |
| jsre = /=\?(&|$)/, |
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
| Sdb.prototype.getQueryString = function(query) { | |
| if (!query.domain) throw new Error('no domain specified'); | |
| if (!query.fields || !query.fields.length) query.fields = '*'; | |
| var str = query.fields.join() + ' from ' + query.domain; | |
| if (query.selectors && query.selectors.length) | |
| str+= ' where ' + query.selectors.join(' intersection '); | |
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
| function echo(string) { console.log(string); } | |
| process.on('uncaughtException', function (err) { | |
| echo(err.stack); | |
| echo('uncaught Exception: ' + err); | |
| }); | |
| var KEYS = require('keychain'), | |
| $ = require('node-jquery'), | |
| S3 = require('amazon-s3').S3; |
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
| ** Steps ** | |
| Problem: | |
| Map asynchronous callbacks onto a multi-step process. | |
| Centralize flow logic | |
| object { | |
| steps : [function, function, function] | |
| advance : function() { this.shift(function)(); } | |
| } |
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
| // SCRIPT IN PROGRESS! BEWARE SUPER HACKY/UGLY CODE BELOW | |
| // takes an associative array of args "a[b][c]" = d into a : { b : { c : d } } | |
| // use: var getArgs = parseGetArgs(url.parse(request.url, true).query); | |
| function parseGetArgs(args) { | |
| if (!args) return null; | |
| var result = {}; |