Skip to content

Instantly share code, notes, and snippets.

@simonlynen
simonlynen / local_static.hpp
Created November 16, 2015 19:00
Singleton with local static
class Singleton {
public:
static Singleton& Instance() {
static Singleton instance;
return instance;
}
private:
Singleton() = default;
~Singleton() = default;
avconv -i 2015Oct07_104821_spm.mp4 -i 2015Oct07_104821_vio.mp4 -filter_complex "[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w" output.mp4
template<typename T>
struct HasConstIterator {
private:
typedef char Yes;
typedef struct {
char array[2];
} No;
template<typename C> static Yes Test(typename C::const_iterator*);
#ifndef MULTIAGENT_MAPPING_COMMON_THREADSAFE_QUEUE_H_
#define MULTIAGENT_MAPPING_COMMON_THREADSAFE_QUEUE_H_
#include <atomic>
#include <memory>
#include <pthread.h>
#include <queue>
#include <string>
#include <sys/time.h>
// From Kenton Varda: http://stackoverflow.com/questions/2340730/are-there-c-equivalents-for-the-protocol-buffers-delimited-i-o-functions-in-ja
bool writeDelimitedTo(
const google::protobuf::MessageLite& message,
google::protobuf::io::ZeroCopyOutputStream* rawOutput) {
// We create a new coded stream for each message. Don't worry, this is fast.
google::protobuf::io::CodedOutputStream output(rawOutput);
// Write the size.
const int size = message.ByteSize();
output.WriteVarint32(size);
view_controller_msgs::CameraPlacement camera_placement;
camera_placement.interpolation_mode =
view_controller_msgs::CameraPlacement::LINEAR;
camera_placement.target_frame = "map";
ros::NodeHandle node_handle("~");
ros::Publisher cp_publisher =
node_handle.advertise<view_controller_msgs::CameraPlacement>(
"/rviz/camera_placement", 10, true);
class C {
public:
class Key {
friend std::shared_ptr<C> make_c();
Key() {}
};
C(const Key &);
//...
};
#!/bin/bash
# Define source, target, maxdepth and cd to source
source="/tmp/source"
target="/tmp/target"
depth=1
cd "${source}"
# Set the maximum number of concurrent rsync threads
maxthreads=30
@simonlynen
simonlynen / mex_C++_maci64.xml.patch
Created October 20, 2014 16:29
clang omp osx mex
--- /Users/slynen/Desktop/mex_C++_maci64.xml 2014-10-20 15:45:15.000000000 +0200
+++ /Users/slynen/Desktop/mex_C++_maci64_patched.xml 2014-10-20 18:27:14.000000000 +0200
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config
- Name="Xcode Clang++"
- ShortName="Clang++"
+ Name="Clang-OMP"
+ ShortName="Clang-OMP"
Manufacturer="Apple"
@simonlynen
simonlynen / clang_omp_osx.sh
Last active April 7, 2017 07:59
clang omp osx
# Stolen and altered from here: http://stackoverflow.com/questions/20321988/error-enabling-openmp-ld-library-not-found-for-lgomp-and-clang-errors/21789869#21789869
INTEL_OPENMP_LATEST_BUILD_LINK=https://www.openmprtl.org/sites/default/files/libomp_20140926_oss.tgz
CLANG_INCLUDE=~/clang_omp/llvm/include
CLANG_BIN=~/clang_omp/llvm/build/Release/bin
CLANG_LIB=~/clang_omp/llvm/build/Release/lib
OPENMP_INCLUDE=~/clang_omp/libomp_oss/exports/common/include
OPENMP_LIB=~/clang_omp/libomp_oss/exports/mac_32e/lib.thin
cd ~/