A collection of reusable bash code.
- log: logging library
A collection of reusable bash code.
#! /usr/bin/env bash | |
set -e -u -o pipefail | |
# set options | |
COLLECTION_ID='317099' # Unsplash Editorial (aka Picture of the Day) | |
# set constants | |
IMG_RESOLUTION=$(xrandr --current | grep '\*' | awk '{print $1}' | sort | tail -n 1) | |
IMG_REMOTE_URI="https://source.unsplash.com/collection/${COLLECTION_ID}/${IMG_RESOLUTION}" |
// ==UserScript== | |
// @name Set C++ standard on cppreference.com | |
// @match https://en.cppreference.com/w/cpp/* | |
// @icon https://en.cppreference.com/favicon.ico | |
// ==/UserScript== | |
const DESIRED_CPP_STANDARD = "C++20"; | |
function changeCppStandard(elem) { | |
// find option labeled with DESIRED_CPP_STANDARD |
#!/bin/bash | |
pkgs=$(./list_purgable.py) | |
for pkg in $pkgs; do | |
echo "$(tput setaf 6)purging $pkg$(tput sgr0)" | |
sudo apt purge "$pkg" || sudo apt-mark manual "$pkg" | |
done |
set(flags "-flto") | |
set(c_flags "") | |
set(cxx_flags "-stdlib=libc++") | |
set(link_flags "-fuse-ld=lld") | |
set(CMAKE_C_COMPILER clang) | |
set(CMAKE_CXX_COMPILER clang++) | |
set(CMAKE_C_FLAGS_INIT "${c_flags} ${flags}") | |
set(CMAKE_CXX_FLAGS_INIT "${cxx_flags} ${flags}") | |
set(CMAKE_EXE_LINKER_FLAGS_INIT "${link_flags}") |
BasedOnStyle: WebKit | |
Language: Cpp | |
Standard: Cpp11 | |
UseTab: Never | |
ColumnLimit: 120 | |
AlignEscapedNewlines: Left | |
NamespaceIndentation: All |
#include <stdint.h> | |
#include <stdio.h> | |
void print_int(const int64_t v) { | |
const bool neg = v < 0; | |
uint64_t pv = neg ? -v : v; | |
// convert into digit characters | |
static const size_t DIGITS_LENGTH = 19; | |
char digits[DIGITS_LENGTH]; |
TODO: Add introduction paragraph.
#include "utf8.hpp" | |
namespace { | |
template<class T> | |
struct range { | |
T low, high; | |
constexpr bool is_in(T value) const { | |
return low <= value && value <= high; | |
} |
#pragma once | |
#include <type_traits> | |
// ======== enum_cast | |
template <class E> | |
constexpr std::enable_if_t<std::is_enum<E>::value, std::underlying_type_t<E>> enum_cast(E e) noexcept | |
{ | |
return static_cast<std::underlying_type_t<E>>(e); |