Skip to content

Instantly share code, notes, and snippets.

View ferd's full-sized avatar
☢️
This place is not a place of honor… no highly esteemed deed is commemorated here

Fred Hebert ferd

☢️
This place is not a place of honor… no highly esteemed deed is commemorated here
View GitHub Profile
@ferd
ferd / race.erl
Last active August 29, 2015 14:03
#!/usr/bin/env escript
%% -*- erlang -*-
%%! +P 100000000
-module(race).
-mode(compile).
-export([main/1]).
main(Args) ->
[NumThreads, NumRunners] = [list_to_integer(Arg) || Arg <- Args],
Parent = self(),
λ /tmp → git clone https://github.com/erlware/relx.git
Cloning into 'relx'...
remote: Reusing existing pack: 2021, done.
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 2026 (delta 0), reused 1 (delta 0)
Receiving objects: 100% (2026/2026), 698.46 KiB | 636 KiB/s, done.
Resolving deltas: 100% (1217/1217), done.
λ /tmp → cd relx
λ relx → master → ls
```erlang
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -nouser
main(_) ->
error_logger:tty(false),
user_drv:start(),
timer:sleep(infinity).
```
@ferd
ferd / gist:843c04c1cc624d3ff6be
Last active August 29, 2015 14:01
vim composability

Vim is its own language.

It has verbs:

d: delete
D: delete line
c: change (overwrite)
C: change line
y: yank (copy)

Y: yank line

Keybase proof

I hereby claim:

  • I am ferd on github.
  • I am mononcqc (https://keybase.io/mononcqc) on keybase.
  • I have a public key whose fingerprint is FE3A BBED E0F2 EB66 56D9 DE8D EABF 7EE9 8680 CF48

To claim this, I am signing this object:

*~
*.beam
ebin/*.app
c_src/*.o
.eunit/*
.#*
deps/*
logs/
*.swp
*.swo
@ferd
ferd / ferd-lite.zsh-theme
Created April 1, 2014 01:12
ZSH theme for light background
PROMPT='$(prompt_clr)λ %{$fg[grey]%}%1~ $(prompt_mode) $(git_prompt_info)$(hg_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}"
function hg_prompt_info {
hg prompt --angle-brackets "\
<%{$fg[blue]%}<branch>%{$reset_color%}> \
<%{$fg[blue]%}<status|modified|unknown>%{$reset_color%} >" 2>/dev/null
}
@ferd
ferd / mod.erl
Last active August 29, 2015 13:57
%% Possible Dialyzer bug
-module(mod).
-export([run/1]).
test(Fun, Arg1, Arg2, Arg3) ->
FinalFun = case check(Arg1) of
reuse -> Fun;
new -> fun do_nothing/2
end,
case FinalFun(Arg2,Arg3) of
λ erlpass → master → make compile
/Users/ferd/local/bin/rebar get-deps compile
==> erlpass (get-deps)
Pulling bcrypt from {git,"https://github.com/opscode/erlang-bcrypt.git",
{tag,"0.5.0.3"}}
Cloning into 'bcrypt'...
==> bcrypt (get-deps)
==> bcrypt (compile)
Compiled src/bcrypt_nif.erl
Compiled src/bcrypt_app.erl
-module(brainfuck).
-export([main/1,run/1]).
-define(Tape, <<0:30000/unit:8>>).
-define(DATA_POINTER, 0).
%% >: data ptr +1
%% <: data ptr -1
%% +: byte+1 at data ptr
%% -: byte-1 at data ptr