Skip to content

Instantly share code, notes, and snippets.

View mashingan's full-sized avatar

mashingan

View GitHub Profile
@planetis-m
planetis-m / csp.nim
Created January 19, 2021 00:47
Classic Computer Science Problems in Python
import tables, options, sugar
type
Constraint*[V, D] = ref object
# Base class for all constraints
variables*: seq[V] # The variables that the constraint is between
satisfied*: proc (assignment: Table[V, D]): bool
Csp*[V, D] = object
# A constraint satisfaction problem consists of variables of type V
@haxscramper
haxscramper / htppserve.nim
Last active May 12, 2021 12:04
Nim emscripten hello world
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:
@haxscramper
haxscramper / languages-and-vms.md
Last active July 2, 2024 03:38
languages-and-vms
# nim c -r --threads:on --gc:orc
import cpuinfo, os, random, locks, deques
type
WorkReq = ref object
id: int
WorkRes = ref object
id: int
@ashwinvis
ashwinvis / THANKS.md
Last active July 7, 2020 05:22
GitHub Retro
@onlurking
onlurking / programming-as-theory-building.md
Last active July 22, 2024 13:14
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

@demotomohiro
demotomohiro / Hotcodereloading_with_glfw_ sample.md
Created February 4, 2020 16:17
Nim's hot code reloading with GLFW sample

Tested this sample with Nim 1.0.6 on Windows 8.1

  1. Install Nim Game Library
nimble install nimgl
  1. Get glfw3.dll Go to GLFW web site, go to Download page and download Windows pre-compiled binaries. Unzip it and copy glfw3.dll to where you run sample program.
@shakna-israel
shakna-israel / LetsDestroyC.md
Created January 30, 2020 03:50
Let's Destroy C

Let's Destroy C

I have a pet project I work on, every now and then. CNoEvil.

The concept is simple enough.

What if, for a moment, we forgot all the rules we know. That we ignore every good idea, and accept all the terrible ones. That nothing is off limits. Can we turn C into a new language? Can we do what Lisp and Forth let the over-eager programmer do, but in C?


@KyrillosWalid
KyrillosWalid / tutorial.md
Last active June 23, 2024 15:56
How to add Nim-lang code to C/C++ code - TUTORIAL

How to add Nim-lang code to C/C++ code


Note 1: This tutorial is for Linux users only, but if you understand the idea, you can use it on all systems and it will work as required :).
Note 2: Nim-lang version used in this tutorial is 1.0.4 (To get Nim-lang version nim -v)

To add Nim-lang code to C/C++ code you have 3 choices :

  • Compile Nim-lang code as a (C/C++ header File). THIS IS WHAT WE WILL TAKE TODAY.
  • Compile Nim-lang code as a (C/C++ static library).
  • Compile Nim-lang code as a (C/C++ dynamic library).