Skip to content

Instantly share code, notes, and snippets.

@kepi74
kepi74 / machine.js
Created July 31, 2023 05:44
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@kepi74
kepi74 / machine.js
Created July 22, 2021 13:52
Generated by XState Viz: https://xstate.js.org/viz
const LoginMachine = Machine({
id: 'loginMachine',
initial: 'credentialsForm',
states: {
credentialsForm: {
initial: 'iddle',
states: {
iddle: {
entry: ['parseAuthParamsFromQueryString', 'checkValidityOfAuthParams'],
on: {
@kepi74
kepi74 / sagas_apiFetch.js
Last active January 22, 2020 15:38
Code for Vue.js meetup
function getEffects(list, payload) {
if (list && list.length) {
return list.map((type) => {
if (typeof type === 'string') {
return put({
type,
payload,
});
}
return put(type);
// Y Combinator
const Y = a => (b => b (b)) (b => a (c => b (b) (c)))
// isomorphic Church encoding/decoding
const Church = {
to: n => f => x => Array.from (Array (n)).reduce (f, x),
from: f => f (x => x + 1) (0)
}
const True = a => b => a
@kepi74
kepi74 / AoC2018-day-01.clj
Created December 2, 2018 14:43 — forked from honzabrecka/AoC2018-day-01.clj
Advent of Code 2018 day 01
(defn get-final-freq
"Day one: calculate resulting frequency"
[freq_list]
; 1. clojurist prefer to use `-` instead of `_` in names
; 2. I'm not sure how you got and what's inside `freq_list` (I suppose integers, then it's fine)
(reduce + freq_list))
(defn repeated-freq
"Day one: first occur of repeated frequency"
[freq_list]
@kepi74
kepi74 / AoC2018-day-01.clj
Last active December 2, 2018 12:21
Advent of Code 2018 day 01
(defn get-final-freq
"Day one: calculate resulting frequency"
[freq_list]
(reduce + freq_list))
(defn repeated-freq
"Day one: first occur of repeated frequency"
[freq_list]
(reduce
(fn [vect freq] (