Skip to content

Instantly share code, notes, and snippets.

View sri-teja's full-sized avatar
😄
Hello World!

Sri Teja sri-teja

😄
Hello World!
View GitHub Profile
import { injectIntl } from 'react-intl'
const Search = ({ intl: { formatMessage } }) => {
return (
<p>{formatMessage({ id: '<key in the messages dict in locale/<language.js>' })}</p
)
}
export default injectIntl(Search)
@sri-teja
sri-teja / aws_lambda_install.sh
Last active December 11, 2020 05:50
AWS Lambda install new packages
pip3 install --target ./package <package name>
cd pacakge
zip -g my-deployment-package.zip ./*
zip -g my-deployment-package.zip <../any other config files other than pacakges>
## update to lambda
aws lambda update-function-code --function-name <YOUR FUNCTION NAME> --zip-file fileb://my-deployment-package.zip
@sri-teja
sri-teja / deployment.yaml
Created August 30, 2020 10:40
Kubernetes Deployment and Service .yaml template
## Author: Sri Teja
## Description: Kubernetes Deployment and Service deployment.yaml template for my projects
## Variables ##
## app_name: Your project name
## host_name: Your database Host Name (localhost/ AWS RDS URL ...)
## image_name: Your image reference to build container (from docker registery/ AWS ECR Image URL ...)
apiVersion: v1
kind: Service
metadata:
from flask import Flask, jsonify
from flasgger import Swagger
from flasgger import swag_from
app = Flask(__name__)
## this is required to give openapi version
## separately in the app.config
## even though we mention it in docs.yml
app.config['SWAGGER'] = {
#!/bin/bash
###################################################################
#Note : Use this script at your risk
###################################################################
#Script Name : initial_server_setup.sh
#Description : setup a non root user with name "ubuntu"
## : and give superuser priviliges along with a
## : basic firewall setup
#Args : 1) server public IP Address,
## : 2) path to .pem file
/**
* @author Sri Teja <[email protected]>
* @link sri-teja.github.io
*/
// Syntax:
// <array>.reduce(<function>, start_value);
// The reduce () method reduces the array to a single value.
// The reduce() method executes a provided function for each value
## Reference: https://docs.sentry.io/platforms/python/flask/
## installation
## pip install --upgrade 'sentry-sdk[flask]==0.13.1'
## usage
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
sentry_sdk.init(
dsn="https://<key>@sentry.io/<id>",
paths:
/testing_get:
get:
description: To check if server is up or not.
responses:
'200':
description: Response if server is up and running.
content:
application/json:
schema:
## Reference: https://medium.com/@trstringer/logging-flask-and-gunicorn-the-manageable-way-2e6f0b8beb2f
## in wsgi.py (gunicorn base file)
## this is to mainitain sync between the levels of logging module and gunicorn logger.
import logging
if __name__ != '__main__':
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(gunicorn_logger.level)
@sri-teja
sri-teja / list_of_loaded_modules.py
Last active October 17, 2019 10:10
This is a python code which gives the list of loaded packages in the current environment. *Source:* stack overflow, link given in the code.
# show versions of packages
# adopted from https://stackoverflow.com/questions/40428931/package-for-listing-version-of-packages-used-in-a-jupyter-notebook
import sys
import pkg_resources
import types
def get_imports():
for name, val in globals().items():
if isinstance(val, types.ModuleType):
# Split ensures you get root package,