iex(64)> msg=%{"hello" => "there"}
%{"hello" => "there"}
iex(65)> Enum.reduce( Map.to_list(msg) , "", fn ({x,y},acc) -> x <> " " <> y <> acc end )
"hello there"
add = fn x -> case x do {x,y,f} -> f.(x,y) {x,y} -> x + y _ -> raise("bad match") end end
iex(9)>
add = fn x ->
case x do
{x,y,f} -> f.(x,y)
{x,y} -> x + y
_ -> raise("bad match")
end
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
| pip install -U git+https://github.com/ansible/ansible.git@devel#egg=ansible |
https://docs.docker.com/engine/admin/logging/overview/
docker run --log-driver=gelf --log-opt gelf-address=udp://logstash:12201 --log-opt tag="docker" packetops/hello-world
docker run --log-driver=syslog --log-opt syslog-address=udp://logstash:10514 packetops/hello-world
docker volume ls
docker volume create --name mysql-data
mysql-data
Create a file inside a volume, the container is terminated. The container is restarted, and the file is still there
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 DockerMachine do | |
| def get_env() do | |
| case System.cmd("docker-machine", ["env","local"]) do | |
| {output,0} -> { | |
| :success, output |> | |
| String.split("\n") |> | |
| Enum.filter(fn x -> x =~ "export DOCKER" end) |> | |
| Enum.map( fn l -> | |
| String.replace(l, ~r/export (.*)/,"\\1") |> |
Q: dumb question - mix start console with test environment - trying to get HTTPoison examples working in the console but exjsx is marked as a :test only dependency.
Obviously I can edit the file, but I’d like to know how to control this with CLI flags or whatever.
A:
MIX_ENV=test iex -S mix
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
| cat ~/bin/rx_bytes_60_seconds | |
| function rx_bytes() { ifconfig eth0 | sed -ne '/RX bytes/{s_RX bytes:\([0-9]*\).*_\1_;s_ __g;p}'; } | |
| start=$(rx_bytes) | |
| sleep 60 | |
| end=$(rx_bytes) | |
| echo "60 second count - rx_bytes = $(( end - start ))" |