25 October 2021

Development, Automation, and Saving Time

(Note to the reader: this post has actually been a draft for a number of years.)

I’m a developer. I write code. Also, I’m just one guy with limited resources, so I can’t be spending a bunch of time testing my code in a bunch of different environments, or making sure that every single little change I make doesn’t have some unknown catastrophic ripple effect.

So I automate my life. I take advantage of freely-available tools. As much as possible.

How, you ask?

Self-Hosting Isn’t Worth It (sometimes).

First off, I don’t bother trying to do everything myself. I used to host my own code repository (a really, REALLY long time ago), and this took excess time to:

  1. setup
  2. configure
  3. maintain
  4. work with (use)
  5. keep updated
  6. handle security crap like SSL (you know, changing the website to https://….)

So I use GitHub. I’ve used SourceForge.net in the past, and it was alright for my first everyone-can-see-it code repository, but GitHub just feels nicer to work with. Going from SVN to Git was a hell of a learning curve, but totally worth it (yes, SourceForge now supports Git, but not when I switched). All my code gets out into the world, others can see it, and I get a tiny bit of exposure.

That said: self-hosting is a lot cheaper, if you’re willing to sacrifice time for money (like if you’re a poor nerd 🤓).

Continuous Integration is Very Important.

Unit testing helps avoid introducing bugs that have a nasty ripple effect. I’m not that great at getting massive code coverage with it, but I’m getting better at it.

The other thing is that, really, I can only directly (read: easily) test with the version of PHP available to me. Which is usually the newest version. And my server, or the servers that would potentially use my code, don’t necessarily have that new of a version… so I need to have something test against those old versions. That’s where Travis-CI comes into play.

So I setup the GitHub repository to work with Travis-CI. Every time I push something to GitHub, Travis-CI gets notified. They spin up a fresh new virtual server for each version of PHP that I declared my code to be compatible with. And they run all my tests in that environment. Oh, and they email me the results. WIN.

Semantic Versioning is Important.

Putting readable, easy-to-understand version numbers in the code makes life easier. Well, usually, except when I fall into “version hell,” where this project requires that project which requires another project, and none of them can decide on a version of a related project that they both like. Yuck.

Anyway, I’ll probably write more on this later. Maybe. If you’re lucky. (And I have time… Which is basically never.)

Category: Code, PHP, Rant, Software Development, System Administration | Comments Off on Development, Automation, and Saving Time
21 October 2021

Self Promotion

I was talking to one of my co-workers the other day, and the topic of self-promotion came up. I was telling him all about how he had to get better at telling others how good he is at creating digital music… and then I realized that I was horrible at it.

So this post is here for promoting me.

Hi, my name is Dan, and I’m a geek.

I’ve done a lot of geeky things.

I’m Self-Taught.

All the programming and system administration capabilities I possess have been achieved through determination. No formal education has furthered that. No classes. No certifications. (I did go to college for a while, and technically I have a 2.96 GPA, but I never finished because they failed me for bogus reasons; I think I have like three credits or six credits left to get my Associate’s degree.)

I’ve been programming since the turn of the millennium, mostly on web applications. I taught myself PHP.

I learned system administration because it interested me, and because there was a need at the place I worked. I watched the owner peck away at a console until I learned the password and gave myself access. I officially became system administrator through sheer force of will. Within a few months, I was administering two dozen servers, with all but a couple of them running various flavors of Linux.

I learned PHP through reading and experimentation.

Is there more to the story? Yes. Quite honestly, this story has been in my drafts since 2014… So it has been time to publish it for a while. So, for better or worse, here it is / was. Lol.

Category: History, PHP, System Administration, Uncategorized | Comments Off on Self Promotion
13 March 2017

Impending Server Changes

I’m going to be making some changes to the server.  I recently had my server “hacked”, which was basically just some skiddie finding a way to post one of those pharmaceutical spam ads on a couple of my WordPress sites.

Hacked - I do not think it means what you think it means.
Hacked – I do not think it means what you think it means.

I’m taking this time to figure out a couple of things.  The plan is:

  • figure out how to use Let’s Encrypt for HTTPS (for TTORP, the Story Teller Forum, and my Fitness Forum).
  • find a way to deploy + update WP sites via git (including initial setup)
  • work on a better CMS for Crazed(Sanity) sites
  • update my “deploy” system to work with GitHub and generic git (not just BitBucket.org)

That’s actually quite a bit of stuff.  It’s going to take a while to get this all setup.  It’s equally possible that I’ll post about impending downtime as I am to simply just do it: pretty much all my sites are (extremely) low traffic.  So, there, I said it.

Category: Code, PHP, Rant, Software Development, System Administration | Comments Off on Impending Server Changes
21 August 2015

Hobbit Walk: Tests are Passing

A quick update on the Project Hobbit Walk status.

I’m in the midst of a fairly large code refactoring–which basically means that I’m changing some of the code and cleaning it up.  A lot of the changes are done so that I can get unit testing done, including some automated testing.

The idea is that, whenever I make a change to the code, there will be an automated process happening that ensures nothing broke.

The major part of that is done.  I’ve still got some updating to do, but a major milestone is out of the way.

Category: Code, Hobbit Walk, PHP, Software Development | Comments Off on Hobbit Walk: Tests are Passing
18 August 2015

Solving the Puzzle

Sometimes a puzzle presents itself to you. Sometimes you’re aware of the puzzle, of it’s nature, and sometimes you just have this little… thing, this irritating little itch that you can’t seem to scratch.

Solving the puzzle can be straightforward.  The answer comes to you in a moment, in a flash of brilliance–or common sense–and then you move on.  But then there are those puzzles that take longer.  Hours.  Days.  Weeks.  Months.  Even years.

“What the hell are you talking about?”

I solved one of those puzzles.  It was a puzzle I’d been working on for years, one that I was only casually aware of, but it was really digging at my (crazed)sanity.

This particular puzzle was one whose nature was in programming.

“I’m not a programmer.  This is gonna suck.”

I won’t get into the details; hell, that would bore the crap out of me.  And I’m the one that’s excited about it.

With programming puzzles, you’re almost never sure if it’s truly complete.  With a real puzzle, you’re told straight out of the box that there’s 250 pieces and it’s 15″ x 15″.  With programming, it might be five pieces, and be 50′ x 50′.  Or it could be 50,000 pieces, but only be a few inches wide and a few feet long… it’s just impossible to know.  And when you get to a point where you think, “gosh, I think it’s done,” you realize there’s a whole bunch more pieces that suddenly showed up.

And the other thing is, sometimes there are pieces of the puzzle that you don’t even realize are pieces.  You hold onto this little bit of information, because you know it’s important, but it just doesn’t seem to have correlation… until all of a sudden, you go, “holy crap, this thing here hooks onto this other thing…”

Yep.  It’s like that.

Category: Code, Living With Linux, PHP, Rant, Software Development | Comments Off on Solving the Puzzle
28 April 2015

Email Updates Suspended

I’ve temporarily disabled email updates due to a problem in the code.

At first I thought it was an issue with the data, maybe invalid interpretation of numbers or something.  But that wasn’t it.

Turns out, the code was pulling the totals for all races and combining them.  So the more races I was in, the higher my total was.

Anyway, I’ve disabled the emails for now, until the bug is fixed.  I don’t expect that it will take too long to adjust, but there are some other things that I’m trying to sort out in the meantime.  Here’s a few things on the short list:

  1. Bug fixes (critical only)
  2. Move code to GitHub
  3. Setup issue tracker (on GitHub)
  4. Setup wiki (on GitHub)
  5. Setup unit tests (keeps bugs from re-emerging)
  6. Integration with Travis-CI (for continuous integration testing)

It’s only a half-dozen things, but it’s no small task.  It’s all fairly important, though.  By moving to GitHub, I get exposure: it helps my resume (gives me some geek cred), allows others to look at it and consider helping, and gives me a wiki and issue tracker.  The issue tracker will help my Beta users to see the list of issues, submit problems, and get updates when there are any, and so forth.

Any questions?  Want to get involved?  Say something in the comments!

Category: Code, Hobbit Walk, PHP, Software Development | Comments Off on Email Updates Suspended
15 April 2015

Email Updates are Coming

I’m close to having the email updates functioning.

I haven’t been very motivated recently to get this stuff done.  Dealing with chaos in the family, stress, and looking for a different job have all been consuming my time.  It’s one of those things where sometimes there’s so much to do that I just don’t want to do any of it.

Anyway, I’m hoping to have some emails being sent automatically in the next few days.  Stay tuned!

Category: Code, Hobbit Walk, PHP, Rant, Software Development | Comments Off on Email Updates are Coming
2 March 2015

We Have Milestones!

After much waiting: there are now milestones!

Yep.  A bit of a let-down.  I know.  Sorry.

In creating the milestones, I noticed there were some things that were probably missed… setting up an order to the milestones (so I don’t necessarily have to insert them in the proper order), etc.  Nothing mind-blowing here.

I’m working on the code and associated SQL to figure out a contestant’s progress in relation to milestones.  Nothing exceptionaly difficult, just takes a little time to do.

But there are MILESTONES now, people!

Category: Code, Health, Hobbit Walk, PHP, Software Development | Comments Off on We Have Milestones!
24 February 2014

Nginx and PHP as Different Users (Pooling)

So, after having installed a few WordPress sites on my server (namely this one), I ran into some permissions errors.  I couldn’t get plugins nor any updates to install.

The problem first appeared simply as a prompt to enter FTP credentials.  That was bizarre, so I hunted to find why that was.  I realized it was a permissions issue by reading this page (among others).

I scoured the Internet for answers (in other words, I tried a lot of different search terms in Google) for a way to make Nginx, the webserver software I used, to run as the proper user.  I’d setup different users for different websites, so just changing the webserver’s default user/group wasn’t the answer.

My first solution, albeit an ugly one, was to give everybody read+write+execute permissions on my WP folders.  That was an ugly kludge, but it worked.  And so it sat for some time.

Then I finally found how.  Through some bit of serendipity, I found an article on Apache and suExec.  I changed the term to Nginx with suExec, and found the answer… sort of.

Nginx, PHP-FPM, and Pooling

So the key was the “pooling” part of PHP-FPM that I’d basically ignored.  I had read the configuration file, but didn’t really understand it.

But after reading this article about pooling with Nginx and PHP-FPM, I found the answer.

So PHP-FPM can be configured to run different pools.  Basically, that means that there are multiple main processes for PHP, and they can run as different users.

Easy.  Added a new pool, changed it’s name and the user, and the new process (well, processes) appeared, with the correct user.  But how could I attach that to my website, so it ran as the correct user (instead of www-data)?

It’s All In The Socket

The bit of magic that makes Nginx hand off the PHP work to the correct pool is the socket.  The new pool needed to have a unique socket, then the affected websites needed to be reconfigured to use the socket corresponding to the appropriate pool.

I went back and changed my new pool to have a unique socket name, then restarted the php5-fpm process.  I then went and changed my website’s configuration file to use the corresponding socket.

Before restarting Nginx, I changed the permissions on my website’s folder to no longer be world readable/writable.  Then I attempted to delete an old plugin: as expected, I got a permissions error.  Restarted Nginx, then tried again, and it worked.   Woot!

Category: Nginx, PHP | Comments Off on Nginx and PHP as Different Users (Pooling)