Skip to content

Instantly share code, notes, and snippets.

View tomas789's full-sized avatar

Tomas Krejci tomas789

  • Ampiato.com
  • Czech Republic, Europe
View GitHub Profile
XVFB=/usr/bin/Xvfb
XVFBARGS=":100 -screen 0 1600x1200x24 -auth /etc/conf.d/Xvfb.cfg -nolisten tcp"
PIDFILE=/var/run/Xvfb.pid
Host ruapehu
HostName ruapehu.example.com
Host aoraki
ProxyCommand ssh -q ruapehu nc -q0 aoraki 22
Host tongariro
ProxyCommand ssh -q aoraki nc -q0 %h 22
#include <iostream>
#include <fstream>
#include <string>
void gen_random(char *s, const int len) {
static const char alphanum[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
@tomas789
tomas789 / gist:6855047
Last active December 24, 2015 19:59
Parallel processing
#include <iostream>
#include <thread>
#include <atomic>
#include <mutex>
#include <vector>
class example {
std::atomic<std::size_t> counter;
std::size_t stop = 160;
@tomas789
tomas789 / gist:7844152
Created December 7, 2013 15:46
Template-based Visitor pattern implementation in C++ PS: Even more generic version. Notice that actual visitor class have non-virtual methods. This allows to have them templated.
#include <iostream>
#include <utility>
template <typename ... Types>
class Visitor;
template <typename T>
class Visitor<T> {
public:
virtual void visit(T & visitable) = 0;
@tomas789
tomas789 / jit.cpp
Created December 28, 2013 17:57
LLVM JIT Example - Example of very simple JIT using LLVM. It compiles function with prototype `int64_t()` returning value `765`. Build: clang++ `llvm-config --cppflags --ldflags --libs core jit X86` jit.cpp
#include <iostream>
#include <cstdint>
#include <string>
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Analysis/Verifier.h"
@tomas789
tomas789 / jit2.cpp
Created December 28, 2013 18:42
Another LLVM JIT - Loading variable from memory clang++-mp-3.3 `llvm-config --cppflags --ldflags --libs core jit X86` jit2.cpp
#include <iostream>
#include <cstdint>
#include <string>
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Analysis/Verifier.h"
@tomas789
tomas789 / llvmfcs.cpp
Created December 28, 2013 19:39
Dump functions from LLVM's bc file Compile: clang++-mp-3.3 `llvm-config-mp-3.3 --cxxflags --ldflags --libs core jit X86 bitreader` -std=c++0x -o llvmfcs llvmfcs.cpp Usage: llvmfcs filename.bc
#include <iostream>
#include <string>
#include <llvm/ADT/OwningPtr.h>
#include <llvm/Bitcode/ReaderWriter.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <llvm/Support/MemoryBuffer.h>
#include <llvm/Support/system_error.h>
@tomas789
tomas789 / gist:10915069
Created April 16, 2014 18:07
C++/C++11 Variadic template CSV parser. Supports quoted strings, custom parsers, strongly typed, STL-like, generic, fast, highly customizable.
#include <functional>
#include <fstream>
#include <iostream>
#include <limits>
#include <sstream>
#include <tuple>
#include <vector>
template <typename ... TList>
struct DefaultParsersTuple;
@tomas789
tomas789 / calibration.yaml
Created October 2, 2016 06:32
Sample camera calibration file for tonav (https://github.com/tomas789/tonav)
#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------
# Camera calibration and distortion parameters (OpenCV)
Camera.fx: 528.52949934564765
Camera.fy: 528.52949934564765
Camera.cx: 319.5
Camera.cy: 239.5