Skip to toolbar

Only the Necessary – some views of Interior design solution

Reading Time: < 1 minute

While most of my days go in a sort of digital flow, thinking of problems of quite abstract nature, I love to stop and look at the physical-environmental solutions at home.

Some of the everyday things are just “wicked” in way. For example, here’s one tough nut:

My perfection on the “siivouskomero” – place holding just the vacuum cleaner

We often stuff unnecesarily much into spaces which don’t support functionally our haphazard choices. The closet where people store the vacuum is one such place. If overstuffed even slightly, it makes the vacuum cleaner removal a noisy business: things fall out of place, followed by one’s awkward bending around the floor, collecting the fallen items.

A small but interesting detail are the support hooks on the closet: those that guide the vacuum hose into a nice, round bend, around the top, and falling back in place again. If this is improperly designed, the vacuum doesn’t “fit” well; instead, it’s crammed in the place, and the hose is left with a tension that unwinds once you open the sliding mirror doors- once again, chaos unwinds.

More to come! Stay simple. 🙂

Facebook Comments

On software testing

Reading Time: 6 minutes

No software is an island, tells a thesis. It means that practically the code we have running in computers, smartphones, and appliances rely on a lot of other code.

Sometimes implications of a small bug are big: Ariane 5 unmanned space rocket crashed due to a SW bug.

Even though there’s been a lot of improvements in technology, the fact remains that essentially computers are blind: the computer follows instructions given by a programmer.

Program code takes input from people. And sometimes people intentionally try to cheat the machine into doing things it shouldn’t. This is called many names:

  • hacking
  • cracking
  • intrusion
  • data theft
  • breaking code

Software quality is about making sure the software is as bug-free as possible, and also if something happens, the process would mitigate the possibility of exploits. In English: gracefully failing systems are better than those that leave a gap wide open, if they fail. It’s not all there is to making secure systems, but software security plays a big part. If the software is insecure, it helps an attacker a lot: they don’t need to, for example, travel to anywhere (instead attack the parts of a server via the weakest point, remotely). They don’t need to convince anyone over the phone, to make dumb things.

Often we might think a small program stays “alive” for maybe a few months. Believe me – this comes from a veteran developer: you might well see your little program live as a crucial part of a business, 10 years from now.

You never know for sure. That’s why high quality and uncompromising work ethics is crucial. You never really know how long the software will live on.

It only takes one bit in the wrong place, a capital letter where a small letter was supposed to be, or mis-interpretation of a value such as ‘undefined’ vs. “None” to make bugs.

What is shared code?

“Other code” from the viewpoint of a software developer is called:

  • software library
  • package
  • a module
  • shared code
  • extension (sometimes)
  • public code

The idea of sharing and reusing pieces of code is that thus we can elevate the level of thinking in software.

Example: searching for text inside text

A common problem to solve is checking does a piece of text occur in another piece, the source text. This is called string matching.

In trivial cases, string matching is very easy to perform. If you want to just get down to Yes / No answer, here’s the simple formula:

  • take first letter of the target string (which you want to find in source)
  • set stillNeeded to be length of target (ie: ‘cat’ => stillNeeded is 3)
  • go through source string, one letter at a time: read the next available, store in variable C
  • if target[0] == C, then decrement stillNeeded by 1
  • if stillNeeded == 0 then answer is Yes
  • if target[0] is not C, then reset stillNeeded to original length, and advance the loop to next character in source
  • if we are at last character in source, answer is No (not found)

Special cases in string matching include:

  • whether character upcase / lowercase makes a difference?
  • how to handle 16-bit Unicode characters in string matching, where there’s larger character set than ASCII’s 8-bit
  • depending on what the programming language is, certain special characters might cause extra coding needs -for example, in C language the strings themselves are “terminated” using value zero, which thus cannot be part of the strings to be compared

There’s a lot of nuances and it requires attention to get string matching algorithms right. If we had to do it every time we developed a piece of software, it would be outright insane.

Tradeoffs in using ‘other code’?

When we take a library to use in our own project, there’s a few implications that happen.

  • check license compatibility with our project
  • documentation helps using the code, a lot!
  • you need to rely on the source of the other code’s supply being stable (repository, servers)
  • have a back-up plan B: what if the library vanishes, or would not be available for use? Is it critical? Can you choose another one?
  • there should be enough people working on maintaining the other code so that you can rely it will be bug fixed, for example

I’m at times participating in the maintenance of a tool that has to do with software testing. It’s a test result reporter. The code produces XML-format chunks of data, and gives that over to a another software, a dashboarding tool. The quality dashboard relies on this “pipe”. Some of the ideas arose when I started to dig deeper into how actually our modern software is tested for high quality.

