Skip to content

Instantly share code, notes, and snippets.

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

Faris Hijazi FarisHijazi

:shipit:
ඞඞඞ
View GitHub Profile
from __future__ import annotations
import logging
import warnings
from collections.abc import Callable, Sequence
from typing import Any, Dict, List, Literal, Optional, Set, Tuple, Union
import numpy as np
import requests
from langchain.pydantic_v1 import BaseModel, Extra, Field, root_validator
@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 May 6, 2024 14: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\""