Skip to content

Instantly share code, notes, and snippets.

outro56 / pimpl.hpp
Last active Sep 15, 2020
Compilation firewalls: pimpl + fast_pimpl
View pimpl.hpp
#include <memory>
#include <cstddef>
// See also:
// - put all private nonvirtual members (data + functions) into T impl
// - when using an impl in a class, all constructors (default/copy/move) and
outro56 / dockerx.zsh
Created Aug 25, 2020
run docker contains with default arguments
View dockerx.zsh
dockerx() {
if [ "$#" -eq "0" ]; then
echo "Usage: dockerx IMAGE [OPTIONS]"
return 1
# remove invalid characters from the container name
name=`echo "$img" | tr /:?\ @ _`
View make_vector.hpp
#include "make_vector_details.hpp"
namespace cmuoh {
template <typename T = void, typename... Args,
typename V = detail::vec_type_helper_t<T, Args...>,
typename std::enable_if<
View is_assignable.hpp
template<typename T, typename U>
using assign_expression = decltype(std::declval<T&>() = std::declval<U&>());
template<typename T, typename U>
constexpr bool is_assignable = is_detected<assign_expression, T, U>;
outro56 / version1.lua
Last active Aug 3, 2018 — forked from randrews/hoc4.lua
Toy calculator in Lua, version 4 -
View version1.lua
function eval(num1, operator, num2)
if operator == '+' then
return num1 + num2
elseif operator == '-' then
return num1 - num2
elseif operator == '*' then
return num1 * num2
elseif operator == '/' then
return num1 / num2
View overload.example.hpp
#include "overload.hpp"
#include <iostream>
#include <string>
#include <variant>
int main() {
using namespace cmuoh;
std::variant<int, float, std::string> intFloatString { "Hello" };
std::visit(overload {
outro56 / call-graph.awk
Created Jun 21, 2018
Parse lua code and print call graph
View call-graph.awk
#!/usr/bin/awk -f
# call_graph.awk
# Usage:
# ./call_graph.awk my_program.lua | dot -Tpng > call_graph.png
# This is a script that generates a visual call graph for a Lua file.
# This script only shows calls made to functions defined within the
# input Lua file; that is, it excludes calls such as standard library
View git
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
git config --global "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
View function-clone.lua
local function clone_function(fn)
local dumped = string.dump(fn)
local cloned = loadstring(dumped)
local i = 1
while true do
local name = debug.getupvalue(fn, i)
if not name then
debug.upvaluejoin(cloned, i, fn, i)
View gist:3c111f72dd26c27ced47862c86e3cf65
stop all containers:
docker kill $(docker ps -q)
remove all containers
docker rm $(docker ps -a -q)
remove all docker images
docker rmi $(docker images -q)