Advent of Code: a great way for coders to celebrate this season

You’ve likely heard of Advent, but have you heard of Advent of Code? Well let the maker of the site, Advent of Code 2023, explain what it is:

Hi! I’m Eric Wastl. I make Advent of Code. I hope you like it! I also made Vanilla JS, PHP Sadness, and lots of other things. You can find me on Twitter, Mastodon, and GitHub. Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as interview prep, company training, university coursework, practice problems, a speed contest, or to challenge each other. You don’t need a computer science background to participate – just a little programming knowledge and some problem solving skills will get you pretty far. Nor do you need a fancy computer; every problem has a solution that completes in at most 15 seconds on ten-year-old hardware.

It seems like just the thing for coders of all kinds, from amateurs to professional devs. Check it out. And if you want to get involved from day 1 in 2024, make a note on your calendar (assuming Eric still does it.)

I asked ChatGPT to do my job and write some code to built out some cloud infrastructure. How did it go?

For fun I decide to see if I am ready to be replaced with AI via ChatGPT. Part of my work is building cloud based infrastructure using a language called HCL from Hashicorp using a tool called Terraform. You write one or more program files using HCL, run it through Terraform, and voila, you have the infrastructure you need.

For this exercise I entered the following prompt:

Create a terraform file for IBM cloud that will provision a VPC, set up networking for the VPC, and provision a virtual server for VPC. It will have 1 security group and a rule for this security group to allow SSH connection to your virtual server instance, 1 subnet to enable networking in your VPC, 1 VPC virtual server instance and 1 floating IP address that you use to access your VPC virtual server instance over the public network.

A good prompt, I thought. Nothing vague or conflicting. Practically a form of code itself.

I was shocked when in a few seconds I got this response:

To provision a VPC, networking, and a virtual server with a security group and a floating IP address on IBM Cloud, you can use the following Terraform configuration file:

# Configure the IBM provider
provider “ibm” {
generation = 2
region = “us-south”
}# Create a VPC
resource “ibm_is_vpc” “vpc” {
name = “my-vpc”
address_prefix_management = “auto”
}
# Create a subnet in the VPC
resource “ibm_is_subnet” “subnet” {
name = “my-subnet”
vpc = ibm_is_vpc.vpc.id
ipv4_cidr_block = “10.240.0.0/24”
}
# Create a security group
resource “ibm_is_security_group” “security_group” {
name = “my-security-group”
vpc = ibm_is_vpc.vpc.id
description = “Allow SSH inbound traffic”
}
# Add an SSH rule to the security group
resource “ibm_is_security_group_rule” “ssh_rule” {
security_group = ibm_is_security_group.security_group.id
direction = “inbound”
protocol = “tcp”
port_min = 22
port_max = 22
remote = “0.0.0.0/0”
}
# Create a virtual server instance in the subnet
resource “ibm_is_instance” “instance” {
name = “my-instance”
image = “ibm-centos-7-10-minimal-amd64-2”
profile = “bx2-2×8”
primary_network_interface {
subnet = ibm_is_subnet.subnet.id
}
vpc = ibm_is_vpc.vpc.id
security_groups = [ibm_is_security_group.security_group.id]
}
# Create a floating IP address
resource “ibm_is_floating_ip” “floating_ip” {
name = “my-floating-ip”
}
# Associate the floating IP address with the virtual server instance
resource “ibm_is_floating_ip_attachment” “attachment” {
floating_ip = ibm_is_floating_ip.floating_ip.address
instance = ibm_is_instance.instance.id
}

Before running the above code, replace with your IBM Cloud API key and and with the appropriate values for your IBM Cloud region and availability zone.
Once you have saved this configuration file, you can initialize Terraform by running terraform init, and then create the resources by running terraform apply. After a few minutes, Terraform will create the VPC, subnet, security group, virtual server, and floating IP address. You can then use the floating IP address to SSH into your virtual server instance over the public network.

Wow! What an amazing response, I thought!  It was quick, detailed, seemingly knowledgeable. Also…wrong.

