01.29
Symfony: How to test?
By Swanand
Create a file like the following in your APP_ROOT , say
my_test_file.php
Now just call:
php my_test_file.php
Findings, Tips & Tricks
Create a file like the following in your APP_ROOT , say
my_test_file.php
Now just call:
php my_test_file.php
Tired of looking at this:
[root@hsrv4 kaveri]# svn diff apps/frontend/modules/socket/templates/_form.php
Index: apps/frontend/modules/socket/templates/_form.php
===================================================================
--- apps/frontend/modules/socket/templates/_form.php (revision 835)
+++ apps/frontend/modules/socket/templates/_form.php (working copy)
@@ -10,7 +10,7 @@
$websites = $user->Group->getWebsites(true);
if (!isset($showAllTabs)) {
- $showAllTabs = true;
+ $showAllTabs = false;
}
//socket_type
$stype = $form['socket_type']->getValue();
[root@hsrv4 kaveri]#
And want this instead:

Color SVN diff
Just a matter of installing a package:
1. Install colordiff ( use the package manager of your choosing, Ubuntu has apt-get, Fedora has yum):
yum install colordiff
2. Instead of this:
svn diff path/to/file.rb
do this:
svn diff path/to/file.rb $* | colordiff
Use this if you want to depend on the GNU diff program. If you trust colordiff enough, use this:
svn diff path/to/file.rb --dif-cmd colordiff
3. That’s it. Done!
If you want to print all the request parameters of a request here is how you can do it.
The following call returns and array of parameters.
$this->getRequest()->getParameterHolder()->getAll();
Suppose you want to hide all the elements with the class name “foo” here is how you can do it using the $$ operator
$$(’.foo’).each(Element.hide); — Notice the “(dot)foo”
Installation
1. Follow this link to install and configure memcached.
2. Start the memcache server using either
memcached -vv
or
/etc/init.d/memcached start
Integrating memcached with your rails application
1. Install memcache-client
gem install memcache-client
2. Add the below line to end of your config/environment.rb file.
CACHE = MemCache.new(’127.0.0.1′)
3. Add the following method to your application controller / application helper or where ever you want according to your needs.
def perform_cache(key)
begin
unless output = CACHE.get(key)
output = yield
CACHE.set(key, output, 15.minutes)
end
rescue => e
logger.info “MEMCACHE ERROR+++++++++++++++++++++++++++++++++++++++”
logger.info “ERROR : #{e.message}”
logger.info “MEMCACHE ERROR+++++++++++++++++++++++++++++++++++++++”
output = yield
end
return output
end
The above method performs the caching based on a unique key. If the value for that key already exists, it will return the output from the stored cache or else it will execute the block you are using when calling the above method and generate a new value from the executed block for the particular key and store it in the cache.
You can set a timer to expire the cached data.(15 mins in my case.)
If you don’t want to expire the cache based on timer, simply remove the third parameter we are passing to ’set’ method.
The above method also handles the exception,in case your memcache server is down for some reason.
4. Cache your complex queries as follows.
my_key = Digest::MD5.hexdigest(request.request_uri)
output = perform_cache(my_key) { ClassName.method_name(…) #Your query/method }
Note : The key generated should be always unique. I am using the URL as the key, Since the URL is pretty long we can take the MD5 hash of it and use it as the key.
That’s it, You are ready to go.
Onchange-event and IE are no friends. Well, it took time for me to find this out.
Yes, IE does not support onchange event.
But NS and Mozilla do.
Solution: Use the onclick event to accomplish the same. This way, all the browsers will be