Web color and font detection

I came across an idea on someone’s blog a bit ago asking for a display of colors/fonts used when bookmarking a website. This was someone speaking from a web designer perspective – curating a list of sites for visual inspiration isn’t uncommon, but knowing a bit more about the details of the sites might save a bit of time if you decide you want to use the same combination of colors or fonts.

I put together a quick service as a proof of concept. You can give it a URL and it will retrieve a screenshot, then parse out the fonts and colors used on the site, and display them to you, usually in under 10 seconds.

Quickly get the fonts and colors for a web page

A few changes may be coming in the next day or two, but this serves its primary purpose for my needs right now. Shoot me an email and let me know what you think…. michael@kimsal.com

installing canjs 5 via npm bug

Was looking at canjs5 earlier, and tried to install via the instructions.

I’ve got npm 6, but there’s a dependency in “can-connect” (must be related to canjs base) which requires npm 3 (only). This was set in 2016, and hasn’t been fixed. I have to wonder how people have been installing and using canjs in the last year or so… ?

I created a bug with canjs, but the ‘fix’ if you happen to get here searching for this bug…

npm install can@5 –save –engine-strict=false

back to some mobile

I’d done some small- to medium-sized projects in ionic a couple years back, and titanium/appcelerator before that, but have been focused on server-side and browser-based work for the last year or so. I’m jumping back to mobile/hybrid, and seeing what’s new.

I’ve been a fan of vuejs for a couple years now, and Ionic 4 now ‘officially’ supports vuejs integration. I was waiting for this for a while – I could take 2 stacks that I know already and be more productive. However… the ‘official’ support seems a bit … weak at the moment, and Angular is still king in the Ionic world. I started a demo project with all the latest angular/ionic stuff, and may put a link to that here if/when I get done with it. I’m just… not a big fan of Angular – it all feels very bulky compared to Vue, so that project may not get done.

To that end, I’ve had some interest in Quasar recently. This looks like “ionic for vue” more or less, but I’m a bit hesitant to jump too far in, mostly just because of time. But it’s on my radar.

Couldn’t remember this name – Framework7 – took a bit of googling to get to it! My friend Mitch threw this at me last year, an it’s now back in my ‘to do’ list to review.

NativeScript – they have ‘official’ support for VueJS (or maybe it’s ‘unofficial’?). This … I dunno – I spent a bit of time last fall looking in to it but it never clicked. Felt a bit like Titanium/Appcelerator perhaps? But I hear/read good things about it, so it’s back on my list.

Svelte.dev – came across this a couple months ago, then my brother mentioned it again recently. I’ve done some basic ‘hello world’ stuff, and maybe a bit further than that. The ‘single component’ aspect feels a lot like Vue components, and the ‘stuff done in the compile step’ is an interesting angle/twist. This video shows a recent talk and is worth watching to understand svelte and the thinking behind it more.

I’m off to dive in to one of these in the next few minutes, just to see how far I can get in 30 min. If I have anything of interest, I’ll follow up 🙂

Python 2 to 3…

Not a python person (used it in some projects, but it’s not my main tool). That said, I’ve been watching the “2->3” migration horror stories and woes for several years. In 2014, the “2015 deadline” for Python 2 deprecation was pushed back to Jan 1, 2020, so it’s once again starting to loom large.

I came across this little gem which may be one reason why so many people didn’t try to upgrade to 3 from 2…

The round() function rounding strategy and return type have changed. Exact halfway cases are now rounded to the nearest even result instead of away from zero. (For example, round(2.5) now returns 2 rather than 3.) round(x[, n]) now delegates to x.round([n]) instead of always returning a float. It generally returns an integer when called with a single argument and a value of the same type as x when called with two arguments.

So any code you had that relied on ’round’ function in Python 2 would automatically work differently when moving to 3. That may be a lot of code to audit/test/change!

