Wednesday, November 06, 2024

Guy Fawkes night

It's a shame that Israel does not celebrate Guy Fawkes night because yesterday evening, 5 November, would have been the perfect timing for the modern equivalent of the Gunpowder plot. Instead of burning an effigy of Guy Fawkes in bonfires, many Israelis would have been only too pleased to burn an effigy of Binyamin Netanahu, our populist Prime Minister.

Why especially last night as opposed to many other nights over the past two years, you may ask. Because Prime (as his equivalent is referred to in the book 'Precipice' by Robert Harris that I recently read) once again fired his defense minister, this time doing it face to face with a 'termination of employment' letter in a meeting that apparently lasted three minutes. Gallant, the previous defense minister will be replaced by a puppet of Prime.

Quoting the Globes article referenced above, Netanyahu said, "In the midst of a war, more than ever, full trust is needed between the prime minister and minister of defense. Unfortunately, although in the first months of the war there was such trust and there was very productive work, in recent months that trust between the minister of defense and myself has been broken."

Whilst that might well be true, many people feel that Gallant was concerted with doing his job to the best of his ability - in other words, defending Israel and defeating its enemies. He was hampered by a Prime Minister who as always seems to be more interested in continuing his rule, whatever the cost. Let us not forget whose 'conception' was shattered a year ago.

As National Unity party leader MK Benny Gantz said in response,"This is politics at the expense of national security."

People took to the streets last night in a repeat of the previous "Night of Gallant"1 although it is doubtful whether these demonstrations will have any effect. This is when the effigy should have been burnt.

This political move comes after a very tense week in which it has been revealed that an advisor of Prime who lacks a sufficient security clearance has been leaking secret data to foreign newspapers. Also it appears that documents relating to cabinet discussions on defense have been doctored after the event. Another blot on the PM's secretariat.

Having a puppet for defense minister means that Prime will be able to remove much of the army's leadership, those who stood firm on the topic of enquiries into the management of the war, especially the events of 7 October. Gallant stood firm in defense of the army and wanted for heads to roll in the political circles should heads fall in the army. Now the politicians will not be called to account for their actions ... once again.

Where are our elections?

And talking of elections, at 10 am, 6 November 2024, it seems fairly certain that once again the American president will be that pig of a man, Donald Trump. I don't know who is emulating who, but Trump and Netanyahu is a marriage made in heaven -- and hell for all those who don't agree with them. Read Yuval No'ach Harari's latest book, "Nexus"2 for an explanation of populism.

I'm not a happy camper today.

Internal links
[1] 1596
[2] 1848



This day in history:

Blog #
Date
TitleTags
5906/11/2006
ShoppingVan der Graaf Generator, Peter Hammill, Musical instruments, Keyboard
21506/11/2009
Eliza Carthy, "Red"Morse, Eliza Carthy
30106/11/2010
Trains and mealsCooking, Trains, Slow cooker
108806/11/2017
Forty years agoPersonal, Sandy Denny, Heron
118306/11/2018
Intermediate thesis submitted!DBA
143606/11/2021
Opening Word from a thread and displaying a fileProgramming, Delphi, Threads
155006/11/2022
Appearances in my school's ChroniclesPersonal, Bristol Grammar School
185106/11/2024
More dopamineProgramming, Blog manager program

More dopamine

Following on from yesterday's blog1 about a slightly more complicated SQL query replacing iteration over a cursor, today I implemented the required change. It was a bit different from the code that I described yesterday as I already had the tag count and so did not need to use count (*) and group by.

While I was working on this, a solution popped into my mind for a problem that occurs only with the first blog of each month. Adding the blog itself is no problem - normally I do this when the 'this day in history' form is showing - but I receive the contents of the blog after having done this; frequently 'tomorrow'. In order to show the blog, I request all the blogs from 'the beginning of the current month', but since there is only one blog, the contents of the blog will be displayed instead of a list of blogs. But as there is no content yet, nothing gets displayed. Of course, I could request all the blogs from 'the beginning of the previous month', but then I get all the blogs that I don't necessarily want to see.

