Skip to content

Instantly share code, notes, and snippets.

José Valim josevalim

Block or report user

Report or block josevalim

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@josevalim
josevalim / authorize.ex
Last active Apr 29, 2018 — forked from jeremytregunna/authorize.ex
This looks horrible (formatter)
View authorize.ex
defmodule Api.Authorize do
alias Account.Models.User
def board?(board_id, %User{} = user, available_permissions, required_permissions) do
with(
{:ok, board} <- Tracker.Board.find(board_id),
true <- Tracker.OrganizationMembers.user_in_organization?(user.id, board.organization_id),
^required_permissions <-
Enum.to_list(
MapSet.intersection(
View keybase.md

Keybase proof

I hereby claim:

  • I am josevalim on github.
  • I am josevalim (https://keybase.io/josevalim) on keybase.
  • I have a public key whose fingerprint is E140 099F 114F 4B2A 21FE 2E69 E337 0FF7 D467 E599

To claim this, I am signing this object:

@josevalim
josevalim / watcher.sh
Last active Apr 18, 2019
A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance
View watcher.sh
# 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
View comeonin.md
$ git clone git@github.com:elixircnx/comeonin.git
$ cd comeonin/
$ git checkout develop
$ mix deps.get
$ mix test
@josevalim
josevalim / mix app.tree
Last active Jul 20, 2018
Sample output of the new "mix app.tree" and "mix deps.tree" tasks in a Phoenix project (using master). The first command shows the applications you will effectively need at runtime in production while "deps.tree" is your whole dependency tree, including compile time, dev and test dependencies.
View mix app.tree
$ mix app.tree
demo
├── elixir
├── phoenix
│ ├── elixir
│ ├── plug
│ │ ├── elixir
│ │ ├── crypto
│ │ └── logger
│ │ └── elixir
@josevalim
josevalim / phoenix showdown rackspace onmetal io.md
Last active May 16, 2019 — forked from omnibs/phoenix showdown rackspace onmetal io.md
Phoenix Showdown Comparative Benchmarks @ Rackspace
View phoenix showdown rackspace onmetal io.md

Comparative Benchmark Numbers @ Rackspace

I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.

Results

Framework Throughput (req/s) Latency (ms) Consistency (σ ms)
View example.ex
defmodule SomeModule do
def start(host, options) do
# We are assuming SomeSup has been already started somewhere
# (ideally in a supervision tree).
{:ok, child_pid} = SomeSup.attach_to(SomeSup, host, options)
end
end
defmodule SomeSup do
use Supervisor
View foo.erl
%% When compiled with: erlc +bin_opt_info foo.erl
%%
%% It prints:
%%
%% foo.erl:13: Warning: NOT OPTIMIZED: compiler limitation: instruction {get_map_elements,
%% {f,3},
%% {x,1},
%% {list,[{atom,state},{x,6}]}} prevents delayed sub binary optimization
-module(foo).
View elixir_parser.yrl
Nonterminals
grammar expr_list
expr container_expr block_expr access_expr
no_parens_expr no_parens_one_expr no_parens_one_ambig_expr
bracket_expr bracket_at_expr bracket_arg matched_expr unmatched_expr max_expr
op_expr matched_op_expr no_parens_op_expr no_parens_many_expr
comp_op_eol at_op_eol unary_op_eol and_op_eol or_op_eol capture_op_eol
add_op_eol mult_op_eol hat_op_eol two_op_eol pipe_op_eol stab_op_eol
arrow_op_eol match_op_eol when_op_eol in_op_eol in_match_op_eol
type_op_eol rel_op_eol
View erl_lint.erl
%% -*- erlang-indent-level: 4 -*-
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
You can’t perform that action at this time.