https://github.com/bryanjos/joken - A JSON Web Token (JWT) Library
token = %{user_id: 123}
|> Joken.token()
|> Joken.with_signer(Joken.hs256("my_secret_key"))
|> Joken.sign()
|> Joken.get_compact()
# Paginate | |
@spec handle_pagination(conn :: Plug.Conn.t(), page :: number | atom, page_size :: number | atom, query :: module) :: | |
Plug.Conn.t() | |
defp handle_pagination(conn, page, page_size, query) do | |
config = %Scrivener.Config{ | |
module: Repo, | |
page_number: page, | |
page_size: page_size, | |
options: [total_entries: total_entries(query)] | |
} |
defmodule Utils.Cowboy do | |
use Bitwise | |
# | |
# ipv4 cowboy string example: "0.0.0.0.0.65535.20060.31747" | |
# ipv6 cowboy string example: "10754.43916.45826.36224.35230.44219.15941.63302" | |
def erlangCowboyIpv6StringToString(string) do | |
if String.starts_with?(string, "0.0.0.0.0.65535") do | |
String.split(string,".") |> Enum.take(-2) |> Enum.map(fn(x)-> String.to_integer x end) |> Enum.map(fn(x)-> [x >>> 8,x &&& 255] end) |> List.flatten |> Enum.join(".") |
# Mojito: https://github.com/appcues/mojito/ | |
# Mint: https://github.com/elixir-mint/mint | |
defmodule ElasticSearch do | |
@config Application.get_env(:my_app, ElasticSearch) | |
@root @config[:root] # ie http://localhost:9200 | |
@headers [ | |
{"content-type", "application/json"} | |
] | |
def put(index, id, doc) do |
version: '3.8' | |
services: | |
zookeeper: | |
image: confluentinc/cp-zookeeper:latest | |
environment: | |
ZOOKEEPER_CLIENT_PORT: 2181 | |
ZOOKEEPER_TICK_TIME: 2000 | |
ports: | |
- 22181:2181 |
defmodule Downloader do | |
defstruct completed: false, | |
content_length: 0, | |
max_body_length: 200 * 1024 * 1024, | |
max_redirect: 3, | |
receive_timeout: 10_000, | |
redirect_count: 0, | |
redirect_location: nil, | |
status: 0 |
http://invisible-island.net/xterm/ | |
XTerm Control Sequences | |
Edward Moy | |
University of California, Berkeley | |
Revised by |
require 'mina/bundler' | |
require 'mina/git' | |
require 'mina/rbenv' | |
set :domain, 'your_domain.com' | |
set :deploy_to, '/home/deployer/app_name' | |
set :repository, 'git@github.com:user_name/app_name' | |
set :branch, ENV["brunch"] || 'master' | |
set :app_name, "app_name" |
https://github.com/bryanjos/joken - A JSON Web Token (JWT) Library
token = %{user_id: 123}
|> Joken.token()
|> Joken.with_signer(Joken.hs256("my_secret_key"))
|> Joken.sign()
|> Joken.get_compact()
#!/usr/bin/env bash | |
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/ | |
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c | |
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver | |
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception | |
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal | |
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04 | |
# Versions | |
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` |