Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View herrfugbaum's full-sized avatar
🤠

Pascal herrfugbaum

🤠
  • Grau Elektronik GmbH
  • Karlsruhe, Germany
  • X @hrfugbaum
View GitHub Profile
@herrfugbaum
herrfugbaum / euclid.js
Last active August 29, 2017 08:16
Euclidean algorithm
const euclid = (w, h) => h === 0 ? w : euclid(h, w % h)
@herrfugbaum
herrfugbaum / random-pastel-rgba.js
Created March 11, 2016 10:09
Return a random pastel rgba color.
/* @param alpha boolean
* if true a random value for the alpha channel is calculated, else alpha channel = 1 (full saturation)
*/
var randomPastelColor = function (alpha) {
var rndm = function (f) { return Math.floor(Math.random() * f)},
pstlfy = function (p) { return Math.round((p + 255) / 2)},
r = pstlfy(rndm(256)),
g = pstlfy(rndm(256)),
b = pstlfy(rndm(256)),
a = alpha ? rndm(11) / 10 : 1
@herrfugbaum
herrfugbaum / machine.js
Last active April 25, 2020 07:41
Generated by XState Viz: https://xstate.js.org/viz
const replMachine = Machine({
id: 'replMachine',
initial: 'repl',
context: {
cursor: 0,
data: [1,2,3,4,5]
},
states: {
repl: {
@herrfugbaum
herrfugbaum / machine.js
Last active June 30, 2020 11:24
Generated by XState Viz: https://xstate.js.org/viz
const FILTER_TYPE_ERROR_STATES = {
type: "parallel",
states: {
FILTER_TYPE_SVALUE: {
initial: "OFF",
states: {
OFF: {
on: {
CLICK_TYPE_SVALUE: "ON"
}
@herrfugbaum
herrfugbaum / machine.js
Created September 10, 2020 12:39
Generated by XState Viz: https://xstate.js.org/viz
const FILTER_TYPE_ERROR_STATES = {
type: "parallel",
states: {
FILTER_TYPE_SVALUE: {
initial: "OFF",
states: {
OFF: {
on: {
CLICK_TYPE_SVALUE: "ON",
},