Skip to content

Instantly share code, notes, and snippets.

View toland's full-sized avatar

Aeryn Toland toland

View GitHub Profile
@hl
hl / context.ex
Last active August 28, 2021 04:55
defmodule Context do
@moduledoc false
defmacro __using__(opts) do
repo = Keyword.fetch!(opts, :repo)
quote do
import Context, only: [context: 1, context: 2]
Module.put_attribute(__MODULE__, :__repo__, unquote(repo))
@aksonov
aksonov / rnrf.md
Last active July 30, 2022 22:39
Proposal for lightning talk at ReactiveConf 2017: What is RNRF (react-native-router-flux)?

What is RNRF (react-native-router-flux)?

React Native is great product but lacks for stable, intuitive and easy navigation API during many years. Every year we see new, better API: Native Navigator, ex-Navigator, NavigationExperimental, ex-Navigation, wix native navigation, airbnb native navigation, ReactNavigation...

Once I've started React Native development, in 2015, I created RNRF - simple API for easy navigation. It was clear that better navigation instruments will come later but I didn't want to change my code again and again to switch for better API. Every new major version of RNRF is based on different navigation framework and mostly preserves own API.

Another goal was to represent all navigation flow within one place in clear, human-readable way - similar to iOS Storyboards concept. This way other engineers could understand your app flow faster.

@aroben
aroben / git-commit-editor.vim
Last active March 30, 2023 07:57
Vim script to show git commit diff in vertical split while writing commit messages
" Put this in your .vimrc and whenever you `git commit` you'll see the diff of your commit next to your commit message.
" For the most accurate diffs, use `git config --global commit.verbose true`
" BufRead seems more appropriate here but for some reason the final `wincmd p` doesn't work if we do that.
autocmd VimEnter COMMIT_EDITMSG call OpenCommitMessageDiff()
function OpenCommitMessageDiff()
" Save the contents of the z register
let old_z = getreg("z")
let old_z_type = getregtype("z")
@rlipscombe
rlipscombe / initial_calls.erl
Last active March 25, 2017 00:54
Finding leaked processes in Erlang
lists:sort(fun({_, X}, {_, Y}) -> X > Y end,
dict:to_list(lists:foldl(
fun(Pid, Dict) ->
InitialCall = case erlang:process_info(Pid, initial_call) of
{initial_call,{proc_lib,init_p,A}} ->
case erlang:process_info(Pid, dictionary) of
{dictionary, D} -> proplists:get_value('$initial_call', D, undefined);
_ -> {proc_lib,init_p,A}
end;
{initial_call,{erlang,apply,A}} ->
@eddywashere
eddywashere / mongo-on-startup.md
Last active August 29, 2015 14:02
Run mongod with some decent settings on startup

Create the mongod.conf and insert the config content.

sudo vim /usr/local/var/mongodb/mongod.conf

Grab the path to mongod. which mongod

Create the org.mongo.mongod.plist file and insert the plist content and update the path to mongod.

child(SupPid, Child) ->
find_child(
Child,
supervisor:which_children(SupPid)
).
find_child(_, []) ->
{error, not_found};
@jamiehodge
jamiehodge / webmachine.markdown
Last active May 7, 2020 22:21
Webmachine state machine and resource callbacks

Webmachine State Machine

General

  • Service available?
    • callback: service_available?
    • false: 503 Service Unavailable
  • Known method?
    • callback: known_methods
  • absent: 501 Not Implemented
@listrophy
listrophy / Custom.css
Created January 3, 2013 15:40
Put this in "~/Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css" to highlight your blocked stories.
.projects_stories_page .storyLabels a[title="blocked"] {
background-color: red;
color: white !important;
padding: 0 3px;
display: inline-block;
}
@sleeptillseven
sleeptillseven / erlang_vm.md
Last active July 18, 2016 13:44
Collection of interesting resources for studying the Erlang VM

List of Interesting Resources Describing the Erlang VM

Hitchhiker's guide to the Erlang VM

Author: Robert Virding (Co-inventor of Erlang)

Slides: pdf

Video: youtube

@arjan
arjan / worker.erl
Created December 14, 2012 09:09
Erlang shell script to do some work in parallel on a number of input files. Parallelism is limited by the NumWorkers variable.
#!/usr/bin/escript
%% -*- mode: erlang -*-
main(Files) ->
NumWorkers = 3,
Parent = self(),
Workers = [spawn_link(fun() -> worker(Parent) end) || _ <- lists:seq(1, NumWorkers)],