Skip to content

Instantly share code, notes, and snippets.

View SirVer's full-sized avatar

Holger Rapp SirVer

View GitHub Profile
use("aux", "set")
-- Connects "start_flag" and "end_flag" with a road with as many flags set as
-- possible. Returns true when a road is build, false on error. This is
-- implemented as a straightforward A* implementation.
function connect_flags(start_flag, end_flag)
local start_field = start_flag.fields[1]
local end_field = end_flag.fields[1]
local closed_set = Set:new()
#!/usr/bin/env python
# encoding: utf-8
import os.path
from subprocess import Popen, PIPE, STDOUT
from colorama import Fore, Back, Style
from shell_grunt import WorkItem, Executor
import sys
## Fix LF in translation branch.
bzr switch translations && bzr pull
utils/remove_lf_in_translations.py
bzr add po
bzr commit -m "Fixed LF in translations." || true
bzr push
# Merge translations.
bzr switch trunk && bzr pull
bzr merge lp:~widelands-dev/widelands/translations
Making check in libasn1parser
make[1]: Entering directory `/tmp/asn1c_vlm/libasn1parser'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/tmp/asn1c_vlm/libasn1parser'
Making check in libasn1fix
make[1]: Entering directory `/tmp/asn1c_vlm/libasn1fix'
make check_fixer
make[2]: Entering directory `/tmp/asn1c_vlm/libasn1fix'
gcc -DHAVE_CONFIG_H -I. -I.. -I../libasn1parser -g -O2 -Wall -Wshadow -Wcast-qual -Wcast-align -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -MT check_fixer.o -MD -MP -MF .deps/check_fixer.Tpo -c -o check_fixer.o check_fixer.c
mv -f .deps/check_fixer.Tpo .deps/check_fixer.Po
use("aux", "formatting")
function image_line(image, count, text)
local imgs={}
for i=1,count do
imgs[#imgs + 1] = image
end
local imgstr = table.concat(imgs, ";")
if text ~= nil then
use("aux", "formatting")
return {
text =
rt(
h1("The Barbarian Lumberjack") ..
h2("General:") ..
p(_
[[The lumberjack clears the landscape from trees enabling you to build new houses.<br>
@SirVer
SirVer / actor_centrality.jl
Created August 14, 2012 22:59
Actor centrality in Julia
type Node
name::UTF8String
n::Set{Node}
Node(name) = new(name, Set{Node}())
end
typealias Graph Dict{UTF8String, Node}
function get(G::Graph, name)
@SirVer
SirVer / actor_centrality.py
Created August 14, 2012 22:59
Actor centrality in Python
#!/usr/bin/env python
# encoding: utf-8
#
def mean(l):
return sum(l, 0.)/len(l)
def centrality_mean(G, v):
dists = {}
next = {v}
@SirVer
SirVer / actor_centrality.cc
Created August 15, 2012 18:42
Actor centrality in Cplusplus
#include <set>
#include <string>
#include <map>
#include <fstream>
#include <iostream>
#include <vector>
#include <stdint.h>
using namespace std;
@SirVer
SirVer / gist:3364304
Created August 15, 2012 22:30
iterfib in various languages
-- iterfib.cc --
#include <iostream>
#include <stdint.h>
using namespace std;
uint64_t fib(int k) {
uint64_t ln = 1;
uint64_t n = 1;