Note: Don't do this on a production evniroment!
Get the heroku database name:
heroku pg:infoName can be found in the reponse from the command above. For example: Add-on: soaring-newly-1337.
| list = Enum.to_list(1..100_000) | |
| Benchee.init(%{time: 3}) | |
| |> Benchee.benchmark("Enum.at", fn -> Enum.at(list, length(list) - 2) end) | |
| |> Benchee.benchmark( | |
| "revers + pattern matching", | |
| fn -> | |
| [_, next_to_last | _] = Enum.reverse(list) | |
| next_to_last | |
| end |
| Logger.remove_backend(:console) |
Note: Don't do this on a production evniroment!
Get the heroku database name:
heroku pg:infoName can be found in the reponse from the command above. For example: Add-on: soaring-newly-1337.
Example code:
def changeset(model, params \\ :empty) do
model
|> cast(params, @required_fieds, @optional_fields)
|> validate_length(:code, is: 2)
|> normalize_code
endfrom(u in User, select: count(u.id)) |> Repo.one!
Execute this in the Rails console and then all SQL queries from ActiveRecord will be shown:
ActiveRecord::Base.logger = Logger.new(STDOUT)After updating postgres brew formula or OS X, afterwards there could be an error similar to:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
One possible fix is:
Initialize your git repository git init. This would save you later a step to add heroku as remote.
Move configuration from config/prod.secret.exs to config/prod.exs and replace the following parts:
config :app_name, AppName.Endpoint,
secret_key_base: System.get_env("SECRET_KEY_BASE")
# Configure your database
config :app_name, AppName.Repo,
| mix phoenix.gen.secret |