Skip to content

Instantly share code, notes, and snippets.

View gtcarlos's full-sized avatar

Guilherme Carlos gtcarlos

View GitHub Profile
No que me diz respeito à essa questão eu percebo que essa mulher ignora totalmente o patriarcado dominante na sociedade.
Ela tem ideias bem interessantes quanto a auto-defesa da mulher, estar preparada para lutar de volta mas isso aí é só uma
contra-medida.
Pelo que vi *desse trecho* do discurso dela, ela não quer que os estupros acabem, ela quer que as mulheres saibam se defender
deles porque o mundo é selvagem, arriscado e cheio de perigos

(my response to https://twitter.com/apotonick/status/717105889845624832)

I haven't yet came across readily available resources for large-scale application architecture for Elixir apps. I found Programming Phoenix to be a good start for that though. And there's ~30 years of knowledge in the Erlang land :)

For web apps, I found the abstractions that Elixir/Phoenix provides to be really helpful. Indeed, the list below is somewhat ORM focused.

In the small, Ecto.Schema, Ecto.Query, Ecto.Changeset, and Phoenix.View allow me to build highly composable and side-effect free modules. I can have many schemas, changesets and queries all interacting with the same underlying DB table(s) if I want to. Most of the side-effects (through Ecto.Repo for DBs) are usually in the Phoenix.Controller (or other Plugs).

@gtcarlos
gtcarlos / cracklepop.ex
Created January 18, 2016 12:47
Crackle Pop Elixir
defmodule CracklePop do
def cpop(n) when rem(n, 3) == 0 and rem(n, 5) == 0, do: "CracklePop"
def cpop(n) when rem(n, 3) == 0, do: "Crackle"
def cpop(n) when rem(n, 5) == 0, do: "Pop"
def cpop(n), do: n
end
1..100 |> Enum.map(&CracklePop.cpop(&1))
Verifying that +gtcarlos is my blockchain ID. https://onename.com/gtcarlos
@gtcarlos
gtcarlos / guard_if.exs
Created September 21, 2015 17:21
Guard clauses vs If
defmodule GuardIf do
def if_double(0), do: [0]
def if_double(n) do
if rem(n, 2) == 0 do
if_double(n - 1) ++ [n]
else
if_double(n - 1)
end
end
@gtcarlos
gtcarlos / chop.ex
Last active August 29, 2015 14:23
Guess exercise in Elixir from PragProg's Programming Elixir book
defmodule Chop do
def guess(actual, range) do
low..high = range
mid = div(low + high, 2)
IO.puts("Is it #{mid}")
_guess(actual, low, high, mid)
end
@gtcarlos
gtcarlos / github_repo
Created May 18, 2015 12:56
Create Github repositories from command line
#!/usr/bin/env ruby
# encoding: UTF-8
user = '<YOUR USERNAME HERE>'
puts 'Repository Name:'
name = gets.chomp
puts 'Repository Description:'
description = gets.chomp
using System.IO;
using System;
class Program
{
static void Main()
{
DateTime date1 = new DateTime(2015, 03, 18, 04, 33, 00);
DateTime date2 = new DateTime(2015, 03, 18, 05, 33, 00);
double hours = date2.Subtract(date1).TotalHours;
#include <stdio.h>
int main ()
{
float peso_ideal, peso_atual, altura;
char sexo;
do {
printf("Digite sua altura: ");
scanf("%f", &altura);
#include <stdio.h>
int main ()
{
float peso_ideal, peso_atual, altura;
char sexo;
do
{
printf ("Digite sua altura em metros e seu sexo.\nSe seu sexo for masculino digite M\nSe seu sexo for feminino digite F\n");