This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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>", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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, |