Thursday, February 27, 2014

Find fast USB ports in Windows 7



You may find copying data to your USB drive very slow. This may be due to that you do not connect USB sticker or external storage to enhanced USB   ports, which are normally located near to audio jet.

To find enhanced USB port, click start -> Control Panel->HardWare and Sound->Device Manager under Devices and Printer, click Universal Serial Bus Controller, below is my snapshot:


Enhanced Host controller - IC26 and IC 20 are fast USB ports. Generic USB hub and other USB hubs are slow USB ports.

Also go to my computer, right click your drive and click properties, go to hardware and select your USB drive, click properties and press "Change Settings" button,
Go to Polices tab, select "Better Performance" instead of "Quick mode", and restart computer. But you must safely remove your USB drive. Click Safely Remove Hardware icon Picture of the Safely Remove Hardware icon under right bottom, or click ^ in right bottom of the Windows  to find it, then select eject external USB,

Friday, February 21, 2014

Many to many relations in relational database design



Many to many relations are important in relational database design.
For example in publication database, one publication has many authors and one author has  many publications.
In publication table: pub_id is primary key
pub_id, pub_title, jour_name, pub_date, volume, start_page, end_page, pub_date

In author table: author_id is primary key
author_id, prefix,  firstnme, lastname, institute, position

 Bad design 1) in publication table, add author1, author2, author3 columns.
Bad design 2)  in publication table, add  one author  column, which requires 3,4,5 (authors are separated by comma) in input.

The good design is to  create another junction or linking table, i.e.
pub_id, author_id
(both of them are not primary keys)/

Wednesday, February 12, 2014

Google survey form password protected



You can create a free survey form via creating a form in Google drive. You can embed it in your website or share with a link. The feedback will be save in a Excel file.

But you may not want everyone fill the survey. You need a password protected form.

 To create a survey form using Google form and make it password protected

1) Google drive - creation form
2) in Text field, make it  required question, and set data validation
as regular expression contains
^mypass$.  mypass is the password you set.
Video:  Google survey form creation and password protection

Sunday, February 9, 2014

Windows - schedule tasks in command line using schtasks



You may need the following schedules in Windows:
 1) every day ftp file to another computer on 11:00pm
2) every day check new files created and redirect the result to a log file
3) every day dump mysql database
4) check any malware run in schedule

You can use   schtasks in comman prompt.
1) schtasks help
schtasks /?
2) Query existing schedules
schtasks /QUERY /FO LIST   /V
3) Create a new schedule
 schtasks /create /tn TaskName /tr TaskRun /sc schedule [/mo modifier] [/d day]
 [/m month[,month...] [/i IdleTime] [/st StartTime] [/sd StartDate] [/ed EndDate]
 [/s computer [/u [domain\]user /p password]] [/ru {[Domain\]User | "System"} [/rp Password]] /?


Example
I have ftp script: ftp1.txt
open 137.82.***.***
username
password
lcd C:\sql_dumps\mysql_admin
cd dbfile
mput *.sql
y
bye


I create a executable file jiansen_ftp.bat
ftp -s:ftp1.txt

Create a schedule to run jiansen_ftp.bat every day 23:58:00
 schtasks /create /tn "myftp" /tr C:\sql_dumps\jiansen_ftp.bat  /sc daily /st 23:58:00
Video: Windows - schedule tasks in command line using schtasks


Monday, February 3, 2014

Windows - find newer and older files in command line or search file by date



1) Example, if today is 2014 Feb, 03 and I want to find files created in one week in folder
 C:\Users\jiansen\Desktop\bike, including sub-directories in Windows.

First type cmd in start menu, and get command prompt in Windows.7
type
forfiles /p  C:\Users\jiansen\Desktop\bike /s  /D +2014-1-27
Windows 2003 server, a little different:
forfiles /p  C:\Users\jiansen\Desktop\bike /s  /D +1/27/2014

Note: /p follows folder name, /s including sub-directories, +2014-1-27, means files newer than  2014-1-27

2) Find file created today
forfiles /p  C:\Users\jiansen\Desktop\bike /s  /D +0

3)Find file older than 7 days
forfiles /p  C:\Users\jiansen\Desktop\bike /s  /D -7


return
"test.txt"
 ... The above commands only returns file name without path name. If output including full pathnames and file names, the command will be
forfiles /p  C:\Users\jiansen\Desktop\bike /s  /D -7 /C "cmd /c echo @path"
return
"C:\Users\jiansen\Desktop\bike\test.txt"
  Summary of forfiles command:
FORFILES [/P pathname] [/M searchmask] [/S]
         [/C command] [/D [+ | -] {yyyy-MM-dd | dd}]

Description:
    Selects a file (or set of files) and executes a
    command on that file. This is helpful for batch jobs.

Parameter List:
    /P    pathname      Indicates the path to start searching.
                        The default folder is the current working
                        directory (.).

    /M    searchmask    Searches files according to a searchmask.
                        The default searchmask is '*' .

    /S                  Instructs forfiles to recurse into
                        subdirectories. Like "DIR /S".

    /C    command       Indicates the command to execute for each file.
                        Command strings should be wrapped in double
                        quotes.

                        The default command is "cmd /c echo @file".

                        The following variables can be used in the
                        command string:
                        @file    - returns the name of the file.
                        @fname   - returns the file name without
                                   extension.
                        @ext     - returns only the extension of the
                                   file.
                        @path    - returns the full path of the file.
                        @relpath - returns the relative path of the
                                   file.
                        @isdir   - returns "TRUE" if a file type is
                                   a directory, and "FALSE" for files.
                        @fsize   - returns the size of the file in
                                   bytes.
                        @fdate   - returns the last modified date of the
                                   file.
                        @ftime   - returns the last modified time of the
                                   file.

                        To include special characters in the command
                        line, use the hexadecimal code for the character
                        in 0xHH format (ex. 0x09 for tab). Internal
                        CMD.exe commands should be preceded with
                        "cmd /c".

    /D    date          Selects files with a last modified date greater
                        than or equal to (+), or less than or equal to
                        (-), the specified date using the
                        "yyyy-MM-dd" format; or selects files with a
                        last modified date greater than or equal to (+)
                        the current date plus "dd" days, or less than or
                        equal to (-) the current date minus "dd" days. A
                        valid "dd" number of days can be any number in
                        the range of 0 - 32768.
                        "+" is taken as default sign if not specified.

    /?                  Displays this help message.

Examples:
    FORFILES /?
    FORFILES
    FORFILES /P C:\WINDOWS /S /M DNS*.*
    FORFILES /S /M *.txt /C "cmd /c type @file | more"
    FORFILES /P C:\ /S /M *.bat
    FORFILES /D -30 /M *.exe
             /C "cmd /c echo @path 0x09 was changed 30 days ago"
    FORFILES /D 2001-01-01
             /C "cmd /c echo @fname is new since Jan 1st 2001"
    FORFILES /D +2014-2-3 /C "cmd /c echo @fname is new today"
    FORFILES /M *.exe /D +1
    FORFILES /S /M *.doc /C "cmd /c echo @fsize"
    FORFILES /M *.txt /C "cmd /c if @isdir==FALSE notepad.exe @file"
Video:  Windows - find newer and older files in command line, search file by date