Angular & MaterializeCSS

During the last year, I’ve developed numerous websites and mobile applications using the Angular framework. I’ve used numerous CSS frameworks as well such as Bootstrap, Ratchet, and Topcoat. But recently, a customer asked me to use MaterializeCSS. MaterializeCSS is a library of CSS and JavaScript code to easily create a material design experience for web applications. It’s quick, easy, and visually appealing. Unfortunately, getting some of the components to work with Angular proved difficult as the online documentation does not show how to setup Materialize for Angular. While most of the components do not require any JavaScript interaction by the developer, some components (such as select option lists or tabs) require initialization. The documentation says that tabs can be initialized by using:

var instance = M.Tabs.init(el, options);

Unfortunately, this won’t work in Angular as you’ll get numerous errors regarding undeclared variables. How can you hook this up properly?

First, declare the ‘M’ variable inside the page component below the imports. This will allow you to use the ‘M’ interface to MaterializeCSS from within your Angular code.

declare var M: any;

Next, get a reference to the object you are trying to interact with. This can be obtained by using a querySelector for the class of object you’re trying to initialize. For instance, tabs will be declared in HTML by assigning a class=”tabs” attribute to object. Once you have the object, you can initialize it by calling the appropriate method. This should all happen on the init method of your page object.

ngOnInit() {
  const elem = document.querySelector('.tabs');
  const options= {};
  M.Tabs.init(elem, options);
}

This is identical for any other object that requires MaterializeCSS initialization and can also be used to call any other functions in the MaterializeCSS framework.

With this information, you should be able to enjoy the benefits of Angular as well as the awesome UI elements of MaterializeCSS to their fullest!

AI Resources

Today, there are countless AI products and resources available for the developer. I’d like to review a few of the resources I’ve used.

AIFH

The first resource on my list is AI For Humans (AIFH) by Jeff Heaton. Of all the books on programming artificial intelligence, his books are by far the best. Written without any heavy math, Jeff’s books explain just about everything you could want to know about artificial intelligence. Additionally, Jeff has his own framework called ENCOG which can be used in Java, or can be run as a standalone GUI for development. Of all the resources I’ve used to date, this is without hesitation the best.

AWS DeepLens

I was recently sent an AWS DeepLens by a client for an artificial intelligence project. It’s always exciting to receive hardware from a client, so I was certainly looking forward to this! Unfortunately, my experience with it has been a bit less exciting. For starters, I’m stuck trying to figure out what exactly the purpose of this box is. Am I to use this to learn artificial intelligence? Is this box intended to be embedded within a product? I have absolutely no idea. While the DeepLens is a neat toy, the setup is far from simple. An internet connection to AWS is needed, certificates need installed on your machine, and everything is configured through your Amazon account. Even worse, the service does not appear to be free. (Note, you do get one free year on AWS, but after that you pay for the service. After that, I have no idea what it costs to run the DeepLens, but I’ve noticed warnings about costs associated with some actions). I applaud Amazon for trying to bring deep learning to the masses, but I think this product is a dud.

DL4J

DeepLearning4Java (DL4J) is a Java library for deep learning AI. Written by SkyMind, DL4J is one of the most well-known AI libraries for Java. With the earlier versions of DL4J, the user would have to install various native libraries such as ND4J (N-Dimensional Arrays 4 Java). This proved to be more difficult than it sounds as various libraries were dependent on other libraries, documentation was scarce, and error messages were cryptic at best. Fortunately, with the 1.X version of DL4J, the install process is streamlined to sampling cloning a repository and running a maven build. Native libraries are managed within the maven build, saving users the trouble from earlier versions. With these changes, DL4J is an excellent framework I would recommend for any AI project.

Killer Robots

During the last year, countless tech leaders have talked about the danger that artificial intelligence could pose in the future. Like most people, I laughed at them. After all, do I really think that The Terminator or The Matrix were prophetic? Hardly. But the more I read and the more I pondered it myself, the more concerned I became. Now, I wonder if there’s any way to prevent it from happening at all.

Is it really reasonable to think AI could take over the world? Do we really think code will be so poorly written and that software testers will be so incompetent as to let AI robots kill humanity? Unfortunately, I do. Not intentionally, of course, but bad code that wasn’t properly tested will make it into the wild on robots. Consider all the system updates that have been performed on your computer or your cell phone. Think about all the app updates that happen every single day. Consider all the one star reviews for apps on the mobile stores. AI will be no different.

Consider all the potential causes of AI issues. Developer errors, inadequate testing, corporate release requirements, poorly defined ethics, unforeseen events, etc. Each one of these issues could cause AI to perform in ways it was not intended with potentially catastrophic consequences. Consider government AI being developed by the lowest bidder – wow, that’s scary.

The more I think about that, the more certain I become that AI will eventually cause huge problems to the world. As such, it’s imperative that we – the tech community – consider the limits of AI – not in regards to technology, but rather in regards to safety and security. Do we want AI police officers or soldiers? That sounds dangerous. Could Russian hackers embed “Order 66” into our own robot army? Do we trust robots with firearms to make the appropriate decision in a life-or-death situation?

My intent is not to sound like an alarmist, but rather to begin thinking about the issues now. If not, we may find it’s too late to do so later.

How I Got Here

During the last decade, I have been asked countless times how I would recommend someone get into the programming world without going to college. Many people don’t want to spend the time or money getting a computer science degree, and since I did it people generally assume I can tell them the shortcut to achieve the same in their life. Unfortunately, few people really realize the amount of time and effort it took for me to get where I am or the difficulties I’ve encountered by not having a degree in a field where a degree is expected.

