Skip to content

Instantly share code, notes, and snippets.

View sebringj's full-sized avatar
💭
Shet yer Shtatus

Jason Sebring sebringj

💭
Shet yer Shtatus
View GitHub Profile
View gist:3807439
info: Welcome to Nodejitsu
info: jitsu v0.9.8
info: It worked if it ends with Nodejitsu ok
info: Executing command users confirm zipstory edb7fe3a-56e8-4442-8423-e90c105ea543
info: Confirming user zipstory
error: Error running command users confirm zipstory edb7fe3a-56e8-4442-8423-e90c105ea543
error: Nodejitsu Error (400): Bad Request
error: connect ECONNREFUSED
help: For help with this error contact Nodejitsu Support:
help: webchat: <http://webchat.nodejitsu.com/>
View custom react infinite
'use strict';
var _ = require('lodash');
var React = require('react');
var ReactDOM = require('react-dom');
var THROTTLE_TIME = 250;
var InfiniteChild = React.createClass({
getInitialState: function() {
View keybase.md

Keybase proof

I hereby claim:

  • I am sebringj on github.
  • I am jasonsebring (https://keybase.io/jasonsebring) on keybase.
  • I have a public key whose fingerprint is C7D8 CC6F F1DB 9014 9A6A E34E C7D8 74CD 6848 F3EE

To claim this, I am signing this object:

@sebringj
sebringj / TinyStore.js
Last active May 2, 2017 14:27
Tiny Flux Store for React
View TinyStore.js
class TinyStore {
constructor(key) {
this._events = {};
this._data = undefined;
this._key = key;
}
on(evt, fn) {
let list = this._events[evt] = this._events[evt] || [];
for (let fnItem of list)
@sebringj
sebringj / promiseMapAll.js
Last active May 3, 2017 06:55
maps Promise.all
View promiseMapAll.js
async function promiseMapAll(promiseMap) {
const keys = Object.keys(promiseMap);
const promises = keys.map(key => promiseMap[key]);
const promisesArr = await Promise.all(promises);
let objMapped = {};
keys.forEach((key, i) => {
objMapped[key] = promisesArr[i];
});
return objMapped;
}
@sebringj
sebringj / LookupList.js
Last active June 21, 2017 15:35
JavaScript LookupList
View LookupList.js
/*
use like so:
const lookupList = new LookupList({ a: 1 }, { b: 2 }, { c: 3 })
console.log(lookupList.valueByKey('a')) // 1
console.log(lookupList.keyByValue(1)) // "a"
console.log(lookupList.keysByValue(1)) // ["a"]
console.log(lookupList.valueByIndex(0)) // 1
console.log(lookupList.keyByIndex(0)) // "a"
@sebringj
sebringj / getKeyList.js
Last active June 21, 2017 15:59
JavaScript getKeyList
View getKeyList.js
/*
use like so:
let keyList = getKeyList("a", "b", "c")
console.log(keyList[0]) // "a"
console.log(keyList.index["a"]) // 0
*/
function getKeyList() {
let arr = [].slice.call(arguments);
@sebringj
sebringj / flattenArray.js
Last active July 21, 2017 15:46
flattens nested list of arrays of integers
View flattenArray.js
// VIEW ON JSFIDDLE -> https://jsfiddle.net/v5scgqao/3/
/*
flattens array without mutation
*/
function flattenArray(arr) {
let arr2 = []
function flatten(a) {
for (let i = 0; i < a.length; i++) {
if (Array.isArray(a[i]))
flatten(a[i])
@sebringj
sebringj / retch.js
Created November 9, 2017 15:27
React Native Fetch alternative with abort method attached to returned promise and timeout support
View retch.js
'use strict';
var self = this || global;
// Polyfill from https://github.com/github/fetch/blob/v1.1.1/fetch.js#L8-L21
var support = {
searchParams: 'URLSearchParams' in self,
iterable: 'Symbol' in self && 'iterator' in Symbol,
blob: 'FileReader' in self && 'Blob' in self && (function() {
try {
@sebringj
sebringj / textFromJson.js
Last active January 17, 2020 21:10
JSON to text in JavaScript
View textFromJson.js
function textFromJson(json) {
if (json === null || json === undefined) {
return '';
}
if (!Array.isArray(json) && !Object.getPrototypeOf(json).isPrototypeOf(Object)) {
return '' + json;
}
const obj = {};
for (const key of Object.keys(json)) {
obj[key] = textFromJson(json[key]);