Skip to content

Instantly share code, notes, and snippets.

View djmill0326's full-sized avatar
🌴
On vacation

Dylan Miller djmill0326

🌴
On vacation
  • LLCLC Long-Playing Cap-LLC (Cap. Long-Long-Capacity) Record Vinyl Production LLC
  • Columbus, OH
View GitHub Profile
@djmill0326
djmill0326 / server.mjs
Created May 22, 2024 21:53
web server (serves web)
import { createServer } from "http"
import { createReadStream } from "fs"
import { createGzip } from "zlib"
import { stat } from "fs/promises"
const PORT = 3000
const STATIC_ROOT = "./web"
const CACHE_AGE = 60
const CACHE_HEADER = `public, max-age=${CACHE_AGE}`
@djmill0326
djmill0326 / wtf.js
Created March 7, 2024 10:25
some experiments
/* functional bullshit */
const narg = (f, n) => (...args) => f(...args.slice(0, n));
const argn = (f, n) => (...args) => f(...args.slice(n));
const nargn = (f, n, start) => (...args) => f(...args.slice(start, start + n));
const split = (f) => (...args) => args.forEach(x => f(x));
const spmap = (f) => (...args) => args.map(x => f(x));
const resv = (f, callback) => (...args) => callback(f(...args));
const side = (f, ...rest) => (...args) => resv(f, arg => rest.forEach(f => f(arg)))(...args);
@djmill0326
djmill0326 / active.rs
Last active February 29, 2024 08:37
active variables blah blah blah
use std::{cell::UnsafeCell, collections::{HashMap, HashSet}, marker::PhantomData, mem::size_of};
// no error handling, unsafe everywhere. bad code. don't use
macro_rules! global {
($name: ident: $type: ident) => {
static mut $name: Option<$type> = None;
};
($name: ident: $type: ident = $default: expr) => {
static mut $name: Option<$type> = Some($default);
@djmill0326
djmill0326 / csv.js
Last active February 27, 2024 21:39
it was all csv this whole time?
const Value = (data, transform, validation) => ({
data, cache: null, listeners: new Set(),
resolve: transform ?
function () {
if (!this.cache) this.cache = transform(this.data, this.index);
return this.cache;
}
: function () { return this.data; },
_update_and_notify: function (value) {
const old_value = this.data;
const bind_id = 0;
export const bind_variable = (value, name="bound") => Object.seal({
name: name.length && name !== "bound" ? name.toString() : "bound" + bind_id++,
value: null,
pending: value,
bindings: new Map(),
listen: function (on_update = (value, previous, tag) => {}) {
this.bindings.set(on_update, (value, previous, tag) => {
console.debug(`<bound ${this.name}/callback/${tag}> updated from ${previous} to ${value}`);
@djmill0326
djmill0326 / mk.ts
Created February 21, 2024 05:52
MK ULTRA
'use evil mode';
const TRADE_NAME = "MK ULTRA";
const mk_handler = (context: ReturnType<typeof mk_context>) => {
const Ctx: {
event_handlers: Map<HTMLElement, Map<string, (ev: Event, context: ReturnType<typeof mk_context>) => boolean>>,
proxy_pass: (el: HTMLElement, event_name: string, ev: Event) => any,
set_event_listener: (el: HTMLElement, event_name: string, f: (ev: Event, context?: ReturnType<typeof mk_context>) => boolean) => any
} = {
var scripts = {
"guesser": "https://gist.githubusercontent.com/djmill0326/3f09d644e0c30657100d1fdcf5e739be/raw/7e0ffdef8bb7087bc8ce194e37dc12cdcbc6842f/thing.js",
"searchbuttons": "https://greasyfork.org/scripts/7543-google-search-extra-buttons/code/Google%20Search%20Extra%20Buttons.user.js",
"translatetooltip": "https://openuserjs.org/install/trespassersW/translate.google_tooltip.min.user.js"
};
function fetchAndRunScript(url){
fetch(url, {mode: 'cors'}).then(
function(response){
response.text().then(
function guesser() {
var randomNumber = Math.floor(Math.random() * 100) + 1;
var guessCorrect = false;
alert("Time to play a guessing game.");
while(!guessCorrect) {
var answer = prompt("Guess the number 1-100. Type exit to stop.");
if (answer.toLowerCase()==="exit") {
alert("Seeya.");
return;
}