Skip to content

Instantly share code, notes, and snippets.

@alexeiz
alexeiz / fonts.conf
Created July 14, 2016 21:28
Font substitutions
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- ~/.config/fontconfig/fonts.conf -->
<fontconfig>
<match target="pattern">
<test qual="any" name="family"><string>Arial</string></test>
<edit name="family" mode="assign" binding="same"><string>Noto Sans</string></edit>
</match>
</fontconfig>
#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <chrono>
#include <boost/thread/barrier.hpp>
using namespace std;
using clock_type = chrono::system_clock;
@alexeiz
alexeiz / docker-toolbox.md
Last active March 25, 2016 03:50
Add an arbitrary mount point to Docker Toolbox containers
  • Add a "Shared Folder" to the default docker VirtualBox virtual machine. There is already a shared folder C:\Users. Add, for example, share host C:\Temp directory as c/Temp.
  • Add the following code to C:\Program Files\Docker Toolbox\start.sh:
init_mounts() {
    ${DOCKER_MACHINE} ssh ${VM} sudo 'mkdir /c/Temp'
    ${DOCKER_MACHINE} ssh ${VM} sudo 'chown docker:staff /c/Temp'
    ${DOCKER_MACHINE} ssh ${VM} sudo 'mount -t vboxsf c/Temp /c/Temp'
}
@alexeiz
alexeiz / sysjitter.md
Created February 26, 2016 19:13
Sysjitter documentation

Sysjitter

The Solarflare sysjitter utility measures the extent to which the system introduces jitter and so impacts on the user‐level process. Sysjitter runs a thread on each processor core and when the thread is de‐scheduled from the core it measures for how long. Sysjitter produces summary statistics for each processor core. The sysjitter utility can be downloaded from www.openonload.org

Sysjitter should be run on a system that is idle. When running on a system with cpusets enabled ‐ run sysjitter as root.

# source into bashrc, zshrc
# ssh-agent management functions for cygwin/msys2
export _SSH_AGENT_LOCK=/tmp/ssh-agent.lock
start_ssh_agent() {
if [ -e $_SSH_AGENT_LOCK ]; then
use_ssh_agent
else
eval `ssh-agent`
@alexeiz
alexeiz / tmux-uptime.sh
Created November 14, 2014 06:22
Show uptime load averages in the tmux status line.
#!/bin/sh
uptime | gawk 'BEGIN{FS="[:,] "}{printf "%s %s %s", $(NF-2), $(NF-1), $NF}'
@alexeiz
alexeiz / timeit.cpp
Created July 17, 2014 14:42
A simple macro to time execution of a block of code.
#include <boost/timer/timer.hpp>
struct timeit_obj
{
template <typename F>
auto operator+(F && func) -> decltype(func()) const
{
boost::timer::auto_cpu_timer t;
return func();
}
@alexeiz
alexeiz / file_notify.cpp
Created February 11, 2014 05:21
Watch for inode changes with <sys/inotify.h>.
#include <boost/exception/all.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/range/iterator.hpp>
#include <exception>
#include <string>
#include <iostream>
#include <array>
#include <tuple>
@alexeiz
alexeiz / multiplex_pipe.cpp
Last active December 26, 2015 01:49
Multiplexing IO from a pipe.
#include <iostream>
#include <fstream>
#include <thread>
#include <stdexcept>
#include <memory>
#include <vector>
#include <cstring>
#include <unistd.h>
#include <fcntl.h>
@alexeiz
alexeiz / result.hpp
Created September 9, 2013 15:41
`result` class is a discriminated union that combines a result of a function call with an exception that a function throws on error that allows to pass the full result of a function execution to code that doesn't allow exceptions.
#ifndef RESULT_H__
#define RESULT_H__
#include <stdexcept>
#include <algorithm>
#include <boost/variant.hpp>
namespace lib
{