(Edit: have learned this pattern is “banker’s rounding“. Still not sure it warranted such a change (or why the algorithm wasn’t pointed out as “banker’s rounding” in the change docs I’d found).

Similarly, “print” was changed from a statement to a function.

2.x: print "The answer is", 22 
3.x: print("The answer is", 22)

The 2.x style simply doesn’t work in Python 3. Again, that would be a hell of a lot of code to review/audit/upgrade, for no functional benefit.

Have you made the jump to 3? Did you just start with 3? Did you have to do a migration? Was it as bad as it sounds?

js promises are the new threads

Years ago I read that ORM was the Vietnam of Computer Science… That was certainly not the first time I’d read a pithy comparison, but it stuck with me.

I had lunch with a friend last weekend, and reminded him of a lunch many years earlier. This was probably… 2008. I’d picked him up for lunch, and our lunch was cut short with “I gotta get back – we’re having some major thread issues on a section of the code, and we’re behind on getting this shipped”.

This was Java, and it was 2008. There were behaviour bugs that no one could track down outside of “this is a threading issue”.

It came to mind because I was recently (the day before) dealing with some inherited JS that was heavy on deferred/promise/async/callback stuff. Guess what? Something wasn’t working. In the course of adding a new feature, I stumbled on something that looked like it’s been non-functioning for months, if not years. Low priority UI thing, but… frustrating.

I spent time trying to track it down – no luck. I reached out to one of the guys who wrote some of this, and has used the codebase (and built on top of it) for years. At first he thought it was a misunderstanding on my part – I’m new on this project, and that’s been the pattern. “Oh, Mike just doesn’t get this”. 10 minutes later I got something like “this is baffling – it’s just not working”. He spent another half hour or so trawling through everything he could think of. No joy.

I write this not with some great words of wisdom, or some silver bullet to cure everything. You use JS frameworks, you’re probably going to be using some degree of callbacks. But… in my old age, I may be more of a luddite than earlier. I avoid callbacks when possible (and again, I know it’s not always possible). But as I get older, I’m trying to optimize for clarity and understandability, and I don’t think promise/callback style development aids that, not on its own, anyway. You have solids tests, sample data and documentation around the code? Go for it! Absent those (which most people don’t do) it’s a harder sell for me.

And… 10 years ago doing Java, I shied away from reliance on threads wherever possible. Bottom line, to me, it’s just difficult to reason about. And, from what I’ve seen, it’s actually difficult for other people too (multiple anecdata from 20+ years of various development work). I’m just not sure people recognize that something is actually adding some potentially unneeded complexity and that is difficult to reason about and test, vs something just being difficult because it’s, perhaps, somewhat new to them.

Again – these tools all have their place, but I tend to view these as necessary evils vs “go to” first practices when architecting something.

misophonia, ears and colored noise

Sorry… couldn’t think of a better title!

Years ago I self-diagnosed with misophonia. Certain sounds trigger me in to difficult-to-control feelings of anger. I’d stop short of using the phrase ‘rage’ exactly, but when others use it, I know what they’re meaning. This started with sounds of others eating food (and oddly, even my own eating sounds on occasion, although that’s not common) when I was a child, and it’s been a steady thing since then.

Normally it’s crispier things – chips, crackers, etc – which trigger the reaction, although chewing with an open mouth is another trigger, as well as gum-chewing.

One big thing that helped as I was growing up was simply my own ability to control my environment. Being able to leave a table for a few moments is often enough to get things back to normal (in my head), and my condition is nowhere near as debilitating as it is for others.

Over the years something else that became a trigger is road noise – large trucks driving past – loud engines, motorcycles, rumbling, etc. Unfortunately, we live close to what’s become a main thoroughfare in our county – one of the few ‘cut through’ country roads which was basically untravelled 14 years ago. We’re fairly close to the road – only 4 houses in – so this has become more of an issue for me over the past 8 years or so.

The biggest help has been wearing earbuds running a whitenoise generator to help get to sleep. I had weeks where I couldn’t get to sleep at all, and it became a nightmare to deal with. Unfortunately, sleeping with earbuds tends to destroy them – I went through a couple of pairs of Bose QC20 (noise cancelling earphones which are a godsend for misophonia folks) before deciding to stop sleeping with them. I now get cheap $4 pairs from the dollar store and they last a couple of months. They’re samll enough to allow for sleeping on my side, and can get buried deep enough so as not to require loud volumes.

I’ve used this whitenoise app for years, and eventually upgraded to the paid version. There’s not much difference, but for all the relief it’s provided over the years, the authors deserved the few bucks it cost. They also have a desktop version I use (with the QC-20) for day to day work stuff at the office. The combination has really been a life-changer for me, and if you’re dealing with misophonia, consider it if you haven’t. Earbuds, whitenoise and a degree of autonomy to change my surroundings when needed has been instrumental in dealing with this. And yes, even changing house surroundings – we’ve been looking to move for a bit now, and sound is a primary consideration for the next house.

So… colors of noise? What’s that? I know people know the term “whitenoise” and I’ve been using it as a general term for ‘masking/hissing noise’, but I usually use brown noise, or a mix of brown/grey, in the app I mentioned earlier, and it’s quite … soothing? White noise itself is rather “tinny” to my ears, and actually hurts a bit after a few minutes. I can listen to grey or brown for hours, often with mixing in some rain or thunder sounds, and it’s fantastic. There’s multiple ‘colors’ all with different frequency characteristics – this article describes them in more detail.

If you’re dealing with misophonia, you have my sympathies. The reddit forum, as small as it is, has been one of the few social places where I’ve found you can find some support. Good luck to you.

early games

so… it’s late at night, i can’t quite sleep, and … been having some weird nostalgia semi-dreams. a few in particular harken back to the days of early 80s gaming. others had apples and ataris and commodores and TI systems. My first computer was a sinclair zx81. w00t!

my recent insomnia led me to poke around, and found a blog post from someone who’s championing ‘tiny games’. These are what we used to call ‘games’: entertainment programs that could fit in to 1k of RAM. For me, early on, that was always done in BASIC, and you couldn’t do much with BASIC (but you could with 16k of RAM – lots of fun stuff from those times, all things considered). But many people could do fascinating stuff with machine code, and you’d get interesting games, and they’d feel much like some of the examples this guy has posted.

He’s converted at least one to JavaScript, so you can play in your browser: try ‘tiny ski’ and see what you think. Except for the fact that this runs amazingly fast, this was my ‘gaming’ in the early days. And it was damn fun.

There’s youtube videos of some ZX81 games, although a) I never had any of these (I just remember seeing some in magazines but couldn’t afford to buy them) and b) none of them ever looked this clear on a CRT home TV and c) I think a couple of these were done later than the early 80s (not sure, but the graphics look ‘too good’ for what I remember possible in 1982).

