Skip to content

Instantly share code, notes, and snippets.

View juancarlospaco's full-sized avatar
👑
https://t.me/NimArgentina

Juan Carlos juancarlospaco

👑
https://t.me/NimArgentina
View GitHub Profile
View debugutils.py
## Debug utilities, to keep it simple and stdlib-only.
import functools
__all__ = ("debugs", )
def debugs(func):
@juancarlospaco
juancarlospaco / README.md
Last active October 20, 2022 21:05
Rust vs C++ vs C vs Cython vs Nim. (year 2022)
View README.md

Build

$ ./compileall.sh 

# Cleanout #############################################################
# Go ###################################################################

real    0m0,283s
user    0m0,227s
View wallets.md

💰➡️🍕

Tether USDT

TRC20 Tron Network

TPfjb2mbSQQwUe9AScZmu5bRax3dHdBBiL

BEP20 Binance Smart Chain Network BSC

@juancarlospaco
juancarlospaco / wikipediadns.nim
Created April 9, 2020 05:52
Wikipedia as DNS Server
View wikipediadns.nim
import httpclient, json, xmltree, q
proc wikipediaDns*(name: string): string {.inline.} =
const w = "http://en.wikipedia.org/w/api.php?action=query&prop=info&inprop=url&format=json&limit=1&titles="
let hc = newHttpClient()
for x in hc.getContent(w & name).parseJson{"query", "pages"}.pairs:
for u in q(hc.getContent(x.val{"fullurl"}.getStr)).select"table.infobox tbody tr a[href*=http]":
return u.attr"href"
echo wikipediaDns("Nim-lang")
@juancarlospaco
juancarlospaco / printf.nim
Last active February 25, 2023 15:12
C print for Nim
View printf.nim
proc printf*(format: cstring): cint {.importc, header: "<stdio.h>".}
proc fprintf*(stream: File, format: cstring): cint {.importc, header: "<stdio.h>".}
proc sprintf*(str: var cstring, format: cstring): cint {.importc, header: "<stdio.h>".}
proc vsprintf*(str: var cstring, format: cstring, arg: varargs[typed, `$`]): cint {.importc, header: "<stdio.h>".}
proc vfprintf*(stream: File, format: cstring, arg: varargs[typed, `$`]): cint {.importc, header: "<stdio.h>".}
@juancarlospaco
juancarlospaco / build_generic_nim_module.yml
Last active May 22, 2021 23:53
.github/workflows/build.yml GitHub Action for Nim (Generic Base Template)
View build_generic_nim_module.yml
name: Build Nim 👑
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
@juancarlospaco
juancarlospaco / nicy.nim
Last active April 7, 2021 16:10
ZSH Terminal "DIY prompt", uses https://github.com/icyphox/nicy
View nicy.nim
import strformat, times, os, osproc, nicypkg/functions
export functions
when isMainModule:
let
prompt = returnCondition(ok = "👍", ng = "👎") & " "
nl = "\n"
gitBranch = color(gitBranch(), "yellow")
cwd = color(tilde(getCwd()), "cyan")
dirty = color("×", "red")
@juancarlospaco
juancarlospaco / function_example.nim
Last active July 23, 2019 03:03
Python Vs Nim: Functions
View function_example.nim
# args are immutable by default.
# Variables immutables by default (std lib).
# func ensures exampleFunction dont have Side Effects (is a Functional function).
func exampleFunction(arg: Natural): range[0..100] = # Static Types no type Bugs possible (wont compile otherwise). range[0..100] only allows integers from 0 to 100. Natural only allows integers not Negative (>=0).
# result variable is automatically created for you (you always need to return a result anyways)
preconditions arg > 0, arg < 101 # Preconditions (like a Unittest BEFORE a block of code, asserts on args and variables)
postconditions result > 0, result < 101 # Postconditions (like a Unittest AFTER a block of code, asserts on result)
result = arg + 1 # Mimic some logic here, it does not really matter for this example
# result is automatically returned, no need for "return result" (can still use return if wanted tho)
@juancarlospaco
juancarlospaco / thermal_printer.md
Last active October 2, 2023 19:44
Arch Linux Thermal Printer USB 58mm / 80mm Drivers & Config
View thermal_printer.md
@juancarlospaco
juancarlospaco / example.txt
Created February 28, 2019 19:12
NimWC with Firejail: typical terminal standard output debug messages when not build for release.
View example.txt
2019-02-28T16:00:52-03:00: Nim Website Creator: starting.
*** Starting xvfb server: "Xvfb" ":529" "-screen" "0" "800x600x24" ***
*** Stating xvfb client: "firejail" ***
*** Attaching to Xvfb display 529 ***
Basic read-only filesystem:
Mounting read-only /bin
Mounting read-only /lib
Mounting read-only /usr