There was so much fundamentally wrong with the code that the only way to get it to work was to rewrite much of it and also add a bunch of new code to make it work. I can’t even tell you how it came up with some of the statements: they are not defined that way for Terraform specs for IBM Cloud.

I even had the AI regenerate the code to see if it could get it right the second time. Instead the new code had 9 errors in it.

Fine. My manager provided me with a prompt of his own: see if it will work on AWS. (Good prompt, Ted!)

I did try it on AWS and Azure. With Azure the response was an incomplete script. (At least the IBM script was complete, though wrong.) With AWS the script was better. I could enter terraform plan and terraform thought it looked good. But once I entered terraform apply to build the resources, it failed.

I suspect the larger problem is lack of sufficient overlapping data for the AI tools to train on. So it sort of gets the code right, but sort of isn’t really good enough.

I see people on the Internet raving about how well AI is doing writing code. Some of the examples are interesting, but I think it has a way to go. I’ll stick to doing my day job. Without AI to help. 🙂

 

The history of people asking: is technology X going to replace programmers?

Recently Nature (of all publications) asked the clickbait-y question:
Are ChatGPT and AlphaCode going to replace programmers?  It then quickly states: “OpenAI and DeepMind systems can now produce meaningful lines of code, but software engineers shouldn’t switch careers quite yet.” Then why even ask the question? It goes on to say: Deepmind, a part of Google, “published its results in Science, showing that AlphaCode beat about half of humans at code competitions”.

Regardless of what you think about that article in Nature, here’s the thing to always keep in mind: technology X has been coming along to replace programmers forever.  We had machine code that was replaced with assembler language. We had Assembler language replaced with higher level languages like Fortran. We had a wealth of more sophisticated programming languages come on to the scene. In addition, programming tools like IDEs have come along to save the day and make programming easier for programmers. Yet we still have not lost the need for programmers to write programs.

Programming is still about taking what people want the computer to do and codifying it in a language that the computer understands. In other words: programming. As long as that code is required for computers to do what humans want, there will always be programmers.

Here’s another thing to consider: code is a more efficient way to communicate to a computer. I can write in English “count all the entries in this column from row 2 to 100 if the entry equals the word ‘arts'” or I can write in (Excel) code “=countif(A2:A100,”arts”)”. That efficiency will likely mean that coding will be around for quite some time yet. And people doing that coding will be programming, even if they don’t consider themselves programmers.

So no, Alphacode is not going to replace programmers and programming. It might replace some of the task of what some of them currently do. But programmers and programming will be around for some time to come.

(I like the image above because it captures how the software design and development process is a complex thing, and not just a matter of writing a bunch of code. A lot of thought goes into developing something like a smart phone application, and that thought results in code that results in a good app.)

If you are writing a bash script to call a curl command and you want to pass variable values to it, read this…

CodingImage
If you are writing a bash script to call a curl command and you want to pass variable values to it, you may find a hard time determining how to go about it. I did!! I consulting with lots of pages, and nothing seemed to tell me what I want.

Here’s what I eventually did.

Take this example. I am using curl to call the sendgrid API, as you can see below. (I don’t have all the variables, but they were all strings like THESUBJECT and THECONTENT.).

The trick is in the use of single and double quotes. For the variables, they are in double quotes. But notice the use of single and double quotes in the curl command:


TOYOU="noone@gmail.com"
THESUBJECT="once again!"
THECONTENT="Looks good!"
curl --request POST --url https://api.sendgrid.com/v3/mail/send \
--header 'Authorization: Bearer '$AUTH_TOKEN \
-H 'Content-Type: application/json' \
--data '{"personalizations": [{"to": [{"email": '\"$TOYOU\"'}]}],"from": {"email": '\"$FROMME\"'}, "subject": '\""$THESUBJECT"\"', "content": [{"type": "text/plain", "value": '\""$THECONTENT"\"' }]}'

Let’s look at the variables in that curl command.

