Skip to content

Instantly share code, notes, and snippets.

View ericmj's full-sized avatar

Eric Meadows-Jönsson ericmj

View GitHub Profile
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

Flaws in unquote fragments

A couple weeks ago, we have pushed support to unquote fragments:

Enum.each [a: 1, b: 2], fn { k, v } ->
  def map(unquote(k)), do: unquote(v)
end

Although it provide a nice way to dynamically define functions, after discussing with developers and extending Elixir to rely more on it, some flaws became aparent.

defp escape({ left, meta, right }) do
{ '{}', meta, [escape(left), meta, escape(right)] }
end
defp escape({ left, right }) do
{ escape(left), escape(right) }
end
defp escape(list) when is_list(list) do
Enum.map(list, escape(&1))
iex> """ |> Erlang.module_to_core |> IO.puts
...> -file("nofile", 1).
...> -module('Elixir.M').
...>
...> -export([hello/0]).
...>
...> hello() -> hello.
...> """
module 'Elixir.M' ['hello'/0,
'module_info'/0,
@essen
essen / http_specs.md
Last active January 10, 2022 02:01
HTTP and related specifications
@BanzaiMan
BanzaiMan / .travis.yml
Created September 25, 2015 15:44
Matrix trick for Elixir 1.2 & 1.x
language: elixir
elixir:
- 1.0.5
otp_release: 17.3
matrix:
include:
- elixir: 1.2
@koudelka
koudelka / lookup.ex
Created October 2, 2015 21:13
Elixir Set Lookup
defmodule Lookup do
@wordfile "words.txt"
@external_resource @wordfile
@times 1_000_000
@words @wordfile |> File.stream! |> Enum.map(&String.strip/1)
@hash_set Enum.into(@words, HashSet.new)
@map_set Enum.into(@words, MapSet.new)
defmodule ReleaseManager.Plugin.ReleaseTasks do
@name "release_tasks"
@shortdoc "Generates an escript to invoke PS.ReleaseTasks"
use ReleaseManager.Plugin
alias ReleaseManager.Utils
def before_release(_), do: nil
def after_release(%Config{name: name}) do
@josevalim
josevalim / watcher.sh
Last active May 22, 2024 10:06
A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance
# You will need fswatch installed (available in homebrew and friends)
# The command below will run tests and wait until fswatch writes something.
# The --stale flag will only run stale entries, it requires Elixir v1.3.
fswatch lib/ test/ | mix test --stale --listen-on-stdin
Originally from: http://erlang.org/pipermail/erlang-questions/2017-August/093170.html
For a safe and fast Erlang SSL server, there's a few
configuration values you might want by default:
[{ciphers, CipherList}, % see below
{honor_cipher_order, true}, % pick the server-defined order of ciphers
{secure_renegotiate, true}, % prevent renegotiation hijacks
{client_renegotiation, false}, % prevent clients DoSing w/ renegs
{versions, ['tlsv1.2', 'tlsv1.1']}, % add tlsv1 if you must