Wednesday, February 29, 2012

MySQl workbench, database backup using Windows scheduler

>br>
MySQL workbench does not support  scheduled backups.

Below I used Windows scheduler to backup my MySQL database schs_lms and schs_research_projects.

A) Create a directory for MYSQL backup dumping:  d:\mysql_dump\. 
I install MySQL in:
c:\Program Files (x86)\MySQL\MySQL Workbench CE 5.2.37

B) Create a bat file c:\bat_dir\mysql_backup.bat as below,  note: carat character ("^" ; shift-6) as a line extension character (continue line) in DOS batch files.
set DATET=%date:~-4%_%date:~7,2%
"c:\Program Files (x86)\MySQL\MySQL Workbench CE 5.2.37\mysqldump" --host="localhost" ^
  --user="root" --password="YOUR_PASSWORD" schs_lms > ^
 "d:\mysql_dump\"backup_%DATET%_schs_lms.sql 
"c:\Program Files (x86)\MySQL\MySQL Workbench CE 5.2.37\mysqldump" --host="localhost" ^
  --user="root" --password="YOUR_PASSWORD" schs_research_projects > ^
    "d:\mysql_dump\"backup_%DATET%_schs_research_projects.sql  
pause

C) Right click mouse and select run as Administrator to test this command.

D) Run in Windows Scheduler, the detail  is as below:
In Windows 2008 Server or other Windows system:
Start->Administrative tools ->Task Scheduler, under action, click a basic task, 
following the instruction step by step. Below is my case: 
1) my task name: scfhs db backup, 
2) Next: backup daily, 
3) next: afternoon 2:29:42 pm, 
4) next: action: start a program
browse the script location: C:\bat_dir\mysql_backup.bat, 
5) select open properties, a window pops up, select Run whether the user is logged on or not.

Monday, February 27, 2012

Synchronize in fireftp



In fireftp, Goto "tools", click  options, Click Downloads/Uploads at the top menu,
Select
Automatic Mode.
use compress,
keep timestamps in sync
check integrity of file transfer

Select the local directory you want to synchronize, which at the first column of the local site;
Select the remote directory you want to synchronize, which at the first column of the remote site;

Click tools at the top menu, select " Sync directories and su-directories"
After comparing two directories (it may take a few minutes), a new window pop up.
You can see Sync Directories

For missing local files, you can select "Download", "delete",  "Do Noting";
For newer local files, you can select "Download", "upload", "Do Nothing",
After your selection, click "Sync" button, synchronize between local and remote directories starts.

Saturday, February 25, 2012

Use LG TV as a computer monitior



I have a  LG 42'' LED TV. I used it as a computer monitor too. I bought a VGA cable ($20) connect my laptop and TV, where most of laptops have VGA connectors. HDMI cable is fine too if your laptop has a HDMI port. My both HP and Toshiba Laptops have laptop ports.  In  Windows 7, go to start->Control Panel->Appearance->Display setting, you can choose using display both or using only TV as a monitor. You can also adjust screen resolution.  In TV, go to menu and change input to RGB if you use VGA cable.

I also bought an audio cable ($10) to connect the earphone in the laptop to "audio in" in TV. So the TV speakers will play the sound. I also bought a wireless keyboard ($30) to control my laptop.  With these, I am able to play YouTube videos  and create posts in my large HD TV in my sofa.

Thursday, February 23, 2012

rsync in Windows, hidden files



I used rsync.exe from DeltaCopy for incremental backup to remote server in Windows. DeltaCopy can be downloaded from
http://www.aboutmyip.com/AboutMyXApp/DeltaCopy.jsp

Several issue need to fix
1) I used  command line:
rsync.exe  -v -rlt -z --chmod=a=rw,Da+x --delete "/cygdrive/C/Users/jiansen/Desktop/CAS/jiansen_dir/www_SCHS/" "//192.168.1.73/jiansen/JIANSEN-PC/www_SCHS/"
The final files are  hidden in Windows.
This is because  -x in cygwin equals to hidden files in Windows
# ls -ls *.txt
0 -rwxrw-rwx 1 user everyone 0 Nov 27 23:27 hidden.txt*
0 -rwxrw-rw- 1 user everyone 0 Nov 27 23:27 visible.txt*
You can find more information
http://forum.qnap.com/viewtopic.php?f=189&t=37351&hilit=QNAP+ReadyNAS+rsync

