Skip to content

Instantly share code, notes, and snippets.

View MaherSaif's full-sized avatar

Maher Saif MaherSaif

View GitHub Profile
@MaherSaif
MaherSaif / compress_video
Created August 22, 2024 11:36 — forked from trvswgnr/compress_video
portable shell script to compress videos with ffmpeg
#!/bin/sh
print_usage() {
echo "usage: compress_video <input_file>"
echo "supported formats: mp4, webm, mkv, mov, avi, flv"
}
get_extension() {
f="${1##*/}"
case "$f" in
@MaherSaif
MaherSaif / service.rb
Created August 6, 2024 12:22 — forked from kyrylo/service.rb
How to define service objects in Rails: the simple way
# frozen_string_literal: true
class ApplicationService
def self.call(...)
new(...).call
end
def initialize(...)
end
end
@MaherSaif
MaherSaif / collect_all_files.py
Created July 26, 2024 07:09 — forked from tarekbadrsh/collect_all_files.py
Multi-File Commenter and Combiner
import os
import fnmatch
def get_comment_prefix(filename):
extension_to_comment = {
'.asm': (';', ';'),
'.awk': ('#', '#'),
'.c': ('//', '//'),
'.clj': (';;', ';;'),
'.cpp': ('//', '//'),
# In your Gemfile
gem "localhost"

# Then, depending on your desired server
gem "falcon"
gem "puma"
@MaherSaif
MaherSaif / monitor.sh
Created April 23, 2024 21:56 — forked from abreujp/monitor.sh
monitor.sh
#!/bin/sh
# link UMC (Universal Modeline Calculator):
# https://sourceforge.net/projects/umc/files/umc/umc-0.2/umc-0.2.tar.gz/download
# compile umc with: "./configure" and "sudo make install" if error install dependencies and repeat.
# chmod +x monitor.sh
# ./monitor.sh
# Alias on .zshrc
# alias monitor='~/monitor.sh'
@MaherSaif
MaherSaif / convert_to_webp.rb
Created April 11, 2024 20:55 — forked from julianrubisch/convert_to_webp.rb
Ruby Oneliners to convert images to webp and generate thumbnails
require 'fileutils'
# Loop through all .jpg and .png files in the current directory
Dir.glob("{*.jpg,*.png}").each do |img|
# Construct the output filename with .webp extension
output_filename = "#{File.basename(img, File.extname(img))}.webp"
# Execute ffmpeg command to convert the image
system("ffmpeg -i '#{img}' '#{output_filename}'")
end
@MaherSaif
MaherSaif / install_vector.sh
Created April 6, 2024 00:22 — forked from stympy/install_vector.sh
Honeybadger Insights config for Hatchbox.io
#!/bin/bash
if [ "$UID" == "0" ]; then
sudo_cmd=''
else
sudo_cmd='sudo'
fi
bash -c "$(curl -sL https://setup.vector.dev)"
@MaherSaif
MaherSaif / broadcastable.rb
Created March 29, 2024 18:14 — forked from hopsoft/broadcastable.rb
Broadcastable model concern/mixin
# frozen_string_literal: true
module Broadcastable
extend ActiveSupport::Concern
def prepend_operation(options = {})
operation = {html: ApplicationController.render(partial: to_partial_path, locals: locals)}
operation.merge options
end
@MaherSaif
MaherSaif / README.md
Created March 29, 2024 18:13 — forked from hopsoft/README.md
Descriptive messages with basic asserts

Descriptive messages with basic asserts

What if I told you that it's possible to get helpful failure messages from basic asserts using idiomatic equality == checks? No DSLs in sight.

This is a proof of concept to demonstrate that it's possible... mostly to satisfy my own curiosity. The concepts here could theoretically be expanded to provide a useful extension to existing testing frameworks or perhaps lay a foundation for an entirely new one.

This experiment created with Ruby 3.0.1. Note to self: There's probably a way to do this with TracePoint instead of monkey patching but I couldn't figure out how to get a reference to the passed variable being compared.

Examples:

@MaherSaif
MaherSaif / Dockerfile
Created March 29, 2024 18:10 — forked from hopsoft/Dockerfile
Ruby + SQLite Dockerfile
FROM ruby:3.2.2-alpine
# ============================================================================================================
# Install system packages
# ============================================================================================================
RUN apk add --no-cache --update \
bash \
build-base \
curl \
gcompat \