Skip to content

Instantly share code, notes, and snippets.

View jirihnidek's full-sized avatar

Jiri Hnidek jirihnidek

View GitHub Profile
@jirihnidek
jirihnidek / VerseCommands.txt
Last active August 29, 2015 13:55
Structure of some commands sent during Verse handshake.
USER_AUTH_FAILURE
0 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+---------------+---------------+
| OpCode=8 | Length=2 |
+---------------+---------------+
USER_AUTH_SUCCESS
@jirihnidek
jirihnidek / bpy_obj.py
Last active August 29, 2015 13:56
This code snippet make active object in Blender not active object, unselected and unselectable
import bpy
obj = bpy.context.active_object
obj.select = False
bpy.context.scene.objects.active = None
obj.hide_select = True
@jirihnidek
jirihnidek / multi_proc.py
Last active August 29, 2015 13:56
Testing of multithreading and multiprocesing in Python interpreters.
#!/usr/bin/env python
"""
Simple module for testing parallel variant of
code using Python multiprocessing
"""
from multiprocessing import Process
import time
@jirihnidek
jirihnidek / Results.md
Last active August 29, 2015 13:56
Simple CTypes example and benchmark.

Results of Benchmark

Python2.6         0.14
Python2.6 CTypes  0.71
Python2.7         0.15
Python2.7 CTypes  0.77
Python3.3         0.14
Python3.3 CTypes 0.71
@jirihnidek
jirihnidek / map_example.cc
Created April 2, 2014 11:59
Pointer as key for C++ map
#include <iostream>
#include <map>
// Compile: g++ map_example.cc
// Run: ./a.out
int main(void)
{
std::map<unsigned char*, int> paleta;
unsigned char rgb1[3], rgb2[3];
@jirihnidek
jirihnidek / README.md
Last active August 29, 2015 14:03
Examples of Python scripts for adding and changing values in Verse layers

Examples of VerseLayer

This gist contains several Python scripts using class VerseLayer from module Verse Entities: https://github.com/verse/verse-entities

Create Verse Layer

The script that is used for creating new layer is called verse_layer_create.py. This script creates new Node, then this node is moved to the parent of scene nodes. Thus this node will not be destroyed after client logout. New layer is created in

@jirihnidek
jirihnidek / webpy_json.py
Last active August 29, 2015 14:08
WebPy JSON Example
"""
This module tries to print JSON from HTTP GET/POST method.
"""
#
# To test the application run application with:
#
# python ./webpy_json.py
#
# and type following URI in browser addres bar:
@jirihnidek
jirihnidek / base.html
Last active August 29, 2015 14:08
WebPy Templetor Example
$def with (content)
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>$content.title</title>
</head>
<body>
$:content
@jirihnidek
jirihnidek / shared_pointers.cc
Created November 7, 2014 12:43
Example of C++ shared pointers
#include <iostream>
#include <memory>
#include <assert.h>
using namespace std;
template <class Value>
class Output
{
@jirihnidek
jirihnidek / layers_example.py
Last active August 29, 2015 14:10
Blender Python API: Example of BMesh layers
import bpy
import bmesh
def element_id_layer(bm, elems, id_name):
"""
This function will create/print verts/edges/faces layer
"""
# Try to get layer of elem IDs
elems_iter = getattr(bm, elems)