Learning the Hard Way

Image for post
Image for post
Photo by Matt Botsford on Unsplash

In my free time, I am attempting to build my own smart home devices. One feature they will need is speech recognition. While I am not certain yet as to how exactly I want to implement that feature, I thought it would be interesting to dive in and explore different options. The first I wanted to try was the SpeechRecognition library.

Why the hard way?

To put a long story short, this tutorial is going to be a little bit different. There were several errors I had to deal with and even redirect my focus. That being said, the coding portion is simple. Only a few lines of code to get it working. The installation took time and effort, but with research it was manageable. Instead, the issue was in the systems I was deciding to use. For example, the first attempt was on an Ubuntu server. Nothing wrong with that, but the default device could not be changed, seeing as the code is being run through ssh. I would have to go to the server and plug everything indirectly. Again, nothing wrong with that. I was just hoping for an easier option. …


Image for post
Image for post

Backstory

Recently, I thought it would be kind of fun to take a walk down memory lane and examine some of my old Github repositories from past hackathons. Over the years, my team and I learned a lot while trying to cover a range of topics such as artificial intelligence, Flask, APIs, front-end Javascript frameworks, and playing with Raspberry Pis. While looking through these repos, there was one in particular that stood out to me.

Back in 2019, we attended Kent Hack Enough and built an application that would turn on/off remote-controlled outlets. To achieve this, we used a Raspberry Pi that has a radio frequency transmitter and receiver attached to it. …


CODEX

Image for post
Image for post
Photo by Clayton Robbins on Unsplash

A while back I found out about Kivy, a Python framework, but never got around to trying it. Recently, I was digging through my notes on the different languages and/or frameworks I wanted to learn. Kivy would be an interesting adventure, but what to build?

Going back to the basics, I decided to build a calculator. Nothing fancy about it. Just add, subtract, divide, and multiply. Although simple, it would be a good way to get familiar with the syntax. Before getting started, we need to know a little more about Kivy.

What is Kivy?

Kivy is a free and open-source Python framework. It is also cross-platform and will run on Linux, Windows, OS X, Android, iOS, and the Raspberry Pi. Being free to use, it can be used for business or personal, business being under an MIT license. Kivy can be used as an open-source UI, a structure for APIs, a Kivy server, as a website, for programming on iOS and Android, or even for gaming. With so many uses, and being free, Kivy would at the least be something interesting to learn. …


Part 2: Building the API

Image for post
Image for post
Source: How-To-Geek

Recap

My previous post discussed our plans for the project and created the database for a new phone directory. In this next part, we will take the project a step further and create an API (Application Programming Interface). To accomplish this task, we will utilize the Python programming language and the popular framework FastAPI.

Design

Before diving into the code, it's always a good idea to start off by figuring out a plan. Thinking about what our API is going to look like, we are going to need at least four endpoints:

GET — /contactsapi/v1

This endpoint retrieves a list of all contacts from the database. …


Building Pong

Image for post
Image for post
Photo by Jason Leung on Unsplash

The Inspiration

As an avid gamer and a collector of gaming systems, I knew that I would want to create a few games of my own. Several years ago, a few of my games were even on Gamejolt. Between work and University, the passion dwindled as my time did. However, recently I have been wanting to start writing videogames again. To relight the flame, I decided to take a dive into making retro games for a Raspberry Pi.

With a heavier background in Python, developing videogames using PyGame was an obvious choice. Knowing the game should be straightforward, Pong was my choice. Pong is a simple game with two paddles and a ball. …


Part 1: Creating the Database

Image for post
Image for post
Photo by Paweł Czerwiński on Unsplash

The Idea

In this day and age, the need to keep a paper copy of your contacts and their corresponding information has become obsolete. The rise of cell phones and the cloud has paved the way for people to access this kind of information within a few seconds using just their fingertips. But what if you happen to lose access to your contact information? Granted, this is a very unlikely scenario, but in the high-tech world, it’s always a good idea to have a backup of your data.

Our project will contain three main parts:

MySQL Database

We need a place to store our contacts and their corresponding information. MySQL is open source and can easily handle this job for us (SQLite, Postgres, etc. will work just fine too). Starting out, the database will contain four tables. The first table we will call ContactType. Essentially, this table will contain the different types of contacts within our list. This can be individuals, businesses, etc. The fields for this table will…


From Installation to Implementation: Part 2

Image for post
Image for post
Photo by Maarten van den Heuvel on Unsplash

Recap

In part one, I started building a database to use for a monthly
budgeting application. After installing MongoDB, we discussed
a brief overview of how to create a database, our first
collections, and inserting documents. With some general
knowledge about MongoDB, the goal is to finish building the remaining collections for the application, and to also learn more
about the syntax of MongoDB.

Continuation

Now that we have one collection created, we can look into understanding the many options that may be imposed on a collection. One such option is to add a maximum collection size to ensure data will not consume excessive space. …


Using FastAPI to generate JSON Web Tokens

Image for post
Image for post
Photo by Philipp Katzenberger on Unsplash

Recently, I wrote a series of posts explaining how JSON Web Tokens could be utilized in an API that was written using Flask. However, a few weeks ago, I discovered how awesome FastAPI is and have been wondering if it’s JWT validation techniques would be a better fit for what I need.

Planning

Before we get started writing any code, it’s always a good idea to do a little planning first. Thinking about the design of the API, we are going to need at least two endpoints.

  • POST — /authenticationapi/v2/create
  • GET — /authenticationapi/v2/login

The “create” endpoint adds a new user to the system while the “login” endpoint generates a token for the user. The really cool part about FastAPI is that it has support for pydantic models. Essentially, these models define what the data being passed to the endpoint should look like. They also validate and return an appropriate error for invalid data. The model for the “create” endpoint will look something like…


From Installation to Implementation: Part 1

Image for post
Image for post
Photo by Prateek Katyal on Unsplash

On the journey to broadening my horizons, I often wondered what a non-relational database would like on a personal monthly budget application. Thinking about the data being stored, it would need a collection of different flexible tables.

In a few different Hackathons, I have heard mention of MongoDB, although I did not know much about it. MongoDB uses NoSQL instead of a relational format to provide flexibility and primarily focuses on documents. With the flexibility of NoSQL, it would be nice to have a collection of receipts without having column restrictions.

Feeling adventurous, I decided to delve into the world of non-relational databases. Before installing MongoDB, I need to know what a NoSQL database is and what type of data it can store. …


I’m sorry Flask, but FastAPI is so much better.

Image for post
Image for post
Photo by Guillaume Jaillet on Unsplash

All across Medium and social media, my feeds have constantly been posts about why people should use FastAPI for writing APIs in Python. Seeing this, I was a little shocked, because I was under the impression that Flask and Django were the major Python API frameworks. For the last few years, Flask has been my go-to framework for writing APIs. With all this hype surrounding FastAPI, I decided to give it a try.

Giving it a Try

With the discovery of FastAPI, I decided to revisit an API that was built a few months ago to handle application logging. Essentially, the plan was to convert this logging API from Flask to FastAPI. …

About

Mike Wolfe

Software Developer, Tech Enthusiast, Runner. Current project http://sqlcheater.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store