Skip to content

Instantly share code, notes, and snippets.

#
# This prints an overview of all lines of code inside a Elixir project
# + gives a indication on how much code exists in tests vs production code
SLOC_TOTAL=0
TLOC_TOTAL=0
echo "Umbrella lines of code overview"
for APP in `ls apps/`
do
SLOC=$(find apps/${APP}/lib -type f -name '*.ex*' -print0 | xargs -0 wc -l | tail -n 1 | awk '{print $1}')
@slapers
slapers / mooc.erl
Created May 11, 2020 16:04
week1.15 erlang mooc excercise
-module(mooc).
-export([xOr1/2, xOr2/2, xOr3/2]).
-export([maxThree/3]).
-export([howManyEqual/3]).
-export([test/0]).
xOr1(X, Y) ->
(not X == Y) and (X or Y).
@slapers
slapers / first.erl
Last active May 5, 2020 09:33
erlang-mooc-exercise-1.9
-module(first).
-export([double/1, mult/2, area/3, square/1, treble/1]).
mult(X, Y) ->
X * Y.
double(X) ->
mult(2, X).
defmodule Parser do
@moduledoc """
Sample parser for article on:
http://stefan.lapers.be/posts/elixir-writing-an-expression-parser-with-nimble-parsec/
"""
import NimbleParsec
not_ = string("!") |> label("!")
and_ = string("&&") |> replace(:&&) |> label("&&")
or_ = string("||") |> replace(:||) |> label("||")
@slapers
slapers / workflow_graph.exs
Created November 18, 2017 18:19
Build a direct acyclic graph to run a simple workflow in elixir
defmodule WorkStep do
defstruct [:name, :in, :out, :mod, :fun, :arg]
require Logger
def add_to_graph(%Graph{} = graph, %__MODULE__{} = step) do
graph
|> Graph.add_vertex(step)
|> Graph.add_edges(step |> edges_in)
|> Graph.add_edges(step |> edges_out)
end
Fri Jun 16 12:39:30 UTC 2017
@slapers
slapers / Dockerfile
Created February 22, 2017 17:29
Thumbor docker
FROM python:2
RUN \
echo " ------ UPDATING AND INSTALLING SYSTEM DEPENDENCIES ------" \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
python-numpy \
python-opencv \
git \
@slapers
slapers / UiModal.elm
Created February 1, 2017 08:53
Modal starter, not working/finished yet
module App.UiModal exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
type alias Modal =
{ content : Maybe String
}
@slapers
slapers / clean_docker_images.sh
Created October 20, 2016 09:38
Cleanup docker images (keeps 10 last versions of each image)
#!/bin/bash
IMAGES=$(docker images --format "{{.Repository}}" | sort | uniq)
for IMAGE in ${IMAGES}; do
OLD=$(docker images ${IMAGE} --format "{{.ID}}" | tail -n +10)
docker rmi ${OLD}
done