Skip to content

Instantly share code, notes, and snippets.

View sunnyyoung's full-sized avatar

Sunny Young sunnyyoung

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 \;
}