Skip to content

Instantly share code, notes, and snippets.

View Tuxified's full-sized avatar
⚗️
Elixiring

Tonći Galić Tuxified

⚗️
Elixiring
View GitHub Profile
defmodule Mix.Tasks.ConvertToVerifiedRoutes do
@moduledoc """
Replaces routes with verified routes.
Forked from
https://gist.github.com/andreaseriksson/e454b9244a734310d4ab74d8595f98cd
This requires all routes to consistently be aliased with
alias MyAppWeb.Router.Helpers, as: Routes
Run with

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
@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
@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
@Qqwy
Qqwy / Capturepipe.ex
Last active January 21, 2022 12:55
Elixir example of a pipe-operator that uses some simple metaprogramming to allow piping into capture-syntax.
defmodule Capturepipe do
@doc """
A pipe-operator that extends the normal pipe
in one tiny way:
It allows the syntax of having a bare `&1` capture
to exist inside a datastructure as one of the pipe results.
This is useful to insert the pipe's results into a datastructure
such as a tuple.
@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,
@astutecat
astutecat / create-darwin-volume.sh
Last active November 1, 2021 21:45
Notes on setting up Nix on MacOS.
#!/bin/sh
set -e
root_disk() {
diskutil info -plist /
}
apfs_volumes_for() {
disk=$1
diskutil apfs list -plist "$disk"
@archan937
archan937 / README.md
Last active February 28, 2019 14:51
Alkmaar Elixir Meetup (20-06-2018)

Alkmaar Elixir Meetup demo (20-06-2018)

A simple host and client script written in Elixir. Hosting a little Elixir quiz.

Running locally (on your own computer)

Run the following in two Terminal windows:

iex -r host.ex
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
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"