Imagine an alternate universe to ours, similar in many ways. Watching television and browsing through magazines is the norm in this world. Just as we in our universe have ad impressions and our own ideas about society are shaped in this way, the people in this other universe are also programmed on a daily basis. How to treat others, what to wear, what to eat and what’s socially-acceptable and even expected are all topics which are schooled, if-you-will, in both worlds by our & their collective media “teachers”.
Using some pretty sophisticated multi-universe equipment that I’ve just invented, I’ve managed to pull some of their advertisements across the ether over into our world to share with you but a warning: some of these images may seem shocking to you. One can only imagine what a wretched society would result from social programming such as this.
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.
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
Before (classic jslint-like formatting)
After (new, suggested method)
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)
After (new, suggested method)
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:
- fs.closeSync() something
- create a variable
- 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.
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
Let’s see… NASA’s InSight probe supposedly landed on Mars back on Monday. Visit their website two days later and there are lots of videos and photos, all of which are CGI-generated or they’re hours’ worth of employees looking excited.
Here’s one I’ve managed to dredge up though:
Is that the best we can do for the US$1B price tag? Presumably, it’s a down-facing camera with a frog-eye lens.
Yet again, it feels like lies stacked on top of lies to me.
Apple recently came out with macOS Mojave as the latest in a series of operating systems. Like most of us, you might believe that all upgrades are good upgrades. The truth is another matter entirely with respect to compatibility.
You probably didn’t know this but Apple is dropping 32-bit support in the next release.
They’ve been migrating to a full 64-bit operating system for several major versions now. You probably didn’t know this but they’re dropping 32-bit support in the next release. This is big news and it isn’t being talked about. Think of it as a means of extorting lots of money from the community of Apple developers. If those developers haven’t purchased new computers and they haven’t upgraded to the very latest version of XCode and if they haven’t paid their annual developer fees year after year then they won’t be able to exist in the next major version of OSX. Their apps just won’t work unless they comply.
What does this mean?
Simply put, perhaps a quarter of the OSX apps—especially those you have paid for—will not run anymore.
Apple’s quiet announcement
Behind-the-scenes, Apple has put up a page which warns developers what’s coming. But it’s not like they’re actually warning their own users NOT to upgrade their operating system. Of course, we’ll be nagged daily to upgrade as usual. Imagine how angry you’ll be some day in the future where you endure the typical hour-long upgrade only to find out that your Adobe Photoshop doesn’t run after the upgrade. Typical of Adobe, they’ll likely end support for the version of their software that’s only 32-bit and you’re caught in the crossfire.
How to tell
Here’s how to tell if a particular app won’t work with the next major release of OSX:
Apple menu -> About This Mac -> Software -> Applications -> select application -> 64-bit: yes/no
In this example, we see one of the pieces of programming provided by Adobe indicates “No” in that field meaning it will stop working soon.
You can adjust the sizing of the report’s columns and then to sort by that 64-bit heading to show a list of the ones which won’t work.
You have to laugh when you seen two of Apple’s own apps in that list and they’re responsible for their updates of course.
Mark me down as one of those who understand that Apollo 11 didn’t go to the moon as publicized by NASA. I’ve known this for a while now but even this video should make sense to some of the people out there who thought otherwise.
As heard in the video, there is clear scripting going on with the astronauts. An extra off-screen voice is heard coaching them when they’re supposed to respond (mimicking the distance delay), instructing them how to fake the Earth’s distance by ricocheting its image off a far glass and by darkening the inside cabin as well as introducing a fake solar terminator. Unfortunately for NASA’s credibility, they accidentally released raw color video which still included all the prompting, planning of fakery and references to later video processing which was to occur.
But of course, they knew back then that they couldn’t survive the journey because the Soviets knew this. In typical Russian style, they just secretively sent many cosmonauts to their death. News of this made it back via spies to NASA of course. Rather than to admit defeat NASA just chose to completely fabricate a story of success.
In a way, it was just bad timing. In the beginning of the sixties, they actually thought that they could make a trip to the moon and back. It wasn’t until the Soviets had sacrificed their own people enough times that the Americans realized that this was a losing game. Having made bold claims to the world about what we were capable of doing, they didn’t feel like backing down from such earlier bravado. So they faked it, nearly the entire thing. The Apollo astronauts just orbited the Earth the entire time, having earlier done the lunar videos on a stage at Disney. Stanley Kubrick’s recent sci-fi movies made him the obvious choice as director; his innovative front screen projection technique was used for the lander footage.
Even to this day, faked videos are being produced by NASA for unknown reasons. That same guy wire technology is still being used to give a false sense of weightlessness.
When asked why it’s difficult to go back to the moon, NASA’s own employees have suggested that “we don’t have the technology to go to the moon” because we destroyed it. Really? That’s the equivalent of “my dog ate my homework”. It’s a 12-year-old’s lie to their teacher.
NASA’s own engineer suggests that they still haven’t figured out how to get past the Van Allen Belts. Really? As if we didn’t already know that you guys couldn’t have gone to the moon in the 1960s because of this.
When George Bush Sr. visited NASA on a tour, I guess everyone was so preoccupied that they forgot to stop making a fake ISS video on a green screen in the background and this was totally published. Oops.
The Mars Viking Landers
According to NASA, the Martian landscape was red and a forbidding landscape. I’m sure we’ve all seen images like this.
But according to one employee, the feed suddenly went dead right after seeing two people in spacesuits doing repairs as seen here.
So we’re left with one of two eventualities: either all this was filmed on a backlot somewhere and 100% faked here on Earth… or the cover story that Mars isn’t inhabited already by us is simply a lie. If this were filmed here on Earth then why the need for a spacesuit or helmet at all? That pretty much leaves us with the other option, the one in which a private version of NASA has been on Mars for some time now.
The Mars Mining Corporation
Marine whistleblower Captain Randy Cramer indicates that he spent nearly an entire 20-year tour on Mars in support of a private mining company located there.
So Why the Lies Now?
I suppose there comes a time when your lies just catch up to you. NASA can’t just come out and say they lied to us in the sixties. For the same reasons, they can’t just suggest that we’ve reasonably managed to secure Mars now for a private corporation. As liars in league with liars, they can’t break ranks and simply tell the truth. Telling us that public dollars have benefited a single corporation’s stockholders just wouldn’t make people happy when you get right down to it.
Until the public in the majority understands the scope of these lies and then directs their anger at NASA and our own government, we’ll just continue to be fed more lies by these people.
Continuing with the work to re-purpose a computer mouse as a filament movement detection device, I designed and printed some parts for this. The bottom part is perhaps 5mm in height from the spool itself and is reasonably a good distance to see changes.
I’ve edited the earlier Python script which originally detected the scroll wheel button; it’s now detecting movements of Y as if the mouse were being moved on a mousepad. It will only do this if I take the white assembly and move it around on a patterned surface, however.
To help the mouse detect movement better, I’ve tried using both grid paper and a polar version of same. I don’t love the feedback loop that’s going now. I’m sure there’s a better way to get this movement detected all the time, though.
This week’s project involves dealing with filament-delivery problems on my 3D printer. Out of the box, the filament runout detection never worked. Frankly, it was a terrible design to begin with from the manufacturer and I’m convinced that someone at the factory just turned off that behavior anyway.
As a result of this, I’ve lost a few print jobs over the last year. In only two cases, I simply ran out of filament for large parts. In all the remaining cases, a number of problems contributed to the loss of filament delivery to the printed part:
- simple end-of-roll loss of filament
- spool sticking to manufacturer’s poorly-designed spool holder
- cross-threading of the filament on the roll
- hot-spooling the filament at the factory which resulted in filament which sticks together
- filament like carbon fiber—infused which likes to stick to itself
- old filament which is now brittle and breaks as a result
- overall poor design of the spool (boxy) shape itself, resulting in cross-threading
- overall poor design of the filament delivery path itself, resulting in too much force needed to extrude
- filament thickness quality issues as combined with PTFE feed tubing, resulting in stuck filament in the tube
- too-flexible filament as combined with any of the conditions above, resulting in filament notching at the bowden gear
- z-offset too close to the bed, resulting in hotend jamming
- poor first-layer adhesion, leading to a build-up of filament and ultimate hotend jamming
Now granted, the bowden drive for this printer is one of the beefiest NEMA 17 style of stepper motors I’ve seen. And yet the number of filament delivery—related problems is just too high to continue to ignore. So I’ve decided to finally deal with the issue rather than working around it.
Ideas & inventions
Remove the stock holder, add bearings to its replacement
I designed, printed and assembled a very good dual-spool filament delivery system which worked much better than the stock filament holder. I sometimes still use it.
Dual runout switches
Perhaps six months ago, I designed, printed, sourced parts for and assembled a very good dual-spool filament runout detection block to replace the stock part. I have yet to install it since I’m not in love with the idea of the filament path beginning at the table level. Time has taught me that the spools need to be higher than the printer for this to be optimal. As designed, though, it works in principle to detect loss of filament from both spools.
And yet, this entire concept does not directly address the problems associated with cross-linked filament. It only addresses the loss of filament as seen in a switch.
Parabolic spool guides and re-purposed monitor stand
Additionally, I designed, printed and assembled parabolic spool guides to better deliver filament (especially for hot-spooled or otherwise sticky filaments like carbon fiber). This I combined with a designed/re-purposed dual-monitor stand to move the spools above the printer rather than below.
Remove the temperature gradient
First-layer adhesion was aided by adding a foam enclosure/door and a temperature-monitoring Raspberry Pi 3B to the inside (opposite the internal webcam). The latter helps to heat up the print volume area, keeping things from 90-100 degrees Fahrenheit.
Remove the PTFE tubing
Filament diameter inconsistencies resulted in filament getting stuck in the PTFE tubing. I now rarely route the filament through the tubing, having removed the awkward bottom-to-top filament delivery path from earlier.
And finally, a filament movement detection mechanism
This weeks work then revolves around fixing the underlying problem. The solution isn’t filament runout detection. The more accurate problem and better solution is actually loss of filament movement and its detection.
When I began to think of solutions, in my head I was adding black/white encoder rings to the sides of the spools themselves. I would need to add those to all spools of course. I’d also need to design something which reads those as ones and zeroes.
I decided that a roller/follower which is turned by the spool is also a solution. I then envisioned writing drivers and creating a small circuit board for all this so that it could talk to Raspbian, the operating system which OctoPrint runs on.
Mouse to the rescue
Finally, it hit me that a standard computer mouse does this naturally. The older style of ball mouse has a follower which detects when the ball is moving. Even the newer style of mice still have a scroll wheel which is covered in rubber and would do nicely. In my imagination, the first iteration of this had the filament trapped against that rubber wheel. In today’s version, the wheel merely comes in contact with the side of the spool itself for the win.
As a bonus, the computer mouse already has the serial communication and Linux driver built-in. It was trivial to write a small Python script to detect scrolling events.
no mice will be harmed … in the making of this gadget.
The mouse should fit nicely and without any modifications to a 3D-printed holder. The serial connection goes to the Raspberry Pi and is then detected in an OctoPrint plugin. During a print job the scrolling events will be monitored; any loss of scrolling over the sampling period will then pause the job and alert the operator with a sound event.
I’ve just used AI to paint a picture from the poem I’ve just penned. Technically, it’s a machine learning algorithm which attempts to generate a painting from the text it has been given. The intent is surrealism and I’d say that it’s not a bad attempt at all.
|NASA paints lies with bold strokes
from a well-worn brush
from neglect and secreted away from prying eyes
Say it isn’t so.
Since the end of October is all about scary stories… Just on the heals of Microsoft buying github for US$7.5B last year, IBM has now has purchased Red Hat Linux for a cool US$34B dollars.
Granted, I haven’t used Red Hat in a few years mostly since it is one of the few paid UNIX-based operating systems out there. Ubuntu, backed by Canonical, is clearly the better choice for anyone who knows what’s going on.
IBM is the antithesis of open-source software, as is Microsoft. This is just sad. But good riddance. Now get in the hole, Red Hat.