svn add/remove newly added files

Sometimes we have an update of codebase many files updates also new files to be added and also removed, to overcome this issue you will need to add them or remove them without adding/removing files already exsits in the repo, the following command line script solve this issue.

add files

svn st | grep ^? | sed 's/?    //' | xargs svn add

remove files

  svn st | grep ^! | sed 's/!    //' | xargs svn rm

edit content in drupal issue with lock message.

Drupal have a good command line interface “CLI” called Drush some time drupal cache behaive in diffrent ways, in one of the projects that I worked on I have a problem with entitycache module, and to solve this issue I had to clear cache everytime I edit and save node, during this I found that I can execute this command “php-eval” :

drush php-eval "entitycache_flush_clear_cache( 'node', nid, TRUE )"

svn diff between tow repositories

To make svn diff include all the unversioned files from your local working copy you have to add these files first. svn diff outputs the same changeset that svn commit would use.

If you know for sure that all unversioned files should be added here’s what you could do.

Prepare a list of unversioned files by taking from the output of svn status all the lines that start with a question mark:

svn status | grep ^? | sed -r ‘s/^\? +//’ > ../unversioned_files_list.txt

You can then pass that list of files to svn addusing xargs:

xargs -r -d ‘\n’ svn add < ../unversioned_files_list.txt

And then produce the patch:

svn diff > ../my_patch.patch

If you don’t want to keep those files added, use the list of files to unadd them:

xargs -r -d ‘\n’ svn rm –keep-local < ../unversioned_files_list.txt

svn diff --old=https://svn-777.prod.hosting.acquia.com/aljbalkanmr/trunk --new=https://svn-777.prod.hosting.acquia.com/aljbalkanmr/tags/2012-04-10/ > ~/Desktop/balkans_diff.txt

MySQL size functions

Today I want to know my database size and after some research about the database size in mysql I found this script

Get Size of all database tables

SELECT TABLE_SCHEMA AS 'Database', TABLE_NAME AS 'Table',
CONCAT(ROUND(((DATA_LENGTH + INDEX_LENGTH - DATA_FREE) / 1024 / 1024),2)," Mb") AS Size FROM INFORMATION_SCHEMA.TABLES;

replace YOUR_DB_NAME with your database name in following 2 examples:
get size of specific database tables

SELECT TABLE_SCHEMA AS 'Database', TABLE_NAME AS 'Table',
CONCAT(ROUND(((DATA_LENGTH + INDEX_LENGTH - DATA_FREE) / 1024 / 1024),2)," MB") AS Size FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA like '%YOUR_DB_NAME%' ;

to get size of entire DB :

SELECT
CONCAT(sum(ROUND(((DATA_LENGTH + INDEX_LENGTH - DATA_FREE) / 1024 / 1024),2))," MB") AS Size FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA like '%YOUR_DB_NAME%' ;

Add directory to system path in ubuntu

Adding a directory to system path varaiable is easy in ubuntu, just you have to append the directory to the system path
and you can do that by exeute the following script :

export PATH=/path/to/directory:$PATH

but this one is temporery for you current session, to make directory avaliable in the system path, just edit you .bashrc file in you home folder, and add the above code at the end of the file:

$ vim ~/.bashrc

.......
.......
export PATH=/path/to/directory:$PATH

VBox : unable to find the sources of your current linux kernel ubuntu

after some update for my ubuntu linux, I wasn’t able to make my VBox machines to work, so i tried to run

sudo /etc/init.d/vboxdrv setup

but no use, but after some googling i found this and it’s solved my proble

sudo apt-get install dkms
sudo apt-get install linux-headers-`uname -r|cut -d'-' -f3`-`uname -r|cut -d'-' -f4`

referance : http://www.khattam.info/solved-error-unable-to-find-the-sources-of-your-current-linux-kernel-specify-kern_dir-and-run-make-again-stop-2010-11-26.html

Create auto-complete with ajax form in Drupal 7

Usually you can create auto-complete functionality in Drupal without facing any issue, the following example can help in creating a text field with auto-complete in drupal 7 :

http://timonweb.com/how-create-ajax-autocomplete-textfield-drupal-7

here I will not discuss how to create auto-complete, it’s very easy thing but, here I want to point to an issue appears when you try to create auto-complete field in a form that submitted by ajax framework in drupal 7,¬† and try to make it more usable, the first thing to do for the filed is to make the result clickable and submit the form when the user click on the result item, and you accomplish this by overriding¬†Drupal.jsAC.prototype.select function in misc/autocomplete.js

 
Drupal.jsAC.prototype.select = function (node) {
  this.input.value = $(node).data('autocompleteValue');
  if(jQuery(this.input).hasClass('auto_submit')){
    this.input.form.submit();
  }
};

The first thing you will notice here after trying to test this is the page will refresh after the click on the result item, hmmm so what’s happening here is weird, but after some debugging and tracking the files and functions in the ajax framework in drupal 7, I noticed Drupal using ajaxForm plugin to submit the form so the form will be submitted after adding the above override to the website, so to make it work with the ajax framework this need some modification so we can click on the auto-complete result item and submit the form by ajax, so here is the modification I added to the code above to make it work with the ajax framework :

Drupal.jsAC.prototype.select = function (node) {
  this.input.value = $(node).data('autocompleteValue');
  if(jQuery(this.input.form).hasClass('ajax-processed')) {
    var options = {
      dataType : 'script',
      url : Drupal.settings.basePath + 'system/ajax',
      type : 'POST',
      data : {_triggering_element_name : "op", _triggering_element_value : ''}
    };
    $(this.input.form).ajaxSubmit(options);
  } else {
    this.input.form.submit();
  }
  //return false to prevent normal browser submit and page navigation
  return false;
};