First I created 3 droplets on digital ocean with 4-cores and 8GB of RAM. Login as root to each and run:
sysctl -w fs.file-max=12000500
sysctl -w fs.nr_open=20000500
ulimit -n 4000000
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'| # ATTENTION: This is now supported in plug_cowboy as of 2.1.0: | |
| # https://hexdocs.pm/plug_cowboy/Plug.Cowboy.Drainer.html | |
| defmodule DrainStop do | |
| @moduledoc """ | |
| DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown | |
| occurs. It first shuts down the acceptor, ensuring that no new requests can be | |
| made. It then waits for all pending requests to complete. If the timeout | |
| expires before this happens, it stops waiting, allowing the supervision tree | |
| to continue its shutdown order. |
| # This code is based on tutorial by slicktechies modified as needed to use oauth token from Twitch. | |
| # You can read more details at: https://www.junian.net/2017/01/how-to-record-twitch-streams.html | |
| # original code is from https://slicktechies.com/how-to-watchrecord-twitch-streams-using-livestreamer/ | |
| import requests | |
| import os | |
| import time | |
| import json | |
| import sys | |
| import subprocess |
| FROM elixir:1.4.5 as asset-builder-mix-getter | |
| ENV HOME=/opt/app | |
| RUN mix do local.hex --force, local.rebar --force | |
| # Cache elixir deps | |
| COPY config/ $HOME/config/ | |
| COPY mix.exs mix.lock $HOME/ | |
| COPY apps/myproject_web/mix.exs $HOME/apps/myproject_web/ | |
| COPY apps/myproject_web/config/ $HOME/apps/myproject_web/config/ |
| /** | |
| * Returns a new object that merges the values of | |
| * `newObj` into `oldObj`. Uses shallow copying. | |
| * | |
| * **WARNING: Do NOT pass cyclical objects! | |
| * This includes React nodes!** | |
| * | |
| * **IMPORTANT:** util.merge does **NOT** behave like | |
| * lodash merge! *TL;DR:* (typed) arrays are not merged | |
| * but replaced by the newer array. |
| default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam' | |
| default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes' | |
| default['sshd']['sshd_config']['PasswordAuthentication'] = 'no' |
| /* | |
| Copy this into the console of any web page that is interactive and doesn't | |
| do hard reloads. You will hear your DOM changes as different pitches of | |
| audio. | |
| I have found this interesting for debugging, but also fun to hear web pages | |
| render like UIs do in movies. | |
| */ | |
| const audioCtx = new (window.AudioContext || window.webkitAudioContext)() |
| #!/bin/bash | |
| if [ "$EUID" -ne 0 ] | |
| then echo "Please run as root" | |
| exit | |
| fi | |
| apt-get install pkg-config libmagickwand-dev -y | |
| cd /tmp | |
| wget https://pecl.php.net/get/imagick-3.4.4.tgz | |
| tar xvzf imagick-3.4.4.tgz |
| defmodule MyAppWeb.GettextTest do | |
| use ExUnit.Case | |
| import MyAppWeb.Gettext | |
| # A unit test for Gettext translations that checks if the original and the translation | |
| # use the same HTML tags. | |
| # | |
| # Uses Floki to parse HTML. | |
| describe "translations" do |
| defmodule NestedWeb.FormLive do | |
| use NestedWeb, :live_view | |
| require Logger | |
| defmodule Form do | |
| use Ecto.Schema | |
| import Ecto.Changeset | |
| embedded_schema do | |
| field :name, :string |