View application.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule UI.Application do | |
use Application | |
def start(_type, _args) do | |
# List of children to be started when checks succeed | |
delayed_children = [ | |
UI.Endpoint, | |
{Absinthe.Subscription, UI.Endpoint} | |
] |
View benchmark.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query = "query { | |
project(id: 1389) { | |
id, | |
slices { | |
id, | |
todos { | |
id, | |
title, | |
description, | |
progress, |
View curry_recipe.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For 2 people will need: | |
1. Spices | |
- 1 table spoon of red curry paste | |
- 2 anise stars | |
- 3 cardamom seeds | |
- 3 cloves | |
- 1 piece of cinnamon bark | |
- 1 long pepper | |
- 2 table spoons of garam masala |
View db_connection_dies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
09:46:57.136 [error] #PID<0.600.0> running Todos.UI.Endpoint terminated | |
Server: localhost:4001 (http) | |
Request: POST /login | |
** (exit) an exception was raised: | |
** (DBConnection.ConnectionError) connection not available because of disconnection | |
(db_connection) lib/db_connection.ex:926: DBConnection.checkout/2 | |
(db_connection) lib/db_connection.ex:742: DBConnection.run/3 | |
(db_connection) lib/db_connection.ex:584: DBConnection.prepare_execute/4 | |
(ecto) lib/ecto/adapters/postgres/connection.ex:73: Ecto.Adapters.Postgres.Connection.prepare_execute/5 | |
(ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6 |
View irb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):029:0> Benchmark.bm do |x| | |
irb(main):030:1* x.report("Strings: ") { 10000000.times {"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".hash} } | |
irb(main):031:1> x.report("Symbols: ") { 10000000.times {:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.hash} } | |
irb(main):032:1> end | |
user system total real | |
Strings: 1.290000 0.000000 1.290000 ( 1.282911) | |
Symbols: 0.450000 0.000000 0.450000 ( 0.458915) |
View Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM phusion/baseimage:0.9.22 | |
CMD ["/sbin/my_init"] | |
RUN add-apt-repository -y ppa:brightbox/ruby-ng | |
RUN apt-get update | |
RUN apt-get install -y libpq-dev git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs wget autoconf tzdata ruby2.4 ruby2.4-dev rubygems ruby-switch | |
RUN ruby-switch --set ruby2.4 | |
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
View gracefully_shutdown_process_tree.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ParentServer do | |
use GenServer | |
import Supervisor.Spec | |
def start_link() do | |
GenServer.start_link(__MODULE__, nil, name: __MODULE__) | |
end | |
def init(_) do | |
Process.flag(:trap_exit, true) |
View application_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
... | |
around_action :use_request_cache, if: Proc.new {|c| request.get? } | |
private | |
def use_request_cache | |
RequestCache.with_cache do | |
yield |
View bench.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Bench do | |
def bench do | |
:timer.tc(fn -> Enum.reduce(Range.new(0, 10000000), 0, &Kernel.+/2) end) |> IO.inspect | |
:timer.tc(fn -> Enum.reduce(Range.new(0, 10000000), 0, fn acc, n -> acc + n end) end) |> IO.inspect | |
:timer.tc(fn -> Enum.reduce(Range.new(0, 10000000), 0, &(&1 + &2)) end) |> IO.inspect | |
nil | |
end | |
end |
View files.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Files do | |
def run do | |
process_file File.read("hello.txt") | |
end | |
def process_file({:ok, contents}) do | |
IO.puts "File contents are here:" | |
IO.puts contents | |
end |
NewerOlder