Skip to content

Instantly share code, notes, and snippets.

@oliverlee
oliverlee / github-context.json
Created June 8, 2024 01:46 — forked from colbyfayock/github-context.json
Sample payload for Github Action `github` context
{
"token": "[token]",
"job": "notifySlack",
"ref": "refs/pull/4/merge",
"sha": "[shad]",
"repository": "colbyfayock/demo-github-actions",
"repository_owner": "colbyfayock",
"repositoryUrl": "git://github.com/colbyfayock/demo-github-actions.git",
"run_id": 120667610,
"run_number": "2",
@oliverlee
oliverlee / git-pr-update.sh
Last active June 26, 2024 19:13
Push commit to Github and open/update a PR
#!/usr/bin/env bash
set -euo pipefail
KEY="Change-Id: "
SOURCE_REMOTE=origin
TARGET_USER=$(git remote get-url "$SOURCE_REMOTE" | sed 's/^.*\.com[:/]\(.*\)\/.*$/\1/')
TARGET_REMOTE="${TARGET_REMOTE:-origin}"
if git rev-parse --verify main >/dev/null 2>&1; then
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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>