Skip to content

Instantly share code, notes, and snippets.

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 Sep 13, 2016
exrm PostgreSQL/MySQL release equivalents for `mix ecto.create` and `mix ecto.drop`.
View exrm_ecto_create_drop_tasks.sh
# 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 Aug 13, 2016
Simplex noise reference implementation in Elixir.
View simplex_noise_reference.ex
# 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 Aug 8, 2016
Elixir translation of Stefan Gustavson's open source simplex noise implementation with improved 4D rank ordering.
View simplex_noise_improved.ex
# A speed-improved simplex noise algorithm for 2D, 3D and 4D
# translated from Java into Elixir.
#
# Based on example code by Stefan Gustavson (stegu@itn.liu.se).
# Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).
# Better rank ordering method for 4D by Stefan Gustavson in 2012.
# Translated into Elixir by Brendan Sechter (bsechter@sennue.com).
#
# 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 Aug 7, 2016
Elixir implementation of simplex noise.
View simplex_noise.ex
# 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 Aug 7, 2016
Elixir implementation of classic Perlin noise.
View classic_noise.ex
# 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}
}
View eval_ast.exs
import Html
quote(do: markup do: text("hi")) |> Code.eval_quoted
markup do: text("hi")
You can’t perform that action at this time.