Skip to content

Instantly share code, notes, and snippets.

@matthiasvegh
matthiasvegh / gist:7979487
Created December 15, 2013 22:52
Inline this please
void foo_impl3() {
std::cout<<"foo"<<std::endl;
}
void foo_impl2() {
foo_impl3();
}
void foo_impl1() {
@matthiasvegh
matthiasvegh / getClang.sh
Created December 16, 2013 09:44
A simple clang getter
#!/bin/bash
#A clang fether/builder from llvm, using svn
rm -rf llvm
rm -rf llvmbuild
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
@matthiasvegh
matthiasvegh / dawkins.cpp
Created December 17, 2013 19:50
A mutating algorithm to find a string
#include <iostream>
#include <string>
#include <ctime>
#include <vector>
#include <algorithm>
#include <unistd.h>
const static std::string magic = "METHINKS IT IS LIKE A WEASEL";
@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;
@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 / 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 / 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 / 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 / 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 / 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'))