Skip to content

Instantly share code, notes, and snippets.

@matthiasvegh
matthiasvegh / walker.py
Created October 15, 2015 11:20
Recursive Dates
#!/usr/bin/env python
import os
import time
def main():
rootDir = '/home/phil/workspace/clang-dump-names'
for dirName, subDirList, fileList in os.walk(rootDir):
depth = dirName.count(os.sep) - rootDir.count(os.sep)
indentation = '\t' * depth
@matthiasvegh
matthiasvegh / defineclasswithbases.cpp
Created September 27, 2015 00:36
Creating classes with publicly visible bases
#define BOOST_PP_VARIADICS 1
#include <boost/mpl/vector.hpp>
#include <iostream>
#include <memory>
#include <typeinfo>
#include <boost/preprocessor.hpp>
#define GETCLASS(elem) BOOST_PP_SEQ_HEAD(elem)
@matthiasvegh
matthiasvegh / redirect.cpp
Created February 1, 2015 23:05
Redirect Cerr
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <sys/epoll.h>
struct Redirecter {
int writeFd, readFd;
@matthiasvegh
matthiasvegh / getFlagsFromYcm.py
Last active August 29, 2015 14:14
Script to retrieve compilation flags according to YouCompleteMe.
#!/usr/bin/env python
import sys
import os
ycmpath = os.path.expanduser("~/.vim/bundle/YouCompleteMe")
def main():
sys.path.insert(0, os.path.join(ycmpath, 'third_party/ycmd'))
@matthiasvegh
matthiasvegh / LazyIterator.cpp
Created February 22, 2014 11:52
ph::find benchmark
#include <iterator>
#include <chrono>
#include <random>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <type_traits>
namespace ph {
@matthiasvegh
matthiasvegh / gist:8350755
Created January 10, 2014 11:57
Also inline this
void foo(T t) {
foo_impl1(t);
}
void foo_impl1(T u) {
foo_impl2(u);
}
void foo_impl2(T w) {
std::cout<<w<<std::endl;
@matthiasvegh
matthiasvegh / plistMaker.py
Last active January 2, 2016 10:49
Smileys.xml to plist for Adium
#!/usr/bin/python
import os
import xml.etree.ElementTree as ET
tree = ET.parse('smileys.xml')
root = tree.getroot()
smileys = []
@matthiasvegh
matthiasvegh / interpolated-1.json
Created January 1, 2014 21:52
interpolated-1.json
{
"sdfVersion": 2,
"name": "interpolated-1",
"width": 1280,
"height": 720,
"exposure": 1.0,
"postprocess": 1,
"renderTime": 3904879,
"spp": 3950,
"sppTarget": 5001,
@matthiasvegh
matthiasvegh / Pipeliner
Created December 29, 2013 14:56
Pipeliner prototype for the composition of many functions to be called on many objects.
template<typename T>
struct ThreadWrapper {
/* ... */
};
template<typename T, typename Ts...>
class PipelineFunctions {
public:
PipelineFunctions() {
@matthiasvegh
matthiasvegh / NonConst->Lock
Created December 19, 2013 09:07
If a class has several non-const functions, these should all contain a lock_guard, however placing this in every function implementation can be too verbose, this is a possible workaround.
#include <iostream>
#include <mutex>
#include <vector>
class Bar { };
class Foo1 {
std::mutex _mutex;
std::vector<Bar> _data;