Skip to content

Instantly share code, notes, and snippets.

View jdan's full-sized avatar
🐫
- : int -> int -> int = <fun>

Jordan Scales jdan

🐫
- : int -> int -> int = <fun>
View GitHub Profile
@jdan
jdan / collatz.py
Created January 22, 2024 01:50
Linear equations that start with a given sequence of moves in the collatz conjecture
import typing
import math
def collatz(n: int) -> typing.List[int]:
"""Returns the Collatz sequence starting at n."""
seq = [n]
while n != 1:
if n % 2 == 0:
n = n // 2
else:
@jdan
jdan / machine.js
Created July 10, 2021 18:34
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'machine',
initial: 'start',
states: {
start: {
on: {
"0.05-Lia": "Lia",
"0.1-Oli": "Oli",
"0.05-Noa": "Noa",
"0.05-Emm": "Emm",
@jdan
jdan / hashart.c
Created April 16, 2021 22:32
Arduino code to display hash.jordanscales.com art on an inkplate.io display
#include "Inkplate.h"
#include <HTTPClient.h>
#include <WiFi.h>
Inkplate display(INKPLATE_1BIT);
// https://github.com/jdan/hashart#a-small-screenshot-service
char *url = "https://FILLMEIN/random/800/600/random.png";
void setup()
@jdan
jdan / fib.lean
Created March 21, 2021 17:05
sum of the first n fibonacci numbers is the n+2'th fibonacci number - 1
import tactic
open nat
@[simp] def fib : ℕ -> ℕ
| 0 := 0
| 1 := 1
| (succ (succ n)) := fib n + fib (succ n)
@[simp] def sum_first_fib : ℕ -> ℕ
| 0 := 0

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@jdan
jdan / seven-segment.pl
Created March 7, 2021 01:39
seven-segment.pl
word(0, [0, 0, 0, 0]).
word(1, [0, 0, 0, 1]).
word(2, [0, 0, 1, 0]).
word(3, [0, 0, 1, 1]).
word(4, [0, 1, 0, 0]).
word(5, [0, 1, 0, 1]).
word(6, [0, 1, 1, 0]).
word(7, [0, 1, 1, 1]).
word(8, [1, 0, 0, 0]).
word(9, [1, 0, 0, 1]).
@jdan
jdan / stack-compiler.rkt
Created December 31, 2020 03:01
A scheme (in scheme) that compilers to a stack machine
#lang racket
(define current-idx 0)
(define (get-fresh-param!)
(let [(idx current-idx)]
(set! current-idx (+ idx 1))
(string->symbol
(string-append "?" (number->string idx)))))
(define (compile exp)
@jdan
jdan / README.md
Last active December 19, 2020 21:39

docker-compose for minecraft

This docker compose file spins up two Minecraft (Bedrock Edition - phones, ipads, consoles, windows 10) servers. One creative (port 19132, the default one) and one survival (port 29132).

I was surprised how easy it was because I've fiddled with Minecraft servers in the past a few times to varying degrees of success.

Now my niece, nephew, and I can bury ourselves in our iPads on christmas while we social distance. (And for those not traveling for the holidays - thank you! - hopefully this makes you feel a little more connected)

More documentation on itzg/minecraft-bedrock-server here

@jdan
jdan / maybe.js
Last active November 11, 2020 18:58
maybe as valueOf
let oracle = [];
class Maybe {
constructor(isNothing, value) {
this.isNothing = isNothing;
this.value = value;
}
valueOf() {
oracle.push(this);
}
@jdan
jdan / ContentView.swift
Created September 18, 2020 12:20
jdan app
//
// ContentView.swift
// Shared
//
// Created by Jordan Scales on 7/25/20.
//
import SwiftUI
import SwiftUIRefresh
struct Response: Codable {