Monday, March 30, 2009

CTS presentation on AJAX

Asynchronous Java Script And XML


1. Asynchronous
2. Javasript
3. XML (Not in literal sense) (Could be tags)




Why? AJAX??


- Lots of data running back and forth.
- Instant feedback for actions from database.
- Not asking server to get the whole page.
Example: some calculation that took long time on a given page and you need to refresh a small component on a page
It would refresh and goes over the same query for that small piece of code.




Microsoft solution inplace of AJAX was ActiveX control
-======-
ASP.NET Examples below.




Asyncronous
- Communication - XML Http Request


Javascript
- Client side processing
- DHTML
Change all the properties of HTML on the fly.


XML
- Data Exchange format.




Script Manager
- Brings the thousands of lines of code to the programming, Its like a container
- In code add where ever but always should be before Update Panel.


Update Panel
- To Ajaxify the exisiting buttons tables or other controls
- After adding
<?xml:namespace prefix = asp /><asp:updatepanel id="panel1update" runat="server"> </asp:updatepanel>

-Add the
 <contenttemplate> </contenttemplate>
tag right after update panel


Question: What if there was object that was outside the scope of <scriptmanager>because of the asthetic reasons?</scriptmanager>
A: Use
<trigger> </trigger>
tag
<triggers></triggers>

 <asp:asyncpostbacktrigger controlid="Button1"></asp:asyncpostbacktrigger>

// CAN HAVE AS MANY AS NEED BE
 



Update Progress
-


Timer
- Shows the time used.








DEMONSTRATION
---------------------------
Client side
============





var xmlHttp;


function PrepareRequest()
{
Request("PrimativeAjax.aspx?data=a");
}


funtion Request(url)
{
xmlHtp = null;
if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
isIE = true;
return new ActiveXObject("Microsoft.XMLHTTP");
}
}




