Skip to content

Instantly share code, notes, and snippets.

View jhaynie's full-sized avatar

Jeff Haynie jhaynie

View GitHub Profile
/**
* Helper Functions for Handlebars Templating engine
*/
var fs = require('fs'),
path = require('path'),
Arrow = require('arrow');
/**
@jhaynie
jhaynie / example.js
Created December 10, 2014 03:45
find -E . -type f -not -regex "^\./\.git/.*" | awk 'BEGIN {FS="."} {tally[$NF]+=1} END {for (key in tally) {printf "%d: %s\n", tally[key], key}}' | sort -n -k 1,1 | tail -r
// simple and quick port of
//
// find -E . -type f -not -regex "^\./\.git/.*" | awk 'BEGIN {FS="."} {tally[$NF]+=1} END {for (key in tally) {printf "%d: %s\n", tally[key], key}}' | sort -n -k 1,1 | tail -r
//
var wrench = require('wrench'),
fs = require('fs'),
path = require('path'),
_ = require('lodash');
@jhaynie
jhaynie / itworks.js
Created July 26, 2014 01:19
Simple Titanium View
var w = Ti.UI.createWindow();
var v = Ti.UI.createView({backgroundColor:'white'});
w.add(v);
var t = Ti.UI.createLabel({text:'It works!'});
v.add(t);
w.open();
@jhaynie
jhaynie / window.js
Created July 25, 2014 01:23
Simple Ti WIndow
var w = Ti.UI.createWindow();
w.open();
w.backgroundColor = 'red';
@jhaynie
jhaynie / gist:8c3be4e49144bc873cbe
Created May 24, 2014 01:51
get the current selected version of Titanium SDK
ti sdk | grep "\[selected\]" | awk '{print $1}'
@jhaynie
jhaynie / 0_reuse_code.js
Created May 13, 2014 09:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
auto _Folder = Windows::Storage::ApplicationData::Current->LocalFolder;
auto _Option = Windows::Storage::CreationCollisionOption::ReplaceExisting;
// create file async
_Folder->CreateFileAsync("MyFileName", _Option);
// create file sync by wrapping in task - then pattern
IAsyncOperation<StorageFile^>^ fileOp = _Folder->CreateFileAsync("MyFileName2", _Option);
auto deviceEnumTask = create_task(fileOp);
deviceEnumTask.then([](StorageFile^ myFile)
function getKeys(obj, keys) {
keys = keys || {};
Object.keys(obj).forEach(function(k){
if (!k in keys) {
var o = obj[k];
keys[k] = 1;
if (typeof o === 'Object') {
getKeys(o,keys);
}
}
@jhaynie
jhaynie / spinner.js
Created June 22, 2013 20:22
Console based spinner module in Node.js -- adapted from code in mocha
var sprintf = require('util').format,
timer;
function play(arr, interval) {
var len = arr.length
, interval = interval || 100
, i = 0;
timer = setInterval(function(){
var str = arr[i++ % len];
@jhaynie
jhaynie / app.js
Created June 19, 2013 18:35 — forked from viezel/app.js
// This is an example of use.
// Here we use the new Bearer Token thats make it possible to get tweets without user login
// More info on Bearer here: https://dev.twitter.com/docs/auth/application-only-auth
// Full Codebird API is here: https://github.com/mynetx/codebird-js
var Codebird = require("codebird");
var cb = new Codebird();
cb.setConsumerKey('CONSUMER_KEY', 'CONSUMER_SECRET_KEY');
var bearerToken = Ti.App.Properties.getString('TwitterBearerToken', null);