All

Bash: How to Show Escape Sequence Colors

Submitted by admin on Sun, 09/04/2016 - 14:49

Create the following script and run:
vi color.sh
chmod +x color.sh
./color.sh

The bash script:
#!/bin/bash

export txtrst='\x1b[00m' # Reset

echo
for i in {0..255} ; do
printf "\x1b[00;${i}m ${i}${txtrst}"
done
echo

echo
for i in {0..255} ; do
printf "\x1b[38;05;%03dm 38;05;%03d " ${i} ${i}
if [ $(( ${i} % 8 )) -eq 7 ] ; then
echo
fi
done
echo

Tags

Linux: How to Change the Timezone

Submitted by admin on Sat, 09/03/2016 - 14:45

To adjust timezone on your Linux to Pacific Standard Time (PST/PDT), type the following on command line.
sudo mv /etc/localtime /etc/localtime.org; sudo ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

To adjust timezone on your Linux to Japanese Standard Time (JST), type the following on command line.
sudo mv /etc/localtime /etc/localtime.org; sudo ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

Tags

Perl: How to Construct "Array of Array" Data Structure

Submitted by admin on Mon, 04/18/2016 - 12:06

How can we express the data structure of "Array of Array" in Perl? Usually we create a generic array in Perl like this: @array = ('aaa', 'bbb', 'ccc'). Please take a look at the sample code shown below.
Note that a vaiable $songs starts with '$'. Also note that parenthesis is [...], not (...), even it is inside the parenthesis. This is to express a "reference" of "Array of Array". Take a look at "foreach" for accessing the reference variable.
 
#!/usr/bin/perl

Tags

Drupal 7: How to Add Bootstrap Multi-level Dropdown Submenu

Submitted by admin on Mon, 04/11/2016 - 10:57

Download and install a Bootstrap theme. Modify the following at
vi bootstrap/templates/menu/system/form-element.func.php

 
/**
* Overrides theme_form_element().
*/
function bootstrap_form_element(&$variables) {
$element = &$variables['element'];
$name = !empty($element['#name']) ? $element['#name'] : FALSE;
$type = !empty($element['#type']) ? $element['#type'] : FALSE;
$checkbox = $type && $type === 'checkbox';
$radio = $type && $type === 'radio';

Tags

Apache2: How to Setup SSL (Self-signed Certificate) on Ubuntu 16.04 TLS

Submitted by admin on Wed, 03/09/2016 - 23:07

Install openssl
==================
sudo apt-get install openssl

Create a select key
==================

e.g. server.key
# Do not use 2048 byte key - It does not work on modern browsers.
sudo openssl genrsa -out server.key 4096 # e.g. no password

Alternative: with a password (e.g. server.key)
# Do not use 2048 byte key - It does not work on modern browsers.
sudo openssl genrsa -des3 -out server.key 4096

Create a public key
==================