Updates

HP Printers and Apple

Recently I was unable to print from my Apple computer, it report a certificate problem. These printer problems are well documented by Mr. Macintosh. Deleting a directory allowed the driver to be reinstalled from the terminal:

sudo rm -Rf /Library/Printers/hp
Posted by John Borden at 19 November 2020, 2:08 am link

Gilded Rose Kata

In the process of teaching my oldest daughter Smalltalk, we finished working through the Gilded Rose Code Kata, for now the code can be found on Smalltalkhub .

The given code is a D&D inventory system, the task is to change the update method so conjured items degrade twice as quickly as normal items. For this we wrote a simple test that degraded a conjured vest by 1 day and compared its value to a normal vest degraded by two days.

One problem which threw us off was GildedRoseImaginaryTest>>#nextDay: takes an argument, but this item must be the same item which is most-recently created by #givenItem:sellIn:quality:. Each time this is sent replaces the inventory.

Its clear that the creators wanted the task to modify GildedRose>>#updateInventory based on the comment that Item should not be modified. An interesting exercise is to support the same functionality by modifying Item and adding subclasses. This means adding a message to express how items lose value:

  • Item
    • AgedItem
    • TicketItem
    • ConjuredItem
    • LegendaryItem

Several advantages are provided by this:

  • The original inventory update method hard-coded the names of the items, the new code changes this to invoking #nextDay on each item. The message Item>>named:... is now a factory for choosing a subclass
  • The original inventory update had two variables to manage, and for some items these had an interconnected relationship (for example tickets to events that have passed have no quality)
Posted by John Borden at 14 October 2020, 1:52 am link

Todo Annotations

Previously, it seemed like a good idea to create a todo annotation similar to the note annotation, which looks like this:

This is a note annotation which starts with two at-signs, the word note, then this text.

This would make make it easy to add a task at the end of page:

@@todo Task that wasn’t finished when editing this page

Unfortunately, the CSS for this also affects tasks lists, like Todo, so it shows up with a bright yellow background.

Bright yellow todo background
Since using HTML works already, it seems like a better idea:

{{{html: <span class="TODO">This is a task that needs work</span>}}}

While working on this, I had issues with browsers caching the style sheet. One method that worked well was changing the port with each test - an example is on Loading Pier 3.2 into Pharo 7.

Posted by John Borden at 28 September 2020, 2:56 am link

Removing Scheduled Tasks from the Menus

While working on A Task to Retrieve URL Content, several improvements were found for Scheduled Tasks:

  • Previously the automated tasks were just listed as completed tasks. If they are running automatically, there's little value in seeing them. Also, they still take up screen space
  • If an automated task is removed, it can cause an error with the report or text missing. While error checking is good for a missing report, its also a good idea to de-automate the task in the remove call

Hiding a task when automating it doesn't take it away the search results. It add more use for the Add a Scheduler Report - all of the automated tasks can be displayed in its report.

Posted by John Borden at 13 September 2020, 12:54 pm link

A Task to Retrieve URL Content

There have been several times that I have found that it would be useful if my todo list would react to another site. For example, if a business is temporary closed for a pandemic, I would like a todo item activated when it is open again. Another use case is moving the task of watering plants to a later date when it is likely to rain.

The method PRScheduledTaskExamples>>reportCheck:thenRetrieveLink:using:onPageAt: implements this for Scheduled Tasks, steps are:

  1. The report check to determine if it should proceed by returning true or false. It accepts the report page as an argument.
  2. Retrieve the contents of the URL, handle any connection errors by displaying in the report page
  3. Pass the URL contents to the using-block. This should return a string to be displayed on the report page

This code should be loaded into a newer version of Pharo 8, using older version (like from this problem) had image crashes retrieving https URLs.

Testing - Reading this page:

  1. Create a ToDo List with two tasks:
    1. One task is Use My Subscription to The Business - Repeats every 5 days
    2. Second is Check the Business
      • it repeats every 10 minutes and has a report child with empty text
      • The check task has the contents: (PRScheduledTaskExamples newForKernelNamed: 'pier') reportCheck: [ :page | '*Aug*' match: page contents ] thenRetrieveLink: 'http://www.myborden.com/pier/john-c-borden/updates/todo-retrieves-url' using: [ :string | ('*temporary closed for a pandemic*' match: string) ifTrue: [ (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Use My Subscription to The Business') hideFromMenus: true. 'the business is still closed' ] ifFalse: [ (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Use My Subscription to The Business') hideFromMenus: false. (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Check the Business') deautomate. 'Open for business' ] ] onPageAt: '/Todo/Check the Business/report'.
      • Automate this task by running in the image: (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Check the Business') automate.
      • inspect: TaskScheduler allInstances anyOne to ensure that this is running
  2. Wait 10 minutes, the report page should display that the check failed, but it lists the date (testing this in August)
  3. Wait 10 minutes more, check the page again. The 'Use My Subscription' should be hidden, the 'Check' should report that the business is closed
  4. Update the page at the URL, change the spelling of the checked words
  5. Wait 10 minutes
  6. The Subscription tasks should be visible again
  7. Check again: TaskScheduler allInstances anyOne inspect - The check business task should not be present

Design Choices

Fetching the contents of a URL is quite time-consuming, and introduces additional dependencies on other systems. For tasks like monitoring another site, this is the intention so the check block can simply be: [ :ignore | true ] and the check won't fail. Other examples like the plant watering example can check the state of the other tasks. Using the report page (like the testing example) allow it to implement a state-machine.

Code changed for this includes:

  • Adding PRToDoTask>>deautomate
  • Modify PRToDo>>tasks to only return tasks which are not hidden from the menus
  • For some reason, JQAjax>>callback: still had a call to #fixCallbackTemps, this has been removed from Pharo 8
Posted by John Borden at 28 August 2020, 2:07 am link
<< 1 2 3 4 5 6 7 8 9 10 >>