Skip to content

Instantly share code, notes, and snippets.

View anossov's full-sized avatar

Pavel Anossov anossov

View GitHub Profile
@anossov
anossov / cave.py
Created November 14, 2012 07:51
Cave generator rewrite
import random
class Point():
__slots__ = ('x', 'y')
def __init__(self, x, y):
self.x = x
self.y = y
#include <GL3/gl3w.h>
#include <GL/glfw.h>
#include <iostream>
#include <string>
#include <vector>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
In [1]: l1 = [[[0]*3]*3]*3
In [2]: l1
Out[2]:
[[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]
In [3]: l1[0][0][0] = 'x'
@anossov
anossov / gist:5411655
Created April 18, 2013 10:12
method attributes
class A(object):
def x(self):
return self.x.y
x.y = 123
class B(object):
def x(self):
return B.x.y
x.y = 123
class A(object):
def x(cls):
return cls.x.y
x.y = 123
x = classmethod(x)
@anossov
anossov / test.py
Last active December 29, 2015 17:39
Panda3d 1.9dev: Broken textures with auto-shader and dynamic Geoms
import direct.directbase.DirectStart
from direct.gui.OnscreenText import OnscreenText
from panda3d.core import *
loadPrcFileData("", "dump-generated-shaders 1")
base.setBackgroundColor(0.5, 0.5, 0.5)
t = OnscreenText(text='asdallaskjf', scale=0.5)
@anossov
anossov / test.py
Last active December 29, 2015 18:18
Panda3d: trying to use sampler2DArray in GLSL
import direct.directbase.DirectStart
from panda3d.core import *
vertex = '''
#version 330
in vec4 p3d_Vertex;
in vec2 p3d_MultiTexCoord0;
uniform mat4 p3d_ModelViewProjectionMatrix;
@anossov
anossov / gist:7927031
Created December 12, 2013 12:04
re.DEBUG
In [87]: re.compile(r'[A-Z]{2,}(?:\s+[A-Z]{2,})+', re.DEBUG)
max_repeat 2 65535
in
range (65, 90)
max_repeat 1 65535
subpattern None
max_repeat 1 65535
in
@anossov
anossov / gist:8707420
Created January 30, 2014 12:25
cPython small integers
#ifndef NSMALLPOSINTS
#define NSMALLPOSINTS 257
#endif
#ifndef NSMALLNEGINTS
#define NSMALLNEGINTS 5
#endif
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
/* References to small integers are saved in this array so that they
can be shared.
The integers that are saved are those in the range
@anossov
anossov / config_parser.py
Created June 8, 2014 18:45
Config parser for github.com/acedrew/ubnt-mfi-py
import json
from collections import defaultdict
def parse_config(conf):
def Tree():
return defaultdict(Tree)
data = Tree()