Random Post :)
October 23, 2009
I dont know where I heard this but I remember this really well … lols . I like the lyrics.
Picture Perfect Memories
Scattered all around the floor,
Reaching for the phone cause
I cant fight it any more,
And I wonder if I ever cross your mind
For me it happens all the time ……
If you know what song do let me know …
I just happened to create a webservice and a client using ASIX for a web service class. As I know that in the environment it is difficult to get things to work and minor issues can halt the process. I am posting a simple Service, Client and my configurations just in case they are helpful to any one. In my environment TOMCAT is the web container and I compile it with AXIS jar files in my classpath, deploy.wsdd is used for deployment:
I use the variable %AXISCLASSPATH% which is set in my environment variables to following:
%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery-0.2.jar;%AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\wsdl4j-1.5.1.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar;
AXIS_LIB is set to: %AXIS_HOME%\lib
AXIS_HOME is set to : C:\axis-1_4
Step 1 is to code the service: In the given scenario the service expects an integer passed to it in the GetDynamicArrayOfRandomNumbers method and it will return an array with the number of elements equal to the number passed in. It will populate the array with random numbers.
import java.util.Random;
/**
* @author Muhammad Asad Siddiqi
* 06/13/2009 Assignment 2 Web Services
* This class is used as the web service and the .class has to be copied under Tomcat/axis/webapps
* deploy.wsdd has to be used for deployment
*/
public class DynamicArrayGeneratorService
{
/*
* This is the remote method that would be called by the client
*/
public int [] GetDynamicArrayOfRandomNumbers (int nArraySize) throws Exception
{
int []arrRandomNumbers = new int[nArraySize];
for (int nCount=0; nCount < nArraySize; nCount++)
{
Random randomGenerator = new Random();
arrRandomNumbers[nCount] = randomGenerator.nextInt((nCount * 4) + 10);
}
return arrRandomNumbers;
}
}
Step 2: Compiling the service can be done by running the following commands from where your code is:
javac -classpath %AXISCLASSPATH% DynamicArrayGeneratorService.java
Step 3 is coding the client, I am copying and pasting the code for the client below:
import java.lang.*;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import java.net.URL;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;
import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
/**
*
* @author Asad Siddiqi
* Assignment # 2 Web services
* This class is the client for the service running on localhost
*/
public class DynamicArrayGeneratorClient
{
public static void main(String args[])
{
try
{
int nSizeToReturn = 0;
if ( args == null || args.length != 1 )
{
System.out.println(“The client utility has to pass in the exactly 1 parameter [size of the array]“);
System.exit(1);
}
nSizeToReturn = Integer.parseInt(args[0]);
// Create an instance of the service
Service serArrayGenerator = new Service();
// Create an instance of the Call to call the method
Call call = (Call) serArrayGenerator.createCall();
// Set the Address for connection
call.setTargetEndpointAddress(new java.net.URL(“http://localhost:8080/axis/services/DynamicArrayGeneratorService“));
// Specify the method to call
call.setOperationName(“GetDynamicArrayOfRandomNumbers”);
// Call the remote method
int [] arrReturned = (int[]) call.invoke(new Object [] {new Integer(nSizeToReturn)});
// Print the output
System.out.println(“PRINTING THE NUMBERS RETURNED BY SERVICE :”);
System.out.println(“——————————————”);
for (int i = 0; i < arrReturned.length; i++)
{
System.out.println(arrReturned[i]);
}
}
catch( Exception e )
{
// Error occured during processing
System.out.println(“Error Occured during processing …”);
e.printStackTrace();
}
}
};
Step 4: Compiling the Client can be done by executing the following command from the same directory as your client code:
javac -classpath %AXISCLASSPATH% DynamicArrayGeneratorClient.java
Step 5 : In your command prompt navigate to the directory where your deploy.wsdd file is located. Once you are in the right directory execute the following command:
java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService deploy.wsdd
Step 6: The client can be executed by again changing the directory to where the .class files were generated for the client and executing the following command:
java -cp .;%AXISCLASSPATH% edu.jhu.webservices.Siddiqui.Asad.DynamicArrayGeneratorClient 20
I am also posting the contents of deploy.wsdd file:
<deployment name=”hw2″ xmlns=”http://xml.apache.org/axis/wsdd/“
xmlns:java=”http://xml.apache.org/axis/wsdd/providers/java“>
<service name=”DynamicArrayGeneratorService” provider=”java:RPC”>
<parameter name=”className” value=”DynamicArrayGeneratorService”/>
<parameter name=”allowedMethods” value=”GetDynamicArrayOfRandomNumbers”/>
<parameter name=”wsdlServicePort” value=”GetDynamicArrayOfRandomNumbers”/>
</service>
</deployment>
If you find it useful or I was able to help you out or you have a question, feel free to comment and I will make sure to reply. Being a .Net developer this was a real pain and it sucks, I just posted to help anyone in the same boat as me.
DOM and SAX Parsing using JAVA
July 26, 2009
I am not a very proficient java developer but I can find my way after spending some time. This might help save some time who is just like me and not a real pro at JAVA
. I am posting a sample XML and the parser to parse it in DOM and SAX using Java.
Here is the xml:
<?xml version=”1.0″?>
<!DOCTYPE Syllabus SYSTEM “Syllabus.dtd”>
<Syllabus xmlns:xsi=”http://www.w3.org/2001/XMLSchema” xsi:schemaLocation=”http://www.w3schools.com note.xsd”>
<Lecture SerialNo=”1″>
<Week>1</Week>
<Date>Jun 3</Date>
<Material>Sample Material</Material>
<Reading>Sample Reading </Reading>
<AssignedHW>Sample Text</AssignedHW>
<DueHW></DueHW>
</Lecture>
<Lecture SerialNo=”2″>
<Week>2</Week>
<Date>Jun 10</Date>
<Material>Some Text</Material>
<Reading>Some Boring Text </Reading>
<AssignedHW>HW2</AssignedHW>
<DueHW>HW1</DueHW>
</Lecture>
<Lecture SerialNo=”3″>
<Week>3</Week>
<Date>Jun 17</Date>
<Material>Some Lame material</Material>
<Reading>Lame reading</Reading>
<AssignedHW>HW4</AssignedHW>
<DueHW>HW3</DueHW>
</Lecture>
</Syllabus>
Here is the code:
import java.io.File;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
public class Parser
{
public Parser()
{
}
public void doDOMParsing(String strFileName)
{
try
{
java.io.File file = new File(strFileName);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(file);
NodeList nodes = doc.getElementsByTagName(“Lecture”);
for (int i = 0; i < nodes.getLength(); i++)
{
System.out.println(“PARSED LECTURE DATA”);
System.out.println(“————-”);
Element element = (Element) nodes.item(i);
NodeList weekData = element.getElementsByTagName(“Week”);
Element line = (Element) weekData.item(0);
String strWeekData = getCharacterDataFromElement(line);
System.out.println(“Week : ” + strWeekData);
NodeList dateData = element.getElementsByTagName(“Date”);
line = (Element)dateData.item(0);
String strDateDate = getCharacterDataFromElement(line);
System.out.println(“Date : ” + strDateDate);
NodeList materialData = element.getElementsByTagName(“Material”);
line = (Element)materialData.item(0);
String strMaterial = getCharacterDataFromElement(line);
System.out.println(“Material : ” + strMaterial);
NodeList readingData = element.getElementsByTagName(“Reading”);
line = (Element)readingData.item(0);
String strReading = getCharacterDataFromElement(line);
System.out.println(“Reading : ” + strReading);
NodeList assignedHWData = element.getElementsByTagName(“AssignedHW”);
line = (Element)assignedHWData.item(0);
String strAssignedHW = getCharacterDataFromElement(line);
System.out.println(“Assigned HomeWork : ” + strAssignedHW);
NodeList dueHWData = element.getElementsByTagName(“DueHW”);
line = (Element)dueHWData.item(0);
String strDueHW = getCharacterDataFromElement(line);
System.out.println(“Due HomeWork : ” + strDueHW);
System.out.println(“——————————–”);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
/* This is the helper function to get Element Data in DOM Parsing */
private String getCharacterDataFromElement(Element e)
{
try
{
Node child = e.getFirstChild();
if(child instanceof CharacterData)
{
CharacterData cd = (CharacterData) child;
return cd.getData();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
return “”;
}
/* This is the innerclass that inherits from Default Handler for SAX Parsing */
class SAXHandler extends DefaultHandler
{
boolean bWeek = false;
boolean bDate = false;
boolean bMaterial = false;
boolean bReading = false;
boolean bAssignedHW = false;
boolean bDueHW = false;
public void startElement(String nsURI, String strippedName,String tagName, Attributes attributes) throws SAXException
{
if (tagName.equalsIgnoreCase(“Week”))
bWeek = true;
if (tagName.equalsIgnoreCase(“Date”))
bDate = true;
if (tagName.equalsIgnoreCase(“Material”))
bMaterial = true;
if (tagName.equalsIgnoreCase(“Reading”))
bReading = true;
if (tagName.equalsIgnoreCase(“AssignedHW”))
bAssignedHW = true;
if (tagName.equalsIgnoreCase(“DueHW”))
bDueHW = true;
}
public void characters(char[] ch, int start, int length)
{
if (bWeek)
{
System.out.println(“Week : ” + new String(ch, start, length));
bWeek = false;
}
else if (bDate)
{
System.out.println(“Date : ” + new String(ch, start,length));
bDate = false;
}
else if (bMaterial)
{
System.out.println(“Material : ” + new String(ch, start,length));
bMaterial = false;
}
else if (bReading)
{
System.out.println(“Reading : ” + new String(ch, start,length));
bReading = false;
}
else if (bAssignedHW)
{
System.out.println(“Assigned Homework : ” + new String(ch, start,length));
bAssignedHW = false;
}
else if (bDueHW)
{
System.out.println(“Due Homework : ” + new String(ch, start,length));
bDueHW = false;
}
}
}
/* This is the entry point where SAX Parsing starts */
public void doSAXParsing(String strFileName )
{
try
{
SAXParserFactory saxFactory = SAXParserFactory.newInstance();
SAXParser saxParser = saxFactory.newSAXParser();
SAXHandler handler = new SAXHandler();
saxParser.parse(new File(strFileName),handler);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
/* This is the driver function from where the DOM AND SAX parsing has to be called
The file name has to be passed in like “Syllabus.xml”
*/
public static void main(String []args)
{
try
{
String strFileName = “..\\resources\\Syllabus.xml”;
String strParsingMode=”";
if (args.length != 1)
{
System.out.println(“The valid values of the parameter passed in are DOM and SAX. Press any key to continue:”);
int a = System.in.read();
System.exit(0);
}
Parser driverParser = new Parser();
strParsingMode = args[0];
if (strParsingMode.equalsIgnoreCase(“dom”))
{
System.out.println(“DOM PARSING”);
driverParser.doDOMParsing(strFileName);
}
else if (strParsingMode.equalsIgnoreCase(“sax”))
{
System.out.println(“SAX PARSING”);
driverParser.doSAXParsing(strFileName);
}
else
{
System.out.println(“The parsing mode can be DOM or SAX”);
System.exit(0);
}
}
catch(Exception ex)
{
System.out.println(“Error Occured while processing”);
ex.printStackTrace();
}
}
}
To me how SAX parsing is implemented using Inner classes was really interesting . I hope it helps someone looking for some help and finds it
Getting started with AJAX in ASP.Net:
April 2, 2009
As a prerequisite you would require to have Microsoft Visual Studio 2008 installed on your system. Alternatively you can also have Microsoft Visual Studio 2005 with AJAX extensions for ASP.Net installed. This would be a very basic example just to get you started and will touch the basics of writing AJAX enabled web applications using Visual Studio and ASP.Net.
So What is AJAX and what is the use ?
AJAX is the abbreviation of “Asynchronous JavaScript and XML”. It is a technique in web development that is used to greatly improve the responsiveness and performance of a web application thus resulting in a great user experience. To understand how it works you should understand how the old web applications worked, how it all started, what is java script and what do we exactly mean by AJAX?
As web applications were hosted and running on a web server, the browser simply accessed the application on a server and rendered the html produced for the user.
“Ever wondered why it took a long time after you clicked a button and when you look at the status bar its slowly moving and after some time it comes back with the response”.
This was mostly the case not with static websites but web applications where a lot of processing was done on the server side based on events like pressing a button. The page would “postback” and provide the server the necessary input. On the event handler there would be some validations and then some processing and then typically another “postback” updating the user. As more users complained that the application was not responsive enough or too slow, more techniques evolved to process minor data on the client side using javascript. Typically these would be tasks like client side input validations, dynamic menus and conversions displaying time and things like that.
The end user liked the experience as the application was much more responsive and wont go back to the server to process each and every piece of information (postback) .
So this idea was refined and the AJAX technologies were introduced and including in all the major web development frameworks. If you are reading this off course you are not an AJAX Expert , you just want to know how you can use AJAX in your application to make it more responsive or just for the heck of it J .
So here is how you do it with ASP.Net using Visual Studio 2008.
1/ Create a new website and name it as AJAXExample. This can be achieved by File -> New -> Website and selecting ASP.Net Website from the installed templates.
2/ Visual Studio .Net will generate the basic skeleton application by generating the following files (pages):
Default.aspx
Default.aspx.cs
Default.aspx is the actual page where all the controls or (html elements are). The Visual Studio IDE enables you to switch between Design View and Source View. Design view is where you can look how the page looks like and the source view is the html view of the page.
3/ Be in the design view and the first control to be dragged and dropped on the page must be “ScriptManager”. This is located under “AJAX Extensions”. Visual studio will rename it as ScriptManager1 and will add the following code when you switch to source view:
<asp:ScriptManager ID=”ScriptManager1″ runat=”server”>
</asp:ScriptManager>
Note: This should be the first control in the page. It tells the asp.net worker process that this application or page uses AJAX and the required “dlls” have to be loaded in memory.
4/ Add the controls whatever is required in your application. For the sake of simplicity I will add a textbox and 2 buttons in the design view. The visual studio will generate the following code in the source view.
<asp:Button ID=”Button1″ runat=”server” Text=”Hello” onclick=”Button1_Click” />
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>
<asp:Button ID=”Button2″ runat=”server” onclick=”Button2_Click” Text=”Clear” />
5/ Define the event handlers in “Default.aspx.cs”.
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = “Hello”;
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = “”;
}
6/ Add the following code in your html before and after your controls code. So the controls you want to process without postbacks has to be wrapped around this block:
<asp:UpdatePanel id=up1 runat=server>
<ContentTemplate>
// Controls here
</ContentTemplate>
</asp:UpdatePanel>
7/ Run the application and Enjoyeee ! In the same way you can put more controls in a page like gridViews comboboxes and list boxes or even databound controls and use it without causing the application to postback.
I am copying and pasting the contents of my code files:
Default.aspx
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title>Untitled Page</title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div style=”height: 295px”>
<asp:ScriptManager ID=”ScriptManager1″ runat=”server”>
</asp:ScriptManager>
<asp:UpdatePanel id=up1 runat=server>
<ContentTemplate>
<asp:Button ID=”Button1″ runat=”server” Text=”Hello” onclick=”Button1_Click” />
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>
<asp:Button ID=”Button2″ runat=”server” onclick=”Button2_Click” Text=”Clear” />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = “Hello”;
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = “”;
}
}
An ExpressionTree in C++
December 19, 2008
I implemented an expression tree in Object Oriented Style and that was one of the homework i had for a class at school.I hated it a lot, but finally when completed I liked it a lot, ahhhhhh felt really like i have achieved something. By the way this is a good example of polymorphism and inheritence and the concept of virtual functions and abstract base classes (if you know what I mean ? ) Many of us do all this stuff in school and keep it to school. We never design types like that at work or someone else doesnt because we dont have the time to spend in design (at least nowhere i worked people had the time to design) but oh well !!
The logic is as Follows:
An Expression Tree consists of Nodes.Nodes can be of different types (Operators , Constants , Variables). All nodes can print themselves and allow their derivative to be taken which also is a expression tree . The derivative has to be taken with respect to a variable and the expression tree can be evaluated by plugging in a value of the variable from a look up table or symbol table …
I am posting the code (of the header file and the driver program) just in case it interests anyone. Your comments and feedback is welcome and you can get a working copy of code if you want. Leave your email address as a comment and i will send you the copy. This is not finished as i did not implement the destructors but you will get the idea.
#include <iostream>
#include <map>
#include <string>
#include <math.h>
using namespace std;
/******************************************************************************************
Muhammad Asad Siddiqi
Making an Expression Tree Representation, given an expression
This files contains the prototype for following classes
-GenericNode
-VariableNode
-BinaryOperatorNode
- AdditionNode
- SubtractionNode
- MultiplicationNode
- DivisonNode
-UnaryOperatorNode
- NegateNode
- SineNode
- CosNode*******************************************************************************************/
class
PoorManSymbolTable {
private:
std::map<std::string,double> symbolTable;
public:
PoorManSymbolTable();
void InitializeSymbolTable();
double getSymbolTableEntry(std::string symbol);
};
//——————————————————————————————// This class represents a Generic Node
class GenericNode
{
public:
GenericNode();
virtual double EvaluateNode() = 0;
virtual void PrintExpression() = 0;
virtual GenericNode *Clone()= 0;
virtual GenericNode* TakeDerivative(std::string variable) = 0;
};
//—————————————————————————————–// This is the node that represents a constant like 15
class ConstantNode : public GenericNode
{
private:
double value;
public:
ConstantNode(doubleconstant);
double EvaluateNode();
voidPrintExpression();
ConstantNode *Clone();
GenericNode* TakeDerivative(std::string variable);
};
//————————————————————————————
// This node represents a Variable like ‘X’
class VariableNode : public GenericNode
{
private:
std::string symbol;
PoorManSymbolTable symbolTable;
public:
VariableNode(std::string variable);
double EvaluateNode();
void PrintExpression();
VariableNode *Clone();
GenericNode* TakeDerivative(std::string variable);
};
//—————————————————————————————–// This is the node that represents a binary Operator ( + , – , * )
class BinaryOperatorNode : public GenericNode
{
protected:
GenericNode *left;
GenericNode *right;
public:
BinaryOperatorNode(void);
BinaryOperatorNode(GenericNode *leftOperand , GenericNode *rightOperand);
GenericNode* TakeDerivative(std::string variable);
};
//—————————————————————————————–// This is the node that represents a unary Operator ( + , – , * )
class UnaryOperatorNode : public GenericNode
{
protected:
GenericNode *childNode;
public:
UnaryOperatorNode(void);
GenericNode* TakeDerivative(std::string variable);
};
//—————————————————————————————–// This is the class that represents a + operator
class
AdditionNode : public BinaryOperatorNode
{
public:
AdditionNode(GenericNode *leftOperand , GenericNode *rightOperand);// realize the pure virtual function
double EvaluateNode();
void PrintExpression();
AdditionNode *Clone();
GenericNode* TakeDerivative(std::string variable);
};
//—————————————————————————————–
// This is the class that represents a – operator
class SubtractionNode : public BinaryOperatorNode
{
public:
SubtractionNode(GenericNode *leftOperand , GenericNode *rightOperand);
// realize the pure virtual function
double EvaluateNode();
void PrintExpression();
SubtractionNode *Clone();
GenericNode* TakeDerivative(std::string variable);
};
//—————————————————————————————–// This is the class that represents a * operator
class MultiplicationNode : public BinaryOperatorNode
{
public:
MultiplicationNode(GenericNode *leftOperand , GenericNode *rightOperand);
// realize the pure virtual function
double EvaluateNode();
void PrintExpression();
MultiplicationNode *Clone();
GenericNode* TakeDerivative(std::string variable);
};
//—————————————————————————————–// This is the class that represents a / operator
class DivisonNode : public BinaryOperatorNode
{
public:
DivisonNode(GenericNode *leftOperand , GenericNode *rightOperand);
// realize the pure virtual function
double EvaluateNode();
void PrintExpression();
DivisonNode *Clone();
GenericNode* TakeDerivative(std::string variable);
};
//—————————————————————————————–// This would be used to negate a node
// Return a negative when evaluate is called
class NegateNode: public UnaryOperatorNode
{
public:
NegateNode(GenericNode *argChildNode);
double EvaluateNode();
NegateNode *Clone();
void PrintExpression();
GenericNode* TakeDerivative(std::string argSymbol);
};
// ————————————————————————————–
// This would be used to create a Sine Operator in the Expression Tree
// It is a unary operation and derivative is a cos Node
class SineNode : public UnaryOperatorNode
{
public:
SineNode(GenericNode *argChildNode);
double EvaluateNode();
void PrintExpression();
SineNode *Clone();
GenericNode* TakeDerivative(std::string argSymbol);
};
//—————————————————————————————–// This would be used to create a Cos Operator in the Expression Tree// It is a unary operation and uses negation in derivative
class CosNode : public UnaryOperatorNode
{
public:
CosNode(GenericNode *argChildNode);
double EvaluateNode();
void PrintExpression();
CosNode *Clone();
GenericNode* TakeDerivative(std::string argSymbol);
};
// The driver program
int
_tmain(int argc, _TCHAR* argv[])
{
GenericNode *objGenericNode , *cloneTest , *derivativeResult;
ConstantNode *var1 = new ConstantNode(45);
ConstantNode *var2 = new ConstantNode (25);
VariableNode *var3 = new VariableNode(“Xray”);
VariableNode *var4 = new VariableNode(“Yellow”);
objGenericNode = new MultiplicationNode(new AdditionNode(var3,var4),new CosNode(var2));
cloneTest = objGenericNode->Clone();
cloneTest->PrintExpression();
cout << endl <<“Printing Derivative of Expression Tree … “ << endl;
derivativeResult = cloneTest->TakeDerivative(“Xray”);
derivativeResult->PrintExpression();
return 0;
}
Notely: This is not about parsing an expression by putting it on 2 stacks using Infix or Postfix notation . This is an implementation of an expression tree where the structure of the tree is known
. I could not post the implementation but would be provided on request .
Where is the C++,C# and UML …
November 30, 2008
And for those of you thinking where are all the while loops and pointers and my keen .Net Tutorials and object oriented designing thoughts some stuff is coming soon enough , just busy with some projects and I will put the design here for your consideration. For right now though , the focus is on the stock market (Laugh out loud)
…. Take care
Technology stock bargains for 2009
October 27, 2008
I am not an experienced investor at all. I wish I were. Perhaps this is one of the bad economic times and the recession seems to be a global one but should you invest now or track back and take all your money out even at a loss? There are many things that I cannot understand as far as investing money is concerned. Can anyone help me figure that out with some logic and experience after reading my point of view?
First off I am not from a very rich background so all these terms like Mutual Funds, EFTs,401 K and Money Market Savings are kind of new to me. I do have a solid understanding of how these works and what people do to diversify their portfolios. But I have my own point of view and intuition about the market and I have no short term plans.
So wherever I have read about the collapsing economy, credit crisis and recession the best advices seem to be “Take all your investments out and sit on your cash”!! Sounds pretty reasonable as if your investments are in the market especially equities they will loose their value and you will see your investments wiped out!! About right. BUT what happens when you are done with this recession and the market changes from Bear to Bull. Don’t you get all your investments back? I mean still the background info is required with company insight business domain and technical analysis of how well the company does financially but generally speaking I would think more companies do well and the market indices rise. You get more returns to your investments. So to conclude when the chips are down everyone takes their investments out, even cut back their 401 K contribution? Doesn’t sound right to me at all!!
You can make a maximum profit especially in equities if you buy at their minimum and sell at the maximum right but I wish someone could have told me when is the minimum and maximum J . Unfortunaly we never and can’t know that but that’s the job for financial analysts. I read many financial analysts and most of them seem optimistic about the future and YES everyone does admit that we are in one of the worst economic times. So to me this indicates a trading and investing opportunity. Big brand stocks on sale I should say on clearance….. Do you think that every company is going to be eventually bankrupt as we are in recession? The world is going to stop? I really don’t think so. However if you are looking at very short term I think it’s very logical not to invest in the stock market. It’s highly unlikely you get positive returns on your investments and it’s highly unpredictable. There are a number of great companies out there who will set records for profits and growth. And if you happen to be a lucky investor you might be very happy otherwise if the recession is over you will just be happier.
I am not an advocate of compelling you to invest in the stock market and I am certainly not an experienced investor as well. Being from the IT background I know what some IT companies are doing and what is in demand at this point in time … My interest lies with the Technology sector of the stock market and I plan to invest some of my savings in these companies early 2009 and leave the investments for a year and see how I did on my first investment venture. Any thoughts, ideas, plans and observations, corrections are highly welcome. Feel free to comment on my observations, discuss a trading strategy or discuss about the research that I put in for these companies. To be short things I look for to estimate the potential is the business domain, major competition, balance sheet, growth, future prospects, msn ratings, earning estimates for next year and a global presence.
· Google(GOOG)
· Adobe (ADBE)
· Ceragon Networks (CRNT)
· Quest Software (QSFT)
· BMC Software (BMC)
· Cognizant technology Solutions (CTSH)
· Synopsys(SNPS)
· NCR Corporation(NCR)
How to generate WCF Client Proxy Class using svcutil.exe
October 25, 2008
I wanted to use wcf because I read about it and like the power and clean implementation which is highly configurable without a lot of effort. I have used and made many clients for web services using Visual Studio .Net and all it requires is to know where the web service is hosted. When you add a service reference and pass in a url where it is hosted (WSDL) the IDE generates a proxy class and WOW !! there you go… Call the methods in ur client, no fuss at all clean , nice and smooth. I was under the impression that WCF is esentially the same and support many other types of bindings like http,tcp blah blah ….. So i started developing the Kool WCF server client application. Little did I know about generating the client proxy class using svcutil.exe . I knew that you can generate proxy classes using svcutil.exe but that is a painful painful process. A little up and down and it gives you exceptions that are very easy to understand [ Devilish smile ] . So to save you the time and effort that you will have to put it to generate proxy classes I will show you the exact app.config file and how to use the svcutil. You can simply copy and paste it and be happy [just rename the Contracts , end point info according to your own and you are good to go] …
I have changed the font to BOLD whatever i was missing and was required by svcutil to generate the proxy class that I used.
Here is my app.config in the Hosting Application (server) from where the service would be run:
<?xml version=“1.0“ encoding=“utf-8“ ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name=“mex“>
<serviceDebug includeExceptionDetailInFaults=“true“ />
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name=“WCFServiceLibrary1.service1“ behaviorConfiguration =“mex“>
<endpoint address=“net.tcp://localhost:6587/Service1/“
binding=“netTcpBinding“
bindingConfiguration=“TestBinding“
name=“RoleEndPoint“
contract=“WCFServiceLibrary1.IService1“ >
<identity>
<dns value=“localhost“ />
</identity>
</endpoint>
<endpoint
address=“mex“
binding=“mexTcpBinding“
name=“MEX“
contract=“IMetadataExchange“ />
<host>
<baseAddresses>
<add baseAddress=“net.tcp://localhost:6587/Service1/“ />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name=“TestBinding“ maxBufferPoolSize=“524288“ maxReceivedMessageSize=“65536“ portSharingEnabled=“false“>
<readerQuotas maxDepth=“32“ maxStringContentLength=“8192“ maxArrayLength=“16384“ maxBytesPerRead=“4096“ maxNameTableCharCount=“16384“ />
<security mode=“None“ />
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
Observe that there is an endpoint defined for metadata exchange called mex. This is used by the svcutil to generate the proxy class. The behavior node also contains a behavior named as mex. Now you are all set to use the svcutil.exe. Simply open the Visual Studio Command prompt from your startup menu à Visual Studio à tools and Command Prompt and type in the following command:
(Remember to replace the name to the service with yours as defined in the server configuration file)
Hope it helps and save you time and effort and I wish you don’t have to go through the pain of getting svcutil to work. Happy Coding !!
C:\Program Files\Microsoft Visual Studio 8\VC>svcutil.exe net.tcp://localhost:6587/Service1/mex
This will generate two files service1.cs (proxy class for the client) and output.config (the app.config for the client). Enjoy !!
Using Windows Communication Foundation WCF with Visual Studio 2008:
October 21, 2008
There is a lot of hype about new (not so new now) technologies from Microsoft and the new architectures that are now a part of Microsoft .Net development environment. These include Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF) and Workflow Foundation (WF).
I will give a brief introduction about what these are just in case you are not familiar. Anyways if you are then probably this article is no good J since I just started working with these. This will help you get a quick start in case you are a starter and I have gathered the info skimming through tutorials and I want to give you something quick and easy. So to start off “What is WPF?” WPF exclusively has everything to do with the UI or user interfaces. Till .Net 2005 the Graphics were GDI (Graphics device Interface) based and in WPF they are Direct X based thus utilizing the faster video card acceleration and fast memory access as compared to the GDI. Secondly this used to be an issue when clients wanted fancy UI e.g. Elliptical buttons, Window Layouts, Animated menus and colors in controls. Microsoft made it possible with user controls to some extent but off course the mainstream developers didn’t want to get in that mess and always wanted to use the default controls with some styling that the client wont like. Customers these days doesn’t want “just another windows button” there should be something innovative about it so WPF enables you to define your own controls with XAML pronounced as (zammel).
The styles, colors, shapes, data bindings and everything that is a part of the control can be done using XAML which is simple xml just defined somewhat like html ( I always see the elements and attributes notations) whenever I see XAML.
So WPF is for UIs and probably an effective solution for at least Windows Vista if not XP. Just as with the “User Interfaces” Microsoft realized that “Services Oriented Architectures” are gaining in popularity. With Central server centric applications and Microsoft efforts to support the SOA with applications like “BizTalk”, “SharePoint” e.t.c something also needed to be done to provide a standard platform for network programming using .Net. Microsoft came with WCF which is a powerful framework for writing and utilizing or consuming web services , windows services , .Net Remoting without needing to write a whole lot of socket interfaces. The implementation is hidden in the components constituting the WCF. WCF like WPF depends heavily on configurations and it is usually a good idea to separate the business logic from the configurations or the (app.config) file. In this article I will demonstrate writing a simple client server program using WCF which will give you some bare essentials for WCF and will help you to explore more in the ever growing world of emerging technologies.
By the way just to get you started if you are not familiar with the client server paradigm, client server application that I am going to develop would be basically two applications. A Server application will let many clients connect to it and say “Hi”. Keeping in mind this is not to tell you how to design better client server applications this is all about getting you up and running with WCF. Ok my friends so don’t get angry =]
Designing the Client and Server with WCF:
Primarily while designing the application remembers there should be something common in the client and server. To explain this better ask yourself the question “How is client going to interact with the Server”? There should be some interface the server should provide to achieve this. If you are familiar with web services think of wsdl (web services description language) that exposes the web service API. So just like that the WCF Service also exposes interfaces. The clients can generate the proxy classes for the API and will call those API methods to communicate with the Server with underlying implementation of Sockets and communication mechanism). I will discuss “How to generate the proxy classes” but first things first “Decide what should the Server be like”? And “what functionality you want to expose”?
So just for the sake of simplicity just think that what the server wants to expose and client wants to consume is 1 single functionality called send message.
The First Step in Writing the Server:
I consider adding the “system.servicemodel” reference a prerequisite to every WCF application so if you have not already added that do make sure the reference is included in the list of your references.
1/ Add a new interface to your solution. I named the solution as WCFServer so the namespace here is WCFServer. I named the interface as CommonInterface just to be clear what this does. This would be the API exposed for the client and would be executed on the server. Good naming convention for this would be to prefix the name of the class with an “I” so something like ICommonInterface but that’s something you know right.
namespace WCFServer
{
[ServiceContract]
public interface CommonInterface
{
[OperationContract]
void SendMessage(string msg);
}
}
Observe that there are two things here which might be new to you. The interface is marked as “ServiceContract” which is the attribute which specifies that this is the contract between the client and server.The other thing is the method is marked as “OperationContract”. For the time being just think that every method in this interface should be marked as an “OperationContract”. This method is what will be executed on the server and what the client will call from the “Client code”.
Second Step is to implement the Interface with your server class:
Give a meaning to the interface by implementing it in your server side code.How to do that is declare a class in your program and name it appropriately and inherit it from this interface that we defined in step 1. For our sample application I defined the server class as shown in the definition below:
namespace WCFServer
{
class Server : CommonInterface
{
public void SendMessage(string msg)
{
Console.WriteLine(“Message from client –> “ + msg);
}
static void Main(string[] args)
{
Console.WriteLine(“Starting the server …”);
ServiceHost host = new ServiceHost(typeof(Server));
host.Open();
Console.WriteLine(“Server started successfully at…Pressing a key would cause the server to shut down …”);
Console.ReadLine();
host.Close();
}
}
}
So if you look at the code closely you will find the implementation of the “SendMessage” function that will be called by the client and a message would be passed and displayed on the Server’s console window.
If you look at the Main function the first thing that we do is to declare a Service Host and specify the sever’s type. Then use the Open method of the service host to start the service.
Our server at this point is up and running and waiting for the clients to say “Hi”. How to write the clients will be discussed in the next article. Hope this helps getting you a quick start of essentially what it is and if you have any ideas, observations I would love to hear from you in the form of comments.Stay tuned for more and thanks for reading.Happy Coding !!
Here are the Configurations necessary for the configurations:
<?xml version=“1.0“ encoding=“utf-8“?>
<configuration>
<system.serviceModel>
<services>
<service name=“WCFServer.Server“>
<endpoint address=“net.tcp://localhost:5555/Server“ binding=“netTcpBinding“
bindingConfiguration=“” contract=“WCFServer.CommonInterface“ />
</service>
</services>
</system.serviceModel>
</configuration>
You can use the “svcconfigeditor.exe” to generate this so you don’t have to memorize this simply go through a wizard and save the file as app.config and copy and paste.The svccinfigeditor can be found at “C:\Program Files\Microsoft Visual Studio 8\Common7\IDE”
Why I hate Open Source ?
May 30, 2008
NOTE : The content below may be offensive for some people and the language used is not very appropriate. Parental Guidance is highly recommended . This is what I realized after your response and is not a part of the original content !! All the following text is based on true experience and I am not paid by Microsoft to hate Open source , i simply dont have the time and stemina to keep going on and on forever
Hello everyone, often while going through details on this topic there are 2 groups of people who are highly opinionated and rigid about their ideas for OPEN Source Vs Licensed Software or for the sake of simplicity call it Microsoft
………………… Yah yah , i know its free [OPEN SOURCE] and the microsoft supporter wud say “You get what you pay for” hehe yah rite
…………..
Let me share a very hillarious experience with another upcoming technology called Ruby on Rails having all the nice features and a powerful framework doing all the stuff for you. I read about it , loved it for rich functionality that these guys put together for quick and rapid application development. I went ahead and checked out a”Tutorial on Ruby On Rails” that was on OnLamp.com and also saw a couple videos on you tube where they were teaching on how to configure the webrick server and get going with the MYSQL database and put in some quick data driven web applications.
I felt absolutely convinced that this is going to be the future of webdevelopment . Like configure a file (called database.yaml or something) and it wud design the UI for you with a feature called dynamic scaffolding ( what the efff !! Are you fuckin jokin ?? ). Wasnt to be for me =] so infact they were fucking joking . I downloaded the Installer i think it was version 2.6.1 or something and installed it , installed MySQL database and tried to write my Hello world application with the technology !!
Believe me it was a pain , i could not say hello at all. It had some routing issues with http/get then it could not find something and i read the forums and all that to figure it all out.After an hour’s effort or so i was able to write a “Hello World with Ruby on Rails” .
The feature i absolutely loved when i read the tutorial was dynamic scaffolding , simply write the datatypes and based on that Ruby knows ” whatch u r upto ” ? or does it ??. I instantly wanted to use it , so i declared a couple of text fields in the database , did all the stuff necessary to see my two labels and textboxes apper on the hello world page. Just refreshed and got an error !! again checked everything “Not working” :S … I was getting angry “What the eff !! ” this that and the other … gimme a break , you 10 minutes dynamic website developers !!
I was still determined to give this a shot because it was worth it , just configure the database and no code , your front end is ready with all the CRUD features , WOW , whooooooaaa !! Yeah babes
Yehhhhh !! i m Loving it (McDonalds Style) !! So i checked out the documentation of the specific version and believed that its something i m missing …. not to long after that the official website proudly said “All Ruby On Rails existing Tutorials are no more ………….. Haha (devil face)” .. We finished em all (devilish smile) … Oh yah !! we dont support any basic stuff which is the chapter 1 in all tutorials that ever existed in the History of the technology !!! “Up urs Tutorials (i mean the middle finger)”!!
Yah ?? What the eff !! hahaha u r so proud of it ? it is retarded dudes !! Cant you do it in the background !! yeah all those optimizations !! Did you realize how difficult it is to follow it for the new developers who want to use it !! ahhh U r bad and evil people !!
So this was just my experience and i hated it , hated myself for wasting 6 hours on my life on this loosing technology , i swear if it was microsoft , it would have been a big deal where every wanna B would be commenting on that on but after this “effyyy experience ” I say “Go ASP.Net” and “Go Microsoft” and I “absolutely hate open source” …..
Have a kool experience with Open Source ? Or a worse experience with Microsoft ?? I would love to hear it !!
NOTE : Some people who have similar reasons to hate OS :
http://www.adequacy.org/stories/2002.5.29.234020.354.html
http://www.madpenguin.org/cms/?m=show&id=7827
http://www.bleepsoft.com/tyler/?itemid=47
http://www.theregister.co.uk/2003/11/24/princeton_opensource_hater_a_loose/
http://linuxhaters.blogspot.com/2008/05/open-source-branding.html
http://www.lockergnome.com/linux/2006/05/03/linux-hatertraitor-turns-to-windows/
http://community.zdnet.co.uk/blog/0,1000000567,10005747o-2000460739b,00.htm
Perhaps i m not the only one :O [Check these ones out ]