Skip to content

Instantly share code, notes, and snippets.

const Sequencer = require('@jest/test-sequencer').default;
class CustomSequencer extends Sequencer {
sort(tests) {
const totalPartitionsEnv = process.env.JEST_TOTAL_PARTITIONS;
const partitionEnv = process.env.JEST_PARTITION;
if (totalPartitionsEnv && partitionEnv) {
const totalPartitions = parseInt(totalPartitionsEnv, 10);
const partition = parseInt(partitionEnv, 10);
title description logo
Spotify
Show what you're listening to.
spotify.png
import { getNowPlaying } from '../../lib/spotify';
defmodule App.PhoneNumber do
use Ecto.Type
defstruct country_code: nil,
national_number: nil,
extension: nil,
italian_leading_zero: nil,
number_of_leading_zeros: nil,
raw_input: nil,
country_code_source: nil,

Keybase proof

I hereby claim:

  • I am thiamsantos on github.
  • I am thiamsantos (https://keybase.io/thiamsantos) on keybase.
  • I have a public key ASC2MA2HxSpWfRT57QpLO9ah51fD3oY8vf7-pPUdnEddnAo

To claim this, I am signing this object:

defmodule Bump do
def run do
patterns = [
{"mix.exs", ~r/@version\s"(?<version>\d+.\d+.\d+)"/, &mix_builder/1},
{"README.md", ~r/{:red_mutex,\s*"~>\s*(?<version>\d+.\d+.\d+)"}/, &readme_builder/1}
]
type = type()
{files, new_version} = patterns
@thiamsantos
thiamsantos / pre-commit.sh
Created March 20, 2019 23:42
Precommit format
#!/bin/bash
for file in $(git diff --name-only --staged | sort | uniq | grep ".exs\?")
do
mix format $file
git add $file
done

Usage

Just eval the file right in the beginning of each config.exs file. It will load the env of the .env files every time the project is compiled.

Umbrella

__ENV__.file()
|> Path.dirname()
|&gt; Path.join("../../../config/dotenv.exs")
defmodule Crypto do
def encrypt(data, key) when is_binary(data) and is_binary(key) do
iv = :crypto.strong_rand_bytes(16)
cipher = :crypto.block_encrypt(:aes_cbc256, hash_key(key), iv, pad(data))
Base.encode64("#{iv}#{cipher}")
end
def decrypt(digest, key) when is_binary(digest) and is_binary(key) do
text = Base.decode64!(digest)
valid_branchs = [
"master"
]
"git"
|> System.cmd(["branch"])
|> elem(0)
|> String.split("\n")
|> Enum.map(&String.trim/1)
|> Enum.reject(&match?("", &1))