Skip to content

Instantly share code, notes, and snippets.

View saswata-dutta's full-sized avatar
💭
I may be slow to respond.

Saswata Dutta saswata-dutta

💭
I may be slow to respond.
View GitHub Profile
@saswata-dutta
saswata-dutta / cloudwatch_query.py
Created March 17, 2021 08:37
Query cloudwatch and dump all records
import boto3
import sys
import time
from datetime import datetime, timezone, timedelta
cloudwatch = boto3.client('logs')
logGroupName = "Prod/application.json.log"
queryString = 'filter message like "EMAIL MATCHING:" | fields message'
field = "message"
start = datetime(2021, 1, 29, tzinfo=timezone.utc)
@saswata-dutta
saswata-dutta / SimpleFuture.java
Created February 27, 2021 04:52 — forked from klausbrunner/SimpleFuture.java
A very simple implementation of the Java Future interface, for passing a single value to some waiting thread. Uses a CountdownLatch to ensure thread safety and provide blocking-with-timeout functionality required by Future. Cancellation isn't supported.
public final class ResultFuture implements Future<Result> {
private final CountDownLatch latch = new CountDownLatch(1);
private Result value;
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
}
@Override
@saswata-dutta
saswata-dutta / spark_latest_record.scala
Created February 26, 2021 12:34
Select latest record per id, while merging deltas or snapshots
val df = Seq(
(1,"foo", 123L),
(2,"foo", 123L),
(3,"foo", 123L),
(4,"foo", 123L),
(3,"foo", 124L),
(2,"foo", 123L),
(1,"foo", 122L),
(1,"foo", 120L)
).toDF("id", "meta", "time_stamp").
@saswata-dutta
saswata-dutta / Neptune_reset.sh
Created February 23, 2021 10:47
Reset Neptune Data
#!/bin/bash
echo 'Dropping DB'
_tok=`curl -X POST -H 'Content-Type: application/json' \
https://neptuneinstance-???.???.us-east-1.neptune.amazonaws.com:8182/system \
-d '{ "action" : "initiateDatabaseReset" }' | grep token |awk '{print $3}'`
echo $_tok
curl -X POST -H 'Content-Type: application/json' https://neptuneinstance-???.???.us-east-1.neptune.amazonaws.com:8182/system \
-d '{ "action" : "performDatabaseReset","token" ':$_tok'}'
@saswata-dutta
saswata-dutta / AdvancedDistributedSystemDesignCourseNotes.md
Created January 12, 2021 09:11 — forked from craigtp/AdvancedDistributedSystemDesignCourseNotes.md
Notes on Udi Dahan's Advanced Distributed System Design Course

Advanced Distributed System Design Course - Udi Dahan

Notes by Craig Phillips

Fallacies of Distributed Computing

  • There are 11 fallacies of Distributed Computing:
    1. The network is reliable
    2. Latency isn’t a problem
    3. Bandwidth isn’t a problem
    4. The network is secure
  1. The topology won’t change
@saswata-dutta
saswata-dutta / service-checklist.md
Created January 4, 2021 06:11 — 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?
Disorderly Escape
=================
Oh no! You've managed to free the bunny prisoners and escape Commander Lambdas exploding space station, but her team of elite starfighters has flanked your ship. If you dont jump to hyperspace, and fast, youll be shot out of the sky!
Problem is, to avoid detection by galactic law enforcement, Commander Lambda planted her space station in the middle of a quasar quantum flux field. In order to make the jump to hyperspace, you need to know the configuration of celestial bodies in the quadrant you plan to jump through. In order to do *that*, you need to figure out how many configurations each quadrant could possibly have, so that you can pick the optimal quadrant through which youll make your jump.
There's something important to note about quasar quantum flux fields' configurations: when drawn on a star grid, configurations are considered equivalent by grouping rather than by order. That is, for a given set of configurations, if you exchange the position of any two columns
@saswata-dutta
saswata-dutta / Working Effectively with Legacy Code.md
Created December 25, 2020 10:57 — forked from jeremy-w/Working Effectively with Legacy Code.md
Notes on Michael Feathers' *Working Effectively with Legacy Code*.

Working Effectively with Legacy Code

Notes by Jeremy W. Sherman, October 2013, based on:

Feathers, Michael. Working Effectively with Legacy Code. Sixth printing, July 2007.

Foreword:

  • Software systems degrade into a mess.
  • Requirements ALWAYS change.
  • Your goal as a software developer: Create designs that tolerate change.
@saswata-dutta
saswata-dutta / request_time.py
Created December 18, 2020 13:25 — forked from andrewwatts/request_time.py
urllib2 vs urllib3 vs requests
#!/usr/bin/env python2.7
import time
_URL = 'http://localhost/tmp/derp.html'
_NUMBER = 1000
def test_urllib2():
import urllib2