Skip to content

Instantly share code, notes, and snippets.

View elieux's full-sized avatar

David Macek elieux

View GitHub Profile
@rkitover
rkitover / load-visual-studio-environment.sh
Last active May 9, 2024 20:08
Load Visual Studio environment in MSYS2.
# Visual Studio Environemnt Loader
#
# For MSYS2/Cygwin/etc..
#
# Set the following in your ~/.bashrc:
#
# ENVIRONMENT CONFIGURATION:
#
# To enable static linking where possible:
#
@grosscol
grosscol / get-cognito-cfd-target.yaml
Last active October 5, 2022 06:47
Custom Cloudformation Resource to get CloudFront Distribution of Cognito User Pool
---
#
# This template example assumes a UserPool and UserPoolDomain exist.
# The function of this is to produce a custom resource with an attribute
# that can be referenced for DNSName of an Route53::RecordSet AliasTarget.
#
# AliasTarget:
# HostedZone: Z2FDTNDATAQYW2
# DNSNAME: !GetAtt UPDomain.CloudFrontDistribution
@elieux
elieux / finddef.php
Created April 2, 2017 16:32
Find preprocessor guards in a C/C++ file
<?php
namespace finddef;
set_error_handler(function($errno, $errstr, $errfile, $errline, $errcontext) { echo "Execution error: {$errstr} on line {$errline} of {$errfile}" . PHP_EOL; exit; });
function make_check_ident($ident) {
$ident = preg_quote($ident, '~');
return function($no, $text) use($ident) { return 1 === preg_match("~\b{$ident}\b~", $text); };
}
@elieux
elieux / midipix.sh
Created June 15, 2016 19:18
Alternative Midipix startup script
#!/bin/sh
prepend_path() {
local _pname _pname_prepend="${1}" IFS=":"
for _pname in ${PATH}; do
if [ "${_pname}" = "${_pname_prepend}" ]; then
return
fi
done
export PATH="${_pname_prepend}${PATH:+:${PATH}}"
@elieux
elieux / msys2-here-uninstall.reg
Created November 23, 2015 08:32
MSYS2 here context menu items
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\MSYS here]
[-HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\MINGW64 here]
[-HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\MINGW32 here]
@elieux
elieux / Unserializer.php
Last active April 2, 2017 14:40
PHP Unserializer
<?php
/*
* Custom PHP unserializer with better error reporting
*
* Does not support objects.
*/
class Unserializer {
private $serialized;
private $len;
@elieux
elieux / msys2-gen-pkg-spreadsheet.sh
Created May 6, 2015 11:08
MSYS2 package spreadsheet generation script
#!/usr/bin/bash
scrape_db() {
local var=$1
local file=$2
local url=$3
[ "$DB_UPDATE" != 'no' ] && wget -nv -O /tmp/$file $url >&2
while read pkg ver; do
@elieux
elieux / msys2-mirror.sh
Last active April 2, 2017 14:45
MSYS2 pacman repos mirroring script
#!/usr/bin/bash
ROOT="$(pwd)"
dl() {
local cookie="/tmp/pacman-mirror-cookie.txt"
touch "${cookie}"
local file
@elieux
elieux / make.sh
Last active April 2, 2017 14:46
Debugging makefiles
#/usr/bin/sh
#http://www.drdobbs.com/tools/debugging-makefiles/197003338
make --eval='print-%: ; @echo $* is $($*)' --eval='OLD_SHELL := $(SHELL)' --eval='SHELL = $(warning [$@ ($^) ($?)])$(OLD_SHELL) -x'
make V=1 VERBOSE=1
make --dry-run
@elieux
elieux / segfault.c
Created March 7, 2015 14:20
Instant crash
typedef int(*fn)();
int main() {
return ((fn)0)();
}