View phoenix_to_umbrella
How to convert existing phoenix app to an umbrella app.
chrismccord [10:14 PM]
@alanpeabody yes, it's straightforward
1) mix new my_umbrella --umbrella

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using and

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
View autossh.service
Description=Keeps a tunnel to '' open
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
View flatten.exs
defmodule Flat do
# [ 1 , 2, 3, [ 1, 2]]
def flatten(list) do
flatten(list, [])
def flatten([h|t], acc_list) when is_list(h) do
# this may be expensive!
flatten(h ++ t, acc_list)
View ticker.ex
# Ticker
defmodule Ticker do
use GenServer
def start_link(%{module: module, function: function, interval: interval} = state)
when is_atom(module) and is_atom(function) and is_integer(interval) and interval > 0 do
GenServer.start_link(__MODULE__, state)
def init(state) do
View config.ex
defmodule Config do
@moduledoc """
This module handles fetching values from the config with some additional niceties
@doc """
Fetches a value from the config, or from the environment if {:system, "VAR"}
is provided.
An optional default value can be provided if desired.
View ticker.ex
defmodule Ticker do
require Logger
# public api
def start(recipient_pid, tick_interval, duration \\ :infinity) do
# Process.monitor(pid) # what to do if the process is dead before this?
# start a process whose only responsibility is to wait for the interval
ticker_pid = spawn(__MODULE__, :loop, [recipient_pid, tick_interval, 0])
# and send a tick to the recipient pid and loop back
send(ticker_pid, :send_tick)
schedule_terminate(ticker_pid, duration)
View poolboy_demo.ex
defmodule HttpRequester do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, nil, [])
def fetch(server, url) do
# Don't use cast:
timeout_ms = 10_000
View vimrc.vim
" settings
colorscheme molokai
let loaded_matchparen=1 " don't automatically highlight the matching parens
let mapleader = ' '
let maplocalleader = ' '
set autowriteall " autosave files
set background=dark
set clipboard=unnamedplus " Yanks go on clipboard
set cmdheight=2
View calc.html
<!doctype html>
<div id='output'>Output: </div>
<input type="text" id="op1" placeholder="Input 1" />
<input type="text" id="op2" placeholder="Input 2" />
<button onclick="calculate()">Add</button>