2) To view hidden files in Windows (but I prefer not to  have hidden files)
just click on the Organize button at the top menu bar in any folder, and then select “Folder and Search Options” from the menu.
and select "show hidden files and folders"

3) The new command:
rsync.exe  -v -rlt  "//Jiansen-PC/Users/jiansen/Desktop/CAS/jiansen_dir/www_SCHS/" "//192.168.1.73/jiansen/JIANSEN-PC/www_SCHS/"
This command is for the final destination file attribute not hidden.
You may need to install cygwin
http://www.cygwin.com/

Tuesday, February 21, 2012

CSS design image gallery


To design an image gallery, first create img1 class:
 div.img img1
{
  margin: 2px;
  height: auto;
  width: auto;
  float: left;
  text-align: center;
  display: inline;
  border: 1px solid #ffffff;
}
 Note: div.img img1 {} applies style to an img element which is a descendant of a div element with the class "img1", for the example below, it is applied to <img src="/_img/banner_........
To add hover effect on images, define hightlightimg class to change image border color:
 .hightlightimg:hover img{border: 1px solid #0000ff;}

Finally, put 4 images side by side:
    <div  class="img1">
<a class="hightlightimg"><img src="/_img/banner_5.png"  width="270" height="130" /></a>
 <a class="hightlightimg"><img src="/_img/banner_4.png"  width="270" height="130" /></a>
<a class="hightlightimg"><img src="/_img/banner_3.png"  width="270" height="130" /></a>
 <a class="hightlightimg"> <img src="/_img/banner_2.png" width="270" height="130" /></a>
</div>

Reference:
http://www.w3schools.com/css/css_image_gallery.asp

Monday, February 20, 2012

Incremental backup tools in Windows 7


DeltaCopy is an open source, fast incremental backup program.
 Download GNU software DeltaCopy from:
http://www.aboutmyip.com/AboutMyXApp/DeltaCopy.jsp
I also need to install cygwin
http://www.cygwin.com/

Installing DeltaCopy server and client is straight forward. But I still have several issues:
1) When I ran "Add file" in Deltacopy client; The error message:

Executing: rsync.exe  -v -rlt -z --chmod=a=rw,Da+x --delete "/cygdrive/C/Users/jiansen/Documents/Leonie.doc" "192.168.1.47::test1/Documents/Leonie.doc"
sending incremental file list

rsync: change_dir#3 "Documents" (in test1) failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at /home/lapo/packaging/rsync-3.0.4-1/src/rsync-3.0.4/main.c(614) [receiver=3.0.4]

rsync: connection unexpectedly closed (5 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /home/lapo/packaging/rsync-3.0.4-1/src/rsync-3.0.4/io.c(632) [sender=3.0.4]

The reason is I used the file Leonie.doc  from Documents directory and the server did not have documents directory (whatever directory missing) and will not create documents directory due to that I used "Add files" instead of "Add folders".
The fix method is:
Create Documents directory in server directory or define a new Virtual directory in Deltacopy server including Documents directory

"Add folder" in client is fine.

2) There is a problem for mapped network file backup, which is explained in:
http://www.aboutmyip.com/AboutMyXApp/DisplayFAQ.do?fid=29

I have to backup them manually using a command line:
rsync.exe  -v -rlt -z --chmod=a=rw,Da+x --delete "/cygdrive/C/Users/jiansen/Desktop/CAS/jiansen_dir/www_SCHS/" "/cygdrive/z/JIANSEN-PC/www_SCHS/"

or use IP or UNC (Universal Name Convention) name:
rsync.exe  -v -rlt -z --chmod=a=rw,Da+x --delete "/cygdrive/C/Users/jiansen/Desktop/CAS/jiansen_dir/www_SCHS/" "//192.168.1.73/jiansen/JIANSEN-PC/www_SCHS/"

Another backup software is Syncrify, which can be downloaded:
http://web.synametrics.com/Syncrify.htm
You may need to pay except personal usage.

