Archive for category Design
Web Development – Mac or PC?
All of my machines are Linux. Been that way for 5 years. I love my Linux machines, but it is becoming apparent that to go further in my development career I need to, at least include, one of the two main computer companies. Read the rest of this entry »
Using Regular Expressions with Twitter Search
Posted by Johnny in Design, PHP, Tech, TechMunchies on July 1, 2009
A new project has me using Twitter’s search api.
The json returns text of each message, which is to be expected, but many posts have “@soandso” or “http://is.gd/lko6g” or something, and that kind of info can’t just be left to sit there now can it?
No it can not.
However, a little regular expression magic and presto! Links GAlore.
Using preg_replace you can quickly and easily replace each text version of ‘@johnmangino’ with @johnmangino.
The only “trick” here is to use the parenthesis to give you a reference that will allow you to make the user link without the ‘@’.
Here is a quick function used within the loop to href the links.
Import the function and run the text through it like so:
$text = $r->text; $text = makeRich($text);
Hope you enjoy.
Yours truly,
$johnny
SELECTing From Multiple Tables in MySQL
Posted by Johnny in Design, PHP, Tech, TechMunchies on June 6, 2009
I needed to grab data from 3 tables in one query for a new app that is being built internally at work.
I was going through the tedious procss of a multiple table JOIN when I discovered I could greatly simplify things with this –
So I thought I would share.
I know the ‘if condition is wonky.
Technically I usually do:
$results=$mysql->query($q);
if($results)
{
...
}
but this seems faster to me.
No?
PHP, Email and Twitter – updated
Posted by Johnny in Design, PHP, Tech, TechMunchies on June 3, 2009
Update: The entire script is available at Snipt for your viewing pleasure.
Whenever we release a new Course at work an email is sent to all of the offices with all of the pertinent information including a link to the product page.
Looking for a way to keep people up-to-date on our releases through Twitter I decided the quickest, easiest and most hands-off way to do that would be to have a script that could take the email and extract the course name and a link to the product page and post it to twitter. This way we can keep people informed of the latest releases at the exact same time it’s being released.
So, I had three goals for this script.
1 – Grab the Subject and the product page link from the email.
2 – Shorten the product page link.
3 – Post the info to VTC’s twitter account
There’s nothing groundbreaking here. It’s basically reading a file with STDIN instead of a static file or webservice. But I thought I would share.







