ms-dos is now open… 36 years too late

I suppose Microsoft is trying to go with this whole… open source thing that the rest of the world embraced a long time ago. They’ve just placed the source code for MS-DOS out into the public domain about three or four decades after it’s useful. Seriously, guys?

It’s probably lost on most people that this code is utterly useless, unless you have access to a time machine, of course. In order to assemble the code you’d need MASM v1.10 which is a very old Microsoft Assembler program indeed. I remember actually owning that about thirty years ago, believe it or not.

Obvious chicanery

Looks like whoever made this available has added a number of poison pills: file-renaming, garbage characters to prevent assembly, the absence of an old (required) assembler, etc. It’s so blatant it would be funny otherwise.

disengenuous

adj. Not straightforward or candid; insincere or calculating

the zen of source code formatting

 

Source code—assuming for a moment that you didn’t already know this—is a collection of (often English) words and symbols for humans which usually is turned into something more meaningful for a computer to understand when the program is running. Each computer language has its own rules about how you order the words and symbols but most allow for a fair amount of leeway with respect to whitespace, the “rests within the melody”, if-you-will.

“most [computer languages] allow for a fair amount of leeway with respect to whitespace, the rests within the melody…”

“Source code formatting is the task of using that whitespace to maximize… something.”

Source code formatting is the task of using that whitespace to maximize… something. This of course means different things to different people. For some, they believe that source code formatting can be done only one way. To format code using any other method, in their mind, would be the equivalent of breaking some sort of law.

Others believe that your text editor knows best and should be the authoritarian on the matter. There’s usually a feature to “format document” which they believe always gets this right.

As someone who’s been coding now for almost forty years, I’d like to share what I’ve learned and to permission you to completely ignore those first two camps who would say that you must do it their way.

The Virus

In my humble opinion, nearly all of the source code formatting as seen in the world’s collection of code suffers from poor readability. And this is so because of the attitudes surrounding the topic as well as the self-imposed “leaders” and big players who believe their way is better, demanding adherence to their own opinions.

In many software development firms, this is a hot topic for debate. Coders feel strongly about how all this plays out. Outspoken individuals like Douglas Crockford (author of jslint) have even developed tools to enforce their own (wrong) ideas about how code must be formatted.

As large corporations like Google publish more in the open source area, they bring with them this kind of Draconian mindset. If you bring in their code, you’re very likely also bringing in format-enforcing restrictions which come along for the ride.

“If we think of jslint as a virus that self-propagates, then cloning a Google-published project has now infected your project.”

I have personally been held hostage for days trying to make the jslint build tool happy when I’ve been forced to use it. It’s one of the worst anti-patterns I’ve seen in this industry, to be honest.

An Innovative & Meaningful Method of Formatting Your Source Code

For me, I choose to maximize whitespace instead so that I may understand the code instantly. The more I understand the code, the less likely it is that I will later introduce a bug into this code. The faster I can speed-read the code, the more productive and happier I’ll be.

“Code Complete” by Steve McConnell

The genesis of this new method comes in part from my having read this excellent book at least twenty years ago. At the time, this was ground-breaking in its revelations of coding statistics with respect to bugs and the impact of good source code formatting to minimize their presence in code.

My method goes beyond the author’s original suggestions and is the work of a couple decades in the making.

A Practical Example

Below, I show a pair of examples. It is the same code, just differently formatted. The code language is JavaScript and is written for NodeJS, more specifically. The other examples below also are written in JavaScript.

Before (classic jslint-like formatting)

Screen Shot 2018-11-29 at 12.20.13 PM
Figure 1

After (new, suggested method)

Screen Shot 2018-11-29 at 12.22.26 PM
Figure 2

Hopefully you will see the appeal to the second method. The spacing in Fig. 2 allows us to quickly see that this section includes the creation of several variables by pulling them in from separate files and modules. Additionally, they are alphabetized to make it easier to spot accidental double-inclusions.