How code operates in a computer?

Some important distinctions to make first. Modern computers are made in a van Neumann architecture. That means the memory banks (RAM) can hold both code and data. It’s a technical detail, but had importance when the shift to modern van Neumann’s happened.

The main brain of your computer, CPU, runs code. Code is done by writing a source program (a listing of text), which is then compiled by another software tool. The source code is turned into some form of executable byte code. The form (syntax) depends on your computer’s make and model.

Developers have to hold a mental image of the task at hand. In code, things can be divided into hierarchies: functions, and modules.

Independence of a function

Functions are designed so that they do an understandable, self-standing piece of service: functions return a value or a structure of many values to the caller.

Related thing is functional programming. There, the whole idea of doing code is about avoiding “state”. Functional programming may become more important as we’re looking for new ways to better handle the complexity of code. Functional programming could be described as removing a lot of the fragile dependencies of individual pieces of code.

Photo by Wes Hicks on Unsplash

Functions should be written so that their actions can be carried out regardless of the situation “outside the function”.

Divide-and-conquer

Let’s take an example that clarifies the problem-solving process. The brain’s capacity to do programming is based on a few things. Mathematics is believed to be crucial to programmers, but possibly much more than abstract math, we need good nerves and a unrelenting attitude to tackle “boring problems”. Not all code is super fascinating to do.

All puzzles in developer’s daily grind can be solved, at least theoreticaly, in a very mechanical fashion. It’s called divide-and-conquer method. But this method is not easy, even though it is one that yields a solution. Using divide-and-conquer reminds a bit of the onion:

Photo by K8 on Unsplash

The craft of software development is about learning theory, applying it, and socially learning how other people solve similar problems. The craft is about learning “templates” (patterns of programming).

It’s just that sometimes we try to skip corners, and bugs happen.

What is TDD?

Test -driven development. Idea:

  • write first your test code
  • then write the actual payload code
  • when your tests turn “green”, ie pass, your code is ready
  • benefit: you won’t over-engineer the code, since you have a clear goal to fulfill

Let’s go to Software Testing

If you know, that during development, you will be making mistakes (bugs), then there’s a powerful idea: test your code!

  • test is a piece of instructions, that tells a testing software to automatically test your project’s code
  • tests call parts of the code, and see if predictable (expected) answer come back
  • correct answer makes test pass
  • a wrong answer makes test fail
  • the idea is bit obscure at first.. think like this: I can build a machine to push the levers and buttons of another machine
  • a test is very simple code, that is for certain correct
  • this test code is run automatically on (against) your real code
  • you will get test results indicating how many % of the test suite “passed”
  • for future, now you have also guarded your own code, against unintentional changes: you’ll see immediately if you (or someone else in the team) tampers with your code in a way the breaks it

What are drawbacks in software testing?

  • you have to write test code (takes time)
  • tests have to follow your code base – if you make new features, ie. knowingly decide to change existing code, the test suite must also be altered
  • writing effective and proper test code is a skill in itself
  • it’s easy to write huge amounts of tests that don’t do anything useful (missing the target)
  • psychologically developers are prone to making new endeavours, instead of delving in mundane testing

Facebook Comments

IL-6 related insight from COVID research

Reading Time: 2 minutes

Some layman-understandable news about the coronavirus, worth reading: a research paper shows the role of interleukins in determining the depth (gravity, danger) of illness from the coronavirus for an individual.

High existing pre-infection levels of IL-6 (interleukin six) predict high probability of getting severe form of the COVID disease.

Normal course of immune reaction

When a human body encounters pathogens (viruses), the reaction consists roughly of four stages:

  • identification of an attack
  • alerting the body via signaling
  • mechanisms that enable the body to attack a pathogen, by activating the apppropriate repertoire of defense (might be T-cells, antibodies)
  • after the pathogen is no longer present in dangerous levels, the immune system shall cease to attack – otherwise the prolonged attack could be harmful to the body itself

For example; when we get a common flu, the stuff running out of our noses is a combination of the pathogen and defense cels from the battlefield. This is part of clearance: our body is getting rid of the attacker by debilitating the structures of the attacking cells (or hindering the capability of the virus to spread further).

With current coronavirus pandemic, what is different is that some people get very ill, once they have caught the coronavirus. This aspect (along with possibly the fact that our immune system doesn’t develop a proper “memory”, ie. immunity to the new coronavirus) is what makes the new virus dangerous.

