Skip to content

Instantly share code, notes, and snippets.

View evantahler's full-sized avatar
💭
Programmin'

Evan Tahler evantahler

💭
Programmin'
View GitHub Profile
@evantahler
evantahler / example.js
Created June 1, 2012 12:31
PhoneGap / Cordova Device Token plugin JS component (iOs)
// An example of how to use the PhoneGap / Cordova plugin described in this post [[ http://blog.evantahler.com/phonegap-and-push-notifications ]] to get an iOs device token
document.addEventListener("deviceready", function(){
getDeviceToken();
}
getDeviceToken = function(){
if(typeof device != "undefined" && typeof cordova == "object"){
var getToken = function(types, success, fail){
cordova.exec(success, fail, "PushToken", "getToken", types);
@evantahler
evantahler / gist:3971280
Created October 29, 2012 03:18
Domain Test for Mocha
var domain = require('domain');
var should = require('should');
//////////////
// Function //
//////////////
var add = function(a,b,callback){
if(!isNumber(a)) { throw new Error(a + "is not a number"); }
if(!isNumber(b)) { throw new Error(b + "is not a number"); }
@evantahler
evantahler / domains_and_clients.js
Created December 13, 2012 07:14
Help with node.js' handling of domain exceptions from clients created outside of their scopes. Check the comment for description
var domain = require('domain');
var redis = require('redis');
var eventEmitter = require('events').EventEmitter;
var tests = [];
var testCounter = 0;
var runTest = function(){
if(tests.length > testCounter){
tests[testCounter]();
}else{
@evantahler
evantahler / twitterOauthActionhero.js
Last active December 9, 2015 20:48 — forked from anonymous/twitterOauthActionhero.js
update for actionHero 6.x
var oauth = require('oauth');
var consumerKey = "AAAAAAAAAAAAAAAAAA";
var consumerSecret = "BBBBBBBBBBBBBBBBBBBB";
var callbackURL = "http://127.0.0.1:8080/twitterOauthCatch"; // be sure to set me in the application's settings on dev.twitter.com
var oathClient = new oauth.OAuth(
"https://twitter.com/oauth/request_token",
"https://twitter.com/oauth/access_token",
consumerKey,
consumerSecret,
@evantahler
evantahler / inspectTasks.js
Created December 28, 2012 17:04
A way to checkout the status of your task queue in actionHero
var action = {};
/////////////////////////////////////////////////////////////////////
// metadata
action.name = "inspectTasks";
action.description = "I show you what it going on";
action.inputs = {
"required" : [],
"optional" : []
};
@evantahler
evantahler / gist:4720365
Created February 6, 2013 04:42
Can't boot actionHero on nodejitsu
nfo: Creating snapshot 4.3.1-7
info Uploading: [=============================] 100%
info: Updating app actionHero
info: Activating snapshot 4.3.1-7 for actionHero
info: Starting app actionHero
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error: There was an error while attempting to deploy the app
error:
error: package.json error: can't find starting script: node ./bin/actionHero start
@evantahler
evantahler / async.rb
Last active December 14, 2015 08:49
Ruby Signal async
def sleeper
i = 0
while i < 10
puts "sleeping... #{i}"
blocking_sleep 1
i = i + 1
end
return i
end
@evantahler
evantahler / _myObject.js
Last active December 14, 2015 15:39
Portable exports function for JS in the browser and in node
// myObject.js
(function(exports){
var myObject = {
thing: 'stuff'
};
exports.myObject = myObject;
})(typeof exports === 'undefined' ? window : exports);
{
// make it pretty
"theme": "Flatland Dark.sublime-theme",
"color_scheme": "Packages/Theme - Flatland/Flatland Dark.tmTheme",
"font_size": 12.5,
// tabs
"tab_size": 2,
"translate_tabs_to_spaces": true,
@evantahler
evantahler / fileResponder.js
Created June 5, 2013 03:22
Using an actionHero action to send a static file (perhaps for a single page app using pushState)
exports.action = {
name: "fileResponder",
description: "fileResponder",
outputExample: {},
inputs: { required: [], optional: [] },
run: function(api, connection, next){
var server = api.servers.servers[connection.type];
try{
// the hard-coded file you want to send, relitive to site's root
connection.params.file = "index.html"