...you can install the official Java JRE: sudo apt-get update sudo apt-get install sun-java6-jre You can now check your default JVM with java -version. It should...
...versions below 10.10. If it does, please update this note. sudo add-apt-repository ppa:sun-java-community-team/sun-java6 You probably want to get rid of OpenJDK (which is...
If you have an html_safe string, you won't be able to call gsub with a block and match reference variables like $1. They will be nil inside the...
...with rails_xss) as well as Rails 3 applications. Here is a fix to SafeBuffer#gsub. Note that it will only fix the $1 behavior, not give you a safe...
A print stylesheet is easy to create. Choose a font suited for paper, hide some elements, done. Unfortunately print stylesheets often break as the application is developed further, because they...
...are quickly forgotten and nobody bothers to check if their change breaks the print stylesheet. This card describes how to write a simple Cucumber feature that tests some aspects of...
Capistrano 2 brings the shell command which allows you to run commands on your deployment targets. There is also invoke to run a command directly from your terminal.
...allow running Capistrano tasks or shell commands, and scope to individual machines or machine roles. Unfortunately Capistrano 3 does not include these commands any more. cap shell Basics
...so I hope it will be fixed with a future release. The following test succeeds: context 'factories' do let(:test_case) { FactoryBot.create(:test_case) } it 'are valid' do expect(test...
...byebug) FactoryBot.create(:test_case) *** NameError Exception: uninitialized constant # ::TargetLimitation Did you mean? TargetsTestScenario It seems like Byebug does not work well with zeitwerk. There is already a patch in Ruby...
...ago and don't remember which one it is? You can go to chrome://settings/appearance (on Chrome 61+) to see the theme's name, and click a link to open...
...it in the Chrome Web Store. If you are on an older version, or if the above no longer works, you have to check Chrome's Preferences file. Linux /home/YOUR_USER_NAME/.config/chromium/Default/Preferences...
...links. Popular pagination libraries like will_paginate or Kaminari do this for us by simply issuing an extra query, like this: SELECT post.* FROM posts LIMIT 20 OFFSET 100;
...of the time. But rarely, you might have very complicated WHERE conditions or a subquery that takes time to run. In these cases, doing two queries is slower than it...
The robots.txt file and HTML tag can be used to control the behavior of search engine crawlers. Both have different effects. robots.txt Marking a URL path as "disallowed" in robots.txt...
...crawlers to not access that path. robots.txt is not a guarantee for exclusion from search engine results. A "disallowed" URL might be known from an external link, and can still...
...On purpose? Right... In Gnome Make it an additional ESC key by going to System -> Preference -> Keyboard -> Layouts -> Options -> CapsLock key behavior and select "Make CapsLock an additional ESC".
...to using dconf. dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:escape']" Or, open Tweak advanced GNOME 3 settings and follow Keyboard & Mouse -> Additional Layout Options to chose the same option as described above...
Angular directives with isolate scopes have three different variable binding strategies, of which one is =. Example: # HTML # Coffeescript @app.directive 'panel', -> scope: evaluated: '=value' bound: '=twoway' link: -> scope.evaluated # = false scope.bound = 'foo...
...bound with = (value, twoway) have their value evaluated as Angular expression in the parent scope's context and have the result assigned to the corresponding scope variable (evaluated, bound). It...
You can use JavaScript to get or set cookie values on the client. Using the vanilla JavaScript API In JavaScript, document.cookie is an accessor to all cookies on the current...
...site. It looks like a String, but its setter is actually more powerful. When setting cookies this way, remember to set the path=/ option. Reading cookies A result may look...
If others on a call (Skype, SIP, ...) can not hear you loud enough, your volume levels are probably too low. Also, Skype may be changing your mixer levels.
...proper recording volume Open your mixer software (run pavucontrol). Switch to input devices. If you have more than one recording device, find the correct one. Make a test call to...
Stringex is a gem that offers some extensions to Ruby's String class. Ruby 1.9 compatible, and knows its way around unicode and fancy characters...
...Examples for stringex's String#to_url method: # A simple prelude "simple English".to_url => "simple-english" "it's nothing at all".to_url => "its-nothing-at-all"
Today I needed to execute a ruby gem executable with sudo. But, surprisingly, bash would tell me command not found for the gem that ran lovely without sudo.
...are installed to /var/lib/gems/1.8/bin, which is not in sudo’s PATH. Unfortunately, you can’t change the path, since sudo for Ubuntu is compiled with the --with-secure-path option...
...message like this, rubygems.org might have issues with their ipv6 connectivity: $ bundle install Fetching source index from https://rubygems.org/ Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch...
...specs from https://rubygems.org/ due to underlying error <timed out (https://rubygems.org/specs.4.8.gz)> The (a little bit dirty) possible solution If that's actually the case, then you can try...
...Ever wanted to give an element "the container's width minus 20px on each side"? Here you go: .foo { width: calc(100% - (20px * 2)); } When using Sass, you need to...
...interpolate Sass expressions: $margin: 20px * 2 .foo width: calc(100% - #{$margin}) Supported by all modern browsers and IE9...
...to those fields that is case-insensitive. The model looked like this: create_table :shop_locations do |t| t.string :street t.string :house_number t.string :zip_code t.string :city t.belongs_to...
end But how to solve the uniqueness problem? Another day, another undocumented Rails feature! This time, it’s that ActiveRecord::Base.connection.add_index supports an undocumented option to pass a...
jQuery offers many different methods to move a selection through the DOM tree. These are the most important: $element.find(selector) Get the descendants of each element in the current set...
...of matched elements, filtered by a selector. Does not find the current element, even it matches. If you wanted to do that, you need to write $element.find(selector).addBack(selector...
...Use Before and After to avoid that. Details Consider this Cucumber feature file: Feature: Something that needs to be tested Background: Given a user And I sign in Scenario: Sign...
When I sign out Then I should see "Signed out" Scenario: Something else # ... Now, assume you have these step definitions: Around do puts "** Around: before yield" yield puts "** Around...
...is edited by WSYIWYG-Editor but want some length checking nevertheless, you need to strip all tags and then the special characters: def hard_sanitize(text) ActionController::Base.helpers.strip_tags(text...
...gsub(/[^[:word:]]+/, " ") end :001 > hard_sanitize("This is beautiful markup ") => "This is beautiful markup" If you allready have nokogiri on board, you can use that as well, though it has...
...when you work for clients from Europe or the US, there are two dominantish standards you should know about. Each of these has subtle differences. ISO 8601 This is adhered...
...to by most European countries. Weeks start on Monday and end on Sunday. To get the number of the weekday in Ruby as defined by ISO 8601, use Date#cwday...
Delegating methods to other objects is often helpful but the syntax of both def_delegators and def_delegator is a complete mess that makes your code hard to read.
...ActiveRecord::Base belongs_to :topic def_delegators :topic, :title, :category end Here, we can say Post.new.title and actually read title from the Post's Topic object. Because of what we...
The SQL code generated by Graticule's spherical distance computation is insufficient and can lead to NULL distances in edge cases. The reason for this is that MySQL is performing...
...several sine and cosine computations which can result in slight rounding errors -- which is usually okay. Rarely, though, for the exact center of the given circle, it is then asked...
Given those modules: module A def foo; end def bar; end end module B end When you want to call...