Skip to content

Instantly share code, notes, and snippets.



  • Western Australia
View GitHub Profile
use std::sync::Arc;
use std::vec::IntoIter as VecIntoIter;
use vulkano::device::Device;
use vulkano::descriptor::descriptor::DescriptorDesc;
extern crate time;
#[derive(Debug, Clone)]
struct Vertex { position: [f32; 2], velocity: [f32; 2] }
fn main() {
let mut arr = vec![ Vertex { position: [0.0, 0.0], velocity: [0.0, 0.0] }; 200000 ];
View broken.nim
var x : auto = 10
# Error: internal error: getTypeDescAux(tyExpr)
# No stack traceback available
# To create a stacktrace, rerun compilation with ./koch temp c <file>
View gist:208ac923ecc66f42caf2
import unittest
type memory* [T=byte] = distinct ptr T
proc `+`*[T](mem: memory[T]; offset: int): memory[T] =
cast[memory[T]](cast[int](mem) + offset*sizeof(T))
proc `-`*[T](mem: memory[T]; offset: int): memory[T] =
cast[memory[T]](cast[int](mem) - offset*sizeof(T))
View gist:c9d9741a1f67d7d5ca94
proc incval(x: string; y: string): string =
"completely unrelated"
proc test(): tuple[incval: proc(); getval: proc():int] =
var val = 0
proc incval() =
inc val
View gist:b2b5c4310e0d7164e614
type Mat2F
rowCount, colCount: static[int];
] =
object ## A 2-dimensional fixed-sized matrix of an arbitrary type
elementList: array[rowCount*colCount, elementType]
View aahh.nim
import unittest, typetraits
suite "aahh":
test "aahh":
var a = 5
let cond = (name(type(a)) == "int")
require(cond) # works
View gist:0827f2e27dda2cc5fcd2
import sequtils
template test(x: int; list: varargs[int]): expr =
foldl(list, a*(b+x))
echo test(5, 1, 2, 3, 4) # 504
View gist:4082fd7e43f221e06570
import memory
type MatD*[ElementT] = tuple
elementCount: uint32
dimensionCount: uint16
data: memory[byte]
template matD(dimensions: varargs[float64]; elementT: typedesc): expr =
View gist:cbb3b7f4453604c3d6ff
type MatF[ElementT, PLEASE_HELP] = object
data: array[SOME_VARIABLE_LENGTH_HERE, ElementT]
template matF*(elementT: typedesc; dimensions: varargs[int]): expr =
let dimensionCount = len(dimensions)
let elementCount = foldl(dimensions, a*b)
You can’t perform that action at this time.