Skip to content

Instantly share code, notes, and snippets.

View pierrickouw's full-sized avatar
💭
I may be slow to respond.

Pierrick Wauquier pierrickouw

💭
I may be slow to respond.
View GitHub Profile
ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper.define_method(:sidekiq_retry_in_block) do
lambda do |count, exception, jobhash|
wrapped_class = jobhash['wrapped']&.safe_constantize
if wrapped_class.method_defined?(:sidekiq_retry_in_block)
return wrapped_class.sidekiq_retry_in_block&.call(count, exception, jobhash)
end
nil
end
end
ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper.define_method(:sidekiq_retry_in_block) do
lambda do |count, exception, jobhash|
wrapped_class = jobhash['wrapped']&.safe_constantize
if wrapped_class.method_defined?(:sidekiq_retry_in_block)
return wrapped_class.sidekiq_retry_in_block&.call(count, exception, jobhash)
end
nil
end
end
# make sure all expect wait for turbo before expecting
module RSpec
module Matchers
expect_old = instance_method(:expect).bind(self)
define_method(:expect) do |*args, &block|
expect_old.call(page).not_to have_selector('html[aria-busy="true"]')
expect_old.call(page).not_to have_selector('turbo-frame[busy]')
expect_old.call(*args, &block)
end
end
@pierrickouw
pierrickouw / index.html
Created April 6, 2020 09:50
Print PDF with Electron and native OS Printer
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.4.456/pdf.js"></script>
<script>
/*
STEP
1) Choose file
2) Open a BrowserWindow ready to print when the url is loaded
3) Use PDF.JS to generate a PDF img per page
4) Render these pages on a html template (draw function)
@pierrickouw
pierrickouw / test2
Last active September 3, 2019 08:41
27491202
27995622
30868411
27473469
27473329
32829524
32829525
32055080
32055130
32054618
34976637
34757706
34768871
34757619
34757709
34874653
34880234
34880365
34880235
34834733
34976637
34757706
34768871
34757619
34757709
34874653
34880234
34880365
34880235
34834733
@pierrickouw
pierrickouw / gaussianblur_filter.class.js
Last active December 29, 2018 07:09
Gaussian Blur filter for fabric.js
/**
* Gaussian blur filter for fabricjs
* Example:
* obj.filters.push(new fabric.Image.filters.GaussianBlur(6));
* obj.applyFilters(canvas.renderAll.bind(canvas));
*
* Adapted from <a href="http://www.quasimondo.com/BoxBlurForCanvas">http://www.quasimondo.com/BoxBlurForCanvas</a>
*/
(function() {