Skip to content

Instantly share code, notes, and snippets.

View sumitsk20's full-sized avatar
Doing epic shit

Sumeet Bhardwaj sumitsk20

Doing epic shit
View GitHub Profile
@sumitsk20
sumitsk20 / zerodha_kite_tick_candle_converter.py
Created June 18, 2024 21:45
Python code that mimic the zerodha websocket behaviour and on_tick() functionality of KiteTicker, convert the tick to candles of different timeframe dynamically and very efficiently using in memory queue, after complete formation of one candle appending to a HDF Store which is efficient for financial data r/w
from collections import defaultdict, deque
import pandas as pd
import datetime
import queue
from threading import Thread
import time
import random
# Data structure to store tick data for each instrument
candles = defaultdict(lambda: defaultdict(lambda: list))
@sumitsk20
sumitsk20 / nginx-socketio-ssl-reverse-proxy.conf
Created February 26, 2020 09:44 — forked from gmanau/nginx-socketio-ssl-reverse-proxy.conf
How to setup nginx as nodejs/socket.io reverse proxy over SSL
upstream upstream-apache2 {
server 127.0.0.1:8080;
}
upstream upstream-nodejs {
server 127.0.0.1:3000;
}
server {
listen 80;
import traceback
from itertools import cycle
import bs4 as bs # pip intsall bs4
import re
import csv
import requests # pip intsall requests
import json
from random import randint
from time import sleep
from lxml.html import fromstring # pip intsall lxml
@sumitsk20
sumitsk20 / amazon_sentence_scrapper.py
Created April 9, 2019 06:35
Script to parse an user input sentence from amazon by pickup words to recreate the following sentence
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import urllib.request
import urllib.parse
from urllib.parse import quote_plus
print("Enter sentence to parse from amazon\n\nExample:'Virtue signalling is society's version of Proof of Stake'\n\n")
query = input()
@sumitsk20
sumitsk20 / backup-mongodb-to-s3.sh
Created January 11, 2019 07:08 — forked from caraboides/backup-mongodb-to-s3.sh
Simple script to backup MongoDB to S3, without waste diskspace for temp files. And a way to restore from the latest snapshot.
#!/bin/sh
set -e
HOST=localhost
DB=test-entd-products
COL=asimproducts
S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
S3LATEST=$S3PATH"latest".dump.gz
/usr/bin/aws s3 mb $S3PATH
@sumitsk20
sumitsk20 / mongodb-s3-backup.sh
Created January 11, 2019 07:08 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@sumitsk20
sumitsk20 / nginx-medium-post.conf
Created August 26, 2018 02:20
nginx config file for uwsgi
upstream updateMe_dev {
server unix:/webapps/updateMe/run/uwsgi.sock;
}
server {
listen 80;
server_name your-IP-or-address-here;
charset utf-8;
client_max_body_size 128M;
@sumitsk20
sumitsk20 / uwgi-service-medium-post.service
Last active September 1, 2018 08:39
uwsgi.service to create systemd service in linux
[Unit]
Description=uWSGI instance to serve updateMe project
After=network.target
[Service]
User=bunny
Group=webapps
WorkingDirectory=/webapps/project_name/src
Environment="PATH=/webapps/project_name/bin"
ExecStart=/webapps/project_name/bin/uwsgi --ini /webapps/project_name/conf/uwsgi.ini
@sumitsk20
sumitsk20 / uwgi-medium-post.ini
Last active January 30, 2024 07:58
uwsgi configuration with most commonly sused options for highly scalable website (medium blog post)
[uwsgi]
# telling user to execute file
uid = bunny
# telling group to execute file
gid = webapps
# name of project you during "django-admin startproject <name>"
project_name = updateMe
@sumitsk20
sumitsk20 / uwsgi.ini
Created August 25, 2018 18:47
uwsgi configuration file for scaling django website. I have included most widely used options that you may want to configure.
[uwsgi]
# name of project you during "django-admin startproject <name>"
project_name = updateMe
# just a directory name i use for different server deployment
branch = develop
# building base path to where project directory is present [In my case this dir is also where my virtual env is]
base_dir = /home/ubuntu/webapps/%(project_name)/%(branch)