Skip to content

Instantly share code, notes, and snippets.

View hickscorp's full-sized avatar
🎯
Focusing

Pierre Martin hickscorp

🎯
Focusing
View GitHub Profile
// See the updated gist at https://gist.github.com/hickscorp/08b0c945e7d3a5879a6b7924c6a44628
// Make sure you install the ANSIEscape package if you want color support.
//
// Just drop this file in your elixir project root folder, and rename it to
// match it, eg `whatever.sublime-project`.
// Then open sublime like so: `subl whatever.sublime-project`
// The build command will become available by pressing `Ctrl+Shift+B`.
//
// It's also recommended to install those two packages:
// - Elixir for syntax coloring: https://packagecontrol.io/packages/Elixir
defmodule GraphqlHelpers do
import Ecto.Query
@doc """
## example
field :storages, list_of(:storage), do: has_many(:storages)
"""
defmacro has_many(model) do
quote do
resolve fn subject, _, _ ->
@prio
prio / server.ex
Created January 6, 2014 22:16
Elixir gen_server example
defmodule Tcprpc.Server do
use GenServer.Behaviour
defrecord State, port: nil, lsock: nil, request_count: 0
def start_link(port) do
:gen_server.start_link({ :local, :tcprcp }, __MODULE__, port, [])
end
def start_link() do