Skip to content

Instantly share code, notes, and snippets.

View andrewodri's full-sized avatar
😍

Andrew Odri andrewodri

😍
View GitHub Profile
@andrewodri
andrewodri / get-dockerfile.sh
Created March 26, 2021 15:39
Rebuild a Dockerfile for a supplied image
#!/bin/bash
docker history --format '{{ .CreatedBy }}' --no-trunc "${@}"
@andrewodri
andrewodri / install.ps1
Created March 18, 2021 13:52
Download, validate and expand archive using PowerShell
$ArchiveHash = '2c1ab54ac560327ed45fdc28a106d539'
New-Item -ItemType Directory -Path '/tmp'
(New-Object System.Net.WebClient).DownloadFile('https://example.com/archive.zip', '/tmp/archive.zip');
if ( ( Get-FileHash -Path '/tmp/archive.zip' -Algorithm MD5 ).Hash -eq $ArchiveHash ) { Write-Output 'Could not validate hash.' } else { exit }
Expand-Archive -Path '/tmp/archive.zip' -DestinationPath '/tmp'
@andrewodri
andrewodri / README.md
Last active November 10, 2023 14:12
Install .NET SDK 5.0 on macOS one-liner

Based on the official Microsoft documentation with a bit of sketchiness added in for convenience:

echo -ne "\033[0;31mdotnet-install:\033[0m Enter the .NET Core SDK channel (i.e. n.n, not n.n.n) you would like to install: " && read CHANNEL; curl -sSL https://dot.net/v1/dotnet-install.sh | bash -s -- --channel "${CHANNEL}" && grep -qxF 'export PATH=$PATH:$HOME/.dotnet' ~/.zshrc || echo 'export PATH=$PATH:$HOME/.dotnet' >> ~/.zshrc && source ~/.zshrc

This does the following:

  • Prompt the user to enter a .NET Core SDK version to install
  • Install the entered .NET Core SDK version
@andrewodri
andrewodri / lifecam.sh
Created January 25, 2021 13:19
Fix overexposure on Microsoft LifeCam in macOS
#!/bin/zsh
cat "alias brew='arch -x86_64 brew'" > ~/.zshrc
brew install nvm
cat EOM > ~/.zshrc
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
@andrewodri
andrewodri / config.yaml
Created December 17, 2020 20:53
Automatically register Gitlab Runners with Gitlab FOSS via Kubernetes
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: gitlab-deployment
spec:
replicas: 1
selector:
matchLabels:
app: gitlab
@andrewodri
andrewodri / action.js
Last active December 1, 2021 21:25
Code 128 generator for Acrobat PDF actions
var barcode = this.getField("CarrierCode").valueAsString + this.getField("CargoControlNumber").valueAsString
var specification = "code128a"
var fontMapping = "common"
var fromMap = {
"common": {
" ": 0,
"Â": 0, "!": 1, "\"": 2, "#": 3, "$": 4, "%": 5, "&": 6, "'": 7,
"(": 8, ")": 9, "*": 10, "+": 11, ",": 12, "-": 13, ".": 14, "/": 15,
@andrewodri
andrewodri / README.md
Last active November 16, 2023 06:53
Download specific macOS version and create USB installer from the CLI

I always seem to forget how to download the macOS version I need by the time I need it again, so here is a quick and nasty guide on how to download a properly signed *.dmg file to build a USB installer.

If you don't want to download the tool or monkey around with permissions, give this a shot: (Provided you are dumb enough to pipe unknown code off the internet in sudo python of course):

  • sudo curl -s https://raw.githubusercontent.com/grahampugh/macadmin-scripts/master/installinstallmacos.py | sudo python - --help

If you're downloading an installer for your current machine, do the following:

@andrewodri
andrewodri / pdf-to-ttf.md
Created June 12, 2020 01:11
Extract fonts from PDF

First, we need to open a shell to the PDF tools Docker container:

docker run --rm -it -v ${PWD}:/pdf gkmr/pdf-tools:latest /bin/sh

Then we need to run the following commands:

cd /pdf
@andrewodri
andrewodri / terminal.scpt
Created May 13, 2020 21:44
Launch Terminal and close window when finished using AppleScript
tell application "Terminal"
activate
do script "sudo say --rate=140 \"Intergalactic Planetary\" && kill -9 $$"
delay 5
repeat
try
do shell script "ps a | grep -v grep | grep 'sudo say --rate=140 Intergalactic Planetary'"
delay 0.5
on error
exit repeat
@andrewodri
andrewodri / python.scpt
Created May 11, 2020 17:16
Python in an AppleScript's covering
#!/usr/bin/osascript
do shell script "/usr/bin/python <<'EOF'
class Message:
def __init__(self, content):
self.content = content
def display(self):
print(self.content)