Skip to content

Instantly share code, notes, and snippets.

View miguelmartin75's full-sized avatar

Miguel Martin miguelmartin75

View GitHub Profile
@miguelmartin75
miguelmartin75 / README.md
Last active September 28, 2024 10:46
json parse CLI example in nim, from https://x.com/lemire/status/1839881289312149549

SETUP:

Install nim

REPO_PATH=$HOME/repos
cd $REPO_PATH
git clone git@github.com:nim-lang/Nim.git
cd Nim
./build_all.sh
@miguelmartin75
miguelmartin75 / buildsupport.nim
Created March 23, 2025 00:00
compile commands json generation for nim in nimscript
import std/[
os,
json,
tables,
options,
strformat,
strutils,
sugar,
sequtils,
]
@miguelmartin75
miguelmartin75 / config.nims
Last active May 10, 2025 20:00
Example of Nim with Objective-C, issue: https://github.com/nim-lang/Nim/issues/9492. Compile with `nim withArc` to execute using Objective-C's ARC and `nim withoutArc` to depend on Nim's ARC to call release
--outdir:"build"
--nimcache:"build/cache"
when defined(useObjcArc):
--passC:"-fobjc-arc"
else:
--passC:"-fno-objc-arc"
task withArc, "compile and run with arc":
exec "nim objc --listCmd -d:useObjcArc -r guts.nim"
import std/[strformat, atomics, terminal, options]
export options
type
ExceptionInfo* = object
name*: string
msg*: string
stacktrace*: string
ParResult*[T] = object
@miguelmartin75
miguelmartin75 / kvs.nim
Created August 28, 2025 20:31
Compile and run with `nim c -r kvs.nim`
import std/[parseutils, strformat, strutils, tables, sugar, enumerate]
type ParseError* = object of CatchableError
proc parseValue*(x: var int, value: string): bool = parseInt(value, x) > 0
proc parseValue*(x: var float, value: string): bool = parseFloat(value, x) > 0
proc parseValue*(x: var string, value: string): bool =
x = value
return true
@miguelmartin75
miguelmartin75 / commandflags.odin
Last active March 17, 2026 05:38
commands for core:flags
package commandflags
import "core:flags"
import "core:fmt"
import "core:io"
import "core:os"
import "core:strings"
Command :: struct {
name: string,