Archive for August, 2009

[Resolved] Work Out Puzzle [ Maths ]

Posted in @home, Technical, work with tags , , , on August 24, 2009 by saffrongeek

A man wanted to get into his work building, but he had forgotten his code. However, he did remember five clues. These are what those clues were:

The fifth number plus the third number equals fourteen.
The fourth number is one more than the second number.
The first number is one less than twice the second number.
The second number plus the third number equals ten.
The sum of all five numbers is 30.

What were the five numbers and in what order?



X5+X3 = 14

X4 = X2+1

X1 = 2X2-1

X2+X3 = 10

X1+X2+X3+X4+X5 = 30


X1+X2+X3+X4+X5 = 30

X1+X2+X4 = 16  ( From, X5+X3 = 14 )

X1+2X2+1 = 16

=> 4×2=16 => X2=4

Now, this => X3=6, X5=8, X1=7, X4=5.

Access Code is 74658.


Resizing and Content not readable issue on new Partition

Posted in @home, Linux, PHP, Technical, work with tags , , , , , on August 24, 2009 by saffrongeek

Background Scenario:

I was finding my 55+GB Ubuntu OS running short of storage space. My harddisk had near to 80GB untouched till now. Somehow, I wanted to move my personal files to a new partitiion space so that my home folder gets a bit light weighted.

In Ubuntu, Go to System->Administration->Partition Editor. Select the partition you are gona resize for use. Make sure the ext3 filesystem is selected, and Click OK.

Now once done, you would have to restart your SESSION or just restart again. In the Places, drop down you would find the new partition. I prefer to mount it as when necessary.


I moved my personal files to new partition but was a bit not sure whether all happened fine. So when I open the partition in file browser, I find the folder with unreadable icon over it. An attempt to explore inside showed me a pop up saying like this :

The folder content could not be displayed. You do not have permission necessary to view the contents.

I just tried the below command and yep now the drive is accessible for read / write. Still, creating a directory from browser is not possible though ‘Terminal’ mode got no issues.

sudo chmod -R a+rX, go-w {pathtofolder}

Yep, Now I have a partition where i could back up my personal and project files and also able to explore them in file browser

The above resolved my issue but not sure to what extent. I find all working fine. I would be glad to know your thoughts and pointers.

Ubuntu :: Forgot your root or user passwords

Posted in Linux, Technical, work with tags , , , , , on August 21, 2009 by saffrongeek

The below mentioned is very simple steps for reseting the user password or root passwords. It happened like , I reset my password before taking off after a long tiring day at work and when i joined back to desk after some rest, I was not able to remember my new password. Also, it was then I realized that I dont remember my root password as well.

What I did was :

1. Restarted my machine.

2. Press ‘Esc’ Key while grub menu appeared. If only Linux , this scree splashes for a second or so .. so in that case you could press ESC key after BIOS load.

3. You would have the below screen where you select ‘recovery mode’



4. After selecting the recovery mode, you would have a similiar screen:

select root password optio

select root password optio

5.  You would be able to get a screen similiar and type o the prompt

passwd {userame}

6. Provide the password ad new password and

password and newpasswd

password and newpasswd

7. Type ‘reboot’

civicrm- dbhandle function I use a lot of times

Posted in mysql, PHP, Technical, work with tags , , , , , , , on August 18, 2009 by saffrongeek

In my cron class scripts, I very fondly make use of the function for dbhandle , got from civicrm files itself.

static function &dbHandle( &$config ) {
CRM_Core_Error::ignoreException( );
$db_uf = DB::connect($config->userFrameworkDSN);
if ( ! $db_uf ||
DB::isError( $db_uf ) ) {
CRM_Core_Error::statusBounce( ts( “Cannot connect to db via %1. Please check the CIVICRM_UF_DSN value in your   civicrm.settings.php file”,
array( 1 => $db_uf->getMessage( ) ) ) );
return $db_uf;
}// static dbhandle function

Once I have this function , all I need to do is

$config =& CRM_Core_Config::singleton( );
CRM_Core_Error::ignoreException( );

$db_uf =& self::dbHandle( $config );

Note: It is always a good practise to close connection . This can be done as below:


civiCRM API and memory release

Posted in Linux, mysql, PHP, Technical, work with tags , , , , , , on August 18, 2009 by saffrongeek

I read in one of the bug threads a resolve to fix the memory issue while manipulatig with contacts in civicrm. What it said was to use

CRM_Core_DAO::freeResult( );

This  reset the DB_DO global array so we can reuse the memory. But I am again a doubting guy so what I used to is free or release dao object the very moment the desired task is hadled.

For eg:-

$upt_qry = “UPDATE civicrm_value_user_status_32 SET {$updt_req} ”
.” WHERE user_type_131=\”%s\” AND entity_id=\”%s\” “;
$upt_qry = sprintf($upt_qry,mysql_escape_string($usertapeInfo[‘user_type’]),
$result = CRM_Core_DAO::executeQuery( $upt_qry );

This I found really helpful in scenarios with low memory and iterative cycles. Please share with me your thoughts.

%d bloggers like this: