Skip to content

Instantly share code, notes, and snippets.

View jkusachi's full-sized avatar

James Kusachi jkusachi

View GitHub Profile
var counter = { x: 0 };
var p = [];
function count(c) {
var time = Math.floor(Math.random() * 1000);
return new Promise(function (resolve) {
setTimeout(function () {
var x = c.x++;
console.log(x + ':' + time);
resolve(x + ':' + time);

View local branches

git branch

  • the one with the * next to it is your current HEAD

View remote branches

git branch -r

  • repositories that are hosted on the repo will be preceded with origin/
@jkusachi
jkusachi / collection-search-find-index-between.js
Last active November 9, 2016 22:48
Given a Collection and a search value, find the index of closet matching value, rounding UP
/**
<p>Given a collection (array of objects) and a value, find the index of the closest matching value (rounding UP).</p>
<br/>
<strong.=>example:</strong>
<pre>
var arr = [{ val: 0}, { val: 25}, { val: 50}, { val: 75}, { val: 100}];
Given: 0 // given value to find
Expected: 0 //index
@jkusachi
jkusachi / static-google-map-signature.js
Last active November 21, 2016 18:19
Static Google Map Signature
const url = require('url');
const crypto = require('crypto');
const config = {
secret: 'YOUR_SECRET',
clientId: 'CLIENT_ID'
}
const generateSignature = (address) => {
const request = url.parse(address);
@jkusachi
jkusachi / HMR Regex
Last active September 13, 2017 19:47
help filter out noise in chrome dev tools when using hot module reload n stuff
// hide HMR and GET
/^((?!HMR|GET).)*$/
// Hide Warnings
/^((?!warning).)*$/
// Hide all
/^((?!warning|HMR|GET).)*$/
// wrap regex in / / if using Canary
@jkusachi
jkusachi / wp-query-args.php
Last active August 3, 2017 17:23 — forked from billerickson/gist:3698476
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@jkusachi
jkusachi / machine.js
Last active July 4, 2021 16:45
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jkusachi
jkusachi / machine.js
Last active July 13, 2021 15:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions