The latest and greatest version of jQuery, version 1.4, was released on January 14, the birthday of jQuery’s original launch. Bugfixes and improvements abound! The jQuery team has put together a site devoted to the new version, called the 14 days of jQuery, covering the major version changes as well as infrastructure updates coinciding with [...]
Read MorePosts tagged "programming"
Get domain out of any URL string (yes, really)
It’s a common problem with no single right answer: extract the top domain (e.g. example.com) from a given string, which may or may not be a valid URL. I had need of such functionality recently and found answers around the web lacking. So if you ever “just wanted the domain name” out of a string, [...]
Read More coding theory, crappy coding, php, programming, regular expressions, software developmentBuild a slick Twitter feed on your site
A few months ago I published an article describing how to output a Twitter stream on a page using PHP, and later followed up with two more to polish the display. The article content and code examples have since been tweaked based on feedback and my own debugging. If you haven’t already had a look, [...]
Read More lifestream, php, programming, regular expressions, social networking, TwitterFind the second (or third, or fourth) occurence in a string
PHP includes some handy functions to find the first or last occurrence of a given string token in a string: strpos and strrpos. However these functions are limited to just the first occurrence; what if I want to know the location of the second token’s position, or the third? These problems usually result in some [...]
Read More handy functions, php, programmingExtract email addresses from tags
Ran into another cool hurdle today for my Fwd:Vault development. When I grab the message content to archive it in the system, first thing I do is scrub it out to ensure that (a) it displays properly, and (b) there are no misbehaving characters. I grab both plain text and HTML email formats (if present), [...]
Read More email, fwdvault, php, programming, regular expressions, security, usabilityVersatile random string generator
A cursory glance around the web will reveal a ton of PHP-based random string generators. With enough looking you’ll find generators that do any of the following: Strings with letters Strings with numbers Strings with letters and numbers Uppercase, lowercase Fixed, variable length strings Option to include symbols Problem is, none of them ever incorporated [...]
Read More extension, programming, securityEasily calculate dates and times in different timezones
Building off my last post, where I showed you how to easily display any public Twitter feed on your site, I ran into another problem: the dates that are delivered by the Twitter API all reflect Greenwich Mean Time (GMT). Now I thought about going the old route and doing some convoluted math using date(), [...]
Read More extension, fwdvault, programming, standardsFormat a RFC2822 date for mysql datetime fields
I was crash-coursing myself on PHP’s IMAP functionality recently, one of the first questions I came across was how I might store the date from an e-mail header in a MySQL DATETIME field. I was afraid I was going to have to parse out the string using a bunch of calls to substr(), but then [...]
Read More mysql, php, programming, standardsAutomating SSH or SFTP in scripts
Recently I needed to automate copying a MySQL database to a backup server. We keep a copy of our site and DB on this box in the event that our main systems go down, or there’s a problem with our internet connection. It’s kind of like a poor man’s colocation setup. I actually prefer the [...]
Read More mysql, programming, securityUsing SQL computations in WHERE clause
When writing SQL statements, sometimes I want to filter the result set based on a value that must be computed out of the stored data. Here’s an example: I want to see which widgets have been sold more than once, and how many times each of those remaining widgets have sold. Obviously we could pass [...]
Read More mysql, programming- 1
- 2