Drupal - Write your first post

By default, Drupal comes with 2 content types: Page and Story.

Page
A page, similar in form to a story, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a page entry does not allow visitor comments and is not featured on the site's initial home page.
Story

Drupal - Install Drupal

Before continuing reading further, it is assumed that you already installed Apache, PHP and MySQL and you have created a database for Drupal.

  1. Download Drupal.
  2. Decompress drupal-x.x.tar.gz and copy the drupal-x.x/ directory into the root directory of Apache(e.g. C:\wamp\www)
  3. Copy the C:\wamp\www\drupal-x.x\sites\default\default.settings.php file to C:\wamp\www\drupal-x.x\sites\default\settings.php.

Drupal - Install and configure Apache, PHP and MySQL for Drupal

Install Apache, PHP and MySQL

Before installing Drupal, you need to install Apache, PHP and MySQL. The easiest way to install them is to use an all-in-one installer that will install all 3 softwares. I used WampServer 2.0-h. Please note that Drupal 6.x doesn't support PHP 5.3.x. Therefore, choose carefully the version of WampServer that you download. As of version 2.0-i, WampServer includes PHP 5.3.0.

  1. Here are the steps to install WampServer.

Bash - Decompress all rar files and delete them if ran successfully

#!/bin/bash
# Description: Decompress all *.rar files and delete them if ran successfully.
#              Errors are logged in err.log.
# Author: Xuan Ngo
# Usage: sh thisScript.sh
# Warning: It doesn't handle multiple part rar files.
 
# Change $IFS so that it handles filename with spaces.
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
 
 
ERROR_LOG=err.log
 
for filename in $(ls *.rar)
do
 
  # Extract and send error text in ${ERROR_LOG}
  rar x -y "${filename}" 2> ${ERROR_LOG}
  ERROR_LOG_SIZE=`ls -sh ${ERROR_LOG} | gawk '{print $1}'`
 
  # If there is no error.

Debian - Automatically take 8 screenshots of a video using mplayer

#!/bin/bash
# Description: Automatically take 8 screenshots of a video using mplayer
#              Screenshots are saved in 01.png, 02.png, ..., 08.png
# Author: Xuan Ngo
# Usage: ./thisScript.sh nameOfVideo
 
filename="$1"
 
# For some unknown reason, the last screenshot is not generated by mplayer.
# Therefore, always add 1 more to the total of screenshots that you want.
NUM_OF_SCREENSHOTS=9
 
# Get the total video length in seconds.
#  Use mplayer to display the info of the video and then get the value of ID_LENGTH, the total number of seconds of the video.

Octave - Multiple functions on 1 graph

octave-3.2.4.exe:1> function y = a(x)
> y=3*x;
> endfunction
octave-3.2.4.exe:2> function y = b(x)
> y=5*x;
> endfunction
octave-3.2.4.exe:3> a(3)
ans =  9
octave-3.2.4.exe:4> b(3)
ans =  15
octave-3.2.4.exe:5> x=1:1:15;
octave-3.2.4.exe:6> plot( x, a(x), b(x) )
octave-3.2.4.exe:7>
octave-3.2.4.exe:7> title("Multiple functions on 1 graph")
octave-3.2.4.exe:8> xlabel("x")
octave-3.2.4.exe:9> ylabel("y")
octave-3.2.4.exe:10> grid

Octave

Variables

octave-3.2.4.exe:5> x=2;
octave-3.2.4.exe:6> y=3;
octave-3.2.4.exe:7> x*y
ans =  6

Vectors

octave-3.2.4.exe:15> v=[1 2 3]
v =
 
   1   2   3
 
octave-3.2.4.exe:16> v*2
ans =
 
   2   4   6

Matrix

octave-3.2.4.exe:13> m=[1 2 3; 3 4 5; 6 7 8]
m =
 
   1   2   3
   3   4   5
   6   7   8
 
octave-3.2.4.exe:14> m*3
ans =
 
    3    6    9
    9   12   15
   18   21   24

User-defined functions

 

Debian - Cronjob

  1. Check if cron service is running:
    ps -el | grep cron
    # It should return a line with cron. Otherwise, Cron service is not running.
     
    # or
    #ls -lut /etc/init.d/cron
    # It shows the last time /etc/init.d/cron was executed or read.
  2. If Cron service is not running on Debian, you have to run the following command:
    /etc/init.d/cron start
  3. To make sure that the Cron service is still running after the reboot, run the following command:
     

Java - Javadoc example

package org.javadoc.tutorial;
 
import java.lang.String;
 
/**
 * Example of what can be done with javadoc.
 * 
 * This is a longer description that can span into
 * multiple lines.
 * 
 * <ul>
 *  <li>{@literal {@value package.class#variable}} shows the value of a public variable 
 *        but it can't show a private variable.
 *  <li>{@literal {@link package.class#variableOrMethod}} links to the variable or method 
 *        but it can't link a private variable or method.
 * </ul>
 * 
 * @author Xuan Ngo
 * @version 1.0
 */
public class Person
{

Varia - Audacity

Issue:Can't hear the playback but was able to hear the exported mp3 using mplayer
Solution: Go to Edit->Preferences, select the default Alsa playback device from Audio I/O section.

Syndicate content