Top
Best
New

Posted by bennett_dev 2 days ago

Compressing a flag to 11 bits(read.vantezzen.io)
131 points | 55 commentspage 2
ComputerGuru 9 hours ago|
If you're on Windows (where Microsoft famously chose they would not get involved with flags and show country codes instead), execute this in dev tools or save it as a javascript bookmarklet to make the emoji flags show up:

    javascript:(function(){if(!document.getElementById('twemoji-styles')){const s=document.createElement('style');s.id='twemoji-styles';s.textContent='img.emoji{height:1em!important;width:1em!important;margin:0 .05em 0 .1em!important;vertical-align:-0.1em!important;display:inline!important;}';document.head.appendChild(s)}const r=()=>{const o={folder:'svg',ext:'.svg'};twemoji.parse(document.body,o);if(!window.__twemojiObserver){let t;const ob=new MutationObserver(()=>{clearTimeout(t);t=setTimeout(()=>{ob.disconnect();twemoji.parse(document.body,o);ob.observe(document.body,{childList:true,subtree:true});},300);});ob.observe(document.body,{childList:true,subtree:true});window.__twemojiObserver=ob;}};if(window.twemoji){r();}else{const sc=document.createElement('script');sc.src='https://cdn.jsdelivr.net/npm/@twemoji/api@latest/dist/twemoji.min.js';sc.crossOrigin='anonymous';sc.onload=r;document.head.appendChild(sc);}})();
Kwpolska 2 hours ago||
Or you can just switch to Firefox.
Titan2189 6 hours ago||
Thanks, that fixes it in Chrome for me. Firefox was already displaying the flags correctly from the beginning.
weinzierl 5 hours ago||
This cool as an encoder, but to me, the most interesting aspect is the generating part near the end of the article. I can see me using that for a game or for avatars.
emptybits 9 hours ago||
Cool idea. The author's AI failed to encode flags for approximately 35% of the world's population. Approximately 3 billion people. At least that's why my AI tells me. India obviously contributes a lot to this. I'm probably salty because my own country's simple (?) flag is also in the "unencodable" group. Lol.

I applaud the author holding aspect ratio as a priority to encode. It's jarring to see an otherwise correct and familiar flag stretched into an incorrect shape when flown or shown.

ComputerGuru 9 hours ago||
Nice work! I wonder if you could (or did?) choose a more median shade for each color, especially blue? It seems, going by the comparison page, that most flags actually call for a less royal, more sky shade of blue, so you could use the median (on a linear RGB scale, or XYZ) shade instead as the designated representative for that color?

I noticed Rwanda seems to have the wrong aspect ratio, though you are able to encode that arbitrarily, no?

Bimos 7 hours ago||
I thought a flag is 1 bit
CoastalCoder 6 hours ago|
> I thought a flag is 1 bit

Well you see, it has to implement IStateful and IBooleanExpression, and both of those involve virtual methods so you have a vtbl pointer as well.

So that's 64+1 bits right there.

Then you also have the address-alignment requirements for that vtbl pointer, so practically speaking were talking 128 bits.

Or 80 bits of you're rolling dirty and say "screw it" to that alignment assumption.

Now if your on x86-64 and want to smuggle that bit value into the unused part of that "64" bit vtbl pointer, you could probably bring it down to just 64 bits overall I guess. Well probably want to let the compiler know about that though, before anyone tries actually using that vtbl pointer.

But, if we also need to make this accessible to Python, then...

harpiaharpyja 10 hours ago||
With all the attention on the link between compression and intelligence lately it is neat to have this example of how creating a encoding scheme naturally allows you to create new (likely) never before seen flags.
ano-ther 10 hours ago||
Cool idea. Interesting that Indonesia, Poland and Monaco with very similar two-stripe designs have different compression rates (11, 14 and 17 respectively). Probably the aspect ratio that also gets encoded.
classified 2 hours ago||
I thought it was meant ironically because a flag (in software) is just one bit.
jtxt 11 hours ago||
Cool project and results! https://vantezzen.github.io/miniflags/
blacklion 10 hours ago|
Fun fact: Constitution of Nepal has chapter about format of The Flag and it reads as geometry textbook problem (starred one, for advanced students).
More comments...