Friday, April 16, 2010

Elevator pitch 1

Hello, my name is Leo Lee, I’m an IT infrastructure Consultant.

I’ve selected the role of IT Infrastructure Manager, as the knowledge in this course can be directly applied to the clients that I’ll visit.

My e-portfolio will be around the e-commerce infrastructure, the skills will include:

1. E-commerce, distributed applications and the Internet
2. Clients, servers and distributed paradigms
3. Database servers
4. Programming web servers
5. Web technologies & frameworks
6. Distributed objects
7. Internet security
8. Concurrency and transactions
9. Business process modeling & MVC
10. Bots, agents, spiders and mobile computing
11. Describe about cloud, grid & service oriented computing
12. Systems integration on open source and Microsoft platforms

Hope this explains my e-portfolio clearly. Have a nice day. Bye


Workshop 3

1. Set up the MySQL tools on your computer as described in section 6 above.

The GUI tool is called MySQL Workbench, and is downloaded from http://www.mysql.com/products/tools/. The latest GA version is 5.1.18a. A Microsoft MSI installation file is available. After installation, it is running successfully and the screen shot is as follow.




2. Rails will setup a new application directory for each of your Web application projects. Get InstantRails (Windows) or Locomotive (MacOS) running on your machine. Both packages install Ruby, Rails, a Web server or one called ‘Mongrel’ or another small Ruby Web server called ‘WEBrick’, and MySQL “inside a bubble” as I call it so that others parts of your system are not modified (Similarly ZOPE does with installing its own Web server and Python versions).

I did not install InstantRails, but the Ruby and Rails from rubyforge.org. The version is 1.86-27, it is an older one but stable.




The RoR is installed successfully, and the folder c:\Ruby is created.

In this version, the RubyGems is not necessary to installed separately. But according to the installation instruction, two instructions to update the RubyGems are required.


C:\rudy> gem update rails

C:\ruby>gem install rails—include-dependencies (takes quite a while)

After installation is completed, the online taxi booking system (OTBS) is created by running command from the Ruby folder.





Associated folders are created.








To start the WEBrick server, below command is run at the c:\ruby\otbs folder.










3. Once Rails is running you at http://localhost:3000, you need to configure database access. Connection to the database is specified in the config/database.yml file.

The port at 3000 of Rails is running as shown as follow:





The detail of the config/database.yml is shown below. The database that connected from three environment ‘development’, ‘test’ and ‘production’ are specified by default.




4. Generate the Passenger model by creating the MySQL database and ‘passengers’ table from the information above.

The procedure can be straightly followed through the Ruby on Rails instructions:

(a) Showing options by running without parameters





(b) Running script/generate command with table ‘Passengers’ and columns





The models and controllers folders are created





(c ) Run rake command to migrate the database


















Monday, April 12, 2010

Worshop 4

To do:

1. Spend some time moving your way through the 46 Ruby coding examples in the Ruby Tutorial with Code from http://www.fincher.org/tips/Languages/Ruby/


2. What are the syntax differences in the way that Ruby and Javascript use the if statement?
Below is a simple example comparing the basic syntax.
JavaScript
if (card > 21) {
document.write("busted");
} else if (card == 21) {
document.write("won");
} else {
document.write("continue");
}
Ruby
if card > 21
print "busted"
elseif card == 21
print "won"
else
print "continue"
end


3. While Ruby and Python are quite similar, can you find some similarities between Ruby and Javascript?

The main similarity between Ruby and Javascript is quite fundamental; they both have similar syntax and are object-oriented language.


Challenge Problems:

1. Create, test and debug a Ruby program called dognames.rb or catnames.rb to accept 3 names from the keyboard and to display each name on the screen in alphabetical order WITHOUT using a data structure such as a list.




2. Write a Ruby program called fizzbuzz.rb that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".





3. Compare the Ruby and Python versions of the dog years calculator:

#!/usr/bin/ruby
# The Dog year calculator program called dogyears.rb

def dogyears
# get the original age
puts “Enter your age (in human years): "
age = gets # gets is a method for input from keyboard
puts # is a method or operator for screen output

#do some range checking, then print result
if age <> 110
puts "Frankly, I don't believe you."
else
puts "That's", age*7, "in dog years."
end
dogyears

Python

#!/usr/bin/python
# The Dog year calculator program called dogyears.py

def dogyears():
# get the original age
age = input("Enter your age (in human years): ")
print # print a blank line

# do some range checking, then print result
if age <> 110:
print "Frankly, I don't believe you."
else:
print "That's", age*7, "in dog years."

### pause for Return key (so window doesn't disappear)
raw_input('press Return>')

def main():
dogyears()
main()

Comparsion:

Ruby Python
File extension rb py
Function quotation No quotation ():
Remark # #
Prompt Puts “ “ Input (“ “)
End of loop 'End' statement No need to put ‘End’ Statement

Sunday, April 4, 2010

Exercise 8

Create an XML document for an online catalogue of cars where each car has the child elements of make, model, year, colour, engine, number_of_doors, transmission_type and accessories. The engine has child elements called number_of_cylinders and fuel_system.

Taking reference from W3School.com, below is the scripts.



Saturday, April 3, 2010

Exercise 7

1. Why is the perception getting stronger that integration will become a critical factor in coming days?

