Skip to content

Instantly share code, notes, and snippets.

Loading './guarrilla_tactics.run' via valgrind.
==5463== Memcheck, a memory error detector
==5463== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==5463== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==5463== Command: ./guarrilla_tactics.run
==5463==
_____ _____ _____ _____
| _ | | | __|
| __| ===| ===|__ |
|__| |_____|_____|_____|
SLOC Directory SLOC-by-Language (Sorted)
27581 phantom cpp=27477,sh=104
3169 sharedlib cpp=3065,sh=104
2443 game cpp=2339,sh=104
1918 libyaxl cpp=1814,sh=104
1849 dedicatedserver cpp=1745,sh=104
338 masterserver cpp=234,sh=104
213 top_dir sh=199,php=14
158 foldertoproject cs=158
98 old-gameobjects cpp=98
@Gerjo
Gerjo / merc history.php
Created November 20, 2012 18:32
Mercurial stats script.
#!/usr/bin/php
<?php
if(!isset($argv[1])) {
print "Usage: $argv[0] path" . PHP_EOL;
exit;
}
date_default_timezone_set("UTC");
@Gerjo
Gerjo / 12lineweb
Created January 24, 2013 17:06
Small threaded webserver, should work most of the time, probably.
#include <cstdlib>
#include <thread>
#include <iostream>
#include <cstring>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <arpa/inet.h>
function blaat(var upperbound) {
var result = 0;
for(var i = 0; i < upperbound; ++i) {
for(var j = i; j < upperbound; ++j) {
++result;
}
}
return result;
}
@Gerjo
Gerjo / bezier
Created July 17, 2013 11:06
Bézier interpolation
/// Calculate a point on a bézier curve. Works for any number of control
/// points.
///
/// TODO: contemplate a generic version that does not require std::vector.
/// perhaps iterators or clever template usage? Resort to C style arrays?
///
///
/// @param points A collection indicating the control points.
/// @param delta Interval at which to calculate the point, ranges from 0 to 1.
/// @return a point on a bézier curve.
@Gerjo
Gerjo / CCL broken
Created July 17, 2013 20:46
Connected Component Labeling - the slow and broken version.
void ConnectedComponentLabeling() {
std::vector<Color> colors;
colors.push_back(Color::Red);
colors.push_back(Color::Blue);
colors.push_back(Color::Purple);
colors.push_back(Color::Yellow);
colors.push_back(Color::Green);
colors.push_back(Color::Grey);
colors.push_back(Color::Cyan);
@Gerjo
Gerjo / Variadic template multiton
Last active December 20, 2015 03:19
Variadic template multiton
template <class T, typename...PARAMS>
T* Load(const std::string& ident, PARAMS...args) {
// Create a hash from the first parameter:
long hash = StringHash(ident);
auto it = resources.find(hash);
if (it != resources.end())
{
@Gerjo
Gerjo / Line intersection
Created August 14, 2013 15:17
Line intersection
Line.prototype.intersection = function(other) {
// Quick hack to make this work. I've taken this code from my C++ project.
var p1 = this.a;
var d1 = this.b;
var p2 = other.a;
var d2 = other.b;
console.log("--- starting intersection --");
//function solve(p1, d1, p2, d2) {
@Gerjo
Gerjo / Bernstein
Created August 19, 2013 17:23
Bernstein basis polynomial
///
///
///
///
float BernsteinBasis(const int d, const int n, float x) {
// Binomial coefficient:
const int b = Factorial(d) / (Factorial(d - n) * Factorial(n));
// Bernstein polynomial: