Urgent.News

What's breaking now, across thousands of outlets.

Tech

Parsing 12' 6" and 2.4 m: measurement input that doesn't annoy people

Most online calculators give you a number box and a unit dropdown. Then someone measures their patio with a tape, gets 12 feet 6 inches , and has to work out that that's 12.5 before they can type anything. I build Toggle9 , a set of free calculators, and I wanted the input box to accept what people actually write down. This post walks through the parser behind it: under 200 lines of plain…

The parser behind Toggle9, a set of free calculators, accepts various input formats for measurements and returns consistent values. It handles inputs like "12 6" which represents 12 feet 6 inches, and converts it to 12.5 feet. Additionally, it accepts "12 -6 1/2" which is equivalent to 12.5417 feet, and "12 1/2" or "12½" which also equates to 12.5 feet.

The parser can also process decimal measurements such as "2.4 m", converting it to 7.874 feet when in a feet field. For inputs like "2,5" in a meters field, it converts it to 2.5 meters. The parser supports different decimal and thousands separators, such as "1,250" (which becomes 1250) and "12 + 3 + 6" which converts to 15.5 feet. It also parses expressions like "12 x 10" as an area of 120 square feet and stores it as 120 m².

However, the parser rejects certain invalid inputs with user-friendly error messages. For instance, "12 sq ft in a length field" is flagged as "That looks like an area; this field needs a length." and "12 apples" is rejected with "Try 12.5, 12 1/2 or 12 6."

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

I built WebWarp because Chrome's Local Overrides never finished the job

Every frontend dev and QA engineer knows this dance: You need to change one response a live site returns — a script, a CSS file, a JSON payload.

  • WebWarp addresses Chrome Local Overrides limitations for frontend developers
  • Supports URL matching, local file mapping, and scoped conditions
  • Offers founder lifetime deal at $99 or monthly plans starting at $19

I replaced NFS with a FUSE filesystem on my homelab, and macOS ate three working days

I run an always-on homelab, a Mac mini, a Dell server on the LAN, a gaming PC, a UPS on every box. Files move between all three constantly, so the hot tier of the Dell used to be a Nextcloud mount…

  • Replaced NFS with FUSE filesystem (JuiceFS) on homelab Mac mini
  • macOS took three days to fully function post-switch
  • Performance boost: 225 MB/s write, 618 MB/s read

More from Friday 16 October →