Skip to content

Instantly share code, notes, and snippets.

View slugbyte's full-sized avatar
⌨️

Duncan Marsh slugbyte

⌨️
View GitHub Profile
const canvasWidth = 400
const canvasHeight = 400
function randomRange(min, max){
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function getLocation(){
@slugbyte
slugbyte / simplefp.js
Created August 5, 2020 11:02
simple fp
export const identity = (data) => () => data;
export const partial = (fn, ...defaults) => (...args) => fn(...defaults, ...args);
export const partialFlip = (fn, ...defaults) => (...args) => fn(...args, ...defaults);
export const map = (fn) => (data) => Array.prototype.map.bind(data)(fn);
export const filter = (fn) => (data) => Array.prototype.filter.bind(data)(fn);
export const reduce = (fn, initial) => (data) => Array.prototype.reduce.bind(data)(fn, initial);
export const compose = (...fns) => (data) => reduce((result, next) => next(result), data)(fns);
export const composeFlip = (...fns) => compose(...fns.reverse());
export const compoesArray = (args) => compose(...args)
export const compoesArrayFlip = (args) => composeFlip(...args)
fetch_observable(){
curl -O https://api.observablehq.com/${1}.js?v=3
}
#!/usr/bin/env bash
# _ _
# __| | ___ | |_
# / _` |/ _ \| __|
# | (_| | (_) | |_
# \__,_|\___/ \__|
#
# an old sysconf tool I replaced with https://github.com/slugbyte/mold
for x in {0..15};do
x=$(( x * 16 ))
for y in {0..16};do
color=$(( x + y ))
echo -n $(tput setab $(( $color ))) $(tput setaf 15)
printf " %3g " $color
echo -n $(tput setab 0)
done;
echo ""
done
G1s0MG0gG1s5N20gICAwICAbWzQwbRtbNDFtIBtbOTdtICAgMSAgG1s0MG0bWzQybSAbWzk3bSAgIDIgIBtbNDBtG1s0M20gG1s5N20gICAzICAbWzQwbRtbNDRtIBtbOTdtICAgNCAgG1s0MG0bWzQ1bSAbWzk3bSAgIDUgIBtbNDBtG1s0Nm0gG1s5N20gICA2ICAbWzQwbRtbNDdtIBtbOTdtICAgNyAgG1s0MG0bWzEwMG0gG1s5N20gICA4ICAbWzQwbRtbMTAxbSAbWzk3bSAgIDkgIBtbNDBtG1sxMDJtIBtbOTdtICAxMCAgG1s0MG0bWzEwM20gG1s5N20gIDExICAbWzQwbRtbMTA0bSAbWzk3bSAgMTIgIBtbNDBtG1sxMDVtIBtbOTdtICAxMyAgG1s0MG0bWzEwNm0gG1s5N20gIDE0ICAbWzQwbRtbMTA3bSAbWzk3bSAgMTUgIBtbNDBtG1s0ODs1OzE2bSAbWzk3bSAgMTYgIBtbNDBtChtbNDg7NTsxNm0gG1s5N20gIDE2ICAbWzQwbRtbNDg7NTsxN20gG1s5N20gIDE3ICAbWzQwbRtbNDg7NTsxOG0gG1s5N20gIDE4ICAbWzQwbRtbNDg7NTsxOW0gG1s5N20gIDE5ICAbWzQwbRtbNDg7NTsyMG0gG1s5N20gIDIwICAbWzQwbRtbNDg7NTsyMW0gG1s5N20gIDIxICAbWzQwbRtbNDg7NTsyMm0gG1s5N20gIDIyICAbWzQwbRtbNDg7NTsyM20gG1s5N20gIDIzICAbWzQwbRtbNDg7NTsyNG0gG1s5N20gIDI0ICAbWzQwbRtbNDg7NTsyNW0gG1s5N20gIDI1ICAbWzQwbRtbNDg7NTsyNm0gG1s5N20gIDI2ICAbWzQwbRtbNDg7NTsyN20gG1s5N20gIDI3ICAbWzQwbRtbNDg7NTsyOG0gG1s5N20gIDI4ICAbWzQwbRtbNDg7NTsyOW0gG1s5N20gIDI5ICAbWzQwbRtb
acp(){
git add .
git commit -m "$(fortune)"
git push origin HEAD
}
function mix(state, block){
let select = block % 4
let zero = state[0] + (state[select] * block) ^ state[state[select] % 4] << 3 | block >> 5
let one = zero * (state[2] + state[3]) - state[1]
let two = (state[2] >> (zero % 10)) - one
let three = (state[3] ^ (two<<2)) ^ (state[select] >> 3)
state = [zero , one, two, three].map(n => n & 0xffffffff)
return state
}
const {get, cloneDeep} = require('lodash/fp')
// A TERRIBLE SIN I KNOW
let oldLog = console.log.bind(console)
console.log = (...args) => {
args = args.map(i => i.isValueHistory ? i.get() : i)
return oldLog(...args)
}
let valueHistory = (name='tracker') => {