Skip to content

Instantly share code, notes, and snippets.

[{"high": 1.77, "exp_date": "2019-10-28", "open_interest": 52929.0, "ask_size": 22.0, "open": null, "id0": 212299066, "mark": 1.125, "low": 0.91, "theta": -0.150152, "symbol": "SPY", "bid_size": 204.0, "strike_price": 300.0, "bid": 1.12, "volume": 3135.0, "rho": 0.016476, "delta": 0.50502, "ask": 1.13, "putorcall": "call", "vega": 0.125255, "time": "2019-10-24 10:45:31.629851-04:00", "implied_volatility": 0.089325, "gamma": 0.142229}, {"high": 1.77, "exp_date": "2019-10-28", "open_interest": 52929.0, "ask_size": 219.0, "open": null, "id0": 212301985, "mark": 1.115, "low": 0.91, "theta": -0.150697, "symbol": "SPY", "bid_size": 2.0, "strike_price": 300.0, "bid": 1.11, "volume": 3147.0, "rho": 0.016336, "delta": 0.500766, "ask": 1.12, "putorcall": "call", "vega": 0.125252, "time": "2019-10-24 10:46:03.964989-04:00", "implied_volatility": 0.089731, "gamma": 0.14161}, {"high": 1.77, "exp_date": "2019-10-28", "open_interest": 52929.0, "ask_size": 440.0, "open": null, "id0": 212304939, "mark": 1.115, "low": 0.91, "t
@aashidham
aashidham / rsync.sh
Last active July 23, 2019 06:35
Attempt at using overlay2 syncing (failed)
rsync --update -raz --progress \
-e "ssh -oStrictHostKeyChecking=no -i /home/ubuntu/.ssh/id_ed25519" \
/var/lib/docker/overlay2/ root@34.73.55.210:/var/lib/docker/overlay2/
# make sure you add key to root ~/.ssh/authorized_keys
# run this from root shell
#prior usage (inside ent-dev) (for seperate purpose)
rsync --progress --delete -rtLv \
-e "ssh -oStrictHostKeyChecking=no -i /home/ubuntu/.ssh/container" \
@aashidham
aashidham / image_move.sh
Last active July 23, 2019 20:10
Move images (in reverse order of the default) to another host without using a registry
sudo docker images -aq | \
sed '1!G;h;$!d' | \
xargs -I % bash -c "echo %; sudo docker save % | bzip2 | pv | \
ssh ubuntu@ent-prod-pg.benuku.com 'bunzip2 | sudo docker load'"
# sed just flips the order of sudo docker images -q
# need quotes within quotes to do remote exec and use xargs at the same time
@aashidham
aashidham / install.sh
Last active July 26, 2019 08:11
installing node / npm without sudo
# zild
cd ~
curl -O https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x64.tar.xz
#or alternately for OSX, run the below and replace "node-v6.9.2-linux-x64"
#in the rest of these invocations with "node-v6.9.2-darwin-x64."
#curl -O https://nodejs.org/dist/v8.11.3/node-v8.11.3-darwin-x64.tar.xz
tar xf node-v8.11.3-linux-x64.tar.xz
mkdir -p ~/.node/
cp -R ~/node-v8.11.3-linux-x64/* ~/.node/
rm -rf node-v8.11.3-linux-x64*
@aashidham
aashidham / analyze_mem.py
Created February 16, 2019 18:04
Write memory footprint to stdout every second
import os
import time
while True:
os.system("ps u -p 7916 | awk '{sum=sum+$6}; END {print sum/1024}' | ts '[%Y-%m-%d %l:%M:%S %p]'")
time.sleep(1)
@aashidham
aashidham / free_mem.sh
Last active June 1, 2018 15:41
On ubuntu where free is installed, log the memory usage over time
free -h| grep Mem | awk -v date="$(date)" '{ print date, "==>" , $4 }'
#another option is '{ print date, "==>" , int($3/$2*100) }' for percentage of used memory
#more here: https://serverfault.com/questions/649024/one-line-script-to-check-and-react-to-memory-usage
@aashidham
aashidham / max_open.sh
Created April 30, 2018 04:31
Determine number of maximum established connections to a server over time
#!/usr/bin/env bash
peak=0
while true; do
sleep 0.1
sample="$(netstat -an | grep ESTABLISHED | wc -l)"
let peak='sample > peak ? sample : peak'
echo "$peak (curr is $sample)"
done
TFSC
TFSCR
TFSCU
TFSCW
PIH
FLWS
FCCY
SRCE
VNET
TWOU
import bisect, time
#this module makes use of the bisect module, especially bisect.bisect_left().
#see https://docs.python.org/2/library/bisect.html for details.
class SlidingCounter(object):
def __init__(self):
self.event_arr = []
@aashidham
aashidham / forward.js
Created March 8, 2017 19:41
Demonstrates the problem I have with port forwarding and node web server integration
var httpProxy = require('http-proxy');
var express = require('express');
var fs = require('fs');
var net = require('net');
var Client = require('ssh2').Client;
var conn = new Client();
var pk = 'insert private_key here';