Skip to content

Instantly share code, notes, and snippets.

@o11c
o11c / analyze.py
Created May 26, 2012 20:52
quick hack replacement for analyze.php
#!/usr/bin/env python
import os
import re
import git
import zipfile
# contains resources.xml and .zip files
updates_path = os.path.join(os.getenv('HOME'), '.local/share/mana/updates/tmw-test.dyndns.org')
# submodule repository
client_data = 'client-data'
@o11c
o11c / alige-mobpoints.txt
Created June 1, 2012 23:35
The results of Alige's suggestion for a mob point formula.
This is a word diff
Key:
tilde is a real newline
plus, minus, space are added, removed, and identical chunks within a line
Note, my script is buggy, so nonexistent monsters are not getting a slot in the array!
diff --git i/world/map/npc/functions/mob_points.txt w/world/map/npc/functions/mob_points.txt
index a3fe8af..6c83fcc 100644
--- i/world/map/npc/functions/mob_points.txt
@o11c
o11c / demangle.cpp
Created September 13, 2012 23:12
Wrapper for c++ demangling
#include <cxxabi.h>
#include <typeinfo>
#include <string>
#include <stdexcept>
std::string demangle(const std::type_info& info)
{
int status;
char *result = abi::__cxa_demangle(info.name(), nullptr, 0, &status);
WARNING 2013-04-21T23:57:11 Error message from mibbit: Closing Link:
elanore[ip68-107-59-170.sd.sd.cox.net] (Ping timeout)
INFO 2013-04-21T23:57:11 Reconnecting to mibbit.
INFO 2013-04-21T23:57:11 Connecting to irc.mibbit.net:6697.
WARNING 2013-04-21T23:57:22 Error connecting to irc.mibbit.net:6697: SSLError:
_ssl.c:489: The handshake operation timed out
INFO 2013-04-21T23:57:22 Reconnecting to mibbit at 2013-04-21T23:57:32.
_ssl.c:489: The handshake operation timed out [0/189]
INFO 2013-04-21T23:57:22 Reconnecting to mibbit at 2013-04-21T23:57:32.
INFO 2013-04-21T23:57:33 Connecting to irc.mibbit.net:6697.
@o11c
o11c / core.py
Created May 7, 2013 21:44
fragment of core.py
class Type:
def __new__(cls, raw, context):
''' Deeply magic wrapper that constructs a Type from a C Type*.
It will always return the same object as long as it exists,
which will actually be an instance of a subclass.
'''
assert isinstance(raw, _core.Type)
assert isinstance(context, Context)
assert cls == Type # subclasses must override it
@o11c
o11c / urand.c
Created May 29, 2013 03:59
A really WTF way of generating a random entry out of a list of numbers.
int main(int argc, char **argv)
{
int fd = open("/dev/urandom", 0);
int ai = 0;
int idx;
for (;;)
{
char c;
@o11c
o11c / asm-via-ll.s
Created June 16, 2013 20:47
missed optimizatino
.file "asm.ll"
.text
.globl _Z4testR6Server
.align 16, 0x90
.type _Z4testR6Server,@function
_Z4testR6Server: # @_Z4testR6Server
.cfi_startproc
# BB#0:
pushq %rax
.Ltmp1:
@o11c
o11c / Makefile
Last active December 19, 2015 19:19
gcc and clang both fail to generate fully correct debuginfo here, in slightly different ways. I would expect Foo and Bar to never be incomplete types.
override CC = ${CXX} # for linking
override CXXFLAGS += -std=c++0x -g
main: main.o foo.o bar.o
main.o: main.cpp common.hpp
foo.o: foo.cpp common.hpp
bar.o: bar.cpp common.hpp
clean:
rm -f main main.o foo.o bar.o
# push some change to the 'test' branch
# IRC message is good
[10:34:11] --> github-tmw (~github-tm@192.30.252.48) has joined #themanaworld-dev
[10:34:11] -- Notice(github-tmw): [tmwa] o11c pushed 3 new commits to test: http://git.io/EIqnNA
[10:34:11] -- Notice(github-tmw): tmwa/test d2c34c4 Ben Longbons: Make some npc errors better
[10:34:11] -- Notice(github-tmw): tmwa/test d3beae7 Ben Longbons: Add dumpers for the rest of the stack types
[10:34:11] -- Notice(github-tmw): tmwa/test 23c0f35 Ben Longbons: Refactor npc event timers to have an expired state...
[10:34:11] <-- github-tmw (~github-tm@192.30.252.48) has left #themanaworld-dev
# push that same changeset to the 'master' branch
@o11c
o11c / Makefile
Created August 28, 2013 20:26
An oddity in GNU Make's definition of the MFLAGS and MAKEFLAGS variables
f := $(MFLAGS)
z := $(MAKEFLAGS)
all:
@echo early MFLAGS: $f
@echo early MAKEFLAGS: $z
@echo late MFLAGS: ${MFLAGS}
@echo late MAKEFLAGS: ${MAKEFLAGS}