Skip to content

Instantly share code, notes, and snippets.

@Olgoetz
Olgoetz / .hyper.js
Created February 2, 2023 15:06
my-hyper-js
"use strict";
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
// default font size in pixels for all tabs
@Olgoetz
Olgoetz / json_pagination.py
Created July 8, 2022 05:55
Example with Terraform Enterprise API how to use json pagination with python
# Envs
TFE_TOKEN = os.environ['TFE_TOKEN']
TFE_API_ENDPOINT_BASE = os.environ['TFE_API_ENDPOINT_BASE']
# Set request header for authentication
HEADERS = { 'Authorization' : 'Bearer ' + TFE_TOKEN }
# Switch for ssl
VERIFY = False
@Olgoetz
Olgoetz / aws_lambda_python_logger.py
Last active April 26, 2022 09:19
AWS Lambda python logger that also works locally
import logging
import os
LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO').lower()
log_level_map = {
"info": logging.INFO,
"debug": logging.DEBUG,
"warning": logging.WARNING,
"error": logging.ERROR,
@Olgoetz
Olgoetz / list_tfe_organizations.go
Last active April 11, 2022 08:16
Example how to consume pagination with the go-tfe-cleint
package main
import (
"context"
"fmt"
"log"
tfe "github.com/hashicorp/go-tfe"
)
@Olgoetz
Olgoetz / createAWSS3Bucket.sh
Created December 15, 2021 11:09
Bash script to create a non public AWS S3 bucket with 'versioning, bucket policy, tags and KMS encryption"
#!/bin/env bash
usage() {
echo "****************************************************"
echo ""
echo "Usage: $0 <env> [nonprod|prod]"
echo ""
echo "****************************************************"
@Olgoetz
Olgoetz / sort_downloads.py
Last active June 12, 2021 11:58
Automatically organise your 'downloads' folder with python3 (script may be invoked via a cronjob).
from pathlib import Path
# Set the path to 'downloads' directory
downloads = Path.home() / "downloads"
# File endings for different types
pictures = ['.jpg', '.png', '.gif', '.JPG', '.jpeg']
media = ['.mp3', '.avi', '.mp4']
documents = ['.pdf', '.doc', '.docx', '.txt', '.xls', '.xlsx']
compressedFiles = ['.rar', '.zip']
@Olgoetz
Olgoetz / logger.py
Created August 9, 2020 20:48
Simple logger in python
import logging
import colorlog
def get_logger(name):
# Create a custom logger
logger = logging.getLogger(name)
# Create handlers
@Olgoetz
Olgoetz / createS3Bucket.py
Last active July 31, 2020 07:06
Create an AWS S3 Bucket with Boto3
def transformTags(tags):
"""Transforms the provided dictionary into a suitable array for applying within boto3.
E.g. tags ={'myTag': '1234'} will be transformed to [{'key': 'myTag, 'value:','1234'}].
Args:
tags: A dictionary with tags.
Returns:
List with [{'key': 'tagKey, 'value:','tagValue'}].