Sunday, February 3, 2008
Mysql::Error: Unknown system variable 'NAMES': SET NAMES 'utf8'
This error occurs if you are using rails 2.0.2.
As far as I understood, in case of rails 2.0.2 when we create a new project, the default database adapter is SQLlite.
In order to use mysql, one need to explicitly tell,
rails -d mysql cookbook
Assuming that you have already created the three database tables: cookbook_development, cookbook_test, cookbook_production,
if you look at the database.yml file that is present in the config folder, you will see the the following lines
development:
adapter: mysql
encoding: utf8
database: cookbook_development
username: root
password: your_password
host: localhost
similarly for test and production.
The singular pint is the addition of the new line encoding: utf8. This is a new addition, if you were using rails version <= 2.0.1, this line is missing.
So I removed the line from development, test, production settings so that my database.yml now looks as
development:
adapter: mysql
database: cookbook_development
username: root
password: your_password
host: localhost
Now if you again run the server and try to access any function of the project from the browser the error wont occur.
Saturday, February 2, 2008
Use of collaborative tagging in understanding social behavior
In this article I will talk about
1. Advantages of delicious tags
2. Social aspects of tagging
3. Problems of tagging systems
Collaborative tagging is the practice of allowing anyone to attach keywords/tags to the content.
Tagging is different from the normal categorization that we see in libraries. It does not follow any hierarchical rules like in dewey decimal system. User can simple say an article is on “C” rather than using saying computers/programming/C
Tags are generally given as per the users understanding of the topic. An article may be on web programming, but a user feels that for him to refer to the same topic its more relevant to give the tag as web2.0, then he will categorize as web2.0
We will be looking on the tagging patterns of the users on the Delicious site (http://del.icio.us). Just a small overview of the delicious site:
1. The site allows the user to bookmark the URLs and categorize them using tags
2. When you are trying to tag a URL, delicious will suggest what all tags other people have given to this URL
3.Delicious gives the information about the number of the users who have tagged this URL. The higher number suggests popularity of the URL
4.One main advantage of deleicious is networking and social aspect. You can visit the deleicious page of a use and see his bookmarks. You can get the RSS feeds of other users tags. This way you can find out the various relevant URLs on a particular topic. This is very useful. Consider the scenario, you want to learn something about web2.0. You did Google for it got some results. Now Google results just list down the URLs having the keywords web 2.0. It does not tell anything about what is the standard of the information given on the page or how other people think about it. May be you are a beginner on the topic of web2.0 and you are looking for a guide for beginners or some pointers how to start on the topic. In this scenario its good if you can find out what others recommend to refer as a beginner. This is the same as before buying any book you would like to see the reviews on Amazon about the book.
5. Delicious also gives a list of the various tags that were provided by the other people to the particular URL. This gives an indication of the different understanding of the people for the particular URL. Also the various categories that describe the URL gives the indication some of the key features that you can expect from the URL. For e.g. an article on flex may be tagged as programming, Flex2, web2.0, RIA. This shows the various categories that are appropriate for the particular URL. It indicates that Flex2 has something to do with programming, web related programming( web2.0), is used in current development (RIA, Web 2.0)
Delicious allows the users to check the tags of other users this is the collaborative part of delicious.
This article is not about the delicious so I will be very brief about discussing about delicious. One can refer to the site for more details.
Lets see some of the social aspects of the tagging
1. As already discussed, the way a user tags the URL shows his understanding of the topic. An article on flex, can be tagged as “programming” by one user say A and “RIA”, “web2.0” by another user say B. This indicates that there is a high possibility that A has got not much understanding of flex or RIA. While B has an understanding of the latest web technologies.
Now the social aspect is that if a person C wants to find out the articles or references on the topic of RIA, he can get to the delicious site of B and there is a high possibility that he will get lot of relevant bookmarks on the various web2.0 related topics like RIA, flex. C can add RSS feed of B and can get updated to the various posts done by B.
2. Delicious also provides a timestamp on when the tag was done.
Also one can do two kinds of queries
1. For a URL find out who all have tagged that url and what all tags they have given
2. For a given tag find out the various URLs that have been tagged.
Timestamp and the information about who all have tagged a particular URL can give lot of insights about the user. The following are some of the information
1. If the timestamp is not much old, it means the user is currently interested in the particular topic
2. If the tags the user has given are very specific it means the user has a good understanding of the topic and he can be of help if you are also interested in the same topic.
3. On the other hand if the timestamp is old that means the user is not currently tagging the articles on this topic may be he is not currently interested in that area. Or if the tags are very generic probably the user’s understanding on this area is not very good, so you may not want to be guided by this users bookmarks on that topic.
By delicious poplar tags, the areas that are currently hot can be known. For e.g. the most popular tags as on 3rd feb 2008 are
This shows that the field of interest/trends of the majority of users is web (blog,web2.0,web design). So there is a good chance that you can easily get valid URL references on the topics related to web
Some of the problems with Tag.
Since there are no rules to give tags, lot of inconsistency exists in the way people tag
1. Some people may say socialnetworking others may say social_networking. Now if you search as deleicious/tag/socialnetworking you will not get the urls under social_networking even though both tags are relevant for the topic “social networking”
2. Other major problem is synonyms. Some people say television others will call TV. The topics are exactly same but the search results will miss out the URLs.
3.Spellings-: some people may use british English and tag “colour” while people using ameriacan English tag as “color” for an article on colors.
4. Plurals: This is again a problem. Some people may tag “blog” others may tag “blogs”. They are referring to same but because of the plural the search results will be different.
I have covered what I understood from tagging, comments are welcome on this topic.
References
1. Delicious site: http://del.icio.us
2. The structure of collaborative tagging systems, scott Golder, Bernardo Huberman
3. del.icio.us mashups, Brett O'Connor, Wrox publications
4. Patterns and Inconsistencies in Collaborative Tagging Systems: An Examination of Tagging practices, Margaret Kipp, D.Grant Campbell
Saturday, January 12, 2008
SQL Error while using WebParts
The webpart requires the sqlserver 2005 for its working. The webpartmanager is looking for SQL Express 2005 which, by default, is the personalization provider. Now if you remove the SQL server Express 2005 and instead install SQL Server 2005 then vs2005 is not able to find out the location of sql server and throws an error regarding SQL server 2005.
The following steps will help in removing this error
1. Open the visual studio command prompt and type aspnet_regsql.exe. This will open up a wizard to set the SQL server settings
2. Click next next till you click finish in the wizard. This will create a default database aspnetdb in the SQL Server 2005
3.Open the SQL server management and check the name of the server: In my case it is INHCJITBZR1SL. This is actually same as the computername.

4. Open the web.config file. Add the following lines.
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="SERVER=INHCJTBZR1SL;Integrated Security=true;Initial Catalog=aspnetdb" providerName="System.Data.SqlClient"/>
</connectionStrings>
<remove> will remove the old settings about the sql server.
Basically you are trying to tell .NET where to find teh SQL server using the connection string.
Compile the code and run it again. It should work. If still the database related error is coming it means that the connection string is not correct.
Some of the other links which talk about the same issue are:
http://blogs.neudesic.com/blogs/pete_orologas/archive/2006/06/14/162.aspx
http://daron.yondem.com/CommentView.aspx?guid=cb37f9ff-81d3-4b9c-ab97-18e9eddd9a27
Wednesday, January 9, 2008
Tag cloud is a cool technique that is used to categorize your posts, bookmarks, articles. The del.icio.us site is one of the most popular place where you can find the tag cloud use in action. Tagging (as it is commonly called) is one of the Web 2.0 feature.
The default templates available on blogspot don't give you the feature of tag cloud.
In order to add the tag cloud to your blog site follow the steps as explained in the following link
http://phy3blog.googlepages.com/Beta-Blogger-Label-Cloud.html
You will realize that Tag cloud is one of the example of how use of some scripting in a language like Javascript or perl along with CSS can increase the utility of a web site.
Monday, January 7, 2008
- The use case describes the system’s behavior under various conditions as it responds to a request from one of the stakeholders, called the primary actor.
- The primary actor initiates an interaction with the system to accomplish some goal.
- Different sequences of behavior, or scenarios, can unfold, depending on the particular requests made and conditions surrounding the requests
- Primary actor is the one with the goal that the use case addresses
- Scope identifies the system that we are addressing
- Preconditions and guarantees are the things that must be done for the success of the use case.
- Main Success is the case in which nothing goes wrong
- Extensions suggest what can happen if something goes wrong in the main success steps
I think that the extensions are the if conditions., At every step we need to ask a question what are the possible alternatives.
Importnt: (page 22): Anyone writing the usecases for a new system to be designed will write blackbox use case and so not discuss the internals
One should not get caught in too much rigor while designing a use case it is costly.
Use cases provide scaffolding that connects information in different parts of the requirements
Usecases add value since they announce a list of goals that help to figure out what the system is going to provide.
Steps to be done in order to write the use cases
- Find out the actors and goals
- Write the main success scenario
- figure out the failure conditions
- figure out the failure handling measures for the failure conditions found in step 3
The usecase should be written in a single grammatical form
suD : System under Discussion
Some of the actors are hidden, they are very much required but they are not the ones who are starting the use case. For eg logging system. It is required but it runs in the background and do not initiate a use case. Such actors are called offstage actors.
Scope
Functional scope:It refers to the services provided by the system. It will eventually be captured by the system.
One should prepare a list of actor-goal . This will make clear what are the goals achieved by a particular actor.
Brief is the 2-6 line description of the use case. The main stress is to mention the significane of the use case.
Design Scope:
It means identifying the software and the hardware that will be the part of the system. Depending on the hardware used the behaviour may change. for e.g. printing using a home laser printer is different than printing in a printing press.
The various scopes are : Enterprise, system, subsystem
Depending on the level of the usecase the details will change. The Enterprise will be a top level while the subsystem level will be dealing about how the internal works.
Stakeholders
A stakeholder is someone with a vested interest in the behavior of the use case, even if they
never interact directly with the system offstage actors.
The inclusion of these actors help in improving the quality of the use cases. They may appear in the logs,checks, validations.
The usecase need to protect the interswets of these satkeholders
Primary actor is often but not always the one to trigger the usecase. ( for e.g in case of the time based trigger the primary actor does not triggers the usecase)
Primary actors are important only at the begining and the end of the usecase. In bvetween they dont play a role, so even if we dont identify the primary actor properly not much damage will happen to the system
use some generic names for the primary user so that any alternative user with correct rights can execute the usecase
Supporting actor is an external actor that provides some kind of service to the system under design. e.g. printing service ( we can also call it as secondary actor);
An actor can be a primary axctor in one use case while a supporting actor in another
when we look into the system and name the componenet and their behavior we treat the system as white box.
There are more than just two actors in a white-box use case, since the components of the system are being
shown as well as the external actors
It is extremely rare and usually a mistake, to write white-box use cases as behavioral requirements
for a computer system to be designed
Three Named Goal Levels ( the level of the usecase)
1. summary goals
2. User Goals
3. Sub functions
User Goal
The user goal is the goal of greatest interest. It is the goal the primary actor has in trying to get
work done, or the user has in using the system at all.
A user goal addresses the question, "Can the primary actor go away happy after having done
this?" It should normally be executed in one sitting and should not take more than 30 min
- complete an purchase order or log on the system are not the user goals
- buy a book, register a new customer are user goals
Summary level
Summary level goals involves multiple user goals they solve three purposes:
1. They show the context in which the user goals operate
2. they show life-cycle sequencing of the related goals
3. They show the table of contents for the lower level use cases
Summary level use case run for more time they may take days to complete. this happens becase a summary level use case consist of number of user level use cases
They can be found by asking a question "why is the actor doing this?"
Subfunction use case:
These are the use cases that are required to caryy any small step in case of a use case e.g find a customer, save as a file
- Put a lot of energy into detecting the sea-level use cases. These are the important ones
- Write a few outermost use cases, to provide context for the others
- When you ask a question "Why ?" you get into one higher level.
- When you ask a question "How?" you get into one lower level.
Preconditions, Triggers, guarantees
Precondition is what the system will ensure before letting the usecase to start. Having a precondition means that somebody has already run a usecase to set up the system for this particular usecase
Minimal guarantees are the least promises that can be made to the stakeholders when the primary actor goals cannot be delivered. They are of interest when the goal is abondoned. common guantees " System logged on how far it goes"
Success Guarantee: it states what interests of the stakeholders are satisfied ion the sucesful completion of a usecase either at the end of the main success path or the alternate path
Webservices
The web service can be easily used in the Flex 2. The web service may be in any language. The client can be made to consume the web service. There are two main ways to do that.
First method
<mx:WebService id="WShello" wsdl="http://localhost:2091/CreditCard/CreditCard.asmx?wsdl">
<mx:operation
name="HelloWorld" result="typeRPCResult(event)">
</mx:operation>
<mx:operation
name="ListFiles" result="showFiles(event)">
</mx:operation>
</mx:WebService>
In this case we make use of mx:webservice Tag. We need to specify the location of the WSDL file.
Then we specify the various operations we want to perform. My advice is mention only the functions that don’t want any parameter to be passed.
Result specify the function to be called once the data has arrived.
The event is of resultEvent type
Now in order to get the data we need to call the webservice. This is done by
WShello.HelloWorld.send();
i.e. Webservice_object. Operation_name. Send();
Once the result has arrived the general prototype of the function called is
Private function function_name(evt:resultEvent):void
{
//here you should typecast the event.result into the expected type
var s:string=(event.result as String);
}
Second Method
This method uses more of a programmatic approach. The main use of this method is to call the webmethods that require paramters to be passed to them
The various steps to be followed are:
1. declare an object of type websevice
public var webse:WebService = new WebService();
2. Call a function that will initialize the object
public function callWebMethod():void{
3. Inside the function you need to specify the wsdl file
webse.wsdl="http://localhost:2091/CreditCard/CreditCard.asmx?wsdl";
4. load the wsdl
webse.loadWSDL();
5. Once loaded wsdl file will generate a LoadEvent. We need to call a function on that event so that the necessary webmethod can be called
webse.addEventListener(LoadEvent.LOAD, onWSDL);
onWSDL is the method to be called
6. private function onWSDL(event:LoadEvent):void{
is the prototype for the function. Note that the event type is LoadEvent. The firast parameter in the eventListener call will specify the kind of event that will happen.
7. Before actually calling the webmethod register an helper method that will handle the results arrived from the webmethod
webse.GetFile.addEventListener(ResultEvent.RESULT, onGetFile);
specify the webmethod_name.addEventListener
Note that the event type is ResultEvent
8. Call the webmethod passing the correct parameter
Webse.GetFile(parm1.parma2…)
9. Handle the result in the onGetFile() function
Private function onGetFile(event:ResultEvent):void{
}
10. type cast the event.result to the type you require
var s:string=(event.result as String);
In my sample code I have typecasted it to an object, since the webservice will be returning a complex data type
var ob:Object=(event.result as Object);
The object is then used to populate WebFileData object.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.soap.LoadEvent;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
import valueObject.*;
[Bindable]
private var arc:ArrayCollection = new ArrayCollection();
private var theWF:WebFileData;
public var webse:WebService = new WebService();
//convert the result into the type that is returned.
public function typeRPCResult(evt:ResultEvent):void{
hell.text=(evt.result as String);
}
// what ever is returned convert the result into that.
public function showFiles(evt:ResultEvent):void{
arc=(evt.result as ArrayCollection);
}
//function to initialise the webservice (THE SECOND METHOD)
public function callWebMethod():void{
webse.wsdl="http://localhost:2091/CreditCard/CreditCard.asmx?wsdl";
webse.loadWSDL();
// the eventhandler that will be called when the loadevent happebns
webse.addEventListener(LoadEvent.LOAD, onWSDL);
}
/**
* function to display the results from the web service
**/
private function onWSDL(event:LoadEvent):void{
Alert.show("wsdl loaded");
// register the eventhandler that will be called once the result is back
webse.GetFile.addEventListener(ResultEvent.RESULT, onGetFile);
var tempString:String=txtFile.text;
var tempFileName:String;
//fileName = fileName.substr(fileName.lastIndexOf(“/”) + 1);
tempFileName=tempString.substr(tempString.lastIndexOf("\")+1);
hell.text=tempFileName;
//Alert.show(hell.text);
webse.GetFile(tempFileName);
}
// this function will be responsible to render the result on the panel
private function onGetFile(event:ResultEvent):void
{
var ob:Object=(event.result as Object);
//you dont need to specify new here , since the createWF function will take care of it
theWF=WebFileData.createWF(ob);
//hell.text=theWF.CreationTime.date.toString();
resName.text=theWF.Name;
resContent.text=theWF.Contents.toString();
resCD.text=theWF.CreationTime.toDateString()+" "+theWF.CreationTime.toTimeString();
resLAT.text=theWF.LastAccessTime.toDateString()+" "+theWF.LastAccessTime.toTimeString();
resLWT.text=theWF.LastWriteTime.toDateString()+" "+theWF.LastWriteTime.toTimeString();
}
// to invoke the web methods
private function init():void{
WShello.HelloWorld.send();
WShello.ListFiles.send();
}
]]>
</mx:Script>
<!-- this is one of the ways to define the web services (THE FIRST METHOD) -->
<mx:WebService id="WShello" wsdl="http://localhost:2091/CreditCard/CreditCard.asmx?wsdl">
<mx:operation name="HelloWorld" result="typeRPCResult(event)">
</mx:operation>
<mx:operation name="ListFiles" result="showFiles(event)">
</mx:operation>
</mx:WebService>
<mx:HBox>
<mx:VBox>
<mx:Label id="hell" />
<mx:List id="ls" dataProvider="{arc}" rowCount="{arc.length}" />
</mx:VBox>
</mx:HBox>
<mx:Panel x="221" y="10" width="500">
<mx:Label text="You have selected:"/>
<mx:Text id="txtFile" width="400" text="{ls.selectedItem.toString()}"/>
<mx:Button name="btnGet" label="Copy" click="callWebMethod()" />
</mx:Panel>
<mx:Panel x="221" y="114" width="500" height="268" layout="absolute" title="The Result">
<mx:Canvas x="10" y="0" width="100%" height="100%">
<mx:Label x="10" y="26" text="Name:"/>
<mx:Text x="60" y="26" width="213" height="18" id="resName" text="xx"/>
<mx:Label x="10" y="52" text="Content"/>
<mx:TextArea x="67" y="51" width="248" height="43" id="resContent"/>
<mx:Label x="10" y="117" text="Creation Date"/>
<mx:Text x="109" y="117" width="206" id="resCD" height="18"/>
<mx:Label x="10" y="143" text="LastAccessTime" width="93"/>
<mx:Text x="121" y="141" width="180" id="resLAT" height="20"/>
<mx:Label x="10" y="169" text="LastWriteAccess" width="93"/>
<mx:Text x="131" y="169" width="170" id="resLWT" height="18"/>
</mx:Canvas>
</mx:Panel>
</mx:Application>
/*****************************/
The WebFileData class
import flash.utils.ByteArray;
import mx.rpc.soap.*;
import mx.charts.chartClasses.DataDescription;
[Bindable]
public class WebFileData
{
public var Name:String;
public var Contents:ByteArray;
public var CreationTime:Date;
public var LastAccessTime:Date;
public var LastWriteTime:Date;
public function WebFileData(_Name:String,_Contents:ByteArray,_CreationTime:Date,_LastAccessTime:Date,_LastWriteTime:Date){
this.Name=_Name;
this.Contents=_Contents;
this.CreationTime=_CreationTime;
this.LastAccessTime=_LastAccessTime;
this.LastWriteTime=_LastWriteTime;
}
/**
* The function will accept the parameter of type object and then it will fill the datastructure and
* return back the object
**/
public static function createWF(o:Object):WebFileData{
var WF:WebFileData=new WebFileData(o.Name,o.Contents,o.CreationTime,o.LastAccessTime,o.LastWriteTime);
return WF;
}
}
Tuesday, September 18, 2007
What does a company want from its employee?
Well in my opinion their ability to deliver on time and correctly is what they were hired for. It was something that is the part of their duty. It has to be done, so they have done nothing extraordinary. For e.g. You asked a plumber to repair the tap, he came and repaired it. Is it something that was not expected from him?
Now what is the one factor that takes you from a average performer to an extraordinary performer? I would like to mention the famous quote "successful people do the things differently". You were given a task, you did that, great!!! but there could be multiple ways of doing that. Try to figure out the way that no one in the company has ever tried and which is appealing to the Boss. For e.g. in case of software, normally it is a requirement that people are asked to debug other people code which generally lacks documentation. I will point out the two approaches one that will grade you as an average employee and the other that makes you above average.
Average: Spend time in understanding the code, find the root cause for the bug, and fix it.
Above Average: Spend time in understanding the code, document the salient points in the code, find out the root cause for the bug, fix it, document the reasons for the errors.
The first guy just did what he was asked to do. The second guy did the necessary stuff and in addition to that he documented the code so that in the future he/ or some other guy need not spend that many man hours in fixing the bug in that code. So in turn he not only performed his duty, he also tried to save some nickels for the company.
So the point here is always look for the opportunities which makes you valuable to the company.
I will give some more examples in the next post