Skip to content

Instantly share code, notes, and snippets.

defmodule FizzBuzz do
def run() do
Enum.each(1..100, fn number ->
IO.puts(fizz_buzz(number))
end)
end
def fizz_buzz(n) do
cond do
is_divisible_by_3?(n) and is_divisible_by_5?(n) -> "FizzBuzz"

Keybase proof

I hereby claim:

  • I am bjvoth on github.
  • I am bjv5284 (https://keybase.io/bjv5284) on keybase.
  • I have a public key ASBpCy3tXqBm4aV32-cUxGhVNoIbWa5BAh374hDHX_WO-Ao

To claim this, I am signing this object:

@bjvoth
bjvoth / duplicate_shipping_fulfillment_remediation.exs
Created July 18, 2018 18:01
EP-3117: Duplicate shipping fulfillment remediation script and results
{:ok, since} = DateTime.from_naive(~N[2018-06-21 13:26:08.003], "Etc/UTC")
recent = Packlane.Mongo.find(:mongo, "fulfillments", %{tags: "courier"}) |> Enum.to_list |> Enum.filter(fn fulfillment -> DateTime.compare(fulfillment["created_at"], since) == :gt end)
iex(packlane@127.0.0.1)5> length recent
1671
iex(packlane@127.0.0.1)6> all_tracking_numbers = recent |> Enum.filter(fn f -> is_list(f["tracking_numbers"]) end) |> Enum.filter(fn f -> Map.get(f, "details") end) |> Enum.reduce([], fn f, a -> a ++ f["trackin
g_numbers"] end)
["781521295386", "781521474177", "781521571940", "781521864590", "781522545857",
@bjvoth
bjvoth / code_snippets.ex
Created July 12, 2018 18:43
Toro Task Error code snippets
{:ok, since} = DateTime.from_naive(~N[2018-05-01 13:26:08.003], "Etc/UTC")
iex(packlane@127.0.0.1)7> since
#DateTime<2018-05-01 13:26:08.003Z>
success_tasks = Toro.Task.find_by_inserted_at(since) |> Toro.Task.by_status("success") |> Lumbergh.Repo.all
iex(packlane@127.0.0.1)8> success_tasks |> Enum.count
10000
@bjvoth
bjvoth / surfboard.js
Last active January 31, 2018 18:48
es6 destructuring
const surfboard = {
length: '6',
width: '20',
volume: '32'
}
{length, width} = surfboard
console.log(length) // '6'
console.log(width) // '20'
function process(tab) {
// dont need this try, as you aren't trying anything that will fail
// try {
console.log("process: ", tab.url)
if (tab.url.match(/^https?:\/\/([^/]+\.)?facebook.com\//)) {
console.log('url matches facebook')
export PATH="/usr/local/bin:$PATH"
# Path to your oh-my-zsh installation.
export ZSH=/Users/bjvoth/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
@bjvoth
bjvoth / app.js
Created October 7, 2016 22:31
sideNavLayoutView requires refresh to display on Event page after first visit to the page
var app = new Backbone.Marionette.Application();
/* add the main region to the application */
app.addRegions({
appRegion: '#AppBase'
});
/* define the module we will be using to create this app */
app.module('RouteTest',function(module, App, Backbone, Marionette, $, _){
var _ = {
// Implements:
// https://lodash.com/docs#join
join: (array, separator = ',') => {
return 'FAIL :(';
}
}
PROBLEM 1:
Write a method that takes a maximum bound and returns all primes starting with 0 up-to and including the maximum bound.
For example:
Should return an array that looks like this:
[2,3,5,7,11]
def prime(n)