Skip to content

Instantly share code, notes, and snippets.

📎
Working on Shrine 3.0

Janko Marohnić janko

📎
Working on Shrine 3.0
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
janko / results
Created Mar 7, 2019
MiniMagick vs libvips benchmark (generating a 500x500 thumbnail)
View results
ImageMagick,libvips
0.124, 0.05
0.187, 0.069
0.345, 0.064
0.424, 0.073
0.513, 0.087
@janko
janko / script.rb
Last active Jan 25, 2019
Ruby operator coercion inconsistency
View script.rb
Value = Struct.new(:value) do
def coerce(other)
puts "called #{self}#coerce(#{other.inspect})"
[Value.new(other), self]
end
def +(other)
puts "called #{self} + #{other.inspect}"
end
@janko
janko / derivate_endpoint.md
Last active Nov 18, 2018
Plans for the new derivate_endpoint Shrine plugin
View derivate_endpoint.md

Derivate Endpoint

Derivate blocks are executed in context of the uploader instance:

class ImageUploader < Shrine
  plugin :derivate_endpoint

  derivate :thumbnail do |file, context|
@janko
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
janko / script.rb
Last active Oct 10, 2018
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
end
@janko
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
DB.disconnect
system "dropdb testing"
end
@janko
janko / Gemfile
Created May 31, 2018
Memory profiling of http.rb and other popular Ruby HTTP client libraries
View Gemfile
source "https://rubygems.org"
gem "roda"
gem "http", "~> 3.3"
gem "rest-client"
gem "httparty"
@janko
janko / shrine-uppy-checksum.md
Last active May 4, 2018
Short guide showing how to use checksums when doing direct (S3) uploads using Uppy and Shrine
@janko
janko / walkthrough-resumable.md
Last active May 4, 2018
Simple walkthrough for adding resumable uploads to a Roda & Sequel app with Shrine
@janko
janko / walkthrough-app.md
Last active May 13, 2018
Simple walkthrough for adding direct (S3) uploads to a Roda & Sequel app with Shrine
You can’t perform that action at this time.