Programming

What’s Old Is New Again – App Store

I decided last night to renew my Apple Developer Account and decided to work on apps again. As a result my old App came back to the App Store. This app is the “Are You Worthy?” App, which is basically a Magic 8 Ball to test to see if you’re worthy of wielding Thor’s Hammer, Mjolnir. Nothing fancy just for fun.

I also decided to build a new app as the last time I did anything with React-Native and Apps was 2018. I pulled a website and idea I was going to build in 2011 back out of the archives. It’s called DriveTime App. The idea of this app is really just designed to track trips to work, see which ways are faster if and when there’s traffic on your favorite route. For me there’s several alternatives and back-ways to get to and from work, this app just lets me track those routes and pick the fastest one should a delay occur.

You’re Doing Your Tech Interview Wrong – 21 Tips

Here are 21 tips I’ve used when interviewing/hiring hundreds of people over the past 5 years. I hope you find them useful.
  1. If you’re asking questions that can be Googled, you’re wasting everyone’s time or you’re lazy.
  2. If you’re not asking questions that indicate someone’s attitude, you’re missing about 80% of their ability to succeed.
  3. A small test of fundamentals is far more indicative of success than gotcha questions.
  4. Ask what they do for fun and outside of work, get them to talk about it.
  5. Have the interviewee pair-program with you for a simple problem or two using the answer from 4 above.
  6. Focus on communication, curiosity, and creativity when pairing vs. the right answers.
  7. Understand how they work. Headphones on and solo? Or are they happy chatting and talking at a large table of other developers?
  8. Challenge them beyond their level of expertise and see how they respond. How do they respond to failure?
  9. Do they smile or laugh at themselves? Not taking yourself too seriously is pivotal to team dynamics and flexibility as requirements and projects change focus.
  10. Do they work on their own stuff outside of work or do they play video games or engage in other passive activities?
  11. Do they share? Have a blog? Are they on GitHub?
  12. Don’t give a code test and ask interviewees to perform “test”. This is another waste of time and a lazy way of evaluating candidates.
  13. See tip #1, #12 and don’t give the impression you’re too busy to interview someone, you’ll only get desperate developers.
  14. Developers with computer science backgrounds do just as well as those without.
  15. Introverted developers are just as good as extroverted ones, don’t confuse personality with ability.
  16. The fit is more important than ability if you’re interviewing someone for a maintenance role that’s much different than a greenfield project.
  17. Your interviewee should interview you, it’s a two-way street if they don’t ask questions about the culture or project that’s a red flag.
  18. Why are they looking to change careers? This will give you insight into how they will fit into your company/culture.
  19. Read their resume and ask questions about the skills they say are their strongest, be to the point and if they say they are 8/10 on a skill, inquire on that, not on something they might know.
  20. Ask how they learn new things, some people are book learners, others are doers.
  21. Trust your gut, if you don’t have a good instinct for people, bring someone who does into the evaluation process.

As I said I’ve interviewed hundreds of candidate and learned a lot over the years when evaluating people for potential roles and these ones seem to work the best.

3 Trends about to take off

alexa-small2017 is halfway over and while some of these trends started a few yeas ago I think we’re about to see a few of these really catch-on, and by catch-on, I mean go mainstream and get funded.

Over the next week I’m going to discuss these three trends in a little more details and provide some code or projects to help you get started!

Trend 1 – Alexa / Voice / AI Chat

What does user experience look like without a mouse & keyboard or easy to enter form fields? How do people talk to AI systems to solve problems? These systems can be through devices like Alexa or virtual systems like automated chatbots. Understanding psychology and human behavior become just as valuable as business knowledge when designing these systems. Because of this we will see new software architectures come into play that deal with these variations and have multiple and guided user flows.

Trend 2 – JS/UI Architecture

SPAs (Single Page Applications) built on frameworks like Angular and React changed the way we think about building software. But for the longest time it was code, code, code without much thought of how it’s going to scale, and how it’s going to be supported in the enterprise. These systems need to hang around and be maintainable for 10 years, refactoring your apps should not have to entail complete system rewrites. Having architectures for UIs that allow for modular building and refactoring are crucial for adoption of these technologies that change every 9 months.

Trend 3 – Augmented Reality

There’s more and more data about the world around us. Why not provide more ways for people to interact with this data? Why make everyone have to look something up on a browser or an app? Voice combined with computer vision begins to bridge this gap. Google Glass still might not be the right use case, but camera augmentation, heads-up displays in cars, smart kiosk and push voice will be where this begins to have application.

Redux’s Connect Method Explained.

Sorry but all the explanations this far have been bad so I thought I’d simplify it.

