Skip to content

Instantly share code, notes, and snippets.

👑
Hunting arcs and orcs

Danil Yarantsev Yardanico

👑
Hunting arcs and orcs
  • Russia
View GitHub Profile
View sse_experiments.nim
const
intrin = "<x86intrin.h>"
{.localPassC: "-msse4.2".}
type
M128i {.importc: "__m128i", header: intrin, bycopy.} = object
const
SIDD_CMP_RANGES = 0b0000_0100'i32
SIDD_NEGATIVE_POLARITY = 0b0001_0000'i32
View workq.nim
# nim c -r --threads:on --gc:orc
import cpuinfo, os, random, locks, deques
type
WorkReq = ref object
id: int
WorkRes = ref object
id: int
View pull-request-poetry.md

Pull request poetry

by Richard Bullington-McGuire richard@obscure.org @obscurerichard on GitHub and Twitter

Use these as comments in pull requests in order to charm the project owner into taking action on the pull request.

Initial ticklers

lonely pull request
the completist in me pines
for its prompt closure
View gamemodel.rst

Basic idea: A Nim DSL that describes the game model declaratively

There is a raw list/sequence of the data for fast iteration over all elements. The implementation should be either based on an ordinary contiguous sequence or something like: http://plflib.org/colony.htm which is essentially a linked list of growing arrays so that no reallocations are required.

In addition to the contiguous storage there can be multiple indexes into the data. The indexes can be hash based or based on a BTree depending on whether ranges queries need to be supported. There is always a primary key of type integer that can be used to index the contiguous array.

An example:

View get_field_names.nim
import macros, times, strutils, tables
type
Data* = object
value*: int
fvalue*: float
tvalue*: Time
Container* = object
desc*: string
@mikroskeem
mikroskeem / get_shell.c
Last active Aug 30, 2018
A script to get Arch Linux ARM rootfs running in proot on Android (Termux)
View get_shell.c
/*
* clang -static -O2 get_shell.c get_shell
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
int main(int argc, char *argv[]) {
View GitHub spoiler markdown.md

Demo:

Spoiler warning

Spoiler text. Note that it's important to have a space after the summary tag. You should be able to write any markdown you want inside the <details> tag... just make sure you close <details> afterward.

console.log("I'm a code block!");
@mratsim
mratsim / call_cuda.nim
Last active Sep 16, 2017
Calling CUDA kernels from Nim
View call_cuda.nim
import nimcuda/[cuda_runtime_api, driver_types, nimcuda]
import sequtils, future
type GpuArray[T: SomeReal] = object
data: ref[ptr T]
len: int
{.compile: "./square.cu".}
proc cuda_square(bpg, tpb: cint, y: ptr cfloat, x: ptr cfloat) {.importc, header:"../square.cuh".}
#../square.cuh is a workaround because header is not copied to nimcache
View nimblepkgstructure.md

First suggestion:

src/
  <pkgname>.nim
tests/
docs/
<pkgname>.nimble # with srcDir = "src"

library with single module

@zacharycarter
zacharycarter / wclwn.md
Last active Jun 2, 2020
Binding to C Libraries with Nim
View wclwn.md
You can’t perform that action at this time.