Skip to content

Instantly share code, notes, and snippets.

View FarisHijazi's full-sized avatar
:shipit:
ඞඞඞ

Faris Hijazi FarisHijazi

:shipit:
ඞඞඞ
View GitHub Profile
@FarisHijazi
FarisHijazi / azure_pr.sh
Created January 16, 2023 12:32
git push, create pr, approve, and merge for azure devops (using `az` azure devops cli)
#!/bin/bash
# create pull request for current git branch and merge using azurecli
git push --set-upstream origin "$(git branch --show-current)" || exit
if pr_list=$(az repos pr list --output json --source-branch "$(git branch --show-current)"); then
if [ $(echo "$pr_list" | jq '. | length') -gt 0 ]; then
pullRequestId=$(echo "$pr_list" | jq '.[0].pullRequestId')
echo "A pull request already exists for the current branch with ID: $pullRequestId"
else
resp=$(az repos pr create --auto-complete true --delete-source-branch true --source-branch "$(git branch --show-current)" --output json) && \
@FarisHijazi
FarisHijazi / backupLGHUB.sh
Last active April 26, 2022 16:04
LGHUB backup and restore profiles and settings
echo backing up LGHUB
rm -rf LGHUBlocal LGHUBroaming
cp -r C:/Users/faris/AppData/Local/LGHUB LGHUB-local
cp -r C:/Users/faris/AppData/Roaming/LGHUB LGHUB-roaming
zip -r LGHUB-local-`date +%Y%m%d_%H%M%S`.zip LGHUB-local/*
zip -r LGHUB-roaming-`date +%Y%m%d_%H%M%S`.zip LGHUB-roaming/*
@FarisHijazi
FarisHijazi / ffmpeg_blackdetect.py
Last active October 18, 2022 16:25
detect and remove black parts of a video using ffmpeg `trim`.
print("""
this file is has migrated to https://github.com/FarisHijazi/deblack/blob/master/deblack.py
Please go head over to the repository and contribute to the project
""")
"""
VoiceFixer
$ python voicefixer_cli.py -i ~/Downloads/download.mp3
# for running on multiple files
$ find path/to/folder -name "*.wav" -not -name "*denoised*" |xargs -P 20 -I{} sh -c 'python voicefixer_cli.py -i {}'
"""
"""
@FarisHijazi
FarisHijazi / getGoogleImages.gs.js
Created September 8, 2021 12:14
Google images thumbnail fetcher for google sheets script
/*
* @author https://github.com/FarisHijazi
* @param query (string): search query to send to google
*
* this script fetches a google images page and uses regex to extract thumbnail URLs
* more work can be done like extracting names and descriptions too
*/
function getGoogleImages(query) {
if (!query) return [];
var html = UrlFetchApp.fetch("https://www.google.com/search?hl=en&tbm=isch&q=" + encodeURIComponent(query.trim()), {
@FarisHijazi
FarisHijazi / vidsplit.sh
Last active September 26, 2021 10:01
segment videos into video or GIF segments using ffmpeg
#!/bin/bash
# https://gist.github.com/FarisHijazi/4ba8d9768eddc6f218ecd21824c24909
#TODO: fix directory naming, name it something related to the file
# argparsing from: https://stackoverflow.com/a/39376824/7771202
# usage function
function usage()
{
@FarisHijazi
FarisHijazi / wheelup_jump.ahk
Created September 22, 2020 21:04
AutoHotkey script to bind mousewheel-up to spacebar, for bunny hopping in video games
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, force
~*wheelup::
sendinput, {Space}
Return
@FarisHijazi
FarisHijazi / googleimages_parse2020format2rg_meta.js
Created April 7, 2020 21:49
Google images new format (2020) is unparsable (unlike using `.rg_meta`), this script will parse the first 100 or so images on a google images page and return
// code to get this:
/**
* @author github.com/FarisHijazi
*
* @returns {{ "id": String, "tu": String, "th": String, "tw": String, "ou": String, "oh": String, "ow": String, "pt": String, "st": String, }[]}
* returns a list of objects, these contain the image info
*
* how it works:
* there's a <script> that contains the images info, the code in it contains `AF_initDataCallback`
@FarisHijazi
FarisHijazi / Unzip_and_delete.reg
Last active April 16, 2024 20:28
7zip: Unzip and delete context menu. Registry entry and .bat file for windows context menu "unzip and delete" command. instead of needing to unzip, then delete an archive manually
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Unzip and delete]
"icon"="C:\\Program Files\\7-Zip\\7zG.exe"
[HKEY_CLASSES_ROOT\*\shell\Unzip and delete\command]
@="\"<PATH TO>\\unzip_and_delete.bat\" \"%1\""
@FarisHijazi
FarisHijazi / snoopProperty.js
Created May 12, 2019 19:07
JavaScript snoop properties of objects. Bind callbacks to getters and setters for all properties of an object. Useful for observing how a page element has its properties accessed
/**
* Snoops on an object, monitors all attempts to access and set properties
* @param {Object} obj - the object to monitor
* @param {string[]=} props - list of properties to watch, watches all properties by default
* @param {Function=} onset - callback when the property is set (newValue is passed)
* @param {Function=} onget - callback when the property is accessed
* @param verbose
*/
function snoopProperty(obj, props = [], onset = (val) => null, onget = () => null, verbose = true) {