Skip to content

Instantly share code, notes, and snippets.

View Arp-G's full-sized avatar
🎯
Focusing

Arpan Ghoshal Arp-G

🎯
Focusing
View GitHub Profile
@Arp-G
Arp-G / erlang_distribution_essentails.md
Last active August 26, 2023 18:18
Erlang's Distributed System Essentials
  • Erlang nodes communicate with each other using a custom communication protocol called the "Erlang Distribution Protocol”
  • EPMD: Erlang Port Mapper Daemon (EPMD) is typically installed by default alongside Erlang/OTP distribution on most Linux systems. It manages node registration and discovery in distributed Erlang systems. EPMD operates as a separate daemon process, listening on port 4369. The protocol is simple text-based and built on top of TCP/IP. The EPMD process can be started explicitly or automatically as a result of the Erlang node startup(The daemon is started automatically by command erl).

    EPMD acts as a name server on all hosts involved in distributed Erlang computations. When an Erlang node starts, the node has a name and it obtains an address from the host OS kernel. The name and address are sent to the epmd daemon running on the local host. The job of the epmd daemon is to **keep track of which node name li

@Arp-G
Arp-G / segment_schema_validator.ex
Last active February 7, 2023 05:51
Add Segment Typewriter validations to elixir
defmodule SegmentSchemaValidator do
@moduledoc """
This module can be used to validate segment payloads generated by elixir.
It can then help us to add elixir tests which validates segment payloads against the tracking plan.
It relies on the `assets/js/plan.json` file that contains a JSON schema representation of the tracking plans for segment events.
To use this module
* Add the segment typewriter to your application and generate a tracking plan, refer to this [page](https://segment.com/docs/protocols/apis-and-extensions/typewriter/#browser-quickstart)
* Make sure you add the [ex_json_schema](https://hex.pm/packages/ex_json_schema) dependency to your `mix.exs` file: `{:ex_json_schema, "~> 0.9.2"}`
* Copy this module to your project and make any changes if needed
@Arp-G
Arp-G / multipart_s3_upload.js
Created June 18, 2022 08:38
Multipart upload to S3
import fs from 'fs';
import { Buffer } from 'node:buffer';
import {
S3Client,
CreateMultipartUploadCommand,
UploadPartCommand,
CompleteMultipartUploadCommand
} from '@aws-sdk/client-s3';
// 100 MB chunk/part size
@Arp-G
Arp-G / README.md
Created April 16, 2022 15:52 — forked from rbishop/README.md
A super simple Elixir server for sending Server Sent Events to the browser.

Generate a new Elixir project using mix and add cowboy and plug as dependencies in mix.exs:

  defp deps do
    [
      {:cowboy, "~> 1.0.0"},
      {:plug, "~> 0.8.1"}
    ]
  end
defmodule GoGal.BloomFilter do
# Seed values for hash functions
@seed {9_881_409, 7_740_287, 1_822_091, 6_436_985, 6_108_165, 9_294_15, 1_815_555, 1_670_246,
7_190_510, 1_923_245}
# The number of elements to store in the bloom filter
@n 1024
# Bloom filter bit string size (1024*4 = 4096 bit = 512 byte)
@m @n * 4
# The number of hash functions to use given by Kernel.ceil(m / n * Math.log(Math.e(), 2))