Wednesday, July 24, 2013

Database Day 03: MySQL in Ubuntu

Create a user at localhost
create user 'david'@'localhost' identified by 'password';

Grant permissions to access all databases and all tables for the user "david"
grant all on *.* to 'david'@'localhost' identified by 'password'; 
SET PASSWORD FOR 'username'@'localhost'=PASSWORD('mynewpassword');
SET PASSWORD FOR 'username'@'hostname'=PASSWORD('mynewpassword');

List all databases managed by the server
show databases;

Work on database test
use test

Display all tables in database test
show tables;

Describe a table in the current database test
describe tablename;

Create table users in the database test
use test;
create table users (users_id INT unsigned NOT NULL AUTO_INCREMENT, users_name VARCHAR(50) NOT NULL, users_email VARCHAR(50) NOT NULL, users_datejoined DATETIME NOT NULL, PRIMARY KEY (users_id));

Add another column to the table "users" after the "users_email" column
ALTER TABLE users ADD users_pass CHAR(40) NOT NULL AFTER users_email;

Insert a new record to the table users
INSERT INTO users (users_name, users_email, users_pass, users_datejoined) VALUES ('John Smith','johnsmith@abc.com', SHA1('mypassword'), NOW());

Insert another record to the table users using the second method
INSERT INTO users VALUES (NULL, 'Peter Jones','peterjones@fakeemail.com', SHA1('password'), NOW());

Show all the records in the table "users"
USE test;
SELECT * from users;

Show all the records in the table "users"
USE test;
SELECT users_name from users;

Show all the records in the table "users"
USE test;
SELECT users_name, users_email from users;

Display the current date and time
SELECT NOW();

Show the user that has the users_id = 5
SELECT users_name FROM users WHERE users_id = 5;

Show users that have the users_id > 3
SELECT users_name FROM users WHERE users_id >3;

Show users that have the users_id between 3 and 10
SELECT users_name FROM users WHERE users_id BETWEEN 3 AND 10;


Show users that have the users_id between 3 and 10 and users_post > 10
SELECT users_name FROM users WHERE (users_id BETWEEN 3 AND 10) AND (users_post  > 10);

Run mysql script to create and populate database
mysql -u root -p
source c:\mysqlstatements.sql

Thursday, May 16, 2013

UNIX/Linux/Ubuntu system administration DAY 03

1. Delete line(s) in a text file

%sed -e '/pattern/d' foo.txt > new_foo.txt

If the keyword has spaces or special characters, use this

%sed -e "/pattern/d" foo.txt > new_foo.txt

2. List only usernames in linux/unix systems 

Type the following awk command:
$awk -F':' '{ print $1}' /etc/passwd

3. Login definition file is at /etc/login.defs
 
This login.defs file contains the starting and ranges of UID for users and groups, password aging controls (e.g. maximum number of days a password may be used, minimum acceptable password length, etc.), default UMASK, use MD5 or DES to encrypt password, etc.)


4. Stop the network interface eth0:
        ifdown eth0


5. Start the network interface eth0:
        ifup eth0


6. Restart all the networks services:

        /etc/init.d/networking restart

7. Display various network interfaces

        /sbin/ifconfig -a

8. Add a default gateway of 192.168.0.1
        route add default gw 192.168.0.1

9. To learn about kernel
        differences between
        $uname -a
        shows machine name and detailed hardware information

        and

        $cat /proc/version
        shows gcc version

10. term, xterm and uxterm
        differences between them
        term: terminal, which is in the Ubuntu default software, is the gnome-terminal.
        The gnome-terminal has more features than xterm.
        xterm: is minimalistic
        uxterm: is xterm with the support of Unicode characters

Sunday, February 3, 2013

Research Day 02: Scientific Method

I. Google articile about The Scientific Method

 

II. Google article about Lesson Plan Notes 


III. Google Student Worksheet




