Welcome to D2T!

Setting Up IIS on your local machine

August 5, 2011 Leave a comment

PURPOSE

  • To test HTML pages with CSS and javascript
  • To test simple banner ads
  • To test pages with no backend

GENERAL INFO

  • Default looks for Default.asp, Default.html, etc as default page
  • CSS/JS usually should be binded to HTML files (no other set up necessary)

INSTRUCTIONS

To enable IIS:
Reference: http://www.victorchen.info/enable-iis-manager-in-windows-7/

  1. Start Menu > Search for “Turn Windows features on or off”
  2. Browse to: Internet Information Services > Web Management Tools > IIS Management Console
  3. Select/Check the “IIS Management Console”
  4. Click the OK Button

To Add a new site:

  1. Open IIS Manager (Control Panel > Administrative Tools > IIS Manager)
  2. Right click your machine or Sites and click “Add Web Site …”
  3. Enter a site name
  4. Find directory of the SVN checkout of the pages
  5. Set Port (Change/increment port if already in use, for multiple projects)
  6. Hit OK
  7. Now go to a browser and go to “http://localhost/(port)

  

DIFFERENCES COMPARING TO TESTING ON A QA SERVER:

  • Control over code base
  • Faster updates/builds by simply doing a SVN update
    • Tools like Jenkens/Hudson- Full builds may take a long time (30 minutes or more)
    • Builds might fail
  • Control over data
  • For video/meda, you can simply throw it on the IIS to test
Advertisements
Categories: Tutorials

How to run legacy versions of applications in Windows 7

August 5, 2011 Leave a comment

This approach uses Windows Virtual PC which allows users to launch applications directly from windows 7 start menu.

Installation/Setup Articles for running legacy IE versions:

http://www.sitepoint.com/ie6-ie7-ie8-win7-xp-mode-2/

http://superuser.com/questions/59148/windows-7-xp-mode-is-it-possible-to-have-multiple-xp-mode-virtual-pcs

http://weblog.200ok.com.au/2010/08/browser-testing-with-windows-7-xp-mode.html

Categories: Tutorials

Installing and running Zombie.js

August 5, 2011 1 comment

For some reason the current setup procedures on the zombie site doesn’t work. I’ve had to look for work-arounds.

The following steps were done for node v0.4.10 and npm v1.0.22

Installation Steps:

  1. Download zombie.tar.gz from here: http://www.box.net/shared/sq8nlkk24ijifhoya7fa
  2. Extract to your node_modules folder
  3. Open command prompt
  4. Install coffeescript by typing: “npm install coffeescript” (Coffeescript should already be there, but still do this just in case)
  5. Type: “cake setup”
  6. Type: “cake clean”
  7. Type: “cake install”

Running Zombie.js

There are different BDD frameworks (node modules) available to execute Zombie scripts:

Sample Scripts

  • Jasmine-Node example: https://github.com/jbueza/zombie-microsoft-sql
  • Vows example:
    var zombie = require('zombie'),
    vows = require('vows'),
    assert = require('assert');
    
    var baseUrl = 'http://www.google.ca/';
    
    vows.describe('Zombie Tests on Google.ca').addBatch({
    'Navigate to Google.ca' : {
        topic: function () {
    	browser = new zombie.Browser({ debug: true });
    	browser.runScripts = false;
    	browser.on('error',function (err){console.log(err.stack)});
    	browser.on('done',function (done){console.log(done.document.cookie)});
    	browser.visit(baseUrl, this.callback);
     	},
        'Should be on Google homepage' : function (browser) {
    	assert.equal(browser.location, baseUrl);
    	},
        'Title should be correct' : function (browser) {
    	assert.equal(browser.text("title"), "Google");
    	},
        'Browser is not redirected' : function (browser) {
    	var redirect = browser.redirected;
    	assert.equal(redirect,false);
    	},
        'There is a button with name "btnG"' : function(browser) {
    	assert.ok(browser.button("btnG"));
    	},
        'and Search for "Test"' : {
    	topic: function (browser) {
    		browser.fill("q","Test");
    		browser.pressButton("btnG",this.callback);
    		},
    	'Title is correct' : function (browser) {
    		assert.equal(browser.text("title"), "Test - Google Search");
    		}
    	}
      },
    }).export(module);
Categories: Tutorials

Installing NodeJS and NPM on Ubuntu VM

August 5, 2011 Leave a comment

