Skip to content

Instantly share code, notes, and snippets.

View Alwinfy's full-sized avatar

Alwinfy Alwinfy

  • United States
View GitHub Profile
@Alwinfy
Alwinfy / wikirace.clj
Last active September 23, 2023 22:56
find paths between wikipedia articles yay
(set! *warn-on-reflection* true)
(ns net.alwinfy.wikirace
(:require
[clojure.set :as set]
[clojure.string :as str]))
(import java.util.Scanner)
@Alwinfy
Alwinfy / parse.js
Last active September 23, 2020 21:34
no kill like overkill
class Parser {
static fact(n) {
return n > 0 ? n * Parser.fact(n - 1n) : 1n;
}
static npow(b, e) {
if (e < 0) return 0n;
let res = 1n;
while (e) {
if (e & 1n)
res *= b;
@Alwinfy
Alwinfy / numparse.cljc
Last active September 29, 2020 20:37
something something portability
(set! *warn-on-reflection* true)
(ns net.alwinfy.numparse)
; cljs hacks i cry
#?(:cljs (def num identity))
(def char->int #?(:clj int, :cljs #(.charCodeAt %)))
; Utilities
(defn lstrip [string]
@Alwinfy
Alwinfy / clisp.js
Last active November 18, 2020 19:55
cursed js clojure-style lisp
"use strict";
// TODO: Figure out how to get recursion to actually work
let RECURSION_DEPTH = 20,
TIME_LIMIT = 20000;
class CompileError extends SyntaxError {
constructor(string) {
super(string);
}
package your.package.here.mixin; // TODO fill this in properly
import net.minecraft.block.BlockState;
import net.minecraft.block.PistonBlockStructureHelper;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
This file has been truncated, but you can view the full file.
name = "jungle/path-01-entrance"
mapWidth = 70
mapHeight = 120
masterLevel = 1
[[levels]]
height = -16
[[levels]]
height = 0
@Alwinfy
Alwinfy / doot.rkt
Last active February 27, 2021 23:18
who needs wav libraries anyway: the repeat update
; Squished with the following vimscript command:
; %s/;.*//g | %s/\n/ /g | %s/\s\+/ /g | %s/\s*\([][()]\)\s*/\1/g | %s/notes-per-min/nm/g | %s/to-bytes/b/g | %s/sample-rate/sr/g | %s/bytes-per-sample/bps/g | %s/write-wav/ww/g | %s/note-freqs/nf/g | %s/note-lengt
h/nl/g | %s/note/n/g
(require racket/flonum)
(define sample-rate 8000)
(define bytes-per-sample 1) ; 8bit audio
(define (to-bytes num len)
(list->bytes
(let loop ([num num] [len len])
use std::collections::HashMap;
pub struct Scope<K, V> {
// Implementation note:
// Since HashMaps are presumably expensive to init,
// we count empty scopes pushed above a given scope
// until we actually attempt to add something.
bindings: Vec<(HashMap<K, V>, usize)>,
}
#![recursion_limit="256"]
// If anyone here wants to go fix rust-lang/rust#38078, that would be just FINE by me
use std::marker::PhantomData;
struct Nil;
struct Cons<H, T> { h: H, t: T }
trait First { type First; }
module Day04 (process) where
import Data.List (transpose, inits)
type Board = [[Integer]]
type State = [Integer]
split :: (a -> Bool) -> [a] -> [[a]]
split _ [] = []
split d s = x : split d (drop 1 y) where (x, y) = break d s