Skip to content

Instantly share code, notes, and snippets.

View mkurdej's full-sized avatar

Marek Kurdej mkurdej

View GitHub Profile
// Having type T checks whether it is an instance of template U<V>.
// http://coliru.stacked-crooked.com/a/b5bcde32c99c7cab
#include <vector>
#include <type_traits>
template<class T, template<typename...> class U, class V = void>
struct is_instance_of : std::false_type
{};
@bblanchon
bblanchon / Azure_CaptureVm.ps1
Created September 2, 2015 15:03
Azure: Capture a VM
$ErrorActionPreference = "Stop"
Add-AzureAccount
Select-AzureSubscription -Name "Continuous Integration"
Write-Host 'The following VM instances are available:'
Get-AzureVM | foreach { $_.Name }
$vmName = Read-Host 'Enter the name of the VM to capture'
Write-Host 'The following VM images are available:'
@bblanchon
bblanchon / Azure_RemoveAllVms.ps1
Created September 2, 2015 10:07
Azure: delete all VMs of a subscription
Add-AzureAccount
Select-AzureSubscription -SubscriptionName "Continuous Integration"
Get-AzureVM | Remove-AzureVM -DeleteVHD -Verbose
@bblanchon
bblanchon / checksums.sh
Last active September 18, 2015 15:19
Compute checksums of files in each folder recursivlty
find $(pwd) -type d | while read DIR
do
cd $DIR
FILES=$(find -maxdepth 1 -type f -not -name '*SUMS' -printf '"%f"\n' | sort)
FILE_COUNT=$(echo $FILES | wc -c)
if [ -z "$FILES" ]
then
rm -f *SUMS
else
echo $FILES | xargs md5sum > MD5SUMS
@kwk
kwk / Makefile
Last active March 17, 2024 22:54
Compiling with Address Sanitizer (ASAN) with CLANG and with GCC-4.8
.PHONY: using-gcc using-gcc-static using-clang
using-gcc:
g++-4.8 -o main-gcc -lasan -O -g -fsanitize=address -fno-omit-frame-pointer main.cpp && \
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer) ./main-gcc
using-gcc-static:
g++-4.8 -o main-gcc-static -static-libstdc++ -static-libasan -O -g -fsanitize=address -fno-omit-frame-pointer main.cpp && \
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer) ./main-gcc-static
@jhorneman
jhorneman / timestamp_osx.cpp
Created June 29, 2014 12:41
Adaption of Edouard Alligand's portable high-resolution timestamp in C++ for OS X
// main.cpp
// timestamp_test
// Created by Jurie Horneman on 29/06/14.
#include <assert.h>
#include <iostream>
// Adapted from "A portable high-resolution timestamp in C++" by Edouard Alligand
// https://blogea.bureau14.fr/index.php/2014/06/a-portable-high-resolution-timestamp-in-c/
@lichray
lichray / make_array.cc
Last active August 29, 2023 16:37
Factory function of std::array
#include <array>
#include <functional>
template <typename... T>
using common_type_t = typename std::common_type<T...>::type;
template <typename T>
using remove_cv_t = typename std::remove_cv<T>::type;
template <bool, typename T, typename... U>
@dabrahams
dabrahams / lambda-overload.cpp
Created September 25, 2012 00:50
Demonstration of Mathias Gaunard's overloaded function object technique. See also https://gist.github.com/3779508
// Copyright Dave Abrahams 2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
template<class...Fs> struct overloaded;
template<class F1, class...Fs>
struct overloaded<F1, Fs...> : F1, overloaded<Fs...>::type
{
typedef overloaded type;
@rocarvaj
rocarvaj / .vimrc
Created April 27, 2012 21:28
Minimal .vimrc for C/C++ developers
" VIM Configuration File
" Description: Optimized for C/C++ development, but useful also for other things.
" Author: Gerhard Gappmeier
"
" set UTF-8 encoding
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
" disable vi compatibility (emulation of old bugs)
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//