Friday, December 9, 2016

javascript30

https://javascript30.com/ - build 30 things in 30 days. Interesting!

freemarker template: safely pass optional freemarker boolean into javascript

New job! I started with CarGurus just this week. Great site if you want to both find cars in your area and know if you'd be getting a good deal or a bad deal.

Interesting culture here - super engineer-centric, features tend to be outlined and handed to coders rather than having a lot (or, any) independent graphic design work beforehand. Plus they have come up with solid answers to problems I've seen plaguing other places I've worked: for example, the way developers too often play with "toy" databases that don't reflect what's going on production. For CarGurus, there are 3 options for our remote dev machines: slice, which is that minimalist subset that is sometimes good to work with on the server side, staging, which is a local weekly copy of production, and shared staging, which is the same but doesn't require everyone to do as much maintenance.

The technology is a mix of proven and reliable and more cutting edge. (Cutting-edge-wise I'm so relieved they're going with React and bypassed the whole Angular thing entirely) On the server, that means some older stuff like Struts and FreeMarker Templating; but both are actually pretty good at what they do. FreeMarker predates JSPs but is a now a well maintained Apache project.

Still, it can be a little arcane. One problem was I wanted to set a variable on the FreeMarker side for Javascript to read as a boolean, but to have the absence of that variable be smoothly treated as 'false'. The code for that turned out to be:

<script>
var isModal = ${(feedbackAsModal?has_content)?then(feedbackAsModal?c,'false')};
</script>

A little wordy but not too bad.

Oh, plus CarGurus bring in lunch for everyone every day, so that's a plus, though I still haven't quite worked out how to manage my calorie counting...

Friday, December 2, 2016

advent calendar redux

advent2016.alienbill.com Once again, I made a virtual advent calendar! An original little digital toy for each day leading up to Christmas. You can come back daily to see what's unlocked.

I've been doing these for about 7 or so years. It's a fun way to remind myself that programming can be fun, it doesn't just have to be for work...

I might have started out with the best of the 25, Santa Hockey is actually kind of a fun little game.

Thursday, November 24, 2016

photocap.php : offline photo captioning hack

So, I haven't posted much lately, I was in Malaysia for a bit under two weeks.

One thing about vacations to Malaysia - lots of pictures...

(If for some reason you want to see more, go here and start clicking through up to the 21st)

Anyway, in the current social media world, I tend to double post; I put photo galleries on FB, where friends and family are more likely to see it and comment, but I also like keeping them on my blog as their permanent home.

FB has polished photo gallery editing, but my blog doesn't. Also, where Internet was spotty (like at our resort; downloading was fine but uploading was terribly slow) or non-existent, I wanted a tool to edit captions offline, one that made it easy to later put the photos onto FB and my site. For FB, it's still pretty manual copy and pasting, but it goes fast. (Haven't researched if there are any better ways to automate making albums with captions, but frankly I do it so rarely it might not be worth more dev time.) For my blog I can just generate the appropriate HTML and copy and paste (modulo some search and replace fiddling I do for my blogs way of handling thumbnails and upload folders)

PHP has a convenient built-in webserver, from a shell run 
php -S localhost:8000
(or whatever port you like)

So here's the simple editor I came up with, a one-file-wonder. It has a bit of Javascript that I kept vanilla (I do like when everything can just be one file), it writes out a tab delimited CAPTIONS.txt file, and it stores deleted photos in a folder called "killem".

Below is the code for my future reference, I just need to copy and paste it into a file named "photocap.php" in the same folder as all the photos. I ran into a few PHP quirks, like I had to encode filenames rather than use them as straight up keys because "." is not allowed in a key.

Also the code is pretty rough, but that's what I get for hacking on a sunny beach while drinking...

I published the code at github.

Friday, November 4, 2016

the art of the emoji


MOMA's Paul's Galloway writes The Original Emoji Set Has Been Added to The Museum of Modern Art’s Collection:
I tend to use emojis more freely than some of my correspondents, I think I'm more aware of how chilly of a tone text messages can have without them, or at least some gratuitous exclamation points.

I don't mind yellow-faced smilies, especially when picked from a list, but I'm sometimes bummed the standard is to automatically translate punctuation smilies like :-) into the cartoon version. It takes a semi-clever typographical joke into a very literal thing, and sometimes has issues with expressions from different emoji sets setting carrying somewhat different moods. (Or stuff like Apple swapping the gun for a squirt gun.) Also sometimes I worry that we're regressing into simple pictographs. On the other hand Wired had a guide to some of the way teens were using emoji in somewhat more nuanced ways.

