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
Rails.application.routes.draw do | |
scope 'YOUR_PREFIX_HERE' do | |
# Your application routes | |
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
require ::File.expand_path('../config/environment', __FILE__) | |
class ScriptName | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
env['SCRIPT_NAME'] += env['HTTP_FRONTEND_URI'].to_s if !Rails.env.development? | |
@app.call(env) |
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 MyGenServer do | |
defmacro __using__(_options \\ :empty) do | |
quote do | |
def start_link(default_state) do | |
Task.start_link(fn -> loop(default_state) end) | |
end | |
def loop(state) do | |
receive do | |
{:call, options, caller} -> |
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 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 |
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
setup do | |
:ok = Ecto.Adapters.SQL.Sandbox.checkout(RemarkApi.Repo) | |
Ecto.Adapters.SQL.Sandbox.mode(RemarkApi.Repo, {:shared, self()}) | |
:ok | |
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
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 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 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 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 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') |