Entries are sorted by author last name.
- Abelson, Harold
- Structure and Interpretation of Computer Programs
- Adams, Douglas
- The Hitchhiker's Guide to the Galaxy
- Aho, Alfred Vaino
- Compilers: Principles, Techniques, & Tools
| const pass = (fn, value) => { | |
| fn(value); | |
| return value; | |
| }; | |
| const UP = (point, fn) => pass(fn, [point[0], point[1] + 1]), | |
| DOWN = (point, fn) => pass(fn, [point[0], point[1] - 1]), | |
| LEFT = (point, fn) => pass(fn, [point[0] - 1, point[1]]), | |
| RIGHT = (point, fn) => pass(fn, [point[0] + 1, point[1]]); |
| #!/usr/bin/env node | |
| // quick and dirty script for downloading pixiv ugoira animations | |
| // dependencies: node-fetch, 7zip (external) | |
| const fetch = require("node-fetch"); | |
| const util = require("util"); | |
| const fs = require("fs"); | |
| const exec = util.promisify(require("child_process").exec); |
| const nthPrime = (n) => { | |
| // conservative upper bound for nth prime is n log(n log n) | |
| // works for all n >= 6 | |
| const max = Math.floor(n * Math.log(n * Math.log(n))); | |
| // allocate sieve | |
| const sieve = new Uint8Array(Math.ceil(max / 8)).fill(0); | |
| // we need to keep track of how many primes we've encountered so far because the upper bound probably includes more than `n` primes |
| // query making helper | |
| // written while feeling very sick | |
| class Query { | |
| constructor(db, tableName) { | |
| this.db = db; | |
| this.tableName = tableName; | |
| } |
| // quick and dirty cache | |
| module.exports = class { | |
| constructor(maxAge, maxSize) { | |
| this.maxAge = maxAge; | |
| this.maxSize = maxSize; | |
| this.cache = new Map(); | |
| } |
| // crude, primitive module for tackling CSVs | |
| // use something better i beg | |
| const parseCSV = (text, delimiter = ",") => { | |
| // extract column headers | |
| const firstNewline = text.indexOf("\n"); | |
| const columns = text.slice(0, firstNewline).split(delimiter); | |
| // read |
| // deps | |
| const net = require("net"); | |
| const makeVarInt = (value) => { | |
| const buf = []; | |
| do { | |
| let cur = value & 0b01111111; | |
| value >>>= 7; | |
| if(value != 0) { | |
| cur |= 0b10000000; |
| <html> | |
| <head> | |
| <title>Mandelbrot</title> | |
| </head> | |
| <body> | |
| <canvas id="output" width="600" height="400" style="border: 1px solid black;"></canvas> | |
| <script> | |
| const canvas = document.getElementById("output"); | |
| const ctx = canvas.getContext("2d"); |
| /* ACSEF Program: find prime numbers */ | |
| /* Compile with -DDEBUG to print all primes */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stdbool.h> | |
| #include <time.h> | |
| #define MAX_PRIME 100000000 |