Skip to content

Instantly share code, notes, and snippets.


Toran Billups toranb

View GitHub Profile
toranb / leex_to_heex.ex
Last active Nov 9, 2021
inline conditional css comparison of leex and heex
View leex_to_heex.ex
##### phx live view 0.16 with leex
def render(assigns) do
<button class="<%= if @foo && @bar && @baz do %>text-blue-600<% else %>text-red-600<% end %>">hello</button>
##### phx live view 0.16 with heex -inline edition
toranb / app.js
Created Jul 4, 2020 — forked from nicolasblanco/app.js
Stripe.js elements integration inside a Elixir LiveView (Bootstrap styles)
View app.js
// Code handling the card payment
const payWithCard = function (stripe, card, clientSecret, liveView) {
.confirmCardPayment(clientSecret, {
payment_method: {
card: card,
.then(function (result) {
if (result.error) {
toranb / jedi-for-python.txt
Created Jan 15, 2019
Python for go-to-definition
View jedi-for-python.txt
pip install jedi
then -in your vimrc
nmap <Leader>j :call InvokeJumpToByType()<CR>
function! InvokeJumpToByType()
let filetype=&ft
if filetype == 'python'
exe ':call jedi#goto_definitions()'
toranb / postgres.txt
Created Dec 23, 2018
First time install of postgres on macOS Mojave
View postgres.txt
1) Install homebrew if you haven't already
2) Install postgres
brew install postgresql
3) Start the database
toranb / wait-for-redux.js
Last active Nov 1, 2018
custom ember helper to wait for redux to be in a given state
View wait-for-redux.js
import { Promise } from 'rsvp';
import { next } from '@ember/runloop';
import { registerWaiter } from '@ember/test';
import { getContext } from '@ember/test-helpers';
export async function waitForRedux(key, value) {
return new Promise(async (resolve) => {
let counter = 1;
registerWaiter(() => counter === 0);
const { owner } = getContext();
toranb / hydrate_state_from_filesystem.ex
Created Oct 28, 2018
Simple GenServer callback to create a map w/ {key, value} pairs by looking at the filesystem
View hydrate_state_from_filesystem.ex
@impl GenServer
def handle_call({:all}, _timeout, _state) do
{:ok, files} = :file.list_dir(@database)
state =, fn (key) ->
value =
case, key)) do
{:ok, contents} -> :erlang.binary_to_term(contents)
_ -> nil
toranb / verbose-some.exs
Created Oct 14, 2018
My first implementation of some in elixir
View verbose-some.exs
defmodule MyEnum do
def some([], _func), do: []
def some([head | tail], func) do
case func.(head) do
true ->
false ->
case some(tail, func) do
true ->
toranb / functions-in-elixir.exs
Created Sep 27, 2018
functions defs can have multiple implementations in elixir
View functions-in-elixir.exs
defmodule Foo do
def my_func({name}) do IO.puts("#{name}") end
def my_func({name, number}) do IO.puts("#{name} #{number}") end
toranb / pinned-values-as-params.exs
Last active Sep 27, 2018
showing how pinned values and pattern matching work in elixir
View pinned-values-as-params.exs
defmodule Robot do
def speak(name, phrase) do
(^name) -> "hello! #{name}, #{phrase}"
(_) -> "sorry ... don't know this name"
toranb /
Created Jun 26, 2018
Over mocking under delivering


The Ember community has a strong testing culture, but advanced topics like the intersection of integration and isolation testing can be as confusing as they are controversial. To make matters worse we are often tricked into believing that a mock library has the answer to all of our problems, making it difficult to evaluate when to use mocks (or even avoid them).

This talk will give you a fresh perspective on the use and abuse of mock objects, explore why this topic is crucial for test suite reliability, and equip developers with strategies to make these distinctions without the guesswork.


For years now I've had varying degrees of success with mock objects but until recently I didn't have a narrative in which to tell the story of "good mock/bad mock"