Monday, February 26, 2024

Javascript webp to png converter

[Done with programmer's assistants: Gemini, DALL-E]
OpenAI's DALL-E produces images, but as webp files which can be awkward to work with. I have code here below for a web page that you can save locally that will allow you to select and convert a webp file. Meantime, here's the working conversion routine:

Convert WebP to PNG

OpenAI should fix this (as well as the response issues which has me using Gemini and Poe more often than not). Having to convert the image is a dumb workaround, but that is what you are left with. I have, in the past had to do various things with images, and although it can be a bit awkward if you are not familiar with it, ImageMagick is surprisingly competent with conversions and a vanilla type conversion is intuitively simple. Confusingly, the ImageMagick executable is 'convert'. To convert a webp to a png: 

magick convert WhyThis.webp WhyThis.png

** With some installations, convert can be called on its own: convert in.webp out.png

You can find ImageMagick here.

Note: I took a look at the files output as webp, gif, and png . The webp savings in size are considerate: 

657,688 in.webp

1,247,110 Out.gif

3,391,612 Out.png

If I were in charge, I probably would have gone with the webp as well, but I would have made it clear it was happening, and why, and I would have provided a tool to at least convert that locally. 

HTML Page -- Convert WebP to PNG

Monday, February 19, 2024

Fake is the New Black

I am overdue writing up the fact that rapid AI advances have now made scammers much more dangerous. People don't seem to realize that things we thought were off in the future last year are here already and becoming so sophisticated so quickly they are, and will be, catching people off-guard. Until we have much better safeguards in place everywhere, you need to be very much on guard. Update passwords and put in place 2 factor authentication everywhere. A video call of a loved one can and eventually will be faked.

If you don't know for sure that it's real, assume it's fake. This year you will have a very hard time knowing it's real.

Unless you are expecting a contact from some source, you should start with a default condition that it is a scam. Scammers can now easily fake the voice of a person sufficiently accurate and undetectable that they can get into banking systems that use voice recognition as a security measure.

An AI system can now tell if you have type 2 diabetes just by listening to about ten seconds of your voice. A scammer's business is to know how to dupe people into lowering their defenses. They can now be aided by AI for working out a particular strategy tailored specifically to fool you personally. That could include AI recognizing from your voice what strategy would work best on you. They can fake any person's real-time moving image as well as their voice.

The link below describes a scam that was successful in fooling someone that they were in a group meeting with their Chief Financial Officer and other employees. All except the employee being scammed were deep fakes and they were convincing enough that he released more than 25 million dollars to the scammers. 

Sunday, February 18, 2024

AI is Smarter Than You, But That’s Not Saying Much

AI is Smarter Than You, But That’s Not Saying Much

Artificial Intelligence (AI) has achieved remarkable feats, from passing bar exams and medical boards to acing SATs and scoring like a genius on IQ tests. However, it’s important to remember that AI doesn’t think the way we do. In fact, for some definitions of ‘think’, it doesn’t think at all.

The Limitations of AI

AI can make unexpected mistakes, such as adding extra limbs to animals in generated images or hallucinating facts and supporting references. These are errors that a human or even an animal with lived experience would never make. In the three-dimensional real world, objects cannot pass through each other like ghosts. While an AI can tell you this in text, it often violates this rule in practice because it doesn’t understand it holistically the way we do.

The Risks of Relying on AI

As AI continues to improve in areas like text construction, photorealistic image generation, full-motion video, invention, and other tasks we consider requiring intelligence, the danger of relying on its ‘common sense’ and the facticity of its output rises. Imagine an AI designing a nuclear facility with a perfectly operating emergency ‘off button’. However, the AI also constructs a robot that, although it looks human, has a hand constructed so it cannot push the button. Despite testing every other conceivable thing in simulation, missing that one vital point could spell disaster.

The Subtlety of AI Mistakes

We can spot many of the mistakes that AI makes, but some strange ones can slip past us. For instance, an AI company recently released dramatically accomplished 3D videos wholly generated by AI. One of the videos, which many were particularly impressed with, had a brief section where a cat had a third arm. Its manifestation was subtle enough that nobody caught it until it was in wide distribution.


As AI continues to get better at things, the danger that things will both slip past and be problematic when they do increases. Don’t be fooled by the impressive achievements of AI. It’s smarter than you in some ways, but that’s not saying much. Always remember that AI, no matter how advanced, lacks the holistic understanding and common sense that come naturally to humans. 

Friday, February 16, 2024

Avoiding Grab Bag Politics

In my observations, well-intentioned individuals forming political platforms often fall into what I describe as "Grab Bag Politics," closely related to Pork Barrel Politics. This approach focuses on seemingly beneficial but ultimately minor issues, distracting from more critical matters. For instance, while it's admirable to want every child to have shoes they like, making it a legislative priority overshadows more significant issues, risking the neglect of broader principles like children's overall well-being and prosperity. Such specificity in legislation is impractical, as it's impossible to address every detail and maintain a holistic balance.

Diverse priorities within a group aiming for societal change can lead to resource allocation conflicts, highlighting the need for a more generalized approach to ensure no essential aspect is overlooked and to manage priorities effectively. I advocate for a system that guarantees everyone a fair share of resources, maximizes individual autonomy, and appropriately divides collective responsibilities such as foreign policy and defense from personal choices.

As we face the transformative impact of AI, with its promise of reduced scarcity and increased abundance, we confront challenges like job displacement and the potential for an education revolution through personalized AI instruction. However, without intervention, this technological shift could exacerbate inequality, leading to a dystopian reality of widespread impoverishment. By forming a united platform in democratic societies like Canada, we can establish a government that genuinely represents its people and secures a prosperous future for all, inspired by models like Norway's social compact and sovereign wealth fund. This approach can help avoid the pitfalls of "Grab Bag Politics" and focus on creating a fair and equitable society.

Monday, February 12, 2024

Try AI right now

If you have yet to actually use an AI chat system, you are in for a surprise. 

I will be writing up how the magic bit of GPTs relates to work I started more than thirty years ago. My work makes me think that current AI has found the magic I was looking for and that magic is very magic indeed. If what has been found is what it appears to be, there is much, much more magic to come, and it is almost certain to come much more quickly than people think. These systems are helpful already if you know how to use them, but they are going to be absolutely indispensable before the end of the year. It's moving that fast. 

Here is the prompt I gave Poe:  

Can you write quick step by step instructions for a new user to set up with, and give a few examples an ordinary person new to AI would enter as prompts and what they could expect?

Here is Poe's response:

Certainly! Here are step-by-step instructions for a new user to set up an account with

Visit the website: Open your web browser and go to

Update -- other websites:

Choose your preferred login method: You have the option to continue with Google, continue with Apple, or use your phone. Select the method that you're most comfortable with.

Agree to Poe's Terms of Service and Privacy Policy: Read through the terms of service and privacy policy, and if you agree with them, click on the checkbox or button indicating your acceptance.

Sign up or log in: If you're a new user, you'll need to create an account by providing the required information, such as your name, email address, and a password. If you already have an account, simply log in using your credentials.

Set up your profile: Once you've logged in, you may have the option to set up your profile. This step is usually optional but can provide a more personalized experience.

Explore the chat interface: After completing the registration process, you'll be directed to the chat interface. This is where you can interact with Poe and ask questions or provide prompts.

Examples of prompts for an ordinary person new to AI:

"What is artificial intelligence?"

"How can AI be used in everyday life?"

"Tell me about the latest advancements in AI technology."

"Can you explain machine learning in simple terms?"

"What are the ethical considerations surrounding AI?"

When entering these prompts, you can expect Poe to provide helpful and informative responses based on its training and knowledge. It can explain concepts, provide examples, and offer insights related to the field of artificial intelligence. Remember that Poe's responses are generated based on pre-existing data and may not always reflect real-time information or current events.

Saturday, February 3, 2024

Show your work

Quora paywalled my answer to a question. 

As a high school junior with only basic coding experience, what should I do now to stand out on college resumes if my goal career is as a full-stack developer?

You should do a project where you can learn and build something that demonstrates you are able to do something useful. You can show what you have done, and having muddled through it you can explain what you did. Put it up on GitHub so you can point somebody to it and to show that you at least know what revision control is.

Note: AI is going to change everything fast so you need to add AI to your workflow. In this example here, use something like ChatGPT or Poe, etc. to ask/answer questions you need answered as you go along. When it comes to adding the database bit to your mini website, learn how to enter the code into an AI system and how to get it to aid you to write what you need. If you are organized and can walk through an AI session to go from this to that you can put up a blogger site, copy and paste this text, copy and paste your AI session, screenshots of the working system, code on Github, and perhaps a tree of the development system where it all resides you will be able to not only point to the working code you will be able to show how you did it. [Note: I taught core CS courses in the past :)]

