Sean Reiser

Hi I'm Seán Reiser, this is my Personal Blog

“A person is what they think about all day long”
~Ralph Waldo Emerson

 I was surprised to find out that the Yankees were off today. I remember in the days when I was younger that on the three summer holidays: Memorial Day, Independence Day, and  Labor Day baseball teams would play single-admission day time double headers. Fathers would take their sons for a long day at the park.  As a New Yorker, I have to admit that I was spoiled. It was always a home team since the Yankees tend to be home when the Mets are away and vice versa there is always a home game for one of our teams.  Nowadays, it's like any other day in the summer if it falls right on the calendar you'll have a game, it might be a day game it might be a night game. No difference at all compared to the game on July 1 or August 15.

 It's not just baseball that's different, it's everything. Stores used to close early if they were open at all. Whenever I point out that stores are now open holidays and open later on those days, someone will point out to me that if EMS workers or the military need to work on these days everyone should work. I'll growing up my dad worked for Con Edison, and as you can imagine he would often not be off on holidays they said he needed electricity 24/7 and he was a part of the process that delivered safe electricity to homes in the city.  This meant that they were years that we celebrated Christmas on December 26 had Thanksgiving dinner at 11 AM and sometimes my Grandfather would have to step in for him to go to the game on some of the summer holidays. So I understand that sacrifices sometimes need to be made by essential workers. But it's not a sacrifice, if everyone does it for mundane reasons.

As a technologist, I'm on call every day of the year. As I like to say I'm only off on the days that the Internet is closed. When I woke up this morning, I checked the service as responsible for, made sure the sites that I'm responsible for our are up and then I can go about my day. However I try to find a way to respect the holiday, no matter what holiday it is. I like to reflect on the meeting of the day, try to find ways to connect with people.

Flag and Firewprks

Happy Independence Day

 

TLDR:  I’m looking at my options for a new machine.  I’m debating a MacBook Pro vs a Mac Studio.

 In January of 2021, my 2015 MacBook Pro died.  I was in the middle of a large project for John Deere and needed to replace it, quickly The Apple’s M1 had just come out, so I didn’t want to pick up an older Intel Mac but everyone knew that the M1 MacBook Pro was on the horizon which is the machine I was waiting on.   So I go the MacBook Air with 16 gig of RAM add a terabyte of SSD, since that model was in stock, and I needed that day to work on the project

The new machine has treated me well over the last year and a half. I've been amazed at how well a machine without a fan performs, it is the fastest machine I have owned. It does about 95% of what I need and a development machine. The problem is of course that other 5%. I'm trying to get swapped over to using Docker and Lando for the local development. For a few of the larger sites I manage I'm running out of memory when using updating the site using  Composer in Docker.  I work around it, I'll build sites outside of Docker, sometimes instead of local development I'll do\ development on a remote server. Both of these work but they're a pain in the ass and not efficient. Generally speaking when I buy a machine I try to hold onto it for seven years, but when I bought this machine I knew that wouldn't be the case. So I'm trying to figure out what I'm doing next.

It's interesting for the past 20 years, I've always owned laptops. I've wanted the flexibility of being able to work from my home office and be able to easily work at a client site when necessary.  But the world has changed, even developers who are full-time employees are more likely to be working from home then going into an office. In the 18 months or so that I've owned this laptop it spent the majority of its time and clamshell mode hooked up to a Thunderbolt Display I could've saved a few bucks and bought a Mac Mini and been just as happy.

So I'm sitting here evaluating my options. Since the guts of the M1 Max MacBook Pros are the same as the guts of the M1 Max Mac Studios, I have an interesting debate in my head.  By all reports, there's little difference in the performance of the MacBook Pro M1 Max and the Mac Studio M1 Max, so I'm not giving up anything if I take the laptop over the desktop (I figured that enhanced thermals in the studio would've allowed Apple to overclock processor, they're not doing that).

I've gone through the effort of specking 3 machines: a Mac studio, a 14” MacBook Pro, and a 16” MacBook Pro all with the lower end M1 Max, 64 GB Ram, one terabyte of storage.  The 14” is $900 more, the 16” is $1100 more.  Either way an increase of about 50%.  Given my quinquagenarian eyes, I’d get the 16”.,

 If I decide to get the Studio, I can keep the MacBook Air, and use it when I need to be on site or when I travel. I also have an added benefit with the studio that I can probably eliminate the home server from the network. I have an older Mac of mine sitting under the television set working as a media server, file server, home automation server. There's no reason I couldn't put those drives onto the Studio, and use it for both purposes, and save a few bucks on electricity.  I can also use some of the money I saved to upgrade my monitor, something 30”, maybe with an 21 x 9 aspect ratio might be better for my needs.

 On the other hand, if I decide to go with the laptop, I can sell the MacBook Air and use the money I received from that to offset some of the difference in cost.  And I have the flexibility of working more efficiently on site if the world changes back to the way it was two and a half years ago. Of course, if I miss out on one opportunity because it harder to work on-site, buying the laptop is immediately worth it.

