While it might seem trivial to implement an invoice that sums up items and shows net, gross and vat totals, it actually involves a lot of rules and caveats. It...

...examples in Ruby and MySQL, the concepts apply to all programming languages and data stores. When to round There are exactly two spots where your invoice logic should round money...

Don't sum up columns with + in a sql-query if NULL-Values can be present. MySQL and PostgreSQL cannot sum up NULL values with the + value. The sum value...

MySQL: mysql> select 1 + 2 + 3; +-----------+ | 1 + 2 + 3 | +-----------+ | 6 | +-----------+ 1 row in set (0,00 sec) mysql> select 1 + NULL + 3; +--------------+ | 1 + NULL + 3 | +--------------+ | NULL...

...popup on all browsers. When you integrate a date picker popup, remember to also set autocomplete="off" on the text input that opens the calendar on click. Otherwise the autocomplete...

...suggestions will cover the calendar box and make it unusable: If you are using a tool like Unpoly you might want to set autocomplete="off" in the JavaScript that also...

If the project team consists of at least 2 members, do a daily standup. It should not take much longer than 15 minutes. Format Tell everyone else

if there are new developments everyone needs to know about A "still working on X, will probably be done today" is totally fine. No need to tell...

Capybara has a global option (Capybara.ignore_hidden_elements) that determines whether Capybara sees or ignores hidden elements. Prefer not to change this global option, and use the :visible...

...and web-applications with real browsers. Capybara has a driver for Selenium that wraps around selenium-webdriver which is a Ruby binding to remote control real browsers via Selenium's...

Since I use this a lot in my daily work and there were no scripts working properly for me, I made one myself. It's actually not bound to Xfce...

...t tried it, though). Installation If you don't yet have xdotool, install it: sudo apt-get install xdotool If you don't yet have wmctrl, install it:

stackoverflow.com

When you use method_missing to have an object return something on a method call, always make sure you also redefine respond_to_missing?. If you don't do it...

def method_missing(method_name, *args, &block) if method_name == :bark 'woof!' else super end end end This will allow you to say: Dog.new.bark => "woof!" But: Dog.new.respond_to? :bark...

You can change which branches will be pushed when saying git push. Our recommendation is to set it to current. From the git-config documentation: push.default Defines the action git...

...branch, but forgot to setup tracking. If you can't currently push, use git branch --set-upstream-to=origin/$(git branch --show-current...

relishapp.com

In RSpec you can tag examples or example groups with any tags you like simply by saying describe ReportCreator, slow: true do # .. end describe ReportCreator do it 'generates reports', slow...

# ... end end You can then only run examples with these tags. rspec --tag slow rspec -t slow # Using the parallel_tests gem rake "parallel:spec[,,--tag slow]"

support.google.com

The old Chrome downloads bar had several advantages over the new subtle downloads dropdown: see all (many, at least) downloads at once and see their progress downloads can be opened...

...with a single click drag them back into another web page to upload them again, with no extra clicks required How to get it back Go to chrome://flags/#download...

This is a small example on how you can check if your Postgres index can be used by a specific query in you Rails application. For more complex execution plans...

...it might still be a good idea to use the same path of proof. 1. Identify the query your application produces query = User.order(:last_name, :created_at).to_sql

...to read the The framework field guide - Fundamentals, the first of a three part series to learn the basics of frontend technologies. I can highly suggest it for learning the...

...fundamentals. 'The framework field guide' is written by Unicron Utterances and there side has many high quality articles on web development and computer science related to programming. The Framework Field...

...that's not a float! This occurs because JavaScript uses double precision floats to store numbers. So according to IEEE floating point definition only numbers between...

...and 2^53 - 1 (9007199254740991) can safely be represented in JavaScript. Number.MAX_SAFE_INTEGER will return the largest integer that can accurately be represented. For arbitrary large numbers (even...

Why string sorting sucks in vanilla Ruby Ruby's sort method doesn't work as expected with special characters (like German umlauts): ["Schwertner", "Schöler"].sort # => ["Schwertner", "Schöler"] # you probably expected...

...Schöler", "Schwertner"] Also numbers in strings will be sorted character by character which you probably don't want: ["1", "2", "11"].sort # => ["1", "11", "2"] # you probably expected...

When you have an Angular directive that transcludes content, you might want to do something in case there is no content inside your element, like showing some default content.

...you can not do something like default goes here . Angular will always empty that element's text, even if there is nothing to transclude. But you can use your directive...

If you need to convert an SVG source to PS or EPS, the most common suggestion on the interwebs is to use Inkscape from the commandline. Inkscape is a fairly...

...converting is CairoSVG. CairoSVG is available on most Linux distros through their package management systems, e.g. apt install cairosvg on Ubuntu. It has few dependencies (most importantly Python 3 and...

...an error if your application logic ever violates it. class User < ApplicationRecord has_one :session, dependent: :destroy end class Session < ApplicationRecord belongs_to :user end create_table :users do |t...

end create_table :sessions do |t| t.references :user, null: false, foreign_key: true, index: { unique: true } # Don't forget the uniqueness here t.timestamps

...core and available in all ruby versions without the need to install anything. This serializes complete ruby objects including id, object_id and all internal state. Marshal.load deserializes a string...

...to an object. A deserialized object cannot be saved to database directly as the the dumped object was not marked dirty, thus rails does not see the need to save...

api.rubyonrails.org

ActiveSupport (since 4.1) includes test helpers to manipulate time, just like the Timecop gem: To freeze the current time, use freeze_time (ActiveSupport 5.2+): freeze_time To travel to a...

...specific moment in time, use travel_to: travel_to 1.hour.from_now Important When freezing time with #travel_to, time will be frozen (like with freeze_time). This means that your...

...PATH << File.expand_path('../../lib', __FILE__) require 'my_cli' MyCli.run! However, if you create a symlink to this file, this will no longer work. __FILE__ will resolve to the path of...

...the symlink, not to its target. One solution is to use File.realpath(__FILE__). In Ruby 2+ you can also use this: $LOAD_PATH << File.expand_path('../lib', __dir__) __dir__ is simply...

...have 2 HTML boxes. The first one has a margin-bottom of let's say 30px and the second one a margin-top of 20px. After rules of collapsing margins...

...too. For example child elements with margins also collapse with margins of the previous sibling of the parent box. Nevertheless there are some exceptions where the behavior of vertical collapsing...

Element finding is a central feature of Capybara. Since #find is normally used to get elements from the current page and interact with them, it's a good thing that...

...some Capybara drivers (e.g. Selenium) will wait an amount of time until the expected element shows up. But if Capybara cannot #find it at all, you'll get an error...

makandra dev

...is just awesome. Install via apt-get or brew. Handy commands t ("tree"): Directory-structure based access. You'll see the current directory annotated with the latest change date and...

...date and author. d ("diff"): Like ENTER on a commit, but arrow keys will scroll the diff! /: Search current view (e.g. commit list, diff). Jump to next hit with n...

developer.mozilla.org

❌ Bad example Let's take a look at a common example: Clear Search The HTML above is being activated with an Unpoly compiler like this: up.compiler('[filter]', function...

...const queryInput = filterForm.querySelector('[filter--query]') function resetQuery() { queryInput.value = '' queryInput.focus() } up.on('click', resetQuery) }) The Clear search button has three issues: It cannot be focused with the keyboard It cannot be pressed...