Bash: How to Show Escape Sequence Colors

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

Once you figure out the escape sequence color number, you can use as follows:

続きを読む

Linux: How to Change the Timezone

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
続きを読む

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

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.

 

続きを読む

CSS: Using Font Awesome Icon for Bullet Points

li:before {
  position: absolute;
  top: 0;
  left: 0;
  font-family: 'FontAwesome';  /* Specify FontAwesome   */
  content: '\f07b';            /* This is a folder icon */
  color: #fab100;              /* Yellow                */
}

li  {
  position: relative;    /* Line breaks without this                       */
  padding-left: 20px;    /* Add a padding for the size of Fontawesome icon */
                         /* at the left of the bullet item                 */
  list-style-type: none; /* Display bullet dot(・)without this            */
}
続きを読む