$AUTH_TOKEN has no quotes around it. In fact, it is up against a single quote on its left. That single quote ends the string Authorization: Bearer and let’s the script fill in the value of $AUTH_TOKEN.

Now look at $TOYOU AND $FROMME. Both of those variables have no blanks in them. So there is a single quote-slash-double quote on the left and a slash-double quote-single quote to the right.

that is different than $THESUBJECT and $THECONTENT. Those strings have blanks in them. For them, there is a single quote-slash-double quote-double quote to the left of them and a double quote-slash-double quote-single quote to the right.

It’s crazy but true. Good luck with it!

(Photo by Shahadat Rahman on Unsplash )

What I find interesting in tech, April 2021. Now with Quantum Computing inside!

Here’s 9000 links* on things I have found interesting in tech in the last while. There’s stuff on IT Architecture, cloud, storage, AIX/Unix, Open Shift, Pico, code, nocode, lowcode, glitch. Also fun stuff, contrarian stuff, nostalgic stuff. So much stuff. Good stuff! Stuff I have been saving away here and there.

On IT Architecture: I love a good reference architecture. Here’s one from an IBM colleague. If you need some cloud adoption patterns when doing IT architecture, read this. Here’s a tool to help architects design IBM Cloud architectures. Like it. Here’s some more tools to do IBM Cloud Architecture. Architectural Decision documentation is a key to being a good IT architect. Here’s some guidance on how to capture ADs. This is also good on
ADs I liked this:some good thoughts on software architecture.

Here’s some thoughts from a leading IT architect in IBM, Shahir Daya. He has a number of good published pieces including this and this.

One of my favorite artifacts as an architect is a good system context diagram. Read about it here. Finally, here’s a piece on UML that I liked.

Cloud: If you want to get started in cloud, read this on starting small. If you are worried about how much cloud can cost, then this is good. Here’s how to connect you site to others using VPN (good for GCP and AWS). A great piece on how the BBC has gone all in on serverless.. For fans of blue green deployments, read this. A good primer on liveness and readiness probes. Want to build you own serverless site? Go here

Storage: I’ve had to do some work recently regarding cloud storage. Here’s a
good tool to help you with storage pricing (for all cloud platforms). Here’s a link to help you with what IBM Cloud storage will cost. If you want to learn more about IBM Object storage go there. If you want to learn about the different type of storage, click here and here.

AIX/Unix: Not for everyone, but here is a good Linux command handbook. And here is a guide to move an AIX LPAR from one server to another. I recommend everyone who use any form of Unix, including MacOS, read
this. That’s a good guide to awk, sed and jq.

Open Shift:  If you want to learn more about Open Shift, this is a good intro. This is a good tutorial on deploying a simple app to Open Shift. If you want to try Open Shift, go here.

Raspberry Pi Pico:  If you have the new Pico, you can learn to set it up here.
Here’s some more intros to it. Also here. Good stuff. Also good is this if you want to add ethernet to a Raspberry Pi pico.

On Networking: If you want to know more about networking you want to read this, this and this. Also this. Trust me.

Code: Some good coding articles. How to process RSS using python. How to be a more efficient python programmer. Or why you should use LISP. To do NLP with Prolog the way IBM Watson did, check this out. If you want to make a web app using python and Flask, go here. If you need some python code to walk through all files within the folder and subfolders and get list of all files that are duplicates then you want this. Here’s how to set up your new MacBook for coding. Here’s a good piece on when SQL Isn’t the Right Answer

Glitch: I know people who are big fans of Glitch.com. If you want to see it’s coolness in action, check. out this and this

No Code Low Code: If you want to read some good no-code/low-code stuff to talk to other APIs, then check out this, this, and this.

Bookmarking tool: If you want to make your own bookmarking tool, read
this, this and this. I got into this because despite my best efforts to use the API of Pocket, I couldn’t get it to work. Read this and see if you get further.

