Saturday, March 31, 2012

Make a videoconference call in skype

You can make internet calls for free with Skype. To sign up a Skype account:

For two people, it is straightforward, you can share video and audio by add  a contact and click call.

To make a video-conference call in Skype for more than two people:

1. First you need to create a new group,
click Contacts > Create New Group
2. Add people to the group
3. call group

For free Skype account, you can only have audio for more than 2 people.
You need to upgrade account to premium for video sharing for more than 2 people.

Thursday, March 29, 2012

Jiansen Lu Social Community - Public Forum - computing - PHP, check if a string contains a substring

br />
This is a test.
Directly share a post in my yuku forum. Yes, it works.

Jiansen Lu Social Community - Public Forum - computing - PHP, check if a string contains a substring

Wednesday, March 28, 2012

HTML, Force to display other languages in content

In Firefox, we can go to menu and select Web developer and  Character decoding and decode your website.  We can also  hard code in the HTML code to force the website to display the language we want. For example, I want to display Chinese language gb2312, I insert the following code in my HTML between <head> and </head>:

    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
Sometimes it may not work well under PHP, you may need to add an extra line in PHP as:
 header ("Content-type: gb2312");

Monday, March 26, 2012

Share file between Remote desktop

1) Click Start in Windows, type  mstsc in sear box
2) Remote desktop pop up
3) Click options, and select Local Resources
4)  Click More under Local devices and resources
5)  Click Drives, select the drive you want to share, I prefer to plug in an external drive to share.
6)  In Remote desktop, click My computer, you can see your local drive under Other,
7) Copy and paste files to that drive as you  want.

Connect to remote desktop in Windows

Connect to remote desktop in Windows 7:
1) Click Start menu
2) Type mstsc in search box, return, Remote desktop connection pop-up
3) Type your remote desktop IP, user name and password

To  allow your computer become a remote desktop:
1) Go to Control Panel ->System and Security ->System
2) Click Remote Setting in left panel
3) Select Allow connections from computers...

Add social networking tools in your website

You may need  to add social networking tools, such as Facebook, twitter, Google + button in your website for your website popularity and e-marketing.

To get  facebook like embed code:

To get twitter and follow twitter embed code

To get Google +1 button embed code

Below is the example of the code, replace my url to yours.

 <!--Facebook like button, (div is the style for me, you may not need it): -->
 <div style="float:left;margin-top:-0.2em;margin-left:2em;">
            <iframe src="" scrolling="no" frameborder="0"
                style="border:none; width:300px; height:80px">

<!--Twitter button: -->
 <div style="float:left;margin-top:-0.2em;margin-left:2em;">
        <a href="" class="twitter-share-button" data-counturl="" data-url="" data-text=" " data-count="horizontal" data-via="CanHealth">Tweet</a>
        <script type="text/javascript" src=""></script>

<!--Follow  in Twitter: -->
 <div style="float:left;margin-top:-0.2em;margin-left:-18em;">
    <a href="" class="twitter-follow-button" data-show-count="false">Follow @jiansenlu</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);;js.src="//";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

<!--Google +1 Button: -->
 <!-- Place this tag where you want the +1 button to render -->
<g:plusone href=""></g:plusone>

<!-- Place this render call where appropriate -->
<script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = '';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
The result: (Google +1 code works fine for my other websites, but some problem with my blogger)

Why 1TB external disk only showing 931GB in Windows?

I bought a 1TB external USB drive, but it only shows 931 GB in Windows 7.
This is due to that  drive manufacturer count TB in different way from Windows.
For Drive manufacturer:
1TB=1,000,000,000,000 bytes
For Windows:
1KB=1024 bytes
i.e 1GB=1073741824 Bytes
931GB= 1,000,000,000,000 bytes

So drive manufactures do not cheat us, but misleading. The definition in Windows is closer to the definition in computer science. 

Friday, March 23, 2012

PHP, refresh button

When you update your site layout using   PHP form, you may need to refresh browsers to see the effect. You can add a refresh button, or include in the form submission, i.e when you submit the form, the website refreshes too.

Below is the code for refresh the web page, PHP function  header("Refresh: $sec; url=$page"); is use for refreshing.

