Skip to content

Instantly share code, notes, and snippets.

View hl's full-sized avatar

Henricus Louwhoff hl

View GitHub Profile
@paulo-ferraz-oliveira
paulo-ferraz-oliveira / recon_trace_format.md
Last active July 12, 2023 08:31
Shows an (Elixir) example of tracing HTTPoison's :request and extracting from the call and the return value, using Fred Hebert's recon

Tracing in Elixir with :recon, and formatter

I tend to not remember how this is done, so here goes, for easier copy-paste effect:

:recon_trace.calls(
  {_mod = HTTPoison, _fun = :request, fn ([_, _, _, _, _]) -> :return_trace end},
  _calls = 10,
  [scope: :local,
 formatter: fn (tuple) ->
defmodule Module.Extend do
@doc """
Extend a module (i.e. define `defdelegate` and `defoverridable` for all functions from the source module in the current module.
Usage:
import Module.Extend
extend_module Common.Text
"""
defmacro extend_module(module) do
require Logger
@mcrumm
mcrumm / phx_sqlite_fly_launch.md
Last active November 7, 2024 20:37
Phoenix + SQLite Deployment tips

Deploying to Fly.io with SQLite

Deploying a Phoenix app to Fly.io is a breeze...is what everyone kept telling me. In fairness, I imagine the process would have been breezier had I just used postgres, but all the sqlite and litestream talk has been far too intriguing to ignore. "Wait", you say. "It is just a flat file. How much harder can it be?"

It is easy to make something harder than it should be. It is hard to take something complex and make it truly simple. flyctl launch does an amazing job at providing a simple interface to the utterly complex task of generating deployment resources, especially now that we are living in a containerd (erm, firecracker) world.

This gist is for anyone who, like me, thinks they know better than to read all of the documentation and therefore necessari

@pyrmont
pyrmont / build.yaml
Created May 21, 2020 17:43
A simple GitHub Actions workflow for CI testing with Janet
name: build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@jswny
jswny / Flexible Dockerized Phoenix Deployments.md
Last active August 25, 2024 06:09
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai

@christhekeele
christhekeele / default_behaviour.ex
Last active August 23, 2024 00:11
Behaviours with Defaults for Elixir
defmodule Default.Behaviour do
@moduledoc """
Creates a behaviour that carries its own default implementation.
When used into a behaviour module, when that module in turn is used, all functions
defined on it are given to the using module.
This allows you to have concrete implementations of the behaviour's default functionality
for testing, unlike cramming them all into a __using__ macro.
@chrismccord
chrismccord / upgrade.md
Last active April 7, 2023 12:03
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@jeroenvisser101
jeroenvisser101 / git-finish
Last active December 19, 2018 16:18
Merge a branch using --ff-only, check status checks, and remove branches locally and on remote.
#!/usr/bin/env ruby
def notice(text)
puts "\e[33m#{text}\e[0m"
end
def success(text)
puts "\e[32m#{text}\e[0m"
end
def error(text)