Color Palette Generator

by Jason on

mouseover me…

I’ve been wanting to create something to get color averages or perhaps generate a palette from an image for awhile now and decided to whip something up using something I rarely use: HTML5’s canvas tag.

The images in this post are drawn onto a canvas and processed using this Palette class. Note that image size is defined via CSS. A babelized version is available for evergreen browsers here.


			    <div class="palette-example2"></div>
			    <link rel="stylesheet" href="/color/scripts/index.css" />
			    <script src="/color/scripts/dist/index.js"></script>
			    new Palette({
			        image: '/color/dragon.jpg',
			        selector: '.palette-example2',
			        horizontalSegments: 20,
			        verticalSegments: 10,
			        displayPalette: false, // default true
			        displayTools: false // default true

			    new Palette({
			        image: '/color/oscar.jpg',
			        selector: '.palette-example3',
			        horizontalSegments: 1,
			        verticalSegments: 100,
			        threshold: 60


  • image
    Type: string

    URL of the image source

  • selector
    Type: string

    CSS selector for the target element / container

  • segments optional
    Type: number

    Number of horizontal and vertical image segments to generate

  • verticalSegments optional
    Type: number

    Number of vertical image segments to generate

  • horizontalSegments optional
    Type: number

    Number of horizontal image segments to generate

  • threshold optional
    Type: number

    Number between 1 and 255 used to calculate whether a color is sufficiently different enough to be included in the palette

  • displayPalette optional
    Type: boolean

    Display the palette div

  • displayTools optional
    Type: boolean

    Display the tools / slider div

Moving Day

by Jason on

Moving Day 3…

While wordpress has been nice all these years, it’s time to move back to a static site.

GitLab pages ftw.

Mise en place - Duex

by Jason on

Part Duex
(Better, Faster, Stronger… Silverier?)

An update to Mise en place development environment

Mise en place (or, literally translated, everything in its place) is a culinary concept that we would do well to practice in software development. Like starting on a woodworking project with a cluttered shop or painting without first prepping the canvas, you’re setting yourself up for failure without first starting from a place where all your pre-requisites are available.

So what’s changed in 4 years…

When I last addressed this my daily routine consisted of creating C# applications and web applications with an occasional foray into PHP or JavaScript applications in Adobe AIR. 5 years later and I still do a heavy bit of C# however the majority of my time is spent enjoying JavaScript. There were times in the past where I made the erroneous (and misinformed) choice of $ over functionality and used PHP where I could have used C#. For other things there were times when I would use Adobe AIR to craft some simple cross-platform desktop application that, given the same constraints, today I’d probably choose nwjs or if I was convinced I couldn’t get by with pure JavaScript, C#.


  • A decent JavaScript editor. There are so many great ones to choose from now. Visual Studio excels at JavaScript but sometimes you just want something that’s a bit lighter. I’ve found Brackets to be a good choice on Windows or, when on Mac, SublimeText or WebStorm.
  • Microsoft Visual Studio. Visual Studio remains a joy to work with. If you’re not fortunate enough to be provided a Pro or other commercial license, get Community, it’s awesome.
  • Node.js (of course)
  • Git
  • Virtual Machines

Nice to Haves

  • Database administration. From MongoDB to the growth in usage of PostgreSQL the number of database technologies a developer might need to work with on a typical project has grown. These days I still keep Microsoft SQL Management Studio around (and it gets heavy usage) but since it’s just as likely I’ll need something else this is no longer a must have.
  • A decent image editor: my usage of this has dropped dramatically and I rarely find myself needing to produce anything with these tools. But when you need one it can be a huge time suck to find or install.
  • Patterns was recommended to me by a colleague a year or two ago and I’ve been surprised how much I’ve come to use it.
  • Fiddler (Windows) or Postman (Mac).
  • I’ve alluded to it throughout the post: OS X. In the past I enjoyed working in Windows primarily and was a staunch advocate of the ecosystem. I begrudgingly switched to Mac when offered by my employer (all-the-while making snide uninformed comments along the way) and over a surprisingly short amount of time grew to love it. Windows is now usually in a VM unless I just don’t have access to a Mac. “Finder” and window management is a joke in OS X compared to Windows (or Linux) but it’s enough of a *nix system to keep me happy and productive while not interfering with my productivity with arbitrary (or whimsical) user interface flaws.

Well that’s it for this!

See you in 4 or 5 years for Mise en Place Trois.


Using Cloudinary with Ghost

by Jason on

Update: Looks like Ghost will support this sort of thing through the App API. Keeping this around in case anyone needs it before that feature goes live.

Decided to take Ghost for a spin. My testbed for that kind of thing is typically AppFog.

Installation was pretty simple. (Here’s a snippet of my Ghost config that I got running on AppFog for anyone who might be looking for this sort of thing. Ignore the storage section unless you read on.)

So it’s alive, running and woohoo! But then I uploaded a cat picture (are there any other kinds?), restarted the application and my picture was gone. It was then I remembered:

No persistent file storage on AppFog

This is a big problem. I can’t upload pictures of cats! Wha? What’s the use of a blog anyway without that functionality! However let me be clear this is an AppFog problem, not a Ghost problem. AppFog has been working on “persistent file storage” for well over a year now.

Ghost is easily extendible and this is a solvable problem. We could use Cloudinary, Amazon, Rackspace or any other cloud to solve the problem. I settled on Cloudinary as it was mentioned in the Ghost to Wordpress migration plugin.

My additions to support Cloudinary in Ghost are in this pull request. Check it out if you’re facing the same issue and want get around AppFogs problems or if you want to extend Ghost support to more cloud providers.

My config for Ghost on AppFog: (my changes from the default highlighted in blue.)

			// # Ghost Configuration
			// Setup your Ghost install for various environments
			// Documentation can be found at
			var path = require('path'),
			var mysqlCred = {};
			if (process.env.NODE_ENV === 'production') {
			    mysqlCred = (JSON.parse(process.env.VCAP_SERVICES || '{}')["mysql-5.1"] || [{}])[0].credentials;
			config = {
			    // ### Production
			    // When running Ghost in the wild, use the production environment
			    // Configure your URL and mail settings here
			    production: {
			        url: '',
			        mail: {},
			        database: {
			            client: 'mysql',
			            connection: {
			                host     :,
			                user     : mysqlCred.user,
			                password : mysqlCred.password,
			                database :,
			                charset  : 'utf8'
			            debug: false
			        server: {
			            // Host to be passed to node's `net.Server#listen()`
			            host: process.env.VMC_APP_HOST || '',
			            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
			            port: process.env.VMC_APP_PORT || 1337
			        storage: {
			            type: 'cloudinary-file-store',
			            credentials: {
			                cloud_name: '',
			                api_key: '',
			                api_secret: ''

Ratings are Bullshit

by Jason on

I have become bullshit, destroyer of words I have become bullshit, destroyer of words

I recently purchased and read the science-fiction series [Redacted] (books 1-4) by [Author Redacted]. I emphasize purchased because in an age of Amazon Prime, Amazon Unlimited and free giveaways a purchase indicates confidence in selection. At this point I will malign the books, not because they’re bad (though I think they are) but because of the reviews and the reviewers.

Before I get to the ratings I’ll explain why I didn’t enjoy these books. If I were forced to give a rating on the standard scale I’d give these one out of a possible five stars and my rationale would be that they were legible and contained relatively few obvious errors. Things did improve by book 4 so I might possibly stray as high as a 2.

There is nothing terrible in these books however there is also very little of anything else within. Immediately after I began the first book in the series a small coal of loathing alighted on soul. By the 2nd book the warm loathing had grown into a mild hatred and I plodded through more out of a duty to my wallet than for enjoyment. In fairness, with these books it is appropriate to say that each was better than the last.

Normally, at this point after a bad read, I’d chalk it up to just an unfortunate purchase but I believe this series is indicative of a problem. Ratings on practically everything have become bullshit. The ratings for this series on Amazon and Goodreads are simply ridiculously off-kilter with the quality of the works. Perhaps readers were interested, as I was, by the author’s ideas. (They are decent and sometimes original.) However the death of these books is in the pacing and structure.

For illustration purposes I have provided a plot synopsis from any one of these books: (no spoilers…)

That thing happened you were kinda interested in and then something else happened and then something else and then something else and then Jason Statham jumped out and shot a few guys and then that thing you were kinda interested in was referenced again and then someone kissed somebody. The End.

All fire, no smoke.

As I’ve said, for me, 1-2 out of 5. For hundreds of other people however, this is, apparently, fantastic. A significant number of people give these books 4 and 5 stars.

I believe it is safe to assume the 5 star people do the same thing I do with books I believe are of that quality: Buy a physical copy to go along with my digital read; give them out as presents; think back fondly and often on them; consider what the book says about me and about you; try to bring it up in conversation so I can recommend it to others; consider placing closer on a shelf in my office just so I can see it every once in awhile, even if I don’t have time to read it right then; if I’m in a used book store: look for signed copies; etc and etc…

I’ve re-read some of these reviews, worrying that maybe these books were actually parodies of something I wasn’t aware of or perhaps I should be reading them as an acrostic and there’s an entirely different story I could reveal hiding just below the milquetoast surface. Maybe I’m just too shallow to “get” it? I don’t think that’s the case. Here’s an example 5 star review:

5/5 - It lived up to my expectations of it.
– Some guy on Goodreads
Aha! Perhaps I’m far too judgmental!

When I read House of Leaves I was enthralled by the winding storytelling. I was deeply uncomfortable while at the same time being enraptured by the process of reading it. In every aspect it defied my expectations. When I read The Road the characterization was so real that for two years after the movie adaptation came out I argued with Cynthia that I had already seen it. It remains that vivid in my memory. Trying to compile a list of my 5 star books would be practically impossible: A Confederacy of Dunces, Dune, Snowcrash, The Shining, Ubik, Hell House, Slaughterhouse Five, Neuromancer, Shame, IT, The Magic Mountain, A Stranger in a Strange Land … (Going back to childhood: Watership Down **, Bunnicula, Indian in the Cupboard, an endless list of wonder … )

How, in a world where a 5 is “lived up to my expectations”, is it possible to rate these, some of my favorite books?

It’s not entirely fair to pick on this single 5 star rating and use it for illustrative purposes. I’m sure there are many other reasons to rate a book 5/5. For me to rate a book a 5 (since this is the highest possible praise I can heap on it) means that this book has attained a permanent place in my life. I know that my 5 is not your 5 and there’s nothing wrong with that. But I believe there is something deeply wrong with a 5, or even a 4, being expected for the overwhelming majority of books. (Or something deeply wrong about a 4 or 5 being “met expectations.”)

Of course, I haven’t officially rated the aforementioned sci-fi series anywhere and I won’t. I understand that the process of gaining positive reviews is currently the gateway to financial success for self-published authors and whom am I to stand in the way? (I appreciate that trashing them publicly is probably mean, but I doubt it’s financially impactful, who reads this blog anyway? I also recognize that I’m part of the problem by not giving these books a bad review on Amazon but I’ll get to why I’m more than just that part of the problem in a minute.)

For me the issue with these was pacing and structure. As I’ve said: all fire, no smoke. Tension, character development, world building, all practically non-existent. If someone wants their novels and novellas just crammed with action, written at an easy reading level and short enough to get through in an evening, whom am I to say their taste is lacking?

Recently I was fortunate to sit in on a talk by splatter-core author Tim Miller and someone asked why his books were relatively short compared to standard novel formats (30k-40k words as opposed to 50k-70k.) And he mentioned that as a reader he enjoyed action. I believe he said something like this: (I didn’t take notes, so my apologies if I’m quoting you incorrectly Tim):

I want to know what happens next. I don’t want to know that they went home and made a sandwich, what kind of sandwich it was etc.
– Poorly remembered Tim Miller quote
… And right then I knew I probably wouldn’t enjoy his books. (Sorry again Tim! However I will purchase one since I name checked you.)

See, I’m the kind of reader that wants to know what sandwich was made and why. I want to know that the heroine used mayonnaise. When she was growing up all her father would buy was mustard because when the power was turned off the mustard never went bad. No matter how she was sometimes nostalgic for her father’s bologna, American cheese and French’s mustard sandwiches she just can no longer tolerate the vinegary smell and the memories of poverty they evoke. It’s not that she preferred mayonnaise. (It’s nothing as casual as a preference.) She was of mayo, she lived it.

So, for me, a book that lacks the “middle” parts between action simply cannot attain a 5. In fiction I can’t connect with a series of events on the same level I can with a character that participates in the events. And I can’t connect with that same character if I’m just provided a few short facts about them.

I began thinking about this due to the combination of listening to Mr. Miller and reading the, now, much maligned sci-fi series. If I remember correctly this post was originally titled something I thought witty about action, action, action etc. It grew into a rant about ratings as I reflected why I purchased those books in the first place.

You see I decided to check out some of my public ratings and reviews. I won’t link them out of shame but you can find them easily enough. As an example: I gave Hugh Howey’s Wool a 5. I really liked Wool when I read it but it’s not a 5. At best it’s a 3 and the series is, perhaps, a 4. Wool is imaginative and fun but it is a bonsai in a forest of redwoods compared to many of my favorite books.

Cynthia and I joke about my Netflix ratings the same way. Officially the 5 stars on Netflix mean the following:

  1. Hated it.
  2. Didn’t like it.
  3. Liked it.
  4. Really liked it.
  5. Loved it.
In practice my star ratings on Netflix mean the following:

  1. It was absolute garbage. There’s no 0 or I would rate this 0.
  2. They tried really hard. It was on film and everything! (Their mom did a great job as the casting director.)
  3. This was a complete waste of time but had professional actors doing their thing.
  4. Pretty decent!
  5. This changed my life! It should be on your bucket-list.
Here is the crux of the problem: I lie. I lie to myself and to the small stars. I inflate everything. It’s as if I know the guy who starred in it is out of work and would be super sad if I rated this craptastic independent docu-drama 1 star so I give it 2, maybe 3 stars.

With books it’s exponentially worse and much more personal. With a book there is a singular author. Not a huge film crew and group of actors, but a real, flesh and blood, individual who has dedicated a huge gulf of their life to this work. When I start to rate the book unless it is riddled with spelling and grammatical errors I start at a 2. Then I think: hey this book was free (+1), didn’t I see somewhere that his kid has lupus? (+1) and I didn’t fall asleep immediately while reading (+1).

Bam: 5 out of 5 stars. I’m a monster. I am ruining literature one rating at a time.

An original version of this post listed a particular sci-fi series and I felt bad about the guy’s lupus kid** so I removed these references. Hint: It’s about nano technology, artificial intelligence, spaaaaaaaaaace, and freakin laser-beams.

* I read this as an adult and loved* it.

* This is a joke.