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
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
# lib./my_app/entries.ex
defmodule MyApp.Entries do
alias MyApp.Entry
# Aqui, eu espero erros serem retornados (como tuplas)
# ao invés de serem lançados (com throw, etc.)
def create_entry(attrs \\ %{}) do
%Entry{}
|> Entry.changeset(attrs)
|> Repo.insert()
// ==UserScript==
// @name MDN always in en-US
// @version 1
// @grant none
// @match https://developer.mozilla.org/*
// @run-at document-start
// ==/UserScript==
(function () {
const url = document && document.location && document.location.host;
defmodule ListOps do
# Please don't use any external modules (especially List or Enum) in your
# implementation. The point of this exercise is to create these basic
# functions yourself. You may use basic Kernel functions (like `Kernel.+/2`
# for adding numbers), but please do not use Kernel functions for Lists like
# `++`, `--`, `hd`, `tl`, `in`, and `length`.
@spec count(list) :: non_neg_integer
# def count(l), do: count(0, l)
# defp count(counter, []), do: counter
const FruitList = (() => {
// Aqui, PRODUCT_LABELS passa a existir apenas dentro desse bloco,
// o que na prática funciona igual a uma closure.
const PRODUCT_LABELS = {
456: { single: "Apple", plural: "Apples" },
123: { single: "Banana", plural: "Bananas" },
789: { single: "Oranges", plural: "Orangess" },
};
// O fato do nome interno ser o mesmo do nome externo é apenas para