Given the column-like behavior and the symmetry of those “require” functions, it’s now much easier to scan down the list. It’s now a pleasure to read.

Before (classic jslint-like formatting)

Screen Shot 2018-11-29 at 12.30.22 PM
Figure 3

After (new, suggested method)

Screen Shot 2018-11-29 at 12.17.01 PM
Figure 4

Here, by tightening up the first/third activities to become single-line events in Fig. 4, it’s easier to then see that we have what appears to be a sandwich-like construction:

  1. fs.closeSync() something
  2. create a variable
  3. fs.closeSync() with that variable

The second activity now has some pretty radical source code formatting. But it follows the column rule introduced from before:  columns make assignments easier to scan.

1) The Column Rule

To sum this up: use consistent whitespace to create columns out of assignments (storing a value into a variable). This applies to multi-line assignments as well as to assignments which take more than one line to accomplish.

Create columns: “…use consistent whitespace to create columns out of assignments…”

2) Squash for Readability

If it is possible to remove vertical space so that an entire function may be reviewed in one screenful in your editor, then consider doing so. Good candidates for this treatment are the open/close pairs of file functions seen in Fig. 4. The pairing makes sense to most coders so it’s a welcome form of abbreviation.

Squash: “If it is possible to remove vertical space so that an entire function may be reviewed in one screenful in your editor, then consider doing so.”

3) Comment the Breadcrumb Trail

When there are several levels of braces in one group at the end of something, clearly comment each with judiciously-provided whitespace so that they line up as a column as seen in Fig. 5.

Screen Shot 2018-11-29 at 12.45.00 PM
Figure 5

Breadcrumbs: “When there are several levels of braces in one group at the end of something, clearly comment each with judiciously-provided whitespace so that they line up as a column…”

4) Semicolons for Readability

Use line-ending punctuation to tell one type of scope/block from another. In Fig. 5 above, fs.readdir() and fs.unlink() as function calls are each terminated with a semicolon after the ending brace. Here, I’m omitting the terminal semicolons for both the sections in the if blocks and the for loop at their ending braces.

Semicolons: “Use line-ending punctuation to tell one type of scope/block from another.”

I’m sure this one will have its critics. I would argue that the introduction of chained functions and the concept of “Promises” have created some rather interesting “dogpiles” of code at times which are too difficult to follow without this strategy.

Applicability to Other Languages

The suggestions indicated also apply to other languages. One notable caution, though, goes out to Python-related code which is fairly picky about beginning indentation style. The beginning of each line of Python marks logical blocks of codes as you might see in a matching pair of braces in JavaScript. It’s therefore critical to first make Python happy in this regard before attempting to then adhere to these suggestions. The continuation line technique seen in Fig. 4 above would not work in Python for this reason.

microsoft wants open source extinguished

On June 9th when Microsoft had just purchased github.com, I wrote about how I thought this was something tragic for the world of open source. This morning I awoke to several new security notifications from my repositories there (requiring about an hour of my time to adjust my code):

“We found a potential security vulnerability in a repository for which you have been granted security alert access. Known low severity security vulnerability detected in debug < 2.6.9 defined in package.json.”

On the surface, one might think that Microsoft is trying to make the world a better place. You might think this if you’re an optimist or a friend of them, perhaps. Maybe Microsoft cares about security so much that—having just purchased github—they now want to ratchet up the quality of the collection of software as stored there by most people who don’t like them…?

But if you’re a pessimist or if you’re someone who doesn’t like Microsoft, could there be another reason behind this new diligence they’re trying to bring to code security? It’s not like Microsoft has a great track record in writing bug-free or network-safe code themselves.

“It’s not like Microsoft has a great track record in writing bug-free or network-safe code themselves.”

Strategic sabotage

