Skip to content

Instantly share code, notes, and snippets.

View nicholasjhenry's full-sized avatar

Nicholas Henry nicholasjhenry

View GitHub Profile
@nicholasjhenry
nicholasjhenry / type_playground.ex
Created November 11, 2018 18:13
Type Playground
defmodule TypePlayground do
defmodule Maybe do
@type t(term) :: {:just, term} | :nothing
end
defmodule Result do
@type t(term) :: {:ok, term} | {:error, atom}
end
defmodule ApiAction do
@nicholasjhenry
nicholasjhenry / elixir_forum.md
Last active October 6, 2018 13:42
Sponsor Spotlight: CivilCode Inc

Please tell us a little bit about your company

Nestled on the border of the Plateau and Mile-end in Montreal, Canada, CivilCode Inc develops tailored business applications. Nicholas Henry (@nicholasjhenry) and Hugo Frappier (@frahugo) founded the company in early 2016 to develop applications exclusively with Elixir. Before CivilCode, Nicholas and Hugo were both freelance Ruby/Rails developers.

We organize the Montreal Elixir Meetup to help grow the local community and sponsor this forum. We feel lucky that we get to use this language every day and by contributing in these ways, we hope others have the opportunity too.

How did you discover Elixir?

Nicholas discovered Elixir watching José Valim on PeepCode's Meet Elixir published in 2013. He initially fell in love with the pattern matching constructs, the appreciation for OTP came after. Two years later, over a bowl of ramen, Nicholas discussed the language with Hugo and the idea of sta

@nicholasjhenry
nicholasjhenry / keybase.md
Created July 11, 2018 13:34
Keybase. Again.

Keybase proof

I hereby claim:

  • I am nicholasjhenry on github.
  • I am nicholasjhenry (https://keybase.io/nicholasjhenry) on keybase.
  • I have a public key ASDsJIpuc8EXEHnE4g-kQyKfiola8K4ZPZZmGe06Exe4hQo

To claim this, I am signing this object:

@nicholasjhenry
nicholasjhenry / keybase.md
Created July 11, 2018 13:34
Keybase. Again.

Keybase proof

I hereby claim:

  • I am nicholasjhenry on github.
  • I am nicholasjhenry (https://keybase.io/nicholasjhenry) on keybase.
  • I have a public key ASDsJIpuc8EXEHnE4g-kQyKfiola8K4ZPZZmGe06Exe4hQo

To claim this, I am signing this object:

@nicholasjhenry
nicholasjhenry / presentation.md
Last active June 19, 2018 20:05
Pull Request Reviews

Pull Request Reviews

  1. Can I understand this?
  2. Does this meet the requirements?
  3. Are there any potential issues?

PDF with presenter notes


@nicholasjhenry
nicholasjhenry / 2017-10-21-how-to-connect-and-debug-elixir-or-phoenix-app-at-heroku.md
Created October 22, 2017 12:23
How to connect and debug Elixir or Phoenix App at Heroku?

How to connect and debug Elixir or Phoenix App at Heroku?

Heroku has a great feature called heroku ps:exec which allows you to connect to running nodes. You can use this command to connect your elixir nodes easily. And debug your nodes like in your network.

Step 1

Let's start with Procfile To run a named app at heroku your procfile should specify the app name like:

web: MIX_ENV=prod elixir --sname coolelixirapp -S mix run --no-halt
@nicholasjhenry
nicholasjhenry / run.sh
Created August 24, 2017 19:20 — forked from djo/run.sh
Handling of UNIX-signals in Erlang/Elixir is not supported, this script provides start-stop management with handling TERM signal for Docker installation.
#!/usr/bin/env bash
set -x
term_handler() {
echo "Stopping the server process with PID $PID"
erl -noshell -name "term@127.0.0.1" -eval "rpc:call('app@127.0.0.1', init, stop, [])" -s init stop
echo "Stopped"
}
trap 'term_handler' TERM INT
@nicholasjhenry
nicholasjhenry / arc.md
Last active July 24, 2017 14:22
Arc Callstack
Arc.Ecto.Schema.cast_attachments 
	-> Arc.Ecto.Type.cast
		-> definition.store (Arc.Actions.Store)
			-> File.new (in the `var` dir)
			-> put (Arc.Storage.S3)
@nicholasjhenry
nicholasjhenry / simple_macro.ex
Created April 19, 2017 16:58
Simple Macro with `do` keyword
defmodule Foo do
defmacro hello(do: func) do
IO.puts "Hello"
func
end
end
defmodule Bar do
require Foo
@nicholasjhenry
nicholasjhenry / subquery.ex
Created April 8, 2017 20:45
Awesome Ecto Examples
defmodule MyApp.Projects.Project.Policy do
alias MyApp.System
import Ecto.Query, only: [from: 2]
def scope(%{role: "admin"}, _action, query), do: query
def scope(user, _action, query), do: projects_for_user(query, user)
defp projects_for_user(query, user) do
user_projects =
from project in query,