When a directory has more than a few thousand entries, ls will start taking really long to list its content...
I've encountered a Ubuntu 16.04 today, where localhost resolved to ::1 instead of 127.0.0.1. This will not usually make a difference, but could be relevant for firewall policies...
...from your current database state. The generated db/seeds.rb will look this: Product.create!([ { category_id: 1, description: "Long Sleeve Shirt", name: "Long Sleeve Shirt" }, { category_id: 3, description: "Plain White Tee...
...Shirt", name: "Plain T-Shirt" } ]) User.create!([ { password: "123456", username: "test_1" }, { password: "234567", username: "test...
...to a certain maximum, you can just compare against the modulus of that maximum + 1. \ For example, the following will yield results between 0 and 9: echo $(($RANDOM % 10...
...echo $(($RANDOM % 10)) 9 Note that this skews random numbers to the lower regions of your boundaries in most cases...
Dir.glob(File.join RAILS_ROOT, 'app', 'models', '*.rb').collect{ |path| path[/.+\/(.+).rb/,1] }.collect(&:camelize).collect(&:constantize...
Note: The behaviour of Spreewald's within step is as described below for version < 1.9.0; For Spreewald >= 1.9.0 it is as described in Solution 1. When doing integration testing with...
# Feature When I pick "Lions" from the album picker within ".media-picker-1" # Step definition When /^I pick "(.+?)" from the album picker$/ do |label|
...# open the picker and...
...an integer and want to use it to represent an element's position (like "1st" for 1, or "2nd" for 2), you can use ActiveSupport's ordinalize: 1.ordinalize # => "1st"
1002.ordinalize # => "1002nd" 1003.ordinalize # => "1003rd" -11.ordinalize # => "-11th" -1001.ordinalize # => "-1001st...
...regexp !~ string) The Ruby 2.4 method Regexp#match? does not set globals like $~ or $1, so it should be more performant...
Service that you can integrate for user feedback. Super-simple integration: Add a tag to your layout, done. It will then add a button to the bottom right of your application. When a user clicks it, they can take a screenshot and leave a message. The screenshot then appears in TrackDuck's interface for you to work off. Current pricing is 9 USD per month for the smallest tier (1 project).
Hashrocket Lunch n' Learn #1 with Avdi Grimm: Making Little Classes out of Big Ones A look at the pros and cons of four different techniques for breaking a too...
...can declare it’s finally here. We’ve brought the work of more than 1,600 contributors together to make everything better, faster, cleaner, and more beautiful...
...form and populate a preview div with the response. $('content_form').request({ parameters: { 'preview': "1" }, // overrides parameters onComplete: function(transport){ $('previewContent').update(transport.responseText...
...to determine if it's possible to generate a string that matches more than 1 of them. Short of writing my own regex engine with this use case in mind...
...you can simply skip asset compilation and re-use the previous release's assets. [1] That is especially easy via Capistrano. Capistrano will automatically symlink your release's public/assets to...
end You can then set the above environment variable when deploying: SKIP_ASSETS=1 cap staging deploy Enjoy. [1] Sprockets will pick any public/assets/.sprocket-manifest-*.json...
...shouldn't do for performance reasons), there are several ways to work around this. 1. Use it_should_receive_callbacks The awesome it_should_run_callbacks macro from spec_candy...
...callback chain and run that. This is what spec_candy wraps for you (method #1). describe Spaceship do describe '#launch' do it 'should run the proper callbacks' do subject.state = 'docked...
...reactivate the new version Shut down RubyMine Extract the downloaded file into your ~/bin/. [1] cd ~/bin && tar xzvf ~/Downloads/RubyMine-X.Y.Z.tar.gz Update your directory symlink [2] to point to the new...
...to update it, too. Go to Tools → Create Command-line Launcher… and confirm twice. [1] We recommend using ~/bin to store binaries for your user. Some of us like to...
...of it. If not, someone could exploit this by creating a user with ID = 1 (e.g. on staging), sign in and then use that cookie to authenticate on another site...
...e.g. on production, where the user with ID = 1 probably is the admin). Here is a one-for-all solution that does not affect current production users, leaving the production...
...browsers will use CSS transforms when available -- which is on basically all but IE. [1] To achieve a rotation on IE8 and IE9, we can use writing-mode. Since other...
However, IEs that do support transform (IE10+) would combine both styles into a 180° rotation which we do not want. So we reset our transform definition for IEs -- and...
...w!#$%&'*+-/=?^`{|}~]+.)*[\w!#$%&'*+-/=?^`{|}~]+@((((([a-z0-9]{1}[a-z0-9-]{0,62}[a-z0-9]{1})|[a-z]).)+[a-z]{2,6})|(\d{1,3}.){3}\d{1,3}(:\d{1...
...find your test results when you come back to the console later Calls RSpec 1 (spec) in a Rails 2 project and RSpec 2 (rspec) in a Rails 3 project...
.../Ubuntu\ One/encrypted Create a random keyfile dd if=/dev/urandom of=~/.sync.key bs=256 count=1 chmod 600 ~/.sync.key Put this script (let's call it mount-ubuntu-one-sync) somewhere...
...to transform every captured string: Transform /^(.*)$/ do |str| str.gsub(/\btranslate:(.+?)\b/) do |match| I18n.t($1) end end Other than with step definitions, Cucumber does not mind multiple transforms matching the...
...Never skip asset compile when servers are running on different code next if revisions.uniq.length > 1 changed_files = `git diff --name-only #{revisions.first}`.split if changed_files.grep(asset_locations).none? puts Airbrussh...
...it is annoying when debugging tests. Here are two ways to disable it: Option 1: prefs You can set profile preferences to disable the password manager like so: prefs = { 'credentials...