The perception of integration getting stronger is because it can bring business benefits. The benefits could be extracted from a research from a networking consultancy company called Camden. (Zeichick. A., 2004)The research is called 'THE BUSINESS BENEFITS OF INTEGRATION', and the main points are summarized below.

Integration may be the most cost-effective way for IT to add business value to the enterprise.

Revenue Enhancers
1. Sell more through suggestive sales techniques.
2. Boost customer retention by turning customer service into self-service.
3. Increase revenue by empowering your own sales and support teams.

Cost Reducers
4. Eliminate the cost of storing and managing redundant data.
5. Reduce the cost of manual data reentry and report generation.
6. Lower ongoing system administration expenses.

Efficiency Improvers
7. Accelerate application development using modern RAD platforms.
8. Control and simplify business processes via work flow.
9. Efficiently incorporate modern security programs.

Future Planning
10. Lay an architectural framework that will provide the enterprise with greater agility.

References


Zeichick.A. (2004). The Business Benefits of Integration. Camden Associates. Retrieved on 3 April, 2010 from www.attachmate.com/NR/rdonlyres/...50C0.../literature_bbintegrate.pdf


2. What is the relationship of AJAX to JQuery (jquery.com) and the lightweight Web 2.0 javascript framework called MooTools (mootools.net) within the enterprise software architecture?


The below information are extracted from Wiki.

jQuery is a lightweight cross-browser JavaScript library that emphasizes interaction between JavaScript and HTML. It was released in January 2006 at BarCamp NYC by John Resig. Used by over 27% of the 10,000 most visited websites, jQuery is the most popular JavaScript library in use today. (Wiki, 2010)

MooTools (My Object-Oriented Tools) is an open-source, lightweight, modular object-oriented programming JavaScript Web application framework released under the MIT License. …The framework includes built-in functions for manipulation of CSS, DOM elements, native JavaScript objects, Ajax requests, DOM effects, and more. MooTools also provides a detailed, coherent application programming interface (API)[8], as well as a custom downloads module allowing developers to download only the modules and dependencies they need for a particular app.

References

Wiki. (2010). iQuery. Retrieved on 4 April 2010 from http://en.wikipedia.org/wiki/JQuery
Wiki. (2010). Mootools. Retrieved on 4 April 2010 from http://en.wikipedia.org/wiki/Mootools

4. What does it mean to develop RESTful practices into our web applications?

Representational State Transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. Conforming to the REST constraints is referred to as being ‘RESTful’.

Constraints
The REST architectural style describes the following six constraints applied to the architecture, while leaving the implementation of the individual components free to design:

Client-server
Stateless
Cacheable
Layered system
Code on demand (optional)
Uniform interface

Complying with these constraints, and thus conforming to the REST architectural style, will enable any kind of distributed hypermedia system to have desirable emergent properties, such as performance, scalability, simplicity, modifiability, visibility, portability and reliability.

Impmenting RESTful web services
A RESTful web service (also called a RESTful web API) is a simple web service implemented using HTTP and the principles of REST. It is a collection of resources, with three defined aspects:

• the base URI for the web service, such as http://example.com/resources/
• the MIME type of the data supported by the web service. This is often JSON, XML or YAML but can be any other valid MIME type.
• the set of operations supported by the web service using HTTP methods (e.g., POST, GET, PUT or DELETE).

Unlike SOAP-based web services, there is no "official" standard for RESTful web service.[8] This is because REST is an architecture, unlike SOAP, which is a protocol. Even though REST is not a standard, a RESTful implementation such as the Web can use standards like HTTP, URL, XML, PNG, etc.

Exercise 6

1. Design the form
“Retrofit” the form data string above:

name=Evan+Burke&card=Visa&number=8443261344895544&order=French+perfume

for buying some French perfume into the HTML form fields and submit button on the Web page form.

My scripts are as follow:



The screen shot of running the program is as follow:





2. Write the script
Script archives exist for PERL, Python and JavaScript. Search the Web for a script that processes the HTML forms data. Read the code and list the steps involved in processing the form.

The scripts I found from the web is as follow, and the steps are very self-explanatory.

#!/usr/bin/python

import sys
import time
import cgi

sys.stderr = sys.stdout

# Read in a template for the page we're to generate

fh = open ("template.htp")
html = "".join(fh.readlines())

# Read in the form contents and save them in a dictionary

inputs = cgi.FieldStorage()
fill = {}
for key in inputs:
fill[key] = inputs[key].value

# Do Work!
# Use values in input to create values in fill

matched = lines = 0
fval = fill.get("code","")
if fval != "":
fill["result"] = "Dialling codes starting " + fill["code"]
fhdata = open("../../live_html/data/stdcodes.xyz")
while 1:
line = fhdata.readline();
if line == "": break
if line.startswith(fval):
fill["result"]+= "
" + line
matched += 1
lines += 1
fill["result"] += "
matched "+str(matched)+ \
" out of "+str(lines)
else:
fill["result"] = "Your results will appear here"
fill["time"] = str(time.time());

# Fill in the response template

for key in fill:
lookfor = "%"+key+"%"
html = html.replace(lookfor,fill[key])

# Send out the results

print "Content-type: text/html\n\n",html


3.Can you modify the script to process the form?

Yes, I can but I would not because it is quite simple already.