This file contains hidden or 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
=erl_crash_dump:0.3 | |
Sun Sep 21 19:46:07 2014 | |
Slogan: Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_child,user,{undef,[{'Elixir.IEx.CLI',start,[],[]},{user_sup,start_user,3,[{file,"user_su | |
System version: Erlang/OTP 17 [erts-6.1] [source-d2a4c20] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] | |
Compiled: Thu Jun 26 17:08:00 2014 | |
Taints: | |
Atoms: 4994 | |
=memory | |
total: 10668648 | |
processes: 3510784 |
This file contains hidden or 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
CREATE OR REPLACE FUNCTION bet_profit(state character varying, stake float, odds float) RETURNS float AS $$ | |
DECLARE | |
result float := 0; | |
half_stake float :=0; | |
BEGIN | |
CASE state | |
WHEN 'in_process' THEN | |
result := 0; | |
WHEN 'guessed' THEN | |
result := (stake * odds); |
This file contains hidden or 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
puts '===> INCLUDE EXAMPLE' | |
module M1 | |
def run | |
puts 'M1 run' | |
end | |
end | |
class C1 | |
include M1 |
This file contains hidden or 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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
This file contains hidden or 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
# Elixir has pipes `|>`. Let's try to implement those in Ruby. | |
# | |
# I want to write this: | |
# | |
# email.body | RemoveSignature | HighlightMentions | :html_safe | |
# | |
# instead of: | |
# | |
# HighlightMentions.call(RemoveSignature.call(email.body)).html_safe | |
# |
This file contains hidden or 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
#!/bin/bash | |
PROJECT_NAME="<YOUR-PROJECT-NAME>" | |
PROJECT_PATH=" ~/Work/railsapps/${PROJECT_NAME}" | |
CD_INTO_PROJECT="cd ${PROJECT_PATH}" | |
tmux has-session -t $PROJECT_NAME | |
if [ $? != 0 ] | |
then |
This file contains hidden or 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
if exists('$TMUX') | |
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" | |
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" | |
else | |
let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
let &t_EI = "\<Esc>]50;CursorShape=0\x7" | |
endif |
This file contains hidden or 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 elixir:1.2.3 | |
MAINTAINER Sergey Gernyak <[email protected]> | |
ENV MIX_ENV=prod | |
RUN apt-get update && apt-get install -y build-essential git-core | |
RUN mkdir -p /app | |
WORKDIR /app |
This file contains hidden or 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
setup do | |
:ok = Ecto.Adapters.SQL.Sandbox.checkout(RemarkApi.Repo) | |
Ecto.Adapters.SQL.Sandbox.mode(RemarkApi.Repo, {:shared, self()}) | |
:ok | |
end |
This file contains hidden or 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 EctoHelper do | |
@moduledoc """ | |
Provides helper functions | |
""" | |
@doc """ | |
Prettifies changeset error messages. | |
By default `changeset.errors` returns errors as keyword list, where key is name of the field | |
and value is part of message. For example, `[body: "is required"]`. | |
This method transforms errors in list which is ready to pass it, for example, in response of |