The goal of course, is a machine that will last seven or so years. I'm trying to figure out how to get the best ROI out of this purchase and be prepared for the future.

Current Mood

 

Lunchtime Learning
CKEditor 5 and a Ham Sandwich

CKEditor 5 in Drupal 10: What is there to be excited about?    DrupalCon Portland 2022

Harry Reid removing the filibuster for judicial appointments is what allowed Trump to get three very conservative justices on the Supreme Court. Removing the filibuster just to get legislation passed, it's only a good strategy if you plan to never lose an election. Where the filibuster prevents a slim liberal majority in the Senate from passing some legislation, it also prevents the conservatives from passing legislation when they have a slim majority.  I worry about passing legislation on 51 vote majorities, without some form of consensus laws  can swing back-and-forth depending upon who is in control.

The reason I prefer codifying rights in the Constitution, is because it's harder to do. If something is hard to do it is equally hard to undo. Yes it is more work to get privacy added to the constitution, but it would be enduring. Passing a law when one side of the other has a slight majority in both houses is easy which leads to inconsistency.

Of course what's worse is enforcing rules by executive fiat. Whether it's by executive order, or by rules enacted by an administrative department, these rules can be changed at the whim of one person.

I still contend that these major questions of rights for citizens and residents of this country should be codified in the Constitution and that a Constitutional Convention of States is important that the structure.

 

 

Lunchtime Learning
Editor Experiences and a Ham Sandwich

Making Drupal Friendly for Editors and Clients   Drupaldelphia 2019

 

Configuring Drupal 9 to use the SMTP module with iCloud+'s custom domains

When Google announced it was going to shut down its legacy free email for domains, I decided to  use iCloud+ to manage the mail from seanreiser.com since I was paying for it anyway. I set it up but it's been working fine as a mail server. I had been running sendmail off my web server to send mail from my site when I needed to. In order to avoid spam folders,I decided to move to using SMTP, which meant I needed to authenticate to Apple's SMTP Server.

At first, I had a problem authenticating, until I realized that your email addresses at your custom domain is an aliase, so you need to authenticate with your iCloud account and an App-Specific Password. I'm using Drupal 9;s SMTP Authentication Support  Module.  Here are the parameters I used on /admin/config/system/smtp:

SMTP server settings
  • Enable TLS encryption automatically - On
  • Turn on the SMTP keep alive feature - Off
SMTP Authentication
  • App-Specific Password.
E-mail options
  • Allow to send e-mails formatted as HTML - up to your use case

Everything else leave as is. I'd do a test with debugging turned on and then turn it off. I also used the mail system module to redirect all mail to SMTP.

Good luck, Share and  enjoy!

 

 

Image
Laptop w/ Stickers

 

Lunchtime Learning
Caching and a Ham Sandwich

Understanding Drupal's Cache API: Lightning Speed with Low Effort,   Drupaldelphia 2019

 

 As I watch the news I wonder how the 3/5 compromise is taught in school today. It is often said that the founders who implemented the 3/5 compromise did so because they believed an African-American is worth 3/5 of a white man. This is really not the case. The compromise was a tool used by abolitionists to limit the power of the south. If slaves were counted the same as freemen, the south would've had more political power and been able to expand slavery. In reality, the south wanted slaves to be counted the same as three people, and the north wanted to be counted as none, hence the compromise.

Somehow over the last couple weeks, ace.js broke on this site, so a number of my coat samples look broken. Lunchtime learning has been replaced today by fixing ace.js. Back to normal tomorrow.  I want to switch to CKeditor's code snippet module, anyway. This is as good a reason as any

Image
Laptop w/ Stickers

Creating a Bookmarklet To Save a Link With Metadata In Drupal 9

This site has a linkblog and I thought I'd do a quick writeup on how I capture the links and their metadata.  You'll notice the the links are displayed in cards, similar to what you see on social media sites such as Facebook and Twitter.

