Skip to content

Instantly share code, notes, and snippets.

from typeguard import install_import_hook, TypeguardFinder, config
# COPY-PASTE SOLUTION: Custom TypeguardFinder with Debug Configuration
# Step 1: Configure debug instrumentation
config.debug_instrumentation = True # Set to False to disable debug
# Step 2: Define packages to instrument
packages_to_instrument = [
'grpc.aio',
'grpc.aio._channel',
@apoorvparijat
apoorvparijat / async-new.java
Created April 11, 2023 14:26
Completion handler
import org.asynchttpclient.*;
import org.asynchttpclient.AsyncHandler;
import org.asynchttpclient.HttpResponseBodyPart;
import org.asynchttpclient.HttpResponseHeaders;
import org.asynchttpclient.HttpResponseStatus;
public class MyAsyncHandler implements AsyncHandler<String> {
private final StringBuilder responseBodyBuilder = new StringBuilder();
@Override
@apoorvparijat
apoorvparijat / async.java
Created April 11, 2023 13:39
How to use injected variable in AsyncHandler
import org.asynchttpclient.*;
import java.util.concurrent.Future;
public class MainClass {
private final String injectedVariable = "Hello, AsyncHandler!";
public static void main(String[] args) {
MainClass mainClass = new MainClass();
mainClass.sendRequest();
}
@apoorvparijat
apoorvparijat / docker-user-permission.sh
Created October 3, 2020 16:30
Docker User Permission
sudo usermod -aG docker $USER
@apoorvparijat
apoorvparijat / install-tmux.sh
Last active June 22, 2020 07:28 — forked from pokev25/install-tmux.sh
Install tmux 2.8 on centos 7
# Install tmux 3.0 on Centos
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -LOk https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz
tar -xf libevent-2.1.11-stable.tar.gz
cd libevent-2.1.11-stable
./configure --prefix=/usr/local
@apoorvparijat
apoorvparijat / curl-format.txt
Created March 1, 2019 06:45
Curl format.txt for debugging latency with curl
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
@apoorvparijat
apoorvparijat / role_arn_to_session.py
Created January 3, 2019 09:32 — forked from gene1wood/role_arn_to_session.py
Simple python function to assume an AWS IAM Role from a role ARN and return a boto3 session object
import boto3
def role_arn_to_session(**args):
"""
Usage :
session = role_arn_to_session(
RoleArn='arn:aws:iam::012345678901:role/example-role',
RoleSessionName='ExampleSessionName')
client = session.client('sqs')
"""
@apoorvparijat
apoorvparijat / gist:09dd0be9b7a47594a52aba514734effb
Last active January 3, 2019 08:50
Zipping Service JSON payload
{
"files": [
"https://s3.amazonaws.com/test/le123.jpeg","https://s3.amazonaws.com/test/sample123.jpeg","https://s3.amazonaws.com/test/sample123.jpeg"
]
"postback_url": "<url>",
"output": {
"bucket": "<bucket-name>",
"file_path": "<directory>/<directory>/<zip-file-name>.zip"
}
}
@apoorvparijat
apoorvparijat / docker-cleanup-resources.md
Created December 24, 2018 12:53 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@apoorvparijat
apoorvparijat / update-security-group.sh
Created December 24, 2018 09:37
Update Security Group Rule
#!/bin/bash
PREVIOUS_IP=`cat previous-ip.txt`
aws ec2 revoke-security-group-ingress \
--region ap-south-1 \
--group-id sg-01d93e4e5fd0fe634 \
--protocol -1 \
--cidr $PREVIOUS_IP
PUBLIC_IP=`curl --silent v4.ifconfig.co | awk '{ print $0 "/32" }'`