Skip to content

Instantly share code, notes, and snippets.

View malleor's full-sized avatar

Janusz Lenar malleor

View GitHub Profile
function play(iteration) {
var ctrl = {
up: function() { window.gm.inputManager.emit('move', 0); return window.gm.moved; },
right: function() { window.gm.inputManager.emit('move', 1); return window.gm.moved; },
down: function() { window.gm.inputManager.emit('move', 2); return window.gm.moved; },
left: function() { window.gm.inputManager.emit('move', 3); return window.gm.moved; }
};
while(!window.gm.over && !window.gm.won) {
if(!iteration(ctrl)) {
@malleor
malleor / iris.py
Last active August 29, 2015 14:03
Playing with Decision Trees from scikit
import numpy as np
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from matplotlib import pyplot as plt
# fetch data
iris = load_iris()
classes = {}
for cls in (0,1,2):
classes[cls] = np.array([v for k, v in zip(iris.target, iris.data) if k == cls])

Crazy inventions

Show the photos:

1a 1b

2

3a

@malleor
malleor / Factory.cpp
Created May 29, 2012 15:10
Generic factoring
class IFactory
{
public:
virtual ~IFactory() {}
/// Creates data object of the specified type
template <class DataType>
DataType* CreateData()
{
return NULL;
@malleor
malleor / points_in_radius_voxels_concept.cpp
Created October 25, 2012 20:24
Get points from spherical neighborhood given a voxel-sorted cloud of points
IProject& proj = ...;
float R = ...;
Eigen::Vector3d ref_point = ...;
IHierarchy& h = proj.GetDefHierarchy();
IHierarchy& all_clouds_h = Query(".cloud", h).Flatten().Result(); // gets flat structure of all clouds
auto all_clouds = all_clouds_h.GetRoot().GetElements();
IData& storage = proj.GetData();
// iterate through clouds
@malleor
malleor / gist:4116567
Created November 20, 2012 07:26
Header guard to pragma once in VS
\#ifndef {[A-Z_]@_H}:b*\n\#define \1:b*\n{(.*\n)*}\#endif(.*\1)*\n -> #pragma once\n\2
@malleor
malleor / Remove doxygen comments
Created November 21, 2012 13:49
Interface class definition to implementation class definition in VS
\n*:b*///.@$ -> None
@malleor
malleor / load_clouds.py
Last active December 11, 2015 03:18
Script execution concept Opt. 1: Batch files
from glob import glob
from os import cwd
from os.path import join, split, splitext
from frames import execute
MANIFEST = { # Declare the algorithm info.
'doc': 'Loads all clouds of given format from the CWD.',
'author': 'John Doe',
'version': '0.6',
'multithreaded': False
@malleor
malleor / load_clouds.py
Last active December 11, 2015 03:19
Script execution concept Opt. 2: Denoted functions
from glob import glob
from os import cwd
from os.path import join, split, splitext
from frames import execute, script
@script(author='John Doe', version='0.6', multithreaded=False) # Declare the algorithm's info.
def load_clouds(cloud_extension='copsxml'): # Name and input params are given a a function with kwargs.
''' Loads all clouds of given format from the CWD. ''' # Documentation in a docstring.
cloud_ids = []
@malleor
malleor / A.py
Last active December 11, 2015 03:28
dla Kuby
from frames import script
@script
def A(a=3, b=5):
''' A returns bollox. '''
print 'Hello, framework.'
try:
args = {'a': 5}