Skip to content

Instantly share code, notes, and snippets.

View NightMachinery's full-sized avatar

Feraidoon Mehri NightMachinery

View GitHub Profile
@NightMachinery
NightMachinery / set-focus-mode.js
Created November 26, 2022 21:50 — forked from drewkerr/set-focus-mode.js
Set a Focus mode on macOS Monterey (12.0+) using JavaScript for Automation (JXA)
function toggleFocus(focus) {
const app = Application("System Preferences")
const pane = app.panes.byId("com.apple.preference.notifications").anchors.byName("Focus")
app.reveal(pane) // Open the preference pane
// Useful way of inspecting the UI hierarchy of an open app:
// Application("System Events").applicationProcesses.byName("System Preferences").entireContents()
const ui = Application("System Events").applicationProcesses.byName("System Preferences").windows.byName("Notifications & Focus").tabGroups.at(0)
@NightMachinery
NightMachinery / get_latest_release.zsh
Last active April 17, 2021 13:15 — forked from lukechilds/get_latest_release.sh
Shell - Get latest release from GitHub
## See latest version at https://github.com/NightMachinary/.shells/blob/master/scripts/zshlang/auto-load/others/github.zsh
## Usage:
# $ gh-release-get "creationix/nvm"
##
alias ec='print -r --'
function gh-release-get() {
local repo="$1"
local releases
releases="$(curl -s https://api.github.com/repos/"$repo"/releases)"
@NightMachinery
NightMachinery / areplace.sh
Last active December 2, 2021 00:13 — forked from hlissner/replace.sh
Bulk search & replace with ag (the_silver_searcher)
# ag <https://github.com/ggreer/the_silver_searcher>
# from=str1 to=sth agr path1 path2 ...
# backs up to .pbak
comment() {
}
doc() {
}
function agr {
doc 'usage: from=sth to=another agr [ag-args]'