Some tools to help with measuring out and keeping track of your nootropic stacks
A :: Large orange scoop with flat bottom
B :: Short white round-bottomed scoop
C :: Long-handled white scoop with partially flattened bottom
D :: Blue microscoop
/** | |
* @example | |
* let testObject = {a:{b:{c:false}}} | |
* // instead of this: | |
* let v1 = null; | |
* if ( | |
* testObject !== null && | |
* typeof testObject == 'object' && | |
* testObject.hasOwnProperty('a') && | |
* testObject.a !== null && |
alias alias.edit='$EDITOR ~/.bash_aliases' | |
alias alias.load='. ~/.bash_aliases' | |
alias alias.save='alias > ~/.bash_aliases' | |
alias alias.to.here='f(){ alias ${@}="cd $(pwd)"; echo -e "\n Alias Created: ${@} -> $(pwd)\n"; unset -f f; }; f' | |
alias bash.edit='$EDITOR ~/.bash_profile' | |
alias bash.load='. ~/.bash_profile' | |
alias ll='ls -FGplah' | |
alias lls='du -sh * | sort -h' | |
alias gh='history|grep --context=0' | |
alias tree.size='f(){ level=${1-1}; shift; tree -vhaF -C --sort=name --dirsfirst -L ${#level} ${@}; unset -f f; }; f' |
const watch = (() => { | |
const isWatched = Symbol('watched') | |
const w = (tgt, obs = [], route = []) => { | |
const isObj = (x) => (typeof x === 'object' && x !== null) || typeof x === 'function' | |
const __path = (obj, prop, prefix) => prefix.join('.') | |
const __watched = (obj, prop, prefix) => isWatched in obj | |
const __unwatch = (obj, prop, prefix) => tgt | |
const mx = { __path, __watched, __unwatch } |
const output = (() => { | |
const o = (msg) => { o.w(`${msg || ''}\n`); return o } | |
o.w = (msg) => { process.stdout.write(msg); return o } | |
o.h1 = (msg = '') => { o.pad(msg.length, '#')()(msg).pad(msg.length, '#')(); return o } | |
o.h2 = (msg = '') => { o(msg).pad(msg.length, '-')()(); return o } | |
o.h3 = (msg = '') => { o.pad(5, '>')(msg)(); return o } | |
o.tab = (n = 1) => { process.stdout.write(Array(n).join('\t')); return o } | |
o.pad = (n = 1, char = ' ') => { process.stdout.write(Array(n+1).join(char || ' ')); return o } | |
o.nl = (n = 1) => { o.pad(n, '\n'); return o } | |
return o |
/** | |
* Conditional polyfill loading using dynamic import | |
*/ | |
export default async () => { | |
if (window) { | |
if ( | |
['fetch', 'Intl', 'Map', 'URL'].find(p => !(p in window)) !== undefined || | |
['assign', 'entries', 'keys'].find(p => !(p in Object)) !== undefined || | |
['endsWith', 'includes', 'startsWith'].find(p => !(p in String.prototype)) !== undefined || | |
['forEach'].find(p => !(p in NodeList.prototype)) !== undefined || |
/** | |
Syntax for $(q,c) | |
$('div.someClass') // [<div.someClass />,<div.someClass />] | |
$$('div.someClass') // $$[<div.someClass />,<div.someClass />] | |
.first() // <div.someClass /> | |
.$first() // $$[<div.someClass />] | |
.last() // <div.someClass /> | |
.$last() // $$[<div.someClass />] |
var classList=function(elem){ | |
return new function(){ | |
var self=this | |
this._el = elem | |
Object.defineProperty(this,'classList',{ | |
get: function(name){ | |
return this._el.className.trim().replace(/\s+/ig,' ').split(' ') | |
}.bind(this) | |
}) |
const ClassName = (() => { | |
// Privately Accessible Data | |
const instancesData = new WeakMap() | |
let instanceData //Stores data by instance | |
let classData = {} //Stores data for the class | |
// Privately Accessible Functions | |
class Pvt { | |
constructor() { return Pvt; }// no instantiation | |
static somePrivateFunction() { |
function tag(html){ | |
return((html)=>{ | |
let container=document.createElement('div') | |
let frag = document.createDocumentFragment() | |
container.innerHTML=html | |
Array.prototype.slice.call(container.childNodes).forEach(node=>{ | |
console.log(`adding ${node}`) | |
frag.appendChild(node) | |
}) | |
return frag |