Dealing with environment variable type conversion in Python.
You've got a program that you want to configure using an OS environment variable - MY_VARIABLE.
# my_program.py
import os
# parse the environment variable| declare var process: { | |
| env: {} | |
| } | |
| class EnvironmentConfig { | |
| name: string | |
| required_variable: string | |
| optional_variable: string | undefined | |
| constructor(env: any) { |
| import os | |
| class EnvironmentConfiguration(): | |
| def __init__(cls): | |
| cls.name = os.environ.get('ENV_NAME', 'development') | |
| cls.required_variable = os.environ.get('REQUIRED_VARIABLE') | |
| cls.some_integer = int(os.environ.get('COOLNESS_LEVEL')) | |
| cls.some_array = str(os.environ.get('GREAT_IDEAS')).split(',') |
| # Config generated by Ghostty Config https://ghostty.zerebos.com/app/import-export | |
| term = xterm-256color | |
| copy-on-select = false | |
| clipboard-paste-bracketed-safe = false | |
| window-vsync = false | |
| background-opacity = 0.9 | |
| unfocused-split-opacity = 0.75 | |
| window-height = 50 | |
| window-width = 120 |
| const slack = require('@slack/web-api'); | |
| //@see https://api.slack.com/authentication/token-types#bot | |
| const slackClient = new slack.WebClient('<your-bot-token>'); | |
| //start deletin' | |
| deleteAllFiles().then(() => { | |
| logg('All done'); | |
| }, err => { | |
| console.error(err); | |
| }); |
node blaseball-terminal.js
# run and keep the feed alive indefinitely
node blaseball-termina.js --follow
# >| /** | |
| * This script will take a list of Kaltura Media Entities, | |
| * check to see if they have more than 1 flavor asset, | |
| * and remove the Source flavor asset if it exists. | |
| * | |
| * Prerequisites: | |
| * Install NodeJS v12+ | |
| * - Add this file to a folder | |
| * - Add a file named "config.json" in the same folder, populate it with | |
| * this: `{"session": "YOUR-VALID-KALTURA-SESSION-TOKEN"}` |
| asyncAwaitTest(); | |
| async function asyncAwaitTest() { | |
| let result1, result2, result3, results; | |
| try { | |
| result1 = promise1(); | |
| result2 = promise2(); | |
| result3 = promise3(); | |
| results = [await result1, await result2, await result3]; | |
| } catch(err) { |