Skip to content

Instantly share code, notes, and snippets.

@svanellewee
svanellewee / cannot_find_logger_handler.py
Created June 8, 2016 10:56
Python logger not found!
log = logging.getLogger('apscheduler.executors.default') # this logger complained.
log.setLevel(logging.INFO) # DEBUG
fmt = logging.Formatter('%(levelname)s:%(name)s:%(message)s')
h = logging.StreamHandler()
h.setFormatter(fmt)
log.addHandler(h)

ert

(ert-deftest foo ()
  (assert nil))

Now: M-x ert RET foo RET

apropos

Emacs makes discovery easier.

@svanellewee
svanellewee / w_wad.py
Created May 9, 2016 20:27
Rewriting doom into python. Wadfiles.
from __future__ import print_function
import unittest
import collections
import struct
'''
vertex test cases:
(10, FileLump(filepos=94972, size=1868, name='VERTEXES'))
(21, FileLump(filepos=179996, size=3768, name='VERTEXES'))
(32, FileLump(filepos=295644, size=3784, name='VERTEXES'))
@svanellewee
svanellewee / current idea.md
Last active May 6, 2016 22:38
Doom's use of the BSP node.

My current interpretation is as follows: A node represents the splitting pane is centered at (x,y) with a direction given by dx,dy.

Remember the cross product? u x v = (u1, u2, u3) X (v1, v2, v3) = (u2v3 - u3v2, u3v1 - u1v3, u1v2 - u2v1)

Node, splittin pane's vector is (dx, dy, 0) what direction does the viewer look at the line ? (viewx - x, viewy - y, 0) = (dvx, dvy, 0) so the cross product would be:

import sys
import logging
import struct
logging.basicConfig(level=logging.DEBUG)
logger =logging.getLogger(__name__)
def get_int(data):
return struct.unpack("<I", data)[0]
DIR_HEADER_SIZE=12
uwsgi --http :8000 --wsgi-file simpleapp.py
@svanellewee
svanellewee / Vagrantfile
Last active January 16, 2016 22:33
Kafka dev environment
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@svanellewee
svanellewee / const_affects_the_left_of_it.c
Last active January 13, 2016 20:17
Const Pointers in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int x,y;
char *make_string(char* message) {
char* val= (char*)malloc(sizeof(message));
strcpy(val,message);
return val;
}
@svanellewee
svanellewee / Dockerfile
Created December 28, 2015 10:47
Emacs NOX Dockerfile
from ubuntu:14.04
# Install dependencies
run apt-get update && \
apt-get install -y emacs24-bin-common emacs24-common emacs24-common-non-dfsg emacsen-common \
emacs24-el \
emacs24-bin-common emacs24-common emacs24-common-non-dfsg emacs24-nox \
emacsen-common
# libasound2 libasound2-data \
# libasound2-plugins alsa-utils
@svanellewee
svanellewee / some_examples.sql
Last active December 26, 2015 21:08
Docker Postgres Hackery
create table Birds (idBirds SERIAL, Name varchar(11));
insert into Birds (Name) values ('Hadida'),('Dikkop');