Skip to content

Instantly share code, notes, and snippets.

View janko's full-sized avatar

Janko Marohnić janko

View GitHub Profile
@janko
janko / script.rb
Created October 29, 2018 22:16
Zip unpacking with Shrine while retaining the same directory structure
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 September 5, 2022 23:13
Workaround for embedded documents in shrine-mongoid
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 September 16, 2018 23:01
Benchmarking different ways of filtering by the associated dataset in SQL
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 19:57
Memory profiling of http.rb and other popular Ruby HTTP client libraries
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 20:33
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 20:32
Simple walkthrough for adding resumable uploads to a Roda & Sequel app with Shrine
@janko
janko / walkthrough-app.md
Last active May 13, 2018 09:53
Simple walkthrough for adding direct (S3) uploads to a Roda & Sequel app with Shrine
@janko
janko / concatenation.rb
Last active September 8, 2016 03:14
Concatenation plugin for Shrine
class Shrine
module Plugins
# The `concatenation` plugin allows you to assign to the attacher a
# cached file which is composed of multiple uploaded parts. The plugin
# will then call `#concat` on the storage, which is expected to
# concatenate the given parts into a single file. The assigned
# attachment will then be a complete cached file.
#
# plugin :concatenation
#
@janko
janko / 0-gemfile.rb
Created July 31, 2016 11:24
Using Shrine with ROM and dry-rb
source "https://rubygems.org"
gem "shrine", github: "janko-m/shrine"
gem "rom-repository"
gem "rom-sql"
gem "sqlite3"
gem "dry-validation"
gem "roda"
gem "sucker_punch", "~> 2.0"
@janko
janko / activerecord.md
Last active May 7, 2016 11:33
Response to http://bikeshed.fm/56 regarding "ActiveRecord is Reinventing Sequel"

Hey Sean,

I just encountered your "The Bike Shed" podcast, concretely number #56 where you were talking about the "ActiveRecord is Reinventing Sequel" post I wrote. I'm sorry that this post struck you as negative, and that it made you feel like I was attacking you. I admit that I did feel some negative energy while I was writing it, but I still felt like I needed to say it.

Firstly, you said in the podcast that you would like to read an article which shows parts where Sequel is better than ActiveRecord. However, I did link my previous "Ode to Sequel" post in the first paragraph of my post, and soon after added two more. So I think it's a bit unfair that I was pr