instaSquared

I showed instaCropper to my social media clients, and they were impressed. One of them suggested that I increase the size of the canvas, rather than crop the images to squares. The tradeoff is that increasing the canvas makes the original image relatively smaller. The advantage is that I can bulk process photos in about a third of the time it took me to process them with instaCropper.

InstaSquared starts by ensuring the file in question is a photo by checking for EXIF data; if there is no EXIF the user is informed that the file is being skipped. Once it’s established that the file is a photo, it finds the longer side and uses that dimension to make a new canvas. There is some math to figure out offsets and the original photo is pasted onto the center of the new canvas.

instaSquared was designed to process bulk images that are sent to me by show photographers. With that in mind I eliminated all of the user decisions that were available in instaCropper. Now all files have “squared_” prefixed onto the original file name and the new file is saved to a “squared” directory in the parent directory.

If you try it out, please let me know what you think.

Original photo from my trip to Oahu
InstaSquared version of the above (resized by WordPress)
Advertisements
instaSquared

instaCropper

I started managing social media for a local theatre group. We’re trying to improve engagement on FaceBook (in our group and in each event), Twitter and Instagram. The process was eating in to the time I allotted for this project, so in addition to setting up an account at Sendible to automate post scheduling, I created the instaCropper tool.

The problem with Insta’ (the ‘Gram) is that the images for upload must be perfectly square (except for story photos which can be something like 1.9:1). The next issue is that performers universally don’t ask their photographers to provide the equivalent of passport photos just so some social media dude can make Instagram posts. Certainly cropping a single photo perfectly square isn’t particularly time consuming…

But I write code! Why would I do this manually? Ten performers plus two producers times three photos for each of those, plus photos of three back-of-house people, plus show prep photos equals more time that I want to spend drawing perfect squares.

Starting with the Pillow library, I was able to write a script that will take in a single image or a directory for processing multiple images. Each image is opened in preview to confirm that image is correct. If the orientation is wrong I can rotate or flip the image as needed. Should there be more background than I want I can set the crop origin. The crop is confirmed via a preview image. Once it’s what I want I can save it with a custom filename and in a separate directory from the original photo – all from the command line.

Processing a single image used to take at least 70 seconds. It now takes about 11 seconds and there is no chance that I will accidentally overwrite the original photo (that happened more than once, fortunately I was working on local copies from a google drive folder). If you use the tool, please let me know. If you think of reasonable additions, feel free to create a github issue.

instaCropper

Let’s Talk Template Literals

It’s interesting that there are so many ways to STDOUT text to the screen. Let’s look at a few of them in JavaScript (ES6) and Python (3.6)

Concatenation: This works in both JavaScript (console.log) and Python (print). “The first half of the sentence ” + “is joined to the second with a plus sign between the halves.” Also works with variables. “Hello, ” + user.name + ” and welcome to our shopping site.” Do pay attention to where spaces are.

Embedded expressions: Javascript allows developer to include simple expressions as well.

console.log( "Hello, " + user.name + ". Your total is: " + (purchase.subTotal + purchase.tax + purchase.delivery) + ".")

Hello, Kristopher. Your total is $123.45.

String formatting: Python 3.6 allows developers to include variables mid-string as follows:

print('We are the {} who say "{}!"'.format('knights', 'Ni')) 

We are the knights who say "Ni!"

