Friday, May 12, 2023

A CLI script to interact with ChatGPT via API

I built this script to find out how much faster would I be translating from the command line interface (CLI) using ChatGPT API versus translating from its web interface, and I was not disappointed. My new poetry book is coming up in English as well as in Spanish at once. Writing in both languages at the same time is test driven delivery (#TDD) because at the time I am done creating, I am also done with reviewed everything, and therefore it is ready to be shipped to my Editor. Exiting times in front of us with #LLMs. These engines are our best pals when it comes to productivity.

Saturday, April 29, 2023

ChatGPT does not get it yet - Learning is not about repeating, but instead about [critical] thinking.

I translated the two books that I have published so far from Spanish to English using #ChatGPT, and here is what I learned:

1. Agreed with that ChatGPT is a good translator for spoken language.
2. 37 problems in a total of 31,459 words. Not bad at all.
3. 9 of the problems were also present in DeepL. The rest were not.
4. ChatGPT can be instructed to keep the format, and with that convert dialogs in Spanish (which use quotation dashes) to dialogs in English (which use quotes).
5. However, DeepL autosuggestion feature is a productivity boost and with just 9 errors shown I think it is still a more effective way to translate in cases where respecting format is not a must-have.
6. If text is heavily formatted like for example XML variants like HTML, then ChatGPT is unable to keep all escaped XML entities like '&lt;'. Instead, it randomly keeps them or shows them as literals, like in this case '<'. Prompting more gets the engine in repeating mode, demonstrating that there is no creativity and no critical thinking in ChatGPT. This to me is a demonstration that the ultimate question scientists have to answer is *how* these models actually "learn" so that we can predict how they will "behave". Learning is not about repeating, but instead about [critical] thinking. We know why and how an atomic bomb works, but we don't fully understand why and how AI works.

I will report back when I finish my upcoming poetry book, which I will only publish once I have the final material in the two languages because ChatGPT has taught me a lesson: In reviewing multilingual content, an author finds better ways to say the same even in their own native/mother tongue.

Thursday, April 27, 2023

Wishful thinking versus scientific evidence

Plotted you see all the numbers for the first draw (ball) of all Megamillions ever played in Europe since Fri Feb 13, 2004 to Tue Apr 25, 2023. Do you see any pattern there? No, you can't. The reason is that these numbers are all random.

If there would be a pattern, then a #LLM like #ChatGPT would be able to find it, but there is none. Yet you get news like "Man makes headlines after winning the lottery with ChatGPT" with statements like "The winning amount was small, but the approach was impressive.".

Take any lottery in the world, line up any amount of wining numbers separated by commas and pipe them through the below python script to find out if you find any pattern. 

  1 import sys

  2 import matplotlib.pyplot as plt


  4 numbers = []

  5 for token in','):

  6     try:

  7         numbers.append(int(token.strip()))

  8     except ValueError:

  9         # ignore tokens that can't be converted to integers

 10         pass


 12 # Create a new figure and axis object

 13 fig, ax = plt.subplots()


 15 # Set the title of the plot

 16 ax.set_title("Input Numbers")


 18 # Set the labels for the X and Y axis

 19 ax.set_xlabel("Position")

 20 ax.set_ylabel("Number")


 22 # Plot the numbers as a line chart

 23 ax.plot(numbers)


 25 # Show the plot



 28 # Save the plot

 29 plt.savefig('plot.png')

If you find one, then you will be using scientific evidence that you can hit the jackpot. If you cannot, then use scientific evidence at a job and you will make a great living. Do not expect though that wishful thinking will get you far.

Having hope is great. We all need it. But nothing can replace the scientific method when it comes to making educated decisions.

Tuesday, March 07, 2023

Remove web page elements that match a certain xpath

Taking for example a bitbucket pull requests page and assuming that we want to hide all PRs tat contain the string JIRA-80 just copy and paste the below to the browser console and press enter
// 1. define the text string to search for as content of a tag
// 2. define the xpath string that matches the tr that contains a td that contains 5 nested divs that contain an anchor with tagContent 
// 3. define the xpath result object that contains all the ORDERED_NODE_SNAPSHOT_TYPE nodes that match the xpath string 
// 4. iterate the xpath result to hide each node in it
var tagContent='JIRA-80';
var xpath="//tr[td[div[div[div[div[div/a[contains(text(),'" + tagContent + "')]]]]]]]";
var xpathResult = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (let i = 0; i < xpathResult.snapshotLength; i++) {
  const xpathNode = xpathResult.snapshotItem(i); = 'none';
Obviously you can inspect the element you want to remove and select the "delete element" option from the chrome inspector "elements tab" but automating the deletion of the elements that you do not want by knowing the xpath of them saves lots of time.

Wednesday, February 22, 2023

wipe out all docker files to gain back hdd space

Warning: Use only if you understand in full what and why you actually need this:
docker stop $(docker ps -q)
docker system prune --volumes

Friday, February 17, 2023

On mobile security - prepare in advance to report your stolen or lost phone if that ever happens

Open your phone app and "call" *#06#

Once you type the last sharp sign you will get important data that uniquely identifies your phone.

Make sure to keep a screenshot of that screen handy to share with authorities in case you lose your phone.