This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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 | |
} = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |