Skip to content

Instantly share code, notes, and snippets.

@brimston3
brimston3 / enum_bitwise_overload.cpp
Created April 29, 2016 15:53
In C++ Anything Is Possible. The only limitation is you!
/* Demonstrate operator|() overloading for enum type.
If you want to hide the fact that your enum's numerical encoding is not actually bit flaggable.
Please don't hurt me, I promise you will never see this in production code from me.
~~aed.20160429
Runnable version:
http://coliru.stacked-crooked.com/a/bfedb189f1929447
*/
@brimston3
brimston3 / maxim_1wire_crc8.c
Last active November 22, 2022 12:44
Demonstrate calculation of CRC8/MAXIM aka DOW-CRC
/*
* maxim_1wire_crc8.c
*
* Demonstrate calculation of CRC8/MAXIM aka DOW-CRC in a way compatible with
* Maxim 1-wire (Dallas iButton).
*
* Original portions copyright (C) June 3, 2016, Andrew Domaszek. All rights reserved.
* Except as noted, this work is licensed under the Modified BSD License (BSD-new).
*/
@ECHO OFF
REM -- Automates cygwin installation
SETLOCAL
REM -- Change to the directory of the executing batch file
CD %~dp0
REM -- Configure our paths
SET SITE=http://mirrors.kernel.org/sourceware/cygwin/
@brimston3
brimston3 / hyperref_bookmarks_ex.tex
Created October 3, 2016 16:00
Very simple example generating pdf bookmarks in LaTeX w/ hyperref
\documentclass{article}
\usepackage[bookmarks=true]{hyperref}
\hypersetup{pdfencoding=auto,
pdfauthor={SomeAuthor}
}
\begin{document}
\section{Test 1}
text 1
@brimston3
brimston3 / makefile_guard.mak
Created November 29, 2016 01:51
Makefile env variable declaration guard w/ file existence protection
guard-%: GUARD
@ if [ -z '${${*}}' ]; then echo 'Environment variable $* not set.' && exit 1; fi
.PHONY: GUARD
GUARD:
@brimston3
brimston3 / mk_gocrypt_test_tmp.sh
Last active January 19, 2017 21:45
create ext2 tmp fs for testing gocryptfs w/ non-fallocate backing store.
#!/bin/sh
# run from sudo
mkdir /tmp/gocryptfs-test-parent
truncate --size 500m gocrypt_ext2.lo
losetup /dev/loop0 gocrypt_ext2.lo
mkfs.ext2 /dev/loop0
mount /dev/loop0 /tmp/gocryptfs-test-parent
chown ${SUDO_UID}:${SUDO_GID} /tmp/gocryptfs-test-parent/.
chmod 1777 /tmp/gocryptfs-test-parent/.
@brimston3
brimston3 / BackupVMScript.ps1
Created January 26, 2017 21:25
Backup Hyper-V VM with powershell
#requires -version 3.0
#requires -module Hyper-V
<#
.SYNOPSIS
Export virtual machines
.DESCRIPTION
This utility will export virtual machines to a target destination. By default
it will create a folder using the format:
@brimston3
brimston3 / pcgen.bat
Created January 27, 2017 18:45
using zulu on the desktop overriding global environment variables
set JAVA_HOME=C:\Develop\zulu8.19.0.1-jdk8.0.112-win_x64
set PATH=%JAVA_HOME%\bin;%PATH%
set JDK_HOME=%JAVA_HOME%
set JRE_HOME=%JAVA_HOME%\jre
set CLASSPATH=.;%JDK_HOME%\lib;%JRE_HOME%\lib
set JAVA_TOOL_OPTIONS=-Dfile.encoding="UTF-8"
set javamem="-d64 -Xms256m -Xmx512m"
java %javamem% -jar ./pcgen.jar
@brimston3
brimston3 / FindKeyutils.cmake
Last active February 1, 2017 20:07
CMake FindKeyutils module
# This module defines
# Keyutils_LIBRARIES, the name of the libraries to link against
# Keyutils_FOUND, if false, do not try to link keyutils
# Keyutils_INCLUDE_DIRS, where to find keyutils.h and dependent includes
#
# As keyutils is a Linux interface, paths for other OSes are not defined
#
# Copyright (c) 2017, Andrew Domaszek
#
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
@brimston3
brimston3 / Makefile
Last active February 13, 2017 21:07
cygwin sign unsigned binaries
# Makefile called like so:
#SIGN=YES gmake
RELEASEFILES:=a.exe a.dll
SIGNED_SDIR:=signed_bin
UNSIGNED_SDIR:=unsigned_bin
ODIR:=install
SIGNTOOL:='/cygdrive/c/Program Files (x86)/Windows Kits/8.1/bin/x64/signtool.exe'
# Update with your signtool options:
SIGOPTS:=/tr http://timestamp.digicert.com /td sha256 /fd sha256 /i DigiCert_Test