Skip to content

Instantly share code, notes, and snippets.

View Gazler's full-sized avatar

Gary Rennie Gazler

View GitHub Profile
difficulty 2
description "You need to fix a bug in the version 1.2 of your app. Checkout the tag `v1.2`."
setup do
repo.init
FileUtils.touch("app.rb")
repo.add("app.rb")
repo.commit_all("Initial commit")
defmodule MasterProxy do
use Application
# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
def start(_type, _args) do
import Supervisor.Spec, warn: false
cowboy = Plug.Adapters.Cowboy.child_spec(:http, MasterProxy.Plug, [])
sysctl -w fs.file-max=12000500
sysctl -w fs.nr_open=20000500
ulimit -n 4000000
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
sysctl -w net.ipv4.tcp_rmem='1024 4096 16384'
sysctl -w net.ipv4.tcp_wmem='1024 4096 16384'
sysctl -w net.core.rmem_max=16384
sysctl -w net.core.wmem_max=16384
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
gazler@gazler-desktop-pc:~/development/pubsub_stress$ WS_CLIENTS=10000 PORT=4000 REMOTE_PORT=4002 MIX_ENV=prod mix phoenix.server
#PID<0.253.0>700 subscribers listening on "rooms:lobby"
{"Kernel pid terminated",application_controller,"{application_start_failure,pubsub_stress,{{shutdown,{failed_to_start_child,'Elixir.PubsubStress.WebSocketSimulator',{'EXIT',{undef,[{'Elixir.PubsubStress.WebSocketSimulator',start_link,[10000,<<\"4002\">>],[]},{supervisor,do_start_child,2,[{file,\"supervisor.erl\"},{line,314}]},{supervisor,start_children,3,[{file,\"supervisor.erl\"},{line,297}]},{supervisor,init_children,2,[{file,\"supervisor.erl\"},{line,263}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,306}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,237}]}]}}}},{'Elixir.PubsubStress',start,[normal,[]]}}}"}
def show
case Car.create(conn.assigns.user, params) do
{:ok, car} ->
conn
|> redirect(to: car)
{:error, changeset} ->
conn
|> render("new.html", changeset: changeset)
end
end
defmodule Authex.Mixfile do
use Mix.Project
def project do
[app: :authex,
version: "0.0.1",
elixir: "~> 1.0",
deps: deps]
end
@Gazler
Gazler / earmark-pipe.exs
Last active August 29, 2015 14:05
earmark test
test "Columns with pipes" do
result = Earmark.to_html(["a | b | c", "d | e \| f | g"])
expected = """
<table>
<colgroup>
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<tr>
@Gazler
Gazler / gist:8c893bbcfad2d09a0dd0
Last active August 29, 2015 14:04
Elixir Regex split
gazler@gazler-desktop-pc:~/development/elixir/elixir$ iex
Erlang/OTP 17 [erts-6.0] [source-07b8f44] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (0.14.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Regex.split(~r/(%{[^}]+})/, "%{foo}(%{bar}): %{baz}")
["", "%{foo}", "(", "%{bar}", "): ", "%{baz}", ""]
gazler@gazler-desktop-pc:~/development/elixir/elixir$ iex
Erlang/OTP 17 [erts-6.0] [source-07b8f44] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
@Gazler
Gazler / Dockerfile
Last active October 21, 2016 05:36
Phoenix Dockerfile
FROM ubuntu
RUN apt-get update
RUN apt-get install -y wget unzip git make
RUN wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
RUN dpkg -i erlang-solutions_1.0_all.deb
RUN apt-get update
RUN apt-get -y install erlang
@Gazler
Gazler / Gemfile
Last active December 19, 2015 01:28
source :rubygems
gem "rapidash"
gem "activesupport", "~>4.0.0"