and on that note, I will try to get back to sleep… zzzz….

Recent tech interview misstep

I’ll clarify a couple things – I’m not sure this was a misstep entirely, but felt awkward in the moment. And… this wasn’t a ‘job’ interview, but a short term contract I was interviewing for. Freelance/contract ‘interviews’ typically are looser than a full on ‘job’ (for a variety of reasons I may get in to later), but it happened that they’re basically looking for another pair of hands for the short term, and there’s already a pretty technical group of folks I’ll be working with, and they wanted some ‘real life’ interaction.

I was given a link to coderpad, and was also doing a voice call with one of the other chaps. The core task was to take a given array of data, pass it to a function and do some calculations. Outside of some date sorting (which I’d just noted up front I wasn’t going to bother with because there were no helper libraries available to deal with date complexities during the session), I had the basics working in a short time.

There were some ‘further challenges’ listed below the main exercise, mostly revolving around how to handle error checking. This was the ‘misstep’, potentially. Given that we were dealing with nested arrays, in PHP, I made some basic helper functions to check for the existence of particular keys, and would throw an error if the key didn’t exist.

function checkValidKeys($array) 
throw new \Exception("blah");

The chap on the phone asked if I knew about ‘coalescing’, and my brain jumped to SQL “COALESCE”, which didn’t quite jive. I stumbled for a moment, then he typed in the ?? operate in PHP…

