Skip to content

Instantly share code, notes, and snippets.

@oliverlee
oliverlee / .vimrc
Created October 21, 2019 08:00
vimrc
" setup for Vundle
set nocompatible
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'rust-lang/rust.vim'
Plugin 'cespare/vim-toml'
@oliverlee
oliverlee / map.cc
Created May 2, 2020 16:43
Compile-time type map
#include <type_traits>
#include <tuple>
#include <utility>
// Expand type_traits to check is a type is a template specialization
template <template <class...> class Template, class T >
struct is_specialization_of : std::false_type {};
template <template <class...> class Template, class... Args >
struct is_specialization_of<Template, Template<Args...>> : std::true_type {};
@oliverlee
oliverlee / state_variant.cc
Last active May 10, 2020 20:22
Compile-time creation of transitions
#include <type_traits>
#include <utility>
#include <iostream>
#include <memory>
#include <string>
#include <algorithm>
#include <stdexcept>
#include <limits>
@oliverlee
oliverlee / connection.h
Created July 4, 2020 10:06
asio composed op
#pragma once
#include "async/future.hpp"
#include "compat/asio.h"
#include "message.h"
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
@oliverlee
oliverlee / user.bazelrc
Created July 15, 2020 11:55
Create bazel symlinks in our dir
build --symlink_prefix='out/'
build --experimental_no_product_name_out_symlink
@oliverlee
oliverlee / main.cc
Created December 5, 2020 19:12
array backed streambuf
#include <array>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <new>
#include <sstream>
#include <vector>
namespace {
@oliverlee
oliverlee / transform.cc
Created December 16, 2020 23:30
invoke callable with exploded tuple
template <class...>
using void_t = void;
template <class Transform, class Arg, class = void>
struct transform_takes_one_arg : std::false_type {};
template <class Transform, class Arg>
struct transform_takes_one_arg<Transform,
Arg,
void_t<decltype(std::declval<Transform>()(std::declval<Arg>()))>>
@oliverlee
oliverlee / woodblock.py
Created December 17, 2020 17:27
Determine rough estimates for material requirements
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Determine rough estimates for material requirements."""
from dataclasses import dataclass
from sympy import Symbol
@dataclass
class Body:
width: Symbol
@oliverlee
oliverlee / tree_search.cc
Last active June 5, 2021 13:00
compile-time tree search
#include <type_traits>
/// @brief Determines of a type is a specialization of a template
/// @see wg21.link/p2098
///@{
template <class T, template <class...> class Primary>
struct is_specialization_of : std::false_type {};
template <template <class...> class Primary, class... Args>
struct is_specialization_of<Primary<Args...>, Primary> : std::true_type {};
@oliverlee
oliverlee / color-test.sh
Created December 22, 2022 04:27 — forked from onaforeignshore/color-test.sh
Prints out the colors for 256-color terminal, as well as testing truecolor
#!/usr/bin/env bash
echo ""
echo -e " \033[38;5;231m System colors:\033[m"
for r in {0..2}; do
for i in {0..15}; do
if [[ "$r" == "1" ]]; then
if [[ $i -gt 1 && $i -ne 4 ]]; then printf "\033[38;5;16m"; fi
printf "\033[48;5;${i}m %03d \033[m " $i
else