Skip to content

Instantly share code, notes, and snippets.

View jirihnidek's full-sized avatar

Jiri Hnidek jirihnidek

View GitHub Profile
@jirihnidek
jirihnidek / blender_dist_pnt_to_plane.py
Last active September 15, 2016 19:36
Simple Blender script for computing distance between plane (camera) and point.
"""
Demonstration of computation distance point to plane. Plane is represented by normal
vector and point laying at the plane.
"""
import bpy
import mathutils
def main():
@jirihnidek
jirihnidek / blender_img_3d_background.py
Last active December 31, 2021 15:56
This is simple Blender Python script for setting 3D background empty object.
"""
This example try to create new empty object visualized as
image. Image fits to the background of current active camera.
When you set X,Y coordinates of empty object called 'Pixel',
then this object is position at corresponding X,Y coordinate
at image in 3D space.
"""
import bpy
import math
@jirihnidek
jirihnidek / bmesh_shape_keys.py
Created September 15, 2016 19:57
Simple Blender Python script demonstrating using BMesh and Shape Keys
import bpy
import bmesh
import mathutils
def main():
"""
Example of bmesh and shape keys
"""
# Add basis shape
@jirihnidek
jirihnidek / simple_webgl.html
Last active November 7, 2016 21:54
Simple example of WebGL
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>WebGL Simple Point</title>
</head>
<body>
<canvas width="512" height="512" id="webgl_canvas"></canvas>
@jirihnidek
jirihnidek / bspline_solid-boolean.py
Created November 9, 2016 08:17
Example of solid boolean operation
"""
This module is able to create simple solid object (cube). Each side of
cube is bspline surface. This solid object can be exported to BREP file.
"""
from OCC.gp import *
from OCC.Geom import *
from OCC.TColGeom import *
from OCC.TColgp import *
from OCC.GeomConvert import *
@jirihnidek
jirihnidek / CMakeLists.txt
Last active November 29, 2016 08:30
Test of forking (creating lot of child processes) at Linux
# Main CMakeFile.txt
# Minimal version of CMake
cmake_minimum_required (VERSION 2.6)
# Build type
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
@jirihnidek
jirihnidek / CMakeLists.txt
Created November 25, 2016 14:35
Test of threads at Linux
# Main CMakeFile.txt
# Minimal version of CMake
cmake_minimum_required (VERSION 2.6)
# Build type
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
@jirihnidek
jirihnidek / getaddrinfo_example.c
Last active February 9, 2025 12:12
Example of getaddrinfo() program.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int
lookup_host (const char *host)
@jirihnidek
jirihnidek / example_res_reset.py
Created May 29, 2017 12:51
Example of reseting resolver using D-Bus, NetworkManager and ctypes
from __future__ import print_function
import dbus
import dbus.mainloop.glib
from gi.repository import GLib
import threading
import time
import socket
import ctypes
try:
@jirihnidek
jirihnidek / client_multi_process.py
Created May 29, 2018 16:06
Multi-threaded vs multi-process vs serial https client
#!/usr/bin/env python
import requests
import time
import copy
from multiprocessing import Process
from data import URLS
def send_request(num, url):