2010
03.22

To use memcached here is how you can set your cache_store variable.

I think it might be better to include this in the environment specific configuration file like “production.rb” etc.

config.cache_store = :mem_cache_store, ‘127.0.0.1:11211′, {:namespace => “production”}

2010
03.14

Here is how to do it

NSMutableArray *myArray = [[[NSMutableArray alloc] init] autorelease];

// Logic to add elements into myArray – let us say you are adding objects with each of them having a property “order”

NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] initWithKey: @”order” ascending: YES] autorelease];
NSArray *sortedArray = (NSMutableArray *)[myArray sortedArrayUsingDescriptors: [NSArray arrayWithObject:sortDescriptor]];
[myArray removeAllObjects];
[myArray addObjectsFromArray: sortedArray];

2010
03.09

SVN: How to Branch?

By Satish Natarajan

I get asked this question quite a few times, so time to document it.

Branching is svn is a simple “svn copy”. Given that most of the repository nowadays use http here is the simplest way to accomplish it.

svn copy http://[server-name-along-with-path]/trunk http://[server-name-along-with-path]/branches/[branch-name] -m “[custom-notes]”

2010
03.01

iPhone: Add and Remove from views

By Satish Natarajan

If you are dynamically adding and removing subviews into an existing view here is how to do

Adding to the current view
[self.view addSubview: subView1];

Removing from the view
[subView1 removeFromSuperview]

2010
02.24

ObjectiveC: A good tutorial on string handling

By Satish Natarajan

I use this all the time – just to make sure to get my bearing right. I am sure it is useful to everyone as well.

http://www.techotopia.com/index.php/Working_with_String_Objects_in_Objective-C

2010
02.05

Linux: disk crash recovering control-d disk in read mode

By Satish Natarajan

Well, This happens when you have a crashed disk and you have an entry for it in /etc/fstab. Without removing the entry it will not boot up.

when it gives you control-d it puts the / partition in readonly mode. Here is how you can mount the disk in readwrite mode – modify fstab and replace the disk –

mount -o remount,rw /

then edit /etc/fstab …

2010
01.29

Symfony: How to test?

By Swanand

Here is a quick know-how an testing code in PHP Symfony framework. I’ve been using it extensively for testing, mainly because I am lazy in creating functional and unit tests.

Create a file like the following in your APP_ROOT , say

my_test_file.php

Now just call:
php my_test_file.php

2010
01.20

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

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!

2010
01.16

Symfony: How to get all the request parameters

By Satish Natarajan

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();

2010
01.16

Prototype: Find elements by class name – $$ method

By Satish Natarajan

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”