Tuesday, October 09, 2018

Simple login demo with NodeJS

I wrote a simple / bare bones login demo with NodeJS. It uses cookies to remember the user. Note that this is the absolute minimum and should not be used in applications requiring security.

Note that in login.html we have to use HTTP POST (not GET. This line in login.html: form action="/login" method="post" ) so that user name and pass is not displayed in browser address bar!

Saturday, September 29, 2018

Modifying Toys

As a hobby, I like playing with Arduinos and having the ability to control real world devices like sensors and motors. Recently I decided to add a Cylon/KITT eye to my son's old robot toy:


First I bought an Arduino Pro Micro and an addressable LED strip. I cut the LED strip to fit into the robot's head, wrote a sketch to simulate Cylon eye and tested the setup:


Then I made sure that it worked with 3 AA batteries:


Then I squeezed in the LED strip into the robot's head and tested once more:


Then I verified that it worked with the robot's batteries:


Finally I assembled the whole robot:


The hardest part was fitting the pro micro and all the extra cables into the robot's body.

What's the point of all of this you ask? First of all, I like doing such things. And secondly... Watch Eli's video: The Value of "Hobbies" for Tech Professionals.

Monday, September 17, 2018

Binary search tree height

As part of HackerRank 30 Days of Code Challenge, I solved the binsary search tree height problem (day 22). My solution is not the most efficient/prettiest solution but it is mine (!):

Tuesday, September 04, 2018

Building a NetBeans java project without installing NetBeans

NetBeans projects that use the Layout class require swing-layout.jar, otherwise you will get the error message "package org.jdesktop.layout does not exist". To build a NetBeans project on a computer without installing NetBeans, you have to copy the swing-layout.jar and add the following to project.properties:
file.references.swing-layout.jar = <path of jar>
java.classpath =
    ${libs.swing-layout.classpath}:\
    ${file.reference.swing-layout.jar}

Also make sure that there are no trailing spaces, especially in the java.classpath section. And finally keep the build-impl.xml file.

Friday, August 31, 2018

Software time estimation

Software project time and effort estimation is difficult. One of the difficulties arise from writing low quality components. These components incur technical debt (or they might just be a mess), break the system at a later time when no one remembers their details, and require frequent revisits. Poor components are usually difficult to understand too. All this results in a lot of unbudgeted effort and delays. Even if you estimated the time for completing the messy version of the component, you would not be able to take into account the additional cost required to get to a clean/stable version.

The corollary is that you have to focus on quality before you spend any time on schedule estimation. To achieve acceptable quality, write unit tests, do code reviews (and at least rudimentary algorithm documentation) and use static analysis tools. Only after you have unit tests, documentation, code reviews and static analysis in place, you might try to guess when the project finishes.

Tuesday, August 28, 2018

Child education

Today we were talking with friends about our favourite topic, education of children. The gist of the conversation was that parents have limited control over their children and can "only" introduce them to different experiences. I criticized the use of the word "only" because a good introduction is not a trivial thing, it requires a lot of thought on the parent's part. The material has to match the child's ability to grasp and find it interesting enough to pursue it further on his/her own.

Examples:
  • Experience foreign languages via computer games, songs, movies and trips abroad.
  • Musical instruments. I played the guitar and keyboard in my younger years and know that playing an instrument is not a matter of talent but a matter of persistent work, i.e. not suitable for most young kids. Talent comes into play when one strives to be a professional.
  • Math, history, politics... All of these are extremely interesting but the wrong teacher can cause the child to be disgusted and block them out completely. I know people who refused math or history until they were 30 years old and found out that these were actually quite fun.
  • Sports, dance and other physical activities: See The Inner Game of Tennis
The first rule of a good introduction for any topic: What good is this for, where is it used? Keep in mind that even if your child is not immediately enthusiastic about the subject, he/she will have it imprinted in his/her mind and when the time comes, will have less difficulty in making that first attempt (which is usually the hardest psychlogically). Example: As a young child I observed how my father (a primary school teacher) was writing with beautiful hand writing his normally boring daily classroom plans. To this day, I like to write nicely. We don't want our kids to realize how everything is so mind blowing until they are adults, do we?