Interleukins mediate cellular signaling. They are small proteins, present in circulation (blood). Interleukins are not capable of crossing inside into a cell, but instead act through the cell surface receptors. Elevated levels of IL-6 were associated with severe form of COVID illness.

Seems that quite simply said, IL-6 is somehow the “strength of alarm clock” that the Sars-CoV-2 coronavirus sends the body. Higher levels of IL-6 make a severe counterattack from body, which is presented as the severe form of COVID illness.

Signaling means that a cell’s nucleus receives information from the outside world. This information determines partially how the cell changes its course of action.

Facebook Comments

Joy of XML with proper tools

Reading Time: 2 minutes

I was doing a recruit platform, in Java, and within there I was currently writing the spec and mechanism for format definition file for IT Skills.

Then I came upon our good old friend XML and it’s companion, the grammar definition XSD (XML Schema definition). These two have a relationship: Since XML files in general must be validly constructed (not “broken”), the validation happens by checking programmatically a XML file against the rules in a XSD file.

The XSD itself is also a language, and it’s quite flexible: you can write your own custom grammars to validate XML against. So a question arises: How is XSD defined, then?

Just enough down the rabbit hole: XSD structure

Photo by Kyle Barr on Unsplash

I’d first written just a text file, ad hoc, about some of the learning I needed to do.

The file had tags, sure, but grammar was not yet there. In order to make the writing easier, it’s useful to have autocompletion in the text editor.

Needs so far:

  • valid XML
  • schema for XML captured as a XSD
  • a validator tool for XML – takes XSD, XML -> shows results
  • editor’s autocomplete mechanism for writing compliant XML
Photo by XPS on Unsplash

Facebook Comments

Setup R for experimenting with algotrading on Windows 10 (part 1)

Reading Time: 2 minutes

Quantmod library is one of my first darlings in the exploratory experiments that I did for quantitative finance. I’d previously read about algotrading and all, but what sparked my interest really further were two things:

Photo by Priscilla Du Preez on Unsplash
  • VPRO documents on quantitative finance (Youtube)
  • especially the VPRO doc ‘The Alchemists of Wall Street
  • availability and ease of use of R and RStudio

I wanted to put my hands in the ‘savi’ (kädet saveen!) as Finns say. Pop your hood open and start meddling with things. Experimentation is the only thing that carries any digital trade forward.

Photo by SwapnIl Dwivedi on Unsplash

What is needed on Windows 10 to run R programs?

R is an interpreter, and it’s also a runtime. If you already have R installed, skip to next part!

Quick rundown of R tools

R is quite simple. Take a look at the folder and file structure:

C:\Program Files\R>dir /s /b R*.exe
C:\Program Files\R\R-4.0.2\bin\R.exe
C:\Program Files\R\R-4.0.2\bin\Rscript.exe
C:\Program Files\R\R-4.0.2\bin\i386\R.exe
C:\Program Files\R\R-4.0.2\bin\i386\Rcmd.exe
C:\Program Files\R\R-4.0.2\bin\i386\Rfe.exe
C:\Program Files\R\R-4.0.2\bin\i386\Rgui.exe
C:\Program Files\R\R-4.0.2\bin\i386\Rscript.exe
C:\Program Files\R\R-4.0.2\bin\i386\RSetReg.exe
C:\Program Files\R\R-4.0.2\bin\i386\Rterm.exe
C:\Program Files\R\R-4.0.2\bin\x64\R.exe
C:\Program Files\R\R-4.0.2\bin\x64\Rcmd.exe
C:\Program Files\R\R-4.0.2\bin\x64\Rfe.exe
C:\Program Files\R\R-4.0.2\bin\x64\Rgui.exe
C:\Program Files\R\R-4.0.2\bin\x64\Rscript.exe
C:\Program Files\R\R-4.0.2\bin\x64\RSetReg.exe
C:\Program Files\R\R-4.0.2\bin\x64\Rterm.exe

The main work horse you will be working with is ‘R.exe’

Naturally the R software installer also automatically sets up .dll libraries and does some registry keys for making sure R environment is properly set up, but you don’t usually need to do anything manually regarding these.

Photo by Todd Quackenbush on Unsplash
Facebook Comments

Boids – beautiful simulation of natural followers using an old algorithm

Reading Time: < 1 minute

Boids – a log of Learning Java EE 7 / 8

Photo by Salmen Bejaoui on Unsplash

