Skip to content

Instantly share code, notes, and snippets.

@nburkley
nburkley / prevent_test_timeout.ex
Created February 15, 2018 09:46
Prevent Timeout in ExUnit tests
# in test/test_helper.exs
ExUnit.configure(timeout: :infinity)
ExUnit.start
# ...
# when using ecto change/add ownership timeout in config.exs
config :myapp, MyApp.Repo,
adapter: Ecto.Adapters.Postgres, # not important
username: "mydatabaseuser", # not important
database: "myapp_test", # not important
@nburkley
nburkley / multilpe_when_case.ex
Created March 9, 2018 16:56
Multiple matches for when
case testvalue do
n when n in [200, 400] ->
true
_ ->
false
end
@nburkley
nburkley / vefify_ssl_documents.sh
Created April 23, 2018 11:06
Verifying SSL Cert, Key and CSR match
# Get CSR MD5
openssl req -noout -modulus -in my_csr.csr | openssl md5
# Get cert MD5
openssl x509 -noout -modulus -in my_cert.crt | openssl md5
# Get Key MD5
openssl rsa -noout -modulus -in my_key.key | openssl md5
class Post < ActiveRecord::Base
after_commit :notify_editors, on: :create
after_commit :generate_feed_item, on: :create
private
def notify_editors
EditorMailer.send_notification(self).deliver_later
end
def generate_feed_item