Friday, April 29, 2022

note to self: leaflet

this post explains how to get leaflet to show your current location:

function onLocationFound(e) {

  var radius = e.accuracy / 2;

  L.marker(e.latlng).addTo(map)

    .bindPopup("You are within " + radius + " meters from this point").openPopup();

  L.circle(e.latlng, radius).addTo(map);

}


map.on('locationfound', onLocationFound);

map.locate({setView: true, watch: true, maxZoom: 8})

john coltrane and visualizing music theory

A new coworker mentioned how the idea of state machines really resonated for him, he liked to build interactive things out of them, and played around with XState. I was able to remember how important going formal was as I used a state machine for an browser/server card game port I made early in quarantine, though I mostly just used switch/case statements.

My coworker followed it up with this tweet about a state machine describing John Coltrane's Giant Steps... fun to see and listen to!

I'm not smart or patient enough to really get intellectual jazz but it's hard not to admire John Coltrane - so much deep theory based music can be kind of sterile, but he manages to still bridge to even casual audiences. 

Famously he made this diagram and gave the drawing to saxophonist and professor Yusef Lateef about progressions... if you've ever taken music theory you've probably heard about this and things like the "Circle of Fifths"...


Here's a medium piece about some spinoffs, and other tangents and deep dives.

Thursday, April 21, 2022

does javascript have too many operators?

 A javascript operator search engine/browser though I guess it doesn't solve the real problem of overloading; things have gotten so busy, especially with typescript, that knowing what a { or : actually MEANS can be super-tough...

Tuesday, April 19, 2022

optimizing apple's airpods max and music settings

At the risk of further entrenching my visible Apple fanboy aspect, for my birthday I treated myself to a set of Apple Airpods Max headphones. 

I really appreciate the design and material of them - the metal and fabric is a lot more pleasant than the plastic and vinyl of other devices.

At first I was totally blown away by the power of "noise cancellation", and it is impressive, but I realized the effect was heightened as I toggled between it and "transparency mode" which I guess uses the mics to ship in EXTRA ambient noise.

So one protip is to go into Bluetooth settings and enable "Off" along with "Noise Cancellation" and Transparency, which lets 


(At least one youtube video I saw by an audiophile claims that disabling Noise Cancellation and the Noise Addition of Transparency leads to a much cleaner sound, which makes sense to me.)

If you don't find it easy to remember which sound effect represents which mode as you toggle through the effects, the phone's control volume control has a shortcut as well:


While researching that, I found another improvement to Music, especially if you don't use the Apple Music service (I agree with Steve Jobs, streaming is way overrated, it's nice to own tunes instead of rent!) - I alway thought it was obnoxious to the point of being un-Apple like to dedicate so much space to advertising:


"Listen Now" taking the most prominent spot on the icon bar at the bottom is just ridiculous... luckily there is a setting for that in "Music" in Settings, "Show Apple Music":


(I'm still nervous that Apple considers "Show Star Ratings" optional (and even then you have to go to an individual song's properties) given how important it is to how I keep my music organized... they tried to remove it from the Music app earlier but they heeded an outcry insisting on its return... and honestly, it's was my ripped and iPod-ed music collection that made me jump to iPhone and kept me from Android.)


Friday, April 15, 2022

svg optimization

SVG is an under-heralded format! The way it's text-based instead of binary, and so very embeddable, is great, plus the way it scales is just fantastic. 

Greg at work pointed me to https://jakearchibald.github.io/svgomg/ which can optimize SVGs - claims shrinking so the final result is like a quarter the size.

One gotcha with React though, if embedding it as a React component (couldn't quite get raw .svg to be included as a a component directly in storybook and Gatsby, though flavors of webpack say they do it, so we wrap it as a proper React  .tsx component file) is you have to convert attributes with hypens into camelcase - fill-opacity to fillOpacity, for example...

Thursday, April 14, 2022

resizable, draggable divs as border for exercising responsive layout

 We use storybook, and by default it shows you a canvas that is influenced by the shape needed by its children (i.e. the component you are building). You have an option to make it fullwidth, but even then it can be a little clumsy to resize the whole browser just to see your component shift.

Old school folks like maybe surprised you can trivially add a draggable corner to any div:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

The style for that is just:

overflow: auto;
resize: both;
padding: 20px;
border: 2px dashed black;
width: 348px;

(The first two being the most "intesting")

platform smell and "In fact, EJB encourages collaboration of *more than six* different parties"

 I like to think I have a fair nose for coding technologies. (Admittedly, this nose works best when the industry shares the same preferences for simplicity and transparency over "do it for you" trends) For example, I knew the JSON was going to eat XML's lunch, and that React was just a better idea than early Angular. (Heh - I just ran into my deep dive into my reservations about Angular circa 2014)

EJBs, "Enterprise JavaBeans", was kind of a darling technology around the turn of the century, on the back half of the dot com run. It was a way of conflating in-memory objects with rows in a database. (If this sounds like a recipe for stuff that just doesn't scale, you're right... as I said at the time... EJBs allow you to distribute your db across many machines, and offer performance that assures that you'll need to...)

One early example of "warning bells clanging" - this passage from a book on EJBs: (I think some version of "Mastering Enterprise JavaBeans")


That is to say:

To get an EJB deployment up and running successfully, you need more than just an application server and components. In fact, EJB encourages collaboration of more than six different parties. [emphasis theirs]

Wow. Even with the disclaimer below it that it's "not for everyone"...yikes. Reading, I think it's talking about 6 human experts, not like "6 susbsystems" or something...

Tuesday, April 12, 2022

which way to scroll

A while back I wrote the ux of scroll direction, and I was reminded of that when talking with an Apple detractor who hates that "natural" trackpad scrolling (controlling the content as if dragging on an ipad, vs moving the viewport as with a scrollbar so that "scroll down" is done by moving a body part down). And then I found this tangentially related bit on tumblr:

Sunday, April 3, 2022

inline magic space

 Heh, I was just bitten by inline magic space, where an image was having some unwanted white space right below it, and then I ran into that article about it....