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
# OpenStruct has caveats and security problems and even leads to a rubocop offense: | |
# https://ruby-doc.org/stdlib-3.1.0/libdoc/ostruct/rdoc/OpenStruct.html#class-OpenStruct-label-Caveats | |
# https://msp-greg.github.io/rubocop/RuboCop/Cop/Style/OpenStructUse.html | |
# | |
# It's time to replace it. The feature I loved most about OpenStruct was being able to retrieve | |
# values by calling a method instead of having to use hash access syntax. | |
# The recommended way to go is Struct, but it is much more cumbersome than OpenStruct was. | |
# So here's MethodAccessibleHash that allows to do that, but without OpenStruct's security problems. | |
# | |
# This revision adds writers, direct creation from Hash, as well as enhanced merging. |
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
How Nginx treats slashes in `location` and `proxy_pass` statements: | |
Base URL: https://www.my.web.site/pre/fix/page.html | |
Our decuced rules, apply for each block A-C: | |
1: Location is passed on without change | |
2: Location is removed, '/' is added | |
3: Location is removed, 'pre/fix' is added | |
4: Location is removed, 'pre/fix/' is added |
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
#!/bin/bash | |
pid= | |
trap '[[ $pid ]] && kill "$pid"' EXIT | |
sleep infinity & pid=$! | |
wait | |
pid= |
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 file demonstrates that attributes created by class_attribute (in Rails' ActiveSupport) are not thread-safe. | |
# On my system, the test fails sometimes when setting count to 1_000 and always with a count of 10_000. | |
# Expected exception: NameError: Undefined method setting for 'BugTest::MyClass' | |
# Note: Occurs on jruby only. | |
# See issue https://github.com/rails/rails/issues/26758 | |
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' |