<form name="revisons" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" class="input-button" name="refresh" value="refresh" /></td>

 if (isset($_POST["refresh"])) {
$page = $_SERVER['PHP_SELF'];
$sec = "1";
//refresh in 1 second.
header("Refresh: $sec; url=$page");

Thursday, March 22, 2012

JSColor: HTML color picker

You may want to show color code via HTML color picker in a HTML form. You can use JSColor, a Javascript and HTML color picker.  You can download JSColor from:

After you download JSColor Javascript, you can call jscolor.js
<script type="text/javascript" src="jscolor/jscolor.js"></script>

Depending on the styles you want you can class="color" in your input tag, example:

<p> This field can be left empty: <input class="color {required:false}">
<p> This field accepts any value: <input class="color {adjust:false}">
<p> Hash symbol:                  <input class="color {hash:true}">
<p> Hash symbol, lowercase:       <input class="color {hash:true,caps:false}">

Try JSColor picker below via click on each box and select color:

This field can be left empty:
This field accepts any value:
Hash symbol:
Hash symbol, lowercase:

Spell Check in FireFox

Google site editor does not have spell check. In Firefox, there is spell checker built in. But it does not work for me when I edited my Google sites.

According to Firefox spell checker statement:
 "Firefox automatically checks the spelling of words that you enter in text boxes containing more than one line. As soon as you finish typing a word, it is checked against the words in the installed dictionary."

I realized that maybe my dictionary is empty.
So I installed English United States (en-US) spell-checking dictionary in Firefox from :

 After I restart the Firefox, the spell checker works fine during my on line editing. To enable or disable spell checker, right click mouse and check or un-check spell checker.

Wednesday, March 21, 2012

MySQL datatime type and timestamp

 When creating a time type column in MYSQL tables, there are 3 choices:
DATE: only date, format:'YYYY-MM-DD'
DATETIME, and TIMESTAMP: data and time, format 'YYYY-MM-DD HH:MM:SS'
There are 3 major MySQL time functions:

NOW()            CURDATE() CURTIME()
    2012-03-11 11:45:34

Below is the example to insert current time in MySQL using MYSQL NOW() function.

Create theme table in cnsh_lms database
CREATE TABLE cnsh_lms.theme (
  `theme_id` mediumint(8) unsigned NOT NULL auto_increment,
   `revision` mediumint(8) unsigned DEFAULT 0,
  `main_width` varchar(255) NOT NULL,
   `page_width` varchar(255) NOT NULL,
    `author` varchar(255) DEFAULT NULL,  
   `submission_date` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`theme_id`)

Where  submission_date is the time format.

 INSERT into  cnsh_lms.theme VALUES(0, 1, '100%', '1100px', 'admin', NOW() );

NOW() function is the current time

SELECT * FROM cnsh_lms.theme t;

2, 1, '100%', '1100px', 'admin', '2012-03-21 09:58:20'

2012-03-21 09:58:20 is the time I inserted using NOW() function
In PHP, we have similar function:
 $mysql_date = date('Y-m-d H:i:s');
 return something like:2012-03-21 10:19:24  

Tuesday, March 20, 2012

PHP, change the theme of a website

The website theme is defined in theme.css. I want administrator can change the them after login the website. I copy theme.css to theme_template.css. and replace
 width: main_width;    
The following code reads  theme_template.css file,  changes main_width  according to the  input value from the form, then writes the output to theme.css. After you submit the form, the website them is changed.

<form method="post" action="<?php echo $PHP_SELF;?>">
main_width:<input type="text" size="12" maxlength="12" name="main_width"  >:<br />
page_width:<input type="text" size="12" maxlength="36" name="page_width">:<br />
  <input type="submit" name="submit" value="Submit Form"><br>

$inputfile = $_SERVER['DOCUMENT_ROOT'].'/_css/theme_template.css';
$outputfile = $_SERVER['DOCUMENT_ROOT'].'/_css/theme.css';
if (isset($_POST['submit'])) {
  $main_width = $_POST['main_width'];
  $file_contents = file_get_contents($inputfile);
  $file_contents = str_replace("main_width",$main_width,$file_contents);

PHP basic function: $_GET

 $_GET allows values to be read in through the page URL (e.g. index.php?name=jiansen) or collect values in a form.
For example, in  index.php?name=jiansen
 $myname =$_GET['name'];
assign  the value jiansen to $myname
Use with form using $_GET:
<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
   <input type="text" name="name"><br>
   <input type="submit" name="submit" value="Submit Form"><br>
if(isset($myname)) echo 'My name is '.$myname;
 The difference between $_REQUEST, $_GET and $_POST
$_GET retrieves variables from the query string, or your URL.
$_POST retrieves variables from a POST method, such as (generally) forms.
$_REQUEST is a merging of $_GET and $_POST where $_POST overrides $_GET. Good to use $_REQUEST on self referential forms for validations.

Video: PHP Basics: $_GET

Monday, March 19, 2012

Embed Google Calendar in your blog

You may need to embed Google Calendar in your blog. First you need to make your calendar public. Then following the steps as below:
1) Log in your Google account, click Calendar at the top.
2) On the right panel,  click the small down arrow of My Calendar under "My Calendars"
3)  Click Calendar setting
4) In the  'Embed This Calendar" column, you can see the embed code.
5) Copy the embed code in your blog in the HTML mode.
6) Done.

