Skip to content

Instantly share code, notes, and snippets.

View duncanatt's full-sized avatar

Duncan Paul Attard duncanatt

View GitHub Profile
@duncanatt
duncanatt / vim_cheat_sheet.md
Last active January 22, 2024 10:39
Vim cheat sheet
@duncanatt
duncanatt / gen_looper.erl
Last active September 19, 2019 12:10
Describes how to use the `gen`, `sys` and `proc_lib` Erlang libraries to create a generic behavior that follows closely the ones implemented in OTP. Still work in progress.
%%%-------------------------------------------------------------------
%%% @author Duncan Paul Attard
%%% @copyright (C) 2019 Duncan Paul Attard
%%% @version 0.9
%%%
%%% @doc Generic looper behavior.
%%%
%%% @end
%%% Created: 18. Sep 2019
%%%
@duncanatt
duncanatt / Brewfile
Last active March 28, 2018 13:24
Brew bundle
tap 'caskroom/cask'
tap 'caskroom/fonts'
# Install utility software.
brew 'git'
brew 'wget'
cask 'dropbox'
cask 'virtualbox'
cask 'virtualbox-extension-pack'
cask 'google-chrome'
@duncanatt
duncanatt / ass_wk2_conc.erl
Created April 24, 2017 15:30
Concurrent Programming in Erlang - Week 1 Assignment
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency_sup).
-export([start/0,allocate/0,deallocate/1,stop/0,client/3,start_client/1]).
@duncanatt
duncanatt / ass_wk1_conc.erl
Created April 20, 2017 09:44
Concurrent Programming in Erlang - Week 1 Assignment
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency2).
-export([start/0,allocate/0,deallocate/1,stop/0,clear/0]).
@duncanatt
duncanatt / ass_wk2.erl
Last active March 2, 2017 19:32
Functional Programming in Erlang - Week 2 Assignment
-module(ass_wk2).
-export([get_file_contents/1,show_file_contents/1]).
-export ([reverse/1, join/2]).
-export ([de_capitalize/1, tokenize/1]).
-export ([process_lines/1, tag_tokens/2, index/1, index_word/2, index_words/1, compress_index/1]).
% Used to read a file into a list of lines.
% Example files available in:
% gettysburg-address.txt (short)
% dickens-christmas.txt (long)
@duncanatt
duncanatt / ass_wk1.erl
Last active May 11, 2020 03:08
Functional Programming in Erlang - Week 1 Assignment
-module (ass_wk1).
-export ([area/1, perimeter/1, enclose/1, bits/1, bits_tail/1]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Question 1 - Shapes. %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% I'm assuming three shapes: circles, rectangles and squares.
%% Perimeter of circle is calulated using the standard formula 2 * Pi * R.
@duncanatt
duncanatt / eunit_example.erl
Created February 9, 2017 14:35
Erlang EUnit Test Format
% Include EUnit.
-include_lib("eunit/include/eunit.hrl").
%% Tests the mHML compiler.
mHml_test_() -> {foreachx,
fun(StartupDataPassedFromEachUnitTest) ->
% Setup computaiton. Return value is passed as a parameter to each
% unit test.
end,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.