Skip to content

Instantly share code, notes, and snippets.

View checkaayush's full-sized avatar

Aayush Sarva checkaayush

View GitHub Profile
@checkaayush
checkaayush / FRIENDS.py
Created September 18, 2016 15:30
Script I used to rename all F.R.I.E.N.D.S. epsiodes by fetching names from Wikipedia
from bs4 import BeautifulSoup
import requests
import os
def get_episode_names(season):
episodes = {}
print "Making request..."
url = "https://en.wikipedia.org/wiki/Friends_(season_%s)#Episodes" % season
print url
@checkaayush
checkaayush / gist:ec14e28aa08343e1e35f47d2c5b2ee3d
Last active October 4, 2016 07:55 — forked from jonleighton/base64ArrayBuffer.js
Encode an ArrayBuffer as a base64 string
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
function base64ArrayBuffer(arrayBuffer) {
var base64 = ''
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
var bytes = new Uint8Array(arrayBuffer)
var byteLength = bytes.byteLength
@checkaayush
checkaayush / suds_object_to_dict.py
Created October 10, 2016 20:55
Convert Suds object to Python dictionary
# Source: http://stackoverflow.com/questions/17581731/parsing-suds-soap-complex-data-type-into-python-dict
def basic_sobject_to_dict(obj):
"""Converts suds object to dict very quickly.
Does not serialize date time or normalize key case.
:param obj: suds object
:return: dict object
"""
if not hasattr(obj, '__keylist__'):
return obj
@checkaayush
checkaayush / push_stats.py
Created November 2, 2016 12:35 — forked from prakashpp/push_stats.py
Script to push github commit stats to slack
import os
from datetime import datetime
from slacker import Slacker
from dateutil.relativedelta import relativedelta
import requests
from requests.auth import HTTPBasicAuth
USERNAME = "prakashpp"
GITHUB_TOKEN = os.environ['GITHUB_ACCESS_TOKEN']
@checkaayush
checkaayush / mysql_to_csv.py
Created February 20, 2017 14:10
Exports MySQL tables to .csv
"""Exports MySQL tables to CSV"""
import os
import pymysql
import pandas as pd
HOST = 'database_host_here'
DATABASE = 'database_name_here'
@checkaayush
checkaayush / mongodb-s3-backup.sh
Created March 17, 2017 11:53 — 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
@checkaayush
checkaayush / backup-mongodb-to-s3.sh
Created March 17, 2017 11:54 — 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
@checkaayush
checkaayush / nginxproxy.md
Created May 21, 2017 18:06 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@checkaayush
checkaayush / README-Template.md
Created July 30, 2017 14:13 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@checkaayush
checkaayush / http_status.py
Created October 15, 2017 20:37 — forked from toast38coza/http_status.py
HTTP status codes as a dict. Source: https://httpstatuses.com/
STATUS_CODES = {
100: "100 Continue",
101: "101 Switching Protocols",
102: "102 Processing",
200: "200 OK",
201: "201 Created",
202: "202 Accepted",
203: "203 Non-authoritative Information",
204: "204 No Content",