Skip to content

Instantly share code, notes, and snippets.

View anandtripathi5's full-sized avatar
🎯
Focusing

Anand Tripathi anandtripathi5

🎯
Focusing
View GitHub Profile
@dmmeteo
dmmeteo / 1.srp.py
Last active June 7, 2024 14:11
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@empeje
empeje / README.md
Last active November 19, 2022 14:56
Setup pyenv in fish shell

Setup pyenv

Required dependencies

brew install pyenv
brew install zlib
brew install sqlite
@anandtripathi5
anandtripathi5 / brief_explanation_of_zen_of_python.md
Last active August 1, 2020 10:34
A brief explanation of zen of python

The Zen of Python is a collection of 20 software principles that influence the design of Python Programming Language, only 19 of which were written down around June 1999 by Tim Peters. You can find the list of Zen of Python in any python interpreter just fire a command - import this

  • Beautiful is better than ugly.

    • To better understand this suppose the editor is your canvas and your code is your art, then how much effort you will put in so that someone will call you an artist. According to Somya Ghosh(Random Quora answer) Rather than using && or|| as logical operators, consider using and || or, if it works && is readable to you.

          if ( a && b == 0 || s == 'yes')
      

      Versus

          if a and b == 0 or s == 'yes': 
      
@anandtripathi5
anandtripathi5 / rabbitmq_auth_backend_ip_range.md
Last active June 12, 2018 12:38
Configure rabbitmq community plugin rabbitmq_auth_backend_ip_range on ubuntu

Rabbitmq-auth-backend-ip-range link is community plugin for client authorization based on source IP address. With this community plugin, we can restrict access to client on the basis of IP address

Steps To configure plugin in rabbitmq version 3.6.X

@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')
@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
@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 | |----|-----------------------------------------------

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.
@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
@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