Skip to content

Instantly share code, notes, and snippets.

Avatar

Colten Jackson jazzyjackson

View GitHub Profile
View bitclout-api-example.json
{
"ProfilesFound": [
{
"PublicKeyBase58Check": "BC1YLi6LpXTemAG8T9ptyWAkMywrjynwZcKjB5DkDXxrsG5kgAwAqxq",
"Username": "maebeam",
"Description": "buidling bitclout",
"ProfilePic": "data:image/jpeg;base64,/9j/2wCEAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDIBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAGQAZAMBIgACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APTqSlq
View advent_day2a.js
let input = [
"1-3 a: abcde",
"1-3 b: cdefg",
"2-9 c: ccccccccc"
]
// wrong
// function testpassword(line){
// let [_, lower, upper, char, password] = line.match(/^(\d+)-(\d+)\s(\w):\s(\w+)$/)
// console.log(line, {lower, upper, char, password})
View adventofcalendarday1_c.js
// Find the complement to each highest number and search the lower numbers for the complement
// So it could be recursive, given a sorted array, loop through it from the top down, handing the lower half of the list to yourself
// base case: I have 2 numbers to fill.
let goal = 2020
let list = [1721, 979, 366, 299, 675, 1456]
let [a,b] = findsum(list, goal, 2)
console.log(a, b, a + b, a * b)
// 1721 299 2020 514579
View adventofcalendarday1.js
// blackjack sum
// given a goal sum and a list of integers, find pairs that add up to the goal
// return their product
// worse-case quadratic, for each in the list, I check all possibilities from the bottom up
// start at the highest number, scan up from the bottom, as soon as I break my goal I exit
let goal = 2020
let bottomup = [1721, 979, 366, 299, 675, 1456].sort((a,b) => a - b) // sort from the largest to the smallest
let topdown = bottomup.slice().reverse()
View adventofcalendarday1_b.js
// complement sum
// ask "what is the complement for x number" and then "Do I have it?"
let goal = 2020
let marbles = new Set([1721, 979, 366, 299, 675, 1456])
let complement
main:
for(var marble of marbles){
complement = goal - marble
if(marbles.has(complement)){
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[