function doCompletion() {
if (completeField.value == "") {
clearTable();
} else {
var url = "autocomplete?action=complete&id=" +
escape(completeField.value);
var req = initRequest();
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
parseMessages(req.responseXML);
} else if (req.status == 204){
clearTable();
}
}
};
req.open("GET", url, true);
req.send(null);
}
}
fucntion ReloadPage(data){
if(data != null)
{
document.getElementById("textbox1").innerText = data;
}








==========
Server Side
==========
if(
Response.Write(Time.Now().ToString());
httpContext.Current.ApplicationInstance.Complete(); // this is for sending the 200 code to the requesting client.

Thursday, March 26, 2009

Color Scheme



#####  Color Palette by Color Scheme Generator #####  Palette URL: http://colorschemedesigner.com/#2K62nsOsOK-K-   *** Primary Color:     var. 1 = #38C113 = rgb( 56,193, 19)    var. 2 = #437935 = rgb( 67,121, 53)    var. 3 = #155C02 = rgb( 21, 92,  2)    var. 4 = #85F069 = rgb(133,240,105)    var. 5 = #B8F0A9 = rgb(184,240,169)  *** Secondary Color A:     var. 1 = #1C4A98 = rgb( 28, 74,152)    var. 2 = #2F415F = rgb( 47, 65, 95)    var. 3 = #031D48 = rgb(  3, 29, 72)    var. 4 = #719CE5 = rgb(113,156,229)    var. 5 = #A9BFE5 = rgb(169,191,229)  *** Secondary Color B:     var. 1 = #E6DE17 = rgb(230,222, 23)    var. 2 = #8F8C3F = rgb(143,140, 63)    var. 3 = #6D6903 = rgb(109,105,  3)    var. 4 = #F9F36D = rgb(249,243,109)    var. 5 = #F9F6B0 = rgb(249,246,176)  *** Complementary Color:     var. 1 = #DC162D = rgb(220, 22, 45)    var. 2 = #8A3C45 = rgb(138, 60, 69)    var. 3 = #69030F = rgb(105,  3, 15)    var. 4 = #F66C7C = rgb(246,108,124)    var. 5 = #F6AEB7 = rgb(246,174,183)   #####  Generated by Color Scheme Designer © Petr Stanicek 2002-2009

CSS tags for a:link a:hover

Found Solution 
a:link:hover, a:visited:hover {text-decoration: underline; color: red; background: yellow}


reference

Tuesday, March 24, 2009

Almost Lost the previous post, Thanks to the auto save feature (draft) in the blogger.com website

This new HP DV9207us laptop craps out on me everytime I am about to finishing up something valuable. 

After the lappy craped out on me, I had 4 mins before the class and had to rush... so on my way was thinking about the google mails auto save feature, and hoping that google integrated that to this blogger website.

Really this feature is a life saver and I rejoiced seeing my typed blog post was saved in as a drafts under posts

rANdOM ThOUgHTS

Just finished watching interview of the whole house crew... and the question about "would you go to medical school?", and their replies were either "I could last their for a week" , "I could be a lawn doctor" makes me wonder... are we all really getting stupid.. yes, i say we cause I feel no different when it comes to thinking "Its too much for me to do or learn"...

After years I realize that a blog might help me share my ideas and elaborate on my thought process and think more clearly... and I Come back to this blog....

Ok, so getting back to the thought process... Is it genetically part of all human beings to set limits for themselves and start saying "I can..." and "I can't..." do this... or its the fear of learning new things and failing... or we are just complaisant enough with what we know, and not learn new things and think would get us around, without them.

I have realized many times, when things start falling apart, my thought process automatically weakens and starts falling apart too and this happens in a growing progression... (It is more in terms that my mind says "I can't" instead of "I can") the only way out for me, is to either completely focus on that thought fight with it or find some digression far away from that thought. When starting to fall apart... the psychological response: if i decide to focus and stick with the thought, then it is to go about taking a nap and relax my body. while the mind has all the freedom to solve the complexities of mind (formal thougth: think only about the problems) and not get distracted by the interrupts raised by other organ system.

Tuesday, December 4, 2007

Algorithms Basics

1 . Algorithm:
A sequence of unambiguous statements that produce output given ligetimate input to it in finite amount of time

Characteristics:



  1. Finiteness: It terminates after finite number of steps

  2. Input: Takes a valid precisely defined input

  3. Output: Generates output that is expected.

  4. Definiteness: The steps are rigiously and unambigiously specified.

  5. Effectiveness: the steps are sufficiently simple and basic.


II. Devising
A. Expressing
(1) English, (pure language) (easy but the most least precise)
(2) pseudocode, or (Language that dosn't give any syntax errors) (better happy medium)
(3) a real programming language (difficult to write and understand)

B. Validation
How to prove that the algorithm works?
one of the hardest parts?
it is easy to convince our selves that an algorithm works for a simple problem. But actual validation of the problem is diffult we need abstract problem specifications.

For validation
1. specify (all the assumptions and consider all the possibilities)
duplicate numbers in input, ordering of duplicates, etc.


2. Proof:
a. formal proof: -predicate calculus
use mathematical language to describe each component
from input ---> operation ---->ouput

b. informal proof: "it is obvious that..."
an argument is broken down into small steps
problem: brittle, make one wrong assuption, everrything falls apart.

c. Testing: give conctret input and see if it gives proper or expected outputs
problem: can not test all cases, in somecases you can...

Problem of not knowing the correct answer sometimes:
try solving different methods and verify if the solutions match to the other kwon method..

Axioms: The assumptions that are made
Lemas: the small parts of the theoroms, simpler parts, pieces of proofs
Theorms: the goal to reach,

C. Analysis




D. Computing models
E. Time complexity
1. Size of problem
2. Best/Average/Worst-case analysis
F. Space complexity
G. Simplicity/understandability
H. Optimality
III. Complexity
A. Complexity bounds
1. Asymptotic notation
o
O




B. Relations between asymptotic
bounded classes
C. Typical complexities
1. Polynomial
2. Polynomial-bounded
3. Exponential
4. Factorial
5. Logarithmic
IV. Recurrences
A. Iteration method
B. Substitution method
C. Master Method
D. Master method
V. Sorting
A. Proof of ( log )n n for comparison
sorts
B. Quicksort
1. Average-case analysis
2. Optimizations
a) Use of sentinels
b) Non recursive algorithm
c) Stack depth consideration
d) Median-of-three
e) Handling of small sublists
C. Counting sort
D. Radix sort
VI. Searching
A. Binary search
B. Interpolation search
C. Digital search tree
D. Tries
E. Patricia trie
VII. Convex hull algorithms
A. O(n2) algorithm (using cross-products)
B. Quick hull (idea only)
C. Graham’s algorithm (idea only)
D. Reduction / optimal complexity bound
VIII. Graphs
A. Terminology
B. Representation
C. Traversal & related algorithms
1. bfs
2. dfs
D. Related algorithms
1. Prim’s algorithm
2. Dijkstra’s algorithm
3. Topological sorting
4. Strongly connected components
From here forward is ~60% of exam
E. Union-find
1. Kruskal’s algorithm
2. Components in directed graphs
F. Flow graphs
1. Flow network definitions
a) [muliple] source/sink
b) Capacity constraints
2. Maximum flow problem
a) Cancellation
b) Ford-Fulkerson method
(1) residual networks
(2) augmenting path
(3) residual capacity
c) cuts & max-flow/min-cut theorem
d) example (maximum bipartite matching)
IX. NP Completemess
A. Notion of tractability
B. Abstract problem
1. Types (decisions, combinatorial...)
C. Concrete problem
1. Definition
2. Encoding
3. Encoding efficiency
D. Language Theory
1. Terminology
2. Accept vs decide string
E. Complexity class P
1. Definitons
F. Verification algorithms
G. Nondeterministic algorithms
H. Complexity class NP
NP problems and NP-Complete problems (our intrest topic)
For NP-complete problems, although there is no effecient algorithm found for NPC probs, nobody has ever proven that an efficient algorithm for one cannot exist. in other words, it is unknown whether or not efficient algorithms exist for NPC problems. Second, the set of NP-Complete probs has the remarkable property that if an efficient algorithm exists for any one of them, then efficient algorithms exist for all of them. Third, several NPC probs are similar but not identical, to problems for which we do know of efficet algorithms. A small change to the problem statement can cause a big change to the efficiency of the best known algorithm.


1. definitons
2. relation to class P
I. Complexity class NP-Complete
1. Cook’s Theorem
2. Evidence for P NP
3. Polynomial-time reduction
4. Proof method that problem is NPC
5. Examples of NPC problems
J. Complexity class NP-Hard
1. Definitions
K. Relationship between complexity
classes