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
import { get, set } from "lodash"; | |
import { produce } from "immer"; | |
export default class Paginator { | |
path: string; | |
limit: number; | |
constructor({ path, limit }) { | |
this.path = path; | |
this.limit = limit; | |
} |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
export default generateTask({ | |
method: 'create', | |
event_base: 'JOB', | |
entity: 'job', | |
url: resources.jobs.create | |
}); | |
// The above expands to the code below |
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
function getArrayDiff(a, b) { | |
var ret = []; | |
if (!(Array.isArray(a) && Array.isArray(b))) { | |
return ret; | |
} | |
var i; | |
var key; | |
for (i = a.length - 1; i >= 0; i--) { | |
key = a[i]; |
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 example = {one : 'something', two: 'somethingElse'}; | |
var test = {} | |
test[example.one]: true; | |
test[example.two]: function () { console.log('so verbose');} | |
console.log(test.something); // true | |
test.somethingElse(); // Prints 'so verbose' |
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
Promise.resolve().then(function () { | |
return 100; | |
}) | |
.then(function() { | |
console.log(arguments); | |
}); | |
// --- | |
Promise.resolve(200).then(function () { |
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
// ---- | |
// Sass (v3.4.7) | |
// Compass (v1.0.1) | |
// ---- | |
$du-responsive-config: ( | |
( | |
table-type: ".portfolio, .options, .currencies, .commodities, .losers, .gainers, .etfs", | |
data-cols: ".data-col4", | |
min: 300, |
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 getData = new Promise(function(resolve, reject){ | |
// Do something asynchronous and pass it a callback | |
getDataFromAMillionMilesAway(function(data){ | |
if(data){ | |
resolve(data); | |
} | |
else { | |
reject(new Error("Thats too far away")); |
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
//Inspired by https://github.com/klughammer/node-randomstring | |
function generateRandomCode($length){ | |
$str = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz'; | |
$randomChar = $str[rand(0, strlen($str)-1)]; | |
$length= ($length == null)? 32 : $length; | |
$randomArray = array(); | |
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
//Reference | |
//http://stackoverflow.com/questions/498970/how-do-i-trim-a-string-in-javascript | |
if (!String.prototype.trim) { | |
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');}; | |
String.prototype.ltrim=function(){return this.replace(/^\s+/,'');}; | |
String.prototype.rtrim=function(){return this.replace(/\s+$/,'');}; | |
String.prototype.fulltrim=function(){return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ');}; | |
NewerOlder