Tuesday, August 30, 2016

note to self: node, nvm...

Note to self, when I'm running functional tests (for our Angular 1.X app suite) and see an error like
const builder = require('./builder');
^^^^^
SyntaxError: Use of const in strict mode.


I'm probably on the wrong node version. "nvm" is what controls that, and hopefully by using "nvm alias default X.X.X" I shouldn't see this again.

(bonus... looking into how to test validators that reject or resolve the defereds from a $q defer()

promise creativeCreateService.validators.impressionTracker3('http://foobar.com');
expect(this.unwrapPromise(promise)).toBeTruthy();

promise creativeCreateService.validators.impressionTracker3('https://foobar.com');
expect(this.unwrapPromise(promise)).toBeTruthy();

promise creativeCreateService.validators.impressionTracker3(_.repeat('A',20));
expect(this.unwrapPromiseRejection(promise)).toBe('Impression tracker must start with http:// or https:// if provided');

the code that supports it is:
    self.unwrapPromise = function unwrapPromise(promise) {
        var value;
        promise.then(function (result) {
            value = result;
        });
        self.$digest();
        return value;
    };

    self.unwrapPromiseRejection = function unwrapPromiseRejection(promise) {
        var value;
        promise.catch(function (error) {
            value = error;
        });
        self.$digest();
        return value;
    };

 )

Saturday, August 27, 2016

the old days of the java plug-in

A while back Gizmodo posted Rest in Hell, Java Plug-In.

It's really too bad it was such a security problem; back before html5 and canvas and powerful javascript, or even before Flash and Shockwave, it really let developers share interesting stuff, much more interesting that what a browser could do alone.

Flash and Shockwave always felt and looked more polished though, both in terms of plugin management and in terms of the end product. Almost all serious Java programs looked a bit "off".

Thursday, August 25, 2016

code katas

Interesting programming exercises: Code katas.

vanilla is the finest of the flavors

This article encouraging starting with "vanilla" javascript intersects with some of my own preferences.

There are some things that are worth not doing from scratch: templating, routing, testing, etc, but even then there's a lot you can do with special purpose libraries rather than overarching frameworks. You then get the pleasure of debugging in a code base that solves just the problem at hand, and is generally bespoke and with business-logic-mirroring stacktraces.

That said, I'm surprised how much one can do while still missing huge swaths of basic Javascript! Take a look at the docs for JS's "Object"... there's more there than you might think - stuff like the prototype chain, the getters and setters... you can go a long way and do a lot of things without realizing they're in there... but then when you have to read someone else's code that uses them, you should be aware.


git 101: rebase from master, squash, etc

I prefer to use SourceTree for git access, and admittedly have generally been leaning "just enough to get by".

I was generally "pulling" from master periodically when working on a story branch, but was introduced to "git rebase master" which does a better job of it - your commits are more your new work, not just a record of the the commits as you kept up with master.

This link has some more about the squash option (like if you do "git rebase -i master"- this will fire up whatever editor you have on git, with lines showing you the commits separately, as "pick" - you have the option of changing all but the first "pick" to "squash" or "fixup" which essentially is saying "treat all these commits changes as one big commit). Once you close the editor, the editor will open again but with a place for the actual commit message you want to include.

I'm not sure what the benefit of squash-ing i, except keeping things a bit neater downstream, or if you have to rollback.

UPDATE: once you do this you have to do a "git push --force-with-lease" since you are rewriting history

Sunday, August 21, 2016

the ugly american

I was in Ireland last week, and noticed that FB must have fiddled with their iconography again; the globe icon was quite a bit odd looking. (An I mean, isn't a globe for "Notifications" a little odd anyway?)

Not going to mention how long it took me to figure out the problem. Forgot that i was so Americas-centric in my outlook!

Sunday, August 14, 2016

imagemagick's mogrify to fix ios exif image rotation issues

Digital Photography Circa 1996 -
cyberpunk gargoyle!
A while back I grumbled about what a hot mess EXIF handling was - how iOS photos tended to always store photos line up with the cameras lens and ignoring orientation for the raw data, but then putting in an EXIF header about how the viewer should rotate it, and some browsers did that, and others didn't and it was generally gross.

At some point in the past I found the fix, but I didn't post about it 'til now- maybe I was holding off 'til I could check it working across different browsers, but I haven't seen an issue for a long time, so-
mogrify -auto-orient imagename.jpg
does the trick.

Sometime in the last year or two I made my blogs upload system both resize the uploaded photo to the appropriate width, as well as store it at original size. Wish I had done that years ago, it really lets my blog be a better archive.

If you like seeing a subjective history of digital photography, starting July on my blog (16th or so) and ending today I've been posting a "dozen best photos of the year"... it's been satisfying kind of mentally revisiting those years, getting back some lost time.

Wednesday, August 10, 2016

convert youtube etc to mp3

I like paying for music. 99 cents to 1.29 a pop is fine, being able to pay for almost any song as a single without all the B-side ballast of a full album is a wonder of the modern age. (And then keeping access to the music, without monthly subscription fees, is also a plus, though I kind of see why some people like the selection they offer.)

Anyway, some songs I just can't find on legit pay download sites as much as I'd like to send the artists a token amount... most often stuff from other countries. (With Apple Music (or my past self hosing) my collection a bit lately, there are a few cases where I'll have to do this again) But Youtube is more international than Amazon or the Apple Music store, so when my only option is a youtube video I have had good luck with convert2mp3.net. In the past, it seemed like youtube was playing "wack-a-mole" and disabling services as they popped up, but this one has been stable and reliable for at least a few years now.