I didn’t start working with computers until around 1997. I was in the US Army at the time, and worked exclusively with Unix machines. Unlike the Windows world, the Unix world has always had tools for developers. The machines I worked on had C, C++, Perl, Tcl/TK, Fortran, Bourne Shell, and numerous other programming tools. During the course of my work, I often used scripts written by others, and soon learned to modify them to do what I wanted them to do. I purchased programming books from Amazon and decided to learn more. At home, I setup an old computer to run Linux so I could have a similar development environment to the machines at work. As time went on, I decided to take courses through the National Cryptologic School on Perl, Unix Administration, C Programming, and other tech subjects. After becoming pretty comfortable with C, I decided to further my education through a correspondence school (the now defunct National Radio Institute) where I earned a diploma in Visual Basic Programming (as I was already pretty comfortable in C, I figured it best to branch out and learn a new language). A few years later, I took a few courses from the University of Maryland in C++ programming. Throughout this time, I spent countless hours at home learning everything I could about programming. I wrote programs to do all kinds of things – from GUI development to command line scripts. This was a difficult time in my life – working a full time job while spending all my free time learning to write computer software took a heavy toll on my marriage. But it would all be worth it when I got out of the Army and found a job in the software realm.

Then, in 2001, it was finally time to step out and find a programming job. Of course, I had no real experience as a programmer. I had written some code and scripts in the Army, but hardly anything that would really be considered production code. None-the-less, I managed to find a local company that needed an entry level programmer. And, thanks to a friend who knew the owner, I was offered a position. In my hubris, I assumed I knew everything at that point in my career. It would take years to fill the gaps in my knowledge to become a good programmer. With project after project under my belt, I would finally become a respected developer around a decade later.

What has my lack of degree caused me? During my entire career, I have found countless companies that wouldn’t even talk to me because I didn’t have a degree – they were unwavering on their requirements for a BS in Comp Sci even though I had been working in the field for years. At various companies I worked at, it became obvious that I would never be promoted simply because I didn’t have a piece of paper. Even though I could code better than my peers, my lack of degree held me back.

At no point has my path been easy. It’s involved an incredible amount of work and sacrifice. And if you’re thinking of teaching yourself to program and find a job, I wish you the best of luck as you are about to find out that it takes far more than watching a few online videos and making a webpage.

If you do choose this path, how can you make it successful? Passion – you must have an unwavering passion to write code. You need to spend every waking hour writing code, reading books, watching videos, and doing everything you can to become a good programmer. Expect to put in substantial time and effort. Expect to struggle finding your first job. Expect difficulty advancing in your career. Don’t think for a minute that it’ll be easy – I can promise you, it won’t.

Change is Good

Yesterday, I took the Myers–Briggs personality test online. I’ve done this many times in the past, and I always come up INTJ – “The Architect”. This is a great personality type to be – listed as being imaginative and strategic, independent and decisive, hard working and determined, and having high self confidence. But as I began my journey into entrepreneurship, I realized that being an introvert wasn’t such a great idea. So, I decided to work to change myself to be more extraverted. After all, if I can’t comfortably talk to people and sell my services to clients, it’s going to be difficult to run my own small business selling software services. To make this change, I started reading books a year ago on small talk, communicating in social settings, and similar skills needed to be an extravert. I also read books on sales and leadership. After all, being an extravert isn’t going to get me far if I can’t sell myself or if I can’t project myself as being a leader in both business and software development. So, when I took the personality test yesterday, I was pleased to see that I have changed to ENFJ. Not only have I become more extraverted, but I have learned to rely more on my feelings instead of just logic. As a software engineer, that’s tough, but the world of people is rarely a world of logic – it’s a world of feelings. If you can’t relate to someone on that level, logic won’t get you very far.  Now, instead of being “The Architect” I’m “The Protagonist”.

Are you growing and changing? Is You 2.0 going to be better than you are today? What are you doing to get where you’re going? Are you willing to work to change the most basic elements of your own self to move your life in the direction you want?

Social Networking

On Tuesday, my daughter and I embarked on an epic rail journey from Anaheim, California to Altoona, Pennsylvania. As I write this, I’m sitting in the lounge at the Chicago Amtrak station. Tomorrow, after another two trains, I’ll finally arrive home.

Anybody who knows me knows I love to travel by rail. While air travel is fast, it’s rarely fun. Rail is the opposite – much slower, but generally an enjoyable experience. One of the best parts of the train is the dining car. Not only is the food good, but due to the limited seating, you end up sitting with strangers. This is always a great way for real social networking. Tuesday night, my daughter and I sat with a couple retired from John Deere. He worked in the factory, and she spent years working in HR and in training other divisions. She was also a frequent traveler to Europe. The next day, I shared a meal with an outspoken Trump supporter and handwriting analysis export, a rail advocate and teacher, and a man who inherited land in the deserts of California. This morning, I shared breakfast with a pastor and his wife from Minnesota who work with troubled inner-city kids.

Unlike Facebook, Twitter, and other so-called ‘social network’ sites, riding the rails gives me an opportunity to share a meal with people across the country. People who are from different states, with different political views, different religious views, and every other difference imaginable. And, unlike social networking sites, discussions are typically cordial and enjoyable. I get to interact with people as people – not as a digital persona. I get to see them as a human – not as a highly curated avatar. These experiences are what real social networking should be about – not an anti-social experience behind a computer screen.

Today, instead of interacting with people on a computer, why not invite a friend for coffee, have dinner with your neighbor, or invite a coworker over for a burger. You’ll find the social interaction far more rewarding than Facebook.