Skip to main content

Posts

The Software Stack for The Arduino CNC Controller

  Computer Numerical Control ( CNC ) is very much software driven. Yet, the architecture of the CNC software is obscured from the general software world. It has evolved separately with its own paradigm and nomenclature. At the heart of a CNC is the G-Code which is an old programming language that resembles an assembly language . A G-Code keyword is a combination of a letter and digits such as G0, G2, M2, M30, etc. All letters in the alphabet are fully used in G-Code. It is all about moving a tool onto a certain path in a work coordinate system with certain speed, duration, distance, and anything related to it. They call it jogging  and inching the tool. It may involves multiple tools simultaneously. The tools need to move accordingly to make, to assemble or to move products. Understanding how G-Code works is the precursor to understand how CNC works. In a CNC controller as depicted above, the Arduino Nano becomes the G-Code interpreter to control 3 stepper motors simultaneou...

Get Current User of Drupal 9 Externally

You have a stand-alone application that is not a Drupal module but resides in a Drupal sub-folder . And you want Drupal to manage your users. You want to access the currently logged-in Drupal user from your application. The following function will give you the current  user id, name, email and roles: use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request; /** * Get Drupal current session user details. * Passing Drupal folder, or its relative folder such as '..' * when it is called from a Drupal sub-folder. * Return ['id', 'name', 'email', 'roles'] */ function get_drupal_current_user($drupal_dir) { // Change the directory to the Drupal root. chdir($drupal_dir); $drupal_root = getcwd(); if ($drupal_root === false) return []; $autoloader = require_once 'autoload.php'; $kernel = new DrupalKernel('prod', $autoloader); $request = Request::createFromGlobals(); // Emulate Drupal /index.php to get ...

How to Create a Tiny Gnome Panel Application

On every  Gnome Shell desktop there is a main panel at the top of the screen. Usually, the panel shows the current time, the WiFi signal, the speaker volume, the power button, and the activity startup button. There can be many other things on the panel as individual user penchants. The panel will not be covered by anything, and will be there at all time except when there is a full-screen application running. The Gnome community has decided that the whole humanity needs the panel. What little things of texts and icons on the panel are called Gnome Shell extensions. Each of them is a kind of a desktop application which always run through out a user session. They can be personalized. We are going to create a simple and useless application that shows a running counter, something like the one that shows '1473' on the panel image above. It can be a starting point for a bigger and productive application. But before we begin let's get familiar with a collection of handy Gnome too...

fatal: Couldn't find remote ref master

If you are using Github then  master is now known as main . Whatever you want to do with a master must now be referred to a main . If you search for this error message on the Internet then you will encounter with a lot of old discussions on how to set up your master properly which is probably not what you are looking for. The master  is your problem. Rename it to main . I wrote Git My Way about two years ago. Today I created another Github repository. I got this  "fatal: Couldn't find remote ref master"  error message when I wanted to sync the new repo for the first time with my notebook using the notes I wrote in the blog. All the discussions around the error message I found on the Internet were perplexing. Then I recalled that Github had renamed master to main  due to the master-slave connotation. We always have a master copy of a code, never a slave copy. Now suddenly a word context has been diminished for good. What is going to happen to the existing va...

Welcome to the Era of Living Cell Programming

I was reading Understanding mRNA COVID-19 Vaccines by the United States Centers of Disease Control and Prevention when it stunned me that living cell can be programmed in vivo . mRNA COVID-19 vaccines are produced by Pfizer and Moderna . I already knew what Ribonucleic acid (RNA) is. RNA is almost a half part of DNA the super-intelligent organic codes that manifest us. But I didn't know that they can produce messenger RNA (mRNA) which can instruct cells to do whatever they wanted. This is my understanding so far. mRNA vaccines instruct our cells to make a protein and then triggers antibodies to kill the protein. In the case of mRNA COVID-19 vaccines it will instruct our cells to make a part of the virus proteins which is harmless to our body but sufficient enough to trigger the antibodies. Later when the real virus enters our body the trained antibodies will kill it. mRNA is a new kind of medicinal system. An mRNA can be sequenced or programmed to instruct a cell to make all sort...

Sub-Domain Pointing into a Drupal Sub-Folder

You will get the Forbidden error message when you try to access a folder which is not a part of Drupal. I got that error message when I created a subdomain which was pointing to a folder inside a Drupal installation. At first, I wasn't thinking about Drupal and I was looking for a solution in a wrong direction until I realized the Drupal's strict .htaccess . Then, I came across a Drupal Answer -  Make a folder inside the drupal installation public . The solution is that you need to configure Drupal .htaccess to ignore the sub-folder for the sub-domain. Add a rewrite condition to ignore the sub-folder somewhere near the rewrite rule for index.php : RewriteCond %{REQUEST_URI} !^/your-sub-folder/ ... RewriteRule ^ index.php [L] And since the sub-folder is being influenced by the Drupal rewrite rules so the sub-folder needs to have its own rewrite rules. Add the following .htaccess file to the sub-folder: <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /your-sub...

The Essence of Blockchain

A blockchain is a chronicle of signatures . Everyone can see the signatures but no one can afford to alter them. As a new block of signatures joins in as time passes the blockchain security as a whole becomes stronger. Blockchain is protected by public cryptography with no need of a central supervision. By design, altering any of the signature will be a very expensive undertaking. So expensive as comparable to the cost of breaking a vault of gold, which act of breaking in is much more expensive than the gold itself. All signatures are well-verified prior to being kept secured into a blockchain. Hence, all signatures in a blockchain can be trusted without requiring any third party verification. The principle of blockchain was made popular through the Bitcoin  whitepaper  by an illusive Satoshi Nakamoto . Even though the two words block and chain were never mentioned as one word in the whitepaper the essence of blockchain was described through out the document. The Bitcoin b...