Skip to content

Instantly share code, notes, and snippets.

RBNodeColor: enum {
black = 0
red = 1
}
RBNode: class <K, V> {
color := RBNodeColor black
Tile: class {
id: Int
init: func (=id)
println: func (x, y: Int) {
"%d, %d: %d" format(x, y, id) println()
}
use math
import math
//PI: const Float = 3.14159265359
TWOPI: const Float = PI*2
HALFPI: const Float = PI/2
Rect: class {
x, y, width, height: Float
@komiga
komiga / test.bmx
Created May 18, 2011 11:09
BlitzMax test code from Pygments
Rem
foobar
EndRem
Rem
foobar!
End Rem
Rem
@komiga
komiga / map-pod-instancing.cpp
Created July 25, 2011 15:10
std::map POD instancing
#include <stdio.h>
#include <map>
class Object;
typedef std::map<int, Object> ObjectMap;
typedef std::map<int, Object*> ObjectPtrMap;
class Object {
struct blah {
blah()
: a(0) // error: uninitialized member ‘blah::<anonymous union>::b’ with ‘const’ type ‘const float’
//, b(0.0f) // error: initializations for multiple members of ‘blah::<anonymous union>’
{}
union {
int const a;
float const b;
};
@komiga
komiga / murmur3_constexpr.cpp
Created April 28, 2012 21:20
MurmurHash3 in C++11 using constexpr!
#include <cstddef>
#include <cstdint>
#include <cstdio>
namespace util {
struct funcs;
template <typename S> struct mh3_internal;
template <typename S, S default_seed> struct mh3;
typedef mh3<uint32_t, 0> mh3_default;
@komiga
komiga / Allocator.hpp
Created August 3, 2012 05:13
Allocator class
class Allocator {
public:
virtual std::size_t get_num_allocations() const=0;
virtual std::size_t get_allocation_size(void* p) const=0;
virtual void* allocate(std::size_t size, std::size_t align=0)=0;
virtual void deallocate(void* p)=0;
template<class U, typename ...Args>
inline U* construct(Args&&... args) {
return new (allocate(sizeof(U), alignof(U))) U(std::forward<Args>(args)...);
@komiga
komiga / 33283-p41-sqrt.patch
Created September 27, 2012 19:37
Solution correction for Gutenberg #33283 p41 s2
--- 33283-t.tex 2012-09-27 14:19:54.131493000 -0400
+++ 33283-t-b.tex 2012-09-27 15:09:31.478376000 -0400
@@ -2545 +2545 @@
-\frac{dy}{dx} = 3a\sqrt{b}x + \frac{3b\sqrt[3]{a}}{x^2}.
+\frac{dy}{dx} = 3a\sqrt{bx} + \frac{3b\sqrt[3]{a}}{x^2}.
@komiga
komiga / 33283-p44-s11.patch
Created September 28, 2012 17:12
Solution correction for Gutenberg #33283 p44 s11
--- 33283-t.tex 2012-09-28 13:08:13.725523000 -0400
+++ 33283-t-b.tex 2012-09-28 13:10:24.538750000 -0400
@@ -2679 +2679 @@
- {6(1 + a \sqrt[2]{3})^2}.
+ {6(1 + a \sqrt[2]{t^3})^2}.