Category: tech


What I Use

April 9th, 2009 — 3:14pm

It occurred to me recently, that there’s a bit of variance in what developers use. For many folks not used to writing code, the availability of software to help write software can be a bit overwhelming. For that reason, I’m writing the stuff that makes me tick.

A disclaimer: I primarily use Mac OS X (Leopard). I love using Ubuntu, but it’s not where I get the bulk of my work done. So, here’s my Mac apps:

Coding:

Eclipse PDTEclipse PDT. I write primarily in PHP, and there’s just no better app out there for big PHP development. Something to note about Eclipse though, don’t use more than what comes out of the box. Eclipse can be buggy as hell, so don’t add all the plugins you can find to it. Eclipse is for writing code, not for committing SVN updates. Remember that, and you’ll love Eclipse as much as me.
TextMateTextMate. After having said all of that, there’s some times when I want a text editor that’s light, and gets the code updated quickly. Eclipse is a memory beast, and if you’re strapped for RAM, you won’t be able to run Photoshop, Illustrator, AND Eclipse at the same time. For that reason, TextMate is awesome.
vimvim. Finally, the most lean of all editors is vi. I use vim, since it has a few extra things I really appreciate. The learning curve on vim is hell, but once you’re used to it you won’t look back.

Graphics:

IllustratorAdobe CS 4. I’ve tried all of the substitutes out there. But none of them hold a candle to Adobe’s mismanaged, bloated, overpriced Creative Suite. Photoshop and Illustrator are indispensable tools if you’re doing web graphics (or any other graphics for that matter)

Communication:

AdiumAdium. I don’t know of an IM client that comes close to Adium. I can be logged into all of the social networks I use at one time, in one window, and it doesn’t cost me anything to do it. That beats the hell out of anything else out there. Hopefully, there will be some challenges to this in the future. But for now, this Mac-only app is the definitive way to do IM.
TweetDeckTweetDeck. Twitter is definitely mainstream these days. TweetDeck lets me create groups out of the people I follow, see replies to me (public and direct), search terms, and see whats trending on Twitter, all in the same window. That’s pretty awesome too. **NOTE** I’m starting to try out Seesmic, and it’s pretty good too. Both of these apps are built on Adobe’s AIR platform, so everyone can get a taste.
Apple MailApple Mail. This might seem a bit obvious, but I wanted to give Apple some credit here. Apple Mail is an awesome mail client that meets almost every need I have, out of the box. I use the WideMail app to give it just the right tweaking I need out of it.

Local Server Software:

MacPortsMacPorts. I tend to need some esoteric stuff from my LAMP environment, so I use MacPorts as a package manager to customize the variables of my development environment to my liking. With MacPorts its usually a trivial issue to install Memcache, Apache, MySQL, PostgreSQL, PHP, etc.. I’ll usually even change the version of rsync and vim using the MacPorts package manager. If you don’t know about MacPorts, you’re definitely missing out.

Miscelaneous:

QuicksilverQuicksilver. Whenever I setup my Mac, Quicksilver is always the very first thing I install. Once you’ve got a mind for using the shortcuts in Quicksilver, you will never ever ever go back to the old school hunt-and-peck way of lanching apps, and performing tasks.
Visor. Another gem from Blacktree: Visor allows the terminal to always be quickly available to me, but also not intrude on the desktop. A lot of times, I don’t even change the default terminal theme (just change the font to Monaco 12pt Anti-Aliased).
TransmissionTransmission. Transmission is the greatest bit-torrent application around. It’s light and gets to the point. Other apps try to push content and channels. Transmission just downloads the torrents. Awesome.

Comment » | personal, tech, work

SSH Without Password

January 21st, 2009 — 9:15am

I used to always refer to a different site when I wanted to remember how to setup a machine to use SSH without a password. That site (I don’t recall what it is) isn’t around anymore. So, I guess I have to post the tutorial here.

SSH is one of the major tools in what I do. For any developers out there who don’t know about it, you’re missing out. Long gone are the days of requiring screen sharing or remote desktop to manage another computer. SSH is the bomb, and it’s been around for a long time.

Here’s how to use it, without needing to enter your password when you make a connection to a remote machine:

  • On the computer you’re making a connection from (i.e. your home computer)
    • If you do not have a ~/.ssh folder already, create one.
    • ssh-keygen -t dsa -f ~/.ssh/id_dsa -P ''
    • scp ~/.ssh/id_dsa.pub <username>@<servername>:~
    • Make an old-skool connection to the server you just copied your public key to (i.e. your public webhost)
  • on that server:
    • cat id_dsa.pub >> ~/.ssh/authorized_keys2
    • chmod 0600 ~/.ssh/authorized_keys2

That’s it. Keep in mind, that you’ll still need to specify your username when connecting to the host (if it’s different than your username on your local machine). If you want to get around that, you’ll need to setup an SSH config file (future tutorial?).

