Skip to content

Instantly share code, notes, and snippets.

View timsavery's full-sized avatar

Tim Savery timsavery

View GitHub Profile
@timsavery
timsavery / gist:4497168
Created January 9, 2013 21:35
Proposed Messaging Subscriber API
var subscription = new Subscriber().CreateSubscription().ToServiceMessages<IEchoService>();
subscription.MessageReceived += message => {
Console.Writeline(x.Body);
};
subscription.Start();
@timsavery
timsavery / gist:3959377
Created October 26, 2012 15:18
Constructing a TypedCache<T> Instance With Chatham.Libraries.Ioc
Chatham.Libraries.Ioc.IocContainer.Instance.Bind<IStatsClient>(() => new StatsdClient());
Chatham.Libraries.Ioc.IocContainer.Instance.Bind<ICacheClient>(() => new MemcachedClient());
var typedCache = Chatham.Libraries.Ioc.IocContainer.Instance.Get<TypedCache<MyObject>>();
@timsavery
timsavery / gist:3959349
Created October 26, 2012 15:13
The Re-Factored Chatham.Libraries.Caching.TypedCache<T> Constructor
public class TypedCache<T> {
private readonly Chatham.Libraries.Stats.Api.IStatsClient _statsClient;
private readonly Chatham.Libraries.Caching.Api.ICacheClient _cacheClient;
public TypedCache(Chatham.Libraries.Stats.Api.IStatsClient statsClient, Chatham.Libraries.Caching.Api.ICacheClient cacheClient) {
this._statsClient = statsClient;
this._cacheClient = cacheClient;
}
...
@timsavery
timsavery / gist:3959244
Created October 26, 2012 14:52
The Current Chatham.Libraries.Caching.TypedCache<T> Constructor
public class TypedCache<T> {
private readonly Chatham.Libraries.Stats.IStatsClient _statsClient;
private readonly Chatham.Libraries.Caching.ICacheClient _cacheClient;
public TypedCache() {
this._statsClient = new Chatham.Libraries.Stats.StatsdClient();
this._cacheClient = new Chatham.Libraries.MemcachedClient.MemcachedClient();
}
...
@timsavery
timsavery / gist:3354026
Created August 14, 2012 23:58
Salesforce Chatter OAuth 2.0
var request = require('request')
, querystring = require('querystring');
module.exports = function ChatterAuth() {
this.environment = process.env.SALESFORCE_ENV;
this.client_id = process.env.SALESFORCE_CLIENT_ID;
this.client_secret = process.env.SALESFORCE_CLIENT_SECRET;
this.oauth_callback_uri = process.env.SALESFORCE_OAUTH_CALLBACK_URI;
this.redirectToLogin = function(req, res) {
function hello(name) {
this.name = name;
this.sayIt = function(callback) {
var self = this;
setTimeout(function() {
callback("Hello " + self.name);
}, Math.random()*1000);
};
};
==============================================================
MODULE :: hello.js
==============================================================
module.exports = function hello(name) {
this.name = name;
this.sayIt = function() {
return "Hello " + this.name;
};
function getQuerystringParamByName(name) {
name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
var regexS = '[\\?&]' + name + '=([^&#]*)'
, regex = new RegExp(regexS)
, results = regex.exec(window.location.search);
if(!results) {
return '';
}
function getTimeSince(start, end) {
var msSince = (end - start);
var msInDay = 24*60*60*1000
, msInHour = 60*60*1000
, msInMinute = 60*1000
, msInSecond = 1000;
if (msSince > msInDay) { // greater than one day
return parseInt(msSince / msInDay).toString() + 'd Ago';
tsavery@tangialt01:~/github/timsavery/nodephilly-raffle$ jitsu env list
info: Welcome to Nodejitsu
info: It worked if it ends with Nodejitsu ok
info: Executing command env list
info: Listing all environment variables for: nodephilly-raffle
data: {
data: USER_KEY: 833786748121301400000,
data: EVENTBRITE_APP_KEY: 'xxxx',
data: SUBDOMAIN: 'nodephillyraffle',
data: NODE_ENV: 'production',