Thursday, February 16, 2012

Apache configuration - stop hotlinks


You may not want other website to embed images or movie from your website. For example:
 http://mydomain.com/image.jpg is allowed, but
 <img src="http://mydomain.com/image.jpg" height="350" width="200"> is not allowed, so called hotlinks.

To prevent hotlinks, you can add the following lines in httpd.conf: (replace http://mydomain.com to your website)
LoadModule rewrite_module modules/mod_rewrite.so
<IfModule rewrite_module>
      RewriteEngine On
      RewriteCond %{HTTP_REFERER} !^$
      RewriteCond %{HTTP_REFERER} !^http://localhost/.*$ [NC]     
      RewriteCond %{HTTP_REFERER} !^http://mydomain.com/.*$ [NC]
      RewriteRule .*\.(jpe?g|png|gif|bmp|swf|flv) - [NC,F,L]
</IfModule>   

These  conditions allow linking only  from your own site http://mydomain.com for files end with
jpeg, png, gif, bmp, swf and flv.  The rewrite_module  is used. The links are written in regular expression.  Some explanation:
1. NC (no case, case insensitive)

2. [F] (force URL to be Forbidden)
Forces the current URL to be forbidden. Send the HTTP response, 403 (FORBIDDEN).

3. [L] (last rule)
Forces the rewriting processing to stop here and don't apply any more rewriting rules.
To check if your images can be  hotlinked, go to the link below:
http://altlab.com/hotlinkchecker.php

Apache configuration-default index page


You may wander which file to display in your Apache server when people
click your website  http://yourdomain.com.

It depends on how you configure your Apache server. In your httpd.conf, you need to add
lines:
       <IfModule dir_module>
               DirectoryIndex index.php  index.html
 </IfModule>
The Apache web server will first look for index.php file first and then index.html as the
order above when people click   your website such as http://yourdomain.com.

Tuesday, February 14, 2012

PHP, download thread safe or non thread safe?


When you download PHP 5.3.10 from:
 http://windows.php.net/download/

You can see  "VC9 x86 Non Thread Safe" and "VC9 x86 Thread Safe".
Which one to use?
 From http://www.sitepoint.com/install-php53-windows/, the advice is:

"A Thread Safe version should be used if you install PHP as an Apache module. The Non Thread Safe version should be used if you install PHP as a CGI binary."

The reason is that  when we use Apache http server, we normally use mod-php. The PHP is loaded into Apache as threads. So we need thread safe  PHP  for Apache.

Monday, February 13, 2012

Free gnu sftp server filezila ftp server


 Filezila ftp server is an open source GNU ftp server. You can download it from:
 http://filezilla-project.org/download.php?type=server 

It is easy to setup.  In edit menu after connect to server locally (127.0.0.1), create a  user and password, and  create share directory D: drive. You have  the option to use SSL. To remotely connect to the server, you can use Filezila client or Fireftp etc.

MySQL Workbench



 The MySQL Installer 5.5 package includes MySQL Server 5.5 GA, MySQL Workbench 5.2 G and MySQL Connectors (.Net / ODBC / Java / C / C++) GA.  The package can be downloaded for windows in:
http://dev.mysql.com/tech-resources/articles/mysql-installer-for-windows.html

With MySQL Workbench, you  do not need to install   mysql-gui-tools separately. 
When you open MySQL WorkBench, you can clearly see three parts: SQL development, Data Modeling, Server Administration.  SQL Development replaces previous MySQL Query Browser.  The third part Server Administration in MySQLWorkBench replaces previous MySQL Administrator from MYSQL GUI tools.

To add a new  user in database in MySQL WorkBench:
1) Start MySQL Workbench 5.2 CE application, and click server Administration near yellow icon
2) Click "Users and privileges" under Security in left panel, and click add account.
3) Click Schema Privileges at the top menu, click "Add Entry" to select object rights.


In this way, you do not need to run the script to "Add new user".

You also can select "Data Export" and "Data Import/Restore"  in Server administration.

Saturday, February 11, 2012

Add infolinks in wordpress

Adding infolinks in wordpress is straight forward. I have wordpress installed in my website.
Below is how I installed infolinks in my wordpress website: http://www.jiansenlu.zoka.cc/wordpress

