Skip to content

Instantly share code, notes, and snippets.

Benny Hallett BennyHallett

  • Central Coast, NSW
Block or report user

Report or block BennyHallett

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fizzbuzz.exs
defmodule FizzBuzz do
@doc """
Given a range, returns an array of values conforming to the FizzBuzz pattern.
## Example
FizzBuzz.calculate 1..15
-> 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
"""
def calculate(range) do
@BennyHallett
BennyHallett / terrain.exs
Created Aug 30, 2014
Unfinished Terrain Generator
View terrain.exs
defmodule Terrain do
def generate do
size = 65 # or 129, 513, 1025 (2^x + 1)
initial_state(size)
|> diamond { 0, 0 }, { size-1, size-1 }
end
defp diamond(current, { x1, y1 }, { x2, y2 }) when x2 == x1 + 2 and y2 == y1 + 2 do
current
@BennyHallett
BennyHallett / INSTRUCTIONS.md
Created Oct 10, 2014
Digital Pet written in Elixir
View INSTRUCTIONS.md

Instuctions

Run the file with:

$ iex digipet.ex

The create a pet via:

iex> pet = DigiPet.new "Franklin"
@BennyHallett
BennyHallett / Dockerfile
Created Oct 11, 2014
Simple Dockerfile for use with a Phoenix app
View Dockerfile
FROM trenpixster/elixir:1.0.1
COPY . /phoenix_app
ENV MIX_ENV prod
WORKDIR /phoenix_app
RUN mix do deps.get, compile
EXPOSE 4000
CMD ["mix", "phoenix.start"]
@BennyHallett
BennyHallett / identicon.exs
Created Oct 18, 2014
ANSI Identicons in Elixir
View identicon.exs
defmodule Identicon do
def make(username) do
username
|> encode
|> draw
end
defp encode(username) do
:crypto.md5(username)
@BennyHallett
BennyHallett / caesar.ex
Last active Aug 29, 2015
Caesar Cipher in Elixir
View caesar.ex
defmodule Caesar do
@doc """
Encode a file with a Caesar Cipher.
Shift value must be between 0 and 25. Works best with only aplha characters. Spaces will be left as spaces.
Usage:
$ iex caesar.ex
iex> Caesar.encode_file("/path/to/file", 13)
@BennyHallett
BennyHallett / scheduler.ex
Created Nov 1, 2014
Tournament Scheduling in Elixir
View scheduler.ex
defmodule Scheduler do
require Integer
@doc """
Generate a number of teams (3 or more)
"""
def generate_teams(number) when number < 3, do: IO.puts "Need to specify at least 3 teams"
def generate_teams(number) do
team_names
You can’t perform that action at this time.