Skip to content

Instantly share code, notes, and snippets.

View devhawk's full-sized avatar

Harry Pierson devhawk

View GitHub Profile
# lifted from coreclr
function(add_precompiled_header header cppFile targetSources)
if(MSVC)
set(precompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/stdafx.pch")
set_source_files_properties(${cppFile}
PROPERTIES COMPILE_FLAGS "/Yc\"${header}\" /Fp\"${precompiledBinary}\""
OBJECT_OUTPUTS "${precompiledBinary}")
set_source_files_properties(${${targetSources}}
PROPERTIES COMPILE_FLAGS "/Yu\"${header}\" /Fp\"${precompiledBinary}\""
@devhawk
devhawk / empty_instance.h
Created January 31, 2019 18:35
C++ Helper function to get nullptr constructed instance if nullptr ctor is available, default constructed instance if nullptr ctor is not available
template <typename T, typename = std::void_t<>>
struct empty_instance
{
static T get() { return T{}; }
};
template <typename T>
struct empty_instance<T, std::void_t<decltype(T{ nullptr })>>
{
@echo off
SETLOCAL
rem https://stackoverflow.com/a/45070967
goto :init
:header
echo %__NAME% v%__VERSION%
echo This is a sample batch file template,
echo providing command-line arguments and flags.
def timed_op(fun):
def sync_wrapper(*args, **kwds):
print("Starting", fun.__name__)
start = time.perf_counter()
ret = fun(*args, **kwds)
end = time.perf_counter()
print(fun.__name__, "took", end - start, "({0})".format(ret))
@devhawk
devhawk / create-gist.ps1
Created October 4, 2018 23:18
create-gist.ps1
[CmdletBinding()]
Param(
[Parameter(ValueFromPipelineByPropertyName)] $FullName,
[string] $description,
[switch] $public,
[switch] $launchBrowser
)
begin
{
"version": "2.7.8",
"url": "https://github.com/IronLanguages/ironpython2/releases/download/ipy-2.7.8/IronPython.2.7.8.zip",
"bin": [
"net45\\ipy.exe",
"net45\\ipy32.exe",
"net45\\ipyc.exe",
"net45\\ipyw.exe",
"net45\\ipyw32.exe"
]
@devhawk
devhawk / msvc_pch.cmake
Last active October 25, 2018 22:21
cmake function to configure MSVC precompiled header support
function(TARGET_CONFIG_MSVC_PCH target pch_cpp pch_header)
set(pch_output_file "\"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pch\"")
get_target_property(sources ${target} SOURCES)
foreach(file ${sources})
if (${file} STREQUAL ${pch_cpp})
set_source_files_properties(${file}
PROPERTIES
COMPILE_FLAGS " /Yc${pch_header} /Fp${pch_output_file}"
@devhawk
devhawk / install-dotnet.sh
Last active May 11, 2018 19:02
installing dotnet on WSL Debian
# enhancement to https://www.microsoft.com/net/learn/get-started/linux/debian9
# debian WSL appears to need --no-check-certificate for wget from packages.microsoft.com
wget --no-check-certificate -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget --no-check-certificate -q https://packages.microsoft.com/config/debian/9/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
# need apt-transport-https installed
sudo apt-get update
{
"version": "3.6.5",
"url": "https://github.com/TextAnalysisTool/Releases/raw/master/TextAnalysisTool.NET.zip",
"bin": "TextAnalysisTool.NET.exe"
}
function Set-ConsoleColors {
param ([string]$theme = "campbell")
# Following source adapted from https://github.com/Microsoft/console/tree/master/tools/ColorTool
add-type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
namespace ColorTool
{