Skip to content

Instantly share code, notes, and snippets.

View naveed-ahmad's full-sized avatar
🏋️‍♂️
hacking stuff

Naveed Ahmad naveed-ahmad

🏋️‍♂️
hacking stuff
View GitHub Profile
@palkan
palkan / mailers_preview_spec.rb
Created July 8, 2022 16:15
mailers_preview_spec.rb
# frozen_string_literal: true
require "rails_helper"
# Automatically smoke-test all mailer previews
describe "/rails/mailers" do
subject { response }
ActionMailer::Preview.all.each do |preview|
next if preview.emails.empty?
@Chocksy
Chocksy / Makefile
Last active January 31, 2022 23:49
Docker for Rails + Puma + Nginx + Pagespeed + PostgreSQL + Redis + Memcached on Heroku | https://blog.epicpxls.com/docker-for-rails-puma-nginx-pagespeed-postgresql-redis-memcached-on-heroku-3272d88968f4
# Build the whole docker images.
# - we first copy all the variables from the figaro yml file to a .env file
# - then we build the docker images
# - we start the images
# - we create the database
# Call this with:
# - make build
build:
@ruby docker/env_vars.rb
@docker compose build
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@yshmarov
yshmarov / _thumbnail.html.erb
Last active September 22, 2022 19:36
embed Youtube in ActionText
app/views/youtubes/_thumbnail.html.erb
<div>
<%= image_tag youtube.thumbnail_url, style: "max-width:400px" %>
</div>
# https://github.com/onnx/models/tree/master/vision/body_analysis/emotion_ferplus
require "onnxruntime"
require "mini_magick"
img = MiniMagick::Image.open("ranger.jpg")
img.crop "100x100+60+20", "-gravity", "center"
img.resize "64x64^", "-gravity", "center", "-extent", "64x64"
img.colorspace "Gray"
img.write("resized.jpg")
@aonemd
aonemd / subtitle_extractor.rb
Last active March 7, 2022 14:05
A Ruby script to extract text from images with subtitles and rename the image file to the extracted text (requires Tesseract to be installed)
require 'pathname'
require 'open3'
require 'mini_magick'
SRC_DIR = '/path/to/src/dir/'.freeze
TMP_DIR = '/path/to/tmp/dir/'.freeze
class TextReader
def initialize(input_path, output_path)
@input_path = input_path
@yocontra
yocontra / aoe2hd.md
Last active June 9, 2023 18:28
Age of Empires II HD - For Mac OSX
@yalab
yalab / bootstrap-memo.md
Last active July 20, 2022 20:29
rails5 + webpacker + bootstrap
$ echo 'gem "webpacker"' >> Gemfile
$ bundle install
$ rails webpacker:install
$ yarn add bootstrap@4.0.0-beta jquery popper.js
diff --git a/config/webpack/environment.js b/config/webpack/environment.js
index d16d9af..86bf1a7 100644
@theorygeek
theorygeek / association_loader.rb
Last active October 31, 2023 07:15
Preloading Associations with graphql-batch
# frozen_string_literal: true
class AssociationLoader < GraphQL::Batch::Loader
attr_reader :klass, :association
def initialize(klass, association)
raise ArgumentError, "association to load must be a symbol (got #{association.inspect})" unless association.is_a?(Symbol)
raise ArgumentError, "cannot load associations for class #{klass.name}" unless klass < ActiveRecord::Base
raise TypeError, "association #{association} does not exist on #{klass.name}" unless klass.reflect_on_association(association)
@klass = klass
@wbotelhos
wbotelhos / clear-sidekiq-jobs.sh
Last active April 2, 2024 10:04
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear