- No performance benchmark.
- Python ⟿
PEP-8
- Nim ⟿
NEP1
- Python ⟿
3.7
- Nim ⟿
0.19
- No Ofuscation, no Code-Golf.
This is to compare elegant, simple, expressive code.
MIT License | |
Copyright (c) 2021 Daniel Ethridge | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
# Get compiled executable there: https://github.com/Guevara-chan/packages/releases/tag/nDustman_0.01 | |
import random, nativesockets, threadpool, parsecfg, strutils, sequtils, terminal | |
const header = "# nDustman junk sites URL generator v0.01\n# Developed in 2021 by Victoria A. Guevara" | |
# Basic init. | |
randomize() | |
const config_file = "config.ini" | |
config_file.open(fmAppend).close() | |
var cfg = config_file.loadConfig() |
<body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c> |
import asynchttpserver, asyncdispatch, os | |
proc handler(req: Request) {.async.} = | |
echo "request for path ", req.url.path | |
let cwd = getCurrentDir() | |
let file = cwd / req.url.path | |
if fileExists(file): | |
await req.respond(Http200, file.readFile()) | |
else: |
# threadSafeFuture.nim | |
# Jens Alfke, 30 June 2020 | |
import asyncdispatch, deques, locks, sugar, threadpool | |
## Utilities for mixing async/await with threads. | |
## | |
## ``threadSafe()`` takes a Future and returns a new Future that can be completed on any thread. | |
## The original Future's callback will still be invoked on its original thread, and ``await`` | |
## works normally. |
# nim c -r --threads:on --gc:orc | |
import cpuinfo, os, random, locks, deques | |
type | |
WorkReq = ref object | |
id: int | |
WorkRes = ref object | |
id: int |
name: Build Nim 👑 | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: |
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 example using | |
# Nim: 0.18.0 | |
# Jester: 0.2.1 | |
# Using Jester >= 0.3.0 is preferrable if your Nim version > 0.18.0 | |
# In case you're using Jester >= 0.3.0, look the syntax different | |
# in its example because it's not backward compatible | |
import db_sqlite, asyncdispatch, json, strformat, strutils, sequtils | |
import jester |