Other things to learn: If you want to learn some C, check out this. AI? Read this Open Shift? Scan this. What about JQuery? Read this or that Bootstrap. this or this piece. Serverless? this looks fun. PouchDB? this and this. Express for Node? this. To use ansible to set up WordPress on Lamp with Ubuntu, go over this. To mount an NFTS mount on a Mac, see this. Here’s how to do a Headless Raspberry Pi Setup with Raspbian Stretch

Also Fun: a Dog API. Yep. Here is CSS to make your website look like Windows 98. A very cool RegEx Cheatsheet mug.. And sure, you can run your VMs in Minecraft if you go and read this. If you want to read something funny about the types of people on an IT project, you definitely want this.

Contrarian stuff: Here are some contrarian tech essays I wanted to argue against, but life is too short. Code is law. Nope. Tech debt doesn’t exist.Bzzzt. Wrong. Don’t teach your kids to code. Whatever dude. Use ML to turn 5K into 200K. Ok. Sure.

Meanwhile: Back to earth, if you want to use bluetooth tech with your IOT projects, check out this, this, this, and this. If you have an old Intel on a stick computer and want to upgrade it (I do), you want this. If you want to run a start up script on a raspberry pi using crontab, read this If you want to use Google Gauge Charts on your web site, then read this and this.

Nostalgia: OS/2 Warp back in the 90s was cool. Read all about it
here.Think ML is new? Read about Machine Learning in 1951
here. This is a good piece on Xerox Parc. Here is some weird history on FAT32. And wow, here is the source code for CP/67/CMS. And I enjoyed this on Margaret Hamilton.

Finally: Here are IBM’s design principles to combat domestic abuse. Here is how and why to start building useful real world-software with no experience. Lastly, the interesting history of the wrt54g router

(* Sorry there was less than 9000 links. Also no quantum computing inside this time. Soon!)

Installing SonarQube on CentOS/RHEL

The following webpage has detailed instructions for installing and configuring SonarQube on a RHEL/CentOS 7 Linux server (real or virtual) and it was one of the best guides I’ve seen (and I’ve reviewed half a dozen):

The webpage  outlines how to update your Linux server, how to install MySQL (as a data repository) on it, and how to then install SonarQube software on the server.

Some things to note. First, this procedures has you using wget to get v6.0 of SonarQube:

Check out the page https://www.sonarqube.org/downloads/ and see the latest version of SonarQube (e.g. 6.4) and replace “sonarqube-6.0.zip” with the latest version (e.g. “sonarqub-6.4.zip”.)

One important thing to note: this procedure creates a userid and database called sonarqube.

Later in the process, the changes made to /opt/sonarqube/conf/sonar.properties needs to match this:

sonar.jdbc.username=sonarqube                                   sonar.jdbc.password=password
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonarqube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

If the userid, password and database you created in MySQL do not match what it is the sonar.properties file, you will see cannot connect to the database errors in the /opt/sonarqube/logs/web.log file and SonarQube will not come up.

Once you enter: sudo ./sonar.sh start

Get the IP address of the SonarQube server and then go to a browser and enter:

My mixed bag of IT links for December

