Saturday, July 28, 2018

Emacs org-mode

I've been an emacs user since around 1979. My hands know where the keys are and which keys to hit to get things done. The fact that I don't need to lift my hands from the keyboard to grab the mouse to get something done (and causing me to lose my train of thought) is huge. This is something that the Apple OS does well and Microsoft doesn't seem to get. To make matters worse, lots of new tools are web based where getting data from one application to the next is near impossible without using the mouse and without interrupting my hands on my keyboard. So I'm thrilled that I now have a non-web based organizer that's in emacs (my favorite editor/environment), it's emacs org-mode. Now I can concentrate on the programming algorithms and not on my tools.

I've been looking for a text based organizer tool where I can put my work notes in some kind of format that I can dump into HTML or work with in an editor. I was looking at learning Microsoft's Onenote but I'll be honest, I really didn't like the idea of learning more because I'm already learning all sorts of new stuff for work (VMs, Docker, micro-services, etc, etc.). I only have so much bandwidth. Somewhere along the way I ran across Emacs org-mode. I decided to give it a try and was overwhelmed with all the options and didn't really come to grips on how to get started. Every once in a while I'd try again and make no progress. Then I found a Uncle Dave's Emacs Videos (start with Org-mode Tutorial 1 - Introduction and basics). While I'm not too thrilled about the profile picture (Pepe the frog, now an alt-right icon) I am thrilled with the material, just emacs. One word of warning, turn up the volume otherwise you won't hear Dave. Anyways, he explains things in a way that is useful to learn enough about org-mode to make it useful in day to day usage (business and hobbist/DIY'r). So with just the first 4 of 5 tutorials I've learned something I can use in my day to day notes needs. I'd also recommend the Emacs Tutorial 6 (Introducing: org-mode). I'm certain there's a lot more to learn and options I'll never need or use but so far I'm thrilled I have a tool that works in both Linux and Windows. And I'm looking forward to a tool that can export my notes into HTML so I can throw them up on the 'net. I'm finding that it's a lot easier to search my notes with Google and I don't have to drag my computer with me.

Tuesday, July 17, 2018

FPGAs, something new to play with.

Well something new for me anyway. These are technically obsolete parts that I'll be playing with but they were cheap and the software is still available.

I have an interest in vintage computers, mainly because I lived through the start up of the microcomputer revolution. And one of my favorite processors is the Motorola 6809. It's assemble language was easy to learn and it always reminded me of the C language in that I could think about my C programming and translate it into 6809 assembly language. Anyways, I have a few 6809 systems but recently found Grant Searle Multicomp board. It's an FPGA based board that can be programmed to be a 6809 system, a Z80 system or a 6502 system. I came across an opportunity to get a bare board cheap. So I ordered it and I've assembled most of it. While the various different systems are very cool my mind is stuck on the 6809. Now I've always wanted to learn about how to program FPGAs and now is my chance. First I'll build it, then run it with a simple ROM monitor, later get it running OS-9 (maybe Level II) and then I'll see where it goes from there. I'm pretty sure I have a steep learning curve but but that's nothing new. To help with this endeavor I have the Multicomp board and it's parts, with an Altera EP2C5, but I also picked up another Altera board with the EP2C8 (a few more pins and maybe some more space in the FPGA). I'm hoping that will be my learning lab while the other board will be my play thing.

So I'm playing with vintage computers, FPGAs (software defined hardware), working with Software Defined Networks, Virtual Machines, virtual environments (Docker containers), emulators, simulators (sim09, etc) and the Agile methodology. This is not a direction I would have expected when I started this journey in college. Strange days indeed.

PS: For those who may be wondering how this all fits in with home automation. All of these things are being used to build the custom parts of various sensors for my home automation devices and the control system. I just put the finishing touchs on the mytimeout node for Node-Red (though I still need the automated testing part) and I will begin to work on the RF/IR node based on the ESP8266. This will be the final part for the feature request from my wife, the TV sleep timer. There are still a few more details to work out but basically she can set the time, hit a button and then if she falls asleep watching TV everything will turn off in the proper order. My wife is very critical of my home automation and five 9s is at the low end limit of her tolerance.

Saturday, July 14, 2018

Playing with Docker

It's been stressful at work, home, and everything else but I have had some time to learn new technologies (or learn more about them). I just published my first node-red node called node-red-contrib-mytimeout. It started out as a clone of Pete Scargill's node-red-contrib-timeout. I just wanted to learn how to create a node and publish it. It quickly morphed into a node of it's own. I found I didn't really understand Pete's code so I poked at it until it did what I wanted. But the code ended up having so many corner cases and patches to get it to work that it became unmaintainable. So I rewrote it starting with a simple state machine. Then I started to run into the corner cases (mostly the different types of input) that the node needed to handle. So I rewrote it again and again and again. I think it's much better now. :-) I'm not saying it's the best way to do things or that I'm a great programmer just that it's better than it was ... a lot cleaner. One thing I picked up was putting node-red into it's own docker container. That helped with testing the new code. Which is all manual at the moment. It seems that I need to learn to make better use of git branches to deal with master, hotfix and features. I did try to make use of node-red-node-test-helper but I don't quite understand it yet and I haven't been able to get the examples to work. I'll spend a bit more time with docker and node-red and understanding node-red-node-test-helper. I did manage to find the solution to being able to do a docker exec and getting an error

$ docker exec -it mynodered /bin/bash
unable to find user node-red: no matching entries in passwd file
$ docker exec -it -u 1001 mynodered /bin/bash
node-red@49cd98fddf2e:~$

I figured out 1001 for user node-red by looking at the /etc/passwd file that I copied out of the container. I could have also logged in as root with 0 and poked around but being root should be limited to only when you need it.

Once I figure out node-red and some kind of reasonable testing strategy I'll have my first Continous Integration (CI) project completed. I do see the full value of this as a way not to repeat the mistakes of the past.

PS: I made one change to my package to run mocha instead of node and the basic test suite ran fine (yeah!). I've since added a bit more basic functionality (unit?) testing and it too runs and passes. Not on to the more complex features. The test quite itself will be as complex as the code it's testing. So do I need a test suite for my test suite? ;-)