Skip to content

Instantly share code, notes, and snippets.

View Dav1dde's full-sized avatar

David Herberth Dav1dde

View GitHub Profile
@Dav1dde
Dav1dde / gist:5831219
Last active December 18, 2015 19:09 — forked from anonymous/gist:5831109
upstream dtutorapp {
server 127.0.0.0:9001;
}
server {
listen 80 default_server;
server_name _;
root /home/dtutor/dtutor/app/static/;
keepalive_timeout 5;
>>> class A(object):
... def __add__(self, o): return "add"
...
... class B(A):
... def __radd__(self, o): return "radd"
>>> A() + B()
0: 'add'
>>>
@Dav1dde
Dav1dde / gist:3788166
Created September 26, 2012 13:50 — forked from anonymous/gist:3788098
DasIch... Tutorials yummy yummy
class AB():
def function1(self, eingabe):
print(eingabe)
tokenDict = {'vE':function1}
a = AB()
test = a.tokenDict['vE']
# smallest positive t such that s+t*ds is an integer
intbound = (s, ds) ->
if ds < 0
intbound -s, -ds
else
s = mod s, 1
return (1 - s) / ds
signum = (x) -> if x > 0 then 1 else (if x < 0 then -1 else 0)
@Dav1dde
Dav1dde / BanSlimes.fix1.py
Created August 8, 2012 19:55 — forked from eddyb/BanSlimes.fix1.py
SethBling's BanSlimes filter, with two of my fixes.
# Feel free to modify and use this filter however you wish. If you do,
# please give credit to SethBling.
# http://youtube.com/SethBling
#from pymclevel import TAG_Long
# Performs signed overflow and underflow for Java's long.
# NOTE apparently not required.
def jlong(x):
# Signed overflow.
@Dav1dde
Dav1dde / gist:3196600
Created July 29, 2012 08:12 — forked from JakobOvrum/gist:3196553
initOnce function
import std.stdio;
bool initOnce(alias var)(lazy typeof(var) init)
{
static bool hasInitialised = false;
if(!hasInitialised)
{
var = init();
hasInitialised = true;