...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...
...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...
...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...
...your first request on opening the input element. The Select2 data format { "results": [ { "id": 1, "text": "Option 1" }, { "id": 2, "text": "Option 2" } ], "pagination": { "more": true } } Basic ajax options
ajax: { url: , data: function (params) { return { query: params.term, page: params.page || 1 } } processResults: function (data, params) { return data }, } }); Further reading: https://select2.org/data-sources/ajax
When your JavaScript bundle is so massive that you cannot load it all up front, I would recommend to load...
...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...
...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.
...closure-like entities? "return" returns from closure True closure? or declaring context...? Arity check? --------------- ----------------------------- ------------------- 1. block (called with yield) N declaring no 2. block (&b => f(&b) => yield) N declaring...
...Y except return declaring warn on too few 5. proc <<< alias for lambda in 1.8, Proc.new in 1.9 >>> 6. lambda Y closure yes, except arity 1 7. method Y closure...
...attached file into config/initializers/ to be able to say in_columns on any Array: >> [1, 2, 3, 4, 5, 6, 7].in_columns(3)
...1, 2, 3, 4, 5, 6, 7].in_columns(2) => [[1, 3, 5, 7], [2, 4, 6]] While in_groups and in_groups_of are provided by Rails this also...
...look at their titles like this: messages[0].find('h2').text => "Hello World" messages[1].find('h2').text => "Hello Universe" So far, so good. Now we want to find titles...
...using a "full" selector to avoid the broken behavior: page.find('.message:nth-of-type(1)', :text => 'Hello World').text => "Hello World" page.find('.message:nth-of-type(2)', :text => 'Hello World...
Trick: Do not use convert but mogrify: mogrify -resize 50% * This overwrites the original image file. In contrast, convert writes...
def hello 'world' end ^ $ git blame foo d47bf443 (Arne Hartherz 2012-12-19 14:44:38 +0100 1) def hello d47bf443 (Arne Hartherz 2012-12-19 14...
d47bf443 (Arne Hartherz 2012-12-19 14:44:38 +0100 3) end Now it's being changed to: def hello if world? 'world' else 'universe' end end
...gitlab-rails console. Remove GitLab Labels from already closed Issues p = Project.find_by_id(1) labels_to_remove = [3, 4, 1, 84, 86] # Scheduled, Active, This Week, One Week, Two...
...Active, This Week, One Week, Two Weeks with the respective label ids 3, 4, 1, 84, 86 which leads to the above code snipped...
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
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...
...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})`);
Observed on Rails 2.3 and machinist 1.0.6 Like the title says, when you define the method empty? like in the following example, you may not longer use collection.make.
...has_many :pages def empty? pages.empty? end end Assuming b1 = Book.find(1) b2 = Book.find(2) instead of expected b1.pages.make #=> #<Page id: 1, book_id: 1> b2.pages.make #=> #<Page id: 2, book...
We forked trusty memoizer to make two changes: Memoized methods now preserve their arity. Previously all memoized methods had an...
...a vertical output. You know this: mysql> SELECT * FROM users; +----+---------+---------------------+-----------------+ | id | name | email | greeting | +----+---------+---------------------+-----------------+ | 1 | Alice | alice@example.com | Hello world! | | 2 | Bob | bob@example.com | Hello universe! | | 3 | Charlie | charlie@example.com | Hi mom...
This is how it looks like vertically: mysql> SELECT * FROM users \G *************************** 1. row *************************** id: 1 name: Alice email: alice@example.com greeting: Hello world! *************************** 2. row *************************** id: 2
...you could then test it like this: get :index persisted_session[:page_views].should == 1 # session[:page_views] is 1, so that would still work get :index persisted_session[:page...
...views].should == 2 # session[:page_views] would be 1, even though it works in the real world
...of objects, uniq does not work as expected, since it uses strict equality. So [[1], [1]].uniq() == [[1], [1]] In some cases, this might be a workaround: [[1], [1]].invoke...
...toJSON").uniq().invoke("evalJSON")
...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() {
...total is either memoized itself, or using some # private memoized method subject.seat_counts = [5, 1] subject.seat_total.reload.should == 6 # => Still 5 end You might be tempted to manually unmemoize any memoized internal...
...fiddling with internal state. When writing tests, stay on your chosen abstraction level. Solution 1 record.unmemoize_all Solution 2 Perform a full reload by re-finding your record:
...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...