tips

Your First jQuery Plugin

We all have come to love and admire jQuery for the amazing Javascript library it is. But we also have fallen in love with numerous extensions to jQuery; plugins, modules - whatever you call 'em. Most of us, however, just use these goodies and bless the hearts of all wonderful people who make the gems available. Some of us are even a little bit intimidated when we look at all the complicated Javascript-ing going on in the source files... Especially when/if we accidentally look into a minified version ;)

Jokes aside, starting a new jQuery plugin is quite simple. Here is just how easy one could be:

(function($) { 

	// jQuery plugin initialization
	$.fn.irakli = function(conf) {   
		alert("okaaaay");		
	}; 
	
})(jQuery);

This goofy plugin will allow you to invoke irakli() function on a jQuery object. For instance, $('div.something').irakli() will have an alert box pop up.

"More" Link's URL for a Block Display in Drupal6 Views2

It is only available in the top-level theme as a variable, but in case you need to derive the same value from the View object, per se, here it is:

$view->display[$view->current_display]->handler->get_path();

How to Delete All Tables in a MySQL Database

If you are working on a system with somewhat large number of tables, you probably have wanted to delete a number of tables matching a pattern (dropping all tables is a specific case of this one). You can do that, by creating a very simple stored procedure:

mysql> delimiter $$
create procedure drop_tables_like(pattern varchar(255))
begin

SELECT 
@drop_sql:=concat('DROP TABLE IF EXISTS ', group_concat(table_name)) 
drop_statement
FROM information_schema.tables
WHERE table_schema=database() and table_name like pattern;

IF (@drop_sql IS NOT NULL) THEN
  PREPARE stmt from @drop_sql;
  EXECUTE stmt;
  DROP PREPARE stmt;
END IF;

end$$
delimiter ;

then you can use this procedure to mass-delete tables like:

mysql> call drop_tables_like ('ika%');

Easily Edit Blocks in Drupal

I finally got around developing a little, nifty Drupal module I've been craving for, for a really long while now. The "Edit Block" module adds inline block editing capability to any theme. It's entirely jQuery-based, hence - no dirty intrusive theming hacks are necessary and is compatible with most properly built Drupal themes.

Some nice themes do provide similar capabilities, but most - do not and adding it is no fun, so now there's a module that does it all for you.

Enjoy

Installing GIT on OS-X In 3 Minutes

How to install GIT on OS-X in under 5 minutes:

curl http://kernel.org/pub/software/scm/git/git-1.6.3.3.tar.gz -O
tar xzvf git-1.6.3.3.tar.gz 
cd git-1.6.3.3
make configure 
./configure --prefix=/usr/local
NO_MSGFMT=yes make prefix=/usr/local all
sudo make install

Git should be installed on your OS-X now, which you can verify by issuing: git --version command in Terminal. However, it's a good idea to also pre-configure the default username and e-mail for your Git installation:

git config --global user.name "Your Firstname Lastname" 
git config --global user.email "username@example.com"
git config --global --list

I personally, also like to set:

git config --global color.ui "auto" 
Syndicate content