Comment » | tech, tutorial

Google Reader and Zend_Http_Client Saves Time

November 16th, 2008 — 6:24pm

I’ve been working a lot on Florida Death Metal lately. Part of that means that I need to know news, as it happens, from a lot of different sources. That can be difficult (and a pain in the ass) to keep track of. The last thing I want to do, is visit 50 different sites every 15 minutes to see if there’s any news I should know about.

The first thing I did, to filter input, was to setup a Google Reader account for Florida Death Metal. At least this allowed me to see updates from a variety of other sites in a single place. This also allows me to search through those new listings for keywords to bands and events I think are important to know about.

This still requires me to visit Google Reader, and parse through a lot of stuff (routinely over 1000 new items) to find out what’s going on in the world. The real dilemma I was having, was trying to implement an active alert system to news going on around me. The active part, was me actively searching through Google Reader for information relevant to Florida Death Metal. 

Needless to say, this started to suck. I have a great full time job, a wonderful wife, and a million other things I like to do with my spare time. Spending my days and nights on Google Reader, struggling to keep up with news for a project blew.

I love Florida Death Metal. I’ve never been involved in something that means so much to me. However, there are only so many days in the week, and so much time in each of those days. I need a way to passively keep up with relevant news and events. I needed some automation, so I could spend time hanging drapes for Melissa, or having a beer with Rob.

Enter Zend_Http_Client ….

One of my favorite programming tricks is breaking down requests to servers, and finding a way to do them programatically. So, I got to thinking about how I could parse through all of my stuff in Google Reader. For each of the views in Google Reader, there is an associated RSS feed. Well, that makes things simple enough. I could just grab the RSS feed and parse it. 

One minor detail, the RSS feeds aren’t publicly available. You have to be logged in to use them. This makes sense. I imagine Google doesn’t want to be used as an aggregator of RSS feeds to be used as a proxy to other sites. Sorry :/

So, here’s a breakdown of what I needed to write a script to do:

  1. Login to Google
  2. Grab the RSS Feed for ‘All Items’
  3. Parse the RSS Feed for keywords relevant to Florida Death Metal
  4. Email me alerts (if there are matches)

Not too bad. So, Here’s the script I came up with. I hope you like it :

 
<?php
/*
Description: Script to parse through a google reader aggregation of content for keywords
Version: 1.0
Author: Cory Collier
Author URI: http://corycollier.com/
*/
 
//Define the constants required for the script
define('GOOGLE_PASSWORD', 	'<your password here>');
define('GOOGLE_RSS_URI', 		'<the url for your google reader rss feed>');
define('GOOGLE_LOGIN_URI',		'https://www.google.com/accounts/ServiceLoginAuth?service=reader');
define('GOOGLE_LOGIN_EMAIL', 	'<your gmail account username / email>');
define('MAILER_FROM_ADDR',		'<where the email should come from>');
define('MAILER_TO_ADDR',		'<where the email should go to>');
define('MAILER_SUBJECT',		'Google Reader Parsing');
 
/*
* a Zend Framework Installation _MUST_ be located on the include path for PHP
*/
require 'Zend/Loader.php';
Zend_Loader::registerAutoload();
 
//Instantiate a new Zend_Http_Client, with the google login url
$client = new Zend_Http_Client(GOOGLE_LOGIN_URI);
 
/*
 * Set the client cookie jar ...
 * Set the method to POST ..
 * Set the parameters to post with
 */
$client->setCookieJar()
	->setMethod(Zend_Http_Client::POST)
	->setParameterPost(array(
		'continue'		=> GOOGLE_RSS_URI,
		'service'		=> 'reader',
		'niu'			=> 1,
		'hl'			=> 'en', 
		'Email'		=> GOOGLE_LOGIN_EMAIL,
		'Passwd'		=> GOOGLE_PASSWORD,
		'PersistentCookie'	=> 'yes',
		'asts'			=> ''
));
 
//make the login request, and store the response in the $response variable ...
$response = $client->request('POST');
 
//If the response was successful, change the uri value for the client object
// to the appropriate rss file for parsing
$client->setUri(GOOGLE_RSS_URI)
 
		//Change the request method to GET
		->setMethod(Zend_Http_Client::GET); 
 
//send the request, and store the results of it
$response = $client->request();
 
//Initialize an array of keywords to look for
$keywords = array (
	//Whatever your keywords are you're looking for
);
 
//SimpleXML is great!
$sx = simplexml_load_string ($response->getBody());
 
