Skip to content

Instantly share code, notes, and snippets.

View sescobb27's full-sized avatar
🇨🇴
sisas parce

Simon Escobar Benitez sescobb27

🇨🇴
sisas parce
View GitHub Profile
defmodule MergeCommonPlaces do
def merge_places([]), do: []
def merge_places([place | rest]) do
{similar_places, rest_places} =
Enum.reduce(rest, {[], []}, fn plc, {same_places, rest} ->
if same_place?(place, plc) do
{[plc | same_places], rest}
else
{same_places, [plc | rest]}
end
defmodule BG.Aggregator.Supervisor do
use Supervisor
@name BG.Aggregator.Supervisor
def start_link() do
Supervisor.start_link(__MODULE__, :ok, name: @name)
end
def init(:ok) do
num_aggregator_consumers = Application.get_env(:twd, :num_aggregator_consumers, 5)
@sescobb27
sescobb27 / libcluster_rabbit.ex
Created December 21, 2017 15:16 — forked from narrowtux/libcluster_rabbit.ex
RabbitMQ strategy for libcluster
defmodule Cluster.RabbitStrategy do
use GenServer
use Cluster.Strategy
import Cluster.Logger
alias Cluster.Strategy.State
@routing_key "cluster.heartbeat"
def start_link(opts) do
@sescobb27
sescobb27 / repo_stream.ex
Created December 21, 2017 15:16 — forked from narrowtux/repo_stream.ex
Module for Ecto and GenStage to work together when you want to use Repo.stream in conjunction with a GenStage subscriber or a Flow.
defmodule RepoStream do
defmodule Producer do
use GenStage
defstruct [:demand, :pid]
def start_link() do
GenStage.start_link(__MODULE__, self())
end
Tinkko - http://tinkko.com
Selina :unicorn_face: - https://www.selina.com/cowork-medellin/
Nodo-coworking - https://nodo.space/coworking-nodo/
Co-Work Latam - http://www.rutanmedellin.org/es/ciudad/item/en-noviembre-se-abrira-el-espacio-de-co-working-mas-grande-de-la-ciudad
Ruta N - https://www.coworklatam.com/sedes/colombia-medellin-ruta-n/
Epicentro - http://www.epicentro.com.co/espacio.html
require 'benchmark'
class Array
def my_map
self.inject([]) do |arr, elm|
arr << (yield elm)
end
end
def filter_map fn
@sescobb27
sescobb27 / deploying_phoenix_on_dokku.md
Created October 7, 2016 17:00 — forked from henrik/deploying_phoenix_on_dokku.md
Deploying Elixir's Phoenix Framework on Dokku.

Deploying Phoenix on Dokku

Worked 2015-09-08 for Phoenix 1.0.1 on Dokku 0.3.25.

These instructions assume you've set up Dokku. If not, go find a tutorial for that part. My notes for setting it up on Digital Ocean.

On your local machine, in the app's repo

Create a Dokku app:

@sescobb27
sescobb27 / Model.coffee
Created September 26, 2016 15:51 — forked from GeoffreyBooth/Model.coffee
Ember.js rollback relationships, including deletions of child objects
# RollbackAttributes should also rollback relationships
# Based on http://stackoverflow.com/a/27184207/223225 and https://github.com/emberjs/rfcs/pull/21#issuecomment-135134132
DS.Model.reopen
rollbackAttributes: ->
@_super()
@rollbackRelationships()
cacheOriginalRelations: ->
@sescobb27
sescobb27 / gproc_tests.erl
Created September 25, 2016 15:18 — forked from rustyio/gproc_tests.erl
gproc_tests.erl
-module(gproc_tests).
-compile(export_all).
-include_lib("stdlib/include/qlc.hrl").
go() -> make:all([load]).
register_stuff() ->
gproc:reg({n, l, key1}, value1),
gproc:reg({n, l, key2}, value2),
gproc:reg({n, l, key3}, value3),
@sescobb27
sescobb27 / service-checklist.md
Created September 15, 2016 00:58 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?