Skip to content

Instantly share code, notes, and snippets.

@nsf
nsf / coroutines.nim
Last active December 13, 2019 14:55
Coroutines in nim
import queues
import locks
import macros
import sequtils
type
SchedulerCommandType = enum
scDone,
scYield,
scWaitForCoroutine,
@nsf
nsf / gist:eabc9018a4662c3f3ffc1a9209eacb6b
Last active May 19, 2019 07:16 — forked from williballenthin/gist:ee0335a6826ce55ece2d
Methods for fetching structure fields in Go (golang)
package main
import "log"
import "time"
import "reflect"
import "unsafe"
// suggested via http://stackoverflow.com/a/8363629/87207
func trace(s string) (string, time.Time) {
log.Println("START:", s)
@nsf
nsf / clean.bash
Last active March 4, 2019 14:38
Perlin noise benchmark
#!/bin/bash
rm -rf *.o *.[568] test_*
using NG.Coroutines;
using NG.Math;
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
namespace NG.VoxelMap {
public static class Const {
@nsf
nsf / gist:1576733
Created January 8, 2012 01:21
Gocode integration guide
Basically you can do that by simple running an external command from
your editor.
Autocompletion command needs the following information from your editor:
1. Current file buffer (possible unsaved).
2. Cursor position (offset in bytes from the beginning of the buffer).
3. The full file name of the currently edited buffer. It can be
relative to the current/working directory.
@nsf
nsf / Vk.h
Created March 29, 2016 02:25
Vulkan C++ wrapper
#pragma once
#include <cstdint>
#include <cstddef>
#include <cstring>
#include <vulkan/vulkan.h>
namespace vk {
template <typename EnumType, typename T = uint32_t>
@nsf
nsf / converters.go
Created March 6, 2016 00:23
VkCpp in Go
package main
import (
"fmt"
"strconv"
"strings"
)
type AnalyzedType struct {
Name string
#/!/bin/bash
set -e
export MYROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MY=$MYROOT/android
MYJAVADIR=$MY/src/com/nosmileface/vquest
MYNAME=VQuest
MYKEYSTORE=/home/nsf/tmp/AndroidKeys/my-developer-key.keystore
struct Quadric {
float q[10];
Quadric() = default;
Quadric(float q0, float q1, float q2, float q3, float q4,
float q5, float q6, float q7, float q8, float q9)
{
q[0] = q0;
q[1] = q1;
q[2] = q2;
q[3] = q3;
using System;
using System.Linq;
using System.Collections.Generic;
namespace NG.Tasks {
public class Counter {
public int Count = 0;
/// Task that waits on this counter.
public Task WaitingTask;