Skip to content

Instantly share code, notes, and snippets.

View jazzyjackson's full-sized avatar

Colten Jackson jazzyjackson

View GitHub Profile
/*
This provides a getter / setter / emitter API for modifying HTML attributes
To replace element.setAttribute('name','nobody') with element.props.name = 'nobody'
And proviede a hook into being notified of attributes that are changed with this API
element.onAttributeChanged = function()
*/
// you have to pass the HTMLElement context to the function,
function updateAttribute(prop, newValue){
let attributeChange = {attribute: prop, oldValue: this.getAttribute(prop)}
ExportVideo[prefix_, framerate_, frames_] := Module[{
digits = Ceiling @ Log10 @ Length @ frames
},
(* create directory (OK if already exist,
prints error and continues *)
CreateDirectory[prefix];
(* export each frame as a png with an enumerated filename,
padded with zeroes *)
Table[
Export[
import {ELElement, ELHTMLComment, ELHTMLStyleElement, ELHTMLElement, ELCSSStyleDeclaration, ELCSSStyleSheet} from "./schemas/elementary"
/**
*
* Elementary has to decide what to do based on the data structure passd to it
* An array is recursed over, an object is made into an HTMLElement or an HTMLStyleELement
* Null is turned into a blank string, bool, numbers and strings are returned as strings.
*/
function elementary(el: ELElement | ELElement[]) : string
{
GemetriaTable = AssociationThread[
Alphabet["Hebrew"],
Join[
Range[1, 9, 1],
Range[10, 90, 10],
Range[100, 400, 100]
]
]
Unfinalize = { "ם" -> "מ", "ן" -> "נ", "ץ" -> "צ", "ף" -> "פ", "ך" -> "כ" , "." -> ""}
class CodemirrorBlock extends TextareaBlock {
constructor(props){
super(props)
this.defaultCodeMirror = {
lineNumbers: true,
// if whitespace value is "wrap" set lineWrapping to true, else lineWrapping is false (default)
lineWrapping: this.getAttribute('whitespace') == 'wrap',
}
}
if [[ $1 =~ '^python=[0-9.]+$' ]]
then
pythonversion=$1 # else if there's 2 arguments, use the first as python version
pythonscript=$2 # and second as path of python script
pyargs="${@:3}" # any remaining arguments will be passed to python
else
pythonversion="python=3.6" # if there's only one argument default to python 3.6
pythonscript=$1 # and use first argument as python script
pyargs=$"${@:2}" # any remaining arguments will be passed to python
fi
/* - Public Domain software by Colten Jackson
* - make a global method to prefer over 'fetch' api
* - pass an object to convert key:value pairs to a properly encoded querystring (k:v, hence, kvetch)
* - use a Proxy with a getter so you can call 'kvetch.get()','kvetch.put()','kvetch.delete()' and so on with a single function
* * */
(function(){
let kv2query = kv => Object.keys(kv || {}).map(key => {
var value = kv[key]
return encodeURIComponent(key) + '=' + encodeURIComponent(value)
}).join('&')
<!-- an example of using the kvetch function -->
<!-- https://github.com/jazzyjackson/kvetch.js -->
<script src="wherever you cloned this file/kvetch.js">
<script>
kvetch.get('/', {anything: 'you want'})
// becomes '/?anything=you%20want'
kvetch.post('/somedata', null, {
"key-1" : "some data you want to send as a JSON body",
"key-b" : "the headers and cookies and everything else are handled for you"
// // edit this first line and call it whatever you want. overwrite document.createElement for all I car.
// // actually maybe that will be a nice upgrade. grab original createElement for safe keeping. if type is string, just call createElement. But I'll keep the two separate for now, and call mixint.createElement to be verbose that I'm doing something different
window.expand = function(graph){
if(!graph) throw new Error("You didn't give me a graph to work with")
// document.createElement can handle a string just fine you don't need me.
if(graph.constructor == String) return document.createElement(graph)
// otherwise let's recurse the graph and create some nodes
let [ tagName, attrObj ] = Object.entries(graph)[0]
let node = document.createElement(tagName)
// references to childNodes will be created in every node's .child property
#!/usr/bin/env python
# must be run with pyvalidate in PYTHONPATH
# condavision uses PYTHONPATH to check dependencies
import pandas,numpy
import StringIO, time
import pyvalidate
valid = pyvalidate.parameters({
"rows": {
"type":"number::int",