Monthly Archives: April 2019

Refactoring++

The title is a bit of a joke since ++ is a way to add one to an integer in C++, but not so much in Python.

While I was refactoring my code, Corey Schafer released a video for cleaning up Python code. So I watched a bit of it and got some pointers to start using in my programs. I learned about the zip() and enumerate() function from the video and have begun to implement them. It does make it look better for sure.

I have updated MOST of my imports in both the sensor program and the control center. The import modifications have made things clearer for where functions and variables are stored. Variables and functions have also been relocated to places that make more sense.

That’s it for today. Until next time!

Refactoring!

Ahh, I managed to get a few good hours in for refactoring. The imports are now standardized. AKA I import like this ‘from folder import module’, which I then access everything from it with module.whatever or module.whatever_function(). This makes it a LOT simpler to find out where everything is located. So tracking down functions and variables is easy now.

I also spent a good few hours on the local management and information HTML webpage. It uses a dark theme and displays all the useful data and links minus actual sensor readings, for which I am going to make another custom page which will have things like automatic reading updates, color changes based on sensor readings, etc. I have not even started on the page yet, but the empty functions are all set to be filled in. I’ll probably work on that one too before a new release.

The 2 things left to do before a new release are.
1. Refactor the control-center program like the RP sensor program (imports & naming).
2. Create a decent sensor readings webpage.

I suspect I’ll be ready by the end of the month. Yay motivation and progress ^_^

New Release soon

I’m fairly happy with my new program updates. The notes work well, the database information window shows useful database information, and I have put in a mini web interface for sensor interaction on the local web server (AKA control the sensor from a webpage served by the sensor). I might tweak the sensor report on the local web server but beyond that, it’s all about refactoring before the new release.

Starting on the local web server interface will make creating an app for the phone rather simple (web page wrapper). Although just bookmarking the sensor website is not difficult (So long as you know the port #).

I haven’t read too much more on the Machine learning yet, but it’s still progressing. I expect I’ll do some more serious reading next week.

That’s it for now.

Notes updates

I’m still slowly doing the notes section. I’m just finishing up on the dual DateTime entries in order to have a reliable index of notes and the ability to place a DateTime stamp for where the data is, that the note pertains to.

After this, I should do some refactoring. For one, I would like to maintain file imports so usage is imported.whatever, in order to easily see where said class, function or variable reside. So that’s going to take a bit and I’ll want to re-word some naming schemes so it doesn’t get too long like some_really_long_import.SuperBadAssClassWithCherriesOnTop()

I’ll have to remember to set aside time for refactoring, in order to bring older code up to my newer standards.

Off to do a bit of work.

Spring is here and progress continues

I’m happy to report most of the snow is gone and many of the roads have already been cleared of debris, dirt and dust. So I have been biking and walking around a lot more.

I have made a single Python file for offline note editing and online editing. It looks decent and works fairly well. I had to do some note text sanitizing for putting into the database and retrieving, so I didn’t get things like, quotes or slashes in the note breaking the SQL query or making new lines actually show as ‘\n’ in the note when viewing.

I still need to work on the date time stamp validation since it is user editable. I also want to add 2 date time stamps per note. One entered in as a index which would always use the current time converted to UTC 0, and another user editable one for where the user wants to associate the note to specific data in the database. This will not only solve a issue of not being able to delete a note with an incorrect date but also allows tracking of when things where done.

After doing the finishing touches on the notes section, it will be time to refactor. Admittedly it’s a tad sloppy at about 700 lines of code. I just wanted to get it working first to help with motivation, once working and happy with function, I’ll have a reservoir of motivation to work on efficiency and readability.

I started my machine learning book, which looks decent and I’m kinda excited to try it out on random data. It should be able to do what I’m thinking, which is finding correlating patterns between sensors and sensor readings. It should also help in finding issues in database entries, like incorrect date stamps on notes.

I still want to look into a better GUI instead of Python Tk, but it seems there are licenses on the qt one I’m not clear on, so I’ll need to look into that more if I go that route. I’m also keeping the possibility open of using a web based interface, as it can very much be customized and allows use over the network. It would also most likely negate the need for my platform tweaks file (changing aspects of the GUI to look right on different operating systems). Of course that opens up other security issues, especially if open to the internet.

That’s it for today.