Skip to content

Instantly share code, notes, and snippets.

Avatar

Colten Jackson jazzyjackson

View GitHub Profile
View latticeclock.nb
Manipulate[Module[{
time = Time2Rotation[seconds],
origin = {0, 0},
minutenorm = 6, (* length of minute hand the long side of the matrix *)
hournorm = 4, (* the length of the hour hand the short side of the matrix *)
minutehand, hourhand,
xbasis, ybasis, pts
},
xbasis = {Cos[time["minutespin"]], Sin[time["minutespin"]]};
ybasis = {Cos[time["hourspin"]], Sin[time["hourspin"]]};
View covidexample.html
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<style>
body {
max-width: 800px;
margin: 0 auto;
}
h2 {
text-align: center;
}
View FourToSixSymmetry.nb
FourToSixSymmetry[FourWayImage_] := Module[
{
Hex = Graphics[Polygon[CirclePoints[6]], ImageSize -> 720],
Quarter = Graphics@Polygon[{{-1, -1}, {-1, 1}, {0, 0}, {1, 1}, {-1, 1}}],
Equalateral, SixWay
},
Equalateral = ImageResize[ImageSubtract[FourWayImage, Quarter], {360, Sqrt[3]/2 * 720 }];
SixWay = Table[ImageRotate[Equalateral, i * Pi/3], {i, -3, 2}];
ImageAdd[Prepend[SixWay, Hex]]
]
View htmlprops.js
/*
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)}
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('&')
You can’t perform that action at this time.