DHH – Software’s Warrior

Warrior? That’s a bold statement, and possibly widely discarded by DHH himself and the industry at-large. Really, though, think through the HerosJourney, what are the basic traits of the Hero – courage, vision, principles.

DHH on courage.
The article RailsIsOmakase presents an underlying trait of DHH – courage to stand his ground, regardless of the hell-and-high-water that will come. For 10-years on he has stood by the principles of Rails, and really more personally, has stood by his only principled views, even in the face of wild backlash over his own bold statements in RailsConfPresentations.

DHH with vision.
Well, an easy seque from the discussion of courage – DHH has held the constant vision from the very start of where Rails fits in the wider arena of Web Frameworks, and that vision has been maintained through the years.

DHH – principled.
Courage and Vision need to be grounded on principles. Like Omakase, there are certain decisions that can be ceded and compromises that can be achieved, yet a set of main rules and guides drive the overall path of development and change over the Rails framework. There are a multitude of examples of this, and DHH has led the 37Signals team with principled vision through so many successfull projects.

Wether DHH would consider himself to have ever been the Warrior of any Hero’s Journey is not really the point. We can celebrate his guidance and vision for the Rails project and by extension our Rails community by that name anyway, since what we can truly celebrate is the Courage, Vision, and Principled Guidance that DHH has given to us all these years.

Thanks David!

Rails + Webpack + Webpack-Manifest + React + Babel 7 + HMR – [chunkHash]

I’m writing this quick one up so you can save the 1.5 hours that I spent debugging this.

Terms :
HMR – HotModelReload – webpack-dev-server option to trigger browser-auto-refresh when webpack detects filechange (and re-compiles)

Here’s what I’m using :

  • Rails 5.2
  • Webpack-Manifest Gem
  • Yarn
    • Webpack (-cli)
    • Webpack-dev-server
    • @babel/core
    • @babel/preset-react

