...your database, you might run into an error like pg_restore: error: unsupported version (1.15) in file header This is because your local pg_restore version is too old to...

...doesn't matter here. For example, the official Ubuntu 20.04 sources include only PostgreSQL 12, so your pg_restore version will also be v12. Ubuntu 22.04 includes version 14 in...

...Experts Group JFIF format) Class: DirectClass Geometry: 5472x3648+0+0 Resolution: 350x350 Print size: 15.6343x10.4229 Units: PixelsPerInch Type: TrueColor Endianess: Undefined Colorspace: sRGB Depth: 8-bit Channel depth:

blue: 8-bit Channel statistics: Red: min: 0 (0) max: 255 (1) mean: 110.006 (0.431397) standard deviation: 56.3503 (0.220982) kurtosis: -0.715336 skewness: 0.213533 Green:

makandra dev

...on hover, the following SASS is used (shorthand syntax): .element color: red transition: color .1s &:hover color: green This tells the browser "whenever the color of an .element changes, let...

...it take 1/10th of a second" and next "whenever an .element is hovered, make its text green". Multiple animated properties are comma-separated: .element color: red opacity: .9 transition: color...

makandra dev

...by allowlisting specific directories directories %w[app config public spec] allowed_js_reload_window = 10 # seconds last_js_change = Time.at(0) guard 'livereload', apply_css_live: true, host: '127.0.0.1' do...

...css)$)) do |match| # Any generated CSS changed, send its name to livereload-js match[1] end watch(%r(^app/assets/.*\.js$)) do |_match| # Any source Javascript changed. Assume the next changes...

...simply issuing an extra query, like this: SELECT post.* FROM posts LIMIT 20 OFFSET 100; SELECT COUNT(*) FROM posts; This is fine most of the time. But rarely, you might...

