Thursday, March 15, 2018

A.I.C.O. Incarnation - typical Japanese anime

Unfortunately, being typical is not a good thing. All characters in A.I.C.O. Incarnation are manga clichés and the few interesting sci-fi ideas are obliterated by the lack of courage in showing body horror and the obvious gaps in logic. The most promising, yet underdelivered concept is that of consciousness and identity. What would happen if brains and bodies were swapped, changed, mingled, etc. This could have been great if each episode explored some way the "malignant matter" affected biology and consciousness, but in truth, less than half of an episode really approaches the idea.

In short, the story follows a group of "Divers" who go into a biological infested area in order to stop said infestation and save people. They have to battle amorphous blob like monsters and government officials and mad scientists to get to their goal. Obviously they are all young and rash and falling in love and trying to protect people and making honor bound promises and so on. It was so by the book that it became nauseating. I think a heavily cut video edit of the first and last two episodes would more than cover the entire series.

It is good that Netflix is paying for more anime adaptations, but this one is not that worthwhile. Still 29 to go, though :) Here is a trailer, if you are still interested:

Monday, March 12, 2018

Boku dake ga Inai Machi (Erased) - an interesting, if kind of predictable, anime

The main character and the girl he saves Literally translating to "The town where only I am missing", Boku dake ga Inai Machi presents (what else?) a manga artist with no life or future who finds out he can transfer his consciousness in the past, fixing things that went wrong. Of course, the worse thing that ever happened to him was living through a killer's series of murders of some of his school classmates. Another traumatic experience makes him, now 29 years old, transfer his consciousness in the past, during his childhood years, and determined to find and stop the killer.

Now, this might not seem particularly captivating, only the solution for saving the children is not to investigate clues or stake out locations or alert adults, but using the tools a mere child has: making friends, being around the lonely people the killer seems to target. This has an impact on the man's life, but also on that of the people around. In the end, it's a call to end self alienation by connecting and doing good things to people close to you. The title is a metaphor to the impact a person has on their environment. What if you never were? Would things change? The English title - Erased - is the one licensed for the US market and has little to do with the plot.

The anime is nicely drawn, if not spectacular, the Japanisms are pretty common, the story is sort of predictable, so the only true positive thing about the show is the mood and moral. I can't recommend it to everybody, but I personally enjoyed it. It has just 12 episodes and so it's like 4 hours in total. Here is a trailer:

Saturday, March 10, 2018

Working on npm packages within other npm packages

Update: the initial article was plaing wrong :) I fixed it now. The important change is that you need to npm link the dist folder, not the root folder of the plugin project.

So, the question arises when you want to change a module that is used (and tested) in another module. Let's say your normal flow is to change the version of the child package, then npm run packagr, then npm publish it, then npm install childModule@latest in the parent app. This quickly gets tiresome and leads to unrealistic version numbers.

A better solution is to use npm link. First, you go to your plugin/child module and you run npm run packagr. When it's done, go to the dist folder and run npm link. This will create a symlink in the global node_modules folder for your project's distribution package. Then, move to the parent module and run npm link <name-of-child>. The name of the child is the same as the name of the application. This creates a symlink in the parent module's node_modules to the global symlink created earlier.

Wait! A few gotchas, first:
  • careful with the operations that might change the content of the folder linked in node_modules, as they will change the actual source code of the plugin
  • after you finish with the work on the plugin, then delete the symlink, publish the child and reinstall @latest at the parent
  • make sure that the version of the plugin package in the parent is permissive (something like >=initialVersion), otherwise you might have problems with the version number you set in the plugin package.json file

Hope this helps.

Friday, March 09, 2018

npm gotcha: commit and do not delete package-lock.json

NPM is a popular package manager (think NuGet for JavaScript) and the information of the packages that it needs to install is stored in a file called package.json. You run npm install, packages are getting downloaded in a folder called node_modules and a package-lock.json file is generated. Since you can always delete node_modules and package-lock.json and rerun the package install, a common assumption is that they are redundant and they shouldn't be stored in source control. That is wrong in most cases.

The lock file not only stores the progress of the npm installation, but also the actual versions of the packages that it installs (for the entire dependency tree). As opposed to this, package.json contains only the packages directly needed by the project and the acceptable ranges of the versions. One can allow for any version of a package to be used, or maybe anything above a version, or an interval or something that is "the best version" around a specific version. Deleting the package-lock.json file effectively tells NPM that you trust package.json and the developers of each package for the versions of the dependencies loaded.

Here is a common scenario: you create a new application, you need some NPM packages so you npm install thePackage. This gets the latest version of thePackage and installs it, then marks the exact version into package-lock.json as well as the versions of the packages thePackage uses and what they use and so on. Finally, you commit the project, including package-lock.json. Three months later, a new developer comes and gets the project from source control. They use npm install and see that everything works perfectly, because the packages restored are the exact same versions as the ones restored for the original developer. But now they think "who committed package-lock.json? Don't they know it's redundant?" so they remove it from source control. Three months later another developer comes and runs npm install on the source from the code repository, only nothing works anymore. The versions that were downloaded are, depending on what is specified in package.json, the latest version of the dependency or maybe a version similar, but with a different minor version, and with the dependencies that the developers thought best for that particular version.

