Skip to content

Instantly share code, notes, and snippets.

Avatar

Max Barraclough MaxBarraclough

View GitHub Profile
View asciimatics_button_bug_demo.py
#!/usr/bin/env python3
## This simple application demonstrates a bug in
## the mouse-click handling for buttons, in asciimatics:
## mouse-clicks on the right side of buttons, fail to register.
## It seems especially evident in buttons with short label strings.
## Dependency:
## pip install asciimatics
@MaxBarraclough
MaxBarraclough / cpp_type_safe_lib_demo.cpp
Last active Nov 15, 2020
Demo of the type_safe C++ library
View cpp_type_safe_lib_demo.cpp
// A small toy program to explore some of what we can do with the
// 'type_safe' library: https://github.com/foonathan/type_safe/
// We will see that we can use it to create distinct new integer types,
// capable of ordinary arithmetic, and *without* implicit conversions.
//
// We will use this to implement Ada-style strong typing, protecting
// against confusing a NumApples_type value with a NumPennies_type value.
//
View boost_strong_typedef_demo.cpp
// A small toy program (in fact it does nothing at all)
// to explore what we can do with BOOST_STRONG_TYPEDEF.
// We will see that it creates a distinct new type, with permissive
// implicit conversions regarding the original type.
//
// BOOST_STRONG_TYPEDEF has its uses, but we will see that we can't use
// BOOST_STRONG_TYPEDEF to implement Ada-style strong typing, such as to protect
// against confusing a NumApples_type value with a NumPennies_type value.
@MaxBarraclough
MaxBarraclough / hello.adb
Created Nov 8, 2020
Print an uninitialized integer in Ada
View hello.adb
-- Prints a nondeterministic integer value
with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
subtype NumFingers is Integer range 0..10;
my_num_fingers : NumFingers; -- := 4;
begin
@MaxBarraclough
MaxBarraclough / amazon_lambda_start_tagged.py
Last active May 10, 2020
Amazon Lambda script: start all appropriately tagged instances
View amazon_lambda_start_tagged.py
## Amazon Lambda script: start all appropriately tagged instances
##
## Runs in Amazon Lambda as Python 2.7 or as Python 3.6.
## Intended to be invoked on a schedule by Amazon Cloud Watch.
## Tag relevant instances with label 'autostart', value 'true'.
## TODO It could be good to add logging to this script
@MaxBarraclough
MaxBarraclough / regexOddness.cs
Last active May 19, 2017
Unexpected different behaviour when using parentheses in C# regex
View regexOddness.cs
System.Text.RegularExpressions.Regex separatorRegex1
= new System.Text.RegularExpressions.Regex("a");
System.Text.RegularExpressions.Regex separatorRegex2
= new System.Text.RegularExpressions.Regex("(a)");
string str = "a";
string[] split1 = separatorRegex1.Split(str); // { "", "" }
string[] split2 = separatorRegex2.Split(str); // { "", "a", "" }
You can’t perform that action at this time.