Posted by & filed under Programming.

Is XAMPP slow?

I’ve used XAMPP for pretty much as long as I’ve been doing web development. It makes it trivial to get Apache, MySQL, and PHP set up.Since upgrading from Windows 7 to Windows 10 though I’ve noticed it was running much slower. I just assumed that XAMPP is slow. There was also an upgrade to XAMPP as part of that, although I don’t remember what versions.

The slowness was especially noticeable working on Moodle plugins. It was almost unusable, although that’s not too surprising with the 250-300 database tables that Moodle uses.

Googling brought a bunch of potential solutions

  • Disable IPv6
  • Edit hosts file to point to localhost
  • Exclude Apache, MySQL, and PHP from firewall

And all of these seemed to help just a little bit, but so little that it could have just been psychological. Read more »

Posted by & filed under WordPress.

Always Edit in HTML Plugin ScreenshotThis is another one of those plugins that I’d thought about writing and Google kept me from needing to.

Sometimes when building a WordPress site I’ll need to create pages using straight HTML instead of the WYSIWYG editor. Without fail though I’ll accidentally click on the Visual tab and the editor will clear out most of my HTML I’ve thought that it would be nice to be able to disable the visual editor, but only for specific posts. Turns out, I wasn’t the only one.

The Always Edit in HTML WordPress plugin takes care of it.

Take a look at the screenshot on the right. Check the box and save your post and the visual editor is gone. Nothing to foul up the HTML.

Posted by & filed under Computers & Internet.

Epson DS-510 ScannerA couple of months ago we bought an Epson DS-510 scanner. Although I haven’t run it long enough to know how well it holds up, it’s been doing really well so far.

One big snag though. The goal was to scan receipts. And most of the time it worked flawlessly. But really long receipts would always jam, even though it’s supposed to support scans up to 36 inches. And it wasn’t really even jamming. It was just stopping and showing a jam message.

Thanks to a comment reply on Amazon I discovered it’s not really jamming. It’s just that the scanner only scans up to about 16 inches if auto paper size is selected. By changing from auto size to a manually selected size it scans longer receipts without a hitch.

Posted by & filed under Moodle.

Moodle LogoIt’s happened at least a dozen times. I’ll punch in a bunch of short answer questions into Examview so that I could inmport into Moodle. Then I go through the hoops of exporting it from Examview into Blackboard so I can import into Moodle.

Then, I remember. Moodle imports short answer questions exported like this as an essay question. That means that the automatic grading doesn’t work.

Apparently this is a pretty common issue. I came across an explanation in the Moodle forums explaining why it works that way, and I totally get the reason. But it’s still annoying.

Turns out all of the explanations stop a little short of a quick and easy fix. Instead of creating short answer questions in Examview, create Completion questions. The fields in Examview are exactly the same. You type in the question on the top and the answer on the bottom. But, when Moodle imports them they come in as Short Answer along with all the automatic grading goodness.

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.

Turned out that I was using a keyword as a property name. Wrapping class in quotes cleared everything up and NetBeans is happily minifying away again.



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 manipulation, really easy for PHP.

The code below loads an image and covers it with a white overlay to fade it out.

I left out the part where the text is added, but Jaguar makes adding text pretty easy as well.

And if you’re interested, the final result is used on the featured image on a font website that I’m setting up.

Posted by & filed under Computer Science, teaching.

I’ve been using NetBeans to teach Computer Science for a while now, but it’s always seemed a bit heavy. Came across a post on the Oracle blogs with a few tips for making NetBeans a little more classroom friendly. So here are a few tips from there along with a couple of tips I’ve come up with along the way.

Alt-Mouse Wheel Let’s you enlarge and shrink the font. I have a “Screen” setting for fonts for display and another for when I’m working without kids watching. But alt-scroll works really well when a student asks me a question about their code. Makes it easier to see their code.

Alt-Shift-Enter Swap to full screen. No menu bars. Gives me a little more space on the screen.

Ctrl-Shift-Enter Puts NetBeans into a presentation mode that shows only the code window without all of the other mess.

Alt-Shift-F Auto formats the code. Cleanly formatting code is something that students always struggle with. Auto formatting the code makes it much easier to help them.

A Perfect Editor?


What I’d really like is some way, short of writing a plugin for NetBeans, that would strip out some of the menu options that aren’t needed for teaching new coders. That may be my next step though.

