Skip to content

Instantly share code, notes, and snippets.

View checkaayush's full-sized avatar

Aayush Sarva checkaayush

View GitHub Profile
@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 / 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 / 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",
@checkaayush
checkaayush / mongodb_setting_up_a_replica_set.md
Last active December 6, 2017 08:22 — forked from leommoore/mongodb_setting_up_a_replica_set.md
MongoDB - Setting up a Replica Set

MongoDB - Setting up a Replica Set

cd \mongodbdir\

mkdir db1
mkdir db2
mkdir db3

Primary

mongod --dbpath ./db1 --port 30000 --replSet "demo"

@checkaayush
checkaayush / Postman.desktop
Created November 14, 2017 11:08 — forked from aviskase/Postman.desktop
Install Postman
[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=postman
Icon=/opt/Postman/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;
@checkaayush
checkaayush / python_decorator_guide.md
Created May 14, 2019 08:09 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].