Skip to content

Instantly share code, notes, and snippets.

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

Praveen Jha praveenjha527

💭
I may be slow to respond.
View GitHub Profile
@praveenjha527
praveenjha527 / aws-temp-token.sh
Created December 27, 2019 10:05 — forked from ogavrisevs/aws-temp-token.sh
Script to generate AWS STS token
#!/bin/bash
#
# Sample for getting temp session token from AWS STS
#
# aws --profile youriamuser sts get-session-token --duration 3600 \
# --serial-number arn:aws:iam::012345678901:mfa/user --token-code 012345
#
# Based on : https://github.com/EvidentSecurity/MFAonCLI/blob/master/aws-temp-token.sh
#
@praveenjha527
praveenjha527 / gist:7286782c96a26ca660741117b5951ab3
Created November 7, 2017 14:06 — forked from tott/gist:3895832
create cpu load in python
#!/usr/bin/env python
"""
Produces load on all available CPU cores
"""
from multiprocessing import Pool
from multiprocessing import cpu_count
def f(x):
while True:
@praveenjha527
praveenjha527 / mongodb-s3-backup.sh
Created March 2, 2017 05:15 — 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
import requests
import re
import time
from lxml import etree
from multiprocessing.dummy import Pool as ThreadPool
from pymongo import MongoClient
db= MongoClient()['mysmartprice']
category_url_list=['http://www.mysmartprice.com/mobile',]
# 'http://www.mysmartprice.com/computer',
@praveenjha527
praveenjha527 / sanp_cat.py
Last active February 21, 2018 09:49
Snapdeal Category crawler
#from __future__ import divison
from lxml import html
import requests
from multiprocessing.dummy import Pool as ThreadPool
import json
import math
from math import ceil
limit=47
page_offset=1
def upload_file():
'This View will handle the uploaded excel file'
if request.method == 'POST':
files = request.files.getlist('file')
print "files are ", files
index = 0
for file in files:
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(UPLOAD_FOLDER, filename))