Here we assume we have a dedicated user myuser
created.
The application is supposed to be in /vol/release/$USER
$ sudo update-alternatives --config editor
wget https://github.com/rabbitmq/erlang-rpm/releases/download/v19.3.6.2/erlang-19.3.6.2-1.el6.x86_64.rpm | |
sudo rpm -Uvh erlang-19.3.6.2-1.el6.x86_64.rpm | |
rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc | |
wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el6.noarch.rpm | |
rpm -Uvh rabbitmq-server-3.6.10-1.el6.noarch.rpm | |
chkconfig rabbitmq-server on | |
/sbin/service rabbitmq-server start | |
rabbitmqctl status | |
rabbitmq-plugins enable rabbitmq_management |
## Given a file, containing 1_000_000 lines, remove all duplicates, save for lines, starting with `#` | |
require 'digest/sha1' # to generate uniqs | |
FILE_NAME = 'input.txt' | |
File.readlines(FILE_NAME).each_with_index.uniq do |s, idx| | |
s.start_with?('#') ? Digest::SHA1.hexdigest(idx.to_s) : s | |
end.join("\n") | |
{ | |
/* | |
// Place your snippets for Elixir here. | |
*/ | |
"GenServer": { | |
"prefix": "genserver", | |
"body": [ | |
"defmodule $1 do", | |
"@moduledoc \"\"\"", | |
" The `$1` server implementation", |
defmodule DryStructMatch do | |
defmacrop clause!(name, mod, fun) do | |
quote bind_quoted: [name: name, mod: mod, fun: fun] do | |
quote do | |
def unquote(name)( | |
unquote({:%, [], [{:__aliases__, [alias: false], [mod]}, {:%{}, [], []}]}) = struct | |
) do | |
# |> ... | |
result = struct | |
unquote(:"#{name}_callback")(unquote(fun), result) |
# === EDITOR === | |
Pry.editor = 'vi' | |
# === PROMPT === | |
Pry.prompt = [ ->(obj, nest_level, _) { "✎ " }, ->(obj, nest_level, _) { "#{' ' * nest_level} " } ] | |
# === COLORS === | |
unless ENV['PRY_BW'] | |
Pry.color = true | |
Pry.config.theme = "railscasts" |
defmodule Validator do | |
def instance!(rules, merge \\ true) do | |
mod = Module.concat(["Validator", "Instance"]) | |
current_rules = | |
if Code.ensure_compiled?(mod) do | |
rules = if merge, do: apply(mod, :rules, []), else: %{} | |
:code.purge(mod) | |
:code.delete(mod) | |
rules |
#!/usr/bin/env bash | |
# based on https://github.com/sbimochan/smart-commit/blob/master/commit | |
# am@aleksei feature/CO-400-some-branch-name$ ./smart-commit.sh "Foo bar." | |
# → [feature/CO-400-some-branch-name f70ebbf167] CO-400: Foo bar. | |
set -euo pipefail | |
if [ -z "${1:-}" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then |
The only reason is to make it easier to embed them into the pipeline built with Kernal.|>/2
.
As one might easily see, String.replace/4
delegates to Regex.replace/4
.
When one starts with a string, they might pipe String.replace/4
without a necessity to leave a pipeline. When one starts with a regex, the same applies to Regex.replace/4
.
defmodule MapAccess do | |
@spec filter((term -> boolean)) :: Access.access_fun(data :: map, get_value :: map) | |
def filter(func) when is_function(func, 1) do | |
fn op, data, next -> filter(op, data, func, next) end | |
end | |
defp filter(:get, %{} = data, func, next) do | |
data |> Enum.filter(func) |> Enum.map(next) |> Map.new() | |
end |