Richard Nixon was known to do something termed ratfucking in the political world. Wiki even has a page on the subject. It means “political sabotage or dirty tricks”. It would eventually result in his impeachment. In some college circles, a mean-spirited prank is part of the playing field. To me, it feels like many of the players inside Microsoft are the same type of people, those who have no qualms destroying the competition, tripping them up and generally exercising a “whatever it takes” attitude toward their so-called success.

Microsoft’s internal methods:

Steal their air

In a lawsuit, the U.S. Department of Justice turned up an internal tactic used inside Microsoft which describes what they do when they feel that a competitor needs to be removed: “embrace, extend and extinguish”. In other words, 1) embrace open source by buying the main storehouse for its code, 2) create products such as Visual Studio Code which replaces similar free editors and 3) gradually remove the competition by getting rid of it now that you’re in a controlling position.

Appeal to fear

Another tactic they use in the market space is to promote fear with respect to anything the competition could provide. We’re seeing this now in the pseudo-warnings being auto-generated by github.

What this is

What we’re seeing is a direct and strategic beginning to Microsoft’s move to embrace, extend and extinguish github and yet it’s open source itself who is their ultimate target.

The future of gihub and open source

Expect more of the same: dirty politics related to the leading repository site of what Microsoft views as their competition.

and now, a positive outlook on ad content

Since I no longer have an Office 365 subscription I find myself occasionally using their web-based version to fetch my email. How very annoying their galley ads have been lately. They’re too animated, they change faster than you could actually read them. They’re about as obnoxious as they could be.

Since I use Safari as my favorite browser, I just wrote a custom stylesheet to deal a blow to those unwanted ads. I’ve specifically targeted the ones usually delivered by Microsoft’s online Outlook website but it could be edited to remove other content you don’t wish to see.

safari-stylesheet

Safari -> Preferences -> Advanced -> Style Sheet:

Screen Shot 2018-08-08 at 12.16.38 PM

Result:

Screen Shot 2018-08-08 at 12.19.24 PM

old-fashioned milk bottles

Once upon a time, you’d get milk delivered in the morning in glass bottles. Okay, honestly, it was other people who got that but I do know this from watching old movies.

milkman

Now that I’m old enough to go shopping myself, I have a fondness for buying my milk in bottles like this. For most people, I’d guess, the thought of adding an extra $2 for the glass rubs them the wrong way. For me, I see it as an excellent way of picking up a great deal. It would cost about $10.84 for that same glass two-quart container from Amazon.

Re-use, recycle, re-invent

So what would I do with the extra bottle? Almost anything that can fit through the top is a good candidate but food is what I primarily store in mine. I have at least 30 bottles storing dry goods, two storing refrigerated drinks and perhaps eight storing filtered water.

When I make waffles, I usually mix up several batches of the batter and that will go into the pint-sized glass bottle. Turbinado sugar also goes into the pint-sized version, making it easy to spoon straight out from there.

I purchase the Mueller’s pot-sized spaghetti which fits nicely into the quart-sized bottles. Most flours as packaged by Bob’s Red Mill will exactly fill the quart-sized version. Potato flakes? Check. Granola? Check.

I have rows of beans and lentils, pastas of all shapes, flours, starches, coconut flakes and almond slices. There’s trailmix in one. I have semolina, masa, corn meal, oatmeal, Scottish oats and Creme of Wheat.

In the refrigerator today I just added two quarts of iced tea and a quart of iced coffee. Three visits to a local coffee shop would probably set me back $12 for three drinks and I’ve just stored away the same amount for a fraction of that cost.

Perhaps the best benefit of storing most of your pantry in glass is that you no longer have to deal with pests. This is the first time in my life that I have literally zero bugs trying to eat my food.

Enter the 3D printer

The tie-in, then, to the 3D printer involves me designing a replacement funnel using Autodesk Fusion 360 for the purchased funnel I’ve used up until now. Hopefully it turns out, it’s about as big as my printer could do.

The previous funnel was okay but it wasn’t a great fit for the bottle. Big items like granola would constantly get stuck in the too-small funnel neck. This one should fit perfectly.

