I’ve been learning WordPress!

I’ve actually been using WordPress for years, but I didn’t do much tinkering with it. This site is a slightly-tweaked WordPress template I’ve loved for years. (GeneratePress, and the paid version is worth every penny.)

But it’s so popular and powerful, I wanted to dig deeper into it. So I converted The Whisker Shop over to WP and did a lot of tweaking and tinkering… I’m still not thrilled with the catalogue/gallery page, because I want to be able to include a link to each item’s page from the gallery images, and it looks like a hot mess with everything I’ve tried so far. It looks like I’m not the first person to have this question in the plug-in’s forum, so maybe there’s a workaround somewhere.

I’d originally installed WP in a blog/ directory just for blog purposes, but I decided to see if I could migrate a WP version from a directory (blog/) to the main directory (thewhiskershop.com) and I did! Without breaking anything! And the credit goes to Ask WP Girl.

Some days you have to celebrate the small victories. 🙂

#100DaysofCode – towing capacity calculator

A quick proof-of-concept for a web app I’d like to make next. (code below, or code on Github.)


#!/usr/bin/env python
''' Towing capacity calculator, takes user inputs for vehicle and trailer data, then determines if the vehicle is over payload or under gross combined vehicle weight rating. Proof of concept before turning this into a web app.

Disclaimer: If you use this, double-check using your own math, too. This has not gone through a formal validation process, and I don't want my code to cause any accidents. -jmf '''

# Check if over/under payload
def payloadcheck(availablepayload):
if availablepayload >= 0:
print("Available payload: {}".format(availablepayload))
return True
else:
print("Exceeded Payload! Over payload capacity by {}".format(availablepayload))
return False

# check if over/under GCVWR
def gcvwcheck(towcapacity, newgcvw):
if newgcvw >= towcapacity:
print("Acceptable! With combined weight of {}".format(newgcvw))
print("You are under your GCVWR by {}".format(towcapacity - newgcvw))
return True
else:
print("Exceeded GCVWR! Over capacity by {}".format(newgcvw - towcapacity))
return False

def getdata():
vehicle = input("What vehicle will be doing the towing? ")

# dry weight, or curb weight = unloaded vehicle weight, WITHOUT driver, passengers, or cargo
truckdrywt = int(input("Curb weight: "))

# gvwr = maximum allowed weight of a fully loaded vehicle (dry wt + driver + passengers + cargo)
gvwr = int(input("Gross Vehicle Weight Rating (GVWR): "))

# gcvw = curb weight + allowable payload + passenger weight + trailer weight
gcvwr = int(input("Gross Combined Vehicle Weight Rating (GCVWR): "))

# payload = maximum allowed weight of passengers + cargo + hitch
payload = int(input("Payload: "))

# tow capacity = defined by manufacturer, listed in owners manual or a manufacturer's tow guide
towcapacity = int(input("Tow capacity: "))

# passenger weight = driver + all human and non-human riders
passengerwt = int(input("Combined driver and passenger weight: "))

# cargo = everything in the vehicle that isn't sentient
cargo = int(input("Cargo weight inside the vehicle: "))

trailer = input("What trailer are you towing? ")

# trailer dry weight, or curb weight = unloaded weight, can be determined by a sticker on the trailer or by taking an unloaded trailer to a truck scale. Published unloaded weights may or may not include water/waste/propane
trailerdrywt = int(input("Trailer curb weight: "))

# trailer gcvw = dry weight + everything inside it
trailergvwr = int(input("Trailer Gross Vehicle Weight Rating (GVWR): "))

# hitch weight = defined by manufacturer, listed in manual or sticker on the trailer
hitchwt = int(input("Trailer hitch weight: "))

availablepayload = payload - (passengerwt + cargo + hitchwt)
newgvw = truckdrywt + hitchwt + passengerwt + cargo
newgcvw = trailergvwr - hitchwt + newgvw

print("\nWith the {} towing the {}: ".format(vehicle, trailer))

payloadcheck(availablepayload)
gcvwcheck(towcapacity, newgcvw)

def main():
print("==================================================")
print("Towing calculator.")
print("It does not matter if you use pounds or kilograms, just be consistent. \n")

getdata()

