[HN Gopher] Bash one-liner to produce a list of HEX color codes ...
       ___________________________________________________________________
        
       Bash one-liner to produce a list of HEX color codes that read like
       English words
        
       Author : ailef
       Score  : 93 points
       Date   : 2022-10-01 18:11 UTC (4 hours ago)
        
 (HTM) web link (gist.github.com)
 (TXT) w3m dump (gist.github.com)
        
       | teaearlgraycold wrote:
       | Fun fact: Every Java .class file starts with the magic bytes
       | C0FEBABE
        
         | tragomaskhalos wrote:
         | It's CAFEBABE
        
         | belter wrote:
         | CAFEBABE
         | 
         | "...We used to go to lunch at a place called St Michael's
         | Alley. According to local legend, in the deep dark past, the
         | Grateful Dead used to perform there before they made it big. It
         | was a pretty funky place that was definitely a Grateful Dead
         | Kinda Place. When Jerry died, they even put up a little
         | Buddhist-esque shrine. When we used to go there, we referred to
         | the place as Cafe Dead. Somewhere along the line, it was
         | noticed that this was a HEX number. I was re-vamping some file
         | format code and needed a couple of magic numbers: one for the
         | persistent object file, and one for classes. I used CAFEDEAD
         | for the object file format, and in grepping for 4 character hex
         | words that fit after "CAFE" (it seemed to be a good theme) I
         | hit on BABE and decided to use it. At that time, it didn't seem
         | terribly important or destined to go anywhere but the trash can
         | of history. So CAFEBABE became the class file format, and
         | CAFEDEAD was the persistent object format. But the persistent
         | object facility went away, and along with it went the use of
         | CAFEDEAD - it was eventually replaced by RMI...."
         | 
         | - James Gosling
        
           | TillE wrote:
           | I've been using that as my own alternative to DEADBEEF for
           | years, I had no idea it was part of the official Java spec.
           | Maybe it got lodged in my brain subconsciously at some point.
        
           | jrumbut wrote:
           | I had the distinct pleasure of discovering CAFEBABE myself,
           | in high school (not sure what direction this is dating myself
           | in but I'll risk it), when I went on a tear of opening odd
           | things in a hex editor.
           | 
           | Now I will never be able to see without thinking of this
           | story: https://aphyr.com/posts/341-hexing-the-technical-
           | interview
        
       | nick0garvey wrote:
       | Interesting one liner but would like to see the colors it
       | generates
        
         | Silverback_VII wrote:
         | Not long ago I saw a link here to site with the words and the
         | colors...
        
           | amenghra wrote:
           | This maybe? https://news.ycombinator.com/item?id=31673662
        
           | styfle wrote:
           | Also this https://news.ycombinator.com/item?id=14537747
        
         | [deleted]
        
         | LanternLight83 wrote:
         | https://gist.github.com/aileftech/dd4f5598b1f3837651fdf16e5a...
        
       | kragen wrote:
       | I tried this a few years ago;
       | http://canonical.org/~kragen/sw/dev3/colors.html has them as
       | foreground colors and
       | http://canonical.org/~kragen/sw/dev3/colors.2.html has them as
       | background colors. I tested 3-letter words as well as 6-letter
       | words, and used 1 as "l" as well as "I", but I didn't try
       | aghasemi's very productive suggestion of using 5 as S. I don't
       | remember if it it didn't occur to me or if I tried it and didn't
       | like the results.
       | 
       | Some of them are pretty #bad (#011 doesn't really look much like
       | "oil") and some, though they read quite well, correspond to awful
       | colors; you might even say, #faeca1 colors. Still, I've made my
       | #bed, #0dd as it may be; now I must #11e in it. I think I've #fed
       | you enough #babb1e for today.
        
       | ratsmack wrote:
       | I don't like using multiple commands.                   mawk
       | 'BEGIN{b = "[abcdefois]"; l = "[a-z]"; W = "^" b l l l l l "$"};
       | $0 ~ W {print "#" toupper($0);}' /usr/share/dict/words
        
         | Keyframe wrote:
         | you also aren't going to get valid color codes
        
         | kbr2000 wrote:
         | I came up with:                 gawk 'BEGIN {IGNORECASE=1}
         | ((length($1) == 6) && /^[a-fois]+$/)
         | {gsub(/o/,0);gsub(/i/,1);gsub(/s/,5); print toupper("#"$1)}'
         | /usr/share/dict/words
         | 
         | (caveat: it does not filter out duplicates)
        
       | netule wrote:
       | Reminds me of debugging pointer values in C with 0xDEADBEEF.
        
       | dspillett wrote:
       | I know this is only looking at single words, so would miss this,
       | but I always like to work ABAD1DEA into PoC work.
        
       | brrrrrm wrote:
       | Similarly, a list of hex words https://jott.live/code/hex_words
        
       | nine_k wrote:
       | Never mind the colors.
       | 
       | This snippet demonstrates how a number of small tools, each doing
       | its narrow job, strung together via the most trivial interface,
       | produces a non-trivial result.
       | 
       | This composability is still unreachable to the vast majority of
       | GUI tools.
        
         | kupopuffs wrote:
         | Ah yes, the Unix Way
        
         | [deleted]
        
         | throwing_away wrote:
         | SaaS companies hate this one weird trick!
        
         | vesinisa wrote:
         | The non-trivial part here is actually the source data (the dict
         | file.) It is also its pitfall - after adding 5 for S you should
         | see a lithany of plurals. Most dict files (for English anyway)
         | however seem to omit plural nouns. I guess the logic is that in
         | English most plurals are regular, and the naive algorithm for
         | deriving them from the singular forms (correctly most of the
         | time) is quite trivial.
        
       | Waterluvian wrote:
       | Does anyone have a link to a guide on how to write Python or node
       | or rust programs that behave well with bash? Ie. Streaming inputs
       | and outputs and other things I probably don't know about?
        
         | [deleted]
        
         | KMnO4 wrote:
         | It's pretty easy. You have three basic streams:
         | 
         | 1. Stdin - just iterate through sys.stdin
         | 
         | 2. Stdout - regular printing will go there
         | 
         | 3. Stderr - print errors here eg with print(...,
         | file=sys.stderr)
         | 
         | And then beyond that as long as your script gets invoked by the
         | interpreter (Ie #!/usr/bin/env python) everything will "just
         | work".
        
       | pwpwp wrote:
       | It's missing #DADB0D
        
         | kragen wrote:
         | I look forward to your improved version that tests against the
         | Cartesian product of /usr/dict/words with itself plus the empty
         | string and maybe some slang words like "bod". I suggest you
         | limit to shortish words before the Cartesian product rather
         | than after.
        
           | mellosouls wrote:
           | https://en.wikipedia.org/wiki/Dad_bod
        
             | kragen wrote:
             | Testing against a list of all Wikipedia article titles is
             | indeed also an avenue worth exploring, and I hope you
             | explore it.
        
           | gabrielsroka wrote:
           | I installed the American English large dictionary on Ubuntu.
           | It has `bod`.
        
             | kragen wrote:
             | Nice! I'm just using the 102'401-entry version.
        
       | dwheeler wrote:
       | I appreciate the presence of #C0FFEE.
       | 
       | Can't do computing without that!! :-)
        
       | silisili wrote:
       | Fun idea. Perhaps could stretch a little like we did in
       | calculators and add 5 for S, or even 7 for T, but that would
       | likely be a bit less readable.
        
         | ghasemi wrote:
         | I added a comment for 5 vs S. 7/T looks like it's a bit too
         | much :D
        
         | bawolff wrote:
         | You could just do full 1337 speek.
        
           | mod wrote:
           | Little town I frequently drive through has a population of
           | 1337.
           | 
           | I always have a little giggle.
        
           | silisili wrote:
           | come to think of it, doing a separate list of toLower l -> 1
           | isn't a bad idea either...
        
       ___________________________________________________________________
       (page generated 2022-10-01 23:00 UTC)