Skip to content

Instantly share code, notes, and snippets.

View abergmeier's full-sized avatar

Andreas Bergmeier abergmeier

View GitHub Profile
@abergmeier
abergmeier / gist:6778064
Last active September 27, 2020 08:46
Initial for hiding implementation.
#pragma once
#include <type_traits>
#include <cstddef>
#include <cassert>
#include <memory>
namespace ab {
template< typename T, std::size_t Bytes >
struct fits_in_storage : public std::integral_constant<bool, sizeof(typename std::aligned_storage<Bytes, 1>::type) >= sizeof(typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type)>
@abergmeier
abergmeier / future
Created February 3, 2014 12:35
N3784+
namespace std {
template< class T >
class continuator;
template< class T >
class shared_continuator;
template< class Type >
continuator async_cast(std::future<Type> fut) noexcept;
@abergmeier
abergmeier / gist:9135888
Last active August 29, 2015 13:56
Extended equality operator for std::optional.
// TODO: Probably necessary to wrap U in decay.
template< class T, class U >
constexpr typename std::enable_if<!std::is_base_of<std::optional<T>, std::optional<U>>::value, bool>::type
operator==( const std::optional<T>& opt, U&& value ) {
return opt == static_cast<const U&>( value );
}
template< class T, class U >
constexpr typename std::enable_if<!std::is_base_of<std::optional<T>, std::optional<U>>::value, bool>::type
@abergmeier
abergmeier / gist:9488990
Created March 11, 2014 16:08
pkgconfig for use with distutils.setup
def pkgconfig(*packages, **kw):
flag_map = {
'-I': 'include_dirs',
'-L': 'library_dirs',
'-l': 'libraries'}
env = os.environ.copy()
# possible narrowing of PkgConfig environment variables
for token in check_output(['pkg-config', '--libs', '--cflags', ' '.join(packages)], env=env).split():
@abergmeier
abergmeier / gist:9913924
Created April 1, 2014 13:24
Build performance

i7: Building idtech4.5: real 3m10.353s user 19m45.920s sys 0m45.130s

## Bootstrapping
set VISUAL_STUDIO_VER=14
set CMAKE_GENERATOR="Visual Studio %VISUAL_STUDIO_VER% 2015 Win64"
set MSBUILD_VERSION=%VISUAL_STUDIO_VER%.0
rem Find msbuild path
for /f "usebackq skip=2 tokens=3*" %%A in (`reg.exe query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\%MSBUILD_VERSION%" /v "MSBuildToolsPath" `) do (
#!/bin/env sh
buildifier
RETVAL=$?
if [ $RETVAL -ne 0 ]
then
exit 1
fi
@abergmeier
abergmeier / Travis CI local install
Last active September 2, 2017 19:32 — forked from jarun/Travis CI local install
How to install Travis CI locally on Ubuntu 16.04.3
sudo apt-get install -y ruby ruby-dev build-essential dh-autoreconf
sudo gem install travis
# install path: /var/lib/gems/
MATCH (n)
DETACH DELETE n
CREATE(InstOpNop:Instruction{name: "OpNop",value: 0})
CREATE(InstOpUndef:Instruction{name: "OpUndef",value: 1})
CREATE(InstOpSizeOf:Instruction{name: "OpSizeOf",value: 321})
CREATE(InstOpSourceContinued:Instruction{name: "OpSourceContinued",value: 2})
CREATE(InstOpSource:Instruction{name: "OpSource",value: 3})
CREATE(InstOpSourceExtension:Instruction{name: "OpSourceExtension",value: 4})
CREATE(InstOpName:Instruction{name: "OpName",value: 5})
CREATE(InstOpMemberName:Instruction{name: "OpMemberName",value: 6})
# Executing dmesg | grep DAL after driver installation gives enabled
# The following output after AMD Pro installation and reboot
# Reboot then leads to the usual kernel panicks. Can only boot with acpi=off.
# Following output when setting acpi=off
~$ dmesg | grep DAL # Gives no output
~$ uname -a
Linux racker 4.10.0-33-generic #37~16.04.1-Ubuntu SMP Fri Aug 11 14:07:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux