Projects

Git Gud at Git

Something that I’ve have tried and fail to quite get a hang of is how to use Git, and more specifically, GitHub. I’ve had a GitHub account for a good while, and at one point I “had” a ton of repositories because instead of simply following something, I would fork it to make a copy of it.  I feel like that’s not quite the proper way to go about using things.  At some point I went through and removed all of these forks and was left with only my code projects.  

I still wanted to get a better feel for the proper flow, which I probably still don’t have, and won’t really ever get until I (if ever) have the chance to actually work with a team using Git.  Most of my projects are just single upload drops.  Almost everything I do I just revise and edit locally until it works, then if I want to “show it off” I scrub out any static IPs, usernames, and passwords, and upload it to a repository.  I suppose there really isn’t anything inherently wrong with this method.  I have, more recently been pushing myself to use Visual Studio Code (VSCode) lately and a few other code apps, and thus I’ve been pushing some repositories with those various program’s interfaces.  

I did get to go through the proper, Fork, Branch, Edit, Push process a few times while doing some lessons through Twilioquest, and a follow up afterwards.  

Still, I think my main take away is… it doesn’t really matter how the code gets there.   Especially for single person projects.  I don’t really have any overall “goal” here.  It feels like the common goal is to try to get a programming job, but I am not really sure I would want that, at least not anytime soon.  I mostly just want to show off some mediocre code to the nobody who would look at it.  

Speaking of “showing off”, I also found that the little games I had made last year with Microsoft’s MakeCode Arcade are all browser based, so I set up a little page to specifically show off Code Projects.  Right now, it’s all just MakeCode games, but I plan to add more if it seems like a good idea.

Another motivator for this push to tidy up my GitHub is it’s an excuse to practice using Markdown more.  Like Git, it feels like a skill I should have practiced more much sooner than now.  The main page for each repository is just a specific Markdown file, so having more repositories means I can make many pages of different types.  I’ve also started using Markdown to draft out blog posts as well as for my archive of old writings.

So anyway, if you want to see some random bits of code, some from 20+ years ago, feel free to poke around my growing pile of repositories.   Actual Repositories, where I did some level of work on them.

Lastly, this whole post is annoying full of things I wanted to blog about but have not.  Markdown, MakeCode, Twilioquest, my huge writing archive, to name a few.

Project – Puzzle Board

I wanted to take a brief moment to talk about a fairly simple project I’ve done making a few Puzzle Boards. Though at the moment, wood prices are kind of nutty, so it’s a good project to do later. I’ve made something like 4 or 5 of these now in various sizes, for use by my family both at my house and extended family. They could be a bit fancier as well but the same concept applies.

Basically, we do puzzles as a group sometimes. Often these puzzles take several days to complete, which means they are often in the way. We also have cats, who like to destroy things because they are cats. This is where the Puzzle Board comes in, it’s a simple flat board with an edge and a cover, to protect the puzzle while it’s being worked on.

It’s extremely simple to make, though it’s best if you have a decent saw and some clamps. For these boards, we bought some medium sized sheets of thin wood. The size depends on how large you want the board to be, the one pictures was likely roughly a 4′ x 4′ sheet. Selecting the type of wood is fairly important and it may cost a bit more than a basic sheet. A lot of flooring or plywood (4′ x 8′ sheets) is too thick, it will make the thing super heavy. Some of the cheaper wood though is too flimsy, it needs to be reasonably stiff, tough the sides will add to the stiffness.

You also need some sort of trim piece. I used 3/4″ pre finished Quarter Round, but you could use something fancier. How much depends on the length of the sides of your board, but unless you are making something absolutely massive, 1-2 8 foot pieces should work. for smaller lap sized boards you’d only need one.

The top cover board is roughly 2 inches smaller than the bottom board, to account for the edge size. So, for example, if you had a 4′ x 4′ square of flat board, you would cut it in two just over half way at 25″ wide. Four feet is 48 inches, half would be 24 inches. Cutting at 25 inches gives you a piece 25 inches wide and a piece 23 inches wide. the 23 inch wide piece will need a couple of inches trimmed off one end, but then it should sit just inside the 25 inch wide base.

For the edges, trim them with a 45 degree angle so the outer side is the same length as the base of the puzzle board. Int he example above, these would be 25 inches and 48 inches, with the 45 degree angles all pointing “in”. It’s best to visualize each piece before cutting and how it will lay, because it’s easy to accidentally cut it incorrectly and then the corners won’t line up.

