Skip to content

Instantly share code, notes, and snippets.

View kbenzie's full-sized avatar

Kenneth Benzie (Benie) kbenzie

View GitHub Profile
@kbenzie
kbenzie / Uninstall.cmake
Last active November 1, 2019 14:57
CMake Uninstall Module
# Uninstall.cmake adds an uninstall target to remove previously installed files,
# it had been adapted from the CMake FAQ at the link.
# https://gitlab.kitware.com/cmake/community/wikis/FAQ#can-i-do-make-uninstall-with-cmake
#
# Copy Uninstall.cmake to a directory on the CMAKE_MODULE_PATH, then include the
# module using: include(Uninstall)
message(STATUS "Uninstall target enabled")
file(WRITE ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake "\
@kbenzie
kbenzie / fresh.vim
Created March 9, 2016 19:17
Airline Theme
" fresh palette
let g:airline#themes#fresh#palette = {}
" NORMAL mode
let s:N1 = ['#005f00', '#afdf00', 22, 148, '']
let s:N2 = ['#ffffff', '#444444', 255, 238, '']
let s:N3 = ['#ffffff', '#121212', 15, 233, 'bold']
let s:W = ['#000000', '#8700df', 232, 92, '']
let s:E = ['#000000', '#990000', 232, 160]
let g:airline#themes#fresh#palette.normal =
@kbenzie
kbenzie / ReleaseAssert.cmake
Last active October 7, 2015 15:47
Add ReleaseAssert build type to CMake
if(UNIX)
string(REPLACE "-DNDEBUG" ""
CMAKE_C_FLAGS_RELEASEASSERT ${CMAKE_C_FLAGS_RELEASE})
string(REPLACE "-DNDEBUG" ""
CMAKE_CXX_FLAGS_RELEASEASSERT ${CMAKE_CXX_FLAGS_RELEASE})
elseif(WIN32)
string(REPLACE "/D NDEBUG" ""
CMAKE_C_FLAGS_RELEASEASSERT ${CMAKE_C_FLAGS_RELEASE})
string(REPLACE "/D NDEBUG" ""
CMAKE_CXX_FLAGS_RELEASEASSERT ${CMAKE_CXX_FLAGS_RELEASE})
@kbenzie
kbenzie / doxygen-errors.py
Last active October 27, 2017 13:43
Treat doxygen warnings as errors and concisely display warnings/errors.
#!/usr/bin/python
from __future__ import print_function
def main():
from argparse import ArgumentParser
from platform import system
from subprocess import Popen, PIPE
from sys import stderr
@kbenzie
kbenzie / c.vim
Created November 27, 2014 19:04
NOTE highlighting in vim for C/C++
"" Add NOTE comment highlighting to C/C++ files
" Place this file in ~/.vim/after/c.vim
" This syntax matchesku the word NOTE
syn keyword cNote contained NOTE
" This add the cNote syntax keyword to the cCommentGroup cluster, so it only
" shows up in comments
syn cluster cCommentGroup contains=cTodo,cNote,cBadContinuation
" This links the syntax matcher to the highlight group Note
hi def link cNote Note
@kbenzie
kbenzie / .ycm_extra_conf.py
Last active July 26, 2017 09:55
YouCompleteMe extra configuration file
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
@kbenzie
kbenzie / clang-format-sublime.py
Last active August 29, 2015 14:01
Modified SublimeText clang-format plugin
# This file is a minimal clang-format sublime-integration. To install:
# - Change 'binary' if clang-format is not on the path (see below).
# - Put this file into your sublime Packages directory, e.g. on Linux:
# ~/.config/sublime-text-2/Packages/User/clang-format-sublime.py
# - Add a key binding:
# { "keys": ["ctrl+shift+c"], "command": "clang_format" },
#
# With this integration you can press the bound key and clang-format will
# format the current lines and selections for all cursor positions. The lines
# or regions are extended to the next bigger syntactic entities.
@kbenzie
kbenzie / operator_of_the_day.cpp
Last active August 29, 2015 13:56
Operator of the day!
#include <stdio.h>
void takes_int_reference(int &i) { i = 42; }
// Trivial wrapper example, a more appropriate use would be to wrap a resource
// which requires R.A.I.I. for safe usage.
class int_wrapper {
private:
int i;
public:
@kbenzie
kbenzie / snippet.sublime-snippet
Created December 14, 2013 19:25
Sublime Text snippet to create a snippet
<snippet>
<description>Sublime Snippet</description>
<content><![CDATA[<snippet>
<description>$1</description>
<content><![CDATA[${TM_FILENAME/(.+)\..+|.*/$1/:name}$2]$NOT_DEFINED]></content>
<tabTrigger>${TM_FILENAME/(.+)\..+|.*/$1/:name}</tabTrigger>
<scope>$0</scope>
</snippet>]]></content>
<tabTrigger>snippet</tabTrigger>
<!-- <scope>$0</scope> -->
#include <iostream>
#include <cassert>
unsigned operator"" _b(const char *str)
{
unsigned ret = 0;
for(size_t i = 0; i < str[i] != '\0'; ++i) {
char digit = str[i];
assert(digit == '0' || digit == '1' && "Binary literal's only support 0 or 1");
ret = ret * 2 + (digit - '0');