Skip to content

Instantly share code, notes, and snippets.

@nsf
nsf / explode.cc
Created October 9, 2013 08:30
C++ tuple explode
#include <cstdio>
#include <tuple>
#include <utility>
#include <type_traits>
template<int ...I> struct index_tuple_type {
template<int N> using append = index_tuple_type<I..., N>;
};
template<int N> struct make_index_impl {
using type = typename make_index_impl<N-1>::type::template append<N-1>;
@nsf
nsf / optparse.lua
Last active December 23, 2015 00:29
Option parser for lua, based on pythonic.optparse found on the net, slightly modified: "dest" defaults to long flag minus "--", also "default" was added. Amongst other things code was properly OOPized instead of using closures.
--[[
LUA MODULE
pythonic.optparse - Lua-based partial reimplementation of Python's
optparse [2-3] command-line parsing module.
SYNOPSIS
local OptionParser = require "pythonic.optparse" . OptionParser
@nsf
nsf / USAGE
Last active December 21, 2015 17:39
uint to enum converter generator for rust
[nsf @ rustenumgen]$ cat test.txt
enum SDL_EventType {
SDL_FIRSTEVENT = 0,
SDL_QUIT = 0x100,
SDL_APP_TERMINATING,
SDL_APP_LOWMEMORY,
SDL_APP_WILLENTERBACKGROUND,
SDL_APP_DIDENTERBACKGROUND,
SDL_APP_WILLENTERFOREGROUND,
SDL_APP_DIDENTERFOREGROUND,
package main
import (
"container/list"
)
type Updater interface {
Update()
}
@nsf
nsf / template.go
Created March 15, 2012 11:19
Instructions
Process the file below with `go tool cgo -godefs <file>`, dump the output. And tell me your `go tool dist env | grep "GOOS\|GOARCH"`
@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 / gist:1492866
Created December 18, 2011 09:37
CommentSkipper
package main
import "io"
import "bufio"
import "bytes"
import "os"
type CommentSkipper struct {
r *bufio.Reader
}
@nsf
nsf / Makefile
Created November 30, 2011 10:57
files with prefix "command_" go to the directory "command" and prefix should be removed
include $(GOROOT)/src/Make.inc
PREREQ += command.a
TARG = test
GOFILES= test.go
include $(GOROOT)/src/Make.cmd
command.a: command/command.go command/Makefile
gomake -C command
@nsf
nsf / clean.bash
Last active March 4, 2019 14:38
Perlin noise benchmark
#!/bin/bash
rm -rf *.o *.[568] test_*
@nsf
nsf / simple.fs
Created February 18, 2011 14:49
Simple :D
#version 330 core
in vec3 frag;
out vec4 col;
void main()
{
col = vec4(frag, 1.0);
}