Redis: getting started and basics

Redis is a key/value in-memory datastore. The Getting Started guide will get you up and running pretty quick.

Startup:

./redis-server

CLI:

./redis-cli

From cli, inserting a value:

set key value

Get a value:

get key

List keys:

keys pattern

List all keys, not recommended against a large prod database:

keys *

Spring Boot: cannot find classfile ConfigurableApplicationContext (invalid LOC header)

Spring Boot with it’s maven starter dependencies is incredibly helpful to get a simple Spring Boot app up and running in no time, but occasionally you run into weird errors in Eclipse like:

The project was not built since its build path is incomplete. 
Cannot find the class file for 
org.springframework.context.ConfigurableApplicationContext. 
Fix the build path then try building this project

Or doing a mvn compile from your shell, something like:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] error reading /Users/kev/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.11/tomcat-embed-core-8.5.11.jar; invalid LOC header (bad signature)

Assuming you’re already using the Spring Boot Starter Web dependency:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

.. errors about Classes not found or errors reading .jars (‘invalid LOC header’) could be related to jars in your local .m2 repo being corrupt.

This is pretty easy to correct if you go into your ~/.m2/repository/ and delete your downloaded dependencies. You can be more specific in what you delete if you have something that you can easily identify as coming from a specific dependency.

Digital Research – Pacific Grove, California

Gary Kildall and his company Digital Research played a pivotal part in the history of the development of the IBM PC. IBM approached Bill Gates and Paul Allen to provide a number of programming languages for the original IBM PC, and later returned to Microsoft to ask if they could also provide the operating system. Not having anything available at the time, Gates suggested they talk with Gary Kildall at Digital Research, who had developed the CP/M operating system for 8080 based computers at the time.

The history of exactly what happened during the meeting with IBM and Gary’s wife at Digital Research may never be clear, but for whatever reason, Kildall was unavailable to discuss with IBM. When IBM returned to Gates and Allen, they decided to go talk with Rod Brock and Tim Patterson at Seattle Computer Products (SCP) and licensed their QDOS operating system for the 8086 for $10,000 and $15,000 for each company that licensed the product from Microsoft. This became the basis for MS-DOS, The rest, is history.

(If you’re interested, I highly recommend the book Fire in the Valley, a great book which covers the story of the IBM PC in detail, as well as earlier and later history)

The original location of Digital Research is at 801 Lighthouse Ave, in Pacific Grove, California. The building is now a private residence. On a vacation to Pacific Grove earlier this month, I looked up the location where the office was, and as it was only a couple of blocks from where we were staying, so we stopped by:

 

 

 

This IEEE have installed a plaque on the sidewalk outside the building to commemorate the contributions of Gary Kildall, Digital Research and the CP/M operating system:

 

Unit testing React components with Jest

Jest is a unit test framework for testing React apps. The Getting Started guide is pretty much all you need to get started. If you’ve created your project using create-react-app then you’re already setup, just run ‘npm test’ and a runner will test up that repeatedly runs your tests as you make code or test changes.

create-react-app also creates a sample test for the sample App.js component. This is a good starting point to follow for other tests:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
  const div = document.createElement('div');
  ReactDOM.render(<App/>, div);
});

To test the results of rendering a component, the enzyme library allows you to easily capture the output from a render, and then query the results. For example:

import React from 'react';
import ReactDOM from 'react-dom';
import {shallow, mount} from 'enzyme';
import Calculator from '../Components/CalculatorComponent';
it('renders with result 3', () => {
    const result = mount(<Calculator value1="1" value2="2" />);
    result.find('button').simulate('click');
    const buttonResult = result.find("#result").first();
    expect(buttonResult.text()).toEqual("3");
});

The CalculatorComponent I’m testing here is the one from my previous React post.