Skip to content

Instantly share code, notes, and snippets.

View Slackwise's full-sized avatar
🛸
Evangelizing Lisp

Adam Flanczewski Slackwise

🛸
Evangelizing Lisp
View GitHub Profile
@Slackwise
Slackwise / oledtest.pde
Created July 16, 2024 03:18 — forked from marcedwards/oledtest.pde
OLED black smearing test for Processing 3.4
// OLED black smearing test for Processing 3.4.
// Black smearing = changing pixels to and from pure black is slower than changing to and from other colours.
//
// Code by @marcedwards from @bjango.
void setup() {
size(360, 360, P2D);
frameRate(60);
smooth(8);
noStroke();
@Slackwise
Slackwise / force_time_sync_win.rb
Last active February 5, 2024 00:39
I hibernate my VMs at work when I'm done, and the time is always off. I can't just sync with w32tm because if I'm more than 24 hours off, it will refuse to sync.
require 'net/ntp' # gem install net-ntp
# Windows' date command expects MM/DD/YYYY, e.g. 5/15/2009
DATE_FORMAT = '%m/%d/%Y'
# Windows' time command expects HH:MM:SS AM/PM, e.g. 5:34:00 PM
TIME_FORMAT = '%I:%M:%S %p'
# External NTP is now firewalled :(
NTP_SERVER = 'MILLDATA'
@Slackwise
Slackwise / gist:f7594c993d84f8707d30ae49471d765d
Last active June 12, 2023 01:52 — forked from dangerous/gist:98b2b158b5625f837b8bdce43a965b3f
First 10000 reddit users sourced from karmalb
1. kn0thing
2. spez
3. third
4. fifth
5. fourth
6. agentorange
7. chickenlittle
8. erzengel
9. fizzypop
10. madmax2
@Slackwise
Slackwise / compile-less.js
Created March 30, 2023 20:15
NPM script to compile LESS files because the Visual Studio "Web Compiler" extension doesn't work anymore.
import fs from 'fs';
import { exec } from 'child_process';
const compilationConfig = JSON.parse(fs.readFileSync('compilerconfig.json', 'utf8'));
compilationConfig
.filter(fileConfig => fileConfig.inputFile.endsWith('.less'))
.map(({outputFile, inputFile, minify}) => {
try {
console.log("LESS\tInput:\t" + inputFile);
@Slackwise
Slackwise / getByPath.js
Created January 19, 2023 21:23
Recursively navigates into nested collections inside `collection` by following a sequence of properties `pathArray`, executing any methods along the way, and returning the first `undefined` encountered.
/**
* Recursively navigates into nested collections inside `collection` by
* following a sequence of properties `pathArray`, executing any methods
* along the way, and returning the first `undefined` encountered.
* @param {any} collection - The collection to traverse.
* @param {Array<string|number|function()>} pathArray - A sequence of
* property names, indexes, or functions to traverse into the `collection`.
* @returns {any|undefined} The final value found,
* otherwise the first `undefined` encountered.
* @example
@Slackwise
Slackwise / schrodingersCat.js
Last active January 13, 2023 23:52
Function definition modeling Schrodinger's Cat.
const cat = {
get state() {
delete this.state;
this.state = Math.random() >= 0.5 ? 'Alive' : 'Dead';
return this.state;
}
};
@Slackwise
Slackwise / Fallout76Custom.ini
Created November 1, 2021 17:47
My Fallout 76 config to disable junk like vsync, mouse accel, DOF, etc.
[General]
bGamepadEnable=0
sIntroSequence=0
bSkipSplash=1
bDisableAllGore=0
[Display]
uiOrthoShadowFilter=3
bVolumetricLightingEnable=0
iSize H=1080
iSize W=1920
@Slackwise
Slackwise / advise.js
Last active October 6, 2021 17:59
Example advising function and use.
const advise = (fn, preFn = (...args) => args, postFn = (...args) => args) =>
(...args) =>
postFn(fn(...preFn(...args)));
add = (x, y) =>
x + y;
advisedAdd = advise(
add,
@Slackwise
Slackwise / logged.js
Last active May 10, 2021 12:58
JavaScript HOF for creating logged functions.
const logged = logF => f =>
(...args) => {
const output = f(...args);
console.log(logF(args, output));
return output;
};
function writeFile(filename) {
console.log(`[ACTUALLY DOING STUFF WITH ${filename}]`);
}
@Slackwise
Slackwise / closureListReduce.js
Last active March 4, 2021 06:23
Implemented the cons cell linked list data structure as well as reduce() using only recursive curried functions and closures.
cons = a => b => f => f(a)(b)
car = a => b => a
cdr = a => b => b
reduce = f => i => l =>
l
? reduce (f) (f(i)(l(car))) (l(cdr))
: i
l = cons(1)(cons(2)(cons(3)(null)))