Skip to content

Instantly share code, notes, and snippets.

@mcharo
mcharo / install-pwsh.sh
Last active November 13, 2019 16:51
Install pwsh on macOS without admin
#!/bin/bash
set -e
version=$1
if [[ -z "$version" ]]; then
cat << EOF
Usage:
$0 <version>
@mcharo
mcharo / non-admin-install.sh
Created November 13, 2019 03:00
Install Microsoft Teams pkg (and maybe others) on macOS without admin
#!/bin/bash
# setup
pkgpath=$1
pkgout=/tmp/$(/usr/bin/openssl rand -hex 10)
payout=/tmp/$(/usr/bin/openssl rand -hex 10)
if [ -d "$pkgout" ]; then
echo $pkgout already exists
exit 1
fi
@mcharo
mcharo / syn_diddle.py
Last active November 10, 2019 04:15
Synology API diddling
#!/usr/bin/env python3
# references:
# - https://github.com/N4S4/synology-api
import requests
import argparse
import json
from getpass import getpass
@mcharo
mcharo / opencv-install.sh
Last active November 9, 2019 05:20
Installing OpenCV 4.1.2 on macOS Mojave
#!/bin/bash
# references:
# - https://medium.com/@nuwanprabhath/installing-opencv-in-macos-high-sierra-for-python-3-89c79f0a246a
# - https://www.learnopencv.com/install-opencv3-on-macos/
# - https://bob.ippoli.to/archives/2005/02/06/using-pth-files-for-python-development/
# this is probably /usr/local for you
BREW_ROOT="/usr/local/homebrew"
@mcharo
mcharo / pingled.ps1
Last active February 7, 2023 21:25
Ping output to macOS CapsLock LED
#!/usr/bin/env pwsh
[CmdletBinding()]
param(
$IpAddress,
$Count = 4
)
@'
var capsState;
@mcharo
mcharo / azdeploy.go
Last active February 7, 2023 20:30
Go CLI Playground
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"runtime"
@mcharo
mcharo / xhyve_ubuntu.sh
Last active April 19, 2019 02:21
Ubuntu on xhyve
# build xhyve
git clone https://github.com/mist64/xhyve
cd xhyve
make
# dump ubuntu iso to ./xhyve/ubuntu
mkdir ubuntu
cd ubuntu
wget http://releases.ubuntu.com/14.04.2/ubuntu-14.04.2-server-amd64.iso
dd if=/dev/zero bs=2k count=1 of=/tmp/tmp.iso
@mcharo
mcharo / hello-node.sh
Last active April 15, 2019 02:21
minikube tests
# create hello-node deployment
kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node
# create loadbalancer service to expose hello-node pods on external network
kubectl expose deployment hello-node --type=LoadBalancer --port=8080
# open browser to service
minikube service hello-node
# scale number of pods behind service to 3
@mcharo
mcharo / hyperkube.sh
Created April 14, 2019 20:18
minikube + hyperkit
#!/bin/sh
# install minikube
brew cask install minikube
# install and modify permission on hyperkit driver
brew install hyperkit docker-machine-driver-hyperkit
sudo chown root:wheel /usr/local/bin/docker-machine-driver-hyperkit
sudo chmod u+s /usr/local/bin/docker-machine-driver-hyperkit
@mcharo
mcharo / Get-PinvokeMethod.ps1
Last active September 3, 2019 22:49
PowerShell Reflection
function Get-NativeMethods
{
[CmdletBinding()]
param(
[switch]$Unsafe
)
$Type = 'Microsoft.Win32.NativeMethods'
if ($Unsafe)
{
$Type = 'Microsoft.Win32.UnsafeNativeMethods'