Screen Shot 2018-07-09 at 4.03.41 PM

Food safety and plastic

Some of you may then caution about the use of printed plastic in conjunction with food. I’m sure the PLA filament (which is made of a polymer of corn starch) is actually closer to be food-safe than the funnel which I’d purchased from a car parts store earlier.

Some of the typical concerns with food versus printed plastic is that the small grooves in the plastic allow for bacteria to grow. Okay, but this is the same for most of the plastic utensils which we routinely include in our kitchen, right?

Another concern is regarding the existence of lead in some of the nozzles used. Yes, but that must be so minuscule as to be outside of the realm of concern. In response, I could site the many harsh chemicals used in the processing of naturally-green soybeans to create an unnaturally-white soy milk product, for example.

For dry goods, the PLA funnel should be a non-issue. With reasonable cleaning I think that it will do fine with liquids as well as long as I don’t use it to funnel boiling water, for example.

adafruit oled display

Other than importing gadgets, Adafruit sometimes also designs them. Today’s review is for their cool 1.3″ OLED display for the Raspberry Pi computer. It appears to fit exactly the top of the Raspberry Pi Zero WH (the one with the included header).

IMG_0041

At $22.50, the hat is about twice the cost of the computer itself. The 128×64 display is enough for most projects, I’d guess.

I’m thinking that I’ll use this one to develop a cold wallet for cryptocurrency.

The hat (“bonnet”) includes a joystick with four positions and a pushbutton as well as two stand-alone pushbuttons on the right. It comes with good support on the Python side of things. If you’re like me and prefer Node JS, then you’ll be doing a lot of research on this one.

The interface is I2C. The device identifier is SSD1306. The example software includes text- and image-based Python and a bit of an animation of text.

In case you’re interested, I’ve written a tutorial for getting this setup.

on the mad exodus from github.com

If you don’t code for a living, you probably didn’t hear about the US7.5B deal in which Microsoft is now purchasing github.com. For the rest of us, this is big news.

GitHub Inc. is a web-based hosting service for version control of software using git. They offer both private repositories and free accounts (which are commonly used to host open-source software projects). With its 28 million public repositories, it’s the largest host of source code in the world.

Github’s competitors are reporting record numbers of customers moving their repositories away from the now Microsoft-owned provider.

What Microsoft now controls

Presumably, Microsoft now controls both Atom and Electron, two extremely powerful platforms in the coding space. The former is a great code editor and the latter is the underlying executable program which allows others to code in JavaScript to create a very usable desktop/GUI application.

Microsoft also now control the revenue stream. Each private repository costs $7/month or $9/month, depending upon whether its personal- or business-related.

Microsoft now apparently has access to the code in those private repositories. Just imagine what their competitors must be thinking, now that Microsoft has a copy of their internal project code to include any secret ideas those competitors have been working on.

Alternatives

We’ve all been lulled by github’s ease-of-use, it’s free nature and such. We haven’t even considered alternatives before now, to be honest. The specter of this new playing field means that we must look at our options.

Gogs.io is an open-source option for hosting your own github-like service.

Gogs

Over the last three days, I’ve now setup my own private, internal Gogs service called gitjs.io. Since I own the domain name I may later push this into the cloud but for now, it’s running on one of my computers here at home.

After the initial hurdles to get OSX to startup the Gogs service on a privileged port (http/80) and to automatically start upon bootup, I must say that I love it.

It’s a full-featured github-like experience throughout with all the screens you’d expect. You can create users, organizational levels and do the things you did over on github.

The command line git program interacts with the service as expected. The underlying code creates a global repository folder to stores everything much the same way that github might.

Screen Shot 2018-06-09 at 6.38.00 PM

The Future of Source Control

I don’t need a crystal ball to suggest that Microsoft’s purchase is going to be a game-changer for open source. The world of open source is the very antonym of what Microsoft stands for.

