Skip to content

Instantly share code, notes, and snippets.

View tdnguyen6's full-sized avatar

T.D. Nguyen tdnguyen6

View GitHub Profile
@tdnguyen6
tdnguyen6 / build-img
Last active December 28, 2021 15:45
Script to build OCI image inside another OCI image using kaniko
#!/usr/bin/env bash
pod_created=false
trap del-pod EXIT
help()
{
echo "Build image using kaniko and output a tarball representing the built image.
Tarball of built image can then be managed (show digest, push, etc.) using crane/gcrane.
@tdnguyen6
tdnguyen6 / clean_abandoned_pipenv.sh
Created August 7, 2021 10:52
Bash script to clean abandoned pipenv environments (non-existing project folder)
#!/usr/bin/env bash
# get all pipenv environments
allPipenvEnv=$(find ~/.local/share/virtualenvs/*/.project -type f)
# find abandoned environments
abandonedEnv=()
for f in $allPipenvEnv; do
proj_path="$(cat $f)" && [ ! -d $proj_path ] && abandonedEnv+=($proj_path)
done

Rust Error Handling Cheatsheet - Result handling functions

Introduction to Rust error handling

Rust error handling is nice but obligatory. Which makes it sometimes plenty of code.

Functions return values of type Result that is "enumeration". In Rust enumeration means complex value that has alternatives and that alternative is shown with a tag.

Result is defined as Ok or Err. The definition is generic, and both alternatives have

@willwm
willwm / EnableRemoting.ps1
Last active September 12, 2024 03:12
Includes fix for "WinRM firewall exception will not work since one of the network connection types on this machine is set to Public."
# https://4sysops.com/archives/enabling-powershell-remoting-fails-due-to-public-network-connection-type/#changing-the-network-connection-type-with-powershell
Set-NetConnectionProfile -NetworkCategory Private
Enable-PSRemoting
@mbreese
mbreese / docker-heredoc-snippet
Last active July 9, 2025 05:06
Running docker with a HEREDOC to script the commands to run inside the container.
docker run -v /Users/mbreese/tmp:/tmp1 -w /tmp1 -i centos:7 /bin/bash -s <<EOF
date > foo
echo 'foo' >> foo
cat /etc/redhat-release >> foo
whoami >> foo
EOF
@yurrriq
yurrriq / ipconfig.sh
Last active May 14, 2025 06:51
Get Public IP Address in Terminal
#!/bin/bash
# Slow
curl -s ifconfig.me | xargs echo -n
# Faster
curl -s icanhazip.com | xargs echo -n
# API: http://api.ident.me
@binaryphile
binaryphile / gist:3500552
Created August 28, 2012 16:54
Autohotkey use Esc as modifier script
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
; This script uses Esc as a modifier key so that the keyboard can be used for directional keys (arrows, etc.)