Using Konva.js to annotate image with bounding boxes

References: Konva Tutorials Konva API Docs Drawing Labels on Image with canvas HTML5 Canvas Export to High Quality Image Tutorial Resolving “Tainted canvases may not be exported” with Konva First up, a working demo below. Click on “Set image” button first. Click “Add box” button to create a new bounding box. Each time the box …

Uploading a folder via HTML form or cURL

References: Upload directory doesn’t send folder name with file Upload files with CURL Multipart formposts How to upload folder using HTML and PHP VGG Image Annotator: Issue 270 – Using Webkitdirectory to import multiple directories and maintain directory hierarchy Contents of folder to be uploaded (drawn using tree –charset unicode –dirsfirst -a -n in bash): …

Logical operators in Javascript do not always return boolean result

Given a variable myObj in Javascript, evaluating myObj.child.name || ‘Kid’ will cause an error if myObj.child does not exist. In comparison, in PHP, $myObj->child->name ?? ‘Kid’ would just yield “Kid” with no errors. One way would be to write the expression let result = (myObj && myObj.child && myObj.child.name) ? myObj.child.name : ‘Kid’;. Another way …

When an object is assigned to a variable, will modifying the variable modify the original object?

This is similar to the previous blog post except this is more direct. The answer is “Yes” for all tested languages except C and C++. This may seem trivial until you meet a situation where the same original object is shared across requests/sessions, like a public static variable in Java or an incorrectly scoped Javascript …

Does modifying objects passed in to functions modify original object?

As per title, ran this across various languages. Results are mixed, but IMHO, it seems unsafe to design your functions/methods this way. It would be better to pass in the object, compute the changes without modifying the object, return the computed changes and assign it back to the original variable. Below are sample code snippets …

Everyone Can Code

In today’s edition (Fri 04 Jul 2014) of the TODAY newspaper, there is an article in the Comment & Analysis section titled “How to teach children computer programming”. It┬ámentions that more and more countries are introducing programming, also known as coding, into their schools. This brought to mind the┬áfamous Youtube video┬áby code.org in Feb 2013, …