Skip to content

Instantly share code, notes, and snippets.

View jirihnidek's full-sized avatar

Jiri Hnidek jirihnidek

View GitHub Profile
@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 / example_mesh_changes.py
Created November 24, 2014 21:04
Blender Python API example: detection of changes in mesh object (edit mode)
import bpy
def cb_scene_update(context):
"""
"""
edit_obj = bpy.context.edit_object
if edit_obj is not None and edit_obj.is_updated_data is True:
print(edit_obj)
@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)
@jirihnidek
jirihnidek / object_template.c
Last active August 29, 2015 14:16
Template of Verse command used in https://github.com/verse/verse
/*
*
* ***** BEGIN BSD LICENSE BLOCK *****
*
* Copyright (c) 2009-2015, Jiri Hnidek
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@jirihnidek
jirihnidek / b3d_prop_callbacks.py
Created March 19, 2015 11:27
Blender property and callbacks
"""
Example of callbacks used for Blender integer property
"""
import bpy
# Some global values
values = {}
default_value = -1
@jirihnidek
jirihnidek / pythonocc_bspline_surface.py
Created April 9, 2015 17:01
PythonOCC example of bspline surface
"""
Simple example of bspline surface
"""
from OCC.gp import *
from OCC.Geom import *
from OCC.TColGeom import *
from OCC.TColgp import *
from OCC.GeomConvert import *
from OCC.BRepBuilderAPI import *