Skip to content

Instantly share code, notes, and snippets.

View MaherSaif's full-sized avatar

Maher Saif MaherSaif

View GitHub Profile
@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
@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 April 22, 2024 21:28
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,
@codemasher
codemasher / timeline.php
Last active December 14, 2022 16:49
Fetch your twitter timeline via the unofficial adaptive search API
<?php
/**
* Twitter timeline backup
*
* Required:
* - PHP 8.1+
* - cURL extension enabled
* - Windows:
* - download https://windows.php.net/downloads/releases/php-8.1.12-Win32-vs16-x64.zip (or a newer available version)
* - unzip to a folder of your choice
@benoittgt
benoittgt / file.vim
Last active April 6, 2024 10:28
iamaputsemojidebugger
function! IAmAPutsEmojiDebugger()
ruby <<EOS
separator = rand(0x1F601..0x1F64F).chr('UTF-8')
VIM::command("normal! oputs '#{separator}' * (`tput cols`.to_i / 2)")
VIM::command('normal! oputs "#{__FILE__}:#{__LINE__}"')
VIM::command("normal! oputs '#{separator}' * (`tput cols`.to_i / 2)")
EOS
@yahonda
yahonda / ruby31onrails.md
Last active April 9, 2024 20:46
Ruby 3.1 on Rails

Ruby 3.1 on Rails

Actions required to use Ruby 3.1.0 with Rails

Rails 7.0.Z

  • Rails 7.0.1 is compatible with Ruby 3.1.0.
  • Rails 7.0.1 addes net-smtp, net-imap and net-pop gems as Action Mailbox and Action Mailer dependency, you do not need to add them explicitly in your application Gemfile anymore.
  • thor 1.2.1 has been released. You will not see DidYouMean::SPELL_CHECKERS.merge deprecate warnings anymore.

Rails 6.1.Z

  • Use Rails 6.1.5 to support database.yml with aliases and secrets.yml with aliases.