Skip to content

Instantly share code, notes, and snippets.

View jreina's full-sized avatar
🛠️
reticulating splines

Johnny Reina jreina

🛠️
reticulating splines
View GitHub Profile
@jreina
jreina / convert.bat
Created November 12, 2024 21:23
Convert M4A from Windows Recorder to WAV
FOR %G IN (*.m4a) DO avconv -i "%G" "%~nG.wav"
@jreina
jreina / tandem.js
Created November 3, 2022 20:08
Tandem Selectors
// The emote button on the bottom of the screen
const emote = document.getElementById('rockets');
// The high-five button on the bottom of the screen
const highfive = document.getElementById('high-five');
@jreina
jreina / keybase.md
Created February 27, 2021 20:46
keybase.md

Keybase proof

I hereby claim:

  • I am jreina on github.
  • I am johnnyreina (https://keybase.io/johnnyreina) on keybase.
  • I have a public key whose fingerprint is C2A4 84D1 23F2 46DB 7E10 8D1E 0AE3 B93B 76AD 9E0E

To claim this, I am signing this object:

@jreina
jreina / scrambleSort.js
Last active October 27, 2020 21:19
ScrambleSort
/**
* @template T
* @param {Array<T>} arr
* @returns {Array<T>}
*/
function scramble(arr) {
arr.sort(() => 0.5 - Math.random());
return arr;
}
@jreina
jreina / GroupBy1.js
Created October 11, 2020 20:29
GroupBy1
fn = function(xs, keySelector) {
if (!Array.isArray(xs)) throw new TypeError('xs must be an array');
if (typeof keySelector !== 'function') throw new TypeError('keySelector must be a function');
const groups = new Map();
for (let x of xs) {
const key = keySelector(x);
if (!groups.has(key)) groups.set(key, []);
groups.get(key).push(x);
}
const groupings = [...groups.entries(groups)].map(([key, items]) => {
@jreina
jreina / GroupBy.js
Last active October 22, 2020 13:41
GroupBy
fn = function(xs, keySelector) {
if (!Array.isArray(xs)) throw new TypeError('xs must be an array');
if (typeof keySelector !== 'function') throw new TypeError('keySelector must be a function');
const groups = new Map();
for (let x of xs) {
const key = keySelector(x);
if (!groups.has(key)) groups.set(key, []);
groups.get(key).push(x);
}
const groupings = [...groups.entries(groups)].map(([key, items]) => {
@jreina
jreina / Aggregate2.js
Created October 6, 2020 00:17
Aggregate2
fn = function(xs, seed, reducer, resultSelector) {
if (!Array.isArray(xs)) throw new TypeError('xs must be an array');
if (typeof reducer !== 'function' || reducer.length !== 2) throw new TypeError('reducer must be a function of arity 2');
if (typeof resultSelector !== 'function') throw new TypeError('resultSelector must be a function');
let val = seed;
for (let x of xs) {
val = reducer(val, x);
}
return resultSelector(val);
@jreina
jreina / Aggregate1.js
Last active October 22, 2020 13:41
Aggregate1
fn = function(xs, reducer) {
if (!Array.isArray(xs)) throw new TypeError('xs must be an array');
if (typeof reducer !== 'function' || reducer.length !== 2) throw new TypeError('reducer must be a function of arity 2');
if (xs.length === 0) throw new Error('Sequence must contain at least one element');
let [val, ...rest] = xs;
for (let x of rest) {
val = reducer(val, x);
}
return val;
@jreina
jreina / Aggregate.js
Created October 5, 2020 23:12
Aggregate.js
fn = function(xs, seed, reducer) {
if (!Array.isArray(xs)) throw new TypeError('xs must be an array');
if (typeof reducer !== 'function' || reducer.length !== 2) throw new TypeError('reducer must be a function of arity 2');
if (xs.length === 0) return seed;
let val = seed;
for (let x of xs) {
val = reducer(val, x);
}
return val;
@jreina
jreina / Map.js
Last active October 22, 2020 13:42
Map
fn = function(xs, xform) {
const arr = [];
for(let x of xs) {
arr.push(xform(x));
}
return arr;
}