This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var keys = {}; | |
lo.forEach(OBJECT, (item) => { | |
lo.forEach(item, (value, key) => { | |
if (!keys[key]) { | |
keys[key] = {}; | |
} | |
var type = typeof value; | |
// differentiate Array from Object | |
type = (type == "object") ? (value instanceof Array ? "array" : "object") : type; | |
// capitalize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var getPipedInput = function() { | |
return new Promise(function(resolve, reject) { | |
var data = ""; | |
var self = process.stdin; | |
var reading = false; | |
self.on('readable', function() { | |
var chunk = this.read(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fancy ID generator that creates 20-character string identifiers with the following properties: | |
* | |
* 1. They're based on timestamp so that they sort *after* any existing ids. | |
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs. | |
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly). | |
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the | |
* latter ones will sort after the former ones. We do this by using the previous random bits | |
* but "incrementing" them by 1 (only in the case of a timestamp collision). | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! moment.js locale configuration | |
//! locale : finnish (fi) | |
//! author : Tarmo Aidantausta : https://github.com/bleadof | |
//! author : Christoffer Niska : https://github.com/crisu83 | |
(function (global, factory) { | |
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) : | |
typeof define === 'function' && define.amd ? define(['moment'], factory) : | |
factory(global.moment) | |
}(this, function (moment) { 'use strict'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<body> | |
<style> | |
#line{ | |
width: 100%; | |
margin: 20px 0; | |
height: 300px; | |
background: #eee; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
/** | |
* Makes it easy to record real API requests and save | |
* them as mocks, which can then be reused. | |
* | |
* Usage inside Jest test file: | |
* - first create a folder request-promise-mocks adjacent | |
* to this file (request-promise.js) | |
* - turn the flag on in a test to use real API: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Backup JSON data of your Path.com feed, including own and others' photos and videos | |
// Just take connect.cid cookie from browser inspector when being logged in to Path.com and place below. | |
// Then run the script, and voila! | |
const _ = require('lodash') | |
const fs = require('fs') | |
const request = require('request-promise') | |
const cookie = '<PLACE YOUR connect.cid PATH cookie here>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const XState = require('xstate') | |
const { Machine, interpret } = XState | |
const { raise } = XState.actions | |
/* | |
run from cli using: | |
node xstate-onentry-timing-bug.js [sync|async|raise] | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let i = 0 | |
Machine({ | |
on: { | |
ERROR: 'restarting', | |
}, | |
invoke: { | |
src: 'subscribeToStatus', | |
}, | |
initial: 'running', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To visualize statechart, copy paste code to https://statecharts.github.io/xstate-viz/ | |
// Available variables: | |
// Machine (machine factory function) | |
// assign (action) | |
// XState (all XState exports) | |
const healthCheck = Machine({ | |
id: 'healthCheck', | |
context: { attempts: 0 }, | |
initial: 'normal', |
OlderNewer