Skip to content

Instantly share code, notes, and snippets.

View christianhg's full-sized avatar
🍔

Christian Grøngaard christianhg

🍔
View GitHub Profile
@christianhg
christianhg / 0_reuse_code.js
Created October 15, 2015 06:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@christianhg
christianhg / cachingPromises.js
Last active November 19, 2017 19:22
Caching Promises
/*
Service used to mimic a slow computation:
*/
class PersonService {
getPersons(caller) {
console.log(`> PersonService#getPersons() triggered by ${caller}`)
return new Promise(resolve =>
setTimeout(
() =>
resolve([
@christianhg
christianhg / cloudSettings
Last active November 6, 2021 18:42
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-11-06T18:41:59.962Z","extensionVersion":"v3.4.3"}
@christianhg
christianhg / machine.js
Last active January 27, 2020 10:11
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@christianhg
christianhg / machine.js
Created April 16, 2020 19:28
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@christianhg
christianhg / machine.js
Last active May 27, 2020 12:24
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@christianhg
christianhg / machine.js
Last active May 27, 2020 12:24
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@christianhg
christianhg / machine.js
Last active June 18, 2021 18:12
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@christianhg
christianhg / machine.js
Last active June 21, 2021 11:29
Generated by XState Viz: https://xstate.js.org/viz
const combobox = Machine({
id: 'combobox',
initial: 'enabled',
context: {
pointer: 0,
query: '',
results: []
},
states: {
disabled: {
@christianhg
christianhg / machine.js
Last active June 28, 2021 19:29
Generated by XState Viz: https://xstate.js.org/viz
const findIndex = (items, item) => {
const index = items.findIndex(item)
console.log(index)
return index >= 0 ? index : undefined
}
const comboboxMachine = Machine({
id: 'combobox',
context: {