Think You Know CURL? Care To Prove It?

Do you happen to remember a browser-based game “You Can’t JavaScript Under Pressure”? It presented coding tasks of ever-increasing difficulty and challenged the player to complete them as quickly as possible. Inspired by that game, [Ben Cox] re-implemented it as You Can’t cURL Under Pressure!

In it, the user is challenged in their knowledge of how to use the ubiquitous curl in a variety of different ways. Perhaps this doesn’t sound terribly daunting, especially if your knowledge of curl is limited to knowing it is a command-line tool to fetch something from a web server. But curl has a staggering number of features. The man page is over 4500 lines in length. The software’s main site offers a (free) 250+ page guide on how to use curl and libcurl. Reflecting on this is exactly what led [Ben] to create his challenge.

It’s a wonderful piece of work, but things get really interesting once [Ben] starts talking about the infrastructure behind it all. At its core the game works by giving the user a problem and a virtual machine, and catching outgoing HTTP calls to see whether they look correct. If the outgoing HTTP call is the right solution for the problem, terminate the current VM and start up the next one with the next problem. He’s put a lot of work into getting suitable VMs up and running quickly, securely, and properly isolated. The code can be found on the project’s GitHub repository for those who want a closer look.

But that’s not all. [Ben] says that in the past he’s had a bad habit of presenting interactive features in his blog posts that can’t keep up with sudden demand. So to address that, the system auto-scales as needed with a small Linux cluster; small brick-sized PCs are started and shut down automatically to meet demand. Hey, the only thing cooler than a functioning cluster is a cluster doing an actual job, like this one that detects NSFW images.

5 thoughts on “Think You Know CURL? Care To Prove It?

  1. +1 for doing this using a proper VM.
    Many, many times I have produced the desired output in some testing similation, only to fail because I did not do arrive at the accepted solution exactly as the author intended.

  2. Back in the day I had a contract to respond to tickets in 4 hours day/night, before SMS or even email alerts were built into platforms. (late 90’s early 2000’s) CURL to the rescue. My job partly consisted of checking a site and responding in that window. Well what is a working stiff to do when the only way to know if you have a job is to look at a site every 4 hours, or miss out on the job.
    Enter DIFF + CURL :)
    Use CURL with user/pass & cookies etc and fetch the interesting page/s with the jobs
    Save the result in a temp spot, and compare it to the last time it fetched the page.
    IF the diff’s show a new ticket number (use SED/AWK/GREP to parse) – blip out an email to the SMS gateway of my cell phone and get a text. The message would contain the job number, contact info and a small bit about the job (what I could fit in a single text) remember when they cost money per message unit? Pop this into a cron job and sit back.

    So at the end of the day my business was able to respond to new issues in minutes. Got a lot of business this way and a lot of happy customers. Even when the contracting company changed systems it was adaptable enough to allow me to freedom to go about my day. Should a job come in I could easily respond and go to work. Today almost all platforms have some way to send notifications, email, text, etc. But kids there was a time… :)

Leave a Reply to Drone Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.