Skip to content

Instantly share code, notes, and snippets.

View fertapric's full-sized avatar

Fernando Tapia Rico fertapric

  • Amsterdam, Netherlands
View GitHub Profile
defmodule Params do
@moduledoc """
A set of functions for working with parameters.
Parameters are maps that impose restrictions on the key type:
* all the keys must be atoms or strings.
* all the keys must be of the same type.
Otherwise, all the functions of this module will raise `Params.MixedKeysError`.
@fertapric
fertapric / init.coffee
Last active September 13, 2023 13:23
Automatically updated by http://atom.io/packages/sync-settings
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@fertapric
fertapric / migration.exs
Last active September 15, 2017 13:53
Shortcut for creating a trgm index (`pg_tgrm`).
defmodule Core.Repo.Migration do
@moduledoc """
Migrations are used to modify your database schema over time.
This module provides many helpers for migrating the database, along with the ones provided
by `Ecto.Migration`.
"""
defmacro __using__(_) do
quote do
@fertapric
fertapric / .iex.exs
Last active February 9, 2018 23:28
Prompt Mix env on IEX (with colors)
env_colors = %{"prod" => ANSI.red(), "dev" => ANSI.green(), "test" => ANSI.green()}
env = System.get_env("MIX_ENV") || "dev"
colored_env = Map.get(env_colors, env, ANSI.yellow()) <> env <> ANSI.reset()
IEx.configure(
default_prompt: "%prefix(#{colored_env},%counter)>",
alive_prompt: "%prefix(#{colored_env},%node,%counter)>"
)
@fertapric
fertapric / README.md
Last active January 12, 2018 17:08
Notes: enumerate all annotations in the current directory (TODO, FIXME, OPTIMIZE, HACK, REVIEW and README) (git compatible)

Usage

Help instructions:

$ notes --help
Enumerate all annotations: TODO, FIXME, OPTIMIZE, HACK, REVIEW, README

    * Use TODO to note missing features or functionality that should
      be added at a later date.
@fertapric
fertapric / mix.exs
Last active June 1, 2017 14:47
Handy alias to run an Elixir escript without building it. Quite useful for development.
defmodule MyAwesomeProject.Mixfile do
use Mix.Project
def project do
[app: :my_awesome_project,
version: "0.1.0",
elixir: "~> 1.3",
escript: escript(),
deps: deps(),
aliases: aliases()]
@fertapric
fertapric / ecs-run
Last active December 10, 2018 05:00
Script to run a Docker container with the same configuration as the ECS service: environment variables and Docker image. It uses ecs-env: https://gist.github.com/fertapric/4ae3a1209e7118c275821ce35512daec
$ ecs-run
Run a Docker container with the same configuration as an ECS service.
It uses the same image and environment variables of the ECS task definition.
Supported AWS CLI environment variables:
- AWS_ACCESS_KEY_ID: AWS access key.
- AWS_SECRET_ACCESS_KEY: AWS secret key.
- AWS_SESSION_TOKEN: session token.
- AWS_DEFAULT_REGION: AWS region.
@fertapric
fertapric / ecs-env.sh
Last active January 2, 2021 21:20
Script to extract environment variables from a ECS service
#!/bin/sh
print_help() {
echo "Extract environment variables from an ECS service."
echo
echo "Usage: $0 [OPTIONS] SERVICE"
echo
echo "Options:"
echo " -h, --help Print usage"
}
@fertapric
fertapric / poor_mans_test_suite_in_bash
Last active January 25, 2017 17:12
Poor man's test suite in Bash
#!/bin/bash
function setup {
[ -z "$FILES_HOST"] && FILES_HOST=localhost
}
function teardown {
echo "REMOVE ALL THE FILES FROM BUCKET"
}