Skip to content

Instantly share code, notes, and snippets.

View expede's full-sized avatar
Highly caffeinated

Brooklyn Zelenka expede

Highly caffeinated
View GitHub Profile
#test for editing
#setup on the command line
gem install rspec
rspec --init
#add to gemfile:
group :test, :development do
gem 'rspec-rails'
end
@expede
expede / debase.zsh
Last active August 29, 2015 14:08
git debase
# Similar to a squashed rebase
# Merges branch A into B, and then resets the branch to A,
# producing an unstaged diff of B for your commit
# exampe usage: `debase master`
# (note the lack of `git` prefix)
function debase() {
if [[ -z $1 ]]; then
echo 'missing branch to debase from'
else
branch=${1}
### Keybase proof
I hereby claim:
* I am expede on github.
* I am expede (https://keybase.io/expede) on keybase.
* I have a public key whose fingerprint is F233 CD9A 63AE 700A 7BD2 451A FB83 8D90 B29C 377A
To claim this, I am signing this object:
@expede
expede / gist:31c89c0b755ad80fc568
Created January 15, 2015 22:40
spacemacs configuration packages
(defvar expede-packages
'(
cucumber-goto-step
ac-haskell-process
ac-html
ac-helm
ac-octave
brainfuck-mode
coffee-mode
helm-robe
@expede
expede / multiple_error_tuples.ex
Created August 31, 2016 11:57
Elixir Multiple Error Tuples
{:error, "Something went boom"}
{:error, "Something went boom", %{original :data}}
{:error, %{original: :data}}
# Yes, this exists in the wild
{:ok, %{error: %{reason: "something went boom", data: %{original: :data}}}}
use Exceptional
OtherFile.read("./existing_file.txt") ~> String.length
# 19
OtherFile.read("./missing.file") ~> String.length
# %OtherFile.NotFoundError{
# message: "File not found at ./missing.file",
# path: "./missing.file"
# }
search_result = find_book(title: title)
case search_result do
page = %Page{} -> render(page)
%Ecto.MultipleResultsError{} when is_series(title) ->
%Book.SeriesAreNotBooksError{
message: "#{title} is a series, not a book.",
title: title,
series: search_result,
plug_status: 422
}
# =====================
# Explicit branch names
# =====================
branch OtherFile.read("./existing_file.txt"),
value_do: String.length,
exception_do: fn %{message: msg} -> msg end.()
# => 1000
branch OtherFile.read("./missing.file"),
OtherFile.read("./existing_file.txt")
~> fn text ->
text
|> String.length
|> fn x -> x / 2 end.()
end.()
|> to_tagged_status
#=> {:ok, 500}
# `ok` alias for tagged_status
use Exceptional
# Success case
iex> OtherFile.read("./existing_file.txt") >>> String.length
1000
# Error case
iex> OtherFile.read("./missing.file") >>> String.length
**(OtherFile.NotFoundError) File not found at ./missing.file