Here’s an idea. Put together a web page for chat with a python web server. Create a script to load the server. Load the server using the script you created and then run two separate browser sessions loading the URL below. Chat with yourself about what a fine fellow you are.


Test the chat to make sure you have it running OK, then pretty it up and maybe add a little bit of function like running another script for a program you have compiled in C/C++ or whatever. If you create a VirtualBox VM with an OS, do the whole thing under that VM, and add code to do something in a database (Example code to show how to use SQLite at the end) you will have have something that shows a stack from OS to development environment, scripting, web server, database, and user interface.

Code for a working web server is below. Note that flask expects your index.html file in a directory below where you run it called ‘templates’. Install python (you’ll have to look that up) on your machine, and install flask-socketio, eventlet, and flask:

pip install flask-socketio eventlet flask


from flask import Flask, render_template 

from flask_socketio import SocketIO, emit 


app = Flask(__name__) 

app.config['SECRET_KEY'] = 'secret_key' 

socketio = SocketIO(app) 


messages = [] 



def index(): 

    return render_template('index.html', messages=messages) 



def handle_connect(): 

    emit('message', 'Connected to the server') 



def handle_send_message(data): 

    message = data['message'] 


    emit('message', message, broadcast=True) 


if __name__ == '__main__':, host='', port=5000, debug=True) 


