Skip to content

Instantly share code, notes, and snippets.

View tomash's full-sized avatar

Tomasz Stachewicz tomash

View GitHub Profile
@MarceloCajueiro
MarceloCajueiro / script.rb
Created July 17, 2018 11:50
Move sidekiq jobs from one queue to another
queue = Sidekiq::Queue.new("default")
queue.each do |job|
if job.klass == "DailyFrequencyCreatorWorker"
DailyFrequencyCreatorWorker.set(queue: 'daily_frequency_creator').perform_async(*job.args)
job.delete
end
end;nil
@ali-sheiba
ali-sheiba / _form.html.erb
Last active July 24, 2024 07:49
Rails scaffold with Bootstrap 4
<%%= form_with(model: <%= model_resource_name %>, local: true) do |form| %>
<div class="card mb-4">
<div class="card-body">
<%% if <%= singular_table_name %>.errors.any? %>
<div id="error_explanation" class="alert alert-danger">
<h2 class="h4"><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
<ul>
<%% <%= singular_table_name %>.errors.full_messages.each do |message| %>
<li><%%= message %></li>
@tenderlove
tenderlove / ngpng.rb
Last active December 12, 2020 14:09
Simple PNG generation example that only depends on zlib in Ruby
# Not Great PNG class. This is a very simple example of writing a PNG. It
# only supports colors from the color palette stored in `@palette`. This is
# meant to be example code, but I am using it in a program for visualizing
# heap dumps from Ruby.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
@jeffchannell
jeffchannell / chapters.sh
Last active January 17, 2025 11:56
Create FFMETADATA for ffmpeg from multiple files.
#!/usr/bin/env bash
# FFMETADATA Chapter generator
# Pass multiple media files to this script to generate a generic FFMETADATA file
# Usage: ARTIST="My Artist" ALBUM="My Album" ./chapters.sh /path/to/*.wav > my.metadata
set -eo pipefail
ARTIST="${ARTIST:-ARTIST}"
ALBUM="${ALBUM:-ALBUM}"
end_stamp=0
begin_stamp=0
i=1
@florentroques
florentroques / vtt2text.py
Last active September 5, 2024 01:44 — forked from glasslion/vtt2text.py
This script converts youtube subtitle file(vtt) to plain text.
"""
Convert YouTube subtitles(vtt) to human readable text.
Download only subtitles from YouTube with youtube-dl:
youtube-dl --skip-download --convert-subs vtt <video_url>
Note that default subtitle format provided by YouTube is ass, which is hard
to process with simple regex. Luckily youtube-dl can convert ass to vtt, which
is easier to process.
@HashNuke
HashNuke / cloudflare-r2-download-worker.js
Last active May 7, 2025 19:47
Cloudflare worker that downloads files from R2 bucket
import jwt from '@tsndr/cloudflare-worker-jwt'
// Add following config to wrangler.toml
//
// r2_buckets = [
// { binding = "STORAGE_BUCKET", bucket_name = "your_bucket_name" }
// ]
//
// Also requires download_jwt_secret in the worker env