There is a situation when package-lock.json is entirely redundant and that is when package.json only specifies exact versions. NPM works so that you cannot replace the same version of a software in their repository, so the devs will never be able to change the package versions they used for a specific version. That is why it is safe to assume that the same version of a package will use the same package dependency tree (unless some of the packages are removed, but that's another question entirely).

Summary: If you have any version of a dependency in package.json specified as anything else than a specific version (no tilde, no caret, no asterisks, no intervals), then you also need to store package-lock.json in your source control.

Sunday, March 04, 2018 is dead, but you don't need it

If you ever used The Pirate Bay, you know that a lot of the content there is porn. Even the most popular distribution users share movies or series among tons of porn links. In order to solve this problem, appeared, as a simple pirate bay proxy that eliminated the porn links. Now that site is dead. I can't say that I am overly sad about it, since it worked very badly anyway. Yet, now, if you want to find movies shared by the likes of xxxlavalxxx or juggs99 (which probably started out as porn distributors anyway, with those nicks), you can't even see where they are in all that sea of xxx.

Well, there is a very simple solution, works in your browser, and all you need to do is install an extension that you probably ought to have had anyway. Now, this article assumes you use Chrome, but it probably works the same with Firefox. For Internet Explorer and Edge I have no idea and I also don't have the time to do the research, so if you feel inclined to help others and you know how to do it, please leave a comment and I will update the post.

This is the solution: install the CJS extension, which is a simple enough tool that allows you to run a script of your own design on any page. After you have installed it, browse to The Pirate Bay, click the extension button and add this script:
    while(node && node.nodeName.toLowerCase()!='tr') { node=node.parentNode};
    if (node)'none';

You might be tempted to try to load jQuery and rewrite the script, for better readability, but take into account that most ad blockers (which you probably use, if you use torrent sites) block jQuery on pirate bay domains.

What the script does is hide all the rows that have the Porn (id 500) category. If the site ever changes its ids, you might want to update the script, although that scenario is pretty unlikely.

Saturday, March 03, 2018

Personal archaeology

We are changing the furniture and repainting the walls in the apartment, so naturally, the first order of business is to dig into closets, drawers, bags, boxes and various regions under existing furniture and throw away as much as possible. It is a strange feeling, one that makes me remember a past and dead self, one that was hopeful, smart, crazy, in love, using technology and doing stuff that I can't even begin to comprehend nowadays.

I dug into old CD albums, remembering with much nostalgia the movies that I was watching and intending to keep forever. The movies are still around, CD players are almost gone. I had to use my wife's laptop to read the CDs, as mine would only accept a few of them. Well, that's because it's broken, but still. Among the CDs I found old source code and material that I had gathered from friends, jobs, the Internet, hacking. I felt like an archaeologist digging through the remains of old civilizations, ones we hold dear and towards which we feel a strong sense of ownership, but with which we have nothing in common.

Here it is: the Palm VX PDA that was built in 1998 and still works now, with the same battery, if you can just find a way to connect it to a computer so you can upload new stuff to it. Here it is: the Nokia E60 phone that worked flawlessly for more than ten years. I bought a smartphone to replace both of them just five years ago. But also, here it is: an external modem I had forgotten I had; I still wonder where I used it, if ever, and how I got hold of it. Same for the audio/video/infrared wireless transmitters and receivers that allowed me to watch movies from the computer to the TV in the other room. Tens of meters of Ethernet and all kinds of connective cables, forgotten in an age of ubiquitous digital wireless connection just forgotten in the odd corners of the house. Remains of two desktop computers (that I could still make work if I had the inclination) linger like the fossilized bones of extinct creatures.

I feel a mix of gratefulness, nostalgia, loss and that I am fucking old, all at the same time. I wonder where I could find people that still value these things that I dug out from my past and that otherwise will soon become anonymous and amorphous junk. Geez, look at the 6 CDs of utility software, stuff I still remember fondly and stuff I have never used: antivirus, archiving, communication, VoIP, OCR, document processing, all software that is in heavy use today but you would be hard pressed to find people still recognizing these particular incarnations. Music that I still have in my playlist on CDs almost twenty years old. Games that I had worked on that I have forgotten ever doing. Random writing from when I was so young I feel embarrassed just to remember.

And this is just from a 50 square meter apartment that we moved into just ten years ago. I can't even imagine how people do this when they move out from their childhood home, where they and their kids have lived for generations. What do they find? Do they even recognize it? What happened to all the people that I once was?

Wednesday, February 28, 2018

HttpInterceptor in Angular (@angular/http vs @angular/common/http)

Just a short info about HttpInterceptor, which is the Angular system of intercepting http requests, so you can do useful stuff like logging, error handling, authentication, etc. There are two npm packets for http, the old one is @angular/http and the new one is in @angular/common. While their interfaces are similar, HttpInterceptor only works for @angular/common/http.

Bonus thing: in the interceptor you are building, when you get the Observable<HttpEvent<any>> from next.handle, do not .subscribe to it, lest you will double all http requests (including adding items).