Plan multithreading for the boid calculation

  • definition of “one round”
  • parallelism explained
  • shadow values (a copy of locations before calculation)
  • using shadow values the execution (order of picking a boid) from mesh does not matter
  • shadow buffer makes the calculations virtually as if they were done in “natural way”: all at once
  • opposite of using shadow buffer would be calculating the boids updates serially; thus the fresh-in, inter-round position of a boid would be used for all other members’ calculations; thus ordering of calculation would have an effect on the resulting positions (a externally introduced flaw, sort of order bias)
Facebook Comments

Automating software installs on Windows 10

Reading Time: 2 minutes

So, after a semi-catastrophy on my laptop, which was caused by me just jumping the gun on getting rid of ads by Acronis (backup software), I’m writing a software to ease and automate the post-bare-metal state.

Photo by Christopher Ott on Unsplash

In English, that means installation of all those software that you had on your laptop, but never actually gave them two cents of thought.

Simple idea.. loop

Think about what installation is all about? Sure. Sounds easy:

  • download the installer file
  • hash-check file in order to know integrity (safety)
  • run it
  • ta-daa!

On surface level it’s really easy. But if you stop imagining the typical installation of software, you’ll quickly remember that there are a few caveats:

  • accepting EULA or similar license dialog (keyboard/mouse)
  • choosing configuration options during installation wizard
  • confirming final options before installation starts
  • knowing when the installation wizard has finished, since Windows can’t run many installation in parallel. The previous has to end before next install can begin

You just need a file; proper user that has privilege to install new software, and a way to authenticate the file is legit and doesn’t contain malware.

So we could write a software to just programmatically drive required tools to install all the needed software. Magic. Wish all programming was this easy. Getting back to this!

Some details of getting installs right on Windows 10

Windows software installers come in a few forms:

  • .exe files
  • MSI files
  • newer MSIX – one thing I need to research a bit
  • good old .zip files

For our purposes, we are only interested in a few specific aspects:

  • is the installation file executable per se
  • if not, what are the minimal prerequisites (dependencies) needed to run file?

Does zip file cause difficulties?

Many installers come as a zip. Zip is a lempel-ziev compressed file. The repetion of consecutive identical bytes has been omitted, and there’s a few extra tricks that make the file size even smaller. If you want to know more of the theory of zip, look at wikipedia: Lempel-Ziv compression.

The problem we might encounter with zip and authenticating has to do with whether the zip can ‘cloak’ content.

This turns out not to be a problem: a hash of zip file is as good as hash of any other content – despite there’s internal structure in the file; a good hash algorithm has a property (preimage resistance) that ensures only two identically same collections of ordered bytes give out the same hash value.

I’m putting my hands down on code, and come up with the results within a couple of weeks. Hopefully! 🙂

Happy coding!

Facebook Comments

Of cleaning

Reading Time: < 1 minute

Crumbs of bread, a bit of flour. Cleaning the house is sometimes more than “just doing”. For me, it’s at its best also a great time to have a moment for thoughts on improving the design of interior.

I’m pretty visual person. Sometimes there’s immense beauty in settings like depicted here. It’s the kitchen drawer. Along a magazine I really enjoy setting my eyes on, and flipping page after page, glancing at designs, immersing myself in the feast of ideas.

Facebook Comments

Windows batch scripting basics in 2020

Reading Time: < 1 minute

Hey, imagine that you open your computer’s shell. And then you write a command. Question: What happens? And what was maybe supposed to happen?

Computers are known to be quite fragile.

More than physically wearing out or actually “breaking” a computer, you’re likely to possibly mess things up a bit. Messing happens often by:

  • typo in command (a spell error)
  • running wrong command
  • running a command that was given by someone intentionally, in an attempt to fool you
  • running a bad command – that you saw on a web page

Don’t worry. Let’s supercharge you with knowledge on these commands and the shell!

use ‘which’ in cmd

Check what your command would do, beforehand.

With shell, we can always use where command

What is a computer shell?

A shell is just another program. It’s written to take in commands, and do stuff. Shells are convenient and powerful tools. They are operated by writing commands.

Shell scripts can in addition run anything that you can write interactively, plus scripts have a few extra powerful things:

  • IF statements (allows you to make logic)
  • loop structures (run thousands of things at once, fast)
  • variables (make complex things possible)

Try the shell commands

A command looks like this:

echo Hi!

Let’s try the “echo” command in an actual Windows shell.

In Windows, first open a shell:

  • press Alt+R
  • enter ‘cmd‘ in the box
  • press enter

Now you should see a rather black and dull looking shell window. Write, using keyboard, ‘echo Hi!’, and press Enter. So just write the text e,c,h,o and space and then capital H and i followed by exclamation character (Shift+1).

The shell says back Hi!

You have used an internal shell command on Windows. See you soon!

Facebook Comments