Computing
This page is for consolidating brief tips and commentary about computing topics, particularly current items. Longer articles reside in their own blog entries.
Computer Industry
In This Section... Articles · A.I. · CPU Comparison · Software: Mission Creep · The "Tragedy of the Common" Internet
Articles
Those important, longer articles on computer and I.T. matters, can be accessed through this link: Computing Articles
A.I.
For purposes of pumping stock and creating a next "big thing" they can profit off of, "Artificial Intelligence" is the latest ploy. There's a new video out about how the new Google A.I. "scared its creators," with how smart it was. Not going to dignify it with so much as a link. This is not the first time they've played this line from their limited playbook. Perhaps the choicest user comment: "People aren't realizing the reason the Terminator turned against people was because the Skynet felt threatened..."
There's an extensive, technical blog on A.I., Stop Killer Robots Now! — The A.I. Blog, so to avoid being bamboozled, you'll want to read that comprehensive report.
CPU Comparison
Curious about how one might pick between different CPUs (computer processors) when buying a computer, I dug up these articles.Well, that's overkill, it's overwhelming. It doesn't really tell us bugger all. Yes we could guess the higher numbers/higher-priced processors are the best, the i9 is going to be better than the i3, and so on, but that's not really what most people need to know.
Don't give me that, "Everyone needs something different" BS, there's probably one or two processors from each company that are the best for everyone except specialized users, a sweet spot.
It would have been nice to start with or include a chart of price/performance, but there are several factors in performance, as they demonstrate. I guess if you're selecting a computer, it's still a good idea to run an online benchmark — if you can find a good one, and remember to, when you're in the stressful midst of shopping. Maybe make a checklist of things to verify when selecting a new machine, and include, "run benchmark" on the list.
It seems it would be a great exercise for someplace like Tom's Hardware to do its own benchmark with dynamic charting, so when you run your machine it shows where on the graph of CPU rankings your own tested machine rates. As well, they should highlight the "sweet spot" areas on the charts. This could be selectable, "If your priority is gaming, click here to highlight the best, if your priority is general use..." It might be of interest to contact Tom's and request they do this, but I strangely got a 404 - Not Found when clicking on their "Contact" page, LOL.
This isn't the Tom's of old. Tom's has been commandeered by some big corporation, it seems, and when you do get to a corporate contact page it's all about services they offer. Talk about the Umbrella Corporation taking over, with the corresponding zombies.
Software: Mission Creep
Something unseen by most people is the complexity of software programming, which continues its wild ride into excess. There is a serious problem with the approach to programming. They add features, subtract features, and sometimes it's overwhelming — or unnerving. The biggest problem was and continues to be, of course, the folly and twisted mindset where languages like C#, and JavaScript are ever more complicated with each version, when the exact reverse should be happening.
Genius generally lies in simplification, not complication, which is why things get so complicated over time. There are few geniuses to come in and clean things up. Fault lies in not recognizing the simple facts: People are very limited in their capabilities, but unfettered in their ego, so they think they can do anything when they can do something. A perfect example is when "old-time, traditionalist" programmers didn't like the idea of garbage collection done by the computer programming language automatically, without having to be coded by giving the computer instruction when to do so ("garbage collection" in computer programming is simply the name for freeing up internal computer memory when that area of memory is no longer being used by a program).
The whole point of computers is automation, but they objected to automation, thinking it made then somehow "better programmers," or "more authoritative," or, worst of all, "more hardcore," *groan*, to take on the unnecessary burden, which is nonsense. It usually means that the authors/programmers don't understand it themselves when complication piles on complication, instead of seeking better, easier solutions. There are limitations of knowledge and ability even among the most skilled, and we need to constantly review and re-work and simplify to address that. In fact, there's a term that in coding that recently acquired wider use, refactoring, to describe rewriting and cleaning up software.
It's sometimes tough understanding how and why anything in computing works at all, the way it's all cobbled together. Things are getting worse rather than better, as new complications in coding come out, you see many websites that are pretty sad states of affairs, as people try to adapt things not fully understood.
Here's a dirty secret about programming: It's mostly a patchwork. People come in and patch together a solution, and hope the changes don't affect something else adversely. But it's too costly and time-consuming and inconvenient in most cases to start from scratch. And, starting from scratch will often mean you get something worse than the old system!
But why care about that? That's their problem. Except it's not, when it affects you and your data is stolen or something goes wrong in an application that inconveniences you or causes you problems. Or, if you run a company, you pay immensely for this type of nonsense.
We have to wonder how much time, energy, effort and money is wasted on bad programming, wasted efforts, dead-ends and the like. It's like other scenes of waste in the world: We all end up paying for it in the end, usually through higher prices.
More than that, often something is extended and overextended to do things that are necessary, but beyond the original scope and intent of the program or system.
Another problem: There's no need for endless complication, but there is a perverse desire for people to continue with something and add complication past the point of rationality.
It comes back to bite them, like in the case of Microsoft, it can't even maintain its own browser, or produce a new one. The old browser, Internet Explorer, always was a worthless piece of Billcrap. The new browser, Edge, isn't anything new at all. It's a "port." It's a "reskin." It's actually Google Chromium browser, disguised!
Yes, the biggest software company, revenue of $143 billion in 2020, can't even produce its own browser, but the shills are out there, doing comparisons of which one is "better!"
Edge and Chrome are built on the Chromium open-source browser using the Blink rendering engine. So you can see original software development is overwhelming, even for big companies.
Horrors of Programming
Software needs simplification, not complication. So of course, it becomes insanely complex.
Cars, overly complex now, have gotten to the point they're almost irreparable. A complaint about German luxury cars to a German mechanic was met with the response that they're only supposed to last four or five years anyway.
There are a lot of best practices, but if you go to work in this field, it's all just, "get it done as fast as possible."
The "Tragedy of the Common" Internet
The "tragedy of the commons," refers to people exploiting things they have no ownership interest in but are "up for grabs," as common holdings (like over-fishing lakes or the ocean). And the internet is this new, fantastic resource. But it suffers from a sort of "tragedy of the commons," with stuff getting outdated, broken links, ads disguised as information...
A more curable problem with the web, is the problem of no dates on things, or files not kept up to date.
A simple fix would be to add new HTML tags to the spec to notify search engines and users the creation date and update date... Yes, after railing against added complexity, I am proposing yet another addition, but this is a pretty simple yet useful one. I propose something like an additional compulsory field for all HTML files that saves the creation date of the article, with perhaps another field to indicate last update. Then, browsers can post those dates beside the link. It's not a fanciful idea, it's an urgent one. This would be handy for developers, too.
Why couldn't search engines incorporate a feature that allows the user to rate a link, based on how useful and related to the search string it was, much the same as online video hosts have a "thumbs up/down" feature? Actually, it needs at least three ratings: Quality, relation to search string and whether or not it's an ad. There's a business opportunity for an ambitious developer.
Link Rot/Not Using Links
This is another real issue with the internet, that also could be addressed easily. It's another thing John Dvorak railed against, years ago, in the '80s and '90s.
Link Rot, where old links don't work, is annoying, because a lot of times this happens even for large corporations or newspapers, which are supposed to be reliable references. Well, in this case it depends on the developer/maintainer of the code to check for bad links periodically. It's a considerable amount of boring work that doesn't provide much, if any, return on investment.
Sometimes they want to cover up or hide things, so the linked article goes away.
Another annoyance is when links aren't used at all. Everyone's in a rush these days, and they might be skipped in an article. We already saw that I had to write to TuSimple, since the article about its product on ZeroHedge didn't include a link. This falls more under internet etiquette, it seems, but it's something for authors to consider when they're writing, so as not to waste their readers' time.
There's another thing: bare links. This is a link without corresponding information to help the user find any information lost due to a broken link. Avoiding bare links simply involves describing the context and where the link goes, in case it does break.
Utilities and Useful Software
In This Section... CopyQ · Perl & Sed
This area is for logging any programs or utilities that I've found useful over time.
CopyQ
Have you ever wished ctrl+C ctrl+P, (copy and paste) were more powerful, to be able to save a copy of more than one thing for later use? Try the CopyQ advanced clipboard manager that saves multiple cuts without overwriting. So you can go find something you cut or copied several items back, click on it, and paste it in. It's a great program, free for Linux, Mac and Windows.
Perl & Sed: Quick Guide to Using Perl for Search & Replace
I don't know why the command line utility, Sed, is needed at all, when there's Perl.
Perl is the way to go if you're doing search and replace, a superset of Sed, doing the same things but with greater functionality. So you probably won't want to even bother with the Sed utility, unless it's second nature due to past usage.
It's a very useful utility, but many of the explanations of how to use Perl are the most arcane and unhelpful guides I've come across. Anyway, after much work, I decided that a quick reference is needed for people in a hurry to get up to speed without misery, sort of a "cheat sheet."
It's an outline on using Perl to search and replace in files where the replacement might span multiple lines. It's worthwhile because that's a major use case for Perl. Why have to learn the whole syntax and jump through hoops just for that?
Now, "Perl" is a utility. What does that mean to me? Click a few buttons, maybe pick a file or two from a file browser, and be done with it.
Okay, so I thought, this Perl ought to be just the thing for a task where I wanted to insert and replace some text in a web page file (HTML file).
Not so fast! Perl is also a full-fledged programming language. That's why, at first, the documentation might as well be reading hieroglyphics.
Take a look at this abstract template example,
perl -0777 -i -pe 's/(\[FOO\][^\^]+)/$1\nsometext!sSOMETEXT/g' file.txt
Something to get us started, one of the simplest possible examples, is where we want to do a simple search and replace. For example, here we'll replace all instances of "John," with "Jackie."
This is the tale of John and his dog Tate. They went for a walk and John stopped at the shop for some items, and then John and Tate continued on their way.
You run the following script in the directory with John.txt, and it will produce Jackie.txt, leaving John.txt unchanged:
perl -0777pe 's#John#Jackie#g' John.txt > Jackie.txt
The result, in the file Jackie.txt, is:
This is the tale of Jackie and his dog Tate. They went for a walk and Jackie stopped at the shop for some items, and then Jackie and Tate continued on their way.
As an exercise, run it yourself — create a file with just the text in the file John.txt and copy it into a directory, then open a terminal in that directory, and paste in and run the Perl script. (All of the example text is click to select.)
Of course, you could use simple search & replace in most any text editor to do this for you, but you need Perl to handle complex situations, like the multiple lines of text (obviously you'll normally be running this on a file with multiple lines or you could do the replace manually), control characters, like, of course, newline, and with unknown numbers of characters, like when you might have multiple tabs or spaces.
Looking at our example, the important parts include the hashmarks to separate the search and replacement text, and the "g" at the end to indicate a global replace, which is to say all instances.
Now we'll look at an example Perl script that might be used to modify more complex HTML, in this case, code from an HTML table.
perl -0777pe 's#\<tr\>.*\n.*\<td height\=\"10\" align\=\"left\"#\<tr\>\n\t\t\<td height\=\"12\" title\=\"Adding a Title with Ampersand \&" align\=\"left\"#g' example.txt > result.txt
Here's your data, which you can put in a file called example.txt.
<tr> <td height="10" align="left" bgcolor="#CCCC99"><font color="#000000">Data 1</font></td> </tr> <tr> <td height="10" align="left" bgcolor="#FFFFCC"><font color="#333333">Data 2</font></td> </tr>
When you run the script in the same directory as the file, example.txt, you'll see the result file, result.txt, has changed the height value and has added a title.
The script seems complicated, so we'll go through piece-by-piece.
- perl -0777pe - calls Perl
- the -0777 is described in the documentation as follows: "The special value -00 will cause Perl to slurp files in paragraph mode. Any value -0400 or above will cause Perl to slurp files whole, but by convention the value -0777 is the one normally used for this purpose." In other words, just use that.
- the p tells Perl to cycle through each line
- the e means to run from command line (from the console)
- Note the entry of the options is flexible in that you can use, for example, -p -e or just -pe
- 's - indicates the start of your text search, and don't miss the leading single quote mark
- # - delimiter, indicates start (and end) of search string
- \<tr\> - we're looking for the HTML table row tag, and to find <tr> in our source file, we need the \ delimiter ahead of special characters, like < and >
- .*\n.* - here we're looking for and expecting a \n, newline character, but we don't know if we'll have any spaces or tabs before and after. With the .*, it acts as a wildcard to pass through and output all the characters before and after the newline.
- <td height\=\"10\" align\=\"left\"# - remainder of search string, looking for the table data tag, and descriptors for height and alignment. Note the backslashes \ before the = and " symbols. The hashmark, as explained, indicates the end of the search string.
- \<tr\>\n\t\t\<td height\=\"12\" title\=\"Adding a Title with Ampersand \&" align\=\"left\"# - our replace string is designed to add a title after the height property, and of course the & needs a leading backslash. The hashmark, again, indicates the end of the string.
- g' example.txt > result.txt - the g tells Perl, "globally replace every search string found, with the replacement string." Don't miss the trailing single quote mark right after the g to close off the command. The input file, example.txt is then given, then the > symbol, telling the program to direct results to the output file, called result.txt in our example.
Wildcards
. matches any character except newlines
* means zero or more times
? is used for matching as few characters as possible - this isn't used in our example, though
Option & Description
-p places a so-called "Printing loop" around your script, which just means it indicates to Perl to read in each line of standard input (the file)
-i tells Perl to edit the file in place, so you don't need to specify an output file
-w prints out warning messages in case something goes wrong
-e allows you to provide the program as an argument rather than in a file so you don't have to create a script file for a Perl one-liner, like our example
-s means literally, "search"
-g is "replace globally," that is, all occurrences. If we didn't include this, our example would just edit the first instance of the search string it found.
Characters
/ or # can be used to delimit the start and end - in our example, # is used
\ prefixes special characters to indicate them to Perl
And that should about cover all you need to conveniently use Perl for search and replace.
WordPress Tips
In This Section... Font Awesome · Plugin Pros & Cons · Plugin Notes Plus · Update PHP on WordPress Localhost
General tips and discoveries for WordPress software.
Font Awesome
Plugging Font Awesome icons into a WordPress site produces an interesting problem. It has always been peculiar that the Font Awesome site recommends using <i></i> to tag the icon. Using this tag, though, doesn't allow menu items to highlight, at least in the theme I used. Making them <span></span>, which you can do, fixes the problem!
It seems that using <i></i> tags is wrong. It never meant "icon," like some say, nor "italic," but that is how browsers always interpreted it; that is, they italicize the text within the open and close "i" tags. Technically, it means, "idiomatic" text, or text that is somehow set off from normal text. For example, a company name is often italicized so you are alerted that it is distinct from a regular word. Also, you used to always see foreign words italicized. But "idiomatic" shouldn't include icons — they aren't text.
Plugin Pros & Cons
Those very handy WordPress plugins are great, but not so great when they crash the site.
When they get abandoned by the creator and aren't kept up to date, that can be a major source of pain. Consider that plugins have to be generic, which means pack in a bunch of things that you probably don't need.
The solution? Add plugins for needed functionality, but replace them with your own code, when possible. Your own code won't have all the unnecessary overhead.
This hit home when I switched over to Blogger — I lost a lot of functionality, not easily reproduced on Blogger since it has no library of third-party plugins anymore. This means I had to start from scratch and lost some features on my blog until they can be replaced. If I'd already had my own replacement code, there'd be no loss. But now I'm finding that home-brew code can often be better tailored for what I need, and have less bloat. I'll report on this in the "Blogger (Blogspot) Tips" area below from time to time.
For big things like site backups, SEO, site protection, mail campaigns and subs, it's impractical to write your own solution. But it seems there are numerous plugins that do the job right and have been for some time, making it likely they'll continue to exist for a while, and not be buggy.
But it's good to keep track of what all your plugins do, and remove the unused ones ASAP. They say you should delete inactive plugins, but some you only need once in a while, but don't want to uninstall and reinstall when you need them. I kept several like that, only to be activated when required, and things seemed to work fine.
Plugin Notes Plus
To keep those details, like noting plugins for potential removal, there's a useful plugin, called Plugin Notes Plus, that, as the name implies, lets you keep notes on each plugin. It's really an essential tool for WordPress.
Set It & Forgot It: Update Your PHP Version on WordPress Localhost
This won't be of interest, unless having to locally configure WordPress and update its PHP.
Many times, you'll run a LAMP or WAMP bundle like XAMPP, which bundles Apache, MySQL, Perl and PHP, and provides a control panel, especially on Windows. On Linux, it's fairly easy just to install these programs separately. Anyway, these details are only of interest to WordPress admins, running Linux. The steps here are for Linux, but similar for Windows.
I had a problem with Apache (server software), because you set it and forget it. I had to update a local WordPress site and had the new Apache version installed, but it wasn't picking it up in WordPress. I looked for a configuration in WordPress, but nothing. WordPress will just use whatever is active on your system.
There are only a few steps shown, for the very specific case of WordPress on Linux, localhost. When you're running a live site your service provider generally takes care of the details of updating things like the Apache host.
Of course you need to get the new PHP version, in this case PHP 8.0. The steps for that are well-documented and easily found via web search. Reminder: Perform the usual back up of your system and apply any updates.
Again, this is for a Linux system, but the principle is the same for any system using Apache.
linuxUser@client ~ $ sudo a2dismod php7.4 linuxUser@client ~ $ sudo a2enmod php8.0 linuxUser@client ~ $ sudo systemctl restart apache2
As shown, you turn off old Apache in your O/S, then set it to the new one. But I faced an issue: it wouldn't take, and it took a while to figure out the sticking point.
Sticking Point
My problem was in having updated to PHP 8.0, those updates wouldn't apply to WordPress. Once explicitly updated, something was stopping WordPress from picking up on 8.0. The sticking point was that I had confirmed the PHP version, and had disabled the version my system said was running, version 7.4. It turned out there was yet another version of PHP, 5.4, running. It looks like it automatically picks up and runs with whatever oldest version of PHP you have on your machine. It was necessary to specify a2dismod php5.4. After that was disabled, I went back into WordPress and finally it was picking up on version 8.0 of PHP (and not giving an "Update your PHP" message any more).
It's advisable to check your install, using the following command.
linuxUser@client ~ $ sudo systemctl status apache2.service
Blogger (Blogspot) Tips
In This Section... About Blogger · Coding
General tips and discoveries for Blogger software.
About Blogger
I've moved to Blogger, the Google-based blogging software, which will give me the opportunity to share any discoveries. They say it's "beginner's software," but if you want to do anything beyond the very basics, you need to get hands dirty with coding HTML, CSS and JavaScript. With WordPress, if you need to code something, it's somewhat more awkward, though that can be avoided to a large degree since there are plugins available for most anything you can think of.
Blogger's kind of refreshing, since it seems to provide enough to make a decent site, while avoiding the time-sink of the much more extensive, wide-ranging WordPress. The KISS principle in action. So far, I'm finding it's quicker to work with, and a little more satisfying in some ways.
Interesting to note, Blogger used to have many third-party plugins, they call "gadgets," but they locked all those out since too many were exploiting the system by making gadgets with malicious code, code that stole data, and so on. It has only retained a few basic, but important, Blogger-created gadgets.
Coding
Looks like the best way to add your CSS and JavaScript is in each individual blog file (for the most part, but universal styling for your entire site can still go in that obscure area Blogger provides for your CSS (Theme->Customize->Advanced->Body->Add CSS)). It's supposedly not good practice to code like that, but it seems to work best in Blogger. Also, it saves loading time to have what you only use on a particular page, on that page. As well, it is sometimes difficult to make JavaScript work at all when you add it directly to the entire block of HTML, or to one of the gadgets they provide.
Also, if Blogger crashes on you, it seems you lose all the code you added to the supposedly safe areas, so it's just prudent to localize your CSS & Javascript.
And then there's another big annoyance. Blogger has an overzealous checker for nuisance and malicious code and spam, and shuts down entire pages or posts arbitrarily, claiming that you have bad code somewhere (without specifying the location), even when you're clean. There is a link to have your code reassessed and that seems to be responsive. It's understandable that they need automated systems to perform checks like this, since Blogger hosts over half a million blogs, but it makes for a nuisance. Perhaps they should send a message like the following, before reacting hastily, "Our automated checker has detected some malicious code on your page, please review and correct it or it will be shut down. If there is no apparent malicious code, please forward the post/page for further review."