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.

Another good use for mod

Posted by & filed under Computer Science, teaching.

Got to admit that mod is one of those topics that I have trouble getting across to my students. Not the idea of what it is and how to do it, but the purpose. The classic isOdd / isEven lab works. It can even be extended a bit into a isDivisible lab. And the College… Read more »

Just finished up a couple of WordPress plugins

Posted by & filed under Programming.

Needed a break from a larger web app I’m working on and this weekend kicked out a couple of WordPress plugins that I’ve had on my idea file for a while now. The first is called rTwit and lets you embed any Twitter feed you want into a post or page. Most of the Twitter… Read more »

bit.ly and PHP

Posted by & filed under Programming.

Needed a quick and easy way to create a bit.ly URL for another site of mine. Google came through for me. David Walsh posted a short PHP function on his site that takes your bit.ly login, API key, and the URL to shorten and returns a nice, short bit.ly link. Link: http://davidwalsh.name/bitly-php Just put the… 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 »

Event tracking with JavaScript

Posted by & filed under Programming.

A while back Google added event tracking to Analytics so you could keep track of Javascript and Flash events.  Pretty cool feature. Being the stat junkie that I wanted to use this to keep track of outgoing clicks on a photography forum of mine.  But I didn’t want to have to go through every link… Read more »

Grouping MySQL query by date

Posted by & filed under Computers & Internet.

Working on a statistics plugin I needed a way to group records by the day.  Turns out it’s remarkably easy. If you just want to group by year and month take off the DAY() part.  This would also be a good query to use WEEK() on to pull records grouped by the week they were… Read more »