 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Abhinav Singh's Blog: Wordpress style "Duplicate comment detected" using Memcached and PHP
by Chris Cornutt January 02, 2010 @ 07:36:27
Abhinav Singh has a new post today looking at his method for preventing duplicate comments (similar to a method used on Wordpress blogs) using memcached.
In this blog post, I will put up some sample PHP code for Duplicate comment detection using Memcached without touching the databases. Towards the end, I will also discuss how the script can be modified for usage in any environment including forums and social networking websites.
His method uses a custom function (is_repetitive_comment) to create an md5 hash of the comment and username to check against the stored values on the memcached server. Code is included as is an explaination of how it all works together.
voice your opinion now!
memcached duplicate comment wordpress
Giorgio Sironi's Blog: Never write the same code twice Dependency Injection
by Chris Cornutt July 29, 2009 @ 10:27:12
In a new post to his blog Giorgio Sironi looks at how using dependency injection in your applications can help keep you from writing the same code over and over:
Is Dependency Injection difficult? Is it hard to do? Certainly it provides value. Particularly in Php, but also in other object-oriented languages, Dependency Injection gives steroids to the process of class reuse, designing components as loosely coupled objects.
He explains a bit of what dependency injection is all about, how it fits in with unit testing applications and a few examples of how it might look in some sample PHP classes. He shows how a bit of refactoring can remove dependence of one class on another and how the factory pattern can be used to correctly create an instance your first class might need.
voice your opinion now!
dependency injection duplicate code tutorial
DevShed: Managing Secure Protocol in Apache-Based Websites using PHP
by Chris Cornutt May 29, 2009 @ 07:55:25
On DevShed today there's a new tutorial that walks you through tips on two things that can help you keep your https site running smoothly and keep in favor with the major search engines - duplicate content and correct 301 redirects.
When trying to maintain a secure protocol on an Apache-based website, you can expect to deal with certain issues, especially if you're also trying to rank well in the search engines. [...] This article provides tips and solutions to help any web developer effectively manage the two most difficult problems in maintaining the secure protocol side of any website. These are the: Duplicate content and 301 redirection from the non-https to http version.
They recommend two things to handle the duplicate content issues: placing a meta tag on the https pages to keep them from being indexed (keeping the search engines from seeing the http and htttps as two different resources, thus two different sites to index) and using a canonical value in a link tag.
As far as the 301 redirects go, they include some PHP code that, if placed at the top of your pages, can detect if the protocol is https or not. If its not, it uses header to perform the 301 redirect.
voice your opinion now!
tutorial content duplicate redirect https
Jani Hartikainen's Blog: Reusable "generic" actions in Zend Framework
by Chris Cornutt December 29, 2008 @ 07:55:13
In this recent blog entry Jani Hartikainen looks at the creation of generic actions for Zend Framework applications - methods that can be used to help eliminate code duplication:
Sometimes you will need nearly the same functionality in many actions. [...] There are several ways to deal with this, such as moving the code into a separate function, or an action helper. But in this post, I'm going to introduce so called "generic actions" - parametrized, easy to reuse actions - which is an idea similar to django generic views.
His example takes a generic action - one that grabs and output records from a table - and modifies it to take in parameters from the defining function as to which action/controller/model and ID to use. Then this action can be used over and over in multiple places without having to do any copy and paste coding.
voice your opinion now!
generic zction zend framework reuse duplicate
Knut Urdalen's Blog: Washing emails
by Chris Cornutt November 27, 2008 @ 14:42:56
Knut Urdalen has posted a new blog item about something he calls "washing emails":
In this tutorial I'll show you how to create a simple PHP script to cleanup a list of email addresses. As a web developer you have probably been asked to wash a list of emails from a manager or marketer some times. Here's the ultimate solution.
His script does a few things - removes duplicates, validates that the email address exists, uses pipes for communication and is as flexible as possible to work on most PHP distributions. You can download the simple script here.
voice your opinion now!
washing email script duplicate valid address pipe flexible
PHPro.org: SQLite-ON DUPLICATE KEY UPDATE
by Chris Cornutt November 10, 2008 @ 12:58:18
This new tutorial on the PHPro.org website shows how to implement a common database feature, ON DUPLICATE KEY UPDATE, in a SQLite database with PHP.
SQLite is an ultra lite database replacement that comes bundled with PHP. Because of its light weight it lacks many of the features found in more robust applications such as MySQL, PostgresQL and others. One of the features that is lacking is the ON DUPLICATE KEY UPDATE that is often used to automatically UPDATE a record, should a duplicate field be found. Here a demonstration is provided to duplicate this behaviour using PHP Exceptions.
Their example creates a table of animals and inserts several to act as a base. They show insert method, how to get the information back out and what happens when you try add a duplicate value to the table. Normally this just results in an exception being displayed but, when caught with exception handling, it can be redirected into an update statement to change that animal's current information.
voice your opinion now!
tutorial exception sqlite update duplicate key
Brian Moon's Blog: ForceType for nice URLs with PHP
by Chris Cornutt October 04, 2007 @ 09:37:00
On his blog today, Brian Moon talks about setting up ForceType directives in Apache, specifically how to make "friendly URLs" without having to use mod_rewrite (which might not be installed on your server).
This has been covered before, but I was just setting up a new force type on our servers and thought I would mention it for the fun of it. You see lots of stuff about using mod_rewrite to make friendly URLs or SEO friendly URLs. But, if you are using PHP (and I guess other Apache modules) you can do it without mod_rewrite.
There's three steps to the process - adding the directive to your Apache config, making the script able to handle the request, avoiding duplication of content and returning a 404 error when there's no matching data.
voice your opinion now!
forcetype url modrewrite duplicate content forcetype url modrewrite duplicate content
Soledad Penades' Blog: Signs your PHP needs refactoring
by Chris Cornutt June 05, 2007 @ 16:26:00
As mentioned by Ed Finkler, there's a list of signs your PHP needs refactoring from Soledad Penades.
I have had to go through a php application recently which has given me more than one headache and has required me to use all my possible patience. While working with it, I thought This is good material for an article, so that nobody else does the same in the future, and nobody else will need to experience the same displeasure as I have had to.
So here are the signs your PHP application needs a serious refactoring, right now
Included in the list are things like:
- Uses global variables
- Everything's an array
- The neverending switch
- Interface inconsistency
It hits on one of the thing that bugs me too, the problem of "Brackets galore" - so many subarrays that you have to resort to three or more sets of bracketed keys to get to the value you want. It's bad enough trying to follow someone else's code without having to "trace down" an array to figure out which of the values they're talking about.
voice your opinion now!
refactoring global bracket duplicate switch interface inconsistent refactoring global bracket duplicate switch interface inconsistent
|
Community Events
Don't see your event here? Let us know!
|