Looking at a site that had been live for years:
They always forget.
As you may have heard, in PHP apparently the following returns true:
'9223372036854775807' == '9223372036854775808'
And after it was posted on reddit a few days ago, shit hit the fan, as expected.
I’m not going to write about whether or not this is bad language design or whether or not PHP sucks – there’s more than enough discussion about that on reddit and hacker news – but there is a really important lesson here:
I was recently working on a site that needed to display the featured image of every page in its sidebar.
On regular, static pages or posts, everything works as intended – you can use is_page(), is_single() and get_the_ID() and not worry about anything.
// This works well on static pages or posts,
// displaying the featured image
if ( is_page() || is_single() ) {
if ( has_post_thumbnail( get_the_ID() ) ) {
the_post_thumbnail( 'full' );
}
}
However, on pages that contain the Loop (blog posts page, custom loop pages), things can get a bit complicated. I’ll walk you through a bunch of different solutions you can use to get the post/page ID, depending on the situation.
Stay away from online games.
They are evil in its purest form.
I was only twenty-two, remember; not that I was so stuck on myself that I didn’t want to know just where I was at fault, but at that age nobody knows much of anything.
Edwin Lefevre, “Reminscences of a Stock Operator”
Fair enough.
The idea that it’s easy to protect your web app from XSS seems to be floating around the interwebz. I’ve seen a whole bunch of “tutorials” saying stuff like “just use htmlencode()” etc.
If you’re building web applications, even small ones, do yourself a favor and use a proper html sanitization library. I hear good things about HTMLPurifier (PHP) and Sanitize (Ruby); there probably is a library for most other languages as well. I don’t dare to recommend anything specific so you’ll need to do some research, but it will be time well spent. And if you’re using a framework or CMS, use the sanitization functions they provide.
I wrote down some notes on building html-based emails for myself and I thought I should post them, since it looks like people are having trouble with html emails. There’s probably nothing new here, but maybe it will be helpful to someone.
Adding custom fields to comment forms in WordPress doesn’t seem to be documented very well online and I couldn’t find any working plugins either. It’s not difficult at all, though.
I worked at Mäksa parish administration for a couple of months this summer. I was in charge of managing the networks & computers of the administration, plus a small school and a library (’tis a really small parish, like most of them in Estonia are). The last IT guy quit overnight without saying goodbye, or telling anyone the current server and network passwords.
And so it came to be that on a sunny day in August, the server hard dive ran out of space, and I (still) didn’t have the root password. So I called the ex-IT-guy, but he didn’t pick up his phone.
I kept calling him for the whole morning. Nothing.
Oh well, I thought, he’s probably really busy with his new job. Maybe he’ll call back later.
But then, in a sudden flash of insight, I looked him up on Facebook and sent him a message.
Got a reply exactly 11 minutes later.
Apparently, paraphrased from this video.
I really wish I had seen this a few years ago. I’ve always known that everything takes time and I just need to keep practicing.. but I lost motivation many many times.
It’s good to know that I’m on the right path.