Instructions

  1. Download and install vmware player
  2. Download Ubuntu
  3. Install Ubuntu as a virtual machine
    • Create a New Virtual Machine
    • Choose “Installer disc image file (iso)”
    • Select the ubuntu iso you downloaded
  4. Install the OpenSSL development packages
    • Open command prompt
    • Type in: “sudo apt-get install libssl-dev”
  5. Install node.js and npm (https://gist.github.com/579814)
    • Follow the second instruction (only-git-all-the-way.sh)
    • Here are the steps for installing the stable version (v0.4)
    • echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
      echo 'export NODE_PATH=$HOME/local:$HOME/local/lib/node_modules' >> ~/.bashrc
      . ~/.bashrc
      
      cd node-v0.4.10
      ./configure --prefix=~/local
      make install
      cd ..
      
      git clone git://github.com/isaacs/npm.git
      cd npm
      make install

Un-Installation Instructions

  1. To uninstall npm:
  2. To uninstall Node.js:


Categories: Tutorials

Java and Random Interview Knowledge

May 30, 2011 1 comment

Java

  • Interpreted and Just-In-Time Compilation (JIT) – hybrid, translation occurs continuously but caches some of the translated machine code to prevent performance degradation
  • Portable – Java compiler generate bytecodes (architecture neutral intermediate format), setting strict definitions of the basic data types and behavior of the arithmetic operators.
  • Robust and reliable – compile time checking and a run-time checking. Automatic garbage collection.
  • High Performance – interpreter can run at full speed without need to check run-time environment
  • No Pointers, functions, structures, complex memory management
  • Have: Classes, Sub-classes, methods, interfaces, packages
  • Single inheritance (extend) of classes
  • Interface (implements) – only methods (no code), can extend multiple interfaces
  • Public (all classes), protected (only subclasses), private (within class)
  • Class variables (static – only one) and instance variable (shared with all objects)
  • Abstract Class/Methods – place-holders that subsequent subclasses must override
  • Synchronized methods – prevents thread interference and memory consistency errors

Object Oriented

  • Encapsulated data and procedures grouped together to represent an entity. Objects and their interactions to solve a problem, design a application or program.
  • Abstraction – data and programs are defined with a representation similar to its meaning and hide away the implementation details, e.g. object
  • Modularity – separate interchangeable components, breaking down program functions into modules
  • Encapsulation–implements information hiding and modularity (abstraction)
  • Polymorphism–the same message sent to different objects results in behavior that’s dependent on the nature of the object receiving the message
  • Inheritance–you define new classes and behavior based on existing classes to obtain code re-use and code organization
  • Dynamic binding–objects could come from anywhere, possibly across the network. You need to be able to send messages to objects without having to know their specific type at the time you write your code. Dynamic binding provides maximum flexibility while a program is executing. Process of mapping a specific sequence of code at runtime.

Vtable

  • Virtual method table, virtual function table
  • Dynamic dispatch (run-time method binding)
  • Table that contain the addresses of the object’s dynamically bound methods. Method calls are performed by fetching the method’s address from this object’s vtable. Same for objects from same class.

Overloading and Overriding

  • Overloading – Type of polymorphism, different functions/methods of the same name are invoked based on the data types of the parameters passed
  • Overriding – An instance method in a subclass with the same signature that have different methods. Have same name, number, type of parameter, return type. (@override). Cannot override static methods.

Static

  • constant

Final

  • Final class cannot be extended
  • Final methods cannot be overridden by subclasses
  • Final variables can only be assigned once

Aspect-Oriented programming

  • Cross-cutting concerns – code scattering and tangling. Provide systematic means to modularize these concerns.
  • Implementation: Combined program or ultimate interpreter or environment is updated
  • Pointcut/Join points: the possible interaction points, point of execution in the application which cross-cutting concern needs to be applied.
  • Advice: the additional code that you want to apply to your existing model.
  • Aspects: a module that encapsulates a concern, combination of a pointcut (Join point) and a advice

JUnit

  • Unit testing framework
  • Linked as a JAR at compile time
  • Test fixtures: setUp, teardown (@Before, @After) methods
  • Place in same class directory to test that class

Database: Normalization

  • Efficiently organizing data in a database
  • Goals: eliminating redundant data (storing same data in more than one table), ensuring data dependencies make sense (only storing related data in a table)
  • Normal forms – guidelines to ensure databases are normalized. 1NF-5NF.
  • BCNF – slightly stronger than 3NF

Database: Denormalization

  • Attempt to optimize the read performance by adding redundant data or by grouping data
  • Cover up inefficiencies
  • E.g. If a query of normalized tables involves a join, creating a denormalized table avoids the join
  • Normalized database imposes a heavy access load over physical storage of data

Database: levels of database schema

  • Conceptual – map of concepts and their relationships
  • Logical – map of entities and their attributes and relations
  • Physical – particular implementation of a logical schema
  • schema

Database: requirements

  • Completeness
  • Overlap preservation
  • Extended overlap preservation
  • Normalization – independent entities and relationships should not be grouped together, no overlapping schema elements
  • Minimality – if any element of the database schema are dropped then the database schema is not ideal

Database: Mapping

  • One-to-one
  • One-to-many
  • Many-to-many

 

ACID

  • Set of properties that guarantee database transaction process reliably.
  • Atomicity
  • Consistency
  • Isolation – degree of locking data
  • Durability

 

Database: Locking

  • Lock is used when multiple users are accessing a database concurrently
  • Pessimistic locking – immediately locked when requested
  • Optimistic locking – only locked when changes are made to the record are updated

 

Performance Improvement

  • Code optimization – reusing code
  • Caching strategy
  • Load balancing
  • Distributed computing – multiple processes on single CPU, multiple CPU, machines

Tokenizer, Parser


Sorting

  • Quick sort – nlogn, nlogn, n2 (already sorted list)
    • function quicksort(array)
    •      var list less, greater
    •      if length(array) ≤ 1
    •          return array  // an array of zero or one elements is already sorted
    •      select and remove a pivot value pivot from array
    •      for each x in array
    •          if x ≤ pivot then append x to less
    •          else append x to greater
    •      return concatenate(quicksort(less), pivot, quicksort(greater))
  • Merge sort – nlogn, nlogn, nlogn
·         function merge(left,right)
·             var list result
·             while length(left) > 0 or length(right) > 0
·                 if length(left) > 0 and length(right) > 0
·                     if first(left) ≤ first(right)
·                         append first(left) to result
·                         left = rest(left)
·                     else
·                         append first(right) to result
·                         right = rest(right)
·                 else if length(left) > 0
·                     append first(left) to result
·                     left = rest(left)
·                 else if length(right) > 0
·                     append first(right) to result
·                     right = rest(right)
·             end while
·             return result
  • Bubble sort – n, n2, n2
procedure bubbleSort( A : list of sortable items )
  n = length(A)
  for (i = 0; i < n; i++)
     /* back through the area bringing smallest remaining element to position i */
     for (j = n-1; j > i; j--)
        if A[j-1] > A[j] then
           swap(A[j-1], A[j])
        end if
     end for
  end for
end procedure

UML Diagrams

  • Structure diagrams – Class, Component, Composite, deployment, object, package, profile
  • Behaviour diagrams – activity, UML state machine, use case diagram
  • Interaction diagrams – communication, interaction overview, sequence, timing

Halting problem

  • Have a description of a computer program, decide whether the program finishes running or continues to run forever. Given a program and a input, whether the program will eventually halt or run forever.
  • Related to Turing machine

Travelling salesman problem

  • Given a list of cities and their pairwise distances, the task is to find a shortest possible tour that visits each city exactly once
  • Solutions: Brute force search, Branch-and-bound, Progressive improvement
  • Benchmark for many optimization methods. Large number of heuristics and exact methods are known.

Bin Packing problem

  • First fit algorithm – placing each item into the first bin in which it will fit – not optimal
  • First fit decreasing algorithm – sorting elements first into decreasing order – better

Java Design Patterns

GoF Design patterns – Interface over implementation

  • Abstract Factory – interface for creating a family of related objects, without explicitly specifying their classes. Avoid the idea of adding code to existing classes in order to make them support encapsulating more general information.
  • Singleton – only one instance of the class is created, provide a global point of access to the object. Consists of a static member, private constructor, and static get method
  • Builder, Prototype, Adapter, Bridge, Façade, Proxy, Chain of responsibility, interpreter, state, template

J2EE patterns

  • MVC – Model/View/Controller
  • Business Delegate
  • Service Locator
Categories: Development

Tomcat, PHP, MySql, phpmyadmin

May 18, 2011 Leave a comment
Categories: Tutorials

Java Beans, Introspection, Reflection

May 2, 2011 Leave a comment
  • Bean Persistence: http://download.oracle.com/javase/tutorial/javabeans/persistence/index.html
  • A bean has the property of persistence when its properties, fields, and state information are saved to and retrieved from storage.
  • The mechanism that makes persistence possible is called serialization. Object serialization means converting an object into a data stream and writing it to storage.
  • All beans must persist. To persist, your beans must support serialization by implementing either the java.io.Serializable(in the API reference documentation) interface, or the java.io.Externalizable(in the API reference documentation) interface.
  • Any class is serializable as long as that class or a parent class implements the java.io.Serializable interface. Examples of serializable classes include ComponentStringDateVector, and Hashtable. Thus, any subclass of the Component class, including Applet, can be serialized. Notable classes not supporting serialization include ImageThreadSocket, and InputStream. Attempting to serialize objects of these types will result in an NotSerializableException.
  • Long-term persistence is a model that enables beans to be saved in XML format.
Categories: Development