1)Download the infolinks plugin from
http://publishers.infolinks.com/members/resources/wordpress 
or
http://downloads.wordpress.org/plugin/infolinks-officlial-plugin.zip 
2) The file name is infolinks-officlial-plugin.zip. Unzip the file. ftp infolinks-officlial-plugin directory to your wordpress/wp-content/plugins directory
3) On your WordPress administration, choose Plugins, you will see infolinks-officlial-plugin and click activate
4) Go to settings on the sidebar menu and click on infolinks setting at the bottom, your will be required to enter publisher ID and Website ID, which can be obtained from step 5.
5) log in to your Infolinks account, add your wordpress website, and get your publisher PID and website ID
6) That is the end.

Friday, February 10, 2012

Add infolinks in your bloggers


I followed the instruction in infolinks about 1-minute integration:

"Use our Blogger widget to automatically add Infolinks to your pages"
I get a strange code in my blogger widget.
I have to use my another method to integrate my infolinks in my blogger:
Go to Desgin >> Edit HTML and find the following body end tag :


</body>

Add infolinks in your bloggersAnd place the code from Infolinks just before </body> above. Now click Save template.
Note </body> is very close to the bottom of the HTML file. As HTML file is very important to your blogger, it is better to save a copy before modification.
Now I successfully add my infolinks in my bloggers:
http://jiansenlu.blogspot.com
http://tv-movie-music-online.blogspot.com/
Jiansen Lu's Job Pipe and Monitoring Canadian S&P/TSX Index

Thursday, February 9, 2012

Check your site info using alexa


With Alexa's free web analytics,
http://www.alexa.com/
you can see your website ranking, linkage, search analystics and other statistics.

You can also use wayback machine
http://www.archive.org/web/web.php
to track back your blog previous look.


Wednesday, February 8, 2012

GIMP - remove white background from an image



If you snapshot an image using snipping tool, you may have a white background.
When you embed your image into your website, the white background will be shown.
This is because the background is not transparent.

You can use GIMP photo tool to fix this. File->Open to open your image. Click colors at the top menu and select "Color to Alpha". A new window pop ups. Select white color (HTML color code is #ffffff) to alpha and save your image, which have a transparent background.

I snapshot an image from the free logo website:
http://www.freelogoservices.com

Before white background processing:

After removing white background from the image using GIMP

Tuesday, February 7, 2012

Stop password changing reminder in Windows 7


Sometimes, you are reminded that you have to change your password in limited time. If you do not want Windows 7 keeping remind you to change your password, you can go to Control panel-> System Administration tools->Account Setting and select "account never expire". Then you don't need to change your password from time to time.

CSS background gradient


For Internet Explorer:
 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#55aaee', endColorstr='#003366');
 For Webkit Browsers, such as Safari, Chrome
 background: -webkit-gradient(linear, left top, left bottom, from(#55aaee), to(#003366));
For FireFox 3.6+:
 background: -moz-linear-gradient(top, #55aaee, #003366);
Example:
 <style type="text/css">
.container-grd {
/* default background colour */
background: #2a6da9;

/* gecko based browsers */
background: -moz-linear-gradient(top, #55aaee, #003366);

/* webkit based browsers */
background: -webkit-gradient(linear, left top, left bottom, from(#55aaee), to(#003366)); 
/*IE based browser */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#55aaee', endColorstr='#003366');

}
</style>
 In HTML


<div class="container-grd">
Test my blue gradient</br>
Test <br>
Test
</div>



Test my blue gradient


Test


Test
Reference:
 http://webdesignerwall.com/tutorials/cross-browser-css-gradient
 http://www.tankedup-imaging.com/css_dev/css-gradient.html

Blend tool in GIMP


GIMP is the GNU Image Manipulation Program. It is a freely distributed piece of software.
It is quite similar to PhotoShop. It can be downloaded from:
http://www.gimp.org/

To use blend tool in GIMP,
1)  Click File at the top menu, then enter width: 400, Height: 300
2)  Click Edit at the top menu, click fill with pattern
3) Click blend tool in the toolbox or right click mouse, choose Tools->Paint tools->Blend
4) Select default in gradient, right click mouse and drag it from left to right in the rectangle at the stage.
The result picture is as follows:

Monday, February 6, 2012

Create a balloon shooter flash game


Click mouse to shoot ballons.

Saturday, February 4, 2012

Using Google Presenation to present your work online


Google presentation in Google Docs is similar to PowerPoint. It is a professional way to introduce yourself and your work. You can have a lot of templates to select. You can insert video, drawings and images. Below is my my example: (Click >> to next slide, each slide contains a YouTube video)

Wednesday, February 1, 2012

Control TELUS digital box and TV Power at Once using Universal Remote Control


The instruction to control TELUS digital box and TV Power at Once using Universal Remote Control can be found:
 http://www.telus.com/imagineportal/Upload/Binaries/Mediaroom_Remote_User_Guide.pdf?_region=AB
But It took me more than 1 hour to set it up.

Step  1: Auto-Searching the Code Library (Program Code 922)

1) Turn on TV. TELUS digital box on or off will not matter
2) Press and while holding a TV selected mode key, press the OK key at the same time.
3) Release both keys and all the mode keys blink twice.
4) Enter the programming code 9 2 2. The mode key you selected in step 3 blinks twice to indicate a successful entry.
6) Point the remote toward the device, and press PLAY until TV power off. If it does not work, you may need to try several time.
6) Send the current code – Press the POWER key on the remote to send the current code. If the
device turns back on, press the ENTER key. If TV is not on, press Play again.
For me, the first time , TV is not on. I pressed PLAY second time and TV is  ON.
I pressed ENTER key to save the code.


