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
| 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 |
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
| 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 |
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
| 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) { |
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
| 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 { |
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 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 |
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
| 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 |
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
| 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 |
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 Math do | |
| def factorial(0), do: 1 | |
| def factorial(n) when n > 0 do | |
| n * factorial(n - 1) | |
| end | |
| end |
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 Enum do | |
| def each([], _fun), do: nil | |
| def each([head | tail], fun) do | |
| fun.(head) | |
| each(tail) | |
| end | |
| end |
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 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 |