Skip to content

Instantly share code, notes, and snippets.

@dvodvo
dvodvo / gist:13459181c945f77f25e6c5b4b1cb98d0
Last active February 20, 2021 14:30
zxing access to camera devices
Memo for when testing with clients.
Browser versions have different access requirements to devices, location, etc.
As this author likes to use older OSes, there are threshholds that can be problematic when testing.
Fail
- google Chrome 60 (latest valid for 10.9)
- opera 49 (10.9 enabled, chromium)
- safari 9.1.3 (10.9)
@dvodvo
dvodvo / gist:313bcb4da83030c48280fe76065da9e3
Last active June 2, 2021 15:46
setting up rails 6 with foundation, client-side validations under webpacker, not breaking UJS
Notes:
1 - Not going the full 9 yards here - I prefer to see the CSS structures and thus have them available, so not handing them off to webpacker.
2 - Autocomplete is often required. js-autocomplete has no dependencies and has a small footprint. So what's wrong with going the old route and only calling the scripts on the pages that require it?
yarn add jquery
yarn add foundation-sites
** application.js **
comment out rails generated initial and close bits, replace with single start call:
@dvodvo
dvodvo / gist:991e2f419009a9c54538196b6949d19d
Created July 5, 2021 08:37
Already initialized pollution on bundle exec
getting innumerable "already initialized constant" warnings?
Run "bundle clean --force" from the root of the Rails app.
@dvodvo
dvodvo / gist:12d0b51af6a8900a27d26d5cae3e1f20
Created October 30, 2021 05:40
getting curl to work on older systems
When https in the browser has its TLS updated and is properly serving up pages, but curl fails:
1. download from https://curl.haxx.se/ca/cacert.pem to get the latest file
2. add '--cacert /path/to/cacert.pem' option to the curl command
@dvodvo
dvodvo / gist:4af67f3015049d848889026c9c84a37c
Created November 5, 2021 08:05
Mobility gem, migrating existing values to key-value table
Assuming Mobility is already configured. if one wishes to properly synch up and migrate existing values from the class table attribute to the default locale
following example with attributes `description_short, description_long, description_search` and default_locale `de`
@articles.all each do |article|
article.update(description_short_de: article[:description_short], description_long_de: article[:description_long], description_search_de: article[:description_search])
end
@dvodvo
dvodvo / gist:9811dc4a0740eac38ba636eac283f736
Last active December 19, 2021 13:28
Stripe authorisation and capture in two steps
def confirm_ts
[...]
else
set_cart_authorisation(@cart)
Stripe.api_key = @cart.shop.private_key
intent = Stripe::PaymentIntent.create({
amount: @authorisation.to_i,
currency: 'eur',
payment_method_types: ['card'],
capture_method: 'manual',
@dvodvo
dvodvo / gist:9b69f7be345fc13ba2572a0f865097f7
Last active January 20, 2022 10:29
Carrierwave && carrierwave-aws initializer for connecting to DO Spaces
# uploads.rb
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = 'my-bucket-s-name' # name of bucket, no FQDN
config.aws_acl = 'private'
# Optionally define an asset host for configurations that are fronted by a
# content host, such as CloudFront.
# config.asset_host = 'http://example.com'
@dvodvo
dvodvo / piano_d_arta.geojson
Created February 14, 2022 10:37
Arta - Piano d'arta
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dvodvo
dvodvo / cabia.geojson
Created February 14, 2022 10:25
arta - cabia
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.