Skip to content

Instantly share code, notes, and snippets.

View khurshid-alam's full-sized avatar

Khurshid Alam khurshid-alam

View GitHub Profile
@khurshid-alam
khurshid-alam / start-app-in-bg.applescript
Created January 16, 2025 19:46
Applescript: Start an app in background
-- Try to start an app in Background
set thisApp to "Keep it Shot"
startUnseen for "Keep it Shot"
on startUnseen for thisApp
if running of application thisApp is false then tell application thisApp to activate
delay 0.1
tell application id "sevs" to set visible of application process thisApp to false
end startUnseen
@khurshid-alam
khurshid-alam / BTT-Middle-Click-Quick-Look.js
Last active August 4, 2024 23:22
//This is javascript action performed by BetterTouchTool when you middle click on any file. // Basically what it does is, to take hover_element_data & extracting file ref url, //then converting it POSIX url which then passed to shell command "qlmanager -p". // MAke sure to set it to "Trigger on mouse up" & include "Maximum hold time". //This is …
//This is javascript action performed by BetterTouchTool when you middle click on any file.
// Basically what it does is, to take hover_element_data & extracting file ref url,
//then converting it POSIX url which then passed to shell command "qlmanager -p".
// MAke sure to set it to "Trigger on mouse up" & include "Maximum hold time".
//This is useful if you set double middle click action with minimum hold time.
//Here maximum hold time needs to be < minimum hold time of that double middle click action.
// To support more files install https://github.com/sbarex/SourceCodeSyntaxHighlight.
@khurshid-alam
khurshid-alam / BTT-Finder-context-menu-new-file.sh
Created August 2, 2024 12:29
# This needs to be put in "Run terminal command (async)" section of Finder context menu configuration in BetterTouchTool # See full tutorial here:
#!/bin/bash
# This needs to be put in "Run terminal command (async)" section of Finder context menu configuration in BetterTouchTool
# See full tutorial here:
filePath="{BTTFinderContextMenuTargetPath}/untitled";fileNo=1;while [ -f "${filePath}" ];do filePath="{BTTFinderContextMenuTargetPath}/untitled${fileNo}";fileNo=$((fileNo+1));done;touch "${filePath}"
@khurshid-alam
khurshid-alam / set_warp_as_default_term.m
Created July 8, 2024 23:31
#This sets warp as default terminal in mac # Code taken from iTerm2 #https://github.com/warpdotdev/Warp/issues/753#issuecomment-1817856836 #Compile with following #clang -framework Foundation -framework CoreServices -o SetDefaultTerminal <path to your .m file> && ./SetDefaultTerminal in the command line
#This sets warp as default terminal in mac
# Code taken from iTerm2
#https://github.com/warpdotdev/Warp/issues/753#issuecomment-1817856836
#Compile with following
#clang -framework Foundation -framework CoreServices -o SetDefaultTerminal <path to your .m file> && ./SetDefaultTerminal in the command line
#import <Foundation/Foundation.h>
@khurshid-alam
khurshid-alam / get_script_name.sh
Created June 19, 2024 11:32
Get scripot name and path from inside bash script. see https://stackoverflow.com/a/246128/10200417
#!/bin/bash
# see https://stackoverflow.com/a/246128/10200417
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
script_name=`basename $0`
# echo "called script $script_name from $script_dir"
(async()=>{
AS=s=>(runAppleScript(s))
PA=n=>{trigger_action({json:JSON.stringify({BTTPredefinedActionType:n})})}
a=await get_string_variable("hovered_element_details")
v=i=>(a.split('AX'+i+': "')[1].split('"')[0])
F=v('Subrole').slice(2,4)˛
console.log("Hello world!")
@khurshid-alam
khurshid-alam / Mac-mouse-fix-toggle.scpt
Last active June 13, 2024 00:03
Toggle mac mouse fix, to be used with Better touch tool/Keyboard Maestro
set appName to "Mac Mouse Fix Helper"
if application appName is not running then
set cmdStr to "open \"/Applications/Mac Mouse Fix.app/Contents/Library/LoginItems/Mac Mouse Fix Helper.app\""
do shell script cmdStr
else if application appName is running then
do shell script "killall \"Mac Mouse Fix Helper\""
end if
USERNAME [a-zA-Z0-9._-]+
USER %{USERNAME}
INT (?:[+-]?(?:[0-9]+))
BASE10NUM (?<![0-9.+-])(?>[+-]?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+)))
NUMBER (?:%{BASE10NUM})
BASE16NUM (?<![0-9A-Fa-f])(?:[+-]?(?:0x)?(?:[0-9A-Fa-f]+))
BASE16FLOAT \b(?<![0-9A-Fa-f.])(?:[+-]?(?:0x)?(?:(?:[0-9A-Fa-f]+(?:\.[0-9A-Fa-f]*)?)|(?:\.[0-9A-Fa-f]+)))\b
POSINT \b(?:[1-9][0-9]*)\b
NONNEGINT \b(?:[0-9]+)\b
@khurshid-alam
khurshid-alam / sysctl.conf
Created October 19, 2020 17:39 — forked from yegorg/sysctl.conf
ubuntu sysctl performance tuning
# Kernel sysctl configuration file for Linux
#
# Version 1.12 - 2015-09-30
# Michiel Klaver - IT Professional
# http://klaver.it/linux/ for the latest version - http://klaver.it/bsd/ for a BSD variant
#
# This file should be saved as /etc/sysctl.conf and can be activated using the command:
# sysctl -e -p /etc/sysctl.conf
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and sysctl.conf(5) for more details.
@khurshid-alam
khurshid-alam / sysctl.conf
Created October 19, 2020 17:39 — forked from yegorg/sysctl.conf
ubuntu sysctl performance tuning
# Kernel sysctl configuration file for Linux
#
# Version 1.12 - 2015-09-30
# Michiel Klaver - IT Professional
# http://klaver.it/linux/ for the latest version - http://klaver.it/bsd/ for a BSD variant
#
# This file should be saved as /etc/sysctl.conf and can be activated using the command:
# sysctl -e -p /etc/sysctl.conf
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and sysctl.conf(5) for more details.