Skip to content

Instantly share code, notes, and snippets.

View sjoulbak's full-sized avatar

Remco Meinen sjoulbak

  • Enschede, Netherlands
View GitHub Profile
@jmhakvoort
jmhakvoort / each_with_progress.rb
Last active February 9, 2026 13:54
Cool Enumerable#each_with_progress I once wrote so I can see how long iterating will take. I have waited too long on empty processes already. Most of the code is a blatant copy of existing code I found on the interwebs, but unfortunately I don't remember where. My contributions are mostly with the RAILS_ENV guard and the output.
module Enumerable
def each_with_progress(&block)
if ENV['RAILS_ENV'] == 'test'
each do |element|
block.call element
end
else
out = $stderr
time = Time.current
total = count
@carlosramireziii
carlosramireziii / attached_validator.rb
Last active April 10, 2024 11:11
A validator and RSpec matcher for requiring an attachment using Active Storage
class AttachedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :attached, options) unless value.attached?
end
end
@sconstantinides
sconstantinides / styles.css
Created April 27, 2018 23:06
PWA media queries
/* Replace "standalone" with "fullscreen" depending on your manifest.json display mode */
@media (display-mode: standalone) {
/* All installed PWAs */
}
@media (max-width: 576px) and (display-mode: standalone) {
/* Installed PWAs on mobile devices */
@supports (-webkit-overflow-scrolling: touch) {