Skip to content

Instantly share code, notes, and snippets.

View almoorthi's full-sized avatar

Moorthi almoorthi

View GitHub Profile
@almoorthi
almoorthi / dummy-web-server.py
Created June 4, 2018 07:11 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
/**
* This script will automatically sync all updates from one database to another. It is meant to be run while
* syncing the database using mongodump and mongorestore.
*
* Example:
* node livesync.js mongodb://<user>:<pass>@dbhost.com:10645/app-production \
* mongodb://<user>:<pass>@dbhost.com:10499/local?authSource=app-production \
* app-production \
* mongodb://<user>:<pass>@newdbhost.com/app-prod
*/
@almoorthi
almoorthi / clickhousedump
Created May 22, 2020 05:51 — forked from inkrement/clickhousedump
dump all clickhouse databases and tables
#!/bin/bash
OUTDIR=.
while read -r db ; do
while read -r table ; do
if [ "$db" == "system" ]; then
echo "skip system db"
continue 2;
@almoorthi
almoorthi / deletes3files.sh
Created March 13, 2023 10:27
delete aws s3 files in a bucket older than specified days
#!/bin/bash
# Usage: ./deletes3files.sh "bucketname" "30 days"
olderThan=$(date -d "-$2" +%s)
s3cmd ls s3://$1 | while read -r line;
do
createDate=$(echo $line|awk {'print $1" "$2'})
createDate=$(date -d "$createDate" +%s)
"""
Non blocking example:
1. Browse to `localhost:8000/sleep1`
2. Browse to `localhost:8000/`
You'll observe that the first call will take 5 seconds and the second call will be executed immediately.
Blocking example:
1. Browse to `localhost:8000/sleep2`
2. Browse to `localhost:8000/`
@almoorthi
almoorthi / img-url-exif.sh
Created February 15, 2024 06:30 — forked from joshskidmore/img-url-exif.sh
img-url-exif.sh
#!/usr/bin/env bash
# Josh Skidmore <[email protected]>
# Basic example of using an HTTP range header to extract EXIF data
# from a JPEG file without having to download the entire image.
# This has no error handling and assumes the EXIF data is embedded
# within the first $KB_TO_DOWNLOAD kilobytes of the image
# Requirements:
# * curl
#usecase: remove pdf password, os: works in MacOS10+
#pre-requisite: brew install qpdf;
qpdf --password='file-password' --decrypt password-protected-file.pdf file-without-password.pdf