Skip to content

Instantly share code, notes, and snippets.

Backathon

See what the other hackers are working on. If you like an hack, play with it.
If not, remove it.

Load Dependencies

_                   = require 'underscore'                  # documentcloud/underscore
@danscan
danscan / keybase.md
Created January 17, 2021 19:37
keybase.md

Keybase proof

I hereby claim:

  • I am danscan on github.
  • I am danscan (https://keybase.io/danscan) on keybase.
  • I have a public key ASAS_Adf3xZSUSirUuF9Cfjd_Bf9PZ_diAinf-zLiouIfwo

To claim this, I am signing this object:

@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 / policy.js
Last active January 25, 2016 17:03
Policy function
function requestUserOwnsPost(requestUser, post) {
return requestUser.id === post.owner;
}
const db = {
postsById: {
'2': {
id: 2,
owner: 1,
body: 'hey',
@danscan
danscan / policy.js
Created January 25, 2016 16:55
Policy function
const db = {
usersBySessionToken: {
'1': {
id: 1,
name: 'Dan',
},
},
postsById: {
'2': {
@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"
@danscan
danscan / .babelrc
Last active November 18, 2015 20:32
react-native-charts example .babelrc
{
"retainLines": true,
"compact": true,
"comments": false,
"stage": 1,
"whitelist": [
"es6.arrowFunctions",
"es6.blockScoping",
"es6.classes",
"es6.destructuring",