Skip to content

Instantly share code, notes, and snippets.

View rcoproc's full-sized avatar
🙏
I pray to God for our great protection in these difficult times!

Ricardo Oliveira rcoproc

🙏
I pray to God for our great protection in these difficult times!
View GitHub Profile
@rcoproc
rcoproc / install_elixir.md
Created February 2, 2020 01:24 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.

Erlang/Elixir syntax reference

This reference is aimed at allowing you to comfortably read erlang documentation and consume terms printed in Erlang format. It does not aim at allowing you to write Erlang code.

This is a modified version of http://elixir-lang.org/crash-course.html

Data types

Erlang and Elixir have the same data types for the most part, but there are a number of differences.

#!/usr/bin/env elixir
defmodule Committer do
defstruct [:name, :email]
def list(repo) do
repo
|> from_repo
|> Stream.unfold(fn str ->
case String.split(str, "\n", parts: 2, trim: true) do
@rcoproc
rcoproc / mappable.rb
Created February 2, 2020 04:05 — forked from jeffchao/mappable.rb
Implementation of Enumerable.map() in Ruby
# Run using rspec.
# e.g.: rspec file_name.rb
require 'rubygems'
require 'rspec'
module Enumerable
def mymap (&block)
return nil if block.nil?
@rcoproc
rcoproc / 1. SRP .md
Last active April 17, 2020 02:12 — forked from Integralist/1. SRP .md
S.O.L.I.D principles in Ruby

Single responsibility principle

"Em outras palavras, todas as classes complicadas devem ser divididas em classes menores, responsáveis ​​por um comportamento específico, facilitando o entendimento e a manutenção da base de código." https://rubygarage.org/blog/solid-principles-of-ood

Probably the most well known principle, and one that should try to adhere to most of the time.

Let's say you have this code:

  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros
@rcoproc
rcoproc / git.md
Last active February 26, 2020 09:35 — forked from thinkgarden/git.md
[git]