Skip to content

Instantly share code, notes, and snippets.

View pedromschmitt's full-sized avatar
🎲

Pedro Schmitt pedromschmitt

🎲
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
@wndxlori
wndxlori / send_to_kindle.rb
Last active April 15, 2024 20:00
When you have a whole LOT of ebooks to send to your Kindle
#!/Usr/bin/env ruby
require 'mail'
require 'fileutils'
# Check if a command line argument is provided
if ARGV.length < 1
puts "Usage: ruby send_to-kindle.rb <directory containing epub files>"
exit 1
@dhh
dhh / linux-setup.sh
Last active July 17, 2024 08:59
linux-setup.sh
# THIS LINUX SETUP SCRIPT HAS MORPHED INTO A WHOLE PROJECT: HTTPS://OMAKUB.ORG
# PLEASE CHECKOUT THAT PROJECT INSTEAD OF THIS OUTDATED SETUP SCRIPT.
#
#
# Libraries and infrastructure
sudo apt update -y
sudo apt install -y \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
@romulogomes
romulogomes / rails_helper.rb
Last active May 2, 2024 16:32
Factories lowest
def red(text)
"\033[31m#{text}\033[0m"
end
number_of_factories_to_analyze = 10
load_begin = Time.now
stats = {}
ActiveSupport::Notifications.subscribe("factory_bot.run_factory") do |_name, start, finish, _id, payload|
execution_time_in_seconds = finish - start
stats[payload[:name]] = stats[payload[:name]].to_f + execution_time_in_seconds
@lucataco
lucataco / ollama_fast_speech_text_speech.py
Last active July 16, 2024 09:14
speech to text to speech using Ollama
""" To use: install Ollama, clone OpenVoice, run this script in the OpenVoice directory
brew install portaudio
brew install git-lfs
git lfs install
git clone https://github.com/myshell-ai/OpenVoice
cd OpenVoice
git clone https://huggingface.co/myshell-ai/OpenVoice
cp -r OpenVoice/* .
@secretpray
secretpray / Integration of TinyMCE in Rails 7 with Turbo Drive Support.md
Created January 13, 2024 23:16
Integration of TinyMCE in Rails 7 with Turbo Drive Support

Integration of TinyMCE in Rails 7 with Turbo Drive Support

Since Rails 7 the turbo-rails library is included by default. Turbo Drive intercepts link clicks and form submits. It makes sure that only the <body> part of the page is rerendered instead of the whole page.

This leads to TinyMCE not being properly detached and reattached when a Turbo Drive response is rendered. The textarea will appear without the TinyMCE editor. In this post we expand on the tinymce-rails gem with a Stimulus controller to prevent this issue. The controller helps to reattach TinyMCE and respects the settings in config/tinymce.yml.

If you want to follow along or check out the end result you can find an example respository here: https://github.com/david-uhlig/example-tinymce-rails7-turbo

Instructions

@sbounmy
sbounmy / .env.production
Last active May 21, 2024 18:34
Files to deploy Rails 7 app with Kamal
KAMAL_REGISTRY_PASSWORD=xxx
RAILS_MASTER_KEY=xxxxxxxxxxxxxxx
POSTGRES_PASSWORD=xxxxxxxxxxxxx
REDIS_PASSWORD=my-redis-password
REDIS_URL=redis://:my-redis-password@n28-redis:6379/1
@jnunemaker
jnunemaker / active_job_checkins.rb
Created September 28, 2023 14:31
Automatic honey badger check ins for active job. Just setup the check in with honey badger and configure an env var to the identifier they provide.
# Set HONEYBADGER_FOO_BAR_JOB=asdf where asdf is the check in value Honeybadger gives you.
class ApplicationJob < ActiveJob::Base
after_perform { |job| job.honeybadger_checkin }
# Check in with Honeybadger to let us know that the job was performed
# if there is an identifier configured for the job.
def honeybadger_checkin
identifier = honeybadger_checkin_identifier
return unless identifier.present?
#!/usr/bin/env ruby
require "net/ssh"
branch = `git rev-parse --abbrev-ref HEAD`.chomp
unless branch == 'main'
puts "oops! you're on a different branch. Merge your changes into main and then try again."
puts "exiting.."
return
end

OpenBSD logo     Rails logo     Falcon logo


Choose OpenBSD for your Unix needs. OpenBSD -- the world's simplest and most secure Unix-like OS. A safe alternatve to the frequent vulnerabilities and overengineering of Linux and related software (NGiNX & Apache (httpd-asiabsdcon2015.pdf), OpenSSL, iptables/nftables, systemd, BIND, Postfix, Docker etc.)

OpenBSD -- the cleanest kernel, the cleanest userland and the cleanest config