Skip to content

Instantly share code, notes, and snippets.

Mac Setup

  1. Adjust settings
  • disable scroll direction: natural
  • allow watch to unlock mac
  • require password 5 seconds after screen saver
  • clear apps from dock and move dock to left
  1. install homebrew
defmodule MontyHall do
defstruct [:doors, :hidden]
def play(door_count) do
game = new(door_count)
pick = :crypto.rand_uniform(1, door_count + 1)
with_revealed_doors = first_move(game, pick)
{action, new_pick} =
case Enum.random([:switch, :dont]) do
@joseph-lozano
joseph-lozano / Dockerfile
Created August 14, 2020 14:49
Docker file for Elixir + Rust
# Setup build image
FROM elixir:1.10.4-alpine AS builder
# Install build dependencies
RUN apk update && \
apk add --no-cache \
bash \
build-base \
curl \
git \
defmodule Flatten do
@spec flatten(List.t()) :: List.t()
def flatten([]), do: []
def flatten([head | tail]) when is_list(head), do: flatten(head) ++ flatten(tail)
def flatten([head | tail]), do: [head | flatten(tail)]
def flatten(_), do: raise("argument must be a list")
end
ExUnit.start()
def flatten(arr, output = [])
raise "Input must be array. Usage: flatten(arr)" unless arr.class == Array
arr.each do |el|
if el.class == Array
flatten(el, output)
else
output << el
end
end
output

Keybase proof

I hereby claim:

  • I am joseph-lozano on github.
  • I am jetpackjoe (https://keybase.io/jetpackjoe) on keybase.
  • I have a public key whose fingerprint is A806 77F7 C40B 1039 9695 29D0 C954 1E5B B4ED B32C

To claim this, I am signing this object:

@joseph-lozano
joseph-lozano / rsa.rb
Last active December 13, 2015 01:16
Simple implementation of RSA public-key encryption and private-key decryption. Not very secure
require 'pry'
# Extend Integers for prime number methods
class Integer < Numeric
def prime?
2.upto((self**0.5).to_i) { |n| return false if self % n == 0 }
true
end
def next_prime
next_prime = self + 1