Skip to content

Instantly share code, notes, and snippets.

Avatar
Highly caffeinated

Brooklyn Zelenka expede

Highly caffeinated
  • @fission-suite
  • Vancouver, Canada
  • Twitter @expede
View GitHub Profile
View Rails testing with RSpec, Capybara and RSpec-Candy
#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 Aug 29, 2015
git debase
View debase.zsh
# 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}
View gist:896a1618dfa5a583f78f
### 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 Jan 15, 2015
spacemacs configuration packages
View gist:31c89c0b755ad80fc568
(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 Aug 31, 2016
Elixir Multiple Error Tuples
View multiple_error_tuples.ex
{: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}}}}
View escape_hatch.ex
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"
# }
View recontextualize.ex
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
}
View if_exception.ex
# =====================
# 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"),
View back_to_tuples.ex
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
View inverted_raise.ex
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