Skip to content

Instantly share code, notes, and snippets.

View DavidAntaramian's full-sized avatar

David Antaramian DavidAntaramian

View GitHub Profile
@DavidAntaramian
DavidAntaramian / exunit_assert_order.exs
Last active February 10, 2017 00:35
ExUnit Test for whether one element appears before another in a list
defmodule ExUnitAssertOrder do
def assert_order(list, first, second) do
assert_order(list, first, second, nil)
end
def assert_order([], first, second, first) do
raise ExUnit.AssertionError, message: "Encountered #{first}, but never encountered #{second}"
end
def assert_order([], first, second, second) do
** (CompileError) lib/ex_aws/operation/rest_json.ex:36: cannot define module ExAws.Operation.ExAws.Operation.JSON because it is currently being defined in lib/ex_aws/operation/json.ex:38
@DavidAntaramian
DavidAntaramian / 01_timber_install.config
Last active September 6, 2017 03:06
Elasticbeanstalk extension providing Timber Agent 0.3.x with automatic key setting
###
#
# Installation configuration script for Timber.io's log collection agent
#
# * Docs: https://timber.io/docs/platforms/aws-elastic-beanstalk
# * Support: [email protected]
#
# To use this file:
#
# 1. Set the environment variable "TIMBER_API_KEY" using `eb setenv`
rm -r ~/.asdf
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
cd ~/.asdf
git checkout v0.3.0
cd ~/
source .bash_profile
asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
# This should be at in /var/logrotate.d/timber-agent.conf
/var/log/timber-agent.log {
missingok
notifempty
size 100K
rotate 2
postrotate
service timber-agent restart
endscript
[Unit]
Description=timber
After=network-online.target
Requires=network-online.target
[Service]
User=odin
Group=odin
WorkingDirectory=/opt/app
ExecStart=/opt/app/bin/timber foreground
@DavidAntaramian
DavidAntaramian / endpoint.ex
Created July 6, 2018 16:44
Using Ecto & Phoenix init/2 Callbacks
defmodule MyApp.Endpoint do
use Phoenix.Endpoint, otp_app: :my_app
# ... a bunch of plugs
def init(_, config) do
port = System.get_env("PORT")
http_config =
config
@DavidAntaramian
DavidAntaramian / benchee_output.txt
Last active July 16, 2018 22:36
Testing the use of inspect/1 with a function yielding an integer
Operating System: macOS"
CPU Information: Intel(R) Core(TM) i7-3840QM CPU @ 2.80GHz
Number of Available Cores: 8
Available memory: 16 GB
Elixir 1.6.4
Erlang 20.3.4
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
defmodule LoadTester do
@table_name :http_results
@url "https://example.com"
def test() do
tab =
:ets.new(table_name, [
:set,
:named_table,
:public,
hexdump -n 12 -e '1/4 "%08x" 1 "\n"' /dev/random