Archive for the ‘Programming’ Category

PHP CLI increase memory limit

Saturday, October 3rd, 2009

When running a PHP script from command line interface (CLI), a higher memory limit may be required in order for the script to be successfully executed. This can be achieved using the "-d" or "--define" option in the command. According to the manual: This option allows you to set a custom ...

Insert value “0″ for primary keys with auto increment in MySQL

Sunday, July 12th, 2009

In order to insert value 0 in a field that is set as primary key for a MySQL table you need to execute the following query prior to any insert query: SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; Now you can successfully run the insert query with 0 set as value for a primary key, ...

Remove blank lines from a textarea using Prototype

Wednesday, February 18th, 2009

Here is a JavaScript function used to remove blank lines from a textarea. This snippet is using the Prototype JavaScript framework function removeBlankLines(field) { $(field).value=$(field).value.gsub(/\s+/, '\r\n'); } You can use it with "onblur" attribute:

Remove spaces from an input field with JavaScript

Wednesday, December 10th, 2008

This is a small snippet to remove the spaces from an input field using JavaScript. It can be useful when you want a value without spaces, or when you want to replace the spaces from the input field with other characters. The JavaScript code: function stripspaces(input) { input.value = input.value.replace(/\s/gi,""); ...

Disable foreign key checks in MySQL

Monday, November 24th, 2008

Disabling foreign key checks in MySQL is usefull when you are dealing with tables that use foreign keys (InnoDB engine). [caption id="attachment_105" align="alignleft" width="205" caption="MySQL logo"][/caption] You can not delete (drop) multiple tables, a parent table or a child table until you disable foreign key checks four your current database. The sql command ...