Engineering Blog

How to program Drupal Cron

From drupalsun.

Implementing Cron tasks in Drupal

Cron tasks are defined by implementing the hook_cron hook in your module, just like in previous Drupal versions.

/** 
 * Implements hook_cron(). 
**/ 
function example_cron() { 
  // Do something here. 
}

And that's pretty much it. Rebuild cache and next time cron runs your hook will be called and executed.

Canon Digital Photo Professional - free download

One of the pieces of software that I enjoy using very much is the Canon Digital Photo Professional. I originally got it a loooong time ago, back when I was taking photography classes. It came with one of the Canon cameras that I've bought over the years. At the time I used it to browse and sort my pictures, sure - and only years later I realized just how valuable and useful this piece of software is.

A recommendation to rename "criticality" -> "priority"

Just throwing two cents here - if the pandemic taught us 10 things, one of those ten gotta be that small details in communication matter very much. With that, I recommend renaming the word "criticality" -> "priority". The reasoning is as follows. And be careful with the red color in the smart sheet too, please, for the same reason. 

An example of a bug report and the technical conversation around it to resolve it

I recently had to justify the amount of effort that software development takes. Someone unfamiliar with the process thought that software development is easy, or that it doesnt take much time. They thought, for example, that an advanced reporting app can get pdf export capability if they just said to the development team, "implement pdf export." Literally, they thought that writing a single line of text like that in a specification document would result in the organization gaining that functionality. 

Testing async code with Jest

After a little bit of struggle, I have managed to implement a jest that correctly tests an async fetch call. That is, suppose clicking a button initiates a POST request, and upon success some action takes place or some message gets displayed. I needed a test to assert that the action indeed took place.

My component looks as follows:

A review of some on-prem software services

I recently came by this picture at r/selfhosted and thought it useful for reviewing which services I use, and more importantly, which services I am missing.

The original post said that he hosted all of these on a single raspberry pi. Regardless of whether that is the case for you, or for me, I think reviewing which services are running, would be useful.

How to mock fetch and a state change in jest, react

tl;dr: I decided not to do it.

Since Enzyme is obsolete as of React 18, you would use <render /> and not <mount />. Therefore, you don't have a wrapper to manipulate and observe the state of the component being tested.

Furthermore, I'm really only testing the component because it's a best practice, and because of the expectation of future complexity. The state change itself is trivial: