Skip to content

Instantly share code, notes, and snippets.

@l4u
l4u / gist:3066929
Created July 7, 2012 15:43
erlang list comprehension finding value given a key
[Y] = [X || {<<"type">>, X} <- Terms]
Y = proplists:get_value(<<"type">>, Terms)
Y = lists:keysearch(<<"type">>, 1, Terms)
%% From #erlounge
%% jlouis: l4u: lists:keysearch is usually very fast because it is implemented as a BIF, but proplists is more general and the thing Licenser suggested is reasonably fast as well
@l4u
l4u / gist:3099130
Created July 12, 2012 16:20
cocoapods git cache path
~/Library/Caches/CocoaPods/Git/
@l4u
l4u / gist:3102687
Created July 13, 2012 04:13
Upgrading podfile for cocoapods 0.8 in vim
:%s/^dependency /pod /g
@l4u
l4u / gist:3175950
Created July 25, 2012 12:38
Mongoid clone objects
original = Model.first
new = Model.new original.attributes.reject {|key| key == '_id'}
new.save!
@l4u
l4u / gist:3346722
Created August 14, 2012 05:52
Erlang version
init:script_id().
erlang:system_info(otp_release).
@l4u
l4u / gist:3368486
Created August 16, 2012 08:46
Installing esl-erlang on ubuntu
deb http://binaries.erlang-solutions.com/debian precise contrib
wget -O - http://binaries.erlang-solutions.com/debian/erlang_solutions.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install esl-erlang
Uncaught error in rebar_core: {'EXIT',
{badarg,
[{re,split,
[[65,82,67,72,70,76,65,71,83,61,45,97,114,
99,104,32,105,51,56,54,32,8211,97,114,99,
104,32,120,56,54,95,54,52],
"=",
[{return,list},{parts,2}]],
[{file,"re.erl"},{line,100}]},
{rebar_port_compiler,'-os_env/0-lc$^0/1-0-',
--- ~PROJECTS/elixir ‹master› » make
==> elixir (compile)
Uncaught error in rebar_core: {'EXIT',
{badarg,
[{re,split,
[[65,82,67,72,70,76,65,71,83,61,45,97,114,
99,104,32,105,51,56,54,32,8211,97,114,99,
104,32,120,56,54,95,54,52],
"=",
[{return,list},{parts,2}]],
@l4u
l4u / elixir.rb
Created September 29, 2012 17:01 — forked from josevalim/elixir.rb
Elixir Homebrew recipe HEAD
# Install this recipe with:
# brew install --HEAD --env=std https://raw.github.com/gist/3804582/da937661db644879c41a8cb2b4b24a7d1e9f3b67/elixir.rb
require 'formula'
class ErlangInstalled < Requirement
def message; <<-EOS.undent
Erlang is required to install.
You can install this with:
@l4u
l4u / gist:3804591
Created September 29, 2012 17:05
Install elixir using std env instead of superenv for homebrew 0.9.3
brew install --HEAD --env=std https://raw.github.com/gist/1955470/c58bda92f07147afff64a86d0c2d8ef65adb9cd6/elixir.rb