I think you can tell Asia has driven a lot of the Emoji standards (I mean, even besides the name which has supplanted Emoticons and Smilies.) For instance in the 1990s, at least for me
:-) was smiling, and
:-D was laughing
but those are called"slightly smiling" and "grinning" respectively,  it seems, and the laughing involves tears.

One thing I discovered playing Pictionary with Germans is that, even an English, a frown is defined as the gesture of the brow, not the lips ("furrow one's brow in an expression of disapproval, displeasure, or concentration.") Similarly, historically Asian emoticons often emphasize the eyes rather than the mouth- In 2003 I blogged about about some Japanese Smilies:

(^_^)
smile
(>_<)
ouch
(-_-)
fuming
(@_@)
confused
*^_^*
blushing
(^^)//
applause

Those were all ASCII based... as Unicode caught on, of course there was even more flexibility in character-based emoji perhaps reaching it's pinnacle with
¯\_(ツ)_/¯

I do love that guy.

the kingdom of nouns

If you like a good (if old) rant you might enjoy Steve Yegge's Execution in the Kingdom of Nouns.

I've always thought verbs were a bit underrated. Earlier this year I wrote:
I don't care so much about the interior lives of things; people and computer objects alike should be judged on what they do, not what you think they "are". (Conversely, from a Bayesian analysis point of view, what they "are" will influence what they are likely to "do", so getting a handle on what they "are" is better than relying on individual observations of their action.) 
It reminds me of that Geocities-era classic Object Oriented Programming Oversold! - though you need the Wayback machine to see it.

The Kingdom article says
It's odd, though, that Java appears to be the only mainstream object-oriented language that exhibits radically noun-centric behavior
If you read You Have Ruined Javascript, you see Angular giving the radical noun-ism the old college try (admittedly well after the Kingdom article was written.)

Image Capture for moving large files and photos in bulk

Macbooks are getting rid of the SD card reader.  Here's Apple exec Phillip Schiller defending that decision in The Independent:
The new Pros have no SD card slot for a camera memory card. Why not?
Because of a couple of things. One, it’s a bit of a cumbersome slot. You've got this thing sticking halfway out. Then there are very fine and fast USB card readers, and then you can use CompactFlash as well as SD. So we could never really resolve this – we picked SD because more consumer cameras have SD but you can only pick one. So, that was a bit of a trade-off. And then more and more cameras are starting to build wireless transfer into the camera. That’s proving very useful. So we think there’s a path forward where you can use a physical adaptor if you want, or do wireless transfer.
I'm not sure I buy the "cumbersome" argument; when not in use it's recessed, and when in use, well, every other port has a big old wire sticking out of it, so I don't see it as a real point.

I find the SD card a great method of generalized file transfer and backup, not just a tool for getting photos off cameras, and it was convenient not to need the reader, though they're cheap. But, just another dongle - dongles which will likely be the way of your world for the next two or three years if you upgrade your Mac or iPhone.

Of course, some of the SD Card indifference is justified because so much amateur photography is done by smartphone now anyway. (Which is probably the strongest pitch for "it's wireless now", camera to wifi last felt really clunky and gimmicky to me, though maybe I'm out of the loop with recent advances.) Still, I find wireless transfer slow, and in my curmudgeonly oldness, I have a strong preference for dealing with photos as regular files and not being beholden to some service for another.

So as a reminder, Macs come with the "Image Capture" app, which I think is the fastest / simplest way of getting photos and videos off of iOS devices in bulk.

Incidentally, I learned about that quote from Shaun McGill's excellent Lost in Mobile blog. 
 His stuff has been through several models seeking a business model, but it's always a great view of modern consumer tech. (And I've always liked his How Did We Get to the iPhone? which traces through the PDAs and the like that provide the evolutionary backdrop for that 2007 wonder.)