Skip to content

Instantly share code, notes, and snippets.

@Lakret
Lakret / gale_shapley.ex
Last active March 1, 2020 18:11
Gale-Shapley stable matching algorithm implementation in Elixir
defmodule StableMatching.Preference do
@enforce_keys [:id, :prefers]
defstruct id: nil, prefers: []
end
defmodule StableMatching.GaleShapley do
alias StableMatching.Preference
@doc """
Solves [stable matching problem](https://en.wikipedia.org/wiki/Stable_marriage_problem#Algorithm)
@Aetherus
Aetherus / scale-out-phoenix-with-websocket.md
Last active February 23, 2024 14:31
How to scale out a Phoenix application with websocket

How to scale out a Phoenix application with websocket

Foreword

It's relatively easy to scale out stateless web applications. You often only need a reverse proxy. But for those stateful web applications, especially those applications that embeds websocket services in them, it's always a pain to distribute them in a cluster. The traditional way is introducing some external services like Redis to handle pubsub, however, in such way, you often need to change your code. Can Erlang/Elixir, the "concurrency oriented programming languages", best other languages in this use case? Has Phoenix framework already integrated the solution of horizontally scaling websocket? I'll do an experiment to prove (or disprove) that.

Resources

@dylanmckay
dylanmckay / facebook-contact-info-summary.rb
Last active July 3, 2025 21:22
A Ruby script for collecting phone record statistics from a Facebook user data dump
#! /usr/bin/env ruby
# NOTE: Requires Ruby 2.1 or greater.
# This script can be used to parse and dump the information from
# the 'html/contact_info.htm' file in a Facebook user data ZIP download.
#
# It prints all cell phone call + SMS message + MMS records, plus a summary of each.
#
# It also dumps all of the records into CSV files inside a 'CSV' folder, that is created
// extract from TELENOR https://ecaf.telenor.com.mm/?orcf=1&lang=my
const townships = [
[
"AhGaYa",
"BaMaNa",
"DaHpaYa",
"HaPaNa",
"HpaKaNa",
"KaMaNa",