Novice

Create a users table


CREATE TABLE `DATABASENAME`.`users` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  `email` VARCHAR(255) NOT NULL,
  `password` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `email_UNIQUE` (`email` ASC));

Create an unmanaged file


/**
 * Create a directory, add an unmanaged file
 * and create url from the new filepath.
 */
function _demo_file_unmanaged() {
  
  $filedir = 'public://demo';
 
  // Create a demo directory in the public dir.
  // file_prepare_directory checks, creates and sets permissions on a directory path.
  $prepared = file_prepare_directory($filedir, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY); 
  dpm('Directory prepared => ' . $prepared);
  
  // Save an unmanaged file.
  // Unmanaged means nothing is saved into the database.

Create a managed file


/**
 * Create a directory, add a managed file,
 * and create url from the new file object.
 */
function _demo_file_managed() {
 
  $filedir = 'public://demo';
 
  // Create a demo directory in the public dir.
  // file_prepare_directory checks, creates and sets permissions on a directory path.
  $prepared = file_prepare_directory($filedir, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY);
  dpm('Directory prepared => ' . $prepared);
 
  // Save a managed file.
  // Managed means a database entry is created in the file_managed table.

Remove all CSS files except current theme files

Function is placed in template.php.


/**
 * Implements hook_css_alter().
 */
function MYTHEME_css_alter(&$css) {
 
  dpm('-- Before unset --');
  dpm($css); 
 
  foreach ($css as $key => $value) {
    if ($value['group'] != CSS_THEME) {
     unset($css[$key]);
    }
  }

  dpm('-- After unset --');
  dpm($css);
   
}

CSS_THEME is a constant defined in common.inc and refers to the group of theme CSS files

Change user password using Drush

drush user-password admin --password="admin"

drush upwd admin --password="admin"

IP address classes and private IP addresses

IP address classes

Class First octet decimal range
Class A 1 to 126
Class B 128 to 191
Class C 192 to 223

Private IP addresses

Class Address Range
A 10.0.0.0 to 10.255.255.255
B 172.16.0.0 to 172.31.255.255
C 192.168.0.0 to 192.168.255.255

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 Dribbit.eu is shown.

Pages

Subscribe to RSS - Novice