Skip to content

Instantly share code, notes, and snippets.

View MaherSaif's full-sized avatar

Maher Saif MaherSaif

View GitHub Profile
@trvswgnr
trvswgnr / compress_video
Last active August 25, 2024 05:50
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
@tarekbadrsh
tarekbadrsh / collect_all_files.py
Last active July 26, 2024 07:09
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"
@julianrubisch
julianrubisch / convert_to_webp.rb
Last active April 26, 2024 08:27
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
@vjanssens
vjanssens / caddy.json
Last active June 22, 2024 16:20
lnav log definition for Caddy server
{
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
"caddy": {
"title": "Caddy Server",
"description": "Caddy Server JSON access logs format",
"url": [
"https://caddyserver.com/docs/caddyfile/directives/log"
],
"json": true,
"timestamp-field": "ts",
@fatkodima
fatkodima / inspect_queries.rb
Created January 17, 2024 00:35
Inspect db queries
# Make sure to have prepared statements enabled.
# config/database.yml
# test:
# database: ...
# prepared_statements: true
# Add this to the top scope of test/test_helper.rb or spec/rails_helper.rb and
# run tests as usual.
queries = Hash.new(0)
@robzolkos
robzolkos / Dockerfile
Last active March 2, 2024 20:59
Kamal / SQLite3 issue
# syntax = docker/dockerfile:1
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.2.2
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
# Rails app lives here
WORKDIR /rails
# Set production environment
@goulvench
goulvench / render_flash_now_for_xhr.rb
Created May 18, 2023 12:46
Force Rails to render flash messages for XHR responses
# To display flash messages inside XHR responses,
# place this file in app/controllers/concerns/
# then include it in ApplicationController
module RenderFlashNowForXhr
extend ActiveSupport::Concern
private
# Flash messages are not directly available for XHR requests
@kconner
kconner / macOS Internals.md
Last active August 24, 2024 23:42
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

This file has been truncated, but you can view the full file.
{
"1594486665971892224": {
"id": 1594486665971892224,
"user_id": 16298441,
"user": null,
"created_at": 1668990219,
"text": "if you tell me The Mask is standing behind me i will turn around and try to look at it. Because my dumb ass thinks The Mask is real",
"source": "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>",
"retweet_count": 670,
"favorite_count": 7772,