I would suggest that anyone and everyone with a github account highly consider the immediate need to move your code elsewhere. Microsoft has a long history of buying up competitive technologies only to starve them of air over time. In fact, internally Microsoft used the term “starve them of air” to describe how they would ruin a competitor’s advantage in the market.

It’s time to take your code and run.

da plane

Obviously, I watched too much television growing up. Every week on Fantasy Island, Hervé Villachaize’s character would point to the sky and make this exclamation.

da-plane

In a 3D printer, it’s really important to start printing on a known, flat plane. And yet, many print beds aren’t made of something rigid like glass so bigger parts end up shaped like the print bed itself. Even small deviations can mess up a print. It’s a problem to be solved, actually.

OctoPrint

The software that’s running on my Robo C2 printer is a fork of the popular OctoPrint open-source software. What’s cool about this software is that it will allow you to write plugins to adjust the way it works.

GCODE

The language the printer listens to during the print job is called GCODE. Think of it as a list of common instructions that almost all 3D printers use now.

Autoleveling

One of the GCODE commands in question is G29 and this tells the printer to run through an autoleveling routine. In some cases, the printer’s extruder will actually touch the print bed in several locations. In others, the extruder assembly will use a light plus a photoresistor to hover above the bed and to gauge its height above it. Using either method, the printer can make a reasonable “map” of the print bed and mathematically create a virtual plane to represent it. If the print bed is a little lower on one side, this routine should allow the printer to compensate for that.

Only…, it doesn’t really work that great, to be honest. Someone deserves a round of applause for trying to fix the problem but honestly, a manual approach is possibly the better way to go here.

Although these printers have a built-in autoleveling feature, manually leveling the print bed is preferred by those who are more advanced at 3D printing.

The Problem

I’m currently now working to manually adjust my print bed so that it is perfectly level and an exact height from the extruder. In fact, I have two replaceable print beds for the same printer so both of them need to be perfectly level and exactly the same height all around. To complicate matters, I anticipate designing and creating a third print bed for this which is heated. And that one should also be perfectly level and the same height as the others. The final goal will be to easily and quickly swap print beds without the task of fussing with any settings.

So now, having created a number of GCODE files over the last four months, I really don’t feel like editing them to remove that unnecessary G29 command. Once you’ve manually leveled everything, an autolevel routine is not only overkill but it can cause problems to the print quality. I needed a way of programmatically switching off the command when seen.

The Solution

I’ve created an OctoPrint plugin which helps to solve this problem. Assuming that I no longer need autoleveling at the start of each job, the plugin tells the printer basically to ignore any G29 commands. I now don’t have to edit countless GCODE files or worry if someone sends me a file—the printer will dutifully ignore this command.

Github:  Toggle Autolevel plugin

 

the matrix linode’d

Today’s review is about a pretty decent hosting company called Linode. Here’s the three-day timeline from idea to implementation:

  1. Thursday: decided to create a new info website about 3D printing, bought the domain name on GoDaddy and waited for the changes to take effect at midnight
  2. Thursday: created a Github repository to store the source for the website since I’m open-source like that
  3. Thursday: created an account on Linode, purchasing a “linode” for that
  4. Thursday: designed/created the initial local/development website layout/framework, collected images and content
  5. Friday: created (provisioned) the basic linode (virtual machine) for the website on production, provisioned a virtual drive, deployed Ubuntu 16.04LTS onto that, booted and remoted into that, ran updates, installed the framework, added the website, setup security and the firewall
  6. Friday: adjusted the DNS at GoDaddy to point to the new server, added more content
  7. Saturday: launched the website on Linode with the initial version
  8. Saturday: tweaked the settings to make the Node.js—based website start on bootup
  9. Saturday: added more content to the website

site

Not bad for an open-sourced 10-page (44 files) responsive website, if I do say so myself.

Please note that when I say “hosting company”, I really mean a “virtual server provider” so this is more like Amazon EC2 as a service offering. I didn’t just rent website space (like on Wix.com or WordPress.com), I rented an entire virtual server, if you will.

