 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Rob Allen's Blog: Sublime Text 2 Snippet for PHP getter and setter generation
by Chris Cornutt January 03, 2012 @ 09:54:23
In a quick new post to his blog, Rob Allen has shared a snippet for the Sublime Text 2 editor to make creating getters and setters for your class simpler (dynamically too).
As with a lot of editors, Sublime Text supports snippets which are essentially text expansions of a short phrase into more text. I needed to create a few getXxx() and setXxx() methods for some properties of a class and decided that the easiest way to do this would be with a snippet.
Included in the post is the code you'll need to put into the snippet - a simple find (regular expression based) looks at the currently selected variable and expands out the getter and setter for it. For more information on the Sublime Text 2 editor, see the product's website.
voice your opinion now!
sublimetext2 editor snippet getter setter code
Sameer Borate's Blog: Grabbing the referrer search engine keywords for a site
by Chris Cornutt October 18, 2011 @ 13:25:27
On his blog today Sameer Borate has a new post with a handy bit of code you can use to find the keywords from a search engine referral to help with tracking how visitors have come to your site.
A couple of weeks back I had to write a solution for a client to track the referrer search engine from where the user came to his sites contact page, without using Google Analytics. If a user was to fill the contact form on the website, the referring search engine name and the keyword for which it was refereed was to be emailed along with the contact information. The following is a solution for the same.
The code itself is pretty simple - it checks the $_SERVER['HTTP_REFERER'] and, based on an array of search engine types, looks for a certain "query" keyname in the URL and matches what follows (with a regular expression). This can be useful for not only determining what sort of audience is visiting your site, but could also be used to present a custom message to visitors from certain search engines (or, more complicated, to show different content based on search terms).
voice your opinion now!
search engine keyword referrer url snippet
WebInOne.net: Date validation for CodeIgniter 2
by Chris Cornutt October 07, 2011 @ 11:57:21
On the WebInOne blog there's a post about doing some date validation in CodeIgniter 2 forms using the "set_validation" method.
I wrote a tutorial here about the CI date. At that post I used the HTML <select> for the input of date. Sometime our client can want to use text box for the date input. We need the validation for this date. I have found this code from here. It is for CI 1.7.* and PHP 5.2.*. So I change some code for the CI 2.0.* and PHP 5.3.*.
There's some code snippets included in the post showing how to use it in the form (HTML), setting the validation on the form object (for US and UK validation) and the actual code of the updated custom Validation class.
voice your opinion now!
date validation tutorial framework snippet form
CatsWhoCode.com: 10 super useful PHP snippets
by Chris Cornutt April 05, 2011 @ 08:38:10
The CatsWhoCode.com blog has a new post today with what they call super useful PHP snippets that could help you out in a pinch.
Having the right code snippet at the right time can definitely be a life saver for web developers. Today, I've compiled 10 really awesome PHP code snippets that will, I hope, be very helpful in your forthcomming developments.
Their list of ten includes bits of code for:
- Super simple page caching (file-based)
- Convert seconds to time (years, months, days, hours...)
- Get current weather using Google API
- Get latitude and longitude from an address
- Save url to PDF
voice your opinion now!
snippet useful helpful
DZone.com: Reuse your closures with functors
by Chris Cornutt December 29, 2010 @ 10:50:19
On DZone.com there's a new tutorial from Giorgio Sironi about reusing closures with the help of functors (a special kind of object instancing done in PHP with the help of __invoke).
I like PHP closures and their superset, anomyous functions, as they implement the Command pattern very well when used correctly. However I feel that sometimes they are: difficult to reuse and difficult to force contracts on. [...] What if we wanted instead, a closure which we can instance even more than one time (maybe with different variables), and that we could type hint?
He shows how to make this possible with a functor created using the __invoke magic method of PHP to handle the request to an object like a function. He includes some sample code to show it in action - a basic callback (SquareCallback) and how it compares to calling a normal closure. It also shows something a bit more technical, an "AdderCallback" class that can be defined as a type hint on a function.
voice your opinion now!
closure functor invoke snippet example callback typehint
Phil Sturgeon's Blog: Power dump() on your PHP applications
by Chris Cornutt September 30, 2010 @ 11:04:03
Phil Sturgeon has a quick new post with a code snippet that could make your debugging life a bit simpler - a "dump" function that can give you a bit more information about your error than a standard var_dump.
When trying to work out what the hell is going wrong in your PHP application the first thing most of us start doing is madly start var_dump()'ing everything possible to work out where the problem is. var_dump() is fine, but by default it comes out in one line. So then we need to echo <pre> tags. Then we can't always see whats going on, especially if the background is black and bla bla bla so it goes on.
He mentions an alternative like XDebug, but that also requires access to install it on the server. His alternative, the "dump" function, catches the error, pulls out a backtrace of the path your script took to get there and echoes it out with the line number of the error and filename.
voice your opinion now!
debug snippet vardump backtrace
Designer Daily: 8 useful recipes to improve your WordPress theme
by Chris Cornutt August 19, 2010 @ 12:39:21
On the Designer Daily blog there's a recent post sharing eight simple bits of code you can use in your WordPress site to help make your theme even better.
Blog engine or CMS, call it whatever you want but WordPress is a great tool for web designers. It just get a little hard to use sometimes when you want to do some more advanced things in your theme and you are not a coder. Here are 8 snippets of code that have helped me in recent projects.
The eight snippets they share show how to include:
- Include post thumbnail in RSS feed
- Next & Previous Post Titles With Thumbnails
- Search Specific Category in WordPress
- List top 10 authors of the blog with their last post
- Automatically insert content in your RSS feed
- Display a Comment's Number in a List
- Display your most commented posts in your blog sidebar
- Excluding Posts from Your WordPress Feed
Each item links back to the full recipe it came from.
voice your opinion now!
wordpress theme recipes snippet code
TheseDays.com: An Easy Way to Detect Mobile Devices
by Chris Cornutt August 11, 2010 @ 08:24:35
On the These Days blog there's a recent post talking about creating a mobile version of your site and how you can detect if the visitor is using a mobile browser or not using WURFL.
WURFL, The Wireless Universal Resource File (WURFL) is an open source project which collects information about all of the different mobile devices in use. It is constantly being updated, so as long as you keep your WURFL definitions up-to-date you don't have to worry about your detection scripts not recognising new devices. By querying a WURFL database with your visitor's User Agent string, you can not only determine whether the device they are using is a mobile device, but whether it has a touch screen, can make phone calls, is a tablet (iPad) and more.
They include a snippet of code that uses the Tera-WURFL service and a call to getCapabilitiesFromAgent to see what kind of client is making the requests and what it supports.
voice your opinion now!
detect wurfl wireless mobile device snippet
Kevin Schroeder's Blog: Debugging an RPC call in Zend Framework
by Chris Cornutt July 26, 2010 @ 08:37:49
In a quick new post to his blog today Kevin Schroeder shows you how to debug an RPC call in your Zend Framework application.
Just a quickie. Do you ever want to debug an RPC call to XML-RPC or Soap or something like that using Zend Studio/PDT and the Zend Debugger? What I mean is debug the RPC call, not the request making the RPC call. Doing that is actually quite simple. I have some code here to share that I recently (as in 5 minutes ago, used).
His code snippet shows an "if" conditional that sets values on a set of cookies that the Zend Debugger will pick up on and start the debugging process (with settings like start_debug, debug_coverage and debug_start_session. He also explains the four you really need to know about in a bit more detail.
voice your opinion now!
debug zendframework rpc snippet
CatsWhoCode.com: 10 life-saving PHP snippets
by Chris Cornutt July 20, 2010 @ 11:47:35
New from the CatsWhoCode.com site today there's a list of ten code snippets from Jean-Baptiste Jung that could be "life-saving" in your development.
In order to be efficient, a web developer should have a toolbox with code snippets he can use and reuse when needed. In this article, I'm going to show you 10 extremely useful PHP code snippets to add to your web developer toolbox.
They're not amazing, but that can be very handy in the right situations - things like:
- Highlight specific words in a phrase
- Automatic password creation
- Calculate age using date of birth
- Maintenance mode with PHP
- Add (th, st, nd, rd, th) to the end of a number
voice your opinion now!
code snippet toolbox
|
Community Events
Don't see your event here? Let us know!
|