(Source: above articles obtained from Google at http://www.google.com/events/sciencefair/educators.html)

Visual Information Day 02

Tablet market share in fourth quarter 2012


(Source: IDC at http://bit.ly/14IdUci)

A Courtroom Map of A Magistrates' Court

References

D.L.A. Barker (2007). Law Made Simple. 12th Ed. Elsevier Ltd

 

Saturday, February 2, 2013

Object Recognition Day 01

Challenges in visual object recognition

 Matching and learning visual objects is challenging because of the following factors.

  1. Illumination conditions
  2. Object pose
  3. Camera viewpoint
  4. Partial occlusions
  5. Unrelated background clutter
  6. Computational complexity
  7. Scalability


State of the art of visual object recognition methods


A good feature extraction method needs to have the following properties.

  1. Being able to extract local invariant features (e.g. scale invariance, affine invariance)
  2. Fast to extract
  3. Robust to viewpoint variations
  4. Retaining enough discriminative power to allow for reliable matching

References

Kristen Grauman and Bastian Leibe (2011) . Visual Object Recognition (Synthesis Lectures on Artificial Intelligence & Machine Learning). Morgan & Claypool.

Visual Information Day 01

 Australia's Tax Take - Winners and Losers

(Source:The Weekend Australia Newspaper, February 2-3, 2013)

(Source:The Age Newspaper, February 2, 2013)

 

 (Source:The Age Newspaper, February 2, 2013)

 

  (Source:The Age Newspaper, February 2, 2013)

 

Victoria, Australia House prices 1 year to 30 October 2012



(Source: Australian Property Investor Magazine, February 2013 Issue)

Monday, January 28, 2013

Operating Systems Day 10 Process Scheduling

A Comparison of Process Scheduling Algorithms

 

Algorithm Preemptive? Description Characteristics Advantages Disadvantages
FCFS (first come first serve) No Handles jobs
according to their
arrival time: the earlier
they arrive, the sooner they served.
Suitable for batch systems. Not suitable for interactive systems because interactive users expect quick response times. Easy to implement Unpredictable turnaround times
SJN (shortest job next) No Handles jobs based on the length of their CPU cycle time. Suitable for batch system (i.e. all of the jobs are available at the same time and the CPU estimates are available and accurate). Minimizes average waiting time Indefinite postponement of some jobs
SRT (shortest remaining time) Yes The CPU is allocated to the job closest to completion. Suitable for batch system. Requires advance knowledge of the CPU time required to complete each job. Ensures fast completion of short jobs Overhead (i.e. OS frequently monitors CPU time for all jobs in the READY queue) incurred by context switching
Round Robin Yes It's easy to implement. It is based on a predetermined slice of time that is given to each job.
Suitable for interactive systems.
Provides reasonable response times to interactive users; provides fair CPU allocations. Requires selection of good time quantum
Priority No It allows the programs with the highest priority to be processed first. Suitable for batch systems Ensure fast completion of important jobs Indefinite postponement of some jobs

References

McHoes, A., & Flynn, I.M. (2011). Understanding operating systems (6th ed.). CENGAGE Learning.

Artificial neural networks Day 06

Problems Classification Clustering Pattern association Optimization Forecasting Function approxi-mation
Determine a function that approximates a stock market index.




Yes
Remember the name of a person.

Yes


Determine whether a person has a lung cancer. Yes




Develop a customer profile that would purchase a sport magazine.
Yes



Determine the genre of a playing song. Yes




Predict the company sales revenue for the next quarter.



Yes
Predict which product(s) a customer would likely buy next if they already bought milk and eggs

Yes


Arranging components on a circuit board such that the total length of wires is minimized.


Yes


References

Kishan Mehrotra, Chilukuri Mohan and Sanjay Ranka (1996). Elements of Artificial Neural Networks. A Bradford Book

Motivation Messages Day 01

At some point in the various journeys we embark on in our lives, we get to a part where we feel like giving up. Sometimes we give up before we even start and other times we give up just before we are about to make that huge break-through that we have been putting so much effort in to achieve.
 
The following shows 16 reasons that you should never give up and inspire other people around you to keep them going.

1- As Long As You Are Alive Anything Is Possible
The only valid excuse you have to give up is if you are dead. As long as you are alive (and healthy and free) you have the choice to keep trying until you finally succeed.
2- Be Realistic
The chance of mastering something the first time you do it is almost non-existent. Everything takes time to learn and you will make mistakes. Learn from them.
3- Michael Jordan
Arguably the best basketball player of all time. He attributes his success to all his failures. He just never gave up even when he knew he had missed over 300 shots and had missed the  winning shot of the game many times. Every time he got knocked down he got back up again.
4- Chris Gardner – The Pursuit of Happiness
Have you seen the movie “The Pursuit of Happiness”? It is based on the life story of Chris Gardener, a man who went for the lowest of the lows in an environment where most people would give up (no money, no job) to the highest of the highs (A millionaire with his own investment firm). If you ever think about giving up, watch this movie!
5- You Are Strong
You are stronger than you think. One little setback is not enough to stop you from achieving your goals. Neither are 10 or 100 or 1000 setbacks.
6- Prove Yourself
You don’t want to be known as someone that is weak and gives up. Go out there and prove yourself to the world and to yourself. You CAN and WILL achieve what you set out to do. The only time you fail is when you give up.
7- Has It Been Done Before?
If someone else can do it then so can you. Even if it is only one other person in the world that has achieved what you have set out to achieve, that should be reason enough for you to never give up.
8- Believe In Your Dreams
Don’t sell yourself short. In life there are going to be many people who will try to bring you down and tell you what you want to achieve is not possible. Don’t let anyone destroy your dreams.
9- Your Family and Friends.
Let the people you love and who mean the world to you be your inspiration to persist and persevere. Maybe you need to try a different angle, study more or practice more but don’t give up!
10- There Are People Worse-Off
Right now there are many people who are in a worse situation and environment than you are right now. Are you thinking about giving up running 5 miles a week? Think about the people who are unable to even walk and how much they would give to be able to run 5 miles every day.
11- Improve Our World
When you achieve whatever you set out to achieve you can use your success to make a difference to the world or other peoples lives.
12- Get Rich or Die Trying
Like Fiddy (50 cent) says, “Get rich or die trying”. 50 Cent is rich, he made it (although he did get shot 9 times). Face your fears and don’t take the easy way out by giving up.
13- Let The Haters Hate
There will always be haters. There will always be plenty of naysayers  and people who try to tear you down. Don’t pay attention to them and don’t take what they say to heart. Let the haters hate and you keep believing in yourself.
14- You Deserve To Be Happy
Don’t ever let anybody tell you otherwise. You deserve to be happy and you deserve to have success. Keep that mindset and never give up until you reach your destination!
15- Inspire Others
Be an inspiration to others by refusing to give up. Who knows what someone else can achieve because you never gave up and in turn inspired them not to give up.
16- You Are So Close
Often when you feel like you want to give up and you are about to give up you are so close to making a huge break-thru. Seth Godin has written an awesome book about this called “The Dip” – a riveting read that teaches that at any given time you are always just a heartbeat away from success.

P.S. NEVER GIVE UP!

The content of the above article has been extracted from the following address with some modifications
 http://www.pickthebrain.com/blog/22-reasons-to-never-give-up/

Sunday, January 27, 2013

Database Day 02: Functions of A Database Management System

Functions of A Database Management System (DBMS)

  1. Create database
  2. Create tables
  3. Create supporting structures (e.g. indexes)
  4. Read database data
  5. Modify (insert, update, or delete) database data
  6. Maintain database structures
  7. Enforce rules
  8. Control concurrency
  9. Provide security
  10. Perform backup and recovery
For example, an organization developes a database that is used to manage its data. The company has two buildings that house different departments. The first building houses Administration, Accouting, Finance and Human Resources departments and the second buidling houses Production, Marketing, and Information Systems departments.The company database contains data about company employees, departments, company projects, company assests (e.g. computer equipment, buildings), and other aspects of company operations (e.g. sale orders, purchasing orders, products).

References

  1. David Kroenke and David Auer (2011). Database Processing: Fundamentals, Design, and Implementation, 12 edition, Prentice Hall.

Friday, January 25, 2013

Operating Systems Day 09 Memory allocation schemes

Fixed size partitions or static partitions

Descriptions

  1. Each partition contains only one job
  2. Entire program is stored contiguously and in memory from the beginning to the end of its execution
  3. This partition scheme is suitable for a system where its jobs have the same size or its sizes are known ahead of time and don't vary between reconfigurations.

Advantages

  1. Protect the job's memory space
  2. Allow several programs to be in memory at the same time, compared with the single-user scheme

Shortcomings

  1. May suffer from internal fragmentation
  2. Large jobs may have a longer turnaround time as they wait for free partitions of sufficient size or may never run
  3. A small job occupies its entire partition. As a result, the unused memory in the partition will remain idle.

Dynamic partitions

Descriptions

  1. Available memory is still kept in contiguous blocks but jobs are given only as much memory as they request.

Advantages

  1. Allocate as much memory as a process requests.

Shortcomings

  1.  May suffer external fragmentation where fragments of memory between blocks of allocated memory cannot be used.

References

  1. McHoes, A., & Flynn, I.M. (2011). Understanding operating systems (6th ed.). CENGAGE Learning.

Saturday, January 19, 2013

Business model tool

Create a business model using a canvas.
Product in the middle


Another business model canvas example captured from the Apple App Store App called "Business Model Toolbox"





Tablet wish list


  1. Long battery >= 12 hours
  2. Responsive
  3. High resolution display (retina display)
  4. Light weigh < 700g
  5. Sharpness
  6. Reasonable price < $AUD 500

Mounting USB drives in Windows Subsystem for Linux

Windows Subsystem for Linux can use (mount): SD card USB drives CD drives (CDFS) Network drives UNC paths Local storage / drives Drives form...