Skip to content

Instantly share code, notes, and snippets.

View anandtripathi5's full-sized avatar
🎯
Focusing

Anand Tripathi anandtripathi5

🎯
Focusing
View GitHub Profile
@baojie
baojie / flask-vs-tornado
Created December 3, 2013 23:42
flask vs tornado benchmark on basic routing and template rendering
Flask, Python 2.7, Single core 271.97 [#/sec] (mean)
Flask, Pypy, Single core 547.11
Flask+Gunicorn, Python, 8Core 1363.06
Flask+Gunicorn, Pypy, 8Core 2701.90
Flask+Gunicorn+Tornado, Python, 8Core 1403.88
Flask+Gunicorn+Tornado, Pypy, 8Core 2582.12
Tornado, Python, Single core 839.65
Tornado, Async, Python, Single core 801.19
Tornado, Pypy, Single core 1841.41
Tornado, Async, Pypy, Single core 1734.37
@mminer
mminer / cachedecorator.py
Created January 12, 2015 23:57
An example of a Python decorator to simplify caching a function's result.
"""An example of a cache decorator."""
import json
from functools import wraps
from redis import StrictRedis
redis = StrictRedis()
def cached(func):
@hussaintamboli
hussaintamboli / Custom response in Flask
Last active October 29, 2020 00:22
Return a Custom response in flask restful API
from flask import Response, jsonify
import json
from flask_restful import Resource
class Api(Resource):
def post(self):
response = Response(
response=json.dumps(dict(error='err')),
@hirobert
hirobert / flask_abort_example.py
Created January 13, 2016 20:38
flask abort as json
from flask import abort, make_response, jsonify
abort(make_response(jsonify(message="Message goes here"), 400))
@trulyronak
trulyronak / .aliases
Last active February 17, 2024 10:52
Awesome Terminal Aliases (Featuring Brilliant Bash)
# fun stuff
alias lenny='echo \_(ツ)_/¯ | pbcopy'
alias tuxsay='cowsay -f tux '
alias fortunes='sh ~/.fortunes.sh'
alias life='figlet 42 | lolcat'
alias lol='while true; do sl; done;'
alias starwars='telnet towel.blinkenlights.nl'
alias fancy='figlet $@'
# to make people confused xD
@matthewjackowski
matthewjackowski / pg-cron-setup.sh
Created July 12, 2017 08:01
Pg-cron on a Amazon AMI
sudo yum -y update
sudo yum -y localinstall https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm
sudo yum -y install postgresql96 postgresql96-server
sudo su - postgres -c "/usr/pgsql-9.6/bin/initdb"
sudo service postgresql-9.6 start
curl https://install.citusdata.com/community/rpm.sh | sudo bash
sudo yum install -y pg_cron_96
sudo -u postgres echo "shared_preload_libraries = 'pg_cron'" >> /var/lib/pgsql/9.6/data/postgresql.conf

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@anandtripathi5
anandtripathi5 / 12_factor_app_checklist_explained.md
Last active December 3, 2022 13:24
The 12 Factor App checklist explained

The twelve-factor app Checklist Explained

| ✓ | Factors | Status | Remarks | |----|-----------------------------------------------

@nqbao
nqbao / ssm_parameter_store.py
Last active May 29, 2024 06:01
Python class to provide a dictionary-like interface to access AWS SSM Parameter Store easily
# Copyright (c) 2018 Bao Nguyen <b@nqbao.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
@orenshk
orenshk / boto-backoff.py
Created June 3, 2018 18:44
AWS exponential back off with boto3
import boto3
from botocore.exceptions import ClientError
class BotoBackoff(object):
"""
Wrap a client for an AWS service such that every call is backed by exponential backoff with jitter.
Examples:
>>> ecs = BotoBackoff('ecs')
>>> ecs.list_tasks(cluster='my-cluster')