Skip to content

Instantly share code, notes, and snippets.

@tonylea
tonylea / Dockerfile.j2
Created July 6, 2023 19:05
Dockerfile.j2 template for Ansible Molecule tests
# Molecule managed
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
{% if item.env is defined %}
{% for var, value in item.env.items() %}

Work MacBook Config

Update OS

softwareupdate --all --install --force

Homebrew

Brew Bundle Brewfile Tips

Copyright & License

Unless otherwise noted (either in this file or in a file's copyright section) the contents of this gist are Copyright ©️2020 by Christopher Allen, and are shared under spdx:Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.) open-source license.

Sponsor

If you more tips and advice like these, you can become a monthly patron on my GitHub Sponsor Page for as little as $5 a month; and your contributions will be multipled, as GitHub is matching the first $5,000! This gist is all about Homebrew, so if you like it you can support it by donating to them or becoming one of their Github Sponsors.

@tonylea
tonylea / valiateFileExtension.ps1
Created September 11, 2021 15:41
Validate file extension in PowerShell parameter
param (
[ValidateScript({
if (-Not ($_ | Test-Path) ) { throw "File does not exist" }
if (-Not ($_ | Test-Path -PathType Leaf) ) { throw "The Path argument must be a file. Folder paths are not allowed." }
if ($_ -notmatch "\.tfplan$") { throw "The file specified in the path argument must be type tfplan" }
return $true
})]
[System.IO.FileInfo]
$FilePath
)
@tonylea
tonylea / sshKeyCopy.sh
Created August 22, 2021 18:25
Copy ssh key to server
cat ~/.ssh/id_rsa.pub | ssh <USER_NAME>@<SERVER_NAME> "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
@tonylea
tonylea / git-push-all.sh
Last active August 16, 2021 15:50
Push git repo, including branches & tags
#!/usr/bin/env bash
# The simplest way to push all branches to a remote repo:
git push --all <remote-name>
@tonylea
tonylea / clean-up-boot-partition-ubuntu.md
Created September 26, 2017 07:51 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@tonylea
tonylea / nginxproxy.md
Created January 29, 2017 00:34 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

Set-ExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
cinst Chocolatey
cinst angryip
cinst autohotkey
cinst autohotkey
cinst checksum
cinst ChocolateyGUI
cinst cutepdf
@tonylea
tonylea / self-elevate-script.ps1
Created August 22, 2016 10:52
Script block to self-elevate a script
# Script found at https://www.autoitscript.com/forum/topic/174609-powershell-script-to-self-elevate/
# Test if admin
function Test-IsAdmin()
{
# Get the current ID and its security principal
$windowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = new-object System.Security.Principal.WindowsPrincipal($windowsID)
# Get the Admin role security principal