Skip to content

Instantly share code, notes, and snippets.

View euforic's full-sized avatar

Christian Sullivan euforic

View GitHub Profile
@euforic
euforic / cli_log.js
Created January 22, 2013 22:08
cli logging objects
var x = {
"test": 1,
"test2": 2,
"testArray": [1,2,3,4]
};
console.log('TEST',x);
/**
* OUTPUT
@euforic
euforic / require.js
Last active December 14, 2015 09:58
Node Style require for browser and Titanium
/**
* Require the given path.
*
* @param {String} path
* @return {Object} exports
* @api public
*/
function require(path, parent, orig) {
var resolved = require.resolve(path);
@euforic
euforic / dataBind.js
Created March 6, 2013 00:31
two way databinding example implementation
/**
* two way data binding
*/
// create root scope
window.$rootScope = {};
@euforic
euforic / app.js
Last active March 15, 2017 14:27
Node.js Libraries for all Titanium platforms | Available Modules [ net, stream (node 9.x version), assert, buffer, util, events ] Still a work in progress
/**
* Available node core libraries
*/
var node = require('node')
, assert = node.assert
, buffer = node.buffer
, events = node.events
, net = node.net
, stream = node.stream
@euforic
euforic / MegaStream.js
Created May 4, 2013 04:52
Mega Stream
/**
* Expose `Stream`.
*/
if ('undefined' !== typeof module) {
module.exports = Stream;
}
/**
@euforic
euforic / Emitter.js
Last active March 15, 2017 14:25
Simple Socket Wrapper for Titanium
/*!
* Event Emitters
*/
/**
* Initialize a new `Emitter`.
*
* @api public
*/
@euforic
euforic / xhr.js
Created August 21, 2013 22:08
superagent XHR Titanium Shim
function XMLHttpRequest() {
// titanium xhr client
this._proxy = Ti.Network.createHTTPClient();
// mapping for compatible functions
this.getResponseHeader = this._proxy.getResponseHeader;
this.open = this._proxy.open;
function mkdirP (p, fn, made) {
if (!made) made = null;
var cb = fn || function () {};
p = path.resolve(p);
fs.mkdir(p, function (err) {
if (!err) return cb(null, made || p);
if (err.code != 'ENOENT') return err;
mkdirP(path.dirname(p), mode, function (err, made) {
@euforic
euforic / xml_entity.js
Created February 14, 2014 00:31
Simple xml entity encoder / decoder
function decodeEntity(str) {
var names = {
'nbsp': 160,
'lt': 60,
'gt': 62,
'amp': 38,
'cent': 162,
'pound': 163,
'yen': 164,
'euro': 8364,
@euforic
euforic / server.go
Created July 20, 2017 23:34
Add pprof to a labstack/echo server
package server
import (
"fmt"
"net/http"
_ "net/http/pprof"
"github.com/labstack/echo"
)