Skip to content

Instantly share code, notes, and snippets.

View s8sg's full-sized avatar
🙌
Eventual Consistency

Swarvanu Sengupta s8sg

🙌
Eventual Consistency
View GitHub Profile
@s8sg
s8sg / StringPathChanger.java
Created April 29, 2022 06:20
Java Implementation of String Path Changer (cd <dir>)
package com.codility;
import java.util.EmptyStackException;
import java.util.Stack;
public class StringPathChanger {
public static final String PARENT_DIR_NOTATION = "..";
public static final String SINGLE_SPACE = " ";
public static final String DIR_PARTITION_NOTATION = "/";
@s8sg
s8sg / Condition_AWSSL_FAASFLOW.md
Created July 26, 2019 04:01
Condition is Amazon States Language vs Condition is Faas-flow

Amazon State Language Specification Example WITH CONDITION

{
  "Comment": "An example of the Amazon States Language using a choice state.",
  "StartAt": "FirstState",
  "States": {
    "FirstState": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:us-east-1:123456789012:function:FUNCTION_NAME",
      "Next": "ChoiceState"
@s8sg
s8sg / CrazyScripts.sh
Created June 12, 2019 01:08
Script Command that I use often
# Pull images used in a compose file:
curl -sSL https://raw.githubusercontent.com/openfaas/faas/master/docker-compose.yml | grep image | awk -F " " '{print $NF}' | xargs -L1 docker pull
@s8sg
s8sg / NetworkingFirecracker.md
Last active May 4, 2024 18:51
Networking with Firecracker

Create Bridge interface on the host and give internet access

sudo ip link add name br0 type bridge
sudo ip addr add 172.20.0.1/24 dev br0
sudo ip link set dev br0 up
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables --table nat --append POSTROUTING --out-interface enp3s0 -j MASQUERADE
sudo iptables --insert FORWARD --in-interface br0 -j ACCEPT

Create a tap device and link to the bridge

@s8sg
s8sg / MountVolumeFirecracker.md
Last active February 13, 2022 23:33
Volume Mount Firecracker

Create qcow image

qemu-img create -f qcow2 file.qcow2 100M
sudo mkfs.ext4 file.qcow2

Add drive it to the MicroVM

--add-drive=file.qcow2:rw
@s8sg
s8sg / FirecrackerQuickStart.md
Last active January 14, 2019 04:41
Getting Started With Firecracker

Firecracker - QuickStart

Overview

Overview

Getting Started with a MicroVM

Get Latest Binary

curl -LOJ https://github.com/firecracker-microvm/firecracker/releases/download/v0.13.0/firecracker-v0.13.0
mv firecracker-v0.13.0 firecracker

A quick head around on VLAN

A quick read on Bonding

Bonding is nothing but Linux kernel feature that allows to aggregate multiple like interfaces (such as eth0, eth1) into a single virtual link such as bond0

N-Way bonded interface can survive loss of N-1 physical interfaces

Bonding Mode

Modes of bonding :
@s8sg
s8sg / concurrent.go
Last active January 2, 2019 03:07
Faasflow parralel
func Define(flow *faasflow.Workflow, context *faasflow.Context) (err error) {
dag := faasflow.CreateDag()
dag.AddModifier("ReadAllItems", ReadSoldItemFromKafkaStream)
itemDag := faasflow.CreateDag()
itemDag.AddModifier("FilterRequiredFields", FilterSellBuyPriceFields)
itemDag.AddModifier("SumSellPrice", ComputeTotalSellPrice)
itemDag.AddModifier("SumBuyPrice", ComputeTotalBuyPrice)
// To Serialize multiple input the vertex need an Aggregator
	modified:   audit-event/vendor/github.com/openfaas/openfaas-cloud/sdk/events.go
	new file:   audit-event/vendor/github.com/openfaas/openfaas-cloud/sdk/statuses.go
	modified:   buildshiprun/handler.go
	modified:   buildshiprun/handler_test.go
	modified:   buildshiprun/vendor/github.com/openfaas/openfaas-cloud/sdk/events.go
	new file:   buildshiprun/vendor/github.com/openfaas/openfaas-cloud/sdk/statuses.go
	modified:   docs/DEV.md
	modified:   git-tar/function/handler.go
	modified:   git-tar/function/ops.go