Once the base and sides are cut, you can stain or paint the base and top (and sides if they are not pre finished) to the desired color. It may also be a good idea to lay things out just to make sure the top board fits and doesn’t need trimmed down any as well. If you are really ambitious you could also potentially attach some sort of mat or fabric to the base piece at this point as well.

Next use some wood glue and glue the sides on carefully, keeping them as straight as you can along the sides of the base piece. Use clamps to hold the side pieces in place as they dry to avoid things coming loose. I also would recommend using an old sock or rag between the clamp and wood, to help keep the clamp for marring the finish. All four sides can be done at once, or a few at a time, depending on how many clamps are available. If you are careful you could also simply place everything on a flat surface (like a table or the ground) and balance something heavy like some large books on top if no clamps are available. Just take care that things don’t slide around. If you re doing this, it may be helpful to use some scrap pieces so the books (or whatever) sit “flat” instead of at an angle (where they will be applying some small sideways force).

Once every thing is dry, that’s it. It’s done. Construct your puzzle on the base, when you’re taking a break, cover it with the cover piece. When not in use you can store the cover in the frame and store it wherever you have room. The basic concept can easily be resized as well. I’ve made smaller lap sized versions of these as well, for single person use in a chair.

Basement – The LEGO Table

The LEGO Table space in the basement was, for the longest time, the catch all space for anything extra. It was always sort of the last space to get finished up in the basement, though it’s always going to be an ongoing project. A lot of the clean up in this space involved cleaning up other areas first. The initial set up involved a counter sort of unit that I had made years ago, that previously was in my wife’s craft room at the old house. She didn’t need it in the new house, so I inherited it and it was a place to land my LEGO Modulars.

Under was used for storage for most of my other LEGO sets, since I didn’t really have a place to put them yet. They’ve still been in boxes for a few years,

At some point we ended up with some pretty hefty book cases second hand that we were using upstairs for a while, but they were no longer needed. Originally these book cases were going to be used in the basement but they were maybe 4″ too tall, so they ended up in the upstairs space. Since they were available again, I opted to go ahead and trim them down a bit so they would fit in the basement.

This process amounted to marking a line around the top end of the book case, using a circular saw to chop all the way around on the line, then removing the top board from the chopped off scrap bit, and reattaching it to the top of the book case. I also put a fresh new coat of paint on the book cases and shelves, as well as cut a few additional shelves.

I originally wasn’t sure where these shelves would end up in the basement, but after some measuring, I decided they would work on either side of the LEGO table. This meant turning the LEGO table itself 90 degrees so it sticks out in the room. I also bought some more pre finished shelving boards, like the original table was constructed from, and build what amounted to, a second table, then strapped them together with some braces to double the available surface area.

This gave me a lot more room to work with for the LEGO city, as well as shelving on either side to display and store additional sets. Which really cleaned out some of the boxes I had stored under the table. The next part of my plan was to add some additional shelving under the table for storage, which lead me to another idea. Why just add shelving on the sides, when it would be fairly easy to add shelving to the end, for a bit more display space. It also gets rid of this ugly as hell blank white surface.

For this process, I separated the two end legs, and shuffled them back the depth of a narrower (8″ I believe) shelf. Then reattached them. I then cut and assembles a smaller shelf unit and attached it to the end of the LEGO table. On the one side, I also adjusted the secondary leg back, as well as the curtain that was there, so I could keep the trash can under the table and out of view as it was. On the opposite side, I simply removed the extra leg.

Finally, for now, I cut some more 24″ pre finished shelf boards and attached them using L braces, inside the length of the table, on both sides, so the mess inside could become a much more organized, and useful mess. I also picked up an LED shop light that I hung over the length of the table, because this particular corner of the basement is a little dark. It lights up the entire space much better than I had expected it to.

In case you noticed, the Return of the Jedi poster fell off the wall at one point. I want to buy better frames and some fresh posters anyway (these three are like 25 years old now), so I simply hadn’t replaced it on the wall yet.

The next phase of this project is to actually start sorting down the extra LEGO into bins and drawers that will go under the table. I already started this a bit with some IKEA bins but I am going to need more bins than I have and it’s slow going since right now all of the LEGO is just in a giant plastic bin.

Basement – Sliding Door Project

So, I’ve been doing a fair number of projects, but writing about them isn’t one of those projects. Some of it has been improving the basement a bit. Part of the slowness of the basement work is because it occasionally floods a bit. Not really “standing in water” flooding, but “there is a puddle that keeps coming” flooding.

