Skip to content

Instantly share code, notes, and snippets.

View pa-0's full-sized avatar

Peter Abbasi pa-0

View GitHub Profile
@pa-0
pa-0 / Mac OS X Disable Hot Corners
Created February 6, 2025 08:44 — forked from klynch/Mac OS X Disable Hot Corners
Disable those pesky hot corners when you don't want them and easily reenable them when you do!
-- By Richard Kulesus, 2009. Released without license!
-- Use this for whatever!
-- I seriously despise code authors who copyright tiny bits of obvious code
-- like it's some great treasure. This is small and simple, and if it saves
-- the next guy some time and trouble coding applescript I'll feel good!
--
-- Quickly change all the hot-corners to do what you want.
-- Particularly useful for presentations and full-screen games.
-- Customize the activity of each hot-corner with "all windows/application windows/dashboard/disable screen saver/none/show desktop/show spaces/sleep display/start screen saver"
-- The MODIFIERS are the keys which can be used to supplement hot-corner activation.
@pa-0
pa-0 / toggleHotCorners.scpt
Created February 6, 2025 08:44 — forked from hng/toggleHotCorners.scpt
Toggles Hot Corners on Mavericks OS X 10.9
-- based on: https://discussions.apple.com/message/23989931#23989931
property theSavedValues : {"Dashboard", "Launchpad", "Mission Control", "Schreibtisch"} -- change "Schreibtisch" to "Desktop" if not german etc.
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.expose"
tell application "System Events"
tell window "Mission Control" of process "System Preferences"
click button "Aktive Ecken …" -- on english computer: "Hot Corners…"
tell sheet 1
@pa-0
pa-0 / encode.sh
Created February 6, 2025 08:44 — forked from The-Running-Dev/encode.sh
This is the shell script I use to drive HandBrakeCLI to re-encode video files in a format suitable for playback on Apple TV, Roku 3, iOS, OS X, etc.
#!/bin/bash
# encode.sh
#
# Copyright (c) 2013 Don Melton
#
# This version published on June 7, 2013.
#
# Re-encode video files in a format suitable for playback on Apple TV, Roku 3,
# iOS, OS X, etc.
@pa-0
pa-0 / Set-LnkToRunAsAdmin.ps1
Created February 6, 2025 08:44 — forked from The-Running-Dev/Set-LnkToRunAsAdmin.ps1
Modify Link to run as admin
$linkFilePath = "C:\Users\$([Environment]::UserName)\Desktop\WindowsTerminal.lnk"
$bytes = [System.IO.File]::ReadAllBytes($linkFilePath)
$bytes[0x15] = $bytes[0x15] -bor 0x20 #set byte 21 (0x15) bit 6 (0x20) ON
[System.IO.File]::WriteAllBytes($linkFilePath, $bytes)
@pa-0
pa-0 / removeDependency.sh
Created February 6, 2025 08:44 — forked from The-Running-Dev/removeDependency.sh
How to Remove a Dependency in QNAP Package
# Resources
# Sample package: https://www.myqnap.org/product/radarr-qbase24/
# Create a simple package: https://cheng-yuan-hong.gitbook.io/qdk-qpkg-development-kit/creating-a-qpkg-package-using-qdk/creating-a-simple-qpkg-package
# QNAP SDK docs: https://edhongcy.gitbooks.io/qdk-qpkg-development-kit/content/
# You will need the QNAP SDK, https://github.com/qnap-dev/QDK
# Download the package and put it on your NAS
# SSH into the nas and go to the directory where the package is located
# Create the QNAP build evnironment
@pa-0
pa-0 / Create Kavita Directory Structure
Created February 6, 2025 08:41 — forked from The-Running-Dev/Create Kavita Directory Structure
Scans a directory of eBooks and creates a direcory and sub directories, with hard links to the actual eBooks.
<#
Save to: Create-Kavita-Structure.ps1
and run it with: .\Create-Kavita-Structure.ps1 -sourceDir 'DriveLetter:\PathToBooks' -kavitaDir 'DriveLetter:\PathToKavitaWatchedDir"
If sourceDir is not specified, assumes current directory (.)
If kavitaDir is not specified, assumes @Kavita under the current directory (.\@Kavita)
To test this without making any changes: Create-Kavita-Structure.ps1 -whatIf
#>
[CmdletBinding(SupportsShouldProcess = $true)]
Param(
admin@ip-172-31-90-86:~$ json=$(
cat <<- EOF
{
"foo": "baru-1",
"su": "baru-2",
"dive": "baru-3"
}
EOF
)
admin@ip-172-31-90-86:~$ echo $json

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@pa-0
pa-0 / main.py
Created January 31, 2025 03:36 — forked from DevGW/main.py
SnippetsLab json export to github gist #gists #snippets
### set a tag in snippets lab "exempt" if you do not want snippet to push to github
### set a tag in snippets lab "private" if you want the new gist to be secret
### export SnippetsLab to json document (named: SnippetsLab.json)
### place exported json file in same directory as main.py
### set your GITHUB_USERNAME and your API_TOKEN (personal access token)
### uncomment lines 130 and 131 to delete all your gists on github
### github only allows removing 30 at a time so you may have to run
### this multiple times.
### run: python main.py
@pa-0
pa-0 / clip-rtf2md.sh
Last active January 30, 2025 04:01 — forked from rolandcrosby/gist:c26571bf4e263f695d2f
Convert rich text on the clipboard to Markdown
if encoded=`osascript -e 'the clipboard as «class HTML»'` 2>/dev/null; then echo $encoded | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | pandoc --wrap=none -f HTML -t markdown; else pbpaste; fi
# for my .vimrc:
# command PasteMarkdown :read !if encoded=`osascript -e 'the clipboard as «class HTML»'` 2>/dev/null; then echo $encoded | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | pandoc --no-wrap -f HTML -t markdown; else; pbpaste; fi
# nnoremap ,pmd :PasteMarkdown<CR>