Highlighting source code in Word and PowerPoint

Posted by & filed under Programming.

File this under “how did I not already know this.” I put together quite a few PowerPoints and Word documents explaining how to do labs. And since I teach computer science, many of these include source code of some type. Normally I just type it in and change the font to Courier New or Lucida… Read more »

ActionScript Error: Expecting semicolon before minus

Posted by & filed under Programming, teaching.

One of my students came across an “expecting semicolon before minus” error while working on an ActionScript project last week. The error totally threw the student, but it made sense to me. At least I though it did. My guess was that somewhere in the code he had accidentally put a minus where one shouldn’t… Read more »

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.

fsockopen / fgets very slow in PHP

Posted by & filed under Programming.

I’ve been using a PHP class in a project that pulls a URL and then caches the result so it doesn’t have to get loaded again until it’s considered stale. Works pretty well, but every time it went out to get a fresh copy of a page it took forever. I was using fsockopen and… Read more »

Posting to Twitter with PHP and OAuth class

Posted by & filed under Programming.

Needed a bit of an update on a font site I threw up a few years ago. Specifically I wanted to put a script together to tweet a random font each day. Should have been easy since I already had a script that tweeted new fonts, although it’s been a bit behind since I haven’t… Read more »

How to create a very simple space game in Flash

Posted by & filed under Programming.

Admit it, you’ve played an online game while at work. And odds are very good it was written in Flash / ActionScript. We’re going to cook up a very simple Flash project that might serve as the start of a game. Keyword here is simple though. We’re not going to worry about anything except for… Read more »

Problem with SyntaxHighlighter and 2 character strings

Posted by & filed under Programming.

Had a very odd, very frustrating issue come up trying to get SyntaxHighlighter working on a project I’m working on. When the code to be highlighted was only two characters long it would blank it out and the code would display empty. After much digging I found this little bit of code inside of the… Read more »