Skip to content

Instantly share code, notes, and snippets.

@danscan
danscan / logs.md
Last active August 29, 2015 14:18
Connect-redis sails crash logs w/ NODE_DEBUG=net

Crash / process exit at the bottom.

Apr 07 22:32:50 ip-10-21-1-100.ec2.internal sh[7031]: Tue, 07 Apr 2015 22:32:49 GMT compression size below threshold
Apr 07 22:32:50 ip-10-21-1-100.ec2.internal sh[7031]: Tue, 07 Apr 2015 22:32:49 GMT compression no compression
Apr 07 22:32:50 ip-10-21-1-100.ec2.internal sh[7031]: Tue, 07 Apr 2015 22:32:49 GMT connect:redis SETEX "sess:h9C9rNrB2VlWjSsiw7dBbHxzTZMMA3ka" ttl:31535999 {"cookie":{"originalMaxAge":31535999998,"expires":"2016-04-06T22:32:49.971Z","httpOnly":true,"path":"/"},"user":"550b26dd80fd0a07009a658f"}
Apr 07 22:32:50 ip-10-21-1-100.ec2.internal sh[7031]: NET 6: onread -4095
Apr 07 22:32:50 ip-10-21-1-100.ec2.internal sh[7031]: NET 6: EOF
Apr 07 22:32:50 ip-10-21-1-100.ec2.internal sh[7031]: NET 6: onSocketEnd { objectMode: false,
Apr 07 22:32:50 ip-10-21-1-100.ec2.internal sh[7031]: highWaterMark: 16384,
@danscan
danscan / gist:3df1d2e95670d617b8c3
Created December 17, 2014 21:25
Carthage Output
~/D/P/0/Present (master) $ carthage update
*** Fetching HLSKit
*** Fetching PresentAPIClient
*** Fetching PresentPrePermissions
*** Fetching PPhotoPickerController
*** Fetching Swifter
*** Fetching HanekeSwift
*** Fetching ReactiveCocoa
*** Fetching emitter-kit
*** Fetching facebook-ios-sdk
@danscan
danscan / TimedFunction.js
Last active January 4, 2016 06:39
A simple way to execute a function with a time limit and an isolated context – useful for maintaining resource availability on platforms that allow multiple HTTP APIs to share infrastructure.
(function generateContext() {
var _startTime = Date.now(),
_timeout = 10000,
_timedOut = false,
_finish = function(error) {
clearTimeout(_timeoutTimeout);
_endTime = Date.now();
_totalExecutionTime = _endTime - _startTime;
@danscan
danscan / gist:7537577
Created November 18, 2013 23:56
My dream-code (just an idea) for how video append request failure can be handled.

Post Sequence

A dream-class that handles sequential-request streaming.

Features

  • POSTs multipart request bodies
  • Caches all requests
  • Failed request are retried immediately within a specified time window
  • If >10% of requests fail during the stream, the entire post sequence is cached for later retry under conditions of greater reliability.
@danscan
danscan / deepProperties.js
Created October 12, 2013 07:23
I was looking for a short, simple way to set and get deep properties in a single line in javascript, and after not finding anything I decided to see how short I could make these methods. Enjoy.
// Set deep property
function setProperty(p,v){p=p.split('.'),i=0,w=("string"===typeof v?'"'+v+'"':v);while(p[i])eval(p.slice(0,++i).join('.')+'='+(p[i]?"{}":w));return v}
// Example
setProperty('some.really.deep.property', 'now exists'); // "now exists"
// Get deep property
function getProperty(p){p=p.split('.'),v=this;while(p[0]&&v){v=v[p.shift()]}return v}
// Example
getProperty('some.really.deep.property'); // "now exists"