Check if two String arrays are permutations

Posted by & filed under Coding.

Earlier this week I was working on a JUnit test for one of the AP free response questions from 2016 where you’re given an array of Strings and need to implement a class that randomly pulls one out using a getNext method. You’re basically writing an iterator without calling it that. But since it was… Read more »

Regex for Twitter username

Posted by & filed under Coding.

Working on a small weekend project I needed an easy way to validate that a string contained a valid Twitter username. Not necessarily an active account, but that could be an account. Found the rules on Twitter’s site that a username can be between 1 and 15 characters and can contain only the characters A-Z,… Read more »

NetBeans JavaScript not minifying

Posted by & filed under Coding.

Spent more time than I’d like to admin banging my head against my keyboard when NetBeans wouldn’t minify a specific JavaScript file. Instead of correctly minifying, the minified version would end up blank. Finally got frustrated enough to start tracking it down and found the cause in the line 2 pasted here. View the code… Read more »

Fading an image with PHP, GD, and Jaguar

Posted by & filed under Coding.

For a project that I’m working on I needed a way to fade out an image before overlaying text on to it. Text I’ve done. That’s not an issue. But I haven’t ever done anything with PHP with fading out an image. Turns out there’s a library called Jaguar that makes it, and other image… Read more »

How to remove .lead CSS class from parent theme

Posted by & filed under Coding, WordPress.

I’ve usd the 320press Bootstrap WordPress theme as a parent theme on a couple of projects, including this site. Overall, it’s great. But there’s been one little nagging “feature” that I’d like to get rid of. The theme adds a lead class to the first paragraph of each post. And the parent CSS for .lead… Read more »

Commit early, commit often

Posted by & filed under Coding.

Learned an important lesson today. I spent a good chunk of yesterday working on a new project. It’s a Moodle plugin that, when finished, will let you put code online for your students to work on along with tests so they know when they’re done and you can automatically get back a grade. But while… Read more »

One line PHP regex search

Posted by & filed under Coding.

Not sure this is the best way to do this, but it works. Working on a project and I’m writing a lot of code to do RegEx searches. Each match is 3 or 4 lines to do the match, check if there was a match, and then do something with the match. Since I was… Read more »

Contrasting color function for PHP

Posted by & filed under Coding.

For another site of mine I needed a way to determine whether black or white was a better choice for text on a randomly colored background. The function takes a color as an array with elements r, g, and b and returns an array with the same 3 elements. Although in the returned array all… Read more »

Moving Enemies with Waypoints

Posted by & filed under Coding.

Getting enemies to move tends to be one of the more difficult things for me to get right. It just doesn’t always seem natural. And I’m not talking about moving with any type of AI. Just moving around the screen in a pattern. Sure, straight lines are pretty easy. But games get really boring if… Read more »