Skip to content

Instantly share code, notes, and snippets.

View edgurgel's full-sized avatar

Eduardo Gurgel edgurgel

View GitHub Profile
@edgurgel
edgurgel / wth.rb
Created March 28, 2014 02:02
WTH 0.0.3 formula
require "formula"
# https://github.com/Homebrew/homebrew/blob/master/Library/Formula/elixir.rb
class ErlangInstalled < Requirement
fatal true
default_formula 'erlang'
env :userpaths
satisfy {
erl = which('erl') and begin
Hey guys,
Now that ListDict is dead, I'm using List API and I find annoying that we need to specify the key position on the tuple (I know this is not a dict) and I think it would be nice to have position as 0 by default.
My proposal is to have a function with less arguments that call the original with 0. We could have position on the end as optional argument, but this would break people's code and maybe harder to read.
keyreplace(list, key, new_tuple) -> keyreplace(list, key, 0, new_tuple)
This would be keyreplace, keystore, keyfind. Also other functions that already have position on the end could be 0 by default.
@edgurgel
edgurgel / unusedwarning_test.exs
Created August 26, 2014 09:28
Unused warning
test "should not give warning?" do
a = "a"
b = "b"
send self, {a, b}
assert_receive {a, b}
# test/unusedwarning_test.exs:8: warning: variable a is unused
# test/unusedwarning_test.exs:8: warning: variable b is unused
end
@edgurgel
edgurgel / example.ex
Created October 10, 2014 22:39
Overriding HTTPoison.Base.request/5
defmodule Example do
use HTTPoison.Base
def request(method, url, body \\ "", headers \\ [], options \\ []) do
IO.inspect [method, url, body, headers, options]
super(method, url, body, headers, options)
end
end
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.*;
public class JsonHelper {
public static Object toJSON(Object object) throws JSONException {
if (object instanceof Map) {
JSONObject json = new JSONObject();
@edgurgel
edgurgel / gist:5709927
Created June 4, 2013 21:51
pygments for Elixir
for lbrace, rbrace, name, in ('\\{', '\\}', 'cb'), \
('\\[', '\\]', 'sb'), \
('\\(', '\\)', 'pa'), \
('\\<', '\\>', 'lt'):
states['strings'] += [
(r'%[a-z]' + lbrace + r'(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b|'
r'[^x0MC])|(\\[MC]-)+\w|[^\s\\])',
String.Double, name + 'intp'),
(r'%[A-Z]' + lbrace, String.Double, name + 'no-intp')
@rebarconfigscript "rebar.config.script"
@doc """
Loads the rebar.config and evaluates rebar.config.script if it
exists in the given directory.
"""
def load_config(dir) do
config_path = Path.join(dir, "rebar.config")
script_path = Path.join(dir, @rebarconfigscript)
config = case :file.consult(config_path) do
@doc """
Loads the rebar.config and evaluates rebar.config.script if it
exists in the given directory.
"""
def load_config(dir) do
config_path = Path.join(dir, "rebar.config")
script_path = Path.join(dir, "rebar.config.script")
config = case :file.consult(config_path) do
{ :ok, config } ->
  • Brennar:

    • v.t.d. o ato de derrubar, derramar, algo ou alguma coisa sem a intenção do praticante da ação. Isso serve pra qualquer coisa água, almoço (ex. Brennou yourself <- sempre ocorre), café (mais costumeiramente).
  • Joiçar:

    • v.t.i. O ato de ficar até tarde no escritório; ou
    • v.t.i. Ficar mechendo no celular o tempo todo, principalmente em eventos sociais; ou
    • v.t.i. Não tomar café e/ou almoçar; ou
    • v.t.d. Brigar com Mateus porque ele sempre Mateusa (vide Mateusar) com o que eu falo ¬¬
  • Halanzar:

@edgurgel
edgurgel / rest-cowboy
Created June 30, 2013 13:38
REST Cowboy
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd">
<svg width="12cm" height="13cm" viewBox="7 9 231 243" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="Background">
<g>
<polygon style="fill: #dbedf3; fill-opacity: 1" points="179.156,28.429 195.383,33.3794 179.156,38.3297 162.929,33.3794 "/>
<polygon style="fill: none; stroke-opacity: 1; stroke-width: 0.2; stroke: #000000" points="179.156,28.429 195.383,33.3794 179.156,38.3297 162.929,33.3794 "/>
<text font-size="1.6" style="fill: #000000; fill-opacity: 1;text-anchor:middle;font-family:sans-serif;font-style:normal;font-weight:normal" x="179.156" y="33.8794">
<tspan x="179.156" y="33.8794">previously_existed/2</tspan>
</text>