Skip to content

Instantly share code, notes, and snippets.

View jirihnidek's full-sized avatar

Jiri Hnidek jirihnidek

View GitHub Profile
@jirihnidek
jirihnidek / FindLibWebSockets.cmake
Created June 26, 2013 08:15
This is simple CMake find module for libwebsockets library
# This module tries to find libWebsockets library and include files
#
# LIBWEBSOCKETS_INCLUDE_DIR, path where to find libwebsockets.h
# LIBWEBSOCKETS_LIBRARY_DIR, path where to find libwebsockets.so
# LIBWEBSOCKETS_LIBRARIES, the library to link against
# LIBWEBSOCKETS_FOUND, If false, do not try to use libWebSockets
#
# This currently works probably only for Linux
FIND_PATH ( LIBWEBSOCKETS_INCLUDE_DIR libwebsockets.h
@jirihnidek
jirihnidek / wslay_openssl_server.c
Last active December 19, 2015 18:08
Example of WebSocket server implemented with WSLay and OpenSSL
/**
* \brief Wslay WebSocket infinite loop
*/
void *websocket_loop(void *arg)
{
struct Context *C = (struct vContext*)arg;
/*
* This structure is passed as *user_data* in callback functions.
*/
struct Session *session = CTX_current_session(C);
@jirihnidek
jirihnidek / vrsent_cli.py
Last active December 23, 2015 12:19
Example of using vrsent module as python cli to verse
import vrsent as v
s = v.VerseSession(hostname='localhost', service='12344', \
callback_thread=True, username='your_name', password='your_pass')
for n in s.nodes.values():
print(n)
n = v.VerseNode(s, custom_type=10)
print(n)
tg = v.VerseTagGroup(n, custom_type=100)
print(tg)
tg = v.VerseTag(tg=tg, value=(1.0,), custom_type=1000)
@jirihnidek
jirihnidek / vrsent_subclasses.py
Last active December 23, 2015 12:19
Subclassing of VerseNode and VerseTag
import vrsent as v
class CustomNode(v.VerseNode):
"""
Custom subclass of VeseNode
"""
custom_type = 10
def __str__(self):
@jirihnidek
jirihnidek / experiment_array.cc
Last active January 3, 2016 23:59
List of base classes.
#include <iostream>
#include <vector>
#include <stdlib.h>
// Not templated abstract class
class DataBase {
public:
DataBase() {};
@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 / .gitignore
Last active November 17, 2022 20:04
UDP client-server application using random port number with respect to statefull firewalls aka hole punching.
.cproject
.project