Skip to content

Instantly share code, notes, and snippets.

@varenc
varenc / get_gists.py
Last active June 14, 2023 20:29 — forked from selimslab/get_gists.py
Download all gists of a user
#!/usr/bin/env python3
import sys
from subprocess import call
import json
import os
import requests
import shutil
import colorama
@varenc
varenc / zshexpn-explained.md
Created November 26, 2022 02:01 — forked from roblogic/zshexpn-explained.md
Regular Expressions in Zsh

The following is taken from a brilliant answer on unix.se. Posting it here for personal reference. The question was:

${var//pattern/replacement} is using zsh wildcard patterns for pattern, the same ones as used for filename generation aka globbing which are a superset of the sh wildcard patterns. The syntax is also affected by the kshglob and extendedglob options. The ${var//pattern/replacement} comes from the Korn shell initially.

I'd recommend enabling extendedglob (set -o extendedglob in your ~/.zshrc) which gives you the most features (more so than standard EREs) at the expense of some backward incompatibility in some corner cases.

You'll find it documented at info zsh 'filename generation'.

@varenc
varenc / profile_defaults.md
Created May 6, 2022 01:37 — forked from dlevi309/profile_defaults.md
An extensive list of settings written when installing a debugging profile from developer.apple.com

MediaPlayer logging:

defaults: {
    "com.apple.homesharing" =     {
        HSConsoleLoggingLevel = 7;
        HSLogFileLoggingLevel = 7;
        HSLogging = 1;
    };
    "com.apple.medialibrary" =     {
@varenc
varenc / launchctl_man_pages.md
Created January 6, 2022 00:49 — forked from dmattera/launchctl_man_pages.md
macOS man page entries for launchctl services

This list was auto-generated on macOS 10.15 (Catalina) using a script that did the following:

  1. grabbed the name of all the .plist files located in the 5 folders used by launchctl:
  • ~/Library/LaunchAgents Per-user agents provided by the user.
  • /Library/LaunchAgents Per-user agents provided by the administrator.
  • /Library/LaunchDaemons System wide daemons provided by the administrator.
  • /System/Library/LaunchAgents OS X Per-user agents.
  • /System/Library/LaunchDaemons OS X System wide daemons.
@varenc
varenc / README.md
Last active December 4, 2021 22:03 — forked from Jahhein/README.md
Display Apple AirPods battery levels via Terminal
@varenc
varenc / close_notifications_applescript.js
Created June 6, 2021 21:56 — forked from lancethomps/close_notifications_applescript.js
AppleScript to close all notifications on macOS Big Sur
function run(input, parameters) {
const appName = "";
const verbose = true;
const scriptName = "close_notifications_applescript";
const CLEAR_ALL_ACTION = "Clear All";
const CLEAR_ALL_ACTION_TOP = "Clear";
const CLOSE_ACTION = "Close";
@varenc
varenc / system-wide-clipboard.zsh
Last active August 31, 2024 23:38 — forked from welldan97/system-wide-clipboard.zsh
Zsh copy & paste system wide for OS X, like in emacs
## 2020-05-16: Changed `echo` to `printf` so that backslashes are not interpretted by echo
## and so that CUTBUFFER shows up exactly in the pasteboard without modification
pb-kill-line () {
zle kill-line
printf '%s' $CUTBUFFER | pbcopy
}
pb-kill-whole-line () {
zle kill-whole-line
@varenc
varenc / export.js
Created March 21, 2021 00:29 — forked from loilo/export.js
Browser console support for shellking4
// Copy this whole snippet to your browser console
var dbName = prompt("What's the name of the database to export?")
;(async () => {
try {
var dbExists = await new Promise(resolve => {
var request = window.indexedDB.open(dbName)
request.onupgradeneeded = e => {
e.target.transaction.abort()
@varenc
varenc / DefaultKeyBinding.dict
Created March 11, 2021 00:37 — forked from trusktr/DefaultKeyBinding.dict
My DefaultKeyBinding.dict for Mac OS X
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
/* file: main.c function: get and set capslock state complie: gcc -std=c99 -framework IOKit -framework CoreFoundation -o
* capslock main.c usage: ./capslock [0|1|-1] 0 : capslock off 1 : capslock on -1 : toggle capslock state : print
* current capslock state (0|1) * written and published as free software by Hiroto, 2015-06 */
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/hidsystem/IOHIDLib.h>
#include <IOKit/hidsystem/IOHIDParameter.h>
#include <libgen.h> // basename
#define CAPSLOCK_OFF 0
#define CAPSLOCK_ON 1