Skip to content

Instantly share code, notes, and snippets.

@mlund
mlund / randone.cpp
Last active December 11, 2015 01:29
Random float in range [0:1[ using C++11's Mersenne Twister as well as a non-deterministic seed.
#include <random>
#include <iostream>
template<typename T, typename Tengine=std::mt19937>
class RandOne {
std::uniform_real_distribution<T> dist_;
Tengine eng_;
public:
/* constructor w. non-deterministic seed */
RandOne() : dist_(0,1) {
std::random_device rd;
@mlund
mlund / agr2pdf.sh
Created January 12, 2013 09:53
Simplistic shell script to convert xmgrace (.agr files) figures to PDF. White borders will be removed in the conversion process using `pdfcrop`
#!/bin/bash
tmpfile=".tmp.pdf"
if [ $# -ge 1 ]; then
if [ $1 != "-h" ]; then
outfile=`dirname $1`/`basename "$1" \.agr`.pdf
LANG=en xmgrace -hardcopy -hdevice PDF $1 -printfile $tmpfile
pdfcrop $tmpfile $outfile
rm -f $tmpfile
exit
fi