Skip to content

Instantly share code, notes, and snippets.

View bjorn's full-sized avatar
🇳🇱

Thorbjørn Lindeijer bjorn

🇳🇱
View GitHub Profile
@bjorn
bjorn / delete-container
Last active December 17, 2015 00:19
libcloud based scripts
#!/usr/bin/env python2
#
# Warning: this script will delete the given container, including its contents
#
from argparse import ArgumentParser
from os import environ
from sys import exit
from libcloud.storage.types import Provider, ContainerDoesNotExistError
# Filename : Image2Map.py
# Authors : Georg Muntingh and Bjorn Lindeijer
# Version : 1.2
# Date : June 16, 2010
# Copyright : Public Domain
import os, sys, Image, networkx
class TileMap:
""" This class represents a map of tiles.
@bjorn
bjorn / dds2image.cpp
Last active September 12, 2016 12:40
Loading a DDS to a QImage using QGLPixelBuffer.
QImage readDDSFile(const QString &filename)
{
QGLWidget glWidget;
glWidget.makeCurrent();
GLuint texture = glWidget.bindTexture(filename);
if (!texture)
return QImage();
// Determine the size of the DDS image
@bjorn
bjorn / authors.rb
Created August 23, 2012 20:47
Generate copyright header author lists
#!/usr/bin/env ruby
# This script can be used to generate a list of authors for each source file,
# for inclusion in the copyright header.
require 'rugged'
require 'set'
repo = Rugged::Repository.new(".")
@bjorn
bjorn / durationlogger.h
Created August 17, 2012 17:47
Duration Logger (Qt)
#ifndef DURATIONLOGGER_H
#define DURATIONLOGGER_H
#include <QTime>
/**
* A helper class that logs the duration of a specific scope.
*/
class DurationLogger
{
@bjorn
bjorn / createupdates.lua
Created July 14, 2012 21:01
Scripts around manaserv
#!/usr/bin/env lua
local function checkenv(varname)
local value = os.getenv(varname)
if not value then
print(varname .. ' not set')
os.exit(1)
end
return value
end
@bjorn
bjorn / object.lua
Created December 15, 2011 18:32
Lua OOP system
--
-- Object is the base class of anything that follows this OOP mechanism.
-- Usage example:
--
--
-- CREATING A DERIVED CLASS
--
-- local Human = Object:subclass {
-- name = "Anonymous",
-- weight = 0,
@bjorn
bjorn / benchmark.lua
Created December 14, 2011 10:57
Lua OOP benchmark
-- This benchmark compares two ways of creating objects.
-- Output commonly seen on the Lua demo site:
--
-- Creation time: 0.16
-- Calling member function time: 0.11
-- Memory: 2868.8798828125
--
-- Creation time: 0.11
-- Calling member function time: 0.13
-- Memory: 1697.4736328125