Skip to content

Instantly share code, notes, and snippets.

View mitnk's full-sized avatar
🦋
Wandering

Hugo Wang mitnk

🦋
Wandering
View GitHub Profile
@utgarda
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.
-module(ring_benchmark).
-export([new/2]).
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),
#!/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
#
@mostlygeek
mostlygeek / ch8prob1.erl
Created July 30, 2011 20:39
Programming Erlang 8.11 Problem #1
%% 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.
-module(ch8prob1).
-export([start/2]).
@shakefu
shakefu / mvim
Last active November 5, 2016 14:02
mvim updated to handle command line options and stdin
#!/bin/sh
#
# This shell script passes all its arguments to the binary inside the
# MacVim.app 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).
@m-radzikowski
m-radzikowski / script-template.sh
Last active April 8, 2024 03:04
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
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...]
@xorvo
xorvo / elixir-hls-server-demo.livemd
Last active April 11, 2024 17:23
Elixir HLS Server Example

HLS Server Demo - My TV Station

Mix.install([
  {:plug_cowboy, "~> 2.6"}
])