What I learned new this week (week 12)
-
In Vim, if we have selected some characters or paragraph and want to count the number of characters then we have to type
:'<,'>s/\%V./&/gnwhile the paragraph is selected. -
In Linux, instead of using
.envfile for storing the environment variable, we can write that inside the.bashrcfile if we have access to.bashrc. Example :-export SOME_SECRET_KEY="some_random_key_for_your_app". -
In Python, to access the environment variable we have to use
getenv()orenvironfrom the os module. Example -
import os
print(os.environ['SOME_SECRET_KEY'])
print(os.getenv('SOME_SECRET_KEY')
- In Linux,
.bashrcdoes not support storing and exporting a json content. But there is a way. We have to stringify that by making that json content single line and adding quotation mark at the beginning and the end of the json content. Then you just have to jsonify in your programming language.
export FIREBASE_CREDS_JSON='{"project_id": "your id goes here", "type": "your project type", "client_id": "your client_id", "...": "..."}'
import os, json
creds_string = os.getenv('FIREBASE_CREDS_JSON')
creds_dict = json.loads(creds_string)
That’s it for this week. Meeting you next week.