Skip to content

Instantly share code, notes, and snippets.

Avatar
🛸
Evangelizing Lisp

Adam Flanczewski Slackwise

🛸
Evangelizing Lisp
View GitHub Profile
@Slackwise
Slackwise / Fallout76Custom.ini
Created Nov 1, 2021
My Fallout 76 config to disable junk like vsync, mouse accel, DOF, etc.
View Fallout76Custom.ini
[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 Oct 6, 2021
Example advising function and use.
View advise.js
const advise = (fn, preFn = (...args) => args, postFn = (...args) => args) =>
(...args) =>
postFn(fn(...preFn(...args)));
add = (x, y) =>
x + y;
advisedAdd = advise(
add,
View EnumBinding.cs
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 Dec 2, 2020
Run this in the Chrome console (Ctrl-Shift-J) on the input file.
View aoc2020_day1_part1.js
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 Feb 10, 2020
Arity matching functions in JavaScript
View arityMatch.js
// 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 Oct 30, 2019
Convert Roman Numerals to Integers.
View romanToInt.js
const values = {
I: 1,
V: 5,
X: 10,
L: 50,
C: 100,
D: 500,
M: 1000
};
@Slackwise
Slackwise / apiAdd.js
Last active Jul 19, 2019
There was a challenge someone mentioned of implementing addition without using the `+` operator... CHALLENGE ACCEPTED!
View apiAdd.js
function add(x, y) {
const apiUrl = `https://api.mathjs.org/v4/?expr=${x}%2B${y}`;
try {
let xhr = new XMLHttpRequest(apiUrl);
xhr.open('GET', apiUrl, false);
xhr.send();
return Number(xhr.responseText);
} catch (ex) {
console.log("Ya'll numbers fucky");
return NaN;
@Slackwise
Slackwise / grouping.js
Last active Jun 10, 2019
Vanilla ES6 functions to group database result sets, and example usage.
View grouping.js
returnedUsers = {
"users": [
{
"name": "dusan",
"id": 1,
"skill": "node.js",
"skill_id": 1
},
{
"name": "dusan",
@Slackwise
Slackwise / groupBy.js
Created Jun 9, 2019
Minimal implementation of an Array groupBy function.
View groupBy.js
// As a function:
const groupBy = (array, key) =>
array.reduce((a, c) => (
{
...a,
[c[key]]: [ ...a[c[key]] || [], c ]
}
), {});
// As a method:
@Slackwise
Slackwise / closureListReduce.js
Last active Mar 4, 2021
Implemented the cons cell linked list data structure as well as reduce() using only recursive curried functions and closures.
View closureListReduce.js
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)))