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 / 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 / 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,
using System;
using System.ComponentModel;
using System.Reflection;
using System.Windows.Data;
public class EnumBindingSourceExtension : System.Windows.Markup.MarkupExtension
{
private Type _enumType;
public Type EnumType
{
@Slackwise
Slackwise / aoc2020_day1_part1.js
Created December 2, 2020 15:32
Run this in the Chrome console (Ctrl-Shift-J) on the input file.
const numbers = document.body.textContent.trim().split('\n').map(Number);
const set = new Set(numbers);
const goalSum = 2020;
const difference = n => goalSum - n;
const subtrahend = numbers.find(n => set.has(difference(n)));
const minuend = difference(subtrahend);
const product = subtrahend * minuend;
console.log(product);
@Slackwise
Slackwise / arityMatch.js
Created February 10, 2020 14:34
Arity matching functions in JavaScript
// Example 1 or 2-arity function f
const f = (...args) =>
[
(x) => console.log("One param"),
(x, y) => console.log("Two params")
][args.length-1](...args);
f(1) // "One param"
f(1, 2) // "Two param"
@Slackwise
Slackwise / romanToInt.js
Created October 30, 2019 02:42
Convert Roman Numerals to Integers.
const values = {
I: 1,
V: 5,
X: 10,
L: 50,
C: 100,
D: 500,
M: 1000
};