Skip to content

Instantly share code, notes, and snippets.

View irvingvjuarez's full-sized avatar
🔥
On fire

Irving Juárez irvingvjuarez

🔥
On fire
View GitHub Profile
@plembo
plembo / PythonReadingEnvFile.md
Last active May 4, 2023 23:16
Python reading .env file

Reading a .env file in Python

The os.environ.get method is usually what I used to read configuration information in the system environment, including secrets, in my python scripts. But sometimes (like during testing) it's convenient to use a local file instead. That's where the python-dotenv library comes in handy.

The library leverages os.environ.get to load variables from a .env file like the system loads them from .profile or .bashrc (in Unix-like systems). By default dotenv looks for the .env file in the same directory as the running program. Note: Always remmember to exclude it from your repo by adding ".env" to your .gitignore. Github's own sample Python.gitignore already does that.

Install:

@chrishasz
chrishasz / localStorageService.ts
Last active January 11, 2022 19:27
A type-generic class to read and write project or extension-wide data in VSCode's durable key-value storage
'use strict';
import { Memento } from "vscode";
export class LocalStorageService {
constructor(private storage: Memento) { }
public getValue<T>(key : string) : T{
return this.storage.get<T>(key, null);