Skip to content

Instantly share code, notes, and snippets.

View sunnyyoung's full-sized avatar

Sunny Young sunnyyoung

View GitHub Profile
@sunnyyoung
sunnyyoung / unpkg.sh
Last active December 17, 2020 09:05
A shell function easy to unpack PKG file.
# unpkg
# Usage: unpkg xxx.pkg
unpkg() {
filepath=$(dirname -- "$1")
filename=$(basename -- "$1")
input="$filepath/$filename"
output="$filepath/${filename%.*}"
pkgutil --expand $input $output
find $output -type f -name 'Payload' -exec tar -xf {} -C $filepath \;
}
@sunnyyoung
sunnyyoung / VNC.vncloc
Created August 26, 2020 01:22
VNC configuration template
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>URL</key>
<string>vnc://username:password@location</string>
<key>restorationAttributes</key>
<dict>
<key>autoClipboard</key>
<true/>
@sunnyyoung
sunnyyoung / export_apple_developer_devices.js
Created August 5, 2022 10:08
Export Apple Developer Devices
var data = document.querySelectorAll(".infinite-scroll-component .row");
var output = "Device ID Device Name\n"
for (var i = 1; i < data.length; i++) {
let identifier = data[i].childNodes[1].childNodes[0].textContent;
let name = data[i].childNodes[0].childNodes[0].textContent;
output += [identifier, name].join(" ") + "\n";
}
console.log(output);
@sunnyyoung
sunnyyoung / namecheap.sh
Created August 5, 2022 17:11
Synology namecheap DDNS provider script
#!/bin/bash
PASSWORD="$2"
DOMAIN="$3"
IP="$4"
PARTS=$(echo $DOMAIN | awk 'BEGIN{FS="."} {print NF?NF-1:0}')
# If $DOMAIN has two parts (domain + tld), use wildcard for host
if [[ $PARTS == 1 ]]; then
HOST='@'
@sunnyyoung
sunnyyoung / swap-ip.sh
Created August 10, 2022 02:29
Raycast script command: Swap between IP string value and IP integer value.
#!/bin/bash
# @raycast.schemaVersion 1
# @raycast.title Swap IP
# @raycast.icon 🔢
# @raycast.mode fullOutput
# @raycast.argument1 { "type": "text", "placeholder": "IP Value" }
if [[ $1 =~ ^-?[0-9]+$ ]] ; then
echo $((($1 >> 24) & 0xFF)).$((($1 >> 16) & 0xFF)).$((($1 >> 8) & 0xFF)).$(($1 & 0xFF))
@sunnyyoung
sunnyyoung / clear-downloads.sh
Created August 10, 2022 02:44
Raycast script command: Move all items from Donwloads to Trash.
#!/usr/bin/osascript
# @raycast.schemaVersion 1
# @raycast.title Clear Downloads
# @raycast.icon 🚮
# @raycast.mode silent
tell application "Finder"
set targets to every item of folder (path to downloads folder as text)
delete targets
@sunnyyoung
sunnyyoung / echo.py
Created August 13, 2022 05:15
Minimal UDP echo tool.
#! /usr/bin/env python
# Client and server for udp (datagram) echo.
#
# Usage: udpecho -s [port] (to start a server)
# or: udpecho -c host [port] <file (client)
import sys
from socket import *
@sunnyyoung
sunnyyoung / build-iperf.sh
Created March 24, 2023 05:04
A macOS/iOS universal iperf3 binary building script.
#!/bin/sh
export SRC="$(pwd)/iperf"
export DST="$(pwd)/iperf.builds"
export XCODE_DIR="$(xcode-select -p)"
echo "Checking out iperf..."
git clone https://github.com/esnet/iperf.git --depth 1 --branch 3.13
echo "Building for macOS..."
#!/bin/bash
# shellcheck disable=2016,2043,2044,2046,2086
VERSION="4.33"
SRC=$(pwd)/libev
DST=$(pwd)/libev.builds
PLATFORMS="macosx iphoneos iphonesimulator appletvos appletvsimulator xros xrsimulator"
set -e
#!/bin/bash
# shellcheck disable=2016,2046,SC2086
VERSION="20220613"
SRC=$(pwd)/boringssl
DST=$(pwd)/boringssl.builds
PLATFORMS="macosx iphoneos iphonesimulator appletvos appletvsimulator xros xrsimulator"
set -e