SShortSingh.
Back to feed

How a measurement parser reads 12' 6", 2.4 m and 2,5 without annoying users

0
·1 views

Online calculators usually force users to convert their measurements into a single number and unit before typing, which frustrates people who measure in feet and inches. The author, who builds the free Toggle9 calculators, describes a dependency-free parser of under 200 lines of JavaScript that accepts natural input such as mixed feet and inches, fractions, vulgar fraction characters, and multiplication expressions. The normaliser standardises varied notations, with rules that treat a comma before exactly three digits as a thousands separator and other digit-comma-digit patterns as decimal commas. A lexer folds fractions into numbers and tags unit tokens with their dimension, so areas and volumes are distinguished from lengths. An evaluator converts every value to SI base units, and the parser returns clear, actionable messages when an input cannot be read or has the wrong dimension for a field.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

GitLab CI/CD Caching Methods Can Cut Docker Build Times by Up to 80%

Developers often face long CI/CD pipeline runs because GitLab's ephemeral runners start with an empty Docker cache, forcing layers to be rebuilt on every commit. Pulling base images from Docker Hub also frequently hits rate limits, causing 429 errors. GitLab offers two built-in features to address both issues: Container Registry with BuildKit layer caching and the Dependency Proxy, which acts as a local pull-through cache for upstream images. The author's guide shows how combining these techniques, along with a layer-friendly Dockerfile ordering, can reduce container build times by as much as 80 percent.

0
ProgrammingDEV Community ·

n8n 2026 Pricing: Cloud Plans Versus Self-Hosting Real Costs

Standard n8n pricing comparisons focus on sticker prices, but overall cost depends on how many workflow executions run each month and what self-hosting really involves. n8n bills per execution rather than per user, and includes unlimited users and active workflows on every plan. Frequent scheduled triggers can push usage past the Starter or Pro limits quickly, with the next tier costing far more. Self-hosting the free Community Edition still requires a server, backups, and ongoing maintenance time, which can add up to more than a Cloud subscription. The article advises checking n8n's pricing page directly, since prices change often.

0
ProgrammingDEV Community ·

Open-Source LocalRAG Lets Teams Query Documents Without Cloud AI APIs

A developer has released LocalRAG, an open-source document question-answering system designed to run entirely within a private or air-gapped environment. The stack lets users upload PDF, DOCX, TXT, or Markdown files, which are chunked, embedded with a local bge-m3 model, and stored in Qdrant for retrieval. Answers are generated by a local LLM through Ollama and returned with source references, with no cloud AI calls at runtime. The project is aimed at sectors like legal, healthcare, and finance that cannot send confidential data to external services. Initial setup still requires network access to pull Docker images and models, and the developer noted that the large unpacked image size can be a problem on slow connections.

0
ProgrammingDEV Community ·

CDP-6001 Exam Breakdown: PySpark Code That Covers 58% of the Cloudera ML Exam

A DEV Community article explains that Cloudera's CDP-6001 Machine Learning Engineer exam has 45 questions to be answered in 90 minutes, with a 60% passing mark. Three domains, Spark, Spark MLlib, and deploying models, together make up 58% of the test, and all are practiced through code in a Cloudera Machine Learning session. The author walks through a sample churn project covering loading events, window features, pipelines, tuning, MLflow tracking, and deployment. Because the exam is proctored and forbids reference material, the author argues that hand-writing the code beforehand helps candidates recognize errors within the roughly two minutes available per question. The piece also covers Spark DataFrame practices such as explicit schemas and partitioned Parquet files.