The solution - as always - is simple when it's formed. A new form displays a listing of the files that are in the directory that the program accesses - normally only one file will be there - the new one. The program reads the file name that will include the full directory name as well as the 'htm' suffix (e.g. 'c:\db programs\data\Perceptions dopamine rush.htm) and extracts the name of the blog entry itself ('dopamine rush'). It then checks to see that there is a blog entry with that title but with no contents, and if so, the regular code for reading the contents is executed, which also deletes the file after it has been read.

Once I had finished writing this, of course a new idea revealed itself that was very simple to implement: display the contents of the new blog entry. This will happen every time that I import contents, not only with this special case.

Internal links
[1] 1850



This day in history:

Blog #Date TitleTags
5906/11/2006ShoppingVan der Graaf Generator, Peter Hammill, Musical instruments, Keyboard
21506/11/2009Eliza Carthy, "Red"Morse, Eliza Carthy
30106/11/2010Trains and mealsCooking, Trains, Slow cooker
108806/11/2017Forty years agoPersonal, Sandy Denny, Heron
118306/11/2018Intermediate thesis submitted!DBA
143606/11/2021Opening Word from a thread and displaying a fileProgramming, Delphi, Threads
155006/11/2022Appearances in my school's ChroniclesPersonal, Bristol Grammar School

Tuesday, November 05, 2024

Dopamine rush

I'm currently reading the book "Coders: the making of a new tribe and the remaking of the world" by Clive Thompson. I initially thought that I had not read the book before, but evidently I have as I left digital notes throughout the book. I wonder whether the title of this book subconsciously inspired the title of my song, "Looking for his tribe". I'm sure that there's a line in the book about the dopamine rush that comes from writing successful code, but I can't find it now.

So, in search of some dopamine, I considered what I could add to my blog manager program. After some musing, I thought that it would be 'neat' to take a list of blogs (e.g. those from the current month) and graph the most popular tags contained in those blogs. I have a graphing unit and I also wrote a query that returns the tag count - I use this to prepare the table that I display at the end of every 100 blogs.

I had to modify that query slightly in order to insert values into the temp table so that they could be passed to the graph unit. My first attempt was as follows

insert into temp (instance, id, chardata, payload) select inttostr (inst), tags.id, tags.name, count (*) from tags inner join tag2entry on tag2entry.tag = tags.id inner join temp t1 on t1.id = tag2entry.entry where t1.instance = :p1 group by tags.id, tags.name

That sql query won't actually work as written because of the 'inttostr (inst)' statement. I am actually building the query as text then adding it to the TSqlQuery component because as far as I know, one can't use a parameter in the select clause. Although the query compiled without error, no results were graphed; after examining the code, I realised that I had used the wrong instance number in the query but had passed to the graph unit the correct instance. As written in 'Coders' and quoting Seymour Papert, No program works right the first time.

When I used the correct instance number, the tag counts were graphed. Immediately I could see that whilst the correct tags were displayed, there were too many of them for to display all their names. I remembered that in previous uses of the graph unit, I had limited the number of tags to be displayed to 10. In those uses, the values had been inserted via a cursor, so I could maintain a count of how many tags had been inserted. Here I was using the 'insert into/select from' syntax, so I was forced inspired to use an SQL command that I rarely use; the first line became 'select first 10' and so only ten values were inserted into the temp table and then displayed.

Whilst this did indeed display only ten values and these ten were displayed in ascending order (a trick of the graph unit), they weren't the correct ten values. I had to sort the query first before selecting the first ten, and so at the end of the query I added the line 'order by 4 desc'. The use of the index 4 means that the query result should be sorted by the fourth field in the select statement, namely count (*). This field doesn't have a name exactly so the index solved that problem.

Now I do have the top ten tags for a given range of blog entries graphed. As is my wont, I contemplated this code whilst walking the dog and realised that the previous queries that I had written to display a top ten of tags could be simplified/complicated by using this syntax. I alluded to this two paragraphs ago when I wrote the values had been inserted via a cursor; whilst the SQL code would be slightly more complicated, the program code itself would be greatly simplified. I'll save that dopamine rush for later.

Internal links
[1] 1844



This day in history:

Blog #
Date
TitleTags
127205/11/2019
Draft thesis reviewDBA
135505/11/2020
First rainPersonal, Weather
143505/11/2021
Counting beats with Van der Graaf Generator (3)Van der Graaf Generator, Time signatures
154905/11/2022
November 5Israel, Literature, Peter Robinson