Skip to content

Instantly share code, notes, and snippets.

View NightMachinery's full-sized avatar

Feraidoon Mehri NightMachinery

View GitHub Profile
@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 / 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)
[
"94.24.16.0/21",
"46.34.160.0/19",
"130.244.71.74/32",
"185.214.36.0/22",
"188.214.120.0/23",
"46.38.156.0/22",
"185.103.128.0/22",
"109.122.192.0/18",
"188.210.96.0/19",
// ==UserScript==
// @name ChatGPT Hotkeys
// @description Refresh and Navigate ChatGPT
// @include https://chat.openai.com/*
// ==/UserScript==
(function () {
var url = 'https://chat.openai.com/?model=gpt-4';
var currentIndex = -1;
@NightMachinery
NightMachinery / battery_limit.zsh
Last active November 8, 2025 05:32
A guide on limiting macOS battery charging to at most 80%.
# Apple Silicon laptops with firmware > 13.0 have a native charge threshold that does not required any userspace daemon running.
# This native limit works even when the laptop is sleeping or powered off therefore it is preferable to the userspace daemon.
# Nonetheless, it only works with fixed thresholds (80% as upper limit and 70% as lower limit).
# CHWA key is the one used to enable/disable the native limit. 01 = 80% limit, 00 = no limit
##
typeset -g smc_command="/usr/local/bin/smc"
typeset -g smc_charge_limit_key="CHWA"
typeset -g smc_charge_limit_status_on="01"
typeset -g smc_charge_limit_status_off="00"