Skip to content

Instantly share code, notes, and snippets.

View postspectacular's full-sized avatar
🎉
Celebrating 24 years of building open source tools

Karsten Schmidt postspectacular

🎉
Celebrating 24 years of building open source tools
View GitHub Profile
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
typedef int16_t int16;
typedef int32_t int32;
int16 deg2i(int16 d) {
return (int32)d*8192 / 45;
@alexpw
alexpw / gist:4346395
Created December 20, 2012 16:23
Seq utilities for grouping and indexing.
(defn group-by-with
"A group-by factory that accepts a combiner-fn to control how the values
of the grouping fn are collected."
[combiner-fn]
(fn [f coll]
(persistent!
(reduce
(fn [ret x]
(let [k (f x)]
(assoc! ret k (combiner-fn (get ret k) x))))
@bnyeggen
bnyeggen / hinttype.clj
Created February 2, 2013 21:13
Macro-generated deftype with type-hinted fields.
(defmacro hinttype
[type-name & hint-symbols]
`(deftype ~type-name
[~@(for [s hint-symbols]
(with-meta (gensym "a")
{:tag (case s
:int 'int
:long 'long
:float 'float
:double 'double
@ray1729
ray1729 / cms.conf
Last active December 21, 2015 05:39
Example upstart script to start Ring web app
# cms - simple CMS
#
# The simple-cms server is a Compojure application serving content for cms.1729.org.uk
description "CMS server"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn

Functions, how do they work?

A good friend asked me how functions work under the covers, so I wrote up this quick explanation. Corners are cut for brevity, but I hope it will convey the general idea.

The three assembly language programs below implement the following (super simple) recursive function:

@tetsu-koba
tetsu-koba / mix.c
Created October 4, 2015 06:42
Various operation for PCM data
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int mix(char *inbuf1, char *inbuf2, char *outbuf, int len, float vol1, float vol2)
{
int16_t *inp1, *inp2;
int16_t *outp;
int cnt = len / sizeof(int16_t);
@darach
darach / instructions.md
Last active February 13, 2016 22:37
Pony on the Raspberry Pi v2

Instructions

The following instructions assume a debian jessie based distribution

0. Prerequisites

Install dependent tools and libraries

$ sudo apt-get update
@jackrusher
jackrusher / koch-like.clj
Created January 18, 2016 10:57
A quick 3D L-system implementation using Toxi's https://github.com/thi-ng libraries.
(defn grow [pos rot points len]
(let [[x y z] (last rot) ;; :( no M33 and no (g/rotate-xyz _ (vec3 x y z))
corners (map #(-> % (g/rotate-x x) (g/rotate-y y) (g/rotate-z z) (g/+ (last pos)))
[(vec3 0 0 0) (vec3 -1 0 0) (vec3 0 -1 0) (vec3 0 1 0)
(vec3 -1 0 len) (vec3 0 -1 len) (vec3 0 1 len) (vec3 0 0 len)])]
[(conj (pop pos) (last corners))
rot
(conj points (map gu/tessellate-3 (g/faces (apply cub/cuboid corners))))]))
(defn build-lsystem [l-system angle len]
@H2CO3
H2CO3 / SpnMap.hpp
Created January 13, 2015 18:20
SpnHashMap, rewritten in C++
//
// SpnMap: Sparkling's hash table, in C++
// Created by Arpad Goretity on 13/01/2015
//
#include <vector>
#include <utility>
#include <cstdint>
#include <climits>
#include <cassert>
@pachacamac
pachacamac / tiny_neural_net.rb
Last active August 4, 2016 01:58
simple feed forward network with back propagation learning, used to detect dice
require 'matrix'
class Matrix
def []=(i, j, x); @rows[i][j] = x; end
def size; [self.row_size, self.column_size]; end
end
class Vector
def []=(i, x); @elements[i] = x; end
def length; @elements.length; end