...for huge amounts. We recently had this issue in a project with more than 100.000 attachments, where we used a structure like this /attachments/123456789/file.pdf. Even the ls command lasted several...
...the list of possible errors that might be unexpected in the first place. Step 1: Prepare your Uploader for the new structure Implement a new structure, like described in a...
...queries (simplified; the number at the beginning of each line is the connection ID): 1 Connect 1 BEGIN 1 INSERT INTO foos 1 Quit 2 Connect 2 SELECT COUNT(*) FROM...
...filter(function() { return this.nodeType === 3; }); } Also check out this list of existing node types. 1 is HTML tag, 3 is text, 8 is comment, etc...
...one of our servers is trying to access the database. # journalctl -u mariadb Dec 16 00:00:03 cool-server mariadbd[788]: 2022-12-16 0:00:03 34996 [Warning...
...Access denied for user 'root'@'localhost' (using password: NO) Dec 17 00:00:02 cool-server mariadbd[788]: 2022-12-17 0:00:02 89012 [Warning] Access denied for user...
When your JavaScript bundle is so massive that you cannot load it all up front, I would recommend to load...
Invocation Result amount(0) 0 amount(0.0) 0 amount(0.5) 0,5 amount(1.5, :minimum_precision => 2) 1,50 amount(1.543, :minimum_precision => 2) 1,543 amount(1.5, :minimum...
...precision => 2, :separator => '.') 1.50 amount(nil) – Rendering money amounts If your amounts are Western hemisphere money amounts, you want some additional prettifications on top of that: Always use a minimum...
...your magic here end end Example structure The resulting directory structure will be: /app-root/public/system/users/avatar/000/001/... (1st record) /app-root/public/system/users/avatar/000/002/... (2nd record) ... /app-root/public/system/users/avatar/000/999/... (999th record) /app-root/public/system/users/avatar/001/000/... (1000th record) ... /app-root/public/system/users/avatar/999/999/... (999'999th record) /app-root/public/system/users/avatar/1000/000...
...1 millionth record) So if you have 500k records, you will still only have 500 directories inside /app-root/public/users/avatar/. And inside each of them, at most 1000 sub-directories.
...can cause the above error, when the arc cosine of something slightly more than 1.0 is to be computed, e.g. for the (zero) distance between the same coordinates (applies only...
...fix, we just force the value we compute the arc cosine of into [-1; 1] bounds. Put this into a config/initializers/graticule_spherical_distance.rb initializer: Graticule::Distance::Spherical.class_eval do def self.distance(from...
...You still need to include rome/dist/rome.css for its basic positioning styles. rome(element, { weekStart: 1, // Monday weekdayFormat: 'short', // Mon styles: { // Picker overlay container: 'rd-container border rounded-lg shadow bg...
...circle, it is then asked to compute the arc cosine of a result like 1.0000000001. Since this is undefined, MySQL correctly returns NULL (instead of the expected distance of...
...this problem is to discard rounding errors by forcing any results into bounds [-1; 1] before computing the arc cosine on it. Put the following into an initializer like config/initializers/graticule_spherical_to_sql_without_nulls.rb...
BANK_CODE = /\A\d{8}\z/ # Germany BANK_ACCOUNT_NUMBER = /\A\d{1,10}\z/ # Germany ZIP_CODE = /\A\d{5}\z/ # Germany HEX_COLOR = /\A([a-fA-F0...
IP_ADDRESS = /\A(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)(?:\.(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)){3}\z...
...a makandra card?") }; let cardsPathPattern = /(\/[\w-]+\/\d+)-.+/; if (window.location.pathname.match(cardsPathPattern)) { let currentPath = window.location.pathname.match(cardsPathPattern)[1]; let title = document.querySelector('h1.note--title')?.textContent; if (title) { prompt("Your markdown link:", `[${title}](${currentPath})`);
Trick: Do not use convert but mogrify: mogrify -resize 50% * This overwrites the original image file. In contrast, convert writes...
Typhoeus has a different way of representing array params in a get request than RestClient. Typhoeus: http://example.com/?foo[0]=1&foo[1]=2&foo[2]=3
...middleware yourself. Here is an example that limits concurrency of the "mailers" queue to 1. It uses a database mutex via the with_advisory_lock gem but you could easily...
...rand(4)}" (not perfect, but might be good enough). For rate-limiting (e.g. only 1 job per 5 seconds) you could name it "mailers-throttle-#{(Time.now.to_i / 5.0).to_i...
We forked trusty memoizer to make two changes: Memoized methods now preserve their arity. Previously all memoized methods had an...
...unexpectedly splat the array elements: block = proc { |a, b| "a=#{a}, b=#{b}" } block.call(1, 2) # "a=1, b=2" block.call([1, 2]) # "a=1, b=2" Note that lambdas...
...behave as expected: block = lambda { |a, b| "a=#{a}, b=#{b}" } block.call(1, 2) # "a=1, b=2" block.call([1, 2]) # ArgumentError: wrong number of arguments (1 for...
...event listener with { once: true }: up.on('up:fragment:inserted', { once: true }, function () {...
In Unpoly 1 you can immediately unregister the listener with up.off: up.on('up:fragment:inserted', function fragmentInsertedCallback() {
...you should still remove them after you're done. Here are three options: Option 1: Using a block it 'does something with a temporary directory' do Dir.mktmpdir('exports') do |export...
...was not detected in the system." $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" exit 1 end end Deploying again should now install the missing dependencies as expected...
...application, you can use these few lines of CoffeeScript code: joinSentence = (array) -> if array.length > 1 array[0..-2].join(', ') + ', and ' + array[-1..] else array.join ', ' Examples: > joinSentence(['cats', 'dogs', 'pandas'])
...Here is some plain JavaScript, should you prefer that: function joinSentence(array) { if (array.length > 1) { return array.slice(0, -1).join(', ') + ', and ' + array.slice(-1); } else { return array.join...
...Let's say you split User into the traits "authentication" and "permissions". In Modularity 1 you now had to say: class User < ActiveRecord::Base does 'user/authentication' does 'user/permissions' end
Automatically migrate a project to Modularity 2 If you have been using Modularity 1 with the does syntax, the Modularity 2 gem provides a script to migrate your Ruby...
...always cached prior to actually storing it (to support form roundtrips). Carrierwave by default 1) copies the file to the cache and then 2) copies it again to its final...
...threads. Unfortunately, when you use blocking system calls (e.g. locks on the database), Ruby 1.8 threads won't work because system calls will block the whole interpreter. Luckily you can...
...ActiveRecord::Base.establish_connection(config) end it 'should synchronize processes on the same lock' do (1..20).each do |i| fork_with_new_connection do @reader.close ActiveRecord::Base.connection.reconnect! Lock.acquire('lock') do...