Outside Links collection sticky icon

Sometimes you find just the right resources that fulfill certain need and nothing much should be added to them, in those cases I will just collect them on this page and add short comment why is this so.

How to combine Git and Drush to have perfect workflow for site maintenance, information and examples are here

Setting upt perfect Git + Drush workflow, read here

Remove some crayze chars like � �

I was doing an import of data from some old DB, that had some chars like � � in them, so how to remove them and keep all the other UTF-8 chars in them?

I used iconv("UTF-8", "UTF-8//IGNORE", $vars). And it saved me from going crayze myself.

Create unique username before user_save

When using user_save to create new user, you want to have username unique, if you are importing data or just want to be safe that someone hasn't have chosen username you already have in DB (and not to get nasty error PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry...). Here is some nice code to run on that username variable before saving an object.

function _prepare_unique_user_name($orig_name) {
$name = '';
if ($orig_name) {
/* filter characters (look at user_validate_name) */

How to set your innodb_pool size, what is the size of your DB

Want to know how much is your DB big, what value to set for innodb_pool in your mysql settings? Use this function


and you will get numbers that you can use to set your my,cnf

Krumo/Devel output in watchdog

If you want to have Krumo/Devel style output in watchdog, just do this.

watchdog('debug',kprint_r($var, TRUE, NULL));

$_SERVER['HTTPS']='on' on reverse proxies - nginx and SSL

When using nginx and SSL and you have a problem that CSS or JS files are using HTTP in their urls and everything else is in HTTPS. The thing you need to do is use this magic


put it in settings.php and also if you have wordpress, do the same, put it in wp-config.php it will do the same and solve the same problem.

Attaching Extra or Pseudo Fields to any Entity in Drupal

This thing is so cool and only recently I found about it. You can create pseudo fields with your entites, most often content types. So you can make some add, edit, delete buttons or any kind of forms on your entites or nodes. And it is pretty quick and straight fwd solution.

Read more about it here

Update and insert only specific fields of your entity

TO not need to use hook_entity_presave and save whole entity try this

//Get the id of your field
$field_name = 'name_of_your_field';
$info = field_info_field($field_name);
$fields = array($info['id']);

//Execute the storage function
field_sql_storage_field_storage_write($entity_type', $entity, 'update', $fields);

Using CRUD with RESTful WS module

There is not much docs about this, but watching this video
will help you with testing your drupal site and RESTful WS and Advanced REST Client.

For more info, look this one
has all the drupal service modules in it and good examples how to use them.

One big GOTCHA is that.
X-CSRF-TOKEN is working on my localhost as

Running mysql on mamp localy

If you have more then one mysql installed on your computer and in your path is not proper MYSQL, you should run

/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

to start MAMP mysql, and to check if the one you want to use is right, run show databases;
Kind of a newbee thing, but could help for Frontenders and people not so good with AMP stacks.