$foo = $array['foo'] ?? null;

This is a new operator in PHP, since 7 (which, admittedly, isn’t that ‘new’ anymore), and I’d indicated that I’ve not used that before. Variety of reasons, some to do with “regular habits”, and some to do with the fact that some of the projects I’ve been triaging in the past year are still PHP 5.5 and 5.6. I’m often jumping between styles and environments, so adopting the newest features isn’t always an option.

However, I pushed back a bit more, based on the situation, and indicated I probably still wouldn’t use that technique in these situations. Why not? If ‘foo’ isn’t present in an array, for the situation presented, that’s probably a Bad Thing (TM), and represents an exceptional scenario to be dealt with. I countered that I’d more than likely use a specific object type (FinancialRequest might have fit for the sample in question), which would give me a better idea of property names available and expected, and the object itself could do some sanity checking as well.

This was the ‘misstep’, so to speak – pushing back on someone during an interview. I’ve not actually gone through this situation in a long time, and the last time I did it, I was not brought on board (I got in to a rather testy back and forth with someone about MySQL indexing interviewing with a team at Zappos years ago, which apparently didn’t end well – or maybe it did?)

I guess it went well enough, as I will be starting working with that team on a short term basis next week.

tax rounding

Just a quick … issue with tax rounding. I’ve put together a ‘bespoke’ commerce system, and have integrated taxjar with it. However… i’ve also had to import orders from bigcommerce, and the bigcommerce store is using avalara.

A charge of 13.28, with 7.25% tax rate, gives .9628, which, going through rounding, gives 96 cents. The info coming from the bigcommerce/avalara shows 97 cents, causing no end of stupid frustration.

Similar example at this link shows an example in Maryland, and avalara’s answer is something to do with Maryland “brackets”, but there’s not a good way to tell which states (or perhaps even which counties in various states do this. Using a ‘per line item’ call to any tax service will get expensive, and the rounding (round half up on a 5) has worked decently with taxjar over the past several months (the numbers we calculate match what they calculate). I’m reluctant to change much of anything, but for parity with the bc/avalara duo, I might have to. Changing round() calls to ceil() calls is probably enough (or… something like ceil(x*100)/100 perhaps) but… argh…. not really a problem I want to be dealing with.

Just felt like sharing…

Sunshine PHP 2019

I just got back from the http://2019.sunshinephp.com conference in Miami. This was my second time (went back in 2015) and … it was as good as the last time (better for me in some ways, which I’ll go in to here).

The hotel itself has undergone a pretty big internal change. The hotel is much more modern now – the atrium at least – the rooms seemed like they did before; nice suites, but they didn’t seem like they’d had a radicalized overhaul like the atrium.

Conferences are different experiences for different folks. Years ago, conferences were more about learning tech at sessions. Being able to soak up so much info from experts was valuable. As time goes on, for me, the conferences are more about people and connections, not so much raw tech.

One of my goals was to connect with more people I didn’t know. I’ve got a list – some of you will be getting emails from me to followup. If you didn’t get one from me, and would like to connect, email michael@kimsal.com 🙂

Some great vendors/sponsors as usual. JetBrains, Twilio, RingCentral, RIPSTech and more. I got some great hands-on demos and assistance from Manik with Nexmo on the TokBox platform (thanks again!) Caught up with David Stokes from MySQL. We first met in Nashville’s SEPHP conference, and he was generous enough to give me a small autographed book 🙂

Great to catch up with friends like Cal Evans and Josh Holmes (both of whom I first met in … 2008 at CodeMash all those years ago!) and hopefully have made a few new friends to see again at tech events in the coming years.

If I have time, I may update this post with a few more thoughts and pictures, but wanted to get a little something up now so I don’t forget. If we connected there, feel free to leave a comment here or reach out by email!

Oh… and thanks to Adam Culp for all the organizational effort he puts in to this event. Seems to be a labor of love, and it sounded like he’s got some more ideas for next year already!