But if you need to refer to the position of the argument (values passed in to ‘format()’ there’s also:

print('{0} and {1}'.format('spam', 'eggs')) 
spam and eggs

or:

print('{1} and {0}'.format('spam', 'eggs')) 
eggs and spam

As well as keyword arguments, though I find this exceptionally cumbersome and wonder why the developer wouldn’t jut hard-code the values into this sentence. I’m including it because it’s in the Python docs and isn’t noted as being too archaic:

print('This {food} is {adjective}.'.format(food='spam', adjective='absolutely horrible')) 

This spam is absolutely horrible.

My personal preference, added to Python in 3.6 is the f-string

print(f'Welcome, {user.name}! Today's special is {special.name} and is on sale for {special.price}.')

Welcome, Kristopher! Today's special is Singing Rooster Coffee 12oz vacuum bag and is on sale for $10.

This is really easy to debug, in part because it reads very much like the end sentence, without extra punctuation. I also don’t have to type-cast my variables like in Python 2.7 (which required %s, %f and %i when referring to strings, floats and integers). Take a look at the Python docs for more examples and explanations: https://docs.python.org/3/tutorial/inputoutput.html

In JavaScript I’m growing attached to template literals. Like the f-string a template literal reads very much like the final product.

console.log(`Welcome, ${user.name}! Today's special is ${special.name} and is on sale for ${special.price}.`

Welcome, Kristopher! Today's special is tomato soup with grilled cheese sandwich and is on sale for $6.75.

The only catch here is to look for backticks (“ the keys that are left of the “1” on a US keyboard). At first they can look like single quotes, though most IDEs I’ve worked with do a good job of making the angle very obvious. MDN has done a great job with the documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

Let’s Talk Template Literals

Ready for Winter?!

We don’t usually lose power at our house beyond a flicker. Which is why it’s odd that we’ve lost power twice in the last eight days. We had a friend over who was amazed by our collection of flashlights and gadgets that we take camping with us, that are obviously ready to double as gear for a night without the lights. Here we go:

These inflatable lanterns are super cool. Not only do they provide a good amount of light to the sides, we often use them as flashlights if we’re just walking around camp. https://amzn.to/2RdRZKv

Speaking of lanterns, this Goal Zero unit is amazing. They put a lot of functionality into it and the battery holds a charge for a long time. We haven’t tested but I suspect we would get well over 12 hours from the single light on Turbo (which is overkill).

https://amzn.to/2R5ixh9

Does anyone remember those lantern battery flashlights? They were really heavy and had a beam we were sure could be seen from space. My obsession with bright flashlights continues:

900 Lumens: https://amzn.to/2UWOneS
1300 Lumens: https://amzn.to/2LvFip7

More so when we’re camping or out for an evening walk, we like to have our hands free.

Black Diamond Storm: https://amzn.to/2SfWq4L

Petzl Tikkina: https://amzn.to/2V6qwK3 
The Petzl I have is different from this unit and is also not super bright. But that makes it useful when we’re just around camp or the house during an outage. It -is- possible for a flashlight to be too bright.

Speaking of going for an evening stroll, we like to have a light on the back of our heads as well. One time a driver slowed down to thank us for wearing red flashers (and reflective stripes!). I can’t find the units we use, but these are close: https://amzn.to/2V28Jn3

The last on my list is definitely a “gadget”. I kickstarted these and I’m mixed. Having a flashlight and firestarter combo is a great idea. Unfortunately I couldn’t ever get anything to light using the plasma lighter. Granted I live in Seattle and everything is slightly damp when we go camping, so every lighter has issues. The mini is great for just carrying around and the light is decent. The Sparkr light is really good and the end cap can go over the light to make it sort of a lantern; if nothing else it’s nice to be able to hang it from things.

Mini: https://amzn.to/2BA676W
Sparkr: https://powerpractical.com/pages/sparkr

So that’s how we keep things lit around the house. We do use some candles (because we have them) but all of the above have seen us through long, dark nights whether at home or in the woods. I just got my BioLite headlamp today (as a Yule present) and I’ll probably do a review of it as I get a chance to use it.

Ready for Winter?!

Notes For the Future: Background Images in iOS Safari

I spent about an hour tonight trying to get my new background image to display in the Xcode device simulator. I thought it might be an image size issue, but it apparently has something to do with how the background is attached. Here’s the code I used for my header on mobile breakpoints:

header {
background: url(“../assets/header.svg”) no-repeat center center fixed;
background-attachment: scroll;
background-color: #4f4f4f;
background-position: center;
margin-top: -35px;
-o-background-size: contain;
-moz-background-size: contain;
-webkit-background-size: contain;
}

Notes For the Future: Background Images in iOS Safari

Notes For the Future: Android SDK Emulator

The Chrome Dev Tools screen size simulator mostly works. But when I open a site on my phone and it isn’t really doing what I expect I start to scratch my head. Fortunately the Android SDK provides a robust device simulator.

The trick, and the reason this is a note to myself for the future, is that “localhost” is at 10.0.2.2:PORT/ The emulator behaves exactly like my phone (for better or worse).

Notes For the Future: Android SDK Emulator

Rite Press Review

I love coffee. I love making coffee. Hand ground with a French grinder from the 40s or in my press-a-button Capresso I love fresh grounds. Kona? Yes, please. Deathwish – you know I’ll drink it. And I love the gadgets for brewing coffee even more.

I was skeptical about the AeroPress but I grew to rely on it as my daily coffee maker. The stainless filters have taken some getting used to but I won’t go back to paper. I have two French presses but I can’t use them. We have old pipes so I can’t wash grounds down the sink, and I don’t want to have to scrape grounds out of a glass carafe when there are other easier options. I have a hybrid of the French and AeroPress called the American press, which has this grounds-holding module with stainless filters on either end that is pressed through the hot water. Neat!

So I was super excited when I heard about the Rite Press. It’s a French Press style unit with a removable bottom; the idea being that cleaning a French Press is the worst part of using one, and I agree. So I super-earlybird pledged my $30 for a 1/2 liter in black and waited. Broad-strokes I think the Rite Press team over extended themselves and didn’t take into account that many of the Chinese factories that KS creators use are very unreliable, especially as production numbers increase in multiples of the expected order. They also made the mistake of offering the press on garbage kickstarter Indiegogo. Currently they’re experiencing a significant delay in 1L press production due to a filter manufacturer error, then changing to a new manufacturer. 1/2 L presses will suffer the same fate eventually, I’m not sure where they are on shipping these units.

But it did arrive and I have the unit to review. First the packaging is very nice. I did not have any issues with the powder coating; several commenters did. The steel button that is intended to attach the timer to the unit had fallen off and was inside the press when I opened it. I’m not sure that’s the worst thing as the timer is on the same side as the spout and the while thing seems like a silly idea. Perhaps if they had incorporated a handle it could go on the handle side. As it is, I’m not sad about it, but commenters are. The thermometer is … weird. I checked it against my CuisinArt PerfecTemp kettle and the needle didn’t get much past the third blue segment. My digital thermometer indicated the water was at 200F so I’m not sure what temp Rite Press thinks coffee should be brewed at. I don’t plan to really use it, but this was another place where the Rite team could have made better decisions.

When I unscrewed the bottom to clean it before using I had a little difficulty with the threads. That has resolved itself and I’ve since used it dozens of times without any leaking or other issues. Others are reporting poorly machines threads that make the bottom difficult to seat.

A pleasant surprise is the rubber sleeve that surrounds the middle of the unit. I believe when I pledged these were listed as vacuum sealed. That’s probably not the case as the carafe heats up quickly, so the sleeve is a nice compromise.

All in all it meets my expectations as a brewing device. Grounds go in, water goes in (and doesn’t leak out), the filter filters out the big chunks. The bottom is easy to remove and I can dump the grounds in the compost; very little of the grounds end up washed down the drain.

But can I recommend it? Not really. At $30 it was a good deal. $45 or $50 seems reasonable (having broken more than one glass carafe, this is a long-term savings for me). $60 is a bit much (and the site says the MSRP is $100), especially considering the QC issues they’ve been having. Consider that a 1L Bodum Brazil (which I have) is about $20. Want a “classic” style French Press with the metal bands? The Chambord Press is about $40 (replacement glass is roughly another $20).  If you want a stainless/metallic carafe they’re roughly $30.

If you have a Rite Press, or have one “on the way” I’d like to hear from you.

[N.b. there are some folks who complain that the piston doesn’t compress the grounds and that a watery, coffee-grounds mess spilled on the counter. It’s not an AeroPress and the French Presses I have don’t allow me to press all the way to the bottom so I’m not sure where this idea came from. Just like with a French Press, you may need to pour off the remaining brew before cleaning. ]

Rite Press Review