It’s annoying, but I’ve been working to fix it. The house originally didn’t have any downspouts on the gutters, I added those. I’ve added extensions to the gutters to direct water away. I added a new downspout near the area where the water seems to come from to help direct it away more. I cut out some drywall in the underside storage area and pulled the bottom step off of the stairs to fill in some ugly crack-ish spots in the area where the water comes from. At this point, I am waiting for more heavy rain to see if some of this has made any real difference. So far the cement fill seems to have done the best. It’s tricky to describe but basically, the water still came in, but it came in waaaay less and in a slightly different place. So I’m getting there.

I’m not really here to discuss the flooding though. It has affected some decisions on how to make the basement nicer, like I am not going to add Drywall walls like I wanted to. And no carpet, though that was out anyway, because the cats are assholes (We also replaced all of the upstairs carpet with vinyl plank flooring).

One fairly simple project was adding a door. In this case, I put in a sliding barn door style door. My wife wanted to put in a real door but I wasn’t keen on that since there isn’t really a good place for it to open to. The door itself had a couple of motivations behind it.

One, the basement is divided into two halves. One half is semi finished and “nicer” and it’s where I keep my computer and collection of stuff and there is a TV and couch with game consoles and my son has a corner that is his bedroom area when he is around. The other half is under the “original house”, it’s rough, the ceilings are a little low, and there is more duct work and such hanging from the ceiling. We use it for storing all sorts of stuff. It’s really great for that.

The “underside” half is ugly though. I wanted the door to be able to block it out, mostly for aesthetic reasons.

The other purpose of the door is to be able to lock the cats in the basement when we have guests over. My parents and my wife’s parents are all allergic to the cats. We lock some of them in bedrooms, we also lock some of them in the small sunroom/office area upstairs. Sometimes we would lock them in the basement by blocking the stairs with a giant cork board we have that doesn’t really have a home.

Now, we can use the door. It slides between the two openings, stairs and underside storage to block off either one.

One concern was air flow from the storage area, so the door can also be positioned in the middle, which is where it usually sits, so air can flow in and out both sides. It also lifts off easily if I needed to remove it.

The door itself isn’t anything complicated. I could have built a door but I opted to just buy one, though the door was pretty pricey since it needed to be extra wide. The roller kit is a low profile barn door kit, easy enough to install and it nestles up into the floor joist ceiling. The tricky part was that the floor joist didn’t reach the edge of the opening, so I had to screw a couple of 2×4 stand offs to the floor joist to get the door to sit int he proper place. This also meant adding some 2×4 lifts under the stand off to support the immense weight of the door.

I also ended up with an issue of the door rolling slightly. I am not sure if it’s the house or if the rail is a little off (probably a little of both) but the door slides towards the stairs on it’s own. Not very quickly, but it does move.

I solved this with magnets, at the suggestion of my uncle. I didn’t really want an ugly latch that would also potentially end up in the way of the door sliding or people walking. I bought some block magnets and some double sided Gorilla tape (I originally used Command Strips but they were too weak). I stuck a larger magnet to the wall, then two smaller magnets on one end and the center of the door. This allows the door to hold it’s position when blocking the stairs or when positioned halfway.

This project isn’t quite done. I may also add an L bracket of some kind in the center of the door, to hold the door from being leaned outwards, and I want to add a roller on the backside to the whole action is smoother. the way things are, if the cats get determined, they can push the door enough to get it to release from the magnet and escape from the basement.

I also need to adjust that network cable because it’s kind of just there and ugly.

Code Project: Network Map Webpage, Making it Better

I wrote a bit about my Network Map Webpage recently. It’s part of a larger home dashboard project I’m working on, but as part of that I’ve updated things a bit to make them more streamlined and easier to use. The biggest problem with the page as it was originally coded is that it shows everything. I’ve cycled most of my regularly used electronics onto the network so they could be captured by an arp scan, though not all of them are on all the time. For example, I still have a Raspbery Pi and Arduino set up to capture temperature data. I also have several Next Thing CHIP devices, though Next Thing has gone out of business. In total, between my IOT stuff and laptops, phones and tablets and the duplicate IPs from the network extender, I have 55 devices in the raw table.

So I set out to make this more manageable at a glance. My original query in my PHP code looked something like this:

SELECT ip, arpscans.mac, arpscans_known_macs.device_name, arpscans_known_macs.device_description, last_seen, device_owners.user_name FROM arpscans LEFT JOIN arpscans_known_macs on arpscans_known_macs.mac = arpscans.mac LEFT JOIN device_owners on device_owners.id = arpscans_known_macs.device_owner ORDER BY ip