...it needs to be. SELECT posts.* FROM (/* some complicated_subquery */) posts LIMIT 20 OFFSET 100; SELECT COUNT(*) FROM (/* some complicated subquery */) posts; Here the subquery had to run twice. (Although...

...upgrade to take a few days even the diff is quite small afterwards. Preparations 1. Find all libraries that are bundled with the asset pipeline. You can check the application.js...

...have to be copied to a private node package into the project. Introduce Webpacker 1. Install Webpacker 2. Check if css extraction is enabled in webpacker.yml: # Extract and emit a...

Using Ruby 1.8.7 you will not be able to use the maximum versions Rubygems 1.8.30 and Bundler 1.17.3 with https://rubygems.org/ anymore. This is a result of a server certificate...

...fetching data: hostname was not match with the server certificate (https://rubygems.org/*) Fix 1: Use docker and gemstash (recommended for makandra employees) Use our legacy docker setup for development...

...convert it into its RGB values using plain Ruby. >> "#ff8000".match(/^#(..)(..)(..)$/).captures.map(&:hex) => [255, 128, 0] You can use that to implement a simple "hex to CSS rgba value with...

...captures.map(&:hex) "rgba(#{rgb.join(", ")}, #{opacity})" end >> hex_color_to_rgba("#ff8000", 0.5) => "rgba(255, 128, 0, 0.5)" If you need to support RGBA hex color codes, you need to handle...

Given you have a strict CSP that only allows elements from your own domain: Content-Security-Policy: script-src 'self' This will block JavaScript handlers inlined as attribute into your HTML elements. Clicking on the following link will only log an error with a strict CSP: click me click me Solution 1: Move the handler into your JavaScript The recommended solution is to move the handler from the HTML to the allowed JavaScript file that we loaded via . In the example above we could invent a new [data-alert] attribute with the alert message: click me Then our JavaScript intercepts clicks on elements with that attribute: document.addEventListener('click', function(event) { let link = event.target.closest('[data-alert]') if (link) { let message = link.dataset.alert alert(message) event.preventDefault() } }) Solution 2: Allow that one handler in your CSP Some browsers allow the CSP directive script-src-attr. This lets you allow the hashes of actual JavaScript code. The SHA256 hash of alert('hello') is vIsp2avtxDy0157AryO+jEJVpLdmka7PI7o7C4q5ABE= (in Base64). We can allow this one event handlers like this: Content-Security-Policy: script-src 'self'; script-src-attr 'unsafe-hashes' 'sha256-vIsp2avtxDy0157AryO+jEJVpLdmka7PI7o7C4q5ABE=' Note the sha256- prefix. This event handler now works when clicked: click me But any other script will still be blocked: click me Dealing with legacy browsers Currently (November 2023) about 75% of browsers support script-src-attr. Here is a forward-looking compromise that many users use with new CSP features: Have a liberal CSP with old directives supported by all browsers Make your CSP stricter with new, more specific directives for browsers that support it The CSP spec supports that approach in that using newer, more specific directives disable older, more general features. In our case this means: For old browsers, allow all inline scripts For new browsers, disallow inline scripts but allow inline handlers with given hashes Here is a CSP directive that works like this: Content-Security-Policy: script-src 'self' 'unsafe-inline'; script-src-elem 'self'; script-src-attr 'unsafe-hashes' 'sha256-vIsp2avtxDy0157AryO+jEJVpLdmka7PI7o7C4q5ABE=' Old browsers will only use script-src. New browsers will use script-src-elem (for tags) and script-src-attr (for inline event handlers), which override the more liberal rules from script-src.

manufacturer, serial_number = product.match(PRODUCT_PATTERN)&.captures # or manufacturer = product[PRODUCT_PATTERN, 1] serial_number = product[PRODUCT_PATTERN, 2] Example with named groups (<2.4) PRODUCT_PATTERN = /\A(? .+) S...

...An OAuth-compatible request matcher Body with ignored order URI ignoring query parameter ordering 1 URI ignoring query parameter ordering 2 Tests with AJAX Using javascript in integration tests might...

weblog.jamisbuck.org

(gdb) t a a bt # thread apply all backtrace (gdb) call (void) close(1) # close the existing file descriptors for stdout (gdb) call (void) close(2) # close the existing...

Previous method on Ruby < 2.4 Article from 2016 Article from 2006 Ruby 1.8.7 # First, find out the PID of your Ruby process (e.g. passenger-status)

github.com

Profit Example Imagine you expect General Kenobi to be in level 6 { level_1: { level_2: { level_3: { level_4: { level_5: { level_6: { general_kenobi: 'Hello there!' } } } } } } }

...actually in level 3. Then RSpec will output the diff this way: expected: {:level_1=>{:level_2=>{:level_3=>{:level_4=>{:level_5=>{:level_6=>{:general_kenobi=>"Hello there!"}}}}}}}

...use permit (or expect) to receive Strong Parameters, but strip extra parameters. # Better (option 1) redirect_to users_path(params.slice(:query, :encoding).permit(:query, :encoding)) # Better (option 2)

...logs the error ActionController::UnpermittedParameters in development + test and do nothing in production. Option 1: In case you use action_on_unpermitted_parameters = :raise for all environments, you might notice...

...but is actually quite simple when using docker and turning off some verification steps. 1. Start a keycloak instance using docker mkdir -p keycloak_data && docker run --network=host -e...

edgeapi.rubyonrails.org

How generated form params look like If you have authors with the IDs 1, 2 and 3, the check boxes above will be named like this: Note the hidden...

In your Rails controller, this will create params like this: { 'post' => { 'author_ids' => ['1', '2', '3', ''] } } Permitting array params in your controller Note that you need some special syntax...

makandra dev

Rails 6 includes a WYSIWYG editor, Action Text. It works out of the box quite well, but chances are that...

...suppress_multiple_term_dialog = True [keybindings] [profiles] [[default]] cursor_color = "#aaaaaa" font = Ubuntu Mono 14 use_system_font = False [layouts] [[PROJECT_NAME]] [[[child0]]] type = Window parent = "" position = 3458:171 maximised...

...profile = default command = 'env startup_cmd="foreman start" startup_args="-f Procfile.dev -m all=1,web=0" bash' [plugins] To make the environment variables work, put the following into your...

...suspect parallel execution for bundling issues, you can try serially with bundle install --jobs 1...

github.com

class User < ActiveRecord::Base ... end class SignUp < ActiveType::Record[User] ... end user = User.find(1) sign_up = ActiveType.cast(user, SignUp) sign_up.is_a?(SignUp) # => true This is basically like ActiveRecord#becomes...

...entire relation (scope) to a relation of an ActiveType::Record: adult_users = User.where('age >= 18') adult_sign_ups = ActiveType.cast(adult_users, SignUp) sign_up = adult_sign_ups.find(1) sign_up.is_a?(SignUp) # => true

...complement for opacity. Just transition both of them: opacity: 0 visibility: hidden transition: all 100ms &.-visible opacity: 1 visibility: visible When fading in, visibility will immediately be set to visible...

...call other matchers. Example The following test checks that two variables foo and bar (1) have no lowercase characters and (2) end with an exclamation mark: expect(foo).to_not...

cookies_jar = ActionDispatch::Cookies::CookieJar.build(request, cookies.to_hash) cookies_jar.signed[:user_id] = 1 cookes[:user_id] = cookies_jar[:user_id] get "/movies/#{user_id}/favorite" Example: describe '/movies...