Skip to content

Instantly share code, notes, and snippets.

@lucaschain
lucaschain / errou_formatter.rb
Last active August 20, 2018 15:13
Fausto Silva's "errou" formatter
class CustomFormatter < RSpec::Core::Formatters::BaseTextFormatter
RSpec::Core::Formatters.register self, :example_passed, :example_pending, :example_failed
def initialize(*args)
super(*args)
@index = 0
end
def increase_index!
@index += 1
@leorog
leorog / solution.exs
Last active September 15, 2016 10:54
WhichIsFaster?
defmodule Solution do
def recur(x, acc \\ 0)
def recur(0, acc), do: acc
def recur(target, acc) do
if (rem(target, 3) == 0 or rem(target, 5) == 0) do
recur(target - 1, acc + target)
else
recur(target - 1, acc)
end
end
@JoelQ
JoelQ / README.md
Created October 15, 2015 13:50
Using Shell Scripts for a Better User Experience (source for https://robots.thoughtbot.com/improving-user-experience-with-shell-scripts)

Server scripts

This is the source for the scripts discussed in https://robots.thoughtbot.com/improving-user-experience-with-shell-scripts

Both scripts are in the bin/ directory of the repo that contains all the markdown documents for blog posts. Users run bin/server and everything is automatically set up for them to view a local preview of the blog. bin/server-setup is a dependency of bin/server and is never run directly by users.

Maitre-d is the name of the "blog engine" discussed in the article.

@leighhalliday
leighhalliday / bin_tree.exs
Last active March 7, 2019 16:29
Playing with Binary Trees in Elixir
defmodule MyList do
# Takes 2 lists like [1,2] and [3,4]
# and produces a single list like [1,3,2,4]
def zip_merge([heada | taila], [headb | tailb]) do
[heada] ++ [headb] ++ zip_merge(taila, tailb)
end
def zip_merge([heada | taila], []) do
[heada] ++ zip_merge(taila, [])
end
@VladSem
VladSem / tmux_ubuntu14.04.sh
Last active July 7, 2020 21:12
install tmux 2.0 on Ubuntu 14.04
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository -y ppa:pi-rho/dev
sudo apt-get update
sudo apt-get install -y tmux=2.0-1~ppa1~t
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a