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 tokenize(s) { // OPS TERMS | |
return s.match(/([+*\-\/])|([\d\.]+)/g).map(function Token(t, i) { | |
return { | |
token: t, | |
type: isFinite(t) ? "num" : "op", | |
index: i, | |
value: isFinite(t) ? +t : "-+*\/".indexOf(t), // data value/op priority | |
}; | |
}); | |
}//end tokenize() |
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
"☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■" |
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
// ccby@dandavis | |
function ImmutableArray(){ | |
function odp(k,v){ Object.defineProperty(r,k,{value:v}); } | |
let r = [...arguments]; | |
if(r.length===1 && Array.isArray(r[0])) r = r[0]; | |
odp("push", function(){return ImmutableArray(r.concat(...arguments));}); |
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 odp(obj, get, set, isHidden){ | |
Object.defineProperty(obj, /^\w+/.exec(get), {get, set, enumerable: !isHidden}); | |
return odp.bind(this, obj); | |
} | |
// example usage in a class | |
class Ohm { | |
constructor(V, I){ | |
odp(this, _=>Ohm) | |
( v=>V, _=>V=_ ) |
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 Ohm(v, i, _){ | |
(_=(k, get, set) => Object.defineProperty(this, k, {get, set, enumerable: 1}) && _) | |
("v", _=>v, x=>v=x) | |
("i", _=>i, x=>i=x) | |
("w", _=>v*i, x=>i=x/v) | |
("r", _=>v/i, x=>i=v/x); | |
} | |
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
/* | |
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined | |
* in FIPS 180-1 | |
* Version 2.2 Copyright Paul Johnston 2000 - 2009. | |
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet | |
* Distributed under the BSD License | |
* See http://pajhome.org.uk/crypt/md5 for details. | |
*/ | |
// smooooshed by dandavis 2024. tested in jscript5.5 |
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 wc(name, def) { // webcomponent wrapper by dandavis. MIT. | |
const PROPS = Object.keys(def.props || {}); | |
class wcMaker extends HTMLElement { | |
constructor() { | |
super(); | |
console.info("constrtr", this.constructor); | |
const shadow = this.attachShadow({ |
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 fmt(String) { // modernized version of dean's tool in ie7.js | |
// Replace %n with arguments[n]. | |
// e.g. fmt("%1 %2%3 %2a %1%3", "she", "se", "lls") == "she sells sea shells"; | |
return String.replace(/%([\d])/g, fmt.call.bind([].at.bind(arguments))); | |
}; | |
// fmt("this is a %2 script, ain't it %1?", "cool", "dan"); | |
// fmt("this is a %2 script, ain't it %1?", "dan", "cool"); |
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 setClipboard(text) { | |
return navigator.clipboard.write( [new ClipboardItem({['text/plain']: new Blob([text], { type:'text/plain'}) })]); | |
} | |
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
var worker = new Worker('data:text/javascript,' + escape("setInterval(postMessage.bind(this,0), 1000)")); | |
worker.onmessage=console.info.bind(console); // attach your interval callback here |
NewerOlder