SShortSingh.
Back to feed

How to Build a Daily Card Feature Without a Database Using Hash Functions

0
·4 views

A developer has shared a stateless approach to implementing a 'card of the day' feature that avoids the need for per-user database writes. The method uses a deterministic hash function — such as FNV-1a or xxhash — seeded with a combination of user ID, date, and deck version to always return the same card for a given user on a given day. Timezone handling remains a practical challenge, and the author settled on accepting client-reported dates while validating them within a ±1-day window of UTC. Including a deck version in the seed prevents retroactive card shifts when new cards are added to the deck. The technique is already in use on a live app called Oraclely and is best suited for ephemeral draws where storing draw history is not required.

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 ·

Keeping a Child's Face Consistent Across 24 AI-Generated Picture Book Pages

Creating AI-illustrated picture books from a single reference photo presents a major challenge: maintaining visual consistency of the same child across all 24 pages. While individual pages may look convincing in isolation, sequential viewing reveals drift in facial features, hair length, and style when pages are generated independently. Developers working on such tools recommend fixing all generation parameters — model version, sampler, style tokens, and step count — across the entire book, and always regenerating the full set rather than individual pages. Identity conditioning should be weighted heavily, as parents are far more likely to forgive stiff poses than an unrecognisable likeness of their child. Metrics like pairwise face-embedding distance and palette variance across pages are more reliable quality checks than single-image scores for catching consistency failures.

0
ProgrammingDEV Community ·

Developer learns repeated quick fixes mask deeper gaps in how we test our own work

A software developer writing on DEV Community reflected on fixing the same category of mistake five times in a single month before recognising a flawed approach to error prevention. Rather than addressing root causes, they had been patching individual instances, gaining brief relief from a passing check without making lasting progress. The developer observed that automated checks only capture failures already imagined by the person who wrote them, leaving unimagined edge cases entirely unguarded. Reviewing their actual past failures, they identified at least five distinct ways a safeguard can fail: blocking valid work, missing bad work, crashing on unexpected input, silently destroying data, or approving incomplete output. The experience prompted a change in working habits, with the key insight being that a green check confirms survival of known cases, not overall correctness.

0
ProgrammingDEV Community ·

Why Developers Need Work Traces, Not Just Screenshots, in the AI Era

As AI tools make it easier to produce polished portfolios, a developer and writer argues that final artifacts like screenshots and demos no longer reliably demonstrate real skill or judgment. The author proposes the concept of a 'work trace' — a documented chain from problem and plan through failures, corrections, and decisions to the final result. This approach aims to make human responsibility visible within AI-assisted workflows, answering not whether AI was used, but where the developer's judgment actually entered the process. The author notes that traditional portfolio elements like READMEs, diagrams, and landing pages can now be generated cheaply, reducing their signal value for evaluators. A traced build, by contrast, exposes the reasoning, rejections, and corrections behind the work, which the author argues is where genuine technical trust is established.

0
ProgrammingDEV Community ·

Why Browser-Generated Print PDFs Fail: Color, Bleed, DPI, and Fonts

Creating print-ready PDFs in a browser involves far more complexity than generating screen-readable documents, as physical printing imposes strict technical requirements. Browsers render in RGB while printers use CMYK, meaning vibrant colors like bright blues and greens appear noticeably duller on paper with no browser warning to alert developers. Print PDFs also require a 3mm bleed beyond the trim edge, 300 DPI image resolution, and properly embedded fonts — standards that typical browser output fails to meet. Reflowable HTML lacks native pagination, forcing developers to manually measure and assign content blocks to pages in code rather than relying on CSS. These challenges were documented by a developer building Cook Press, a tool that converts recipes into print-ready hardcover books sold on Etsy.