Skip to content

Instantly share code, notes, and snippets.

View zacharycarter's full-sized avatar
👀
Looking for work!

Tail Wag Games zacharycarter

👀
Looking for work!
View GitHub Profile
zobsd$ ./koch tools
bin/nim c --noNimblePath -p:compiler -d:release -o:bin/nimsuggest nimsuggest/nimsuggest.nim
Hint: used config file 'config/nim.cfg' [Conf]
Hint: used config file '/home/zachcarter/projects/Nim/nimsuggest/nimsuggest.nim.cfg' [Conf]
Hint: system [Processing]
Hint: nimsuggest [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
@zacharycarter
zacharycarter / project-layout.txt
Created May 12, 2018 15:36
Example project layout
zachcarter@A-TX39FHTD6  ~/projects/nim-playground  tree -I '.vscode|node_modules|nimcache|.cache|dist'
.
├── Dockerfile
├── README.md
├── docker-compose.yaml
├── nginx.conf
├── parcel-plugin-nim
│ ├── package-lock.json
│ ├── package.json
│ └── src
good morning - I had a docker daemon running on a digital ocean droplet and uh, it kind of just crapped out on me after a while... I was unable to get the docker service running again through systemd
if I run a systemctl status on the service, I see logs like -
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: activating (start) since Sat 2018-04-28 15:58:22 UTC; 59s ago
Docs: https://docs.docker.com
Main PID: 2738 (dockerd)
Tasks: 8
Memory: 390.8M
Zach Carter [1:59 PM]
reading through this now - https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ - but the author starts out making a pretty bold assertion
```In this post, I want to convince you that nurseries aren't quirky or idiosyncratic at all, but rather a new control flow primitive that's just as fundamental as for loops or function calls. And furthermore, the other approaches we saw above – thread spawning and callback registration – should be removed entirely and replaced with nurseries.```
He's talking about two different modes of concurrency here - thread spawning and callbacks
and saying we should ditch both traditional methods in favor of this new construct
Cory Simpson [2:02 PM]
Yeah i read that article, you can’t get away from threads its in the cpu instruction, you can hide them and manage them but something has to spawn threads
import jester, json, asyncdispatch, parsecfg, strutils, uuids, os, osproc, threadpool, asyncfile
type
PlaygroundConfig = object
tmpDir: string
logFileName: string
CompilationTarget {.pure.} = enum
C, CPP
@zacharycarter
zacharycarter / aws_example.nim
Created March 20, 2018 15:59 — forked from Varriount/aws_example.nim
Nim AWS Snippets
# AWS Version 4 signing example
# EC2 API (DescribeRegions)
# See: http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
# This version makes a GET request and passes the signature
# in the Authorization header.
import base64, httpclient, hmac, nimSHA2, os, times, strutils, httpcore
# ************* REQUEST VALUES *************
@zacharycarter
zacharycarter / sigv4.nim
Created March 20, 2018 15:59 — forked from Varriount/sigv4.nim
Optimized sigv4.nim
#[
# AWS SignatureV4 Authorization Library
Implements functions to handle the AWS Signature v4 request signing
http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
]#
import os, times
import strutils except toLower
import sequtils, algorithm, tables, nimSHA2
import securehash, hmac, base64, re, unicode
import compiler/[ast, idents, modulegraphs, modules, vm, vmdef], macros, ospaths, tables, threadpool
export vm
let graph* = newModuleGraph()
let identCache* = newIdentCache()
macro api*(impl: untyped): untyped =
let moduleName = splitFile(lineInfoObj(callsite()).filename).name
let module = graph.makeModule(moduleName)
curl --request POST \
--url http://localhost:8082/foo \
--header 'content-type: application/json' \
--data '{
"bar": "FOOBAR"
}'
# grassland area with cliffs, water, and some buildings
[Image]
img=images/tilesets/tileset_grassland.png
[Tiles]
# grass tiles (use in a 4x4 repeating grid for best results)
tile=16,0,0,64,32,32,16
tile=17,64,0,64,32,32,16
tile=18,128,0,64,32,32,16
tile=19,192,0,64,32,32,16