Posted by & filed under Moodle, teaching.

For a review leading into AP testing I like to give my students a review test where they’ll take a set of 5 questions out of a banks of a few hundred. To get a grade, they’ll need to get 80% or higher a set number of times. This six weeks we’re doing 2 points per attempt with a score of 80% or higher, up to 120 points for a test grade. So if they get an 80 or higher 53 times between now and the end of the six weeks I’ll put a 106 in the gradebook.

Catch is that it’s really time consuming for me to go through and count how many attempts 100 plus students tried.

Enter a plugin for Moodle called ad-hoc database queries.

With the plugin you can write SQL that’s run on your Moodle database and it will kick out a table with the results. The SQL below is what I used.

A couple of things to add that aren’t there yet is I’d like to add a prompt for the course ID. Right now it’s prompting for the module ID and the minimum grade you want to count. And, it’d be nice if it would sort by groups instead of just lumping everybody together.

But for now, it’s still way better than scrolling through and counting.

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 causes the text to be bigger than the rest of the paragraphs.

On this site I just put an !important tag in my child CSS for .lead to make it the same size. But that didn’t feel like a clean enough solution.

What I’ve done on another site, and it works without a hitch, is to take out the filter that the parent theme is using to put .lead on the first paragraph. The code below goes in the functions.php file for your child theme.

[snippet id=”344″]

I had tried to remove the filter before, but it has to go inside something called after both themes load since the child functions.php file is loaded first.

Posted by & filed under Blogs, Computers & Internet.

I’ve been dealing with a slow WordPress site for a while. In fact, it’s a whole series of slow WordPress sites. This site, along with a group of WordPress sites running in multi site, have never been quite as snappy as I’d like. And that’s weird considering that I’ve got another WordPress site running extremely well on the same sized droplet at Digital Ocean.

I’ve gone through all the normal fixes of optimizing the database, minifying JS and CSS, reviewing and changing memory settings for MySQL, and pretty much every other suggestion I could find online. They helped a bit, moving the server response time from 2 seconds to 1.9 or 1.5 on a good day. But it wasn’t significant.

A couple of days ago I took a look at and reviewed the access.log files for the server. And I was amazed at the number of times that wp-login.php was getting posted to. Guess that amazed probably isn’t the right word, but there were stretches where it was getting hit 5 or 10 times a second for nearly an hour. I’ve got the Limit Login Attempts plugin active on most of the sites so I’m not all that worried about them actually getting in. It was just the number of times that it was getting hit seemed to be a problem.

Even with Limit Logins, wp-login.php still needed to load WordPress each time that it’s hit. Loading the full WordPress stack 5 or 10 times a second so that a bot can try to break in is a waste of resources. A quick IP block and my server response time dropped to 0.6 seconds from around 2 seconds. Still not ideal, but way better. And it stayed that way until the bot started coming from another IP.

Protecting wp-admin.php

The next step was to protect the wp-admin.php file at a lower level before WordPress, or even PHP, gets involved.

First, you’ll need to create a password file. Through SSH you’d run something similar to the following. If you can’t get to SSH, your host probably has a tool in the control panel to do this.

$ htpasswd -c /home/username/.wpadmin username

It’ll prompt you twice for a password to make sure you’re entering the same thing.

And then you’ll need to add the following to your site config file, although you can probably do the same through .htaccess. I typically don’t use .htaccess, so I’m not sure if the syntax is exactly the same. I put this in /etc/apache2/sites-available/

<FilesMatch "wp-login.php">
	AuthName "Login"
	AuthType Basic
	AuthUserFile /home/username/.wpadmin
	require valid-user

A quick restart and now any request for wp-login.php will bring up a login prompt.

Did it work

I tried just about everything I could find online on how to fix a slow WordPress site. And really, most everything I tried worked to make it a little better. But this appears to be the single change that’s made the most significant difference.

Looking through the log files after this change the hits on wp-login.php are still there. But now a log file review is showing a 401 response code instead of a 200 which means that Apache is blocking the request before it even gets to PHP and WordPress.

It’s still probably better to block the big offenders through something like iptables so that they’re stopped as soon as the packet comes in and keep even Apache out of it. But at least this saves PHP and MySQL from having to do anything. –Ryan