Skip to content

Instantly share code, notes, and snippets.

View philss's full-sized avatar

Philip Sampaio philss

View GitHub Profile
@philss
philss / bench-from-list.md.livemd
Created March 17, 2022 17:40
Compare from_list/1 and from_map/1

Benchmark Explorer.DataFrame.from_list/1

Deps

Mix.install([
  {:benchee, "~> 1.0.0"},
  {:explorer, github: "kimjoaoun/explorer", branch: "joao/from_list"}
])
@philss
philss / mix.exs
Created December 24, 2019 20:25
Mix project with a flexible config for the Elixir artifacts
defmodule MyApp.MixProject do
use Mix.Project
def project do
[
app: :my_app,
version: "0.1.0",
elixir: "~> 1.5",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
@philss
philss / docker-compose.yml
Created December 24, 2019 20:22
Docker compose config with Elixir artifacts not being shared with host
version: "3.3"
services:
db:
image: postgres:11.1-alpine
ports:
- "5432:5432"
app:
env_file: .env
build:
context: .

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@philss
philss / oban-output.txt
Created June 7, 2019 14:04
Oban output after crashing without finding the table
22:27:17.495 [error] GenServer Oban.Pruner terminating
** (Postgrex.Error) ERROR 42P01 (undefined_table) relation "oban_jobs" does not exist
query: DELETE FROM "oban_jobs" AS o0 USING (SELECT o0."id" AS "id", o0."state" AS "state", o0."queue" AS "queue", o0."worker" AS "worker", o0."args" AS "args", o0."errors" AS "errors", o0."attempt" AS "attempt", o0."max_attempts" AS "max_attempts", o0."attempted_at" AS "attempted_at", o0."completed_at" AS "completed_at", o0."inserted_at" AS "inserted_at", o0."scheduled_at" AS "scheduled_at" FROM "oban_jobs" AS o0 WHERE (o0."state" IN ('completed','discarded')) ORDER BY o0."id" DESC OFFSET $1) AS s1 WHERE (o0."id" = s1."id")
(ecto_sql) lib/ecto/adapters/sql.ex:618: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto_sql) lib/ecto/adapters/sql.ex:551: Ecto.Adapters.SQL.execute/5
(oban) lib/oban/pruner.ex:44: Oban.Pruner.handle_info/2
(stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:388: :gen_server.loop/7
(stdlib) proc_lib.erl:249: :proc_lib.init
@philss
philss / Dockerfile
Created February 20, 2018 03:25
Example of Dockerfile for a Phoenix App
FROM elixir:1.6.0-alpine
RUN mix local.hex --force \
&& mix local.rebar --force \
&& apk --no-cache --update add postgresql-client bash \
&& rm -rf /var/cache/apk/* \
&& mkdir /app
COPY . /app
WORKDIR /app
@philss
philss / docker-compose.yml
Created February 20, 2018 03:23
Example of docker compose for a Phoenix App
version: "3.3"
services:
db:
image: postgres
ports:
- "5432"
web:
build:
context: .
dockerfile: Dockerfile

SML Module System

There is a way to define a namespace in SML: define an "structure" that creates a module.

Example:

structure MyMath =
struct
val pi = 3.141529

Mutual recursion

Every finete state machine that does not need to hold state can be represented by a mutual recursive pair (or more) of functions.

ML specific

You can implement mutual recursion using the built-in and keyword between functions. It is also possible to implement it using a higher order function (a function that receives another function).

@philss
philss / ternjs-with-neovim.md
Last active August 12, 2018 13:26
Some details about my installation of Ternjs with Neovim and Deoplete

Ternjs with Neovim

  • upgrade nvim (in my case, I have the master version):
$ brew tap neovim/neovim
$ brew reinstall --HEAD neovim
  • check Python 2 and 3, if are installed:
$ which python2