Skip to content

Instantly share code, notes, and snippets.

View guilleiguaran's full-sized avatar
💭

Guillermo Iguaran guilleiguaran

💭
View GitHub Profile
trait Semigroup[A] {
def op(a1: A, a2: A): A
}
trait Monoid[A] extends Semigroup[A] {
def zero: A
}
trait Group[A] extends Monoid[A] {
// Override one or both
require 'gctools/oobgc'
module GC
module OOB
module PumaMiddleware
def self.new(app)
ObjectSpace.each_object(Puma::Server) do |s|
s.extend(self)
end
app
NSURL *url = [NSURL URLWithString:@"ws://localhost:4000/ws"];
// Opens connection to Phoenix
_phoenix = [[Phoenix alloc] initWithURL:url];
[_phoenix setDelegate:self];
[_phoenix open];
// Creates, listens on, and joins channel
_channel = [[PhoenixChannel alloc] initWithTopic:@"locations:1" payload:nil withPhoenix:_phoenix];
[_channel on:@"driver:location" handleEventBlock:^(id message) {
sealed trait InvoiceStatus
case class NoGenerated() extends InvoiceStatus
case class Generated() extends InvoiceStatus
case class Paid() extends InvoiceStatus
case class Invoice[State <: InvoiceStatus](id: Option[Long], value: Long, status: State)
trait InvoiceServices {
defmodule Comision do
defstruct estado: nil
def liquidar(%Comision{} = c) do
%{c | estado: :liquidada}
end
def anular(%Comision{estado: :liquidada} = c) do
%{c | estado: :anulada}
end
def salaries_by_lang(salaries, lang)
salaries.find_all{|x| x[:in_what_technologies_are_you_proficient?] =~ /#{lang}/}
end
# company_type can be for example: multinational, outside, exclusively
def salaries_by_company_type(salaries, company_type)
salaries.find_all{|x| x[:"referring_to_the_company_or_project_that_you_work_for_most_of_the_time:"] =~ /#{company_type}/}
end
@guilleiguaran
guilleiguaran / gist:e00f8a609f0a30e35c18
Last active August 29, 2015 14:15
Salaries for devs that know Ruby.
Colombia salaries:
Total: 77
$0: 1
USD$1 - USD$999: 27
USD$1,000 - USD$1,999: 31
USD$2,000 - USD$2,999: 8
USD$3,000 - USD$3,999: 6
USD$4,000 - USD$4,999: 1
USD$5,000 - USD$5,999: 2
USD$6,000 - USD$6,999: 0
defmodule Math do
def factorial(0), do: 1
def factorial(n) when n > 0 do
n * factorial(n - 1)
end
end
defmodule Enum do
def each([], _fun), do: nil
def each([head | tail], fun) do
fun.(head)
each(tail)
end
end
defmodule Enum do
def map([], _fun), do: []
def map([head | tail], fun) do
[fun.(head) | map(tail)]
end
def reduce([], acc, _fun), do: acc
def reduce([head | tail], acc, fun) do