By slipping in “WHERE last_seen >= NOW() – INTERVAL 5 MINUTE” just before ORDER BY, I can make the code return only currently connected devices. The ARP scan runs every 5 minutes, anything that has a last seen time stamp within 5 minutes is assumed to still be attached. This interval could be shorted to almost real time, but I don’t really need that much of a check.

I can also view all disconnected devices with a simple change of the above command, making it “WHERE last_seen <= NOW() – INTERVAL 5 MINUTE”. This wouldn’t work if I were still keeping historical data, but I essentially only capture the last seen data for any device. Essentially what this does is return everything not seen in the last 5 minutes.

I also broke out my PHP code that builds my table from my query into it’s own PHP function. This was I could set the variable $SQL for the active devices, call the function to build the table, then set $SQL for inactive devices and build a second table, under the first.

I immediately scrapped this, because it was ugly. Plus, sometimes I do want to see “everything”.

Enter some GET calls and an if/else statement.

	if($_GET['show'] == "active") {
	// SQL for selecting active devices
	$tabletitle="Active Devices";
	$sql = "SELECT ip, arpscans.mac, arpscans_known_macs.device_name, arpscans_known_macs.device_description, last_seen, device_owners.user_name FROM arpscans LEFT JOIN arpscans_known_macs on arpscans_known_macs.mac = arpscans.mac LEFT JOIN device_owners on device_owners.id = arpscans_known_macs.device_owner WHERE last_seen >= NOW() - INTERVAL 5 MINUTE ORDER BY ip";
	}
	elseif($_GET['show'] == "inactive") {
	// SQL for selecting active devices
	$tabletitle="Inactive Devices";
	$sql = "SELECT ip, arpscans.mac, arpscans_known_macs.device_name, arpscans_known_macs.device_description, last_seen, device_owners.user_name FROM arpscans LEFT JOIN arpscans_known_macs on arpscans_known_macs.mac = arpscans.mac LEFT JOIN device_owners on device_owners.id = arpscans_known_macs.device_owner WHERE last_seen <= NOW() - INTERVAL 5 MINUTE ORDER BY ip";
	}
	else {
	// SQL for Selecting all devices
	$tabletitle="All Devices";
	$sql = "SELECT ip, arpscans.mac, arpscans_known_macs.device_name, arpscans_known_macs.device_description, last_seen, device_owners.user_name FROM arpscans LEFT JOIN arpscans_known_macs on arpscans_known_macs.mac = arpscans.mac LEFT JOIN device_owners on device_owners.id = arpscans_known_macs.device_owner ORDER BY ip";
	}

Basically, if nothing, or a random string is passed by the URL variable “show”, then it goes to the end, and displays everything when accessing the page at index.php. If it passes index.php?show=active, it sets $SQL for showing active devices and if it gets index.php?show=inactive, it shows inactive devices. It also sets a variable called $tabletitle which is just echoed out into some header tags. I then added links across the top of the page to each of these filters.

This allows for a quick and easy toggle of which data is pulled and displayed.

Additionally, I updated the way the Add Device form works. Previously, the form would fill in the MAC, a Device Name and a Device Description, then it would POST to another PHP page that would insert the data into the table, then forward on back to the index page with a header redirect. I’m not going to get into too much detail on it here, but I also integrated the Network Map into my dashboard framework with a header, navigation, sidebar, and footer. It also uses a table based navigation system, so in order to view the network map, I am hitting “index.php?page=4”. Pages basically all need to be wrapped in this structure to work properly, so in order to make things flow better, the Add Device form now POSTs back to the Network Map page itself, which checks to see if the POST variables are set, and if they are, it inserts the new information, before pulling the table.

This also meant slightly altering my page calls to look for “index.php?page=4&show=active” and “index.php?page=4&show=inactive”.

Eventually I want to move the Add Device form to appear at the top of the page, so the whole thing is all handled in one single page.

Lastly, I made up a quick block of code in it’s own page, that simple counts and displays the number of currently connected devices on the network. This block is embedded on the front page of my Dashboard Framework and links to the full Network Map page. The general idea on the Dashboard is to have widgets like this that show quick glance information, with links to detailed information.

I have not built a lot of them yet, but one of the others I have built works somewhat similar to the ARP scanning system. A script makes a call to my TT-RSS instance for each of the segmented accounts I have, then dumps the unread count into a table on the server. The widget shows how many unread articles each topic/account has. I am still really bad about only actually reading the Basic feed (mostly Toys and Video Games).

But I will get into the Dashboard Widgets thing a bit more in a future post probably.