Skip to content

Instantly share code, notes, and snippets.

View ammar-faifi's full-sized avatar
🎯
Focusing

ammar-faifi

🎯
Focusing
View GitHub Profile
@ammar-faifi
ammar-faifi / kitty.conf
Created December 6, 2023 18:02
kitty terminal map with regex to open python error in nvim with specified line number
# add this to your kitty config: `~/.config/kitty/kitty.conf`
map ctrl+g kitten hints --type=linenum --regex='(?P<path>\/.*?\.[\w:]+)",\sline\s(?P<line>\d*)' --program='tab nvim +{line} {path}'
@ammar-faifi
ammar-faifi / samplt.cs
Created December 6, 2023 17:30
GraphQL fetch to Petroly
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
await FetchDataFromGraphQL();
@ammar-faifi
ammar-faifi / fetch.js
Last active November 16, 2023 15:38
sample of requesting no-authorized data from Petroly API
const endpointUrl = 'https://api.petroly.co/';
const graphqlQuery = `
{
search(term: "202320", department: "ICS", title: "")
}
`;
fetch(endpointUrl, {
method: 'POST',
@ammar-faifi
ammar-faifi / reduce_with_ffmpeg.py
Created July 28, 2023 07:46
Using `ffmpeg` to reduce quality video and convert it to `mp4`
import subprocess
def reduce_video_quality(
input_file,
output_file,
target_resolution=(640, 360),
target_fps=30,
target_bitrate="1500k",
):
@ammar-faifi
ammar-faifi / reduce_and_stack.py
Last active July 28, 2023 07:48
Reduce quality of `jpg` images and stack on them `png` logos
from PIL import Image
import os
import glob
def resize_and_reduce_quality(input_dir, output_dir, max_size, quality):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
for filename in os.listdir(input_dir):
@ammar-faifi
ammar-faifi / convert_to_mp4.py
Created July 28, 2023 07:44
Read and convert `.mov` video into `.mp4` extension
from moviepy.editor import VideoFileClip
def convert_mov_to_mp4(input_file, output_file):
try:
video_clip = VideoFileClip(input_file, target_resolution=(1920, 1080))
video_clip.write_videofile(
output_file,
codec="libx264",
audio_codec="aac",
@ammar-faifi
ammar-faifi / shuffle_names.py
Created July 28, 2023 07:42
read and shuffle CSV names into groups in terminal
import random
def read_csv(file_path):
with open(file_path, "r") as file:
lines = file.readlines()
rows = [line.strip().split(",") for line in lines]
return rows