Skip to content

Instantly share code, notes, and snippets.

View devhawk's full-sized avatar

Harry Pierson devhawk

View GitHub Profile
{
"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 / create-gist.ps1
Created October 4, 2018 23:18
create-gist.ps1
[CmdletBinding()]
Param(
[Parameter(ValueFromPipelineByPropertyName)] $FullName,
[string] $description,
[switch] $public,
[switch] $launchBrowser
)
begin
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))
@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.
@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 })>>
{
# 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 / python_locator.ps1
Last active February 26, 2019 21:10
Powershell utilities for locating Python installations from Windows registry
function Get-DefaultPython {
$pythonVersions = (get-item HKCU:\Software\Python\PythonCore).GetSubKeyNames()
$pythons = $pythonVersions | %{Get-ItemProperty "hkcu:\Software\Python\PythonCore\$_"}
# favor most recent version of Python and x64 version of Python over x86 version
$x64Pythons = $pythons | ?{$_.SysArchitecture.StartsWith("64")} | Sort-Object -Property SysVersion -Descending
if ($x64Pythons.Length -gt 0)
{
using System;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
// https://stackoverflow.com/a/21848564
public class ConsoleAppManager
{
private readonly string appName;
function Get-PythonVersions {
(get-item HKCU:\Software\Python\PythonCore).GetSubKeyNames()
}
function Get-DefaultPython {
$pythons = Get-PythonVersions | ForEach-Object{Get-ItemProperty "hkcu:\Software\Python\PythonCore\$_"}
$x64Pythons = $pythons | Where-Object{$_.SysArchitecture.StartsWith("64")} | Sort-Object -Property SysVersion -Descending
void write_snake_case(writer& w, std::string_view const& name, bool uppercase)
{
auto case_func = [uppercase](char c)
{
return uppercase
? static_cast<char>(::toupper(c))
: static_cast<char>(::tolower(c));
};