Skip to content

Instantly share code, notes, and snippets.

View nicc777's full-sized avatar
🏠
Working from home

Nico Coetzee nicc777

🏠
Working from home
  • Utrecht, Netherlands
View GitHub Profile
@nicc777
nicc777 / argocd_api_token.md
Last active August 3, 2023 07:01
Get ArgoCD API Token

To get the token:

export ARGOCD_SERVER="https://<<your-url>>"
export ARGOCD_ADMIN_PASSWORD=`aws secretsmanager get-secret-value --secret-id SecretText_odde-eks_eks1_argocd_initial-admin-secret --output json | jq -r ".SecretString"`
rm /tmp/creds.json
cat << EOF >> /tmp/creds.json
{
	"username":"admin",
	"password":"$ARGOCD_ADMIN_PASSWORD"
@nicc777
nicc777 / world_clock.sh
Created July 23, 2023 09:08
Command Line World Clock
#!/bin/sh
# Command-line world clock - source: https://stackoverflow.com/questions/370075/command-line-world-clock
: ${WORLDCLOCK_ZONES:=$HOME/world_time_zones}
: ${WORLDCLOCK_FORMAT:='+%Y-%m-%d %H:%M:%S %Z'}
while read zone
do echo $zone '!' $(TZ=$zone date "$WORLDCLOCK_FORMAT")
done < $WORLDCLOCK_ZONES |
awk -F '!' '{ printf "%-20s %s\n", $1, $2;}'
@nicc777
nicc777 / load_any_yaml_tag.py
Created July 22, 2023 09:01 — forked from lukeplausin/load_any_yaml_tag.py
Load any YAML tag including custom tags in python with PyYAML
# Inspired by this great answer...
# https://stackoverflow.com/a/60785401
import yaml
class SafeUnknownConstructor(yaml.constructor.SafeConstructor):
def __init__(self):
yaml.constructor.SafeConstructor.__init__(self)
def construct_undefined(self, node):
@nicc777
nicc777 / get_non_open_files_in_current_dir.sh
Created May 17, 2023 11:31
Linux: Identify all files in a directory not currently open by an application
#!/bin/bash
for f in *; do
fuser -s "$f" || echo "$f" >> /tmp/files
done
@nicc777
nicc777 / python_dict_Deep_merge.md
Created March 31, 2023 07:12
Python deep merge dictionaries

Info Question to chatGPT 4: python deep merge two dictionaries

Response:

def deep_merge_dicts(dict1, dict2):
    """
    Recursively merge two dictionaries.
    """

Keybase proof

I hereby claim:

  • I am nicc777 on github.
  • I am nicc777 (https://keybase.io/nicc777) on keybase.
  • I have a public key ASCw2KEtFioxkgSyfTkWNcXnjyg0xm2tNkOSqpbno20BOAo

To claim this, I am signing this object:

@nicc777
nicc777 / dump_to_json.py
Created October 28, 2022 07:03
Dumping dicts to json in Python, where the dict has `datetime` or `tzlocal` objets
import json
import datetime
from dateutil.tz import tzlocal # pip3 install python-dateutil
your_dict = {} # Data...
json.dumps(your_dict, sort_keys=True, default=str)
@nicc777
nicc777 / pySmtpSend.py
Created September 29, 2022 09:23
Python raw SMTP ()unauthenticated)
#!/usr/bin/python
import smtplib
import os
SMTP_SERVER = os.getenv('SMTP_SERVER', 'localhost')
SMTP_PORT = os.getenv('SMTP_PORT', '25')
SENDER_EMAIL_ADDR = os.getenv('SENDER_EMAIL_ADDR', '[email protected]')
SENDER_NAME = os.getenv('SENDER_NAME', 'NO-REPLY')
RECEIVER_EMAIL_ADDR = os.getenv('RECEIVER_EMAIL_ADDR', 'root@localhost')
RECEIVER_NAME = os.getenv('RECEIVER_NAME', 'Root')
@nicc777
nicc777 / dynamic_dns_using_aws_howto.md
Last active September 21, 2023 16:58
Using AWS for managing your PC dynamic DNS entry

Summary of info I got from this post on 2022-09-11

Shell script:

#!/bin/bash

#Variable Declaration - Change These
HOSTED_ZONE_ID="XXXXXXXXXXXX"
NAME="example.com."