How to reconfigure keyboard on a Debian based distro

When the keyboard on a Debian based distro isn't properly configured, the configuration can be altered by using the following command:

sudo dpkg-reconfigure keyboard-configuration

dpkg-reconfigure needs to be executed as root.

Restart the system after saving the new configuration.

sudo reboot

The most common HTTP status codes

The HTTP GET command is used to request web pages from a server. The server responds with the requested document, preceded by a header. T​his header contains a status code, which is a 3 digit number which describes the request status.

An example of the first piece of the HTTP header when the browser uses the GET command to request is shown.

Troubleshoot internet connection problems with the ping command

The ping command

Ping is a command line network utility tool to test network connectivity. ​It tests the connection between a sender and a receiver node. It reports whether the receiver node responds by sending an echo request. The receiving node responds with an echo reply.

Ping simply sends a signal to another computer and waits for a response.

Set weight on a module

 * Implements hook_install().
function MY_MODULE_install() {
  // Set module weight in order to invoke module after other modules.
  ->fields(array('weight' => 100))
  ->condition('name', 'MY_MODULE')

Create table by using hook_schema

 * Implements hook_schema().
function MYMODULE_schema() {
  $schema['MYTABLE'] = array(
    'description' => 'DESCRIPTION',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      'language' => array(
        'type' => 'varchar',
        'length' => 4,
        'not null' => TRUE,

Show one image on a node teaser

Hook_process_field can be used inside template.php to render only one image on a multiple image field.

Find files with a pattern in a directory


$filenames = scandir(DIR_PATH);

$pattern = '/^PATTERN/';
$matches = array();
$matches[] = preg_grep($pattern, $filenames);


Create a simple countdown object

 * Create and process a new Countdown object.
 * @param seconds
 *  Integer
function Countdown(seconds) {
	var timer = window.setInterval(function() {
	  if (seconds === 0) {
      seconds -= 1;
	}, 1000);
	this.stop = function() {


Subscribe to RSS