Step 2. Control TELUS digital box and TV  Power at Once

1. Press and hold the STB mode key on the remote.
2. Without releasing the STB key, press and hold the
OK key.
3. Release both keys and all mode keys blink twice.
4. Enter the programming code 9 7 7 by pressing the
numeric keys on the remote. The STB mode key
blinks twice to indicate a successful entry.
5. For the first device, press the STB key. The STB
mode key blinks twice.
6. For the second device TV, press the TV mode key . The selected mode key blinks twice.
7. Press the ENTER key to complete the power switch control programming. The last selected mode key blinks three times to indicate a successful entry.

Step 3.(After step 1 and step, I found I can not control the volume, I need to setup volume control).  Control Volume for TV
1. Press and hold the STB mode key on the remote.
2. Without releasing the STB key, press and hold the OK key.
3. Release both keys and all mode keys blink twice.
4. Enter the programming code 9 5 5 by pressing the number keys on the remote. The STB mode key
blinks twice indicating a successful entry.
5. Press and release the TV mode key.  The selected mode key blinks three
times to indicate a successful entry.

Actionscript 3.0 load image from external or library


1) To load a image from external in ActionScript 3.0
(The disadvantage of loading an external file is that you need to upload the flash and the external file both, or it will not play)
    import flash.display.*;
    import flash.events.*;
    import flash.net.URLRequest;
    import flash.geom.*;
    import flash.utils.Timer;
     public function loadBitmap(bitmapFile:String) {
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingDone);
            var request:URLRequest = new URLRequest(bitmapFile);
            loader.load(request);
        }
     public function loadingDone(event:Event):void {
            // create new image to hold loaded bitmap
            var image:Bitmap = Bitmap(event.target.loader.content);
            var pieceWidth:Number = image.width/2.;
            var pieceHeight:Number = image.height/2.;
}

To load an image myimage.jpg, call function loadBitmap("myimage.jpg");
2. To load a image from flash library:
Open Flash CS5. Click import and import to library.
Right click image to get Bitmap Properties:
check box: Export for ActionScript and Export in frame 1. Set class name, for example: penguin2.
Using following code ro create new image to hold the imported image
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    var bmp:BitmapData = new penguin2(0,0);
    var    image:Bitmap = new Bitmap(bmp);   

ActionScript 3.0 Create a textfield with url link


Code:
var toplabel:Label=new Label();
toplabel.htmlText='<a href="http://jiansenlu.blogspot.com"target="_blank">jiansenlu.blogspot.com</a>';

See example below: