Creating a QR Code step by step
247 points by D4Ha 16 days ago | 46 comments
  • belter 16 days ago |
    The feedback he receives is quite fun: https://www.nayuki.io/page/poor-feedback-from-readers
    • redbell 16 days ago |
      Oh, I see how terrible managing a personal blog might be. You have to deal with all kinds of people. Fortunately, he also shares good/decent feedback: https://www.nayuki.io/page/decent-feedback-from-readers
    • seabass-labrax 16 days ago |
      Personally, I don't enjoy reading that as much. The commentary seems a bit reminiscent of XKCD #406, and has what I read as tinges of racism.

      The characterization of some of these senders as lazy is simply not true: I once engaged with a student who wrote like some of those examples and was trying to contribute to a FOSS project I ran; he turned out to be an excellent contributor who nobody could reasonably say was lacking in either skill or effort. It is usually just a combination of shyness and excessive respect that produces these 'lazy' requests. And, frankly, using words like 'ur' and 'thx' are how some 100% native speakers of English write. (The ever-relevant XKCD strikes again, #1414 this time.)

      I consider myself to be extremely lucky that my native language happens to be the lingua franca of the computer industry if not the world, and even luckier that I don't have any impediment such as dyslexia that would hinder me capitalizing on that good fortune to the full.

      And finally, yes, most of what one receives online is spam. Lots of spam, in fact, but when someone makes as least as much effort to contact me individually I try to make at least that much effort in return.

    • jacomoRodriguez 16 days ago |
      Sorry, Sounds more like the blog author is kind of a douche: "No, your not allowed to use my code from a GitHub repo for your university projekt chat bot: your coding standards are not up to mine. And btw. Your English sucks"
    • meiraleal 16 days ago |
      Making fun of poor english is always a sign of stupidity (smart people can be idiots).
    • ipdashc 16 days ago |
      Man, I understand that it can be annoying to get spammy messages, but a few of these are really kind of lame on the blogger's part. The sales mail, advertisement requests, and "want to sell your website" offers, sure, whatever, post and slander 'em. But a chunk of these are just genuine, polite requests for help, even if some (but not all) are sloppy or have bad grammar. There's a few that are asking for an interview or sound like they just want to be friends. There's no obligation to reply, of course, but to post them online just to mock them? That's really kind of sad, and I'm surprised the author is fine with doing it / thinks it casts them in a good light? Put all together, this is one of the most pretentious pages I've ever seen on the Internet.

      And then there's "that shameless country", "that needy country", "that unspeakable country", as others have pointed out. ... really? Yeah, we've all gotten spammy emails from Indian senders, joking about it is one thing, but that's just gross.

    • saagarjha 16 days ago |
      Generally, when you get a message from someone that you don’t like, it helps if your complaint does not include casual racism and a critique of the author’s English proficiency.
    • prab97 16 days ago |
      <rant> The commentary mocking people for their poor English, followed by disparaging remarks about an entire country as if the email senders represent a typical sample from that nation, says more about the blog owner than about the email senders themselves.

      The blog owner exudes elitist vibes in the commentary. A quick skim of the blog reveals a request for Bitcoin donations, suggesting $3 as the amount, without considering that a large portion of this donation will be eaten up by fees. </rant>

      • nindalf 15 days ago |
        Dude really doesn’t like Indians huh.

        I can see why these racists come to the conclusion that all Indians speak a certain way. If they see something written with a few quirks common to Indian English they confirm their bias that all Indians speak and write that way. If they see text without that tell, their bias is still confirmed because they conclude this person must have grown up elsewhere.

        For the racists at the back - language diverges over time. That’s perfectly normal. As the reader/listener it’s easier for us to make the effort to understand than it is for someone to change how they speak. If you’re ok with making an effort to understand unusual words and phrases used by Australian, Scottish, Irish, Kiwi people but you won’t do the same for Indian people, reflect on why you do that.

        People from NZ change most “e” sounds to “i”, so they’d eat pincakes for breakfast for example. I find that quirk endearing. Or Australians using words like ute, jaffle etc. But somehow only white English speakers are given the benefit of the doubt when they do this? Why can’t Indians get the same thing when they’re speaking their second language?

        • InsideOutSanta 15 days ago |
          "it’s easier for us to make the effort to understand than it is for someone to change how they speak"

          Not just change how they speak, but learn entirely new concepts that do not exist in their language, and that they have no intuition for. I'm currently teaching German to somebody whose native language has no tenses, no cases, mostly no plurals, essentially no genders, different phonemes, and is written in a different script.

          Having to not just learn these concepts, but be familiar enough with them to form an intuitive understanding and use them correctly in most instances, at a near-native level, is something that takes a decade or more for an adult. To be dismissive of somebody who makes that effort is pathetic.

          • nindalf 15 days ago |
            Yeah I thought we have a universal consensus that we never make fun of the way people speak English because they’re trying their best in a second or third language. And they’re doing that despite the challenges you point out.

            If someone does it, it means they’re racist. The act itself isn’t racist, but I’d bet dollars to doughnuts that they’d have other racist opinions and do racist things.

        • meiraleal 15 days ago |
          I totally agree with you. But I'm curious about one thing: how do most Indians react to Indians scamming people from all around the world? Is there a movement to push back against them or are we (the world) on our own? Same thing I wish to ask the Nigerians about the Nigeria princes.
          • nindalf 15 days ago |
            I think no one, from any country, has any sympathy for scammers. FWIW, Indians suffer plenty from the same scammers because it's possible to target Indians much more easily. You don't need to figure out international payments, accents, international calling - just pick up the phone and go.

            I would challenge the notion that a "movement" can push back against criminals. This is a law enforcement issue and a difficult one at that because law enforcement doesn't have real time insight into money transfers.

            If it is any comfort, India is a democratic country and the government is somewhat receptive to the needs of the people. With Indian people suffering from financial crime and complaining about it the government could start to crack down on it.

          • ripe 15 days ago |
            People in India suffer from these same scams, too. They are pissed.

            I haven't lived in India for decades, but saw an interesting TV show about a famous phone phishing operation run out of a small village in Bihar state. It's fiction, but based on a real news report.

            https://en.m.wikipedia.org/wiki/Jamtara_%E2%80%93_Sabka_Numb...

      • magic_hamster 15 days ago |
        There are many genuinely talented and accomplished computer scientists from and in India; however, if you are an internet personality and you are constantly bombarded with blatant requests, or even demands, which are indeed poorly written and come off as just trying to get something from you, it points to a possible culture difference. A lot of these requests come from students who are looking for shortcuts, or think that because you have code on GitHub, they are entitled to your personal support. India is a huge country, so even if a very small part of the population acts this way, it can be overwhelming and form some strong opinions on the receiving end - and this is not limited to India.
        • meiraleal 15 days ago |
          > however, if you are an internet personality and you are constantly bombarded with blatant requests, or even demands, which are indeed poorly written and come off as just trying to get something from you, it points to a possible culture difference

          Since I backpacked for 5 years, I started to have a shallow understanding of culture differences but enough to make me think that people from two or three cultures aren't really great to interact with. I keep these to myself, voicing it would say more about me than them.

    • agnishom 16 days ago |
      I understand it is annoying to receive spam, and Nayuki is under no obligation to help strangers with their code. However, how about a little empathy for the students whose cultural and education system have not taught them any better?

      In some cases, Nayuki is not even happy with people pointing out legit errors in their blog. For example,

      > I want to use the parameters [...] and > > invNTT(NTT(invec)) !=invec ?

    • nindalf 15 days ago |
      Fun for racists, sure.
      • bilekas 15 days ago |
        In what sense??

        Edit: Okay I didn't read the commentary of the author. It's an unnecessary complaint for sure.

  • redbell 16 days ago |
    A good practice is to tag the title with the year of the article (in this case, 2018), when it is not from the current year.
    • D4Ha 15 days ago |
      I agree, the original link to the post, doesnt have a date as far as i can tell, and I can't edit it anymore.
      • redbell 15 days ago |
        Although the date is included in the article, it is located at the very bottom of the page, which is unlikely to be easily found. It reads: "Last updated: 2018-11-05"
  • bb88 16 days ago |
    This is pretty awesome. I would like to see the same thing for the decoder.
    • smitelli 16 days ago |
      Same. I always marvel at how my phone can decode a badly lit, blurry, 1/4 out of frame QR code as quickly as it does.
      • bb88 15 days ago |
        My first instinct would be to go look at the discrete cosine transform that JPEG uses. But I don't know how to do the other parts like aligning and using the timing patterns.
    • kfl 15 days ago |
      Maybe you'll enjoy Piko and blinry's guide on reading QR codes without a computer: https://qr.blinry.org/
      • bb88 15 days ago |
        Yeah interesting, but not really any different than the original content. Maybe a little easier to grok.

        I was looking for algorithms to extract out a QR code from an image.

    • phoronixrly 15 days ago |
      Yeah, I've been looking for a guide to implementing qr readers from 0. Explicitly not 'oh just plug in this CV library in, feed it the image and it spits out the result' like all the stuff I find in Google on the topic.

      I am looking for a guide that walks you through implementing all the algorithms necessary after you have the decoded raw image data.

      • vrighter 15 days ago |
        find a copy of the standard. A version of it is floating online. The latest version just added some clarifications, but is not needed. I built an implementation out of that, though the error correction part, of course, I had to learn somewhere else. But the spec is very readable
  • jaza 16 days ago |
    Nice! Learning how QR codes work has been on my todo list for ages, this was a nice introduction.
  • throw0101c 16 days ago |
    Recent Veritasium video on the topic, "I used to hate QR codes. But they're actually genius":

    * https://www.youtube.com/watch?v=w5ebcowAJD8

  • slig 16 days ago |
    This resource is awesome. I wanted to have the smallest readable QR code for my printables pages footer [1], and I discovered there that it's possible to encode URLs in "Alphanumeric mode", version 1, using only uppercase characters, e.g., HTTPS://FOO.CC/ABCDEFGHIJ, so I got a three letter domain name and built the simplest URL shortener hosted on a CF worker.

    [1]: https://pdf.ahaprintables.com/pdf/preview/aha/zebra-puzzles-... (PDF)

    • davchana 16 days ago |
      Would you please share more information about it? Thanks.
      • slig 15 days ago |
        The URL shortener only use uppercase letters for the path of the URL, the domain and protocol are not case sensitive. Modern phones can read such QR code easily and identify them as URL.
  • greggman24 16 days ago |
    it's nice to have an explanation. for me, I just wanted to quickly make them. Googling led to ad covered sites and "register to use" site. Found a few on GitHub but they had other issues so threw together my own using a well designed library I'd used before. took about 15 minutes

    https://greggman.github.io/qr-code/

    might add more options but in truth I don't think most users need the options

    • D4Ha 15 days ago |
      happy you found it to be useful. I also wanted to write an implementation for sometime. The only things I could find were ready-made packages (python/Golang...etc).

      The part I'd also like to know about is error correction, if you have anything useful related to QR codes for that.

  • Timwi 16 days ago |
    Unfortunately it seems that every online explanation of QR codes always leaves out the Reed-Solomon error code calculation. The author here describes it as “long, tedious, and not very interesting”, but since everyone seems to think that, it is now very hard to find.
    • cammikebrown 16 days ago |
      There’s a Wikipedia article for it
    • steventhedev 15 days ago |
      I took a code theory course in grad school. It was the most rigorous course I took, and for all of the 5 students it was difficult, but I'm also really glad I took it.

      Reed Solomon was about two thirds of the way through the semester, and the gist is that it's based on polynomials - with enough points you can define exactly where the polynomial is - so include some extra points and that way if some get lost along the way you can recreate them.

      The rest of it is how to apply that for binary data (finite fields). Which is mathematically beautiful, but where they get somewhat complex.

    • larsbrinkhoff 15 days ago |
      • Timwi 14 days ago |
        Thank you so much! That's really helpful and enlightening.
    • amenghra 15 days ago |
      https://www.quaxio.com/an_artisanal_qr_code.html and PagedOut! Issue #2 have a qrcode from scratch including the error code calculation using long division. Enjoy!
    • vrighter 15 days ago |
      it is long, tedious, and the absolute most interesting part of it all.
  • aabiji 16 days ago |
    I built an implementation in Rust a while back:

    https://github.com/aabiji/qr

  • fforflo 16 days ago |
    Plug: Now that you know how they work, you can use them in your SQL queries too https://github.com/Florents-Tselai/pgQR