Skip to content

Instantly share code, notes, and snippets.

View joeljuca's full-sized avatar
👨‍💻
Working on smt new

Joel Jucá joeljuca

👨‍💻
Working on smt new
View GitHub Profile
defmodule MyApp.Accounts do
# (...)
@spec sign_up(params :: %{String.t() => String.t()}) ::
{:ok, User.t()} | {:error, Ecto.Changeset.t()}
def sign_up(%{} = params) do
# Here, a list of params and their types
params_schema = %{
name: :string,
# (...)
@joeljuca
joeljuca / SlotMachine.js
Created August 18, 2024 14:15
A highly questionable (from an ethical POV) implementation of a slot machine
var SlotMachine = (function () {
//prettier-ignore
var invalidBetError = new Error("Bet should be a number between 1 and 10");
/**
* @params params Object { maxRounds: number, maxWins: number }
*/
var SlotMachine = function (params) {
var winCount = 0;
var roundCount = 0;
defmodule MyApp.Accounts do
# (...)
def sign_up(%{} = params) do
params_schema = %{
name: :string,
email: :string,
phone: :string,
password: :string
}
defmodule MyApp.Accounts do
import Ecto.Changeset
def sign_up(%{} = params) do
params_schema = %{
name: :string,
email: :string,
phone: :string,
password: :string
}
const change = (payment, coins) => {
let _change = {},
remaining = payment;
for (let i = 0; i < coins.sort((x, y) => (x < y ? 1 : -1)).length; i++) {
const coin = coins[i];
console.log({ coin });
_change[`${coin}`] = Math.floor(remaining / coin);
#!/usr/bin/env bash
rm_old_branches() {
# rm_old_branches
#
# Quo corporis ea tempore quisquam ducimus. At tempore nemo qui et distinctio
# consectetur quia quaerat. Et quia aliquam ad sed aut libero.
#
# Non deleniti eligendi est explicabo harum qui. Consequatur et assumenda
# aperiam eligendi ut error odit aut. In ut dolores nobis harum facilis vero
# Snippet provided by the Slab Engineering Team
input = [
%{"text" => "One", "indent" => 0, "type" => "ordered"},
%{"text" => "Two", "indent" => 0, "type" => "ordered"},
%{"text" => "Alpha", "indent" => 1, "type" => "bullet"},
%{"text" => "Beta", "indent" => 1, "type" => "bullet"},
%{"text" => "I", "indent" => 2, "type" => "ordered"},
%{"text" => "II", "indent" => 2, "type" => "ordered"},
%{"text" => "Three", "indent" => 0, "type" => "ordered"}
]
# #!/usr/bin/env sh
# https://dragoshmocrii.com/fix-vscode-elixirls-intellisense-for-code-imported-with-use/
function elixirls_update() {
if ! ls "${HOME}/.vscode/extensions" | grep "^jakebecker.elixir-ls"; then
echo "Aborting operation - extension not installed."
else
local extension_dirname="$(ls -1 ${HOME}/.vscode/extensions | grep '^jakebecker.elixir-ls' | head -n 1)"
function number-only() {
if test ! -t 0; then
strlen "$(</dev/stdin)"
else
echo -n $@ |
xargs |
sed -E "s/[^0-9]+//g"
fi
}
defmodule Sorteio do
@moduledoc false
@people """
Fernando Collor
Fernando Henrique Cardoso
Luiz da Silva
"""
def people do