Friday, March 16, 2012

MySQL auto-increment fail

I set the index of MySQL table as auto_increment. But auto_increment failed after "INSERT INTO".
Finally I found a solution.

The index of MySQL Table edu_course_cats is created using auto_increment:

DROP TABLE IF EXISTS `cesei_new1`.`edu_course_cats`;
CREATE TABLE  `cesei_new1`.`edu_course_cats` (
  `cat_id` mediumint(8) unsigned NOT NULL auto_increment,
  `cat_name` varchar(100) NOT NULL default '',
  `cat_parent` mediumint(8) unsigned NOT NULL default '0',
  `theme` varchar(30) NOT NULL default '',
  `dept_id` mediumint(8) unsigned NOT NULL default '0',
  `approved` tinyint(4) NOT NULL default '0',
  `member_id` mediumint(8) unsigned NOT NULL default '0',
  PRIMARY KEY  (`cat_id`)

In MySQL, when I used:
$sql = "INSERT INTO edu_course_cats VALUES ('', '$cat_name', $cat_parent_id, '$cat_theme', $dept_id, $approved, $mem_id)";
I got the error message : " Incorrect integer value"

There are two ways to fix this:
Method 1, using
$sql = "INSERT INTO edu_course_cats VALUES (NULL, '$cat_name', $cat_parent_id, '$cat_theme', $dept_id, $approved, $mem_id)";

Method 2, Set the MySQL mode not so strict
in my.ini in MYSQL server directory, line 87 change

Or use  MySQL workbench
Server  administration->Options File under configuration, select Advanced tab, check box
sql-mode, change

Then restart the MySQL server.
You may need to change php.ini permission to full control for your account via right click mouse on the file and select properties.

Wednesday, March 14, 2012

PHP script, to get maximum upload file size variable from php.ini

 PHP maximum upload file size is determined by three variables in php.ini
 ; Maximum amount of memory a script may consume (128MB)
memory_limit = 128M
 ; Maximum size of POST data that PHP will accept.
post_max_size = 100M
;Maximum allowed size for uploaded files.
 upload_max_filesize = 100M

To access these variables in PHP script:
$max_upload = (int)(ini_get('upload_max_filesize'));
$max_post = (int)(ini_get('post_max_size'));
$memory_limit = (int)(ini_get('memory_limit'));
$upload_mb = min($max_upload, $max_post, $memory_limit);

  Here $upload_mb is the minimum of these three variables, i.e the maximum file size you can upload.

Note: some directories you may need to modify in php.ini
; Directory in which the loadable extensions (modules) reside.
; extension_dir = "./"
; On windows:
; extension_dir = "ext"
extension_dir = "C:\php\ext"

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =
upload_tmp_dir ="C:\LMS\file_uploads"

;session.save_path defines the argument which is passed to the save handler. If you choose the ;default files handler, this is the path where the files are created.

Sunday, March 11, 2012

How to create a narrated PowerPoint file uploadable to YouTube.

To make a narrated PowerPoint file video to YouTube:

1) You need to save the PowerPoint file to JPEG files.
2)  Import these JPEG files to Windows live movie maker. To start Windows live movie maker in
Windows 7, go to start menu, click Windows  Live, select Windows live movie maker.
3) Click each JPEG file and drag it to story board, click "start narration" and speak using your microphone, and click "stop narration" when it is done.
4) In final sharing, you can upload it to YouTube
Video: PowerPoint to YouTube using Windows Movie Maker

Free midi to mp3 file converter

If you have midi music files, you may need midi to mp3 file converter softeware.

A lot of video software such as Windows live movie maker, Camtasia Studio, DVD photo slide maker
can not import midi music files as background music. They only accept mp3, wav and WMA music file formats.  You need to convert midi format to mp3 file format.

You can download  Free MIDI to MP3 Converter from:

There are also some online free midi to mp3 converters:

Saturday, March 10, 2012

PHP, create a thumb image

In PHP, you may need to create a thumb image from an existing  image.  This is widely used in PHP photo album creation. Below is the explanation of how to create a thumb image from existing image in PHP.

1) First we need to use PHP getimagesize function  to get the image type.
See below for the function getimagesize return vales:
list($width$height$type$attr) = getimagesize("img/flag.jpg");
The third element of  getimagesize() return the image type. You can use 
to get the image type.

