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.

Code Project: Network Map Webpage

I want to start off by saying, there isn’t going to be a ton of code here, and if there is code, it’s going to be super dirty. I’m fairly good at making code for “private use” that is pretty insecure, and not so great at code that’s scrubbed up and user friendly to distribute to others.

I’ve been working a bit on some local code projects, specifically for my little private “Dashboard” that runs on my file server. One project I’ve wanted to try for a while is a dynamic network tracker tool. I’ve looked into some options available, and they all seem to run as a plug in for some complicated 3rd party analytics software that often has some goofy complicated set up procedure that’s beyond “apt-get” or even just dumping a bunch of files in a web server directory.

This project is both kind of simple and not. It was fairly simple in set up and execution, but it’s somewhat complex in design. The first job was getting a list of currently connected devices on the network. This is easily done via the command line with an arp-scan request.

sudo arp-scan --localnet

The output of which looks something like this:

Using a pipe, I can shove all of this into a text file, which contains everything above.

sudo arp-scan --localnet | scan.txt

The trick is, how to display this output on a webpage. One way would be to pull it from a database. Pulling data from MySQL is pretty easy, dumping it to a pretty looking table is also easy. The harder part is getting the output of arp-scan to MySQL in a useful manner.

This is where Python comes into play. I am sure there are other methods or languages available, but like Python, and mostly know how to use Python. Essentially, I wrote a script that would open the file, scan.txt, that was created above. I am only concerned with lines that contain IP addresses, so I used the function “is_number()” to check if the first character of each line is numeric, if it is, it runs through a couple of operations.

Firstly, the output of arp-scan is tab delimited, so I can use the “split” function on “\t”, and dump the result into an array. This gives me an array of the IP address, MAC address, and Manufacturer. This sticks a new line in with the Manufacturer, so I did a “replace” on \n in the third item of the list. Lastly, I wanted the IPs to be uniformly formatted, so I write a little function that would add in leading zeros to the IP octets.

Finally, the Python builds an SQL statement from the line’s list, and make a call to the server to insert the values. A modified version of this code that just displays the resulting SQL commands instead of executing them is below.

#!/usr/bin/python

# Open a file

def is_number(s):
        try:
                float(s)
                return True                                                         except ValueError:
                return False

def format_ip(ipstring):
        octets = ipstring.split(".")
        n=0
        for i in octets:
                while(len(i)<3):
                        i=add_zero(i)
                octets[n]=i
                n=n+1
        return octets[0]+"."+octets[1]+"."+octets[2]+"."+octets[3]
        #return ipstring

def add_zero(shortstring):                                                          return "0"+shortstring


import MySQLdb

mydb = MySQLdb.connect(
  host="localhost",
  user="YOURSQLUSERNAME",
  passwd="YOURSQLPASSWORD",
  database="YOURTARGETDATABASE"
)

mycursor = mydb.cursor()

fo = open("scan.txt", "r")
#print ("Name of the file: ", fo.name)

fo.seek(0)

# read each line of the list
for line in fo:
        #check for lines that contain IP addresses
        if is_number(line[0]):                                                              #Convert lines into list
                line_list = line.split("\t")
                #remove line delimitors
                line_list[2]=line_list[2].replace("\n","")
                #Make IP Octets 3 digits
                line_list[0] = format_ip(line_list[0])
                SQL = "INSERT INTO arpscans (ip, mac, mfg) VALUES ("+line_l$                print SQL                                                   
fo.close()

It’s not super pretty, but it was a quick way to make sure everything came out looking correct. The table I used is called “arpscans” and contains columns called, “ip”, “mac”, “mfg”, and “last_seen”. The time stamp is an automatically generated time stamp.

I then created a shell script that would run the arp-scan piped into scan.txt then runt he python script. I set up this script in the root crontab to run once every half hour. Root is required to run the arp-scan command, so my user crontab wouldn’t cut it. Everything ran fine when I manually did a run of the script using sudo. The PHP on the other end out output the latest values based on the time stamp to a webpage.

This is where I ran into my first major hurdle. The script wasn’t running in cron. After a lot of digging and futzing, I found that basically, when cron runs the script, it works off of different environmental variables. I had to specify in ,y bash file, specifically where each command existed. The end result looks something like this:

#!/usr/bin/env bash
/usr/sbin/arp-scan --localnet > /home/ramen/scripts/arp_sql/scan.txt
/usr/bin/python /home/ramen/scripts/arp_sql/arp_post.py

Eventually the scan was running and posting data automatically as expected. After a few days, I ran into my second major issue. There was simply put, way too much data for my crappy old “server” to handle. The webpage slowed to a crawl as the table contained something like 9000+ entries. It’s possible and likely that my query was also rubbish, but rather than stress more figuring it out, I modified all of the code again.

Instead of adding a new entry for every MAC address every scan, I changed it to check if there already was an entry, and simply update the last_seen time. I had originally designed the system with the idea of getting legacy data for attached devices, but decided I only really cared about a generic history.

The new webpage table now displays all devices, current and previously seen, with the last seen date.

A few issues came up on the output end as well, though none of them were super hard to correct. One, I wanted a way to sort the table by clicking the headers. There are several scripts you can toss in your code to do this online.

I also wanted more data about each device, so I added a form where I could fill in more data about each device. Specifically, the network name, if there was one, a description of what the device is, the User of the device (which family member or if it’s just a network device). This also checks and updates based on MAC address.

I also ran into an issue with MAC addresses and my Network extender. When devices are connected to the Network Extender, the first half of the MAC is replaced with the first part of the Extender’s MAC, though they retain the last half. I may eventually write some code to detect and merge these entries, but for now, I’ve simply been labeling them in the description as “(Extender)”, so I know it’s the same device on the other connection.

The final end result looks something like this:

I used to have the network super organized before I moved, but the new router doesn’t work nicely with my Pi DHCP server, so I have not gotten things quite as nicely sorted as I would like. Everything in the picture is sorted, but above .100, it’s a mess. I also can’t assign IPs to some devices at all, like the DirecTV gear or my Amazon Echos, which is really annoying.

One of my future projects will hopefully correct this, as I want to put a second router on the network with DD-WRT, between the ISP gateway and everything else.

Overall, it’s been a fun little exercise in coding that combined a lot different techniques together in a fun way.