Skip to content

Instantly share code, notes, and snippets.


Hugo Wang mitnk

View GitHub Profile
m-radzikowski /
Last active March 19, 2023 20:59
Minimal safe Bash script template - see the article with full description:
#!/usr/bin/env bash
set -Eeuo pipefail
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
shakefu / mvim
Last active November 5, 2016 14:02
mvim updated to handle command line options and stdin
View mvim
# This shell script passes all its arguments to the binary inside the
# application bundle. If you make links to this script as view,
# gvim, etc., then it will peek at the name used to call it and set options
# appropriately.
# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This
# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico
# Weber and Bjorn Winckler, Aug 13 2007).
mostlygeek / ch8prob1.erl
Created July 30, 2011 20:39
Programming Erlang 8.11 Problem #1
View ch8prob1.erl
%% Write a function start(AnAtom, Fun) to register
%% AnAtom as spawn(Fun). Make sure your program
%% works correctly in the case when two parallel
%% processes simultaneously evaluate start/2. In
%% this case, you must guarantee that one of
%% these processes succeeds and the other fails.
#!/usr/bin/env python
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
utgarda / ring_benchmark.erl
Created December 8, 2010 16:51
Tutorial problem from "Programming Erlang" by Joe Armstrong , 8.11 Write a ring benchmark. Create N processes in a ring. Send a msage round the ring M times so that a total of N * M messages sent. Time how long this takes for different values of N and M.
View ring_benchmark.erl
new(N, M) ->
spawn(fun() -> spawn_ring(N, M) end).
spawn_ring(N, M) ->
io:format("First process: ~p~n", [self()]),
NextPid = spawn_rest(self(), N),