Skip to content

Instantly share code, notes, and snippets.

View brentonhouse's full-sized avatar
🚀
Busy being awesome!

Brenton House brentonhouse

🚀
Busy being awesome!
View GitHub Profile
@dawsontoth
dawsontoth / xmlToJS.js
Created March 22, 2012 17:25
XML to JS Module
/**
* XMLToJS Module 0.1
*
* To use:
* var XMLToJS = require('xmlToJS');
* var jsObject = XMLToJS.convert(xml);
*
* This will take XMl like the following:
*
<atom:feed xmlns:atom="http://www.w3.org/2005/Atom">
@donayama
donayama / PlatformRequire.js
Created March 26, 2012 22:22
TiShadow iOS Simulator Patch (from line:29)
var log = require("/api/Log");
var os = Ti.Platform.osname;
// The TiShadow build of the Titanium SDK does not cache CommonJS modules loaded
// from the applicationDataDirectory. This is so that if an update to the app is
// deployed, i.e. a file in the applicationDataDirectory is modified, the changes
// while be loaded. That said loading a CommonJS module every time that it is loaded
// make the deployed bundle run slowly. So we will manage the caching of those
// modules here in the code.
@dawsontoth
dawsontoth / app.js
Created April 16, 2012 19:36
Pullable Left Menu
var win = Ti.UI.createWindow({
backgroundColor: '#333'
});
var menuWidth = 200;
var container = Ti.UI.createScrollView({
disableBounce: false,
horizontalBounce: true,
contentWidth: Ti.Platform.displayCaps.platformWidth + menuWidth
@gasman
gasman / pnginator.rb
Created April 30, 2012 18:08
pnginator: pack Javascript into a self-extracting PNG
#!/usr/bin/env ruby -w
# pnginator.rb: pack a .js file into a PNG image with an HTML payload;
# when saved with an .html extension and opened in a browser, the HTML extracts and executes
# the javascript.
# Usage: ruby pnginator.rb input.js output.png.html
# By Gasman <http://matt.west.co.tt/>
# from an original idea by Daeken: http://daeken.com/superpacking-js-demos
@domenic
domenic / promise-retryer.js
Last active September 16, 2023 02:43
Generalized promise retryer
"use strict";
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances.
// If one of those happens, we want to retry until it doesn't.
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects;
// it has no synchronous behavior (e.g. throwing).
function dontGiveUp(f) {
return f().then(
undefined, // pass through success
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active May 14, 2026 00:53
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@kriskowal
kriskowal / cancelable-xhr.js
Created July 31, 2012 00:56
Demonstration of Mark Miller’s idea for cancelable promises: return the deferred.
var cancelableRequest = function (url) {
var xhr = new XMLHttpRequest();
var deferred = Q.defer();
function onload() {
if (xhr.status === 200 || xhr.status === 0 && xhr.responseText) {
deferred.resolve(xhr.responseText);
} else {
onerror();
}
@cuppster
cuppster / 1.cs
Created September 3, 2012 18:39
Promises for C# using Generics
/*
modified from original source: https://bitbucket.org/mattkotsenas/c-promises/overview
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Promises
exports.definition =
config:
adapter:
type: "rest"
name: "Agent"
extendModel: (Model) ->
_.extend Model::,
url: ->
@aaronksaunders
aaronksaunders / new_sql.js
Last active January 28, 2016 19:20
new adapter using REPLACE INTO for Appcelerator Titanium Alloy, also fixed the read switch, was not performing properly
//
// Here are the tests I am running against the adapter
// https://gist.github.com/aaronksaunders/4722895
//
// aaron@clearlyinnovative.com
//
function SQLiteMigrateDB(config) {
this.dbname = config.adapter.db_name;
this.table = config.adapter.collection_name;