Skip to content

Instantly share code, notes, and snippets.

View MaherSaif's full-sized avatar

Maher Saif MaherSaif

View GitHub Profile
@MaherSaif
MaherSaif / monitor.sh
Created April 23, 2024 21:56 — forked from jpstudioweb/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 \
@MaherSaif
MaherSaif / README.md
Created March 29, 2024 18:06 — forked from hopsoft/README.md
ActiveRecord ETL

ActiveRecord ETL

I created this to help me run benchmarks/comparisons against Universal ID, but it could serve as the foundation for a robust ETL data pipeline... and it's less than 70 LOC right now! 🤯 🚀

It handles the extract and transform parts of an ETL process and supports the following options:

  • only - specify which attributes to include
@MaherSaif
MaherSaif / README.md
Created March 29, 2024 18:03 — forked from hopsoft/README.md
stdin → fzf with preview

stdin → fzf with preview

Setup

  1. Add the script below to your PATH
  2. Pipe anything from stdin to infzf
  3. Enjoy!

Usage

@MaherSaif
MaherSaif / analyzer.rb
Created March 22, 2024 09:44 — forked from fffx/analyzer.rb
blurhash rails-7 with libvips
class BlurhashAnalyzer < ActiveStorage::Analyzer::ImageAnalyzer::Vips
def metadata
read_image do |image|
if rotated_image?(image)
{ width: image.height, height: image.width }
else
{ width: image.width, height: image.height }
end.merge blurhash(image)
end
end
@MaherSaif
MaherSaif / trim.py
Created March 17, 2024 13:26 — forked from kitze/trim.py
trim blank space around images in a folder
from PIL import Image
import os
input_folder = "./public/old"
output_folder = "./public"
if not os.path.exists(output_folder):
os.makedirs(output_folder)
for filename in os.listdir(input_folder):