This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Sorteio do | |
@moduledoc false | |
@people """ | |
Fernando Collor | |
Fernando Henrique Cardoso | |
Luiz da Silva | |
""" | |
def people do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule TwitterClient do | |
use Tesla | |
@token System.get_env("TWITTER_TOKEN") | |
plug(Tesla.Middleware.BaseUrl, "https://api.twitter.com") | |
plug(Tesla.Middleware.DecodeJson) | |
def get_tweets do | |
{:ok, response} = make_request() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
person = :joel | |
given_person = :john | |
case given_person do | |
^person -> "Hi, Joel!" | |
person -> "Hi, #{person}!" | |
end | |
# => "Hi, john!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type DocumentVersion = { | |
// CouchDB's own ID system | |
_id: string; | |
// Your document history ID - the same across all versions of a document | |
historyId: string; | |
// The _id of the ancestor document (undefined if first version) | |
parentId: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Option = ({ option, onChange }) => { | |
return ( | |
<label for=""> | |
<option onChange={onChange} /> {option.title} | |
</label> | |
); | |
}; | |
const Question = ({ question, onSubmit }) => { | |
return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IIFE - Immediately Invoked Function Expression | |
(function () { | |
"use strict" | |
console.log("I'm inside a private scope!") | |
})() |