Skip to content

Instantly share code, notes, and snippets.

View bryanhunter's full-sized avatar

Bryan Hunter bryanhunter

View GitHub Profile
@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]).
@bryanhunter
bryanhunter / build-erlang-17.0.sh
Last active October 6, 2024 03:47
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 / ndc-oslo-2014.md
Last active April 10, 2016 11:40
NDC Oslo 2014 - FP Cheat Sheet

#The Functional Programmers Cheat Sheet for NDC Oslo 2014

This year NDC Oslo has a full three-day functional programming track with an amazing lineup. If you agree that the future of programming is FP, use this as your "auto pilot" guide on what sessions to attend.

Cheer for sessions on Twitter using the #ndcoslo and #fptrack hashtags.

[The full agenda (including non-fp sessions) is here].

@bryanhunter
bryanhunter / .emacs
Created June 7, 2014 18:50
Emacs setup for Erlang developement
;; Where is Erlang on this machine?
(if (not (boundp 'erlang-root-dir))
(cond
((or (eq system-type 'windows-nt)(eq system-type 'ms-dos))
(setq erlang-root-dir "C:/bin/erlang/erl5.9")) ;; Windows
((eq system-type 'darwin)
(setq erlang-root-dir "/usr/local/lib/erlang")) ;; Mac
((eq system-type 'gnu/linux)
(setq erlang-root-dir "/usr/local/lib/erlang")) ;; Linux
)
@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
# Copyright 2012 Erlware, LLC. All Rights Reserved.
#
# This file is provided to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
## Functional Track talks from NDC London 2014
### Wednesday 2014-12-3
* [F-Words - Functional Programming Terms With More Than Four Letters - Calvin Bottoms](http://www.ndcvideos.com/#/app/video/2191)
* [Reactive Game Development For The Discerning Hipster - Bodil Stokke](http://www.ndcvideos.com/#/app/video/2221)
* [Erlang Patterns Matching Business Needs -- Torben Hoffman](http://www.ndcvideos.com/#/app/video/2211)
* [Equivalence Classes, xUnit.net, FsCheck, Property-Based Testing -- Mark Seemann](http://www.ndcvideos.com/#/app/video/2291)
* [Functional programming design patterns -- Scott Wlaschin](http://www.ndcvideos.com/#/app/video/2311)
* [Write Your Own Compiler in 24 Hours -- Phillip Trelford](http://www.ndcvideos.com/#/app/video/2281)
@bryanhunter
bryanhunter / Handy.exs
Created January 11, 2015 15:29
Growing bag of handy short functions and one-liners in Elixir
# Show all Pids on local node with at least one message queued in its mailbox
Process.list |> Enum.filter(&(Process.info(&1)[:message_queue_len] >0))
@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 / HelloPhoenix.fsx
Created December 14, 2016 19:01
F# script that connects to Phoenix channels
// This sample shows connecting to a sample Phoenix chat application running locally.
// The sample Phoenix app was written by Chris McCord and can be found here:
// https://github.com/chrismccord/phoenix_chat_example)
// #r @".\packages\WebSocketSharp.1.0.3-rc11\lib\websocket-sharp.dll"
open WebSocketSharp
let ws = new WebSocket("ws://localhost:4000/socket/websocket")
ws.OnOpen.Add(fun args -> System.Console.WriteLine("Open"))