Skip to content

Instantly share code, notes, and snippets.

@flisboac
flisboac / test-constexpr-elements-set-2.cpp
Last active December 30, 2016 07:54
Note: C++11 has a crappy std::array API for constexpr usage. Why, standard bodies? Why?
// This is a better version (i think), it does not use std::get().
#include <iostream>
#include <array>
template <typename T, T T1, T... Ts>
struct ConstexprSetHelper {
constexpr static size_t size = 1 + sizeof...(Ts);
constexpr static bool contains(T elem) {
return (elem == T1) || ConstexprSetHelper<T, Ts...>::contains(elem);
@flisboac
flisboac / paclist
Created January 6, 2017 17:50
Lists all packages in an Arch Linux system, and separate them into groups (official, non-official, AUR and non-AUR).
#/bin/bash
ALL_PACKAGES=""
NOSYNC_PACKAGES=""
AUR_PACKAGES=""
NON_AUR_PACKAGES=""
OFFICIAL_PACKAGES=""
STATE_RAN=0
@flisboac
flisboac / test-simple-facade-with-sfinae.cpp
Created January 22, 2017 04:27
C++11: Testing a combination of a (possibly constexpr) facade from various adapters to concrete classes. Possible use on concept checking. (saying no to Boost, before someone asks!)
// compiled as in: `g++ -std=c++1y 'test-facade-through-sfinae.cpp' -o 'test-facade-through-sfinae'
#include <iostream>
template <typename T, template <typename TTTs> class... TTs>
struct facade : public TTs<T>... {
facade(T& t): state__(&t) {}
constexpr inline operator T&() { return *state__; }
private:
T* state__;
@flisboac
flisboac / edgy-error.hpp
Created March 13, 2017 02:48
Some refinements of system_error ideas.
// $flisboac 2017-03-01
/**
* @file error.hpp
*/
#pragma once
#ifndef adl__error__hpp__
#define adl__error__hpp__
#include <string>
@flisboac
flisboac / fix-intel_wifi_aer-avell_g1513_fire_v3
Last active February 12, 2023 15:58
Temporary fix for AER's excessive `severity=Corrected` logging for Intel Wireless (Avell G1513 Fire V3) (Arch Linux)
silly gist hack, why do we need you? :(
#include <iostream>
#include <chrono>
#include <type_traits>
using clock_type = std::conditional<
std::chrono::high_resolution_clock::is_steady,
std::chrono::high_resolution_clock,
std::chrono::steady_clock
>::type;
@flisboac
flisboac / xmlrpc-c-config
Created October 19, 2017 23:52
Sample xmlrpc-c-config
#! /bin/sh
#
# This file was generated by a make rule
#
#
#######################################################
# From 'shell_config'
#######################################################
ENABLE_ABYSS_THREADS="yes"
THREAD_LIBS="-lpthread"
See https://stackoverflow.com/questions/38335668/how-to-refer-to-typescript-enum-in-d-ts-file-when-using-amd
Run with `npm run exec`, will install all dependencies as needed.
@flisboac
flisboac / m2-purge
Last active July 25, 2018 17:26
Forcibly deletes/purges individual artifact coordinates from a default-layout M2 repository, without using `mvn` or downloading any dependency tree. (P.S.: Does not work with transitive dependencies! For that, use https://maven.apache.org/plugins/maven-dependency-plugin/purge-local-repository-mojo.html)
#!/bin/sh
main() {
local m2_root; m2_root="~/.m2"
local groupId
local artifactId
local parsing; parsing=0
local path
local exitcode; exitcode=0
local dry_run; dry_run=1
@flisboac
flisboac / ws.sh
Last active September 12, 2018 23:30
#!/bin/sh
readonly wsconfig_env_home="$(cd "$(dirname "$0")" && pwd -P)"
{ WS_DOCKERFILE_CONTENTS="$(cat)"; } <<"_DOCKERFILE_"
FROM ubuntu:bionic
ENV DEBIAN_FRONTEND="teletype"
# Update system and install essential developer tools