//Iterate through each of the retrieved entries
foreach ($sx->entry as $entry ) 
{	//Now, iterate through each of the defined keywords / keyphrases
    foreach ( $keywords as $keyword ) 
    {	//First, check to see if the title contains a keyword / keyphrase
        if ( stristr((string)$entry->title, $keyword) ) 
        {	//Append any matches to the matches arrays
            $matches[] = (string)$entry->link['href'];
        }
    	//Next, check to see if there are any matches in the summary
        if ( stristr((string)$entry->summary, $keyword) ) 
        {	//same deal: If there are matches, add them to the stack
            $matches[] = (string)$entry->link['href'];
        }
    } //END keyword iteration
 
} // END posting iteration
 
//IF matches were found, send an email
if(count($matches)) 
{	//Initialize a variable to store a mesage in
    $message = '';
 
    //Iterate through each of the matches
    foreach($matches as $match)
    {	//For each of the matches, append them to the message string, separated 
    	// by newlines
        $message .= "\n" .  $match;  
    }
    //Initialize a new Zend_Mail object 
    $mail = new Zend_Mail;
 
    //Set the parameters necessary to send a message 
    $mail->addTo(MAILER_TO_ADDR)
        ->setFrom(MAILER_FROM_ADDR)
        ->setSubject(MAILER_SUBJECT)
        ->setBodyText($message);
 
    //I never trust email, so wrap the email execution in a try/catch statement
    try  
    {	//Send the mail
        $mail->send();   
    } catch (Exception $e ){
        //Do something here
    }
}

Wrapping all of this up, I stuck this script on a spare debian box at my house, and setup a cronjob to run the script every 15 minutes. It saves me a lot of time. I’d love to hear some feedback from y’all about how I got this done. I’m a script guy at heart. So, this stuff is super fun for me.

Wrapping all of this up, I stuck this script on a spare debian box at my house, and setup a cronjob to run the script every 15 minutes. It saves me a lot of time. I'd love to hear some feedback from y'all about how I got this done. I'm a script guy at heart. So, this stuff is super fun for me.

I know I should have checked the success of the initial login attempt before assuming the second request would get anything at all. Keep in mind though, this is a script I use to make my own life easier. Exceptions being thrown here cause me no harm. If I don't get anything, I can check my error logs for issues. Not a perfect solution, but it's working pretty well for me now. :D

1 comment » | tech

Red Hat vs PDO vs PCRE vs Zend Lucene Search

October 16th, 2008 — 9:37pm

Recently while working at my new job at Hydra Studio, my buddy Rob and I came across an issue that was killing us: 

“Invalid parameter number: no parameters were bound”

 When people used our search feature on our site, a few specific search terms would result in un-caught exceptions. Of course, this ONLY happened on the client’s server. Nothing like saying a project is solid, only to find out there’s something ’special’ about the production environment.

The first thing we did, was to list out what was unique about the client’s server. The client was using a Media Temple box running CentOS 5.2. For the un-initiated, CentOS is the free version of Red Hat Enterprise Server. We run Macs in the office, and our staging server is a Mac too. Other than the OS, the normal ‘LAMP’ stuff pretty much matched verbatim. 

So, we started digging into the differences between the compiled versions of PHP between the development and production environments, and one thing popped out at us:

PCRE

The version that’s supported on Red Hat / CentOS is 6.6. That’s horrible. 6.6 came out nearly 3 years ago, and the version the client was running had no support for unicode at all. A little research, and we found out that Zend Search Lucene (what we built the search functionality on top of) requires unicode for the way it stores search indexes.

With that, we figured we were done. The client had a limitation on their server, they needed to address it, and the problem would fix itself when they did. Not quite so fast …

I was testing some of the searching on my iMac, when the same issue happened on my own computer. Disaster! Could it be that something in our own code was the culprit? What half-reproducible error was causing this? 

After hours of searching for an answer on the googlez, I came across some help on the Zend Issue Tracker. It turns out, that PDO was failing when it was trying to prepare a statement, when that statement contained a question mark. When I switched my SQL adapter to Mysqli, the problem was solved. Both the production and the development environments were bug free after the change.

It turns out, that our search indexes would return fields that either contained question marks, because they actually existed in the document (as was the case locally), or because the document had encoding errors when the search index was built (as was the case on the production servers). The ORM we used would grab the documents, and grab relevant data from the database by querying with the fields stored in the index.

The SQL that was being prepared, would then look something like this:

‘SELECT id FROM folks WHERE first_name LIKE ‘Jo?hnny’

The question marks would be interpreted by PDO as variable markers, which rightfully didn’t exist.

So, the real solution wound up being a little bit of a mix between the client’s problem, and our own. Granted, we needed to catch question marks being stored in db before they got there. That improves the longevity of our own code. However, the search functionality will still return results that may have question marks in them, thus causing the same issue. That issue is resolved by using Mysqli, but that feels more like a hack, than a solution.

Anyways, I spent a long time trying to search the answer to this and found nothing except the one mention in the issue tracker. For those of you using Zend Lucence Search on Red Hat / CentOS servers. Make sure you use Mysql if you’re using the Zend ORM to populate models based on results returned from the index. 

Oh yeah, and make sure you filter your input too, Mr. Bobby Tables…..

1 comment » | tech

XP Logs Off Automatically

July 31st, 2008 — 9:39pm

So I got a call from a client today regarding a few issues they were having. Most of the problems weren’t all that difficult to solve, save one….

The boss’s computer would immediately log off after he tried to logon. While this might sound funny (in other circumstances, it really is), the client (who is a really cool guy, whom I respect a lot) did not think it was funny at all.

So, I dived into the Google to find out the issue. The short version; there was a bad registry setting. Basically, when this sort of thing happens, the first thing you should check is the registry. Now, you can’t connect to the registry locally, since you can’t logon to the computer with this issue.

So, the first thing you need to do, is logon to a computer on the same network as a user who has administrative rights on the computer concerned. Once you’ve gotten that far, you’ll need to open regedit. Something like this:

After that, you’ll need to connect to the computer in question. That’s easy, check the following pics:

then… 

The following key is what you should be looking for:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

That key should contain a string value for ‘Userinit’. If you’re confused, you should see something like the following:

Well, you probably shouldn’t see the green box, but you should see the string value for Userinit. If you don’t see that value in the root of key Winlogon, then you’ll need to create it. 

That’s not too bad either. First, right click the right hand pane of the registry editor:

Select the ‘String Value’ item in the right click menu. Once you’ve gotten that done, you’ll have a new string value in the right hand pane, awaiting you to name it. It’ll look something like: 

Name the string Userinit. After you’ve done that, right click the entry and select ‘Modify’. Make sure that the value for the key is:

c:\windows\system32\userinit.exe

Again, here’s a picture:

And that’s it. If you have any issues after you’ve gotten this done, I recommend an ERD disk or formatting your HD. Those are extreme options, I know. However, I don’t think you want to tool around with your computer for hours on end ( or maybe you do ).

2 comments » | review, tech, tutorial

Social Media Programs Worth Something

July 28th, 2008 — 3:29am

So, as  a follow up to my rant about the lack of value in most social networks that clog the arteries of the internet these days; I thought it’d be a good idea to follow up with some thoughts on networks and programs that I do like, and why I think they’re cool.

[Networks - The places online for social media]


 

 

Twitter

1. Twitter – Probably not a surprise to most tech folks out there. For those of you who don’t know (geez), twitter offers a sort of ‘micro-blogging’ platform. It’s kinda like blogging for people who don’t have time to blog. With a max post length of 140 characters (not words), you can’t say too much. However, it’s a great way to keep up to date with your friends, or important people, like Tim O’Reilly

Pownce

1.a. Pownce – For all the same as Twitter, but a different network (with more features too). This is Kevin Rose’s (Founder of Digg) Twitter Clone. 

 

Delicious

2. Delicious – I can’t begin to say how much I like Delicious. The actual site (again, for those of you who are scratching your heads right now) is del.icio.us. The idea is to have a place online where you can store your bookmarks. That way, you never have to worry about not being able to find that one video online, when you’re at your mom’s house or something.

2.a. Magnolia. – For all the same reasons as Delicious. Magnolia is just a different interface to the same idea as Delicious. 

 

 

3. Flickr – Hands down, nobody has online photo sharing down like Flickr. The amount of things you can do to your photos with Flickr is nothing short of obscene. To top it off, the developers are a pretty eclectic group of characters. Call me an idealist, but I like the idea of nutty dudes (and dudettes) writing software that really does something for the world.

[Software - The stuff on your computer that helps _you_ out]


 

 

1. Twhirl – I use Twhirl pretty much exclusively for ‘tweeting’ these days. Twhirl runs off of Adobe AIR, a sort of intermediary between a program, and it’s operating system. This means that if you’re running Windows (XP, or whatever Vista variant), Linux (within reason), or OSX; you will be running the same program. That makes for easy support. Anyways, Twhirl is awesome because it doesn’t always give me the ‘too many requests’ errors of twitteriffic, AND it posts to Pownce for me too.

 

2. Flock – Flock is a browser that’s built on top of Firefox. It makes keeping up with Social Media sites pretty easy. Some of the features of flock (like the top media bar, displaying photos and videos) are equally awesome, and cumbersome. Despite some of it’s shortcomings, Flock is still a really cool app that does a good job of combining a web browser with a social media dashboard.

 

3. Adium – Now, some of you might not think of instant messaging as a type of social network. No websites, no pictures, no birthdays, no etc… However, IM was really the first type of social network, and it was well beyond it’s time. These days, if you’re not on IM, you don’t talk much to me. Seriously, my wife has to get on IM to chat with me, when we’re in the house together. IM is king, and Adium makes using IM a breeze.

Comment » | opinion, review, tech

Back to top