Skip to content

Instantly share code, notes, and snippets.

View simonask's full-sized avatar

Simon Ask Ulsnes simonask

View GitHub Profile
void render() {
// Tiles
for (int i = 0; i < columns; ++i)
{
for (int j = 0; j < rows; ++j)
{
glBegin(GL_QUADS);
glColor3f(0.0, 1.0, 0.0);
glVertex2f(i*tile_width, j*tile_height);
glVertex2f(i*tile_width+tile_width, j*tile_height);
foo: [a, b] { return a + b }
puts(foo.disassemble())
#include <iostream>
using namespace std;
template <int N> int fib() {
return fib<N-1>() + fib<N-2>();
}
template <>
int fib<0>() {
class Base {
private:
int m_Lol;
public:
Base(int lol) : m_Lol(lol) {}
};
class Foo : public Base {
public:
Foo() : Base(123) {}
#include <stdio.h>
class Mixin1 {
protected:
Mixin1() {}
public:
int a, b, c;
};
class Mixin2 {
xml: XmlBuilder()
xml {
.root {
.element1(attr: "hej") {
.cdata("MUUUUH")
}
.element2(whatever: "lals") {
.cdata("...")
}
template <typename T> class Delegate;
template <typaname T> class DelegateFunction;
// Specialization for 2-argument callbacks:
template <typename C, typename R, typename A1, typename A2>
class DelegateMemberFunction : public DelegateFunction<R, A1, A2> {
private:
C* m_Instance;
R (*m_Function)(A1, A2);
public:
#include <stdio.h>
#include <dlfcn.h>
extern "C" int foo() {
puts("LOOOOOL");
}
int main() {
void* handle = dlopen(NULL, RTLD_NOW);
int(*my_foo)() = dlsym(handle, "foo");
require("dlopen")
Something: module {
lib: dlopen("libsomething.dylib")
.foo: lib.symbol("foo", INT, POINTER)
.bar: lib.symbol("bar", POINTER)
}
ptr: Something.bar()
Foo: class {
get_stuff: { /* do it */ }
.property(#stuff, get_stuff, nil)
}
foo: Foo.new()
foo.stuff // => get_stuff()
foo.stuff: 2 // => ERROR