Skip to content

Instantly share code, notes, and snippets.

Avatar

James Kusachi jkusachi

View GitHub Profile
View wp-query-args.php
<?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 / HMR Regex
Last active Sep 13, 2017
help filter out noise in chrome dev tools when using hot module reload n stuff
View HMR Regex
// hide HMR and GET
/^((?!HMR|GET).)*$/
// Hide Warnings
/^((?!warning).)*$/
// Hide all
/^((?!warning|HMR|GET).)*$/
// wrap regex in / / if using Canary
@jkusachi
jkusachi / static-google-map-signature.js
Last active Nov 21, 2016
Static Google Map Signature
View static-google-map-signature.js
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 / collection-search-find-index-between.js
Last active Nov 9, 2016
Given a Collection and a search value, find the index of closet matching value, rounding UP
View collection-search-find-index-between.js
/**
<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
View git-notes.md

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/
View timer.js
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 passing-of-the-args.js
var data = {
name: 'james',
age: 30
};
function doSomething(){
console.log('- doSomething');
return (...args) => {
@jkusachi
jkusachi / destructuring.js
Created Mar 31, 2016
Playing with Destructuring
View destructuring.js
var master = {
data: {
values: [1, 2, 3],
labels: ["one", "two", "three"],
food: {
name: "pizza"
},
groups: [
{
brand: 'zillow',
@jkusachi
jkusachi / dedupe-not-null-by-key.js
Created Feb 11, 2016
Takes a collection of data and removes any duplicates, based on key, thare are not null. If the key value is null, it is not filtered out.
View dedupe-not-null-by-key.js
var deDupeNonNull = function(data, key){
var used = [];
return _.reduce(data, function(cur, data){
if(!!data[key] && !_.includes(used, data[key])){
used.push(data[key]);
cur.push(data);
}
else if(!data[key]) {
cur.push(data);
View validator.js
'use strict';
var filter = require('lodash/collection/filter');
var typeRegexes = {
/*eslint-disable */
email: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i
You can’t perform that action at this time.