This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# enqueue with following parameters hash: | |
# - headers | |
# - work_at - time of execution | |
# - work_queue - destination queue for actually doing the work | |
# | |
class DelayWorker | |
include Sneakers::Worker | |
from_queue :treadmill, { handler: Sneakers::Handlers::Delay } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Requires that you set a custom field on the product with logo_src = image url | |
function sv_add_logo_above_wc_shop_image() { | |
global $product; | |
// replace the custom field name logo_src with your own | |
$logo_src = get_post_meta( $product->id, 'logo_src', true ); | |
// Add these fields to the shop loop if set | |
if ( ! empty( $logo_src ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Core_loadData', function () { | |
var id = 'testContainer'; | |
beforeEach(function () { | |
this.$container = $('<div id="' + id + '"></div>').appendTo('body'); | |
}); | |
afterEach(function () { | |
if (this.$container) { | |
this.$container.remove(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
REP = 100_000 | |
dat = [1, 2, 3, 2, 4, 5, 4, 4] | |
Benchmark.bmbm 25 do |x| | |
x.report "Jan low level" do | |
REP.times do | |
dups = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This works best in 2019 forward because its basically the code from the gem itself with some tweaks added: | |
# https://github.com/teamcapybara/capybara/blob/master/lib/capybara/registrations/drivers.rb | |
# The additional option/flags work for me but you probebly want to checkout what you would need here first: | |
# https://peter.sh/experiments/chromium-command-line-switches/ | |
Capybara.register_driver :selenium_chrome_headless do |app| | |
# Capybara::Selenium::Driver.load_selenium | |
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts| | |
opts.args << '--window-size=1920,1080' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kelder | |
module PrefixKeyWithToken | |
# Prefix all generated blob keys with the tenant. Do not | |
# use slash as a delimiter because it needs different escaping | |
# depending on the storage service adapter - in some cases it | |
# might be significant, in other cases it might get escaped as a path | |
# component etc. | |
def generate_unique_secure_token | |
tenant_slug = Apartment::Tenant.current.split('_').last | |
"#{tenant_slug}-#{super}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
# thanks to http://blog.phusion.nl/2011/08/14/rendering-rails-3-1-assets-to-string/ | |
# you may need to change the owner of the tmp/cache/* directories to the web servers user | |
# e.g. for Debian systems: `chown -R www-data:www-data tmp/cache/*` | |
def render_asset(asset) | |
Conferator::Application.assets.find_asset(asset).body.html_safe | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.3" | |
services: | |
reverse-proxy: | |
image: traefik:latest | |
restart: unless-stopped | |
command: | |
- --api | |
- --providers.docker=true | |
- --entrypoints.web.address=:80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
networks: | |
proxy: | |
external: true | |
internal: | |
external: false | |
services: |
OlderNewer