Comparison of virtual server versus website space

There are some advantages/disadvantages of renting a virtual server over just some website slot on a server somewhere:

Pros:

  • In theory, you could run several websites from a virtual server
  • You can run services in the background (like Node.js) and manage them
  • You can run multiple threads on the same server, like helper routines which do something other than serving up pages
  • You’re not limited to the set of templates that are available from Wix.com, for example
  • Your website runs separately from other websites
  • You get an IP address which is only used for your website

Cons:

  • You have to setup security yourself since you’re responsible for the entire server
  • The learning curve is steeper
  • You have to know I.T. things like setting up servers and installing software

Framework/software

Here’s a list of what I used for this website:

  • Node.js: Probably the most famous event-driven JavaScript runtime engine out there
  • Express: A minimalistic Node.js framework for separating code from content on a website
  • Bootstrap.css: A responsive stylesheet and component library for styling a website
  • PM2: A handy process manager for Node-based applications on a server.  After pulling new code, I might run the command pm2 restart AppName to restart the service

Documentation

Kudos to Linode for providing a detailed Getting Started guide along with several tutorial videos on the subject.

And further, a note of thanks to PM2 which seems to satisfy the requirements of bringing up and managing a Node.js application as a service within a production environment and their ample documentation.

Suitability

Is Linode well-suited for most website designers/developers? Probably not. On an I.T. complexity scale from 1 to 10 potatoes, I’d say they’re probably seven potatoes, perhaps. In this case, you’d have to be comfortable doing the following:

  • Using a web-based console to allocate and bring up/down a virtual server
  • Using ssh to remote into your virtual server
  • Navigating within a command line interface on a Linux computer or similar
  • Using ssh-keygen to generate a keypair
  • Using apt-get to update things
  • Editing files using nano
  • Managing services, reading log files
  • Remotely rebooting your virtual server
  • Setting up a firewall, testing and managing same
  • Applying code using git
  • Testing a website to verify that there are no 404 (file not found) type of errors, for example
  • And obviously, creating/designing a website in the first place and using a repository like Github for storing those files

That said, it was a perfect fit for me since I can do those things. In fact, the Linode-related part of this took no more than two hours since this is the first time I’ve used their interface. My next one should go much faster.

Observations

I will say that I’m impressed. Unlike Amazon AWS, Microsoft and Google, the people at Linode haven’t created an interface that’s overly complicated. It seems to work simply and to do the things you need to do and those are: 1) buy a virtual server, 2) deploy something onto it, 3) turn it on and 4) remote into it. I don’t think the “big three” have figured this out yet; their interfaces and the assumed workflow requires too much research, in my humble opinion.

Additionally, the PM2 software does a great job of working with the git-based code distribution model, allowing you to restart the Node.js app when it’s required and to start up automatically each reboot. There’s an easy-to-remember command interface like pm2 show AppName which tells you what you usually want to know.

At a cost of $5/month, it compares favorably to most of the well-known hosting providers out there. The basic linode will likely satisfy the requirements of the average Node.js application up to a reasonable level of simultaneous users, I’d suggest.

price

don’t make me clamp you, part 3

Oh, the fun.  After a few fails, I managed to print out several C-shaped clamps in carbon fiber—infused PLA, finally getting the temperature right.  I then spent several more hours in Autodesk Fusion 360 to further tweak/finalize the bottom of the chassis for the Raspberry Pi 3 supercomputer and sent that off for a 56-hour print job.  Whoa.

IMG_0139IMG_0138

Four of these clamps then were employed during last night’s printout while it was still going.

IMG_0149IMG_0151

Unfortunately, the pause feature that I’d asked for in the slicing software went rogue upon resume and tried to bury the extruder into the plastic, forcing me to abort at 4am this morning.  <_<

At least there’s much less part curling at the base versus last time. So I think I’ll redesign the clamps to have an even lower top profile and clamp right after the first four layers of the raft are down.