Skip to content

Instantly share code, notes, and snippets.

View skiano's full-sized avatar

Greg Skiano skiano

View GitHub Profile
// SOLUTION 1
const getBlobBoundingBox1 = (blobString) => {
blobString = blobString.trim()
const width = (/\s/.exec(blobString) || {}).index
const one = /1/g
blobString = blobString.replace(/\s+/g, '')
@skiano
skiano / linked.js
Last active September 28, 2018 02:46
little doubly linked list
function createList() {
var next = 'prev'
, prev = 'next'
, length = 0
, head
, tail
, arr
, n;
return {
@skiano
skiano / traverse.js
Created February 9, 2022 05:36
gen traverse but skip dulicates!
function* each(arr) {
let i;
for (i = 0; i < arr.length; i++) yield arr[i];
}
export function* traverse (arr) {
let queue = [each(arr)];
let seen = new WeakSet();
while (queue.length) {
@skiano
skiano / tag.js
Created August 11, 2022 22:51
A helper for creating dom stuff
function create(tag, attr = {}, children = []) {
children = Array.isArray(children) ? children : [children];
const elm = document.createElement(tag);
for (let a in attr) {
if (a.startsWith('on')) {
elm.addEventListener(a.slice(2).toLowerCase(), attr[a])
} else {
if (attr[a]) elm.setAttribute(a, attr[a]);
}
}