Tag Archives: Technology
Few PHP 5.3 Presentations & RegX Cheat Sheet I Liked
I happen to find these while reading/surfing, so thought of putting it here …. I would be adding more to this post ….
[pdf http://www.decentmind.com/wp-content/uploads/2011/01/php5.3.pdf ]
regular-expressions-cheat-sheet-v2.pdf
Courtesy: [http://ebookchoice.net/php-5-3-awesome.html#]
-deepak Continue reading
Use Javascript/JQuery to Rewrite Amazon Affiliate Links
Just put following javascript at the bottom of the html page on which you would like to re-write/add the Amazon Affiliate ID to all amazon products.
What it simply does is, searches for “tag” in the url and adds the affiliate id to it.
<script type="text/javascript"> $(document).ready(function() { $('a[href*="amazon.com"]').each(function() { this.href = this.href.replace(/\?.*$/,"") + $.query.load(this.href).set("tag","Your-Affiliate-Id").toString();}); }); </script>
NOTE: Don’t forget add following jquery plugin JS in the header section of your page
As this code chunk is based on jQuery you have to include jQuery library as well on the top. Continue reading
Doctrine YAML Schema Files: Abbreviated Syntax
Doctrine offers the ability to specify schema in an abbreviated syntax. A lot of the schema parameters have values they default to, this allows us to abbreviate the syntax and let Doctrine just use its defaults. Below is an example of schema taking advantage of all the abbreviations.
The detect_relations option will attempt to guess relationships based on column names. In the example below Doctrine knows that User has one Contact and will automatically define the relationship between the models.
---
detect_relations: true
User: Continue reading
symfony form field without a label
I was standing in front of the problem that I have a form with only one field. In this case the label of the field has shown no sense. For this reason, it had gone – but how? The solution … Continue reading
Symfony2 WebProfiler
Symfony2 just introduced its WebProfiler, the utility will soon be the favorite of all programmers. Most veterans will recall that five years ago was the first Symfony framework to include a web debug toolbar. This bar displays useful information for debugging applications and provides access to all logs with a single click:
Symfony2 presents its WebProfiler as the great evolution of the web debug toolbar. Whenever you view a page, Symfony2 generates a unique token debug (pictured above, the token is 4c7e59811509c). By clicking on that token, it shows the WebProfiler with all the debug information:
In the menu on the left side you can see the five main sections to the Profiler which now has:
Request: displays information about the request and response (parameters, cookies, headers).
Exception: if the request has caused an exception, it shows the type of exception, the message from the server and the whole execution trace.
Events: Shows the events raised during execution of the application (along with their event listeners) and the events that have been identified but have not come to run.
Logs: Displays the same information to log the original debug toolbar.
Doctrine / Propel: shows the queries to the database and the time taken for each.
Another great features of the Profiler is that it keeps all your information in a database called SQLiteprofiler.db and stored in the directory cache/ in your application. With this database, you’ll be able to consult the entire execution history of your application, which will facilitate the clearance of projects:
If you want to try the Profiler, you need version of the sandbox Symfony2 PR3, which has not yet been published as a downloadable file. Therefore, when you can only download via git:
mkdir sandbox
git clone http://github.com/symfony/symfony-sandbox.git sandbox
cd sandbox /
git checkout PR3
Now you can try accessing http://localhost/sandbox/index_dev.php Continue reading
Multiple domains on symfony project
This post is about developing a symfony project that provides multiple applications that are reachable on multiple top level domains. In our case, the symfony applications “UMTS Netzabdeckung” and “Flatrates Vergleich” share the same backend (models, data, etc.) but each site is a standalone application and has a dedicated top level domain.
Create two applications
The first step is to create two applications. Run
symfony generate:app site1
symfony generate:app site2
in your console and change the default actions, routing, etc. Same thing as usual.
Edit .htaccess
The next step is quite simple: Open your .htaccess file in /sf_project_dir/web and insert your second application to the .htaccess file (BEFORE the default RewriteRule)
RewriteCond %{HTTP_HOST} secondhost.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ site2.php [QSA,L]
That’s all!
That’s all to get it working. Each request to your second domain will be redirected to the according application. A drawback is, that your “frontend” application is still reachable on your second domain if you type in the script name directly. Since I’m not an htaccess expert, I just added some php code to my index.php:
if($_SERVER['SERVER_NAME'] != ‘www.flatratesvergleich.de’) {
header(‘Location: http://www.flatratesvergleich.de’ . $_SERVER['REQUEST_URI']);
die;
} Continue reading
Incident Management
I am posting it here for my own reference, Few of you might find it useful. So here I go. An incident is any significant, unplanned event that occurs during testing that requires subsequent investigation and/or correction. Incidents are raised … Continue reading
How to Create Your First WordPress Plugin
Today I just explained the concept a wordpress plugin to one fo my mate @ workplace. So thought of documenting it here for my own reference. Example explained here is different than what i explained to my friend.
A WordPress plugin is simply one or more PHP files that adhere to certain rules and conventions. All you need to understand and complete this post is a basic understanding of PHP programming.
Aim of this post is to explain the concept of creating a Wordpress Plugin i.e. to explain the process for newbies.
Lets create a plugin which simply displays the most commented 5 posts.
Plugin Folder Structure
../wp-cpntent/plugin/your_plugin
Now we will create a folder in Wordpress Plugin directory say “most_commented_post” i.e.
../wp-cpntent/plugin/most_comments_on_post
Activating/Deactivating the Plugin
In order for wordpress to activate/deactivate we need to add PHP comments to main file of the plugin. Means we will create a file named “most_commented_post.php”
../wp-cpntent/plugin/most_comments_on_post/most_commented_post.p Continue reading
Symfony Coding Standards
Following coding standards is one of the easiest way for everybody to understand everybody’s code.Here’s the golden rule: Imitate the existing symfony code. Never use tabulations in the code. Indentation is done by steps of 2 spaces: <?php class sfFoo … Continue reading
CSS Sprites
I have been working on this technique and found it quite interesting and loved working on it. Lets discuss more about this technique. What it is?? Technique wherein small images are consolidated at one place and then that consolidated image … Continue reading


