Skip to content

Instantly share code, notes, and snippets.

View aaronlelevier's full-sized avatar

Aaron Lelevier aaronlelevier

View GitHub Profile
@aaronlelevier
aaronlelevier / RTOP.tla
Last active January 23, 2022 19:56
My 2nd TLA+ Spec. RTOP stands for R-to-P and is a spec that shows a mapping of many-to-many P to R and the inverse
-------------------------------- MODULE RTOP --------------------------------
CONSTANT P, R
VARIABLE ptor, rtop
vars == <<ptor, rtop>>
TypeOK == /\ ptor \in [P -> SUBSET R]
/\ rtop \in [R -> SUBSET P]
@aaronlelevier
aaronlelevier / practice_lists.erl
Created September 27, 2020 21:38
Practice with Lists in Erlang
%%%-------------------------------------------------------------------
%%% @author Aaron Lelevier
%%% @doc Practice with Lists in Erlang. It's been about a week since coding up some Erlang
%%% These functions are all in the [lists](http://erlang.org/doc/man/lists.html) module
%%% @end
%%% Created : 27. Sep 2020 2:26 PM
%%%-------------------------------------------------------------------
-module(practice).
-author("Aaron Lelevier").
-vsn(1.0).
@aaronlelevier
aaronlelevier / applicative.py
Created October 23, 2019 19:18
Python Applicative Pattern - apply a container of functions to a container of values
def add1(x):
return x+1
def double(x):
return x+x
def square(x):
return x*x
funs = [add1, double, square]
@aaronlelevier
aaronlelevier / jupyter-notebook-quickstart.sh
Last active September 11, 2019 22:07
Bash commands to set up a local dev environment for Jupyter Notebook
mkdir juptyer-practice
cd juptyer-practice
echo "create virtualenv step"
python3 -m venv venv
echo "activate virtualenv"
source venv/bin/activate
echo "install dependencies"
@aaronlelevier
aaronlelevier / intellij-keymaps.xml
Created September 11, 2019 14:17
Key bindings for Intellij - Mac OS X 10.5+ specifid
<keymap version="1" name="Mac OS X 10.5+ copy" parent="Mac OS X 10.5+">
<action id="ChangesView.Diff" />
<action id="ChangesView.GroupBy.Directory" />
<action id="CompareTwoFiles" />
<action id="Diff.ShowDiff" />
<action id="EditorDuplicate" />
<action id="FileChooser.GotoDesktop" />
<action id="FileChooser.TogglePathShowing" />
<action id="FileStructurePopup">
<keyboard-shortcut first-keystroke="meta f12" />
@aaronlelevier
aaronlelevier / iam-protocols.md
Created September 11, 2019 14:11
Ideas for IAM automation protocols

Define a protocol for an IAM request, example

{
  request_type: assume-role,
  roles: [],
  assume_roles: []
}
@aaronlelevier
aaronlelevier / codejam.py
Created July 4, 2019 02:59
Python Codejam
Python 2.7.16 (v2.7.16:413a49145e, Mar 2 2019, 14:32:10)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> # let's do this the same way. It has to be command line. If it were in Jupyter notebook, then that just wouldn't be fair. Right?!
...
>>> d = {'foo': 1, 'bar': 2}
>>> # what are they keys
...
>>> d.keys()
['foo', 'bar']
@aaronlelevier
aaronlelevier / codejam.erl
Created July 4, 2019 02:58
Erlang Codejam
Erlang/OTP 20 [erts-9.2.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Eshell V9.2.1 (abort with ^G)
1> bob.
bob
2> % ok let's go.
2> ab.
ab
3> bob.
bob
@aaronlelevier
aaronlelevier / complete_a_task.erl
Created June 16, 2019 01:24
Erlange code for solving the question, "How long is it going to take me to read 'Programming Erlang 2nd Edition'."
-module(complete_a_task).
-author("Aaron Lelevier").
-export([
%% prod
completion_date/2,
add_days/2,
total_weeks_to_complete/1,
total_days_to_complete/1,
work_days_to_complete/1,
@aaronlelevier
aaronlelevier / coco_checker.py
Last active June 1, 2019 22:41
Prod and test code example of unit testing in Python from: https://github.com/aaronlelevier/mlearning
# coco_checker.py
from pathlib import Path
class LabeledData:
@classmethod
def images_numbered_sequentially(cls, filepath):
"""
Returns a tuple (bool, list)