The issue : When running webpack-dev-server with --hot option (enable HotModelReloading, webpack compile fails with :

ERROR in chunk hello_react [entry]
js/[name]-[contenthash].js
Cannot use [chunkhash] or [contenthash] for chunk in 'js/[name]-[contenthash].js' (use [hash] instead)

Context : With Rails + Webpack-Manifest gem, webpack config is being used from ./config/webpack/environment.js (and it’s named siblings).

This SO discussed the problem and solution
https://stackoverflow.com/questions/50217480/cannot-use-chunkhash-or-contenthash-for-chunk-in-name-chunkhash-js-us
It does not unfortunately tell you very well what to do with

// 4th SO andswer of SO:50217480
output: {
    filename: process.env.production ? `bundle-[chunkHash].js` : `bundle-[hash].js`
}

Luckly, this SO includes a complete webpack.config.js (still not quite where we’re at with webpack-manifest… close.
We’ll notice that output.filename is part of the main config.
I validated this by adding console.log("webpack env", environment) to ./config/webpack/development.js and verifying that, apart from output of virtual-object names, :outputis indeed on the base config object.

SO (THE ANSWER) : edit ./config/webpack/development.js and add : config.output.filename = "js/[name]-[hash].js".

// ./config/webpack/developer.js - at least for my app

process.env.NODE_ENV = process.env.NODE_ENV || 'development'

const environment = require('./environment')

const config = environment.toWebpackConfig();
config.devServer = {
  contentBase: '.',
  host: "localhost",
  port: 3035,
  publicPath: 'http://localhost:3035/',
  historyApiFallback: true,
  proxy: {
    '/packs': { // string to look for proxying requests to api
      target: 'http://localhost:3035', // Path of your rails api server
    },
  },
}
config.output.filename = "js/[name]-[hash].js"

module.exports = config;

Enjoy!

Building an App – EKG

In this series, I’ll build an app in step-by-step posts that will produce an EKG (heart monitor) display.

The inspiration is the Phillips IntelliVue MP50 (found at my local hospital):

Tools we’ll use

Pretty much the whole point of this series… to learn some new tools and techniques:

  • Rail 6 – coming from a Rails 4/5 background, I’ll point out specifically “new to me” details.
  • SvelteJS – both introductory how-to and deep-dive into charting and real-time data streams.
  • Real-time data streams – although our sample data comes in CSV form, we’ll build some benchtesting harness to present this data to our front-end in “real-time”

Assumptions I’ll make

This tutorial makes many assumptions about you, the reader. Hopefully you can find what you need in the EKG – Resources page.

  • You know what Terminal is (or Cmd and PowerShell). You know what $ means in script examples
  • You know Ruby, and maybe Rails (not necessarily version 6)
  • You know some basic database operations, at least enough to understand Sqlite db

Project Details

I’ll be working through the following details over the series:

  • EKG sample data / downloads
  • Streaming real-time data to client (websockets)
  • SvelteJS
  • ChartJS (as a SvelteJS component)
  • ChartJS real-time update
  • Display layout
  • Automated downloads of sample data (web scraping the EKG sample-data site)
  • Creating a desktop app (ElectronJs + SvelteJS)
  • “VCR” controls over display – a design addition leveraging our desktop/mouse/keyboard oriented implementation

Let’s get started!

BlazorWasm template for Visual Studio 2019

As of Dotnet Core 3.1 Preview1 (3.1.0-preview1.19506.1), the blazorwasm template is missing from the default manifest.

If you’re following FreeCodeCamp – How to create a SPA with Razor pages and Blazor then this is a problem for you! As well, the New Project UI has changed and does not follow the VS 2017 flow.

The solution is found here. Use the dotnet CLI to add the blazorwasm template and then to create the demo project.

dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.1.0-preview1.19508.20

Now dotnet new -l will show blazorwasm as a template option.

dotnet new -l

Templates                 Short Name    Language     Tags
----------------------------------------------------------------------------------------------------------------------------------
Blazor Server App       blazorserver    [C#]         Web/Blazor
Blazor WebAssembly App  blazorwasm      [C#]         Web/Blazor
                                                     /WebAssembly

And now, create the demo Solution :

dotnet new blazorwasm --hosted -o BlazorSPA

This creates the 3-project solution (--hosted) under the new folder blazorwasm (-o blazorwasm).

Update Oct 21, 2019 – Found “Get Started w/ ASP.NET Core Blazor” page, including Dotnet Core 3.1 compatible template.

Write Better Software : Embrace your Humanity

This is a bit of a stream-of-conciousness post about thought processes-vs-time.

As a software developer, I invariably encounter new challenging problems, algebraic, database, mathematical. I spend time working through these problems, and the larger more complex ones take significant time, hours, many-hours, days. The day problems are the frame of reference that is interesting here.

 
How do we solve our problems? How much subconcious thought is involved in brainstorming solutions, testing them against the constraints and requirements of the problem-set, and ultimately encountering a solution that fits?

 
I believe every human, in and out of technology work, encounters a situation to “sleep on it”. In the developer community, I have discussed with many many colleagues about problems and how a colleague solved it while eating breakfast, in the shower, in their dreams, etc. I have solved computing problems in every one of these ways, and I’m sure many more. I recall solving a problem while watching the sunrise once… and computing was not on my mind in the moment.

 
The fact is that every living moment of our life colours the work that we do in technology. These complex computing environments that we are implementing in technology today easily defy our abilities to immediately grasp the full-breadth of the design, the implications of design decisions, and the constraints, requirements, and responsibilities of components of the design at various levels of abstraction. Every time we are introduced to a new application design, it takes time to fully absorb that information and be able to make new hypotheses, suppositions, corrections, enhancements, and improvements upon that design. Our brain, though, is not as compartmentalized as we belive (or sometimes wish!). All those moments “off-hours”, spending time with family or friends, eating a meal, watching TV, reading a book, sleeping, dreaming… change the connections in our vast computational grey-matter. Those changes then directly affect the way we consider and imagine the technological problem-set that is also at hand over the time of days.

 
Our humanity colours everything we do and think about as computer scientists. It is extremely important that we embrace this aspect of our humanity, and embrace our colleauges humanity as well. Take time and give our wet-ware the computational time it takes to gain our insights and understandings of our common problem-sets.

“Sleeping on it” could be the best thing for your career you could do.

It has done wonders for my career!

Heroku ! Fingerprint already exists when key-comment does not match account email

I recently registered on heroku with my work email address : peter@fitzgibbons.info (obsfuscated)
My ssh id_dsa though is signed with my personal email address : peter.fitzgibbons@gmail.com.

Heroku doesn’t like this one bit.
Following this advice, I created id_heroku_rsa wtih my work-email comment.

Still no-joy.  But, this StackOverflow thread left a clue… using the ssh debugging output, I can see that ssh is still trying to send id_rsa or id_dsa.
The answer, included on that post is to ‘ssh-add’ the special key created.

Voila, now my push succeeds.

STOP SOPA

From Wikipedia on STOP SOPA DAY

Imagine a World
Without Free Knowledge

For over a decade, we have spent millions of hours building the largest encyclopedia in human history. Right now, the U.S. Congress is considering legislation that could fatally damage the free and open Internet. For 24 hours, to raise awareness, we are blacking out Wikipedia. Learn more.

BDD/TDD test cycle for beginners

I sent this message to a RailsMentor Protege of mine :

A couple notes on BDD testing :

1. Never test “the glue”. “Glue” means anything that Ruby or Rails should be doing “automatically”. That means, database querying, sending values from controller to view, etc. So, in a view test, you should be able to adequately test your views using the isolated view tests. This is where you could test that your table-building code is working right as you expect. Your controller tests should be able to be tested without database requests (mocking model instances), see #2.

2. Skinny Controllers, Skinny Views. Make your controller code, and your view usage as absolutely minimal as possible.
The ideal controller method looks like :
def show
respond_with @some_record
end

Yes, THAT SMALL. Rails framework provides a HEAP of assistive methods to accomplish that. #before_filter, #after_filter, #respond_to

Views should contain very little Ruby code. #render :partial and generous use of Helpers allows your view code to be very small (and subsequently, very testable). Repeatable elements like table-rows should be in partials, where they are easily testable.

3. Cucumber-level testing : Are you using Cucumber (http://cukes.info)? Cucumber scripts should really be reserved for “business owner specification”. A business owner would not usually be concerned with error handling or the exact placement (or even widget-type) of elements on the forms. The Business owner instead is interested in knowing that Page A => Page B => Page C works… or for instance, “If I buy product “Widget Sharpener”, then my shopping cart counter increases to 1 ”

There is a general BDD/TDD work cycle :

Create cucumber feature
Code supporting Cucumber step
Cucumber-RED : Cucumber execution fails because step causes failure in model/view/controller
Match expected functionality in model/controller/view RSpec
RSpec-RED : Rspec execution fails because functionality is not implemented
Modify model/view/controller with added functionality
RSpec-GREEN : Rspec now succeeds
Cucumber-GREEN : Cucumber now succeeds

You will often find steps 5-7 (Rspec Red/Green cycle) will repeat several times between Cucumber Red/Green cycles. This is our minute-to-minute Ruby-programmer’s work experience.

I’m looking forward to hearing more from you of your experience learning Ruby and Rails.

Brown Shoes Introduction

I will be writing about lessons-learned as I move through
the implementation of Shoes on Jruby.. known as Brown Shoes.

Repo – What’s what where

The Brown Shoes Repo is at : https://github.com/shoes/shoes/tree/brown_shoes – a branch on Shoooes Github project.

Right now there are two parallel implementations within
the brown_shoes branch.

At ./lib/shoes is the Eclipse SWT Library implementation.
This is using the expected event-loop main-display and
native SWT widgets.

At ./lib/brown_shoes is the Java/Swing implementation.
JFrame, JPanel, and a bit of AWT as necessary.

There are some issues found on the Pivotal Tracker for
Brown Shoes https://www.pivotaltracker.com/projects/444909

We need your help!

There are details about running SWT or Swing apps that
completely befuddle the newbie in this Jruby/Shoes
business. (namely.. ME!)

If you are a seasoned Jruby, Java/SWT, Java/Swing… or
maybe just JAVA developer, and have interest and a few
hours to spare, your expertise would be GREATLY
appreciated.

Who’s up for a fun challenge that will help Kids learn
Ruby – Hackety Hack runs on … Shoooes!