print("\nDon't forget to check the capacity of your tires and gross axle weight ratings (GAWR).")
print("==================================================")

main()

''' inspiration for this came from Marc Leach's Excel worksheet here: http://www.keepyourdaydream.com/payload/ '''

#100daysofcode

It’s been a bit of a rough month. I’ve been tinkering with this Mastodon moderation bot— and as a bonus, it’s in Python, which I love and want to do more. I’m currently working locally, but when I have something nice to contribute I’ll be setting up a gitlab account.

My family recently had to say goodbye to the greatest cat I could’ve hoped for, my kitty BFF for the last 15 years. She was always so sweet when she’d sit with me while I was working: she was always careful NOT to step on the keyboard, and I’ve never known another cat who does that. She also always remembered which parts of me hurt too much to stand or lay on, and would be near me without hurting me. She was such an angel. I’ll miss you, Ginger.
An orange cat laying on a pillow, her face and front paw sticking out from under a blanket.

#100DaysofCode – PHP edition

I switched The Whisker Shop over to use some PHP. Originally (and part of my WD4E capstone), it was HTML, CSS, and a little JS, but I wanted to keep the JS to a minimum, so it still involved a lot of repetition, copying and pasting the same code between pages, which was just annoying and antiquated.

So I put down some PHP, created a whole separate header file for the nav bar, and updated everything. I also removed the JS Lightbox from the gallery, because a Lightbox for 6 pictures felt a little silly. The site loads a lot faster now, too, although I still plan on making the photos load faster in the future, and finding a more attractive way to display that gallery page. Front-end isn’t my forte but enough people have done so many beautiful things before me, that I’m confident I can make this even prettier.

In the shorter term, I plan on updating the nav bar with a pure-CSS drop-down menu.

#100DaysofCode – link scraping script (python)

I found this great Pythonic HTML parser today and wrote a quick script for snagging the links off a page.


linkpull.py

# !/usr/bin/python

# takes URL as input, outputs all links to a file
# requires the excellent pythonic HTML parser, requests_hmtl
# parser source: https://github.com/kennethreitz/requests-html

from requests_html import HTMLSession
import os, sys

def maketextfile(linklist, filename):
    with open(filename, 'a+') as file:
        for link in linklist:
            file.write(link + '\n')

def main():
    print("\nThis is a tiny link scraper!\n")
    
    # destination file for your links:
    filename = 'linklist.txt'
    
    # get URL source:
    url = input("Enter a complete URL: ")
    
    session = HTMLSession()
    r = session.get(url)
    linklist = [link for link in r.html.absolute_links]
    maketextfile(linklist, filename)
    print("\nFinished! Your file {} is located at \n {}\n".format(filename, os.getcwd()))

main()

(part of my tiny scripts repository on github.)

#100DaysofCode – a file renaming script (python)

I can’t stand doing the same task more than 10 times in a row if there’s a way to automate it. My recent website projects have involved a lot of compressing and renaming image files, and the process is tedious. I fixed it:


renameme.py

# !/usr/bin/python

''' takes source and destination strings as input, and changes names of files in the local directory. '''

import os, sys

def fileRename(src, dest):
    for filename in os.listdir("."):
        if src in filename:
            newname = filename.replace(src, dest)
            os.rename(filename, newname)
    return

def main():
    src = input("What is the substring you need to change? ")
    dest = input("What would you like to replace it with? ")
    fileRename(src, dest)

main()

# ls
print("Process complete! New directory contents:\n{}".format(os.listdir(os.getcwd())))

(part of my tiny scripts repository on github.)

#100DaysofCode

I’ve been sussing out the details for a photo gallery… Mostly playing with CSS and Lightbox so far. I came upon a treasure trove of photos taken by a friend who passed away a year ago, and I’d like to share them with the world.

There is the main page with a basic/sample Lightbox… There will be many more photos in a gallery page and more Lightbox tweaking in the future: Eternity’s Sunrise.

Some web dev thoughts: I don’t feel like I have an eye for design, but I really enjoy tangible end results. This is why I like the idea of working on a team– I can contribute in ways that don’t involve beautification (but accessibility-improvements! those I can do!) while the real artists make things pretty. 🙂

Still, though. I think Jerry would’ve liked this gallery. He always liked simple, accessible sites.