Fun with fail2ban and WordPress

We run some webservers at work as a part of the services we offer our customers, we’re not a large host by a long shot, but we still get a large amount of brute force attacks against the WordPress installs we run.

I’ve been monitoring the servers and just manually dealing with them using a quick firewall block whenever I’ve seen these in the past, but unfortunately we’ve passed the point of this being a viable solution.

Enter fail2ban.

Continue reading

I love joined subqueries in MySQL

So I was looking into ways of improving the load times of a project, and knowing SQL is one of my biggest weaknesses (in my own humble opinion), I figured there might be a fair bit to gain by researching a bit around it, which lead to a friend linking me to

Judging by his benchmarks on a low amount of data points, he discovered a massive leap between a subquery and a joined subquery. I’ve been using join statements all along (and in some cases multiple queries like the schmuck I am) so I figured it was worth giving this a shot on the data I was working with. I mention the data points as it was put up in the comments that the amount of data he queried against was very low, I hit mine against ~50 000 rows of data

Continue reading

What got me into development

I had the weirdest memory hit me this morning, and it made me chuckle a little (people at bus stops give you odd looks if you laugh randomly); What got me into development in the first place.

Many moons ago (actually ~15 years ago I believe) I was playing a text based strategy game, that featured a chat, which led to me discovering IRC. Back then full scale IRC “bundles” were all the rage, and I remember looking long and hard to find a cool one.

I’d like to point out that I was an awkward teen with a horrible sense of humor…much like now, except substitute teen with “pretend adult”.

This was how I met my first friend online, Chris, as we both discovered the same bundled script (named MurderScript, because it was a friendly one) which auto-joined all users to their own IRC channel, and this was where we met.

One day as I got home from school I connected, and as soon as I joined, the cheesiest line ever came faster than I could blink:

Oh no! It’s Clorith, run for cover and don’t bend over!

It seems somewhat juvenile now, but this was the most fascinating thing to me, HOW did he do this magical thing, at first I actually believed he had been sitting there waiting for me to join just to write that.

My IRC poison of choice is mIRC, now as then, and it comes with its own scripting language (aptly acronymified down to mSL), which lets you customize your experience to the tiniest detail.

I took this, I wrote scripts, MANY scripts. I like to think I became very good at them. But in the long run, I wanted more!

I wanted to do something cool that others could make use of as well. I started with some flash (actionscript anyone?), but quickly moved away form this as it relied on coldfusion and I didn’t much care for it.

So I discovered PHP instead, it let me do anything I set my mind to, and I loved it!

So now I have a job where I get to do development, and I have a hobby which lets me develop, all thanks to that one juvenile joke so many years back… and I still chuckle thinking of my excitement that day.

Epson: The sequel

A few months back I wrote an article aptly titled Epson: A horror story and today, after all this time, there was finally a breakthrough (granted there’s been a few months of ignoring the problem in resignation in between).

Not that it’s not a horror story still, a month ago I was informed that my issue had been elevated to level 2 support…yesterday I emailed them informing them I’d not heard for Level 2 yet, and got a fun little response; My concerns over not hearing from level 2 had been elevated to level 2…

Any way, since others may stumble upon the same issues as me, I’ll outline the problem, what caused the confusion and problems, and the solution to the nightmare (which is so simple I should feel ashamed for not having thought of trying it).

The problem

I needed to print out logos on our POS (Point of Sale) thermal printers, we’ve tried a few of them, Epson so far had the best interface for configuring them, and everything in general just seemed a lot cleaner up until the image part.

I opted to use an NV image for my logos (images are stored to the internal memory of the printer it self, making for faster prints, and allowing me to provide multiple images if I so desired), this provides you with a key code, the default being two consecutive spaces.

The confusion

The programmers documentation form Epson (which they couldn’t help me interpret I might add…horror!) has the following entry for printing data from the NV memory;

14-09-09 14.54.03

Sorry for the picture, but it’s a nightmare trying to spell this out!

The main confusion here was caused by the format line, I worked off the Decimal line, converting each entry to their ASCII value using PHPs chr() function,

kc1 and kc2 represent KeyCode1 and Keycode2 for the NV image (the two spaces), since it had the same word on each line, I expected the value provided belonging to the ASCII line, and I would then provide the Decimal of this, I thus interpreted the above as follows;

29 40 76 6 0 48 69 32 32 49 49

This was my mistake.

The solution

After a lot of back and forth, I was trying to describe my approach, and the documentation to people in multiple channels on IRC getting all the help I could to crack this nut, and in doing so I confused many many users.

That’s good though, because the outside perspectives they provided showed me what I was doing wrong, and where the documentation fails on a high grade in my opinion.

Turns out the x and y values are both provided in Decimal format, where as the debug output form the printer shows the keycodes in ASCII I made the presumption that that’s what I could be fed with (especially since they provide both hex and decimal values, it makes little sense to then further down only provide a decimal value).

The CORRECT representation of the above should thus be

29 40 76 6 0 48 69 32 32 1 1

That I had not even thought to try this before baffles me…I tried many variations with the decimal string above, but never ever thought to try providing the x and y values in that manner.



I’ll be over there, in the corner…