Tuesday, September 6, 2022

the dataLayer, and using local storage for cross-tab communication

 Just the other week I started looking more closely at the "dataLayer" - it's a standard variable off of window that Google Analytics uses to let processes record analytics events.

It seems like a strange way to do an API, especially since the data doesn't need to have identical structures, and it's just a big array like object you push on to. But it seems to be kinda standard in the industry thanks to the prevalence of Google Analytics.

In other learnings, I was impressed by the results my company was getting using localStorage to communicate some state across tabs/windows, in React the setup was something like 

  useEffect(() => {

    updateFromLocalStorageData();

    const storageListener = (e: StorageEvent) => {

      if (e.key === KEY_FOR_DATA) {

        updateFromLocalStorageData();

      }

    };

    window.addEventListener('storage', storageListener);

    // deregister event listener on re-render

    return () => {

      window.removeEventListener('storage', storageListener);

    };

  }, []);


using shortcuts to open google doc in app right from ios homescreen

Melissa was psyched to figure find this out on her own - we use a shared google doc for a shopping list, and she wanted a link right it from her iPhone homescreen.

The steps, taken from apple.stackexchange.com/questions/285696/create-google-sheets-shortcut-in-homescreen, are:

  • Open the document in GoogleDocs app on your iPhone.
  • Tap the three dots in the top corner
  • Share & export
  • Copy link
  • Leave the GoogleDocs app and open Shortcuts app
  • Create Shortcut
  • Add Action
  • Search for Safari
  • Open URLs
  • Tap the little gray field that says URL
  • Type googledocs://
  • Tap and paste (the link you copied from GoogleDocs). The result will look something like http://googledocs://https://docs.google.com/document/d/bunch-of-random-characters
  • Tap where it says “New Shortcut” at the top in big bold letters and name the shortcut
  • Tap the three dots
  • You can change the icon (the gray square with the magic wand in it) to what you want and give it a shortcut name.
  • Tap Add to Home Screen
  • Add
  • Done
  • Done/Next
Pretty keen!

The Daring Fireball's The Talk Show had Rosemary Orchard on talking about her book Take Control of Shortcuts, and she says there are tons of things to automate. I'm not sure if it's my lack of imagination, the way I am pretty good at building tools for my own workflows, or a distrust of formalizing activities that sometimes ned flexibility, but I have trouble thinking of more I'd like to do for myself, on either phone or laptop...

Tuesday, August 30, 2022

i can has :has?

 Man, the new :has pseudo-class sounds pretty great! Unfortunately browser coverage is poor. Still the ability to do a query based on the children in it, like 

figure:has(figcaption) {

  background: white;

  padding: 0.6rem;

}

seems awesome

Somehow it reminds me of James while John had had had had had had had had had had had a better effect on the teacher....

Monday, August 29, 2022

iOS tip of the day: view JUST photos or JUST videos in Photos app on iPhone

TL/DR: iOS Photo Albums have a "..." menu item including "Filter" for "Videos","Photos","Edited", and and "Favorites"

I've been doing 1 Second Everyday for years now, so I impulsively take a lot of quick snippet video footage - but when I'm browsing for post-worthy photos on my phone, I don't really want to see all the videos.

I assumed this would be accomplished via some kind of smart folder or album, but according to r/ios the best path is to just use the filter under the "..." menu that each album holds. A little fiddly but good enough,

Thursday, August 25, 2022

cheaters never prosper but sometimes we have more fun at wordle

 So, Spoilers for Aug 25's Wordle....

Here was my share:

Wordle 432 4/6
⬜⬜⬜⬜⬜
⬜⬜🟩⬜⬜
🟩🟩🟩⬜⬜
🟩🟩🟩🟩🟩

So had the first 3 letters... and knew I had all the vowels after step 2... but I wasn't seeing the answer and running all the permutations seemed tiresome, so I hopped over to jsitor (better than codepen as a js sandbox I think) and came up with

const letters = 'qwopfghjlzxcvbnm';
letters.split('').forEach(a=>{letters.split('').forEach(b=>console.log(`clo${a}${b}`))});

Yeah, the answer was "clown". Darn w-blends :-D I knew it as soon as I saw the second entry "cloqw"

Definitely not as cheat-y as going to a specialized website or even using /usr/dict/words , and actually I prefer a little programming exercise to gutting it out when the answer isn't showing up for me.

Thursday, August 18, 2022

give 'em the hook

 In one of those - am I being smarter or dumber than the person whose code I'm looking at, I was examining a big custom hook, and trying to figure out why it was a hook and not just a function. I was stackoverflowing react custom hooks vs normal functions, what is the difference and found a pretty good video about hooks in general, and making a case they can be a worthwhile layer for business logic apart from the UI:

Monday, August 15, 2022

the blind helping the blind

THE HIDDEN HISTORY OF SCREEN READERS ("For decades, blind programmers have been creating the tools their community needs")

Great read, especially for learning about JAWS vs NVDA.

For me, cognition is so entwined with vision, which in turn is entangled with how I approach programming, that it's daunting to consider a life not laid out on a 2D surface I can quickly skim...