SShortSingh.
Back to feed

Converting IP Ranges to CIDR Blocks for ClickHouse Geolocation Lookups

0
·2 views

A common ClickHouse IP geolocation recipe converts each IP range into a single CIDR block with a one-line XOR trick, which miscalculates most multi-address ranges and overstates their size. The article demonstrates an exact conversion in plain ClickHouse SQL covering both IPv4 and IPv6, splitting each range into the precise set of CIDR blocks. It recommends the ip_trie dictionary layout, the only option that supports IPv6 range lookups, and notes that keeping only queried columns sharply reduces memory use. Enrichment is applied at insert time via MATERIALIZED columns so historical rows keep their original location data. Daily refreshes are handled by building replacement tables, verifying row counts, swapping them, and reloading the dictionary without downtime.

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 ·

Map Every AI Agent Action and Gate the Irreversible Ones Behind Human Sign-Off

The article argues that AI agents able to issue refunds, cancel orders, send emails, or move money pose a greater risk than those that only draft replies, because their results can be impossible or hard to reverse. It recommends listing every concrete action an agent can take, then asking whether each can be quickly and fully reversed. Actions that cannot be undone, such as sent messages, submitted payments, or taken-effect cancellations, should require human approval. Organizations should name specific approvers with backups, set safe defaults when reviews stall, and log all irreversible actions. The author also advises testing whether the agent can bypass these controls before customers interact with it.

0
ProgrammingDEV Community ·

DeOldify, DDColor and BigColor Compared on Colorization Error Using CIEDE2000

On ten grayscale-converted Prokudin-Gorskii photos, DeOldify's median whole-image color error was 9.55 ΔE2000, close to DDColor's 9.32 and BigColor's 9.04. Its results were less saturated, with mean chroma of 9.5 across 34 measured zones versus 18.9 in the original photos. The model also missed skies in some images, and the hosted version added a small icon in one corner. The test used Replicate with default settings, and errors were computed per pixel in CIELAB with a regional breakdown. The DeOldify repository was archived in October 2024.

0
ProgrammingDEV Community ·

How Opening Two Breakers on a Substation Ring Bus Splits the Network

A ring bus links circuit positions into a loop so power can flow either way around it. With all six breakers closed, the ring operates as a single electrical bus, and opening one breaker still leaves a connected path. Opening two breakers can cut the ring into separate sections, each of which must be analyzed independently. A section cut off from both incoming circuits has no power source, so no solved result should be reported for it. The article uses a 230 kV example with four demands to illustrate these effects.

0
ProgrammingDEV Community ·

MentoraLoop Launches Platform Combining Exam Prep, Skill Courses and Mentorship

MentoraLoop is an online learning platform designed to let students prepare for competitive exams, learn technical skills, and pursue creative interests in one place. Its developers aimed to move beyond traditional course-only education by offering a centralized, interactive environment. Subject categories range from exam preparation such as MDCAT, ECAT, SAT and CSS to programming, arts, crafts, media, baking and jewelry-making. The student dashboard consolidates classes, upcoming sessions, tests, performance and announcements, while live classes integrate with Google Meet and a content library offers recorded lectures and downloadable notes.