Skip to content

Instantly share code, notes, and snippets.

View anandtripathi5's full-sized avatar
🎯
Focusing

Anand Tripathi anandtripathi5

🎯
Focusing
View GitHub Profile
@anandtripathi5
anandtripathi5 / jenkins-docker-compose.yml
Last active June 21, 2021 09:50
docker-compose.yml file of Jenkins server. Proxy plugin configuration will work with the below configuration of docker-compose
version: "3"
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
hostname: jenkins
environment:
- HTTP_PROXY=http://localhost:8080
- http_proxy=http://localhost:8080
@anandtripathi5
anandtripathi5 / app.py
Created October 29, 2021 21:54
Flask app getting issue in MacOS Monterey
from flask import Flask
app = Flask(__name__)
@app.get('/hello')
def hello():
return 'Hello'
@anandtripathi5
anandtripathi5 / config.py
Created February 5, 2022 18:13
Pydantic usage with python-dotenv
import os
from typing import Union
from pydantic import BaseSettings, Field
class Base(BaseSettings):
secret_key: str = Field('random_string', env='ANOTHER_SECRET_KEY')
port: int = 5050
username: str = "ANAND"
@anandtripathi5
anandtripathi5 / main.py
Created February 5, 2022 18:15
Flask application with pydantic as configuration
from flask import Flask
from dotenv import load_dotenv
from config import settings
load_dotenv() # take environment variables from .env.
app = Flask(__name__)
@anandtripathi5
anandtripathi5 / zen_of_python_1.py
Last active February 13, 2022 23:48
Beautiful is better than ugly
if (is_valid(a) && b == 0 || s == 1)
# or
if is_valid(a) and not b or s
@anandtripathi5
anandtripathi5 / zen_of_python_2.py
Created February 13, 2022 23:47
Explicit is better than implicit
from .. import some_module
# or
from foo.bar import some_module
# another example
from foo.bar.some_module import *
# or
from foo.bar.some_module import specific_variable
@anandtripathi5
anandtripathi5 / zen_of_python_3.py
Created February 13, 2022 23:56
Simple is better than complex
# c,a,b,d are some random variables
c = a and b or d
# or
if a:
c = b
else:
c = d
@anandtripathi5
anandtripathi5 / complex_is_better_than_complicated.py
Created February 16, 2022 10:16
Zen of python - Complex is better than complicated
counter = 0
while counter < 5:
print counter
counter += 1
@anandtripathi5
anandtripathi5 / complex_is_better_than_complicated_solution.py
Created February 16, 2022 10:17
Zen of python - Complex is better than complicated
for i in xrange(5):
print i
@anandtripathi5
anandtripathi5 / sparse_better_than_dense.py
Last active February 16, 2022 10:24
Zen of python - Sparse is better than dense
if i>0: return sqrt(i)
elif i==0: return 0
else: return 1j * sqrt(-i)
# Versus
if i > 0:
return sqrt(i)
elif i == 0: