Author Archives: scottb

2019 Videos, Links, & Whatever…

Wright Brothers vs Samuel Pierpont Langley

I am listening to The Wright Brothers audio book by David McCullough. I have really been enjoying it. You may remember his voice from The Civil War series by Ken Burns.
Listening to the book reminded me of a talk I heard earlier by Simon Sinek where he compared the resources of the Wright brothers to Samuel Langley. In the book, McCullough noted that Langley had over 50K and a dream team for his work. Meanwhile, the Wright brothers spent less than $1000 of their own money on the entire venture.

GraphQL – From the beginning

I have seen a couple videos on GraphQL in the past, but it has been some time. So, in one sense, I am starting fresh.

Here is the first video I watched this evening. It is a very good overview of GraphQL with a nice intro about some of the limitations of REST.

The video included a link to a site to play around with things at this url:
Here is a good query to start with

{
  allFilms {
    films {
      id,
      title,
      director,
      openingCrawl
    }
  }
}

More to come…

2018 Videos, Links, & Whatever…

My Ramblings…

Mac Powell – Super Dad!

It has been months since I shared a video, but I just had to share this one. It is cool that Mac brings his daughter up on stage to fulfill one of her dreams. However, the part I like is when he realizes that he wants to be sure not to embarrass her with a song she may not know the words to (especially with her nervousness of being on stage in front of this many people).
So, he enlists the crowd to sing along. It becomes like any other worship session where the leader is saying the words before each verse. I believe Mac is doing this not only for the audience, but also to make sure his daughter feels safe in the process and doesn’t get tripped up.
I would guess she has sang this song a thousand times in her life, but everything is different on a stage. Mac knows that and is protecting her. It is a valuable lesson for any dad.

2017 Videos, Links, whatever

My Ramblings…

Guy Kawasaki – The Lessons of Steve Jobs – Lean Startup Week 2016

Guy is a great speaker, full of energy. This is a fun quick video to watch where he does a top 10 from Steve. Not to give it away, but I liked the Steve quote, “Some things need to be believed to be seen”.

Jake Archibald – Instant Loading: Building offline-first Progressive Web Apps – Google I/O 2016

This is a very fun to watch video from a very skilled presenter. Ward Bell suggested this on a podcast I recently listened to. Ward pointed out to listen for the “We can ship that” multiple times in the talk which is funny. It gives a thorough explanation of ServiceWorkers and how to progressively update an app to use them.

Jason Fried – Why 40 Hours is Enough: Lessons from Basecamp – Lean Startup 2016

Excellent talk from a fellow who has been “doing it” for the past 17 years. I have always NOT been a fan of email for project related communications. Now that I hear this talk, I wonder if some of my original problems with that type of communication came from reading his book (Getting Real, which I read back in 2006).

Sam Newman – Feature Branches and Toggles in a Post-GitHub World

This guy literally wrote the book on Building Microservices. In this talk he gives a nice history of version control and git. He shows the challenges with feature branching and suggests an alternative “Branch-by abstraction”. This is a major part of using feature toggles. In relation to flags, he suggests using a flag in as few places as possible and remove the flag when it is no longer needed. Another thought is to treat every check-in as a release candidate. He does a great job talking about the problem of having too many changes in a release, which causes it to take longer, which increases the potential for problems (both deployment and one change breaking something else). He also talks about trunk based development. For the right teams on the right kinds of projects, this seems like the sweet spot to me.

Simon Brown – Modular Monoliths

He tries to make documentation match the software it is intended to describe. He leans a little more towards continuing the monoliths than I prefer, but I do like the idea of simple architecture designs that actually describe the software.

Publishing ServiceBus message from Node (Electron)

This is a handy little module that wraps up the Azure ServiceBus code in a tight little package. I don’t claim any of it as original work, since I have pulled from more sources than I can remember.

It is a work in progress, but I wanted to document what I have so far.

Code for azHelper.js

"use strict";

var azure = require("azure-sb");
var sbConnect = "Endpoint VALID CONNECTION STRING HERE...";
var sbService = azure.createServiceBusService(sbConnect);

function publishMessage(messageLabel, message, category) {
  
  if (!category) {
    category = 1000;
  }
  console.log("Publishing message", messageLabel);

  var sbMessage = {
    body: JSON.stringify(message),
    brokerProperties: {
      Label: messageLabel
    },   
    customProperties: {
      Category: category
    }
  };

  sbService.sendTopicMessage("rapids", sbMessage, sbCallback);
}

var sbCallback = function(err) {
  if (err) {
    console.log("ERROR publishing message", err);
  } else {
    console.log("message published");
  }
};

module.exports = {
  publish: publishMessage
};

And the calling code…

var azHelper = require("./azhelper.js");

var contentFoundMessage = {
    fileName: fileName,
    baseName: baseName
};

azHelper.publish("ContentFound", contentFoundMessage, 1100);

Unique object names for S3

When creating buckets or objects in S3, I wanted an easy way to create a unique name for each object.

