Skip to content

Instantly share code, notes, and snippets.

@simonratner
simonratner / get_facility_code_wiegan_length_from_format_name.js
Created November 7, 2017 19:21 — forked from goliatone/get_facility_code_wiegan_length_from_format_name.js
Calculate parity bit for a string representation of a binary number, i.e 0101011101
var FACILITY_CODE = /(\d+)$/;
var WIEGAND_LENGTH = /^Wiegand (\d+)/i;
function getFacilityCode(format=''){
let match = format.match(FACILITY_CODE);
if(!match) return undefined;
let code = match[1];
return parseInt(code);
}
@simonratner
simonratner / gist:1372192
Created November 17, 2011 02:27 — forked from powmedia/gist:1081802
Backbone.sync for Titanium
//Customise Backbone.sync to work with Titanium rather than jQuery
Backbone.sync = (function() {
var methodMap = {
'create': 'POST',
'read' : 'GET',
'update': 'PUT',
'delete': 'DELETE'
};
var xhr = Ti.Network.createHTTPClient({ timeout: 5000 });