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 csvToJSON(csv) { | |
const lines = csv.split('\n') | |
const result = [] | |
const headers = lines[0].split(',') | |
for (let i = 1; i < lines.length; i++) { | |
if (!lines[i]) | |
continue | |
const obj = {} | |
const currentline = lines[i].split(',') |
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 nextUntil(elem, selector) { | |
let siblings = []; | |
elem = elem.nextElementSibling; | |
while(elem) { | |
if(elem.matches(selector)) break; | |
siblings.push(elem); | |
elem = elem.nextElementSibling; | |
} |
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 pbcopy(data) { | |
var proc = require('child_process').spawn('pbcopy'); | |
proc.stdin.write(data); proc.stdin.end(); | |
} | |
pbcopy(somObject); |
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
git config --global alias.lg "log --color --graph --pretty=format:'%Cblue%h%Creset -%C(red)%d%Creset %s %Cgreen(%cr)' --abbrev-commit" |
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 getParam(key, q) { | |
let pair = new RegExp(key + "=([^&#]*)"); | |
let match = q.match(pair); | |
return match ? match[1] : ''; | |
} |
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
window.addEventListener("message", e => { | |
let d = e.data; | |
if(d.sentinel == 'gofer' && d.type == 'resize') { | |
let f = document.querySelector(`iframe[src="${d.location}"]`); | |
if(f && f.style) { | |
f.style.height = `${d.height}px`; | |
} | |
} | |
}); |
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
<script> | |
class DomModule extends HTMLElement { | |
constructor() { | |
super(); | |
} | |
connectedCallback() { | |
this.register(); | |
} |
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 shuffle(array) { | |
var m = array.length, t, i; | |
while (m) { | |
i = Math.floor(Math.random() * m--); | |
t = array[m]; | |
array[m] = array[i]; | |
array[i] = t; | |
} | |
return 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
function debounce(func, wait, immediate) { | |
var timeout; | |
return function() { | |
var context = this, args = arguments; | |
var later = function() { | |
timeout = null; | |
if (!immediate) func.apply(context, args); | |
}; | |
var callNow = immediate && !timeout; | |
clearTimeout(timeout); |
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
Object.extend = function() { | |
var args = Array.prototype.slice.call(arguments); | |
var destination = args.shift(); | |
var i = 0; | |
while(i < args.length) { | |
var source = args[i]; | |
for(prop in source) { | |
if(Object.prototype.hasOwnProperty.call(source, prop)) { |
NewerOlder