Skip to content

Instantly share code, notes, and snippets.

@starch0
starch0 / Elixir.md
Last active April 29, 2024 22:32
Elixir.md

#elixir #article #ongoing

Embarcando no Elixir, Mix e Ecto.

Escrevo este artigo supondo que você, leitor tem noções básicas de programação. Pretendo manter a leitura simples , mas se sua primeira linguagem de programação for Elixir, talvez fique confuso.

Elixir

Elixir é uma linguagem de programação funcional que roda em cima da máquina virtual do ERlang a BEAM.

defmodule TTTMap do
def win?(%{s1: x, s2: x, s3: x}) when not is_nil(x), do: true
def win?(%{s4: x, s5: x, s6: x}) when not is_nil(x), do: true
def win?(%{s7: x, s8: x, s9: x}) when not is_nil(x), do: true
def win?(%{s1: x, s4: x, s7: x}) when not is_nil(x), do: true
def win?(%{s2: x, s5: x, s8: x}) when not is_nil(x), do: true
def win?(%{s3: x, s6: x, s9: x}) when not is_nil(x), do: true
def win?(%{s1: x, s5: x, s9: x}) when not is_nil(x), do: true
def win?(%{s3: x, s5: x, s7: x}) when not is_nil(x), do: true
def win?(_), do: false
@willowiscool
willowiscool / _about.md
Last active December 18, 2021 06:18
An Advent of Code light theme

AOC light theme

This is a light theme for advent of code. style.css contains the style. bookmarklet.html can be visited with rawgit (that's the direct link to bookmarklet.html) to find a bookmarklet that can be dragged to your bookmarks bar and then pressed to make the AOC webpage light.

@evadne
evadne / xmastree.ex
Last active December 16, 2019 06:29
Christmas Trees in Elixir
defmodule Tree do
def print(n) do
for i <- 1 .. n do
p(n - i, " ")
p(i * 2 - 1, "*")
w("\n")
end
p(n - 1, " ")
w("|\n")
end
@mauricioaniche
mauricioaniche / qp.R
Last active October 4, 2016 22:51
Quantile plot in R
# distr <- your data
# logscale <- T if you want it to be at log-scale
qp <- function(distr, logscale) {
x <- c()
y <- c()
qt <- 0.01
for(i in 1:99) {
x <- append(x, qt)
newY <- quantile(distr, c(qt))[1]
@parmentf
parmentf / GitCommitEmoji.md
Last active May 20, 2024 14:58
Git Commit message Emoji
@fbarbirato
fbarbirato / gist:211abbe30be956d21521
Last active August 29, 2015 14:01
Sobre a discussão recente sobre TDD entre DHH, Uncle Bob, Kent Beck e Martin Fowler

Discussão iniciada no grupo tdd-no-mundo-real

Pessoal, desculpe a resposta longa mas esse assunto é muito interessante. Quem hoje em dia, pode acompanhar uma discussão entre grandes pioneiros de sua área que com certeza entrarão para a história da Engenharia de Software nos séculos seguintes? Somos muito afortunados quanto a isso.

Tenho acompanhado essas discussões pelos blogs do DHH e do Uncle Bob.

Achei que deveriam ter incluído o Uncle Bob no hangout. Como disseram que fariam outros episódios, creio que ele deve participar no próximo.

Resumindo o que tirei das opiniões deles:

@adolfont
adolfont / ke.clj
Created July 27, 2012 14:39
Tests e Classe KE
(ns ke)
(defrecord AtomicFormula [name])
;; RUIM
(defmethod print-method AtomicFormula [o w]
(print-simple
(str (:name o))
w
)
@adolfont
adolfont / gist:1169258
Created August 24, 2011 21:12
Truth Assignments in Prolog
% Truth Assignments for Classical Propositional Logica
% Adolfo Neto @adolfont https://github.com/adolfont
% August 24th, 2011
:- dynamic v/1.
% Definitions:
% P is the set of propositional atoms
% Example: P = {p1, p2, p3, ... }