Skip to content

Instantly share code, notes, and snippets.

@randomphrase
randomphrase / monitor.cpp
Last active November 22, 2019 17:07
Price type experimentation
#define BOOST_TEST_MODULE sides
#include <boost/test/unit_test.hpp>
#include <boost/test/tools/output_test_stream.hpp>
#include <thread>
#include <chrono>
namespace btt = boost::test_tools;
namespace demo {
#define BOOST_TEST_MODULE collinear
#include <boost/test/unit_test.hpp>
#include <boost/range/algorithm/generate.hpp>
#include <set>
#include <cmath>
struct Point {
int x;
int y;
};
@randomphrase
randomphrase / xmlgen.sh
Created April 29, 2015 18:36
Example how bash function input/output can be used to compose
#!/bin/bash
# Creates an XML element from the first parameter. Remaining parameters and all stdin are copied to stdout.
function elem() {
local name=$1
echo -n "<$name>"
shift
echo -n $*
[[ ! -t 0 ]] && cat
echo "</$name>"

Keybase proof

I hereby claim:

  • I am randomphrase on github.
  • I am randomphrase (https://keybase.io/randomphrase) on keybase.
  • I have a public key whose fingerprint is 64E4 B67C D2B7 EEC4 63C9 AA74 F63A 9AD9 E44B 21C7

To claim this, I am signing this object:

// -*- mode: c++; c-basic-offset: 4 -*-
#include <boost/timer.hpp>
#include <algorithm>
#include <random>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <stdexcept>
const unsigned WARMUP = 5;
@randomphrase
randomphrase / cmdoptions.cpp
Last active February 17, 2023 05:51
Demonstration of how to do subcommand option processing with boost program_options
#define BOOST_TEST_MODULE subcommand options
#include <boost/test/unit_test.hpp>
#include <boost/program_options.hpp>
#include <boost/variant/variant.hpp>
#include <boost/variant/get.hpp>
struct GenericOptions {
bool debug_;
};
@randomphrase
randomphrase / semantic-browse-c++-doc.el
Last active August 29, 2015 13:56
semantic-browse-c++-doc
(defun c++-type-at (point)
"Use semantic to determine the fully namespace-qualified type of the symbol at POINT."
(interactive "d")
(let* ((ctxt (semantic-analyze-current-context point))
(pf (reverse (oref ctxt prefix)))
(lastname (pop pf))
(tag (if (semantic-tag-p lastname) lastname (car pf)))
(names (append
(when (semantic-tag-p tag)
(save-excursion
@randomphrase
randomphrase / gist:7744453
Created December 2, 2013 03:16
Cask build error for org-plus-contrib (see https://github.com/cask/cask/issues/119)
alastair@lulu ~/.emacs.d ±master⚡ » cask
Contacting host: orgmode.org:80
Saving file /Users/alastair/.emacs.d/.cask/24.3.1/elpa/archives/org/archive-contents...
Wrote /Users/alastair/.emacs.d/.cask/24.3.1/elpa/archives/org/archive-contents
Contacting host: marmalade-repo.org:80
Saving file /Users/alastair/.emacs.d/.cask/24.3.1/elpa/archives/marmalade/archive-contents...
Wrote /Users/alastair/.emacs.d/.cask/24.3.1/elpa/archives/marmalade/archive-contents
Contacting host: melpa.milkbox.net:80
Saving file /Users/alastair/.emacs.d/.cask/24.3.1/elpa/archives/melpa/archive-contents...
Wrote /Users/alastair/.emacs.d/.cask/24.3.1/elpa/archives/melpa/archive-contents
@randomphrase
randomphrase / 99bob.cpp
Created August 7, 2011 11:33
99 Bottles Of Beer, using Boost MPL
#include <boost/mpl/assert.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/back_inserter.hpp>
#include <boost/mpl/copy.hpp>
#include <boost/mpl/divides.hpp>
#include <boost/mpl/empty_sequence.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/for_each.hpp>