Skip to content

Instantly share code, notes, and snippets.

@agrif
agrif / mtime_test.py
Created March 1, 2011 01:21
a simple os.stat performance test
import os, os.path, sys, time
if not len(sys.argv) in (2, 3):
print "Usage: %s dir_to_scan [num_tests]" % (sys.argv[0],)
sys.exit(1)
num_tests = 5
if len(sys.argv) == 3:
try:
num_tests = int(sys.argv[2])
@agrif
agrif / gist:893734
Created March 30, 2011 02:04
wacky python bug
class SomeClass:
def __init__(self, some_var=[]):
self.data = some_var
def append(self, var):
self.data.append(var)
a = SomeClass()
a.append(1)
a.append(2)
# This file is part of the Minecraft Overviewer.
#
# Minecraft Overviewer is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# Minecraft Overviewer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
(04/08/11 23:18:24) [core] error: error in <local.build.BuildPlugin object at 0x2d66710>
Traceback (most recent call last):
File "/home/agrif/devel/gitbot/hesperus/agent.py", line 73, in start
item[0](self, *item[1], **item[2])
File "/home/agrif/devel/gitbot/hesperus/plugin.py", line 152, in handle_incoming
if func(self, chans, msg, direct, reply):
File "/home/agrif/devel/gitbot/hesperus/plugin.py", line 143, in sub_function
func(self, chans, match, direct, reply)
File "/home/agrif/devel/gitbot/local/build.py", line 70, in build_command
j = self.gm_client.submit_job(func, data, background=False, wait_until_complete=False)
@agrif
agrif / mcrtool.py
Created April 10, 2011 00:57
a simple MCR chunk extractor
#!/usr/bin/python
usage = "python contrib/%prog [-v] [-f file] [-o output/]"
description = """
Extracts the given MCR file into output/. If -o is not provided, it
will be derived from the input file name.
"""
from optparse import OptionParser
@agrif
agrif / gist:934818
Created April 21, 2011 15:52
hacky php unsigned long to float
$n = unpack("N", ...);
$res = 0.0;
for ($bit = 0; $bit < 32; $bit++) {
if ($n & (1 << $bit)) {
$res += pow(2, $bit);
}
}
echo $res;
@agrif
agrif / settings.py
Created June 15, 2011 01:15
Example rendermode-options settings.py
rendermode = ['lighting', 'subway-cave', 'subway-overlay']
custom_rendermodes = {
'subway-cave' : {'parent' : 'cave',
'description' : 'a subway map, based on the cave rendermode',
'options' : {
'depth_tinting' : False,
'lighting' : True,
'only_lit' : True,
'min_depth' : 40,
@agrif
agrif / minecraft-overviewer-9999.ebuild
Created July 11, 2011 21:11
an ebuild for Minecraft Overviewer
EAPI=2
inherit git distutils
DESCRIPTION="Generates large resolution images of a Minecraft map."
HOMEPAGE="http://overviewer.org/"
EGIT_REPO_URI="git://github.com/brownan/Minecraft-Overviewer.git"
LICENSE="GPL-3"
SLOT="0"
@agrif
agrif / settings.py
Created July 15, 2011 02:40
example dungeon overlay for rendermode-options
rendermode = ['lighting', 'dungeon']
custom_rendermodes = {
'dungeon' : {
'parent' : 'mineral',
'description' : 'an overlay showing the location of dungeons',
'options' : {
'minerals' : [
(52, (0, 0, 255)),
(48, (0, 255, 0)),
@agrif
agrif / settings.py
Created July 19, 2011 02:12
another example settings.py for rendermode-options
rendermode = ['my-custom-mode']
custom_rendermodes = {
'my-custom-mode' : {'parent' : 'cave',
'description' : 'a custom mode that only renders certain depths',
'options' : {
#'depth_tinting' : False,
#'lighting' : True,
#'only_lit' : True,
'min_depth' : 40,