In plain Redux without connect you need to manually bind up your store.dispatch to your components as well as subscribe to updates so you can call store.getState(). But your components are suppose to be dumb.

const store = createStore(reducer);

const render = () => ReactDOM.render( // turns ReactDOM.render into executable function
  <Counter
    value={store.getState()}
    onIncrement={() => store.dispatch({ type: 'INCREMENT' })}
    onDecrement={() => store.dispatch({ type: 'DECREMENT' })}
  />,
  document.getElementById('root')
);

render();
store.subscribe(render);

So rather than manually linking dispatch and subscribing to updates we create two mapping functions, both of which bind the dispatch and the state to props of the ‘connected component’. So in this case all updates to this.store.getState().value are mapped to this.props.value and rather than mapping dispatch directly, we just wrap it and pass it in as a prop.

// create component
class ContainerComponent extends React.Component {
  render() {
    <PresentationComponent 
      value={this.props.value}
      onIncrement={this.props.onIncrement} 
      onDecrement={this.props.onDecrement} />
  }
}
// create state mapping
function mapStateToProps(state) {
  return { 
    value: state.value
  };
}
// add dispatch mapper 
function mapDispatchToProps(dispatch) { 
  return { 
    onIncrement: function() { 
      dispatch({type:'INCREMENT'}); 
    }, 
    onDecrement : function() { 
      dispatch({type:'DECREMENT'}); 
    } 
  }; 
} 
export default connect(mapStateToProps,mapDispatchToProps)(ContainerComponent);

Now when you call your components you can simply call the value passed in like so.

export default class PresentationComponent extends React.Component {
render() {
    return (      
        <div>
<span>{this.props.value}</span>
<button onClick={this.props.onIncrement}>Increment</button>
<button onClick={this.props.onDecrement}>Decrement</button>
        </div>
    );
  }
}

For more information you can checkout both of these github projects for reference.

JavaScript has become Java, sigh…

  • If I wanted to work with compiled languages, I would have stuck with Java.
  • If I wanted complicated build systems, I would have stuck with Java.
  • If I wanted complicated all encompassing frameworks, I would have stuck with Java.
  • If I wanted complicated unreadable error messages, I would have stuck with Java.
  • If I wanted to run server side code (Node) in my browser, I would have stuck with Java.

Something needs to happen to fix JavaScript making it more and more like Java is not the answer. Or is it time to move to another language with less ceremony???

libopenzwave.so error

If you’ve ever seen this error:

MinOZW: error while loading shared libraries: libopenzwave.so.1.3: cannot open shared object file: No such file or directory

or 

Error: libopenzwave.so.1.3: cannot open shared object file: No such file or directory

Just type this and it did the trick for me (Ubuntu 14.04).

sudo ldconfig /usr/local/lib64

 

Openzwave Binary Sensors

I’ve been struggling a bit with openzwave items because its so poorly documented. I’ve finally figured out how to get results from a door sensors with the node package node-openzwave-shared.

If you follow the install script, then just add this event handler below, you can receive updates.

zwave.on('node event', function(nodeid, nodeEvt) {
 console.log(new Date(), 'node event', nodeid, nodeEvt);
});

More live examples coming soon here: https://github.com/scottpreston/node-openzwave-examples

And via npm via npm-install node-openzwave-examples

Simple WebSocket & NodeJS Server Example

I’ve been searching for a NodeJS server for web sockets, but socket.io, required both the client and server to be run from within node. I wanted to connect to this server via a normal web page using WebSockets from HTML5. Here’s some code, hope you find it useful:

https://github.com/scottpreston/examples

Server Code

var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({port: 3000});

wss.on('connection', function (ws) {
    ws.on('message', function (message) {
        console.log('received: %s', message);
        ws.send(message + "!!!!");
    });
});

Client Code

    var websocket = new WebSocket('ws://localhost:3000');
    websocket.onopen = function (evt) {
        websocket.send("This Rocks!");
        websocket.close();
     }
    websocket.onmessage = function (evt) {
        console.log('RESPONSE: ' + evt.data);
    };

 

Home Grown Script Loader

I was wondering how RequireJS and AMD worked. So I created this snip. It might not be correct but it worked for me.

load('foo', function (foo){
        var f = new foo();
        f.a = 100;
        f.b = 200;
        alert(f.add());
    });

    function define(name, callback) {
        modules[name] = callback;
    }

    function load(file, callback) {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.async = true;
        script.src = file + ".js";
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
        script.onload = function() {
            callback(modules[file]);
        };
    }

    var modules = [];

// foo.js
define("foo", function() {
    var foo = {
        a: 1,
        b: 2,
        add: function () {
            return this.a + this.b;
        }
    };
    return foo;
});
Scroll to Top