$ ./compileall.sh
# Cleanout #############################################################
# Go ###################################################################
real 0m0,283s
user 0m0,227s
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 std/[os, strutils, json, sequtils] | |
proc main(cwd: string) = | |
if dirExists(cwd / "Content"): | |
# Minify uproject to valid minimal. | |
for f in walkPattern(cwd / "*.uproject"): | |
let uproject = parseFile(f) | |
if uproject.contains"Category": uproject.delete"Category" | |
if uproject.contains"Description": uproject.delete"Description" |
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
## Debug utilities, to keep it simple and stdlib-only. | |
import functools | |
__all__ = ("debugs", ) | |
def debugs(func): |
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 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") |
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
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>".} |
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
name: Build Nim 👑 | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: |
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 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") |
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
# 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) |
- How to install and print on a Thermal Printer USB 58mm / 80mm. https://twitter.com/juancarlospaco/status/1128781387782344710/photo/1 https://twitter.com/juancarlospaco/status/1128732835131678720/photo/1
- This kind of printer is cheap as hell compared to all other kind of printers, including ink-tank and dot-matrix.
NewerOlder