This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
This file contains hidden or 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 pl0t # https://github.com/al6x/pl0t/blob/main/api/nim/pl0t.nim | |
let options = TableOptions[seq[float]]( | |
order: @[("mv_usd", PlotOrder.desc_e)].some, | |
columns: @[ | |
PlotTableColumn( | |
id: "mv_usd", | |
`type`: "number", | |
format: FormatOptions( | |
`type`: PlotFormatType.line_e, |
This file contains hidden or 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 nimib, nimibook | |
import ggplotnim | |
nbInit() | |
nbUseNimibook | |
# Simple plotting using [ggplotnim](https://github.com/Vindaar/ggplotnim) | |
## Line plot |
This file contains hidden or 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 times, os, std/json, std/jsonutils | |
type OptionContract* = ref object | |
id*: string | |
right*: string | |
expiration*: string | |
strike_raw*: float | |
premium_raw*: float | |
data_type*: string |
This file contains hidden or 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 tables, strformat, sugar, sequtils | |
{.experimental: "code_reordering".} | |
type Message = tuple[from_channel_id: int, message_id: int, message: string] | |
# Channels | |
# TODO channels should be initialized with macro, like `define_channels()`, don't know how to do that. | |
var channel_1: Channel[Message] | |
channel_1.open() |
This file contains hidden or 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
# | |
# | |
# Nim's Runtime Library | |
# (c) Copyright 2015 Andreas Rumpf | |
# | |
# See the file "copying.txt", included in this | |
# distribution, for details about the copyright. | |
# | |
## Profiling support for Nim. This is an embedded profiler that requires |
This file contains hidden or 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 kotlin.concurrent.thread | |
sealed class Errorneous<R> | |
data class Success<R>(val result: R) : Errorneous<R>() | |
data class Fail<R>(val error: Exception) : Errorneous<R>() | |
fun <R> thread_with_result(fn: () -> R): (() -> Errorneous<R>) { | |
var r: Errorneous<R>? = null | |
val t = thread { | |
r = try { Success(fn()) } catch (e: Exception) { Fail(e) } |