Skip to content

Instantly share code, notes, and snippets.

View sgeos's full-sized avatar
💭
Too much to do, not enough time.

Brendan A R Sechter sgeos

💭
Too much to do, not enough time.
View GitHub Profile
@sgeos
sgeos / exrm_ecto_create_drop_tasks.sh
Last active September 13, 2016 09:39
exrm PostgreSQL/MySQL release equivalents for `mix ecto.create` and `mix ecto.drop`.
# PostgreSQL `mix ecto.create` equivalent
psql -c "CREATE USER ${DB_USER} WITH PASSWORD '${DB_PASSWORD}';"
createdb "${DB_NAME}"
psql -c "GRANT ALL PRIVILEGES ON DATABASE ${DB_NAME} to ${DB_USER};"
# PostgreSQL `mix ecto.drop` equivalent
dropdb "${DB_NAME}"
dropuser "${DB_USER}"
# PostgresSQL interactive terminal
@sgeos
sgeos / simplex_noise_reference.ex
Last active August 13, 2016 14:55
Simplex noise reference implementation in Elixir.
# Reference:
# http://www.csee.umbc.edu/~olano/s2002c36/ch02.pdf
# https://www.google.com/patents/US6867776
# A complete implementation of a function returning a value that
# conforms to the new method is given below.
# Translated from Java class definition to Elixir module.
defmodule SimplexNoiseReference do
use Bitwise
@sgeos
sgeos / simplex_noise_improved.ex
Created August 8, 2016 04:44
Elixir translation of Stefan Gustavson's open source simplex noise implementation with improved 4D rank ordering.
# A speed-improved simplex noise algorithm for 2D, 3D and 4D
# translated from Java into Elixir.
#
# Based on example code by Stefan Gustavson ([email protected]).
# Optimisations by Peter Eastman ([email protected]).
# Better rank ordering method for 4D by Stefan Gustavson in 2012.
# Translated into Elixir by Brendan Sechter ([email protected]).
#
# The Java version could be speeded up even further, but it's useful
# as it is. Assessment of Java optimazations for the Elixir version
@sgeos
sgeos / simplex_noise.ex
Last active August 7, 2016 11:59
Elixir implementation of simplex noise.
# Reference:
# http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
# Simplex noise in 2D, 3D and 4D
defmodule SimplexNoise do
@grad3 {
{1, 1, 0}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0},
{1, 0, 1}, {-1, 0, 1}, {1, 0, -1}, {-1, 0, -1},
{0, 1, 1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}
}
@sgeos
sgeos / classic_noise.ex
Last active August 7, 2016 12:00
Elixir implementation of classic Perlin noise.
# Reference:
# http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
# Classic Perlin noise in 3D, for comparison
defmodule ClassicNoise do
@grad3 {
{1, 1, 0}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0},
{1, 0, 1}, {-1, 0, 1}, {1, 0, -1}, {-1, 0, -1},
{0, 1, 1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}
}
import Html
quote(do: markup do: text("hi")) |> Code.eval_quoted
markup do: text("hi")