Skip to content

Instantly share code, notes, and snippets.

@bryanhunter
bryanhunter / oo-banana.md
Created February 10, 2012 04:05
Joe Armstrong on reusability in software (OO-vs-functional)

I think the lack of reusability comes in object-oriented languages, not functional languages. Because the problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.

If you have referentially transparent code, if you have pure functions-- all the data comes in its input arguments and everything goes out and leaves no state behind-- it's incredibly reusable. You can just reuse it here, there, and everywhere.

-Joe Armstrong, Designer and implementer of the Erlang programming language

@bryanhunter
bryanhunter / virdings-rule.md
Created October 26, 2012 19:28
Virding's First Rule of Programming

Any sufficiently complicated concurrent program in another language contains an ad hoc informally-specified bug-ridden slow implementation of half of Erlang.

@bryanhunter
bryanhunter / build-erlang-17.0.sh
Last active May 22, 2022 12:02
Build Erlang 17.0 on a fresh Ubuntu box (tested on 12.04 and 14.04)
#!/bin/bash
# Pull this file down, make it executable and run it with sudo
# wget https://gist.githubusercontent.com/bryanhunter/10380945/raw/build-erlang-17.0.sh
# chmod u+x build-erlang-17.0.sh
# sudo ./build-erlang-17.0.sh
if [ $(id -u) != "0" ]; then
echo "You must be the superuser to run this script" >&2
exit 1
fi
@bryanhunter
bryanhunter / bumper.exs
Created January 20, 2015 21:18
Example of Elixir and the bit-syntax to read a Bitmap image
defmodule Bumper do
@doc ~S"""
Reads a Bitmap (24-bit) and displays width, height, and the RGB of each pixel
"""
def show(filename) do
{:ok, bindata} = File.read(filename)
<< "BM",
_::size(64),
offset_to_pixels::size(32)-little,
@bryanhunter
bryanhunter / MonokaiSW.md
Last active October 15, 2021 08:12
Mapping colors of the Monokai color scheme to their nearest Sherwin-Williams paint color
@bryanhunter
bryanhunter / build-erlang.sh
Last active October 5, 2021 14:27
This script will install dependencies and then build and install erlang using kerl on Ubuntu
#!/bin/bash
# This script will install dependencies then build and install erlang using kerl
# Pull this file down, make it executable and run it with sudo
#
# wget https://gist.githubusercontent.com/bryanhunter/adbd9c8d9fb2f6366eee/raw/build-erlang.sh
# chmod u+x build-erlang.sh
# sudo ./build-erlang.sh
#
# Version: 17.1
@bryanhunter
bryanhunter / build-erlang-r16b.sh
Created April 30, 2013 09:26
Build Erlang R16B on Ubuntu
#!/bin/bash
# Pull this file down, make it executable and run it with sudo
# wget https://raw.github.com/gist/5487621/build-erlang-r16b.sh
# chmod u+x build-erlang-r16b.sh
# sudo ./build-erlang-r16b.sh
if [ $(id -u) != "0" ]; then
echo "You must be the superuser to run this script" >&2
exit 1
fi
@bryanhunter
bryanhunter / keybindings.json
Created April 20, 2018 20:43
VS Code User Settings
// Mac ~/Library/Application Support/Code/User/keybindings.json
[
{
"key": "alt+enter",
"command": "workbench.action.terminal.runSelectedText"
},
{
"key": "cmd+h",
"command": "editor.action.startFindReplaceAction"
},
@bryanhunter
bryanhunter / ColorNameTest.exs
Last active March 31, 2018 18:41
An example of property-based testing in Elixir 1.6
# Until StreamData ships in Elixir it needs to be added as a dependency.
# https://hexdocs.pm/stream_data/StreamData.html#content
# https://hex.pm/packages/stream_data
# Add this to your mix.exs deps...
# {:stream_data, "~> 0.4.2"}
defmodule ColorNameTest do
use ExUnit.Case, async: true
use ExUnitProperties
@bryanhunter
bryanhunter / mike_check.erl
Created February 11, 2014 19:10
Simple program to test the performance of a concurrent language.
-module(mike_check).
% The performance of a concurrent language is predicated by three things:
% 1) the context switching time,
% 2) The message passing time,
% 3) and the time to create a process.”
% - Mike Williams
-export([start_and_time/1,start/1, do_it_all/2]).