Skip to content

Instantly share code, notes, and snippets.

Avatar
👻

Matteo Giachino matteosister

👻
View GitHub Profile
@matteosister
matteosister / ot_tracing_new.rs
Last active Nov 30, 2020
opentelemetry tracing update
View ot_tracing_new.rs
// with these deps it compiles, but the global tracer do not log anything
// tracing = { version = "^0.1.21" }
// tracing-subscriber = "^0.2.15"
// tracing-opentelemetry = "^0.9.0"
// tracing-futures = "^0.2.4"
// opentelemetry = { version = "^0.10.0" }
// opentelemetry-jaeger = { version = "^0.9.0", features = ["collector_client"] }
//
// I call this from main with
// let uninstall = Tracing::initialize().expect("unable to initialize tracing");
View elm compile time
rm -rf elm-stuff/build-artifacts/ && time sysconfcpus -n 1 ./node_modules/.bin/elm-make elm/Crash.elm
Success! Compiled 260 modules.
Successfully generated index.html
real 1m33.461s
user 1m31.141s
sys 0m2.268s
===================================================================
@matteosister
matteosister / .formatter.exs
Last active Jun 5, 2018
formatter config file
View .formatter.exs
[
inputs: ["lib/**/*.{ex,exs}", "test/**/*.{ex,exs}"],
locals_without_parens: [
# plug
plug: :*,
parse: :*,
serialize: :*,
value: :*,
match: :*,
@matteosister
matteosister / pre-commit
Created Jun 15, 2016
pre-commit hook for elixir
View pre-commit
#!/bin/sh
# credo checks before commit
mix credo
CREDO_RES=$?
if [ $CREDO_RES -ne 0 ]
then
exit $CREDO_RES
fi
@matteosister
matteosister / circle.yml
Created Feb 10, 2016
circle for elixir builds
View circle.yml
dependencies:
pre:
- config/circleci/prepare.sh
cache_directories:
- ~/dependencies
- ~/.mix
- _build
- deps
test:
View infix_use.ex
defmodule TestInfix do
import InfixFC
def invert(what) do
what |> String.graphemes |> Enum.reverse |> Enum.join
end
def inverted_and_stripped_upcase(subject) do
func = (&invert/1) <|> (&String.upcase/1) <|> (&String.strip/1)
func.(subject)
View infix_operator.ex
defmodule InfixFC do
@doc """
define an infix operator <|> to compose functions
"""
defmacro left <|> right do
quote bind_quoted: [left: left, right: right] do
fn (v) -> left.(right.(v)) end
end
end
View simple_function_composition.exs
defmodule SimpleFC do
require Integer
def even(n), do: Integer.is_even(n)
def negate(n), do: not n
def compose(func1, func2) do
fn (n) ->
func2.(func1.(n))
end
View function_composition.exs
defmodule PipeFunctionComposition do
require Integer
def even(n), do: Integer.is_even(n)
def negate(n), do: not n
def multiply_by(n, factor), do: n * factor
@doc """
true if the passed number is not even
"""
View function_composition.hs
even :: Int -> Bool
not :: Bool -> Bool
isnoteven :: Int -> Bool
isnoteven = not . even
even(10) -- True
not(True) -- False
isnoteven(9) -- True