Skip to content

Instantly share code, notes, and snippets.

View daniellizik's full-sized avatar

Daniel Lizik daniellizik

  • Tablecheck
  • Tokyo, JP
View GitHub Profile
@daniellizik
daniellizik / path-generator.js
Last active May 18, 2022 03:03
Generate browser query selector string from a given dom element
'use strict';
(() => {
class QuerySelector {
constructor(origin) {
/**
* :nth-of-type is only ie9+ https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type
@daniellizik
daniellizik / deepsearch-find-first-object.js
Last active May 22, 2016 04:15
deepsearch find object
'use strict';
function deepsearch_find_first_object(needle, haystack, parent) {
let iterable;
if (Object.prototype.toString.call(haystack) === '[object Array]') {
iterable = haystack;
} else if (Object.prototype.toString.call(haystack) === '[object Object]') {
iterable = Object.keys(haystack);
@daniellizik
daniellizik / pathfinder.js
Last active May 18, 2016 17:52
searches haystack for needle and returns array of tree nodes from correct path
function pathfinder(needle, haystack, child = haystack, parent, result = [], path = [], paths = [[[haystack]]], siblingIndex = 0, depthIndex = 0, rootIndex, onRoot) {
let iterable = [];
if (Object.prototype.toString.call(child) === '[object Array]') {
iterable = child;
} else if (Object.prototype.toString.call(child) === '[object Object]') {
iterable = Object.keys(child);
}
@daniellizik
daniellizik / deepsearch-find-first-make-path.js
Created May 17, 2016 03:54
deepsearch find first, make path
function deepsearch_find_first_make_path(needle, haystack, delimiter = '.', path = []) {
let i = 0;
let p;
let found;
if (Object.prototype.toString.call(haystack) === '[object Array]') {
for (i; i < haystack.length; i++) {
found = deepsearch_find_first_make_path(needle, haystack[i], delimiter, path.concat(i));
if (found && found !== path) {
@daniellizik
daniellizik / deepsearch-pull-matches.js
Last active May 17, 2016 03:10
deep search, pull all matches
function deepsearch_pull_matches(needle, haystack, parent, bucket = []) {
let i = 0;
let p;
let found;
if (Object.prototype.toString.call(haystack) === '[object Array]') {
for (i; i < haystack.length; i++) {
found = ds(needle, haystack[i], haystack, bucket);
if (found !== undefined && found !== bucket)
@daniellizik
daniellizik / deepsearch-get-keys.js
Last active May 17, 2016 03:10
deep search key accumulate
function deepsearch_get_keys(haystack, bucket = []) {
let i = 0;
let p;
if (Object.prototype.toString.call(haystack) === '[object Array]') {
for (i; i < haystack.length; i++)
ds(haystack[i], bucket);
}
@daniellizik
daniellizik / deepsearch-find-first.js
Last active May 22, 2016 03:02
needle/haystack deep search, searches for value if it matches a key and will stop execution once found.
'use strict';
function deepsearch_find_first(needle, haystack, parent) {
let iterable;
if (Object.prototype.toString.call(haystack) === '[object Array]') {
iterable = haystack;
} else if (Object.prototype.toString.call(haystack) === '[object Object]') {
iterable = Object.keys(haystack);
@daniellizik
daniellizik / constants.yml
Last active April 24, 2016 18:48
webpack, postcss (import, map, nested, lost, autoprefix), hmr, middleware, express
breakpoints:
mobile:
max: "600px"
tablet:
min: "601px"
max: "1000px"
desktop:
min: "1001px"
@daniellizik
daniellizik / log.js
Created April 22, 2016 16:04
colorful logging in chrome
(function(root, name, factory) {
root[name] = factory();
})(this, 'Log', function() {
'use strict';
/**
* @constructor Log
* logs pretty, easy
*
* @param {string} - message to log
@daniellizik
daniellizik / webpack.config.development.js
Created April 21, 2016 04:06
express, angular 1x, webpack, HMR, webpack dev middleware, stylus loading
var path = require('path'),
webpack = require('webpack'),
packageJson = require('./package.json');
module.exports = {
devtool: 'eval',
context: __dirname,