This writeup will cover:

  1. The conten type to store a link and its metadata,
  2. Creating a bookmarklet so you can easily add a story to your site as you surf the web.
  3. Scraping metadata on a webpage to get the image, site name, title and description.

This writeup assumes that you have some basic understanding of Drupal on a site builder level.  I'm assuming you understand basic administration tasks such as creating content types, and fields as well as how to create a module,.  

Although I wrote the code for Drupal 9, as I review it, I see no reason that it won't work for Drupal 8.   Since support is ending for Drupal 8, you should be upgrading to Drupal 9, but that's a different matter.

Creating The Content Type

You'll need a content type to house the links.  On this site I'm using my generic note type which I use for most of my blog posts (this allows me to add a link to any post).  But I assume you want to use a separate content type, let's create a content type named link.  In addition to the standard title and body fields you want to give it the following fields::

Label

Field Name

Field Type

Link

field_link

Link

OG Link Description

field_og_link_description

Text (plain, long)

OG Link Image Url

field_og_link_image_url

Text (plain, long)

OG Link Site Name

field_og_link_site_name

Text (plain)

OG Link Title

field_og_link_title

Text (plain)

OG Link URL

field_og_link_url

Text (plain, long

HTTP Status Code

field_http_status_code

Text (plain, long)

 

Of course you can just add these fields to an existing content type as I did, you'll just need to adjust the code as you go forward.

Building the Bookmarklet

Simply put, a bookmarklet is a browser bookmark that contains JavaScript.  We're going to create one that will open a node add form with the url of the current page already prepopulated into the link field.  This saves you the effort of copying the current URL, opening your site, navigating to the node add form and pasting in the url of the page you want to blog.  There are 2 things we need ti do to make this work:

First we'll  get Drupal to accept a parameter on the node add form's URL and prepopulate the link field.  We either need to create a new module or use a module that you already use for glue code and use hook_form_alter.


use Drupal\Core\Form\FormStateInterface;
Use Drupal\Core\Routing;

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // Adding custom validation for the welcome page type field.
  if ($form_id == 'node_link_form') {
  	 $form['field_link']['widget'][0]['uri']['#default_value'] = \Drupal::request()->query->get('link');
  }
}

This code basically says, "when loading the node add page for the link content type, look to see if there is a 'link' query string, and if there is, put the contents of the query string into field_link."

Next we need to get the query string into the URL .... that's where the bookmarket comes into play.  Here's a little javascript


javascript:(function(){var url=document.location.href;var uri="https://seanreiser.com/node/add/note?link="+url;window.open(uri,"_blank");}());

You need to replace "example.com" with your site's URL.  Just add a bookmark in your browser, call it something like "Add Link To My Site" and paste the javascript in as the link.  Add the bookmark to the favorites bar and when you're on a page that you want to blog about, click on the button, add any commentary in the body field and rock and roll.

There is a contributed module, Prepopulate which accomplishes the sane thing (and more) but is a little more overhead than the couple of lines of code I wrote here.  Plus, if we use contrib for the easy things, we'll never learn anything.

Fetching Metadata

Next we need to fetch the image url, site name, title and description.   You can either scrape the content for metadata server side at save or client side at when rendering the page.  I prefer doing it at save since doing it  doing it at client side will slow down page loads.  Of course, since you're caching the information, if the site changes any of the metadata, your site will be out of date.

Instead of writing code to parse out the metadata, I took advantage of opengraph.php, a library that does the heavy lifting,  Very simply, I used hook_ENTITY_TYPE_presave to populate the appropriate fields.  You can put this in the same module from above:


require_once('opengraph.php');

function mymodule_node_presave(Drupal\Core\Entity\EntityInterface $entity){
  if ($entity->bundle() == "link") {		    
    $link_url = $entity->get('field_link')->uri;	    
    if (($link_url) && !($entity->field_http_status_code->getValue())){   
      $headers = get_headers($link_url, 1);
      $og_data = OpenGraph::fetch($link_url);
      $entity->field_og_link_site_name->value = $og_data->site_name;
      $entity->field_og_link_description->value = $og_data->description;
      $entity->field_og_link_image_url->value = $og_data->image;
      $entity->field_og_link_title->value = $og_data->title;
      $entity->field_og_link_url->value = $og_data->url;
      $entity->field_http_status_code = var_export($headers,1);
    }
  }
}

This loads the open graph library, loads the page info a variable and pass the page to the library to find the  metadata and then add it to the node before it's saved.

 

 

Image
Laptop w/ Stickers