Skip to content

Instantly share code, notes, and snippets.

@entone
entone / client.ex
Created March 27, 2021 14:30
Basic TCP/SSL Client
defmodule Broker.Client do
use GenServer
require Logger
alias Broker.{Message, Parser}
defmodule State do
defstruct [
:socket,
:host,
@entone
entone / StopDocker.md
Last active February 8, 2020 14:50
Dockerfile multiple start commands with ctrl-c and graceful stop

Initially I had the nginx command in the start script, but BASH was ignoring SIGINT signals, or capturing them but not forwarding them to the Nginx daemon.

This snippet allows docker stop <hash> to shutdown the container properly, without waiting the default 10 seconds for cleanup, and ctrl-c works as expected.

Dockerfile

CMD /app/start.sh && \
 exec nginx -g 'daemon off;'

Keybase proof

I hereby claim:

  • I am entone on github.
  • I am entropealabs (https://keybase.io/entropealabs) on keybase.
  • I have a public key ASCMe4U_xWD19RPVTxy1t3utAFNfbnef5_Qpw6ezbEeuMgo

To claim this, I am signing this object:

@entone
entone / Dockerfile.frontend
Created September 4, 2019 20:22
Dockerfile for building a separate container for a React frontend in `priv/admin` directory of an Elixir application
# Build step
FROM node:12.8 as build
WORKDIR /app
COPY ./priv/admin .
RUN npm install
RUN npm run-script build --frozen-lockfile --non-interactive
# Release step
FROM nginx:1.17.2-alpine
COPY ./priv/admin/nginx/default.conf /etc/nginx/conf.d/default.conf
FROM elixir:1.9.1-alpine as build
# # install build dependencies
RUN apk add --no-cache \
gcc \
g++ \
git \
make \
musl-dev
RUN mix do local.hex --force, local.rebar --force
@entone
entone / .dockerignore
Last active October 3, 2020 03:54
Elixir 1.9 example Dockerfile
/_build/
# If you run "mix test --cover", coverage assets end up here.
/cover/
# The directory Mix downloads your dependencies sources to.
/deps/
# Where 3rd-party dependencies like ExDoc output generated docs.
/doc/
@entone
entone / card_parser.js
Last active October 19, 2017 20:04
parse credit card data from magnetic card reader and input it into NAR Booth Payments form
var credit_card_data = "";
var timer = null;
function parse(val){
var tracks = val.split("?");
var parts = tracks[0].split("^");
var card = parts[0].replace("%B", "");
var card_type = get_card_type(card);
var names = parts[1].split("/")
var name = names[1].trim()+" "+names[0].trim();
@entone
entone / get_ip4_address.ex
Last active October 3, 2017 20:07
iterate over local network interfaces and find first non local ip4v address
def get_ipv4_address() do
:inet.getifaddrs()
|> elem(1)
|> Enum.find(fn {_interface, attr} ->
case attr |> Keyword.get_values(:addr) do
[] -> false
list -> list |> Enum.find(fn(addr) ->
case addr do
nil -> false
{127, 0, 0, 1} -> false
Verifying that +entone is my openname (Bitcoin username). https://onename.io/entone
FB.ui({
method: 'send',
link: "<%=j URI::encode(@facebook_invite_url) %>",
name: "Join Dashboard",
to: friend_fb_id,
});