Skip to content

Instantly share code, notes, and snippets.

Colten Jackson jazzyjackson

View GitHub Profile
View exportvideo.nb
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[
View elementary.ts
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
{
View Gemetria.mathematica
GemetriaTable = AssociationThread[
Alphabet["Hebrew"],
Join[
Range[1, 9, 1],
Range[10, 90, 10],
Range[100, 400, 100]
]
]
Unfinalize = { "ם" -> "מ", "ן" -> "נ", "ץ" -> "צ", "ף" -> "פ", "ך" -> "כ" , "." -> ""}
View class.js
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',
}
}
View condavision.sh
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
View kvetch.js
/* - 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('&')
View kvetch-example.html
<!-- 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"
View expand.js
// // 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
View local-file.py
#!/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",
View pyvalidate.py
# Python 2.7
from ConfigParser import *
import os, re, sys, json, io, atexit
import boto3
import time, datetime, traceback
def dictFromConfig(filepath):
config = ConfigParser()
config.read(filepath)
return {section.lower(): dict(config.items(section)) for section in config.sections()}
You can’t perform that action at this time.