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 Home::IndexPage < MainLayout | |
def content | |
Kilt.embed "my_page.slang", io_name: @view | |
end | |
end |
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 Somethings::Index < BrowserAction | |
before require_sign_in | |
action { "do stuff" } | |
# You can extract all this to a module since you'll likely use it in multiple places | |
# Probably in src/pipes/authentication.cr or something | |
private def require_sign_in | |
if signed_in? |
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
% wrk -t4 -c100 -d30S --timeout 2000 http://localhost:8080 | |
Running 30s test @ http://localhost:8080 | |
4 threads and 100 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 1.89ms 481.91us 14.54ms 93.89% | |
Req/Sec 13.41k 1.90k 14.70k 90.08% | |
1601002 requests in 30.00s, 299.26MB read | |
Requests/sec: 53358.67 | |
Transfer/sec: 9.97MB |
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
# spec/support/app_conn.cr | |
require "http/client" | |
class AppConn | |
getter! response | |
@response : HTTP::Client::Response? = nil | |
module Matchers | |
def contain_html(html : String) | |
ContainHtmlExpectation.new(html) |
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 MyApp.Factory do | |
def user_factory do | |
%User{ | |
email: "[email protected]", | |
name: "Paul" | |
} | |
end | |
end | |
# Makes it easy to organize factories however you want |
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
$ file -I Makefile | |
Makefile: text/x-makefile; charset=us-ascii |
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
var bourbonPath = require("bourbon").includePaths[0]; | |
exports.config = { | |
// See http://brunch.io/#documentation for docs. | |
files: { | |
javascripts: { | |
joinTo: "js/app.js" | |
// To use a separate vendor.js bundle, specify two files path | |
// https://github.com/brunch/brunch/blob/stable/docs/config.md#files |
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
:dbg.tracer | |
:dbg.p :all, :c | |
:dbg.tpl ModuleToTrace, :x |
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 MyApp.Changeset do | |
def cast(model_or_changeset, :empty, required, optional) do | |
Ecto.Changeset.cast(model_or_changeset, :empty, required, optional) | |
end | |
def cast(model_or_changeset, params, required, optional) do | |
param_keys = params |> Map.keys |> Enum.map(&to_string/1) | |
allowed_params = (required ++ optional) |> Enum.map(&to_string/1) | |
disallowed_params = param_keys -- allowed_params |
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
"timestamp_with_timezone" | |
|> Timex.DateTime.parse("{ISO}") | |
|> Timex.DateConvert.to_erlang_datetime | |
# You probably don't need this next line for most things in Ecto. | |
# Changesets and queries automatically cast erlang timestamps | |
|> Ecto.DateTime.from_erl |