Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Error’d: Pickup Sticklers

      September 27, 2025

      From Prompt To Partner: Designing Your Custom AI Assistant

      September 27, 2025

      Microsoft unveils reimagined Marketplace for cloud solutions, AI apps, and more

      September 27, 2025

      Design Dialects: Breaking the Rules, Not the System

      September 27, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Cailabs secures €57M to accelerate growth and industrial scale-up

      September 12, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025
      Recent

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025

      Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

      September 28, 2025

      The first browser with JavaScript landed 30 years ago

      September 27, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured
      Recent
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Off Color

    CodeSOD: Off Color

    July 8, 2025

    Carolyn inherited a somewhat old project that had been initiated by a “rockstar” developer, and then passed to developer after developer over the years. They burned through rockstars faster than Spinal Tap goes through drummers. The result is gems like this:

    private <span class="hljs-keyword">void</span> <span class="hljs-title function_">init</span>(<span class="hljs-params"></span>){
    	<span class="hljs-title class_">ResourceHelper</span> rh = <span class="hljs-keyword">new</span> <span class="hljs-title class_">ResourceHelper</span>();
    	<span class="hljs-keyword">for</span> ( int i = <span class="hljs-number">0</span>; i < <span class="hljs-number">12</span>; i++) {
    		months[i] = rh.<span class="hljs-title function_">getResource</span>(<span class="hljs-string">"calendar."</span>+monthkeys[i]+<span class="hljs-string">".long"</span>);
    		months_s[i] = rh.<span class="hljs-title function_">getResource</span>(<span class="hljs-string">"calendar."</span>+monthkeys[i]+<span class="hljs-string">".short"</span>);
    	}
    	<span class="hljs-title class_">StaticData</span> data = <span class="hljs-title class_">SomeService</span>.<span class="hljs-title function_">current</span>().<span class="hljs-title function_">getStaticData</span>();
    	<span class="hljs-variable language_">this</span>.<span class="hljs-property">bankHolidayList</span> = data.<span class="hljs-title function_">getBankHolidayList</span>();
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#dddddd"</span>, <span class="hljs-string">"#dddddd"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#cccccc"</span>, <span class="hljs-string">"#cccccc"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#e6e6e6"</span>, <span class="hljs-string">"#e6e6e6"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#ff0000"</span>, <span class="hljs-string">"#ffcccc"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#ffff00"</span>, <span class="hljs-string">"#ffffcc"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#00ff00"</span>, <span class="hljs-string">"#ccffcc"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#5050ff"</span>, <span class="hljs-string">"#ccccff"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#aa0000"</span>, <span class="hljs-string">"#ff9999"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#ff8000"</span>, <span class="hljs-string">"#ffcc99"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#99ff99"</span>, <span class="hljs-string">"#ccffcc"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#ffcc99"</span>, <span class="hljs-string">"#ffffcc"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#ff9966"</span>, <span class="hljs-string">"#ffcc99"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#00c040"</span>, <span class="hljs-string">"#99cc99"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#aadddd"</span>, <span class="hljs-string">"#ccffff"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#e0e040"</span>, <span class="hljs-string">"#ffff99"</span>);
    	colors.<span class="hljs-title function_">put</span>(<span class="hljs-string">"#6699ff"</span>, <span class="hljs-string">"#99ccff"</span>);
    }
    

    There are plenty of things in this function that raise concerns- whatever is going on with the ResourceHelper and the monthkeys array, for example. But let’s just breeze past that into that colors lookup table, because boy oh boy.

    There’s the obvious issue of using server-side code to manage colors instead of CSS, which is bad, sure. But this translation table which converts some colors (presumably already used in the display?) to some other colors (presumably to replace the display colors) is downright mystifying. How did this happen? Why did this happen? What happens when we attempt to apply a color not in the lookup table?

    I want to say more mean things about this, but the more I stare at the original colors and what they get translated to, I think this lookup table is trying to tell me I should…

    …
    …

    lighten up.

    [Advertisement]
    Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticlePublic exploits released for CitrixBleed 2 NetScaler flaw, patch now
    Next Article CISA Adds 3 Flaws to KEV Catalog, Impacting AMI MegaRAC, D-Link, Fortinet

    Related Posts

    News & Updates

    Building personal apps with open source and AI

    September 12, 2025
    News & Updates

    What Can We Actually Do With corner-shape?

    September 12, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Filter Model Attributes with Laravel’s New except() Method

    Development

    Accelerate enterprise AI implementations with Amazon Q Business

    Machine Learning

    From idea to PR: A guide to GitHub Copilot’s agentic workflows

    News & Updates

    This new Gmail tool lets you declutter your inbox in seconds – here’s how to use it

    News & Updates

    Highlights

    Development

    Hackers Breach Toptal GitHub, Publish 10 Malicious npm Packages With 5,000 Downloads

    July 28, 2025

    In what’s the latest instance of a software supply chain attack, unknown threat actors managed…

    CISA Warns of Critical Vulnerabilities in Planet Technology Products

    April 28, 2025

    Russian Hackers Exploit Microsoft OAuth to Target Ukraine Allies via Signal and WhatsApp

    April 23, 2025

    Fortinet Patches CVE-2025-32756 Zero-Day RCE Flaw Exploited in FortiVoice Systems

    May 14, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.