The names to be as short and human readable as possible. (Guids have their place, but I don’t want to look at them).

The Aws Rules for Bucket Naming lists the following guidelines.

  • Bucket names must be at least 3 and no more than 63 characters long.
  • Bucket names must be a series of one or more labels. Adjacent labels are separated by a single period (.). Bucket names can contain lowercase letters, numbers, and hyphens. Each label must start and end with a lowercase letter or a number.
  • Bucket names must not be formatted as an IP address (e.g., 192.168.5.4).
  • When using virtual hosted–style buckets with SSL, the SSL wildcard certificate only matches buckets that do not contain periods. To work around this, use HTTP or write your own certificate verification logic. We recommend that you do not use periods (".") in bucket name

NPM shortid

In the past, I had settled on using the NPM package shortid, but it did not seem to be returning the first character randomly. Based on my recent listen to the Pluralsight course File Storage Using AWS S3 and Glacier: Developer Deep Dive, I want my names to be random, so Amazon can better spread the load out on the hardware.

Custom Id Generation

The bulk of this code comes directly from Tom Spencer’s post – Short ID Generation in JavaScript. His use case was a little different, but you should read it for a more generic approach. I wanted something that took the date into consideration, so I hacked his approach.

Finally, some code

Here is my s3helper.js module

"use strict";

module.exports = (function() {
  const moment = require("moment");

  // Just to ensure we don't start a name with a number, we
  // use alpha only for the prefix.
  const LIST_ALPHA = "abdegjkmnpqrvwxyz";
  const LIST_ALL = "23456789" + LIST_ALPHA;

  const ALL_LENGTH = LIST_ALL.length;
  const BUCKET_ID_LENGTH = 8;
  const OBJECT_ID_LENGTH = 3;

  var getPrefix = function() {
    var retVal = LIST_ALPHA.charAt(
      Math.floor(Math.random() * LIST_ALPHA.length)
    );
    return retVal;
  };

  function getbucketName() {
    var retVal = getPrefix();
    for (var iLoop = 0; iLoop < BUCKET_ID_LENGTH; iLoop++) {
      retVal += LIST_ALL.charAt(Math.floor(Math.random() * ALL_LENGTH));
    }
    return retVal;
  }

  function getobjectName() {
    var retVal = getPrefix();
    for (var iLoop = 0; iLoop < OBJECT_ID_LENGTH; iLoop++) {
      retVal += LIST_ALL.charAt(Math.floor(Math.random() * ALL_LENGTH));
    }

    retVal += "-" + moment().diff("2014-08-26T08:01", "seconds");
    return retVal;
  }

  return {
    bucketName: getbucketName,
    objectName: getobjectName
  };
})();

Using the code is pretty easy.

console.log("s3", s3Helper.bucketName(), s3Helper.objectName());

Which gives me this output in the console.

Dropping files in Electron (with Angular)

I started with a clone this project.
https://github.com/maximegris/angular-electron

My goal was to find an easy way for a user to drop files into an Electron app.

Electron makes this pretty easy by providing the File Object. However, that code was not working for me, since I was working in an Angular app.

This Post on StackOverflow helped me solve the issue. (This Gunter guy is awesome!)

StackOverflow post

The only small hurdle was finding the right place to put the dropscript.js. This is what I ended up with.

Links

Weekend Brain Dump

It is no secret that I am a fan of checklists. Tools like Trello are awesome. I also use NirvanaHq for my GTD type lists (Thanks David Allen). One of the few books that I am reading right now,
The Checklist Manifesto is about how important checklists can be.

However, sometimes I know I have things on those lists, but they are still swimming around in my head. I have the mind like water that David refers to, but it is not the calm still water. Instead, it feels like the rapids.

When I reach that point, I find it helpful to grab a pile of notepads and just start dumping things out of my head. I don’t like using just one notepad and flipping pages, since things seem to get hidden that way. Instead, I dedicate a notebook for each “area” that I am “dumping”. I can easily lay them out and see everything.

Here is a picture from this morning. I am trying to get into the habit of keeping an index card with the 2 or 3 things that I hope to get done in a day. For this day, it was so overwhelming, I just picked one. BTW, the breakfast was great and the boys (these boys) had a good time.160703_WeekendBrainDump

Html PlaceHolder Attribute done right

While a pet peeve is described as a “minor annoyance”, this issue has always been a little more than that for me. I don’t know how many times I see a textbox on a form somewhere and when I click in the textbox, the label disappears. I get distracted for a moment, and when I look back at the screen, I can’t remember what I was expected to be entering. It happens a lot with Logins. Once I start to log in, I wonder, did they want a username or an email?

So, when I was signing up with Grammarly (I know, from my posts, you wouldn’t guess I would need their service 🙂 ), I was pleased to find out they are doing inputs “right”.

When I clicked into the input, the caption animated down to a smaller version so I could still see which input field I was in.

It is odd to create a blog post for such a minor thing, but I was just so happy to see somebody doing it right that I had to post it somewhere.

160528_PlaceholderMinimized