Skip to content

Instantly share code, notes, and snippets.

View calvinfo's full-sized avatar

Calvin French-Owen calvinfo

View GitHub Profile

Keybase proof

I hereby claim:

  • I am calvinfo on github.
  • I am calvinfo (https://keybase.io/calvinfo) on keybase.
  • I have a public key whose fingerprint is A454 9029 F458 3705 25AC 9309 592B 56C5 AC5D 12A0

To claim this, I am signing this object:

/**
* Set up our uncaught exception handler
**/
process.on('uncaughtException', function(err){
log.critical('uncaught', err);
setTimeout(function(){
// cleanup...
}, 1000);
});
@calvinfo
calvinfo / key_range_slice.js
Created October 12, 2012 22:41
CF key_range_slice demo
var helenus = require('helenus');
pool = new helenus.ConnectionPool({
hosts : ['localhost:9160'],
keyspace : 'segmentio',
timeout : 3000
});
pool.on('error', function(err){
console.error(err.name, err.message);
@calvinfo
calvinfo / purgatory.js
Created October 16, 2012 00:15
Purgatory
var _ = require('underscore'),
rabbit = require('rabbit-pool'),
logging = require('logging')(module);
var exchange,
handlers = {},
messages = [];
@calvinfo
calvinfo / Preferences.json
Created December 10, 2012 19:29
Sublime profile
{
"alignment_chars":
[
"=",
":"
],
"alignment_prefix_chars":
[
"+",
"-",
@calvinfo
calvinfo / sublime-lint.json
Created December 10, 2012 19:37
Sublimelint
{
"sublimelinter": "load-save",
"jshint_options":
{
"browser": true,
"eqeqeq": true,
"evil": true,
"expr": true,
@calvinfo
calvinfo / debug-analytics.rb
Created January 30, 2013 01:02
Analytics-Ruby debugging
error_handler = Proc.new { |status, msg| print status, msg }
Analytics.init(secret: "mysecret", on_error: error_handler)
@calvinfo
calvinfo / session.js
Last active December 14, 2015 12:38
Once per session tracking
(function () {
var traits = analytics.user.traits()
, session = traits.session
, now = +(new Date); // shim for Date.now in older browsers
if (!session || (now - session) > 60*60*1000) {
// Track things which happen once a session
analytics.track('Once a session');
analytics.ready(function() {
if ($("#mixpanel_distinct_id").length > 0) {
var interval = setInterval(function () {
if (window.mixpanel.get_distinct_id) {
$("#mixpanel_distinct_id").val(window.mixpanel.get_distinct_id());
clearInterval(interval);
}
}, 300);
}
});
@calvinfo
calvinfo / queue.js
Created May 7, 2013 19:51
Multiple queue
function subscribe(queue) {
logger.info('API logger queue created.');
queue.bind('ingestion', '#');
var options = { ack : true, prefetchCount : 1000 };
queue.subscribe(options, function (payload, headers, deliveryInfo, message) {
importer.log(payload, function (err) {
try {
if (err) message.reject(true); // requeue the message