...9200/my_documents Index ansehen: http GET :9200/my_documents { "my_documents": { "aliases": { }, "mappings": { }, "settings": { "index": { "creation_date": "1556793804746", "number_of_replicas": "1", "number_of_shards": "5", "provided_name": "my_documents", "uuid": "Q9nNksJhT3Ky7SOqDQa4bA", "version...
...PUT :9200/my_documents/post/1 { "title": "A sample document", "body": "I wrote something", "author": { "name": "Tobias" } } { "_id": "1", "_index": "my_documents", "_primary_term": 1, "_seq_no": 0, "_shards": { "failed": 0, "successful": 1,
it "creates a first project for the user" do user = FactoryBot.create(:user) user.projects.size.should == 1 user.projects[0].name.should == 'My first project' end end
...in your RVM or rbenv setup. Updating one does not update the others. Ruby 1.8.7 If you are using Ruby 1.8.7 you cannot use the latest version of Rubygems. Type...
...the following to get the latest version that is compatible with 1.8.7: gem update --system 1.8.30 Updating RubyGems for all installed Ruby versions Because of occasional security issues in RubyGems...
...low-level logic and have good reasons to do otherwise, probably stick with option 1.
...PDF file, you can use ghostscript to compress embedded images: ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=new-smaller-file.pdf large-original-file.pdf Note that your PDF printer (or similiar...
...put this snippet into your ~/.bash_aliases: alias pdf_compress='_compress(){ ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$1".c.pdf "$1";}; _compress' Reload aliases (source ~/bash_aliases) and...
...and weekdays differ. Times are formatted differently in different regions. Some regions use a 12 hour clock instead of 24 hours. Numbers and money amounts have different fractional separators and...
...has many issues that can lead to stored timestamps being off by some hours (1, 2, 3, 4). You can control this, but you will shed tears.
...next if [:string, :text].exclude?(column.type) attribute_name = column.name class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{attribute_name}=(value) super(value.to_s.strip.presence) end RUBY end rescue PG::ConnectionBad, ActiveRecord::StatementInvalid
...than a few months, it may stay at level 2. Never go below level 1. 0. Working code You have implemented that feature and it works. Congrats! You have reached...
...three levels of code quality lie ahead. First, make sure your code is reliable: 1. Reliable code In order to reach the baseline for good code, make your code:
...you want to couple the lock to the model's soft delete logic. Option 1 might also work when setting both the lock_strategy and unlock_strategy to none.
IRB 1.2 (shipped with Ruby 2.7, but works on 2.5+) brings pretty syntax highlighting and multiline cursor navigation. However, pasting longer contents is incredibly slow. You can fix that by...
...disabling said features. [1] Ruby 3.0.0-pre2 solved the issue (however, the fix does not appear to be included in IRB 1.2.6, it must be Ruby itself). Option 1:
accepts_nested_attributes_for :invoice_items, :allow_destroy => true # the critical code 1/2 before_save :calculate_and_store_amount # the critical code 2/2 private def calculate_and_store...
accepts_nested_attributes_for :invoice_items, :allow_destroy => true # the critical code 1/2 before_save :calculate_and_store_amount # the critical code 2/2 private def calculate_and_store...
As mentioned above, the esbuild_error_development.txt file must exist for Guard to watch it. [1] Sadly, Git does not offer a way to add a file and ignore further changes...
...esbuild, and break stuff. You should see error messages be delivered by your application. [1] Side note: Our implementation of the controller module also expects the file to exist. If...
...and times incomparisons, mind to not compare datetimes with date ranges in MySQL. Visualisation 1. ------- ------- AAA AAA BBB BBB ------- ------- 2. ------- AAA B ------- 3. ------- A BBB ------- 4. ------- AAA BBB ------- 5. -------
...the application again. How can we invalidate old session cookies on logout with Devise? 1) Reset password The only option provided per default by Devise is to change the password...
...interpolation syntax you know from strings: re1 = /x/ re2 = /a#{re1}b/ 'aaxbb' =~ re2 # => 1 Note If your regular expression contains backreferences like \1, they may no longer refer to...
.../etc/fstab are meaning? The first number fs_freq When this field is set to 1 dump(8) will make a backup of the partition. Not using dump for backups? You...
...the commit I want to fixup: alias fixup='git log --oneline | fzf | awk '\''{print $1}'\'' | xargs -I '\''{}'\'' git commit --fixup {}' After you have used fixup you still will have run...
...Add this line to your application's Gemfile: gem 'capistrano', '~> 3.0' gem 'capistrano-maintenance', '~> 1.0' Add this line to you application's Capfile: require 'capistrano/maintenance' Enable task Present a maintenance...
...specifying the REASON and UNTIL environment variables: cap maintenance:enable REASON="hardware upgrade" UNTIL="12pm Central Time" You can use a different template for the maintenance page by setting the...
There are multiple ways to redirect URLs to a different URL in Rails, and they differ in small but important...
...Now you should have the build packages: $ ls -l ../ total 7968 drwxr-xr-x 16 root root 4096 Sep 9 22:08 exim4-4.86.2 -rw-r--r-- 1 root root...
...Sep 9 22:09 exim4_4.86.2-2ubuntu2.5_all.deb -rw-r--r-- 1 root root 140620 Sep 9 22:09 exim4_4.86.2-2ubuntu2.5_amd64.build -rw-r--r-- 1 root root 5251 Sep 9 22:09 exim4_4.86.2-2ubuntu2.5_amd64.changes
...newIndex > -1 && newIndex < array.length) { // Remove the element from the array const removedElement = array.splice(index, 1)[0] // At "newIndex", remove 0 elements and insert the removed element array.splice(newIndex, 0, removedElement...
...negative to move towards the beginning): const list = [object1, object2, object3] moveArrayElement(list, object2, 1) // list => [object1, object3, object2] moveArrayElement(list, object2, -2) // list => [object2, object1, object3]
...Power.new(build(:user)) Power.with_power(power) do expect(power).to receive(:buildings).at_least(1).time.and_return [building, other_building] expect(build(:unit)).to allow_association_values(building, other_building...
...assignable_values generates: ... Power.with_power(power) do expect(power).to receive(:buildings).at_least(1).time.and_return [building, other_building] unit = build(:unit) expect(unit.assignable_buildings).to contain_exactly(building...
...have a reference to their parent uploader class DemoUploader < CarrierWave::Uploader::Base process :resize # 1 before :cache, :do_something # 3 version :thumb do # 2 process :crop end private
...with Selenium and Capybara despite these issues. Both have different advantages and drawbacks. Method 1: Inspecting the file without navigation There are ways to download and inspect a file without...
features/support/download_helpers.rb # This is an adapted approach from # https://collectiveidea.com/blog/archives/2012/01/27/testing-file-downloads-with-capybara-and-chromedriver module DownloadHelpers TIMEOUT = 10 module_function def download_path download_path = Rails.root.join("tmp/test_downloads#{ENV['TEST_ENV_NUMBER']}") FileUtils.mkdir_p...