Skip to content

Instantly share code, notes, and snippets.

View Tuxified's full-sized avatar
⚗️
Elixiring

Tonći Galić Tuxified

⚗️
Elixiring
View GitHub Profile
@novaugust
novaugust / 1_rewriting_a_codebase_with_sourceror.exs
Last active March 1, 2023 21:35
Credo Rewrites Via Sourceror
# for an example of a suggested `locals_without_parens`, see z_locals_without_parens.exs
# parsing and expanding a formatter.exs file would be a good route too
opts = [sourceror_opts: [locals_without_parens: [...], line_length: 122]]
for transformation <- [&PipeChainStart.run/1, &SinglePipe.run/1] do
ProjTraversal.transform("../my_codebase/", transformation, opts)
end
Originally from: http://erlang.org/pipermail/erlang-questions/2017-August/093170.html
For a safe and fast Erlang SSL server, there's a few
configuration values you might want by default:
[{ciphers, CipherList}, % see below
{honor_cipher_order, true}, % pick the server-defined order of ciphers
{secure_renegotiate, true}, % prevent renegotiation hijacks
{client_renegotiation, false}, % prevent clients DoSing w/ renegs
{versions, ['tlsv1.2', 'tlsv1.1']}, % add tlsv1 if you must
@aaronjensen
aaronjensen / drain_stop.ex
Last active November 28, 2022 06:59
Phoenix Drain Stop
# 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.
@mmmries
mmmries / 01.README.md
Last active November 11, 2022 16:59
Load Test Phoenix Presence

Phoenix Nodes

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'
@jt
jt / merge.md
Created August 23, 2011 18:47
Merge a forked gist

If someone forks a gist and you'd like to merge their changes. Do this:

  1. clone your repo, I use the name of the gist

     git clone git://gist.github.com/1163142.git gist-1163142
    
  2. add a remote for the forked gist, I'm using the name of my fellow developer

     git remote add aaron git://gist.github.com/1164196.git
    
@giuseppeg
giuseppeg / fuzzbuzz.js
Last active July 6, 2022 08:55
FizzBuzz solution with just one comparison:Bitwise operations, using predefined 0-15 numbers masksource: http://www.zoharbabin.com/which-fizzbuzz-solution-is-the-most-efficient
// FizzBuzz solution with one comparison:
// Bitwise operations, using predefined 0-15 numbers mask
// live demo: http://jsfiddle.net/TbAuQ/
// source: http://www.zoharbabin.com/which-fizzbuzz-solution-is-the-most-efficient
var words = [undefined, "Fizz", "Buzz", "FizzBuzz"],
mask = 810092048, //11 00 00 01 00 10 01 00 00 01 10 00 01 00 00
c = 0;

Install makeself:

apt-get install makeself

or

brew install makeself

Neural network from scratch in ... Elixir

Pure Elixir initial version test

inputs = [1, 2, 3, 2.5]
weights = [0.2, 0.8, -0.5, 1.0]
bias = 2.0
@spec as_ast(%{
body: binary,
declaration: bitstring,
documentation: bitstring,
elixir_module: %{documentation: bitstring, slug: bitstring},
elixir_typespec: %{inputs: bitstring, return: bitstring},
guards: binary,
inputs: bitstring,
name: bitstring,
slug: integer,
@cararemixed
cararemixed / .iex.exs
Created January 5, 2021 16:58
Some utility code.
defmodule C do
def decompile(module, lang \\ :erlang)
def decompile(module, lang) when is_atom(module) do
decompile(:code.which(module), lang)
end
def decompile('', _) do
# When we get this, it's because a module name was passed