This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
CommandKind = enum eval, replace | |
CodeCmd = object # not required, but makes my point clearer | |
kind: eval | |
code: string | |
ReplaceCmd = object | |
kind: replace | |
element_id: string | |
content: string | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
CommandKind = enum eval, replace | |
CodeCmd = object # not required, but makes my point clearer | |
kind: eval | |
code: string | |
ReplaceCmd = object | |
kind: replace | |
element_id: string | |
content: string | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render = (lines) -> | |
@button -> | |
@text "Say hello!" | |
@onclick (e) -> | |
lines.add "Hello simulated universe" | |
for x in lines | |
@div -> | |
@text x | |
# impl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base, mono/[core, http], ext/persistence, std/os | |
# Model ------------------------------------------------------------------------------------------- | |
type | |
Square = enum | |
Empty, X, O | |
Board = array[3, array[3, Square]] | |
Game = ref object | |
board: Board |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type SpecialInputKeys = 'alt' | 'ctrl' | 'meta' | 'shift' | |
interface ClickEvent { special_keys: SpecialInputKeys[] } | |
interface KeydownEvent { key: string, special_keys: SpecialInputKeys[] } | |
interface ChangeEvent { stub: string } | |
interface BlurEvent { stub: string } | |
interface InputEvent { value: string } | |
type InEvent = | |
{ kind: 'location', el: number[], location: string } | // el not needed for location but Nim requires it. | |
{ kind: 'click', el: number[], click: ClickEvent } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base, ../app, ../h | |
# Model -------------------------------------------------------------------------------------------- | |
type TodoItemState = enum active, completed | |
type TodoItem = ref object | |
text: string | |
completed: bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as parser from "@babel/parser"; | |
import * as t from '@babel/types'; | |
import _traverse from "@babel/traverse"; | |
const traverse = _traverse.default; | |
import _generate from '@babel/generator'; | |
const generate = _generate.default; | |
let code | |
code = ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"editor.tokenColorCustomizations": { | |
"textMateRules": [ | |
// Nim --------------------------------------------------------------------------------------- | |
{ // Bold | |
"scope": [ | |
"entity.name.function.nim", | |
], | |
"settings": { "foreground": "#111827", "fontStyle": "bold" } // #3730A3 | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"workbench.colorTheme": "Default Light+", | |
"editor.tokenColorCustomizations": { | |
// gray 900 #111827 | |
"textMateRules": [ | |
{ | |
"scope": [ | |
"punctuation.definition.comment", | |
], | |
"settings": { "foreground": "#047857", "fontStyle": "bold" } | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base/[basem, timem, jsonm, mathm, logm, docm] | |
import ext/[persistencem] | |
import std/os | |
export jsonm, timem # otherwise there will be bug | |
# Defaults ----------------------------------------------------------------------------------------- | |
let default_retry_timeout = 5.minutes | |
let default_max_retry_timeout = 4.hours |
NewerOlder