Skip to content

Instantly share code, notes, and snippets.

Janko Marohnić janko

Block or report user

Report or block janko

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
janko / shrine-cli.rb
Created Mar 24, 2020
The CLI I wrote for creating new AWS S3 buckets for reproducing issues reported for Shrine. It's can serve as an example for programmatically creating new S3 buckets with bucket-specific credentials.
View shrine-cli.rb
#!/usr/bin/env ruby
require "dry/cli"
require "aws-sdk-s3"
require "aws-sdk-iam"
require "json"
janko / application_controller.rb
Last active Oct 31, 2019
Simpler implementation of ActionController::Live
View application_controller.rb
class ApplicationController < ActionController::Base
def stream_body(async: false, **options, &block)
self.status ||= 200
self.headers["Cache-Control"] = "no-cache"
stream_class = async ? AsyncStream : Stream
janko / results
Last active Aug 24, 2019
MiniMagick vs libvips benchmark (generating a 500x500 thumbnail)
View results
width, imagemagick, libvips
1000, 0.129, 0.045
1500, 0.190, 0.067
2000, 0.276, 0.054
2500, 0.380, 0.068
3000, 0.498, 0.085
janko / script.rb
Last active Jan 25, 2019
Ruby operator coercion inconsistency
View script.rb
Value = do
def coerce(other)
puts "called #{self}#coerce(#{other.inspect})"
[, self]
def +(other)
puts "called #{self} + #{other.inspect}"
janko /
Last active Nov 18, 2018
Plans for the new derivate_endpoint Shrine plugin

Derivate Endpoint

Derivate blocks are executed in context of the uploader instance:

class ImageUploader < Shrine
  plugin :derivate_endpoint

  derivate :thumbnail do |file, context|
janko / script.rb
Created Oct 29, 2018
Zip unpacking with Shrine while retaining the same directory structure
View script.rb
require "sequel"
require "shrine"
require "shrine/storage/memory"
require "zip"
require "tempfile"
require "securerandom"
DB = Sequel.sqlite
DB.create_table :archives do
primary_key :id
janko / script.rb
Last active Apr 30, 2020
Workaround for embedded documents in shrine-mongoid
View script.rb
require "mongoid"
require "shrine"
require "shrine/storage/memory"
require "stringio"
Mongoid.configure do |config|
config.clients.default = { hosts: ['localhost:27017'], database: 'my_db' }
config.log_level = :debug
janko / benchmark.rb
Last active Sep 16, 2018
Benchmarking different ways of filtering by the associated dataset in SQL
View benchmark.rb
require "sequel"
require "benchmark"
system "createdb testing"
DB = Sequel.postgres("testing")
at_exit do
system "dropdb testing"
janko / Gemfile
Created May 31, 2018
Memory profiling of http.rb and other popular Ruby HTTP client libraries
View Gemfile
source ""
gem "roda"
gem "http", "~> 3.3"
gem "rest-client"
gem "httparty"
janko /
Last active May 4, 2018
Short guide showing how to use checksums when doing direct (S3) uploads using Uppy and Shrine
You can’t perform that action at this time.