2) Then you can use  PHP built in function imagecreatetruecolor()  to create an 
image identifier representing a black image of the specified size.

3) And  use PHP built in function imagecopyresized() to copy a image and resize it.

4) And  you  can use PHP function imagejpeg() to create a JPEG file from the
 given image. similar function: 
Example of function  imagejpeg:
// Create a blank image and add some text
 $im imagecreatetruecolor(12020);
 $text_color imagecolorallocate($im2331491);
 imagestring($im155,  'A Simple Text String'$text_color);// Save the image as 'simpletext.jpg' 
imagejpeg($im'simpletext.jpg');// Free up memoryimagedestroy($im);
5) Finally, below is the  PHP function code to make thumb jpeg file from 
a source image of format gif, jpeg or png:

function create_thumb($srcfile,$dest,$desired_width)

  /* read the source image */
 $x = @getimagesize($srcfile); 
  switch($x[2]) { 
   case 1: 
        $source_image = imagecreatefromgif($srcfile); 
   case 2: 
        $source_image = imagecreatefromjpeg($srcfile);
   case 3: 
        $source_image = imagecreatefrompng($srcfile);  
        echo "file is not a valid image file.<br>"; 
  $width = imagesx($source_image);
  $height = imagesy($source_image);
  /* find the "desired height" of this thumbnail, relative to the desired width  */
  $desired_height = floor($height*($desired_width/$width));
  /* create a new, "virtual" image */
  $virtual_image = imagecreatetruecolor($desired_width,$desired_height);
  /* copy source image at a resized size */ 
  /* create the physical thumbnail image to its destination */

Display multiple youtube videos in one frame using iframe

You  may not want to embed a lot of  YouTube videos in one post using YouTube embed function. You can use iframe  to display multiple YouTube videos in a frame to save space.
Below is the same code, result displayed after the code:

<table align="center" border="1" cellpadding="0" cellspacing="0" style="background: #52C9CB; border: #64f1f3 1px solid; color: #555555; text-align: center; width: 600px;"><tbody>
<td><a href="" target="frame138">Part 1</a></td>
<td><a href="" target="frame138">Part 2</a></td>
<td><a href="" target="frame138">Part 3</a></td>
<td><a href="" target="frame138">Part 4</a></td>
<td><a href="" target="frame138">Part 5</a></td>
 <td><a href="" target="frame138">Part 6</a>
<iframe height="600" name="frame138" src="" width="100%"></iframe>

1. YouTube videos address format  should be similar to

2.  Target name and iframe  name (here is frame138) should be the same in one post, but should be different for different posts.

Below is the result: (Click part 1 to part 6, display  in the same frame)
Video:PHP Tutorials: Register & Login: User login
Part of the 'Register & Login' Project from phpcademy. This tutorials walks you through how to process a username and password based login against details found in a database, set a session, and process a logout function. Phpcademy Official website:

Part 1 Part 2 Part 3 Part 4 Part 5 Part 6

Wednesday, March 7, 2012

Create your own music using cgMusic

You may want some music in your photo background, or post some music in your photo album in YouTube. But you do not want to violate the copyright. You can use cgMusic to create midi music and export as a midi file.  You do not have to be  a musician. The computer does most of the job. The detail introduction and download of cgMusic software can be found:

Below is the  music I produce called jiansen blue dream: link here

SugarSync - online backup and synchronize

SugarSync website:

The first 5GB is free. After install sugarsync, following the instruction, register an account, sign in your email to activate your account,  and select the folder you want to backup. The folder is synchronized in the storage in online cloud.  You can access to this folder where there is an Internet connection.

You can also can upload the files and access them via mobile phone. You can upload some files or put them in synchronized directory from your office and access them at home,  and vice verse.

Download google site to local computer using HTTrack

Google site has only copy function, but no download function to local computer. Using HTTtrack, you can not only download your Google sites recursively all directories to your local computer., but also any other websites.

 HTTrack can be downloaded from:

Below is the introduction of httrack software from
HTTrack is a free (GPL, libre/free software) and easy-to-use offline browser utility.
It allows you to download a World Wide Web site from the Internet to a local directory, building recursively all directories, getting HTML, images, and other files from the server to your computer. HTTrack arranges the original site's relative link-structure. Simply open a page of the "mirrored" website in your browser, and you can browse the site from link to link, as if you were viewing it online. HTTrack can also update an existing mirrored site, and resume interrupted downloads. HTTrack is fully configurable, and has an integrated help system.
WinHTTrack is the Windows 2000/XP/Vista/Seven release of HTTrack, and WebHTTrack the Linux/Unix/BSD release. "

Running HTTrack is straightforward. After installing HTTrack.  you can run HTTrack. Create a project name  and base directory, enter the website you want to download. The website will be downloaded to the project name directory under base directory.

Monday, March 5, 2012

espeak, free text to speech converter

espeak can be downloaded from

 Text to Speech engine for English and many other languages. Compact size with clear but artificial pronunciation. Available as a command-line program with many options, a shared library for Linux, and a Windows SAPI5 version.

The final speech can be saved as .wav file

How to change microphone volume or mute mic in Windows 7

In Windows 7, right click the volume icon at the bottom right of the task bar and there it is, Volume Control Options.  Click Recording devices,  you can see microphone,  double click microphone,
a Window pop up. Select level and change volume level.

Add facebook like in your blogger sidebar

To add facebook like in your blogger sidebar, go to layout-> add gadget-> add HTML/JavaScript:
and copy the following JavaScript code and place,  then replace to your site

<iframe src=";layout=button_count&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowtransparency="true" style="border:none; overflow:hidden; width:450px; height:60px"></iframe>
    <fb:like href="" layout="standard" show_faces="true" width="450" action="like" colorscheme="light" /></fb:like>

After a user clicks facebook like, the link of your blog will be shown in his facebook wall.

PHP, to avoid type login information lost

To avoid users to retype login infomation such as full name, you can change
<input type='text' name='fullname'>
<input type='text' name='fullname' vaule='<?php echo $fullname>'>

Sunday, March 4, 2012

Link youtube account to my Google account

I have a YouTube account created on 2010, which is linked to a Gmail account. But I most used Gmail account is another one. I try to link that YouTube account to this Gmail. I read  several posts and I realize only the YouTube account prior to May 2009 can be unlinked and link to new Gmail account, reference:

So I have to use two YouTube accounts.  As my current Gmail account is related to my AdSense, I plan to upload videos in this account.

Create Photo Slide show and upload to youtube

You may want to create a slideshow and upload to youtube.   I have tried Windows live Movie maker, which comes with Windows 7, and Camtasia Studio.  Recently I tried DVD Photo Slideshow trial version(download the DVD Photo Slideshow trial version. The detail can be found:

For the trial version, the last page of your slide show has DVD photo slide show web address.
To produce slideshow is quite straightforward, collect your photos and insert to slide, choose your style and music, and finally choose to upload to youtube. After upload to yourtube, you can change to other youtube free music in edit function.

Below is the photo slide show I produced using DVD Photo Slideshow trial version

Saturday, March 3, 2012

Setup Brother DCP-7065DN printer
After using Brother HL-2140 laser printer for 2 years, the toner run out, The toner is TN-330 and it costs around $54 in future shop. But the printer price was only $70. It only has printing function and non-duplex.

I decided to buy a new laser printer Brother DCP-7065DN, which has copy, scan and duplex copy and printing function. The original price is $199, but now it is only $119 in Staples. Note: there is no USB cable inside. But HL-2140 has one.

The toner is demo version (only 700 pages). You can buy TN-420 standard yield and TN-450 high yield (around 2600 pages) when you replace your toner.

The installation is straight forward. Connect USB cable and wired network cable. Insert CD to install BROTHER MFL-PRO program. For my local desktop, I choose install from USB cable. For my wireless laptop, I choose install from wired network. During installation, do not let the printer sleep or the installation repeats several times and finally fail due to the printer not detected.

After successful installation, when you press scan button and press OK button, you can choose scan to email and scan to file. You can see local PC and laptop name in the list. As I am a Gmail user, I do not want to set default email in my computer which requires outlook setup. So I choose scan to file for my wireless laptop. It works fine. The scanned file is shown in my laptop,

Friday, March 2, 2012

CSS text-decoration

Using style text-decoration, you can put underline, overline, line-through, blink or none in your links. You can also use this style  for any text and header..
<A STYLE="text-decoration:none" HREF="">
result: Google
<A STYLE="text-decoration:underline" HREF="">
result:  Google
<A STYLE="text-decoration:overline" HREF="">
result:  Google
 <A STYLE="text-decoration:line-through" HREF="">

 <A STYLE="text-decoration:blink" HREF="">
result: Google

Thursday, March 1, 2012

EXCEL, count number of same instances

For example, in A column of EXCEL, there are 5 rows: high, high,high,high, low,low, I want to find how many high and low. In column A6, enter the following function: =COUNTIF(A1:A5,"high"), You will get the number of  instance of  "high" 3.

When you click fx at the top menu of EXCEL2010, you can not see COUNTIF.  You only see SUM, IF, AVERAGE, HYPERLINK,COUNT......