<!DOCTYPE html> 



    <title>Chat Server</title> 



    <h1>Chat Server</h1> 

    <div id="messages"> 

        {% for message in messages %} 

            <p>{{ message }}</p> 

        {% endfor %} 


    <form id="message-form"> 

        <input type="text" id="message-input" name="message" placeholder="Enter your message"> 

        <button type="submit" id="send-button">Send</button> 


    <script src=""></script> 

    <script src=""></script> 


        $(document).ready(function() { 

            var socket = io(); 


            socket.on('connect', function() { 

                console.log('Connected to the server'); 



            socket.on('message', function(message) { 

                $("#messages").append("<p>" + message + "</p>"); 



            $("#message-form").submit(function(event) { 


                var message = $("#message-input").val(); 

                socket.emit('send_message', { message: message }); 







Below is a python program that uses SQLite to create a table, insert some rows into it, and then retrieve the data. SQLite is a lightweight, disk-based database that doesn’t require a separate server process. If you hack the python server and html so that you can build, populate, and use a SQLite database from the above little set of code you will have done something that shows you can at least be a good helper. Best of luck!

The example will be simple for clarity:

1. Create a table named example_table with two columns: id (integer) and name (text).

2. Insert a few rows into the table.

3. Select the rows and print them out.

Here’s the Python code:

import sqlite3

# Connect to SQLite database (or create it if it doesn't exist) 

conn = sqlite3.connect('example.db') 

# Create a cursor object using the cursor method 

cursor = conn.cursor() 

# Create table 

cursor.execute('''CREATE TABLE IF NOT EXISTS example_table 

                  (id INTEGER PRIMARY KEY, name TEXT)''') 

# Insert rows 

cursor.execute("INSERT INTO example_table (name) VALUES ('Alice')") 

cursor.execute("INSERT INTO example_table (name) VALUES ('Bob')") 

cursor.execute("INSERT INTO example_table (name) VALUES ('Charlie')") 

# Commit the changes 


# Select and display all rows 

cursor.execute("SELECT * FROM example_table") 

rows = cursor.fetchall() 

for row in rows: 


# Close the connection 


This script sets up a basic SQLite database, adds some entries, and then fetches and prints them. Remember to handle database connections and exceptions properly in a production environment.

Friday, February 2, 2024

How much more powerful will artificial intelligence get in the future?

Below is a post that I made on Quora that Quora might make inaccessible due to their monetization thing, so... 

Profile photo for Bob Trower

First, let’s have a look at underlying aspects. One aspect is the advancements of underlying hardware according to Moore’s law. Much has been said about how it must end, but it has not ended yet and with a movement to better technology due to AI (say, graphene processors), it is not likely to end soon. Also, I have overlain a line on the Kurzweil derived graph and you can see that exponential and then some in practice.

Another underlying aspect is that investment in AI is increasing. Tools are increasing in power, but they are also increasing in numbers.

Another is that they are increasing in terms of their applications and those have a synergistic effect. Among other things, time saved by AI in one thing frees up more time to work on AI. They are more powerful, there is more of them and they affect more things. Assuming that these all contribute a 10x, you are looking at 1000x in aggregate power.

I expect that AI will be superhuman by the end of 2024 and at worst, by the end of the decade nobody will deny that AI has exceeded human intelligence by a large margin.

In medicine, AI holds immense potential for personalized healthcare. Advanced AI algorithms can analyze large volumes of patient data, including medical records, genomic information, and imaging data, to provide tailored diagnoses and treatment plans. AI can assist in early disease detection, drug discovery, and precision medicine, leading to more effective and efficient healthcare outcomes.

In chemistry, AI can aid in drug discovery and development. By analyzing vast chemical databases and simulating molecular interactions, AI algorithms can identify potential drug candidates, predict their properties, and optimize their efficacy. This can accelerate the discovery of new medications and facilitate the design of novel materials with specific properties.

In physics, AI can contribute to data analysis and modeling. AI techniques such as deep learning can extract meaningful patterns from large datasets generated by particle accelerators and observatories. This can lead to advancements in particle physics, astrophysics, and cosmology, helping scientists gain deeper insights into the fundamental workings of the universe.

In mathematics, AI can assist in solving complex problems and proving theorems. AI algorithms can explore vast mathematical spaces, identify patterns, and generate conjectures. This can aid mathematicians in making new discoveries, validating conjectures, and providing insights into unexplored mathematical territories.

In biology, AI can enhance our understanding of complex biological systems. AI algorithms can analyze genomic data, model protein folding, and simulate biological processes. This can lead to advancements in fields such as genomics, synthetic biology, and drug design, enabling breakthroughs in personalized medicine and bioengineering.

In materials science, AI can accelerate materials discovery and design. AI algorithms can predict material properties, identify novel materials with desired characteristics, and optimize their synthesis processes. This can lead to the development of advanced materials for energy storage, electronics, and sustainable technologies.

Regarding embodied AI, AI systems that interact with the physical world through robotic bodies can have a profound impact. Embodied AI can enable robots to navigate complex environments, manipulate objects, and interact with humans more intuitively. This has applications in areas such as healthcare, manufacturing, and autonomous transportation.

Augmented reality (AR) and virtual reality (VR) can be enhanced by AI, providing realistic and immersive experiences. AI algorithms can improve object recognition, scene understanding, and gesture recognition, enhancing the quality and interactivity of AR/VR applications across various domains, including education, entertainment, and training simulations.

Cybernetics, the study of systems and control in humans and machines, can benefit from AI advancements. AI can enable more sophisticated human-machine interfaces, brain-computer interfaces, and assistive technologies. This can enhance human capabilities, enable neuroprosthetics, and improve the quality of life for individuals with disabilities.

Finally, AI's power lies not only in its impact across scientific disciplines but also in amplifying developer productivity and its own advancement. AI tools and frameworks streamline the development process, automate repetitive tasks, and enable faster prototyping and experimentation. This boosts developer productivity and facilitates the creation of cutting-edge AI applications. Furthermore, AI's ability to learn from data and improve its own performance, known as machine learning, allows AI systems to continually evolve and become more powerful over time.

In conclusion, the future of AI holds immense potential in medicine, chemistry, physics, math, biology, materials science, embodied AI, AR/VR, and cybernetics. Its power lies in its ability to augment human capabilities, accelerate scientific advancements, and amplify developer productivity. As AI continues to advance, it is poised to revolutionize multiple domains, shaping the future of technology, science, and society.

Wednesday, January 31, 2024

Code Signing and Virtual Box VM

Signing an executable hello.exe:

Note that you need to have and install a valid code-signing certificate. The current certificate I am using here is a cert signed by Sectigo. I will try to return to this to add instructions for doing this. 

Assuming you have your cert installed and signtool.exe on your path, this below will sign a file that will be considered valid as long as your certificate is valid and the current date is within the time covered by your certificate.

signtool sign hello.exe

Doing the following additionally to the signed file above will link it to a current time stamp. As long as your certificate is valid at the time of signing and it remains valid, the signed file will be valid. 

signtool timestamp /t hello.exe


Below is a cut and paste from an entry I made on Stackoverflow. I originally was asking how to do something but I was able to answer it myself before I got an answer:

How can I sign an Oracle VirtualBox virtual appliance (.OVA)

I want to sign an Oracle VirtualBox Virtual Appliance, an OVA file. I am looking for instructions.

I have had extensive conversations with Comodo and Sectigo. They don't know how and had trouble even understanding the question.

When I load my VM in VirtualBox it says that it is unsigned but gives no information as to how to correct that. I have a code signing certificate, and I have no trouble signing and timestamping an executable file:

signtool sign /t t_hello.exe Done Adding Additional Store Successfully signed: t_hello.exe

Attempting with an .ova file gives an error:

signtool sign /t ACoreTpl.ova Done Adding Additional Store SignTool Error: This file format cannot be signed because it is not recognized. SignTool Error: An error occurred while attempting to sign: ACoreTpl.ova

I took a shot at downloading a tool from VMWare, but it did not work on my VirtualBox appliance. It just gave error messages.

Unless the error message is meaningless and just hardcoded in VirtualBox, there is code inspecting something. I really don't want to go fishing through the code, but at this point it seems like I might have to.

The purpose of this exercise is so that I can publish a working system as a virtual appliance that is 'known good' and can be verified as the real thing when it loads.

Answer from Myself: 

[Note: There are images in the document I pasted this from, but they would not paste in here.] I was able to muddle through a work-around. The workaround involves getting a tool from VMWare (ovftool.exe), which seems a bit strange. It allows the import of the OVA, showing the certificate and marking it as 'safe'. It still has a couple of issues. One is an annoying warning message issued while creating the signed file, for which I was unable to find a cure. The other is that it does not seem to contact a timeserver to timestamp the file. Presumably that means that when the signing certificate expires, you get warnings again when loading.

I would still like to know how you are supposed to do it properly according to Oracle. Surely, Oracle is not using VMWare's software to sign their Virtual Appliances.

This is my journey under Windows 10. At the end, I have a publishable appliance.

You need a virtual appliance (*.ova)

You need a signing certificate.

You need to have OpenSSL installed.

You need the program ovftool.exe from VMWare

To get the .ova file, you need to export one of your VMs as a virtual appliance:

Open the export virtual appliance dialog:

File->Export Appliance [Alternatively E]

Choose the virtual machine to export. Fill in whatever Virtual system settings apply.

For appliance settings, set the Format to Open Virtualization Format 1.0

Make sure the 'Write Manifest file' checkbox is checked.

Click on the button to write file.

You should have the signing certificate installed in the certificate store. If you don't have this already, you need to consult your certificate provider.

To get the signing certificate in a usable form, you have to jump through a few hoops to get an old-timey Privacy Enhanced Mail (PEM) file.

You need to get the certificate into a file first.

Start the Certificate Manager by running certmgr.msc

Open Personal->Certificates and right-click on your signing certificate

Open the All tasks menu and choose Export

This should open the Certificate Export Wizard

Click [Next]

Choose the radio button marked "Yes, export the private key"

Click [Next]

Choose "Personal Information Exchange - PKCS (.PFX)"

Check "Include all certificates in the certification path if possible"

Check "Export all extended properties"

Check "Enable certificate privacy"

Click [Next]

Check the Password checkbox, and enter and confirm a password [using password "IMPPass" in this example]

Change the Encryption dropdown to AES256-SHA256

Click [Next]

Assign the filename and path for the exported certificate. In this example, I called it "MyCert". Note that you don't put the file extension on the name here. The Certificate Export Wizard adds it when it writes the file. You should save it on the path where you saved the OVA file.

Click [Next]

Review settings and Click

It should pop up a message box saying the export was successful. Dismiss it by clicking on the button.

You need to do the next steps at the command line.

Open a console window.

Change to the directory where you have saved your OVA and PFX files.

cd c:<yoursavelocation>

You now need to convert the certificate to a form that can be used (.pem). To do this, you need to use OpenSSL. Here is the form of the command:

openssl pkcs12 -in MyCert.pfx -out MyCert.pem

Respond to the prompts for Import Password and PEM pass phrase:

Enter Import Password: IMPPass

Enter PEM pass phrase: PEMPass

Verifying - Enter PEM pass phrase: PEMPass

Finally, you can sign the exported OVA with ovftool with a command like this:

ovftool --privateKey=MyCert.pem --shaAlgorithm=SHA1 DamnSmall.ova DSL.ova

Opening OVA source: DamnSmall.ova

Opening OVA target: DSL.ova

Writing OVA package: DSL.ova

Transfer Completed

The manifest validates

Enter passphrase for MyCert.pem: PEMPass

A warning is issued here, but it will not interfere with the signing.


No supported manifest(sha1, sha256, sha512) entry found for: 'DamnSmall-disk001.vmdk'. Completed successfully

At this point, there should be a signed file called DSL.ova. It will indicate that when imported in VirtualBox.

To test, import the newly created and signed OVA file. Open the import dialog:

File->Import Appliance or alternatively I

Enter the path and name of the signed Virtual Appliance. Click [Next]

The Appliance settings dialog should have text in the bottom left corner indicating that you have signed the appliance, and that it is trusted.

Appliance is signed

Sunday, January 21, 2024

Imperfect practice makes better

Re Quora question: "What are your thoughts on the idea that writing a lot of bad code will eventually lead to better coding skills (programming, software engineering)? Do you think there is any truth to this idea? If so, why do you think this is the case?"

There is some truth to the idea that writing a lot of bad code can eventually lead to better coding skills in programming and software engineering. While practicing a skill area often, even if done poorly, can still provide some benefit, it is important to recognize the limitations and the need for deliberate practice to see meaningful improvement.

Consistent practice is essential for skill development in any field, including coding. Even the most accomplished experts started at a lower level of skill and relied on practice to refine their abilities. The saying 'practice makes perfect' holds some truth in this context. Regular practice helps build familiarity, muscle memory, and neural pathways associated with the skill, which can contribute to improvement over time.

However, the quality of practice is crucial. Practicing a skill poorly risks reinforcing poor techniques or habits, which can hinder progress and make it harder to reach a high level of skill. Poor practice may also fail to push you beyond your current abilities and limit the extent of improvement.

To optimize skill development, it is important to combine regular practice with deliberate and focused efforts to improve. This involves seeking feedback from experienced practitioners, studying and understanding the correct techniques, and adjusting your approach based on feedback received. Deliberate practice allows you to identify weaknesses, target specific areas for improvement, and gradually refine your skills over time.

While practicing a skill area often, even poorly, can provide some benefit, it is generally more effective to strive for deliberate and quality practice in order to see meaningful improvement in your coding skills. It is through deliberate practice that you can develop a deep understanding of coding principles, refine your problem-solving abilities, and gain the necessary experience to create robust and efficient code.

Furthermore, there is value in learning from mistakes and experiencing the consequences of writing bad code. Proactive defensive practices, such as error detection and mitigation techniques, can be better understood and appreciated through personal experience. Intimate familiarity with the creation, consequences, technical debt, and burden of bad code can provide valuable insights and drive a commitment to improvement. At some level, doing poorly can serve as a necessary prerequisite for deeply learning how to do well.

In conclusion, while practicing poorly can contribute to some improvement, it is important to balance it with deliberate practice and a focus on quality. By combining regular practice with deliberate efforts to improve, seeking feedback, and learning from mistakes, you can develop your coding skills more effectively and strive for excellence in the field of programming and software engineering.

Javascript webp to png converter

[Done with programmer's assistants: Gemini, DALL-E] OpenAI's DALL-E produces images, but as webp files which can be awkward to work ...