WordPress recent posts as JSON

Posted by & filed under Programming.

For an update to one of my web projects I went looking for a way to get the recent posts as JSON instead of using the RSS feed. I personally find JSON much easier to deal with than RSS, so that’s the route I wanted to take.

days_ago function for PHP

Posted by & filed under Programming.

Can’t take credit for all of this, but I also don’t remember where the code that I started with came from. days_ago is a function that will take two dates and return a more human friendly version of dates. So if you pass today’s date and yesterday’s date it will return “1 day ago.”

PHP function to get first n words from a string

Posted by & filed under Programming.

A handy little function for your bag of tricks. This PHP function will return a max number of words out of a string, or the whole string if it’s already shorter. This probably could be made shorter, but I was in a hurry when I needed this and went for quick rather than clever.

JavaScript version of PHP __FILE__ or __DIR__

Posted by & filed under Programming.

This is one of those issues I keep coming back to.  I need a way to get the path of the current JavaScript file.  Something analogous to the PHP __DIR__ constant or dirname(__FILE__). Found something close on Stack Overflow.  The solution there gets the entire file.  A bit of substring and lastIndexOf and I had… Read more »

When in doubt, restart

Posted by & filed under Computers & Internet.

Sure, it’s a cliche.  Computer not working?  Restart the sucker.  This time though, it paid off. I just spent the better part of this afternoon working on a JavaScript issue.  I’m using SWFUploader to handle image uploads for a web application of mine; and it was working flawlessly in Chrome, Opera, and IE8.  Firefox, not… Read more »

phpMailer – Could not instantiate mail function

Posted by & filed under Programming.

Had a client getting this error when trying to send emails last week and have now spent several hours on Google trying to find a solution. Biggest catch is that other scripts were able to send mail, so it seemed unlikely that it was the host. So I took the phpMailer class and uploaded it… Read more »

Curved corners script for Photoshop

Posted by & filed under Programming.

I’ve been looking for an excuse to play around with scripting in Photoshop. Today I found one. I came across a series of actions that rounded off the corners of an image to get it ready for uploading to a web site. The problem is that it was a series of actions. As in one… Read more »

A routine to create GUIDs in PHP

Posted by & filed under Programming.

During development of an online application, I needed a way to generate a GUID. I’m sure there are other, better ways to do this. But, this is how I decided to do it.