Skip to content

Instantly share code, notes, and snippets.

.0000000000000000000000000000000000000-0
-.------------------------------------/-
00.00+++++++++++++++++++++++++++++++++0+
+00.00++++++++++++++++++++++++++++++++0+
+000.00+++++++++++++++++++++++++++++++0+
+0+00.00++++++++++++++++++++++++++++++0+
+0++00.00+++++++++++++++++++++++++++++0+
+0+++00.00++++++++++++++++++++++++++++0+
+0++++00.00+++++++++++++++++++++++++++0+
+0+++++00.00++++++++++++++++++++++++++0+
/*
JavaScript Promise puzzle
What will be printed, and what will the exit code be?
*/
const main = async () => {
process.on('unhandledRejection', error => {
console.log('UNHANDLED');
process.exit(2);
});
@rolfwr
rolfwr / MineSweeper1D.py
Last active September 21, 2020 01:31
Calculate likelihood of winning a 2D Minesweeper board using optimal strategy
#! /bin/python
# -*- coding: utf-8 -*-
import sys
import re
#
# The likelihood of winning a 1xn Minesweeper game with two mines
# ===============================================================
#
# An optimal strategy for playing the 1xn Minesweeper game with 2 mines is
# deterministic, meaning that for a given initial board state the strategy will
@rolfwr
rolfwr / project-ref-package-ref-issue.cmd
Created July 18, 2018 21:34
Reproduction recipe for Visual Studio bug: CS0246 errors but builds just fine.
rem -- Start of file project-ref-package-ref-issue.cmd
rem -- Run this cmd script to reproduce error.
del /q /s reprod
mkdir reprod
mkdir reprod\TargetLib
dotnet new classlib -o reprod\TargetLib
dotnet add reprod\TargetLib package Microsoft.NET.Sdk.Functions
mkdir reprod\ConsumerLib
dotnet new classlib -o reprod\ConsumerLib
@rolfwr
rolfwr / HelloWorldCSharp-annotated.sh
Last active August 29, 2015 14:09
Hello world in C# compiled to .NET IL, and then compiled down to a stand-alone portable Bourne shell
#! /bin/sh
LC_CTYPE=C; export LC_CTYPE
charat() { if test -z $BASH; then r=$(expr substr $1 $(($2 + 1)) 1); else r=${1:$2:1}; fi }
p=0
h=0
i=0
while true; do
case $i in
0)
@rolfwr
rolfwr / HelloWorldBf.sh
Created November 15, 2014 22:10
A hello world program written in BrainFuck, run by a BrainFuck interpreter written in C#, compiled to IL and AOT compiled down to a portable Bourne shell script.
#! /bin/sh
LC_CTYPE=C; export LC_CTYPE
charat() { if test -z $BASH; then r=$(expr substr $1 $(($2 + 1)) 1); else r=${1:$2:1}; fi }
p=0
h=0
i=0
while true; do
case $i in
0)
eval "s${p}=\"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.\""