Most active commenters
  • neya(5)

←back to thread

296 points reverseCh | 15 comments | | HN request time: 1.233s | source | bottom

I recently came across the concept of "useless" programs - pieces of code that serve no practical purpose but are fun, creative, or challenging to write. These could be anything from elaborate ASCII art generators to programs that solve imaginary problems. I'm curious to hear about the most interesting or creative "useless" programs the HN community has written. What was your motivation? What unexpected challenges did you face? Did you learn anything valuable from the experience? Some examples to get the ball rolling: 1. A program that prints the lyrics of "99 Bottles of Beer" in binary. A text-based game where you play as a semicolon trying to find its way to the end of a line of code. A script that translates English text into Shakespearean insults. Share your creations, no matter how quirky or impractical. Let's celebrate the joy of coding for coding's sake!
1. neya ◴[] No.41896536[source]
A decade and a half ago, I came across this beautiful bar in Bahrain (online) that was visually appealing to the eye with contrasty colors. I was so fascinated by it that I started writing a simple algorithm to just extract out the dominant colors in the image, just for fun, but mostly because I was so lazy to open Photoshop and pick the colors out manually.

Turns out, this is actually a real challenging task for computers - what the eyes perceive as dominant, computers do not and vice-versa. For example, if you draw a small circle on a black board with white chalk, take a picture of it and ask a computer, it will tell you black is the dominant color because it covers most of the pixels. Whereas, any human would tell you the white drawing is the dominant color because it stands out.

There are some ways of guiding the computer to get the color palette you want out of an image, but they are never as accurate. Over the years, I would from time to time, throw a bunch of images at it - ranging from portraits to beautiful flowers from gardens to see how my algorithm would perform and improved it bit by bit. I would say, it is close to 90% accuracy now and I still work on it over the weekends. It has no use cases so far (for me). It just exists as a pure passion project that got me excited about programming such algorithms.

Recently, I did a Fashion degree just out of passion and I realized this code has so much applications for things like making mood boards and color palettes from inspiration boards. However, none of my professors nor fellow students were impressed or saw utility in it because they believed no algorithm can match or replace a true creative process. They are pretty old-school about this, so, there's that. But, they just didn't seem to understand the technical challenge about this seemingly simple task.

However, over the years, I did build an API around this algorithm, kept fine tuning it and even made some marketing material for it. For no purpose other than reminding myself of why I am excited about programming.

If you're interested, here is a decade old snapshot of the algorithm's output:

https://ibb.co/SvYLLG3

https://ibb.co/tHKf9T8

replies(5): >>41914224 #>>41919976 #>>41920126 #>>41924316 #>>41924921 #
2. bittwiddle ◴[] No.41914224[source]
Hey this is pretty cool! Have you thought about putting it online? I've occasionally used tools like Adobe's color scheme finder, where you upload an image and it suggests a fitting colorscheme derived from the photo. Though honestly theirs doesn't perform too well.

Yours looks like a nice improvement.

replies(1): >>41963754 #
3. rozab ◴[] No.41919976[source]
It's a cool problem. Did you ever see the pywal project? It has a few backends for generating palettes, I think the best is the imagemagick one in wal.py

https://github.com/dylanaraps/pywal/tree/master/pywal/backen...

Also, I guess dylanaraps has archived all his projects and taken up farming? Fair enough

replies(2): >>41920040 #>>41963746 #
4. diggan ◴[] No.41920040[source]
> Also, I guess dylanaraps has archived all his projects and taken up farming? Fair enough

Seems the author mostly wrote Bash (and Python) code. Makes sense that at one point they just had enough.

5. karim79 ◴[] No.41920126[source]
I'm replying because it's the first mention of Bahrain I've come across on HN. I spent the first 30 years of my life there.

Interestingly though, I've worked on similar algorithms before, some of which are in production.

replies(2): >>41920154 #>>41963769 #
6. dgfitz ◴[] No.41920154[source]
I’m hear about that country at work often, mostly people traveling back talking about all the crazy expensive cars they saw.
replies(1): >>41920246 #
7. karim79 ◴[] No.41920246{3}[source]
That would depend largely on where you're comparing it to I guess.

One reason is that fuel is extremely cheap - I thinks it's only cheaper in Saudi Arabia and Kuwait. When fuel cost is almost not a factor then it basically becomes about which fancy car is affordable.

There's a huge wealth gap out there as well, and quite a tiny population. I would highly recommend checking it out some day. It's quite an interesting little island!

replies(1): >>41920296 #
8. dgfitz ◴[] No.41920296{4}[source]
I’ve heard enough about the place that I’m not interested!
9. fullstackchris ◴[] No.41924316[source]
Fantastic stuff, this would be very useful in print art work I do.

For those further interested you see the issue this resolves by converting an full color image to an indexed image (often key colors, but low in total pixel count are neglected)

10. mandmandam ◴[] No.41924921[source]
I'll add to the chorus of how cool and interesting this is, and how potentially useful. Got a newsletter?
replies(1): >>41963788 #
11. neya ◴[] No.41963746[source]
Thanks, that looks useful. Will check it out :)
12. neya ◴[] No.41963754[source]
Thank you, I will soon :) I do have a newsletter I write about technical articles, please feel free to follow it, I may drop an article about this soon.

https://medium.com/build-ideas/newsletter

13. neya ◴[] No.41963769[source]
Thanks, I've been meaning to check out that Buddha bar I used in the picture. I have a sentimental attachment to it, being my first entry into such programming and all. I even thought about laying low in Bahrain, seems like a really cool place.
14. neya ◴[] No.41963788[source]
Yes, I do :)

https://medium.com/build-ideas/newsletter

replies(1): >>41974557 #
15. mandmandam ◴[] No.41974557{3}[source]
When do we get part 2 of the speaker saga :D

Part 1 was fantastic.