Author: Matt

  • Learning AI Algorithms

    One of my goals for the year is to get deeper into learning the new generation of AI algorithms and practice getting good at applying those to real problems. AI has been one of those areas that always fascinated me, and then I took the AI course at university and learned that it just wasn’t as difficult or as interesting once the covers had been lifted on the mystique of it.

    There are many approaches to algorithms that can be classified as AI.  If you consider that AI is the ability of a program to be given a dataset and then answer questions outside that dataset then something as simple as a linear regression is considered and AI.

    #!/usr/bin/env python3
    import random
    def linear_regression(x, y):
     length = len(x)
     sum_x = sum(x)
     sum_y = sum(y)
    # Σx**2 and Σxy
     sum_x_squared = sum(map(lambda a: a*a, x))
     sum_of_products = sum([x[i] * y[i] for i in range(length)])
    a = (sum_of_products - (sum_x * sum_y) / length) / (sum_x_squared - ((sum_x**2) / length))
     b = (sum_y - a * sum_x) / length
     return a, b # y = ax + b
    if __name__ == '__main__':
     simple_data = [[0, 10], [0, 10]] # slope=1, intercept=0
     print(linear_regression(*simple_data))

    random_data = [list(range(1000)), [random.triangular(20, 99, 70) for i in range(1000)]] # should be slope ~=0 intercept ~= 70 print(linear_regression(*random_data))

    In a real world example this would be expanded into an N dimensional regression where each dimension is an attribute.  As the data gets bigger and bigger, regressions need more advanced techniques to comute things efficiently.  But ultimately it never feels like you’re doing something emergent, you’re just doing math.

    Decision trees are another popular form of AI algorithm.  in the most basic form this is just a binary tree of questions, to answer a question like “do I have cancer?” you start at the top of the tree and answer yes or no questions at each node until you reach the leaf which should provide the answer.  Again these get more advanced as they are applied to more difficult use cases but never really get to the point where they feel like an intelligence.

    Neural networks and the new research in deep learning approaches are by far the most interesting, and yet they are also still nowhere near a state of general intelligence.  A neuron in a neural network is a simple program that takes input, modifies it and sends that as ouput and accepts feedback to re-inforce positive modifications.  These neurons are then connected into vast networks, usually in layers.

    The breakthough in deep learning is that we can provide re-inforcement at different layers in the network for successively more specific things and get better results.  Applied to a data set these can do remarkably well at thing like identifying faces in a photo.

    There is a bit of artistry required to apply these to a real world problem. Given data and a problem to answer from it, which type of algorithm do you use, how does the data need to be cleaned up or re-factored, how will you train and verify your AI algorithm afterwards?  There’s enough options there that just choosing a path to go on is often the most difficult task.

    The whole AI space still is at it’s infancy and really needs a genius to come in and shake up everything.  All the current approaches are narrow in scope and a breakthrough is required to find a path that will lead to a strong general AI.

  • SSL All The Things

    If you’re a frequent reader of this blog you might notice that eveything is now going through https.

    Thanks to the awesome people at Lets Encrypt I’ve managed to get free SSL Certs for many of my websites.  If it’s free why not encrypt all the things.

    Nobody uses telnet anymore when ssh is far more ubiquitous and secure.  Yet the use of unencrypted http is vastly more popular than the secure https version.  Why? Mostly because of cost and complexity with setting up https.

    Lets Encrypt is a pretty neat tool.  you run it on the server directly and it will validate the site automatically, generate the keys, install them into apache or nginx and modify the configurations to enable https for those sites.  It’s free and just takes a few seconds to generate and install the certificates.

    Now that it’s easy and free to setup SSL Certificates and enable HTTPS, I’m hopeful that it will force other SSL providers to compete and encrypted web traffic will become the norm instead of the exception.

  • Project Mu

    In a one night spark of interest I thought I’d write a webframework that deploys to Amazon Lambda and API Gateway.

    A web framework that deploys to a serverless environment is kind of an interesting idea.  Costs scale directly with the users and limit the base costs in some cases all the way to $0.

    Now that Amazon Lambda supports Python I thought it was worth trying to make something that allows you to manage a larger project in a way that is familiar to most web application developers.

    To start with I based the framework on the awesome Falcon web framework because it is 1. high performance 2. API focused and 3. very easy to understand.

    What makes this framework unique is that deployment needs to be baked in.  The framework needs to understand how the APIs are built in order to chop them up into stand alone functions and upload them to Amazon.

    The net result is an easy to use framework for developing APIs that can deploy directly to a scalable platform.

    It’s still early alpha stages but I’m hopeful that this or something like it will catch on in the future.  For those interested, you can follow the development on github.

  • Why You Need a Meta Project

    I got this idea from the guys at Yelp and how they manage their deployments and several internal infratructure tools.

    The basic concept is this: If you had a source of information about all your projects in a simple easy to work with format what kind of tooling would be easy to implement with it?

    Yelp does this with a git repository full of yaml files. coupled with a handful of commit hooks, cron jobs and rsync they are able to provide local access to this information to any scripts that want it.

    If you had the ability to get information about all your projects what kind of things would you want to know:

    • where is the git repository
    • where are the servers hosted
    • who should be notified if there are problems
    • how is it deployed
    • how can it be monitored

    With this information what kind of easy to write scripts could be developed?

    • connect to all servers and check for security patches
    • check all git repositories for outdated requirements
    • validate status of all services and notify developers of problems
    • build analytics of activity across all projects
    • be the source of information for a business dashboard

    Also interesting about this approach is that it easily handles new strategies.  If you’re deploying to Heroku, Elastic Beanstalk, raw EC2, Digital Ocean, or through new deployment services it doesn’t matter.  Create a new document with the information needed for a new method and write the required scripts that know how to use it.

    By not using a webservice or database you gain the simplicity of just dealing with reading local files.  This low bar makes it trivial to implement new ideas.

    A meta project: a project with information about other projects is an intriguing and powerful idea.

  • Raspberry Pi Zero

    I’ve been intrigued by the stuff happening in the IoT space over the last 6 months because I’ve been spending considerable amount of time working on an IoT project for work.

    Yesterday the Raspberry Pi guys put out a new model before the holidays.  A smaller device that costs only $5.

    A $5 computer.

    So I ordered one along with a couple of extra bits to help make developing an application a little easier.

    Not sure exactly what I want to do with it yet but I have a long list of possible ideas.

  • Server Security: Lesson #1

    A recent project I have been working on involved a custom built Linux distro running on an ARMv6 piece of hardware. We figured we were fairly immune to getting hacked based on obscure old hardware and pared-down Linux distro.

    Unfortunately, early in development for ease of working on things we chose a guessable root password.  By the time (months later) that we wanted to plug our device onto the internet for testing we’d long since forgot the state that we had left things with the root user account.

    It took just 1 week of being connected to the internet for the device to be hacked and malware installed.

    An investigation uncovered just how unsophisticated of an attack was required to gain access.

    So a lesson was learned by everyone on the team. Basic security precations such as using a strong root password should be made from the start – not procrastenated.

  • On Taking Action

    Many years ago I started reading and taking advice from a dating guru. One of the most important things I got out of the material was the frame of mind that being the guy who actually does things and leads by example is critical.  I changed from the guy who doesn’t dance to the one who is always first on the dance floor.  That re-frame cascaded into other areas of life.

    Being the first person on a dance floor takes confidence and an ability to see what to do and then take unilateral action. Taking action and following through until completion is something that I take a lot of pride in.

    Changing a broken lightbulb, writing code for a personal project, trying out a business idea or building something are action items that can make a real difference. Not every action leads to success, but luck comes to those who keep trying.

    Like this quote from Thomas Jefferson:

    I’m a great believer in luck, and I find that the harder I work, the more I have of it

  • Next Generation Productivity

    Computers have a long history of replacing the work of humans.  Before mainframes large businesses would have armies of people with punch calculators to do the work that is now in a single spreadsheet (each person performing just a cell of that sheet).

    Over the past 60 years the primary productivity benefit from computers has been the ability to do our math work and implement logical rules on data.

    It seems like we are finally getting to a point where computers can start to do some of the softer skills normally only done by humans.

    Projects like OpenCV and Scikit-learn give mere mortal programmers the ability to write software tools that are astonishing.  There are a growing catalog of libraries for deep learning, big data and natural language processing that are at a tipping point of being easy to use and deploy.

    The next generation of productivity wins will come from leveraging these new tools.  Smart email auto-replies, smarter code completion, smarter communication, and plumbing together of much more complex automations. Talking to computers as if communicating to a human and expecting it to understand.

    This may be the final turning point in productivity where humans lose the ability to keep up or find a new industry to be employed.  One of the fastest growing segments of employment is being a personal trainer.  Computers so far have failed to provide a compelling replacement to person-to-person motivation at the gym.  However there is no guarantee that those jobs are not at risk given smart watches and connected equipment paired with sufficiently written software.

    If that is the case then a good strategy would be to try and be on the side that takes advantage of the productivity gains and not on the side that will become unemployed because of them.  If a doctor using the latest in AI tools can see and treat 5x the number of patients as one who doesn’t use them then if you’re a doctor you should try to avoid being one of those doctors who can only examine 1/5th the number of patients.

    These kind of productivity gains will take time to fully materialize but perhaps less than you expect. As they come into play more wealth will consolidate into the hands of those at the head of the curve.  It will increasingly be difficult to keep those jobs that are automatable.

    It seems inevitable that this will happen and it’s up to you to make career moves that will land you on the side that stays employed.  If you’re in a position to leverage these new AI tools it will be in your personal best interest to do so.

  • The Bots Are Coming

    Slack is the fastest growing startup in history, and it is starting to drive a new kind of interface for users to make things happen within their businesses.

    If you remember way back the only way you could interact with a computer was through a command line.  With this interface you form very specific commands that require a manual for reference. Then with the advent of the mouse and graphical operating systems, these command line tools were mostly replaced with buttons and menus. This opened up computers to a new level of novice users, but there still was a need for manuals and books to learn how to use all these graphical applications.

    Today we have two new possible interfaces for how you can make computers do what you want.  Voice systems like Siri offer a compelling next generation way to talk to a computer with your voice but the technical demands for integrating this technology is still FAR too difficult to make it work with arbitrary custom software.  The other option is bots that run in chat systems like Slack that can offer natural language interfaces that blur the boundary between what we have come to expect of computers and what the future may be like.

    Slack

    The other night I programmed a quick slack bot powered by the script from The Big Lebowski (one of the best movies ever).  This simple script interacts with the user in a conversational way and took less than 1 hour to implement.

    This type of interaction offers a future where we can casually talk (through typing) to the computer and have it do things on our behalf.  It doesn’t require a manual to know how to specify commands.

    This seems like a step in the right direction towards a broad range of tools that work in a more natural way.  Ultimately replacing the text input with voice will bring us to a Star Trek style future. But until that time comes we will be continuing to develop frameworks that allow developers to create interesting tools that know how to interact with users naturally.

    These bots can trigger plenty of things that might not have been possible with other interfaces.

    >> matt: hey @meeting_assistant, start a meeting with @jack and @jill

    >> meeting_assistant: ok @matt, join the Google hangout <here>, I’ll keep meeting minutes of anything you type in here.

    >> matt: @jack can you contact the client about that thing at that place tomorrow?

    >> meeting_assistant: @jack I added a reminder to your calendar for this ^^

    >> matt: @meeting_assistant, all done.

    >> meeting_assistant: ok, I’ll email the meeting minutes to everyone.

    This sort of theoretical chat bot is now entirely possible and it may just usher in a new age of business communications.  It’s now easy to forego the large enterprise application development cycles and instead focus on small text based services that can easily be deployed.

    The future of this kind of interaction may create a new opportunities to reduce costs and streamline business functions.  By triggering messages based on external events it’s possible to prompt employees to their maintain their workflows, or reward them automatically:

    >> time_bot: @matt, you haven’t recorded your time for yesterday.  please update your timesheet.

    >> overtime_bot: @matt, thanks for staying late, but it’s time to get back to your family

    >> kpi_bot: @matt, your performance has been exemplary this week, we’re sending you an Amazon gift card as a thank you.  Keep up the good work.

    I think this could be a big shift in how businesses run.  And companies that take advantage of this next generation technology stand to gain a tremendous competitive advantage in the coming years.

  • Productivity of higher level languages

    I recently had an experience where I was given the same programming problem as a handful of other software developers.  My advantage was that I was using Python while the other people were forced to write their solution in Java or C.

    The difference in the amount of time it took to solve the same problem with a different language was striking.  Most other people completed in about the 45 minute mark whereas I had finished in just 15 minutes.  An average of 3x less time.  That’s a massively significant difference in developer performance that comes primarily from using languages that aim to be readable and focused on developer productivity.

    I’d always known that Python was a productive language but that was the first time that I had experienced first hand just how beneficial it can be to switch from one platform to another.

    Imagine taking a 3 month project and complete it in just 1.  That’s a massive savings; enough to change a business idea from impractical to highly lucrative.

    One thing I’ve learned over the last couple of years is that with the right approach and the right tools you can make difficult application development accessible to even small budgets.  Sometimes it requires creative thinking and accepting unconventional solutions.

    I’ve worked on $1M projects that could have been MVP’d for 20 cents on the dollar by choosing different technology and different developers. It’s quite shocking to see just how variable it can be to develop the same software with different tools.

    If there’s a lesson in this it’s: Take care when choosing the people and technology.  The right choice can save you a tremendous amount of time and money.