Like previous collections of IT links, this collection reflects things I am interested in or found useful recently:

  1. If you want to get started using APIs, I recommend this: Most Popular APIs Used at Hackathons | ProgrammableWeb
  2. If you want to build that web site, consider Using Twitter Bootstrap with Node.js, Express and Jade – Andrea Grandi, and this Building a Website from Scratch with ExpressJS and Bootstrap | Codementor. Also Mastering MEAN: Introducing the MEAN stack and Bluemix Mobile, Part 1: Creating a Store Catalog application – Bluemix Blog
  3. Or develop a mobile app like this: Create Swift mobile apps with IBM Watson services – developerWorks Courses
  4. I am a fan of Bluemix and Eclipse. This article ties them nicely together: IBM Bluemix – Eclipse Package Download – Neon release.
  5. I am also a fan of IoT these days. For fellow IoT fans, these links are good: Intro to Hardware Hacking on the Arduino — Julia H Grace and $10 DIY Wifi Smart Button | SimpleIOThings.
  6. Speaking of IoT, if you have been doing some work with Arduinos, you might be interested in the ESP8266. Some good info on it here ESP8266 Thing Hookup Guide – learn.sparkfun.com and a good thing to do with it, here: SimpleIOThings | Simple Do-It-Yourself Internet-of-Things Projects
  7. More good links related to software and application development work here Migrate an app from Heroku to Bluemix and here A Concise Introduction To Prolog, plus Building without an Ounce of Code – Part 2 – Apps Without Code Blog and this Turning a form element into JSON and submiting it via jQuery – Developer Drive
  8. Some interesting links pertaining to Minecraft: Can Minecraft teach kids how to code? – Safari Blog and Minecraft and Bluemix, Part 1: Running Minecraft servers within Docker.
  9. There’s lots of talk about AI these days, the  Economist explains why artificial intelligence is enjoying a renaissance
  10. If you are interesting in working in IT, you might like this: How to Get a Job In Deep Learning or this: An Unconventional Guide for Getting a Software Engineering Job — Julia H Grace
  11. Or maybe you want start a start-up. If so, check this out: A Free Course from Y Combinator Taught at Stanford | Open Culture
  12. Finally, here are just a number of interesting but mostly unrelated links:
    1. IBM Blockchain 101: Quick-start guide for developers
    2. Building three-tier architectures with security groups | AWS Blog
    3. Performance Tuning Apache and MySQL for Drupal
    4. How to secure an Ubuntu 16.04 LTS server 
    5. Clean Your System and Free Disk Space | BleachBit
    6. Use an iPad as a Raspberry Pi display — Kano OS – YouTube
    7. (Software iSCSI) Configuring SAN boot on Red Hat Enterprise Linux 5 or 6 series

 

ICYMI: What is code, by Paul Ford

Happy Monday! Are you affected by code at work? Of course you are! Do you code at work yourself? Very likely, even if it is to use formulae in a spreadsheet program like Excel (which, years ago, would have required been considered coding). However code affects you, I highly recommend you read this:
Code. It’s a very rich piece on code (i.e. software) and what it means to you (and everyone else).

Among other things, it is brilliantly designed. Lots of hard work went into this piece. If you can’t get started yet this week at work, read this as a research project.

Are you trying to learn to code? Are you finding it difficult?

It’s likely not you. As this piece argues, Learnable Programming, there are limits to the approaches that online sites have which many can get by, but some cannot. If you are in the latter group, give this piece a read. Afterwards you might think: aha! That’s why I couldn’t get it!

With technology, if you don’t understand something, don’t assume the problem lies with you. It may, but most of the time, the problem lies with the technology.

A return to Twitter (not the service, but the community)

After the frustration with the Twitter service for changes like this, I thought I would give up Twitter. However, Twitter is the sum of a number of parts: there is the service that Twitter provides, from the backend servers to the APIs to the user interfaces and client software you use;  and then there are the people that contribute to Twitter. Among those contributors are people I really enjoy socializing with whom I cannot connect with any other way. To give up all of Twitter means tossing out the baby, the bathwater and even the tub itself. That’s dumb. (I do dumb things often, but typically correct most of them in time. :))

To get around that, I decided to use my limited software skills and the APIs that Twitter provides to write my own Twitter client, in a way. It is a hack, but it is a good hack (for me). I am able to control what I see this way. Not only do I not have promoted tweets, etc., in my feed, but I am able to get rid of things like RTs from everyone, rather than having to turn of RTs one at a time. I’m also able to save all the tweets in a spreadsheet or some other format, so I can look at them when I am less busy, or decide on other filters I want to apply, etc. Later on I can write more filters so if a trending topic gets to be too much, I can just delete it or save it to a different file for later.

Now my Twitter experience is gone from poor to great (for me).  I have thrown out the dirty bath water, but kept the tub and the baby. This makes more sense, obviously.

Last but not least, I appreciate all the people who expressed concern over my leaving Twitter. It was very kind of you, and why I want to stick around, if I can.