Top Commenters Page
An addition to my website is the top commenters page. Even though the page doesn't look that complex, there is still a bit going on behind the scenes.
To get the top commenter count I have to thank Ryan Peterson in helping me write this custom MySQL query. I used Group By to lump the results together based on the commenter's email address. Then use count(*) to count the number of records in the group. Also used the NOT function in MySQL to filter my email address.
Mysql:
SELECT `Comment`.`author`, `Comment`.`id`, `Comment`.`url`, count(*) AS `count` FROM `cake_comments` AS `Comment` WHERE 1 = 1 AND NOT(`Comment`.`email`=\'m@marcgrabanski.com\') GROUP BY `Comment`.`email` ORDER BY `count` DESC LIMIT 0, 10Since I didn't want to load all of the related comments at once, I decied to use a little jQuery and Ajax to show comments that they have made.
First, I put a
spantag around the comment count, because without JavaScript you won't see this functionality. On page load I swapped the spans into links with$(this).replaceWith('<a>' + $(this).html() + '</a>');Instead adding behavior later after append, I used a jQuery object inside
replaceWithso I can attach behavior to the link and I like how the code looks.JavaScript:
$(this).replaceWith( $('<a>' + $(this).html() + '</a>').click(function(){ //code here }) );Using CakePHP's JavaScript object generator,
$javascript->object($data);it was easy to send JSON back to the client and parse with jQuery. Here is the full source of the JavaScript file.JavaScript:
$(document).ready(function(){ $('.get_comments').each(function(){ $(this).replaceWith( $('<a>'+$(this).html()+'</a>').click(function(){ link = $(this); $.post('comments/get/comments', { 'data[Comment][id]': $(this).siblings('.author').attr('id') }, function(data){ out = ''; for (i in data) { prefix = data[i].Article.type ? 'article/' : 'answers/'; out += '<li><a href="' + prefix + data[i].Article.slug + '#c' + data[i].Comment.id + '">' + data[i].Article.title + '</a>' + data[i].Comment.created + '</li>'; } $('<ol>' + out + '</ol>').hide().appendTo(link.parents('li:first')).slideDown(); $(link).replaceWith( $(link).html() ); }, 'json'); }) ); }); });
Update: I think I'll post the CakePHP code just in case someone is interested. Here is the controller, I use the RequestHandler component
var $components = array('RequestHandler');and the Time helpervar $helpers = array('Time');in the top of the controller.
PHP:
function get($type = null) { if ($this->RequestHandler->isAjax()) { Configure::write('debug', 0); if ($type == 'comments') { 'fields' => 'Article.title, Article.slug, Article.type, Comment.id, Comment.created' )); } } }I also turn debug off with
Configure::write('debug', 0);. Also, I only use$typeso that I can setup my code to get types of data if I want later - more of a design pattern I typically follow.Then in my view I use the time helper and output a JSON object.
PHP:
<?php if ($result): $results[$key]['Comment']['created'] = $time->timeAgoInWords($result['Comment']['created']); endif; endforeach; ?>
To see in action, click the comments count next to someone's name on the top commenters page.
11 Comment(s)Four Types of Web Developers, Which are You?
After years of working with developers and observing motivations - it seems I've generalized people into a few categories.
Please don't balk if they aren't 100% accurate, since everyone is different it is hard to generalize - but this shows the general trends I see of paths people follow when devleoping for the web.
Type A: Developers for Developers
The core of the coding world. They have philosophical debates about code with each other. From this group of people came all the programming languages ( C++, PHP, Java, Ruby, etc ). If they have any people skills at all you will see them leading conferences and in the lime-light. Otherwise you can find them in password protected MIRC channels and in the deep dark caverns of corporations where no business person has ever step foot.
Type B: Developers for Client-Developers
They build plugins, frameworks and tools for themselves and fellow developers. The focus is on developing bits of reusable code to accomplish client work more efficiently. In the marketplace some are self-employeed, yet most of these people occupying full-time positions as team leads (or normal developers who exceed employer expectations). Their philisophical debates are found to be mostly around what are the best tools to use, but also on how to write the best code. Community activity is high - as most have blogs, comment regularly on blogs and attend conferences.
Type C: Client-Developers
These developers use out-of-the-box software packages and slightly modifies them to get client work done. Their focus is on doing what the boss or client tells them for the day. May listen to podcasts, or participate in community lightly via blog comments or in-frequently posted to blog hosted at Blogger.com. Will only attend a conference if it is local and 100% paid for. In the marketplace you will find them working 40 hour weeks. Prime motivating factor is family and job security.
Type D: Developers for Money
These people are hack'n'mash, "developers". You will find them grabbing dreamweaver or any WYSWYG tool to, "make a million" via affiliate programs and any idea they can get their hands on to make money. Visit their sites and see all types of ads - link ads, popup ads, pop-under ads (though some are finding smarter methods). Products are being sold because they understand the human condition and feed desire into a sale (conversion).
What type of devleoper are you? I am definitely type B.
Business Cards
After getting tired of not having business cards when people asked, I decided to buckle down and make some.
I sent the design over to www.overnightprints.com to get them printed. They turned out exactly how I wanted them - A+ print job by my standards. These cards turned out great!
It is exciting to have some business cards that are this nice. No more writing my email address on a napkin!!
List of Personal Projects as of August, 2008
A list of what personal projects I have going on.
- Rent Update - Rental property listing web application - I have high hopes for this project.
Status: Well-Underway - backend data entry developed, design complete, UI development started.
- jQuery Datepicker v4 - Rewriting jQuery datepicker on top of the jQuery UI core.
Status: Started - initial code structure is complete.
- CakePHP jQuery Integration - Integrating jQuery and jQuery UI into the core of CakePHP.
Status: Concept - digging into current code. Thinking ways to integrate helpers to follow jQuery mindset.
- Carcassonne Online - Board game converted to JavaScript on top of jQuery UI and Comet.
Status: Underway - much of the game interaction has been developed, some difficult parts left.
- Family Reminder - Web application to help those of us with bad memories to list family events and birthdays, members of a family can subscribe to reminders and get invitations, address where to send cards, etc.
Status: Started - database structure and concept complete.
- Open Ad Sense - Open source ad system which gives more ad revenue to publishers instead of Google/Yahoo taking most of it.
Status: Concept - industry professionals are excited about the concept after I explain it.
These are all unpaid (at the moment) and for my own personal career development.
My Response to Full-Time Employment Opportunity
I received a request for employment from a company who had gotten funding and was trying to assemble an, "all star team" (I made the above logo for fun). Most of the time I do not respond, but in this case the person hiring took so much time crafting the email that I decide that I needed to email back. My response was largely canned, but at least I took the time to respond:
I am currently not seeking full-time employment, however I do consult for agencies that know my work or have worked with me in the past. I find that working relationships are most beneficial if the agency has had experience with my work, because they are able to accurately judge my abilities. Typically, I am sought after for prototyping and user interface development. My rate is ___ per hour.
He then responded with a line of questions regarding why I was only open to consulting. Here was my response, which I think sums up a lot of where I am at in my professional life:
Employer: Thanks for the reply. May I ask why you are not open to full-time employment? Do you prefer consulting work?
Marc: Consulting allows me the ability to work from home and keep working for agencies to a minimum. I try to stick to 24 hours of consulting per week, allowing the rest of my time to be dedicated to personal projects. My projects are worth their weight in gold, more valuable to me than the fleeting cash that I get from consulting. That said, I still need to pay bills and I do love to do client work when it suits my talents and abilities.
Employer: One thing to mention is that we could talk about giving you the option to do consulting work on the side, while being a full-time employee of ours.
Marc: I tried full-time employment with working on side projects and got burnt out, so this is not an added benefit. Full-time employment is too demanding on time. You only have so many fresh-thinking development hours in a week. My opinion is that if you do 60+ hours in a week, than a lot of that time you weren't spending on pressing your abilities to the maximum - not only do you end up having no life, but you most likely wasted a lot of time with clouded thinking.
The goal here is efficiency and making time as effective as possible.
Employer: We need an all-star team to turn our company into a multi-million dollar enterprise and we think you could be a great asset to our team.
Marc: Thanks again for considering me for your all-star team. As far as making a company into a multi-million dollar enterprise... I have worked with fortune 50 companies (UnitedHealth Group, HSBC, 3M and Ford) and have seen them make millions off of my work, which is a reason that ultimately led me to go off on my own as soon as I could. I am happy to make people money, but the fact is that if you are full-time, then your rate is pretty much set and you don't have the time to dedicate to creating your own ideas.
Employer: Will you consider it with the right pay? Let me know.
Marc: I do not consider full-time to be an option right now because it limits me from doing the projects that I feel the need to create.
Overall the goal is to create ideas, and full-time employment doesn't allow me to do that at this point in my life.







