Saturday, November 15, 2008

Practical Django Projects - Errata

Brett has good notes on how to get the examples to work. This a must if you are following the book. Otherwise it is pretty painful and I am sure you will give up.

coltrane entry_detail, there is a regex typo

Onto p61 ignore the class Admin, and then on p69 there is a typo in the regex. The last bit should be (?P[-\w]+)/$'

Check out complete list at:

http://blog.haydon.id.au/2008/08/4-django-powered-weblog.html

Friday, November 14, 2008

ImportError: cannot import name parse_lookup

Here is the solution to this problem:

1. instead of downloading the version of tagging use the one in svn
svn checkout http://django-tagging.googlecode.com/svn/trunk/ tagging-svn

2. either set the pythonpath or install

- cd tagging-svn
- sudo python setup.py install

This does the work.
coltrane, practical django projects book issues and errata

Monday, November 10, 2008

Day 1: Django - getting started - Django Tutorial

If you are on a linux system, check if you have python installed. Most probably it is.
shell> python
shell> .......
Download and install django and test it out

*********** Install Django ****************
wget http://www.djangoproject.com/download/1.0/tarball/
tar xvf Django-1.0.tar.gz
cd Django-1.0
sudo python setup.py install

*********** Test the install ***************
python
>>>> import django
>>>> django.VER
(1, 0, 'final')
>>>

************ Test to see if you have MySql installed ********************
1. Can you start and stop mysql on your system
sudo /etc/init.d/mysql start/stop

2. Initialize the grant tables
sudo mysql_install_db --user=mysql

3. Secure your mysql installation
mysql_secure_installation

4. log into mysql command line
mysql -u root -p

5. check users and set user passwords
select host,user from mysql.user;
set password 'xxxxxx'@'localhost'=password('dsfkjhdf');

6. check if you can log into mysql command line
mysql -u xxxxxx -p

****** create a new test site ****
1. django-admin.py startproject mysite
2. cd mysite
3. start django dev server
- python manage.py runserver
4. http://127.0.0.1:8000/

**** Installing mysqldb into python
python>>> import MySQLdb
---- if there is an error then install this

1. download libmysqldb python api from source forge
2. check if mysql_config is there in your system
3. if not do
apt-get install libmysqlclient15-dev
This will install the mysql_config tool.
4. python setup.py build
sudo python setup.py install

5. python>> import MySQLdb
-- no error successful



Monday, September 15, 2008

Google Chrome high cpu & memory issues

Google chrome version 0.2.149.29 has serious memory and high cpu issues. I tried removing the phishing filter option in options, but that does not solve problems.

Lots of sites have this issue with chrome. So, google should fix these issues asap.

High CPU is producing a lot of heat and the fan turns on immediately. There are a lot of sites that just hang. 

In its current form, its mostly unusable.

Monday, May 12, 2008

Twitter earlier than news (By 3 minutes)

I just read the article that Twitter beats news story reports earlier than online news sites. The story was on Techmeme and other technology blog sites. Lately there has been a lot of noise about how useful twitter is and how it is helping these tech bloggers break news even before anyone can post.

All this crazy non-sense started me thinking the whole purpose that these tech bloggers are going after. Now who cares if a news story breaks 3 minutes before a major news site breaks it. For many of the readers, whats more important is the content and substance not just breaking headlines.

So, techcrunch Michael Arrogant mentioned recently that he cannot live without twitter and how its a journalistic arsenal. I agree with him, but I think many who subscribe to those thoughts just care of breaking headlines and who beats who, instead of substance.

Many people I know and have talked to mentioned the same thing. They do not care if a particular news site breaks a headline 3 minutes earlier. What they care about is "Predictable, Reputable content that can be trusted".

Case in point: how many of M. Arrogants stories proved to be false. They seem to be chasing rumors of this and that using twitter and many of these does not pan out.

So, who do I trust?

NYTimes Journalist - who waits to corroborate the story and are delligent in giving THE correct story or bloggers who use twitter and jump up and down to break stories early without going through the pain of corroborating thier stories.

Well, I will stick with true and tried stories and bloggers/journalists who corroborate thier stories.

References:
http://scobleizer.com/2008/05/12/quake-in-china/

Thursday, April 17, 2008

How to find Device information on Ubuntu Laptop

dmesg | less
> gives a whole bunch of information

lspci
> gives information about pci device.
> I use this to find my wireless device make and model

installing mysql in Ubuntu

Simple:-)

sudo apt-get install mysql-server mysql-client

This should install the latest mysql 5.0 distribution.

I am using 7.10 when I did this.

Wednesday, April 16, 2008

Installing eclipse and Java on Ubuntu:
1. sudo apt-get install eclipse
2. sudo apt-get install sun-java5-sdk

Before this, enable multiverse under Administration > Software Sources

Update:
This unfortunately installs eclipse 3.2. Its better to download linux version of Eclipse 3.3 and put it in /opt

Ubuntu

I installed ubuntu 7.10 recently and have made several modifications to make sure everything works perfectly and visually appeals my tastes.

What I have done:
1. Default ubuntu install does not have security updates set. Dont know why this is. So, first thing is to set the following options in synaptic package manager:
- System > Administration > Software Sources
- Click on Updates Tab
- Check the following
- Important Security Updates
- Recommended updates
Also, go to Ubuntu Software and check the following:
- main
- universe
- multiverse

2. Have you noticed the Fonts in Ubuntu default sucks, Firefox fonts are downright ugly and pathetic. They are too big and seem to bleed. So, after a little bit of searching found the perfect solution. Thanks to the following site:
fix firefox fonts in ubuntu
Anyway, simplified steps:
1. sudo apt-get install msttcorefonts
2. Window comes up warning of some non-sense, hit ok
3. Copy fontconfig.tbz
to your desktop
4. cd /etc/fonts
5. sudo tar xvf fontconfig.tbz
6. Restart firefox
You should see much better fonts
this worked for me like a charm. If others use this method please comment I would like to see if this works for more folks.

3. I configured compiz-fusion on X40 and it worked like a charm.
Pretty much used synaptics-manager to get compiz-fusion as stated in the ubuntu-wiki

My kid is bowled over by the compiz-fusion stuff and he is already an ubuntu convert :-)

4. Configured Pause Key to launch Terminal
1. System > Preferences > Keyboard Shortcuts
2. Choose Desktop > Run a Terminal > choose shortcut and press the Pause key
Now everytime you hit pause a terminal pops up.
Smooth and convinient.

5. Installed Avant Window Navigator but not using it that much

7. Changed the look and feel for Ubuntu Login Screen (I used Avio-GDM theme, most popular download)
1. Go to Avio GDM
2. Howto install it under Gnome (Ubuntu):

  • 1. Download this theme (currently 0.9)
  • 2. Open the "gdmsetup", also called "Login Window Preferences"
  • 3. Open the tab "Local"
  • 4. Use the "Add" Button and select the downloaded file.
  • 5. Make sure you select the "Avio-GDM" in the List.
  • 6. Close dialog and logout to see it.

Tuesday, March 4, 2008

GroovyConsole and proxyHost and proxyPort

I was working with Groovy and experimenting with GroovyWS. I tried a simple Web Service script and tried executing it but was blocked by my firewall.

The first thing I looked at is how to set -DproxyHost and -DproxyHost.

I set this at the groovy command line and everything was groov-eh.

But, when I tried to utilize GroovyConsole it did not have any option to set the proxyPort or proxyHost.

So, what to do:
- Went to Groovy/bin
- created a proxyGroovyConsole.bat (copy GroovyConsole.bat)
- created a proxyStartGroovy.bat (copy StartGroovy.bat)
- in proxyStartGroovy.bat
add the following lines:
set JAVA_OPTS=%JAVA_OPTS% -DproxySet="true"
set JAVA_OPTS=%JAVA_OPTS% -DproxyHost="x.com"
set JAVA_OPTS=%JAVA_OPTS% -DproxyPort="1234"

- change proxyGroovyConsole.bat to call proxyStartGroovy.bat

= works!!!

So, why go through the pain of creating another proxyFile? why not make the changes in the same file?
- because @ work I need to use proxy
- @ home no proxy!!

I could've set Windows env variables, but that poses the same problems too.
So, the simple minimalistic way is to create a separate BAT file

Friday, January 25, 2008

How to use JadeGateway to bridge between a Servlet Container and JADE Platform

JadeGateway class provides a communication bridge between an external application and the JADE platform. I will show a simple version of using JadeGateway. Later posts will elaborate more on the best way to implement this.
The reason I am starting this is, there is no clear documentation out there to explain this stuff. So, hopefully this will help someone to not go through the pain.

By the way, I just extended the bookTrading example in the jade distribution to get this to work.

1. Create JSP form




Title



Cost







2. Create a simple bookTradingServlet which will send an ACLMessage to the agent. we will be using a simple OneShotBehaviour

- Create your servlet class
- Declare a private variable
private JadeGateway gateway = null;
- Initialize JADE gateway

public void init(ServletConfig config) throws ServletException
{
JadeGateway.init(null, null);
}

The first parameter should be null if you want to utilize the internal Agent class, which is supplied by default.
The second parameter is null unless you want to set some container parameters in the newly created container.

- in the doPost method, create ACLMessage, Behaviour and execute JADEGateway

protected void process(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
String title = "Sent Buyer Agent a Request :-)";
String bookTitle = req.getParameter("Title");
String cost = req.getParameter("Cost");

try
{

JadeGateway.execute(new OneShotBehaviour()
{
public void action()
{
final ACLMessage msg = new ACLMessage(ACLMessage.REQUEST);
AID buyer = new AID("Buyer@LA7750389:1099/JADE", false);
msg.addReceiver(buyer);
msg.setConversationId("book-trade-setup");
msg.setContent("TESTING Message via servlet");
myAgent.send(msg);
}
});
}
catch(Exception e)
{
e.printStackTrace();
System.out.println(e.getMessage());
}

out.println(ServletUtilities.headWithTitle(title) +
"\n" +
"

" + title + "

\n" +
"
    \n" +
    "
  • param1: "
    + bookTitle + "\n" +
    "
  • param2: "
    + cost + "\n" + "\n" +
    "
\n" +
"");
}


3. Now you need to add a Request Processor in the Agent that you want this message to be processed:
-- Put this in the setup method of the agent
// Perform the request
addBehaviour(new ProcessExternalRequests());

4. Create a Behaviour to process the requests.
- Remember the conversation id we used in the servlet should match the messages we are trying to pull out. This way we are looking for messages that we are interested in.

private class ProcessExternalRequests extends CyclicBehaviour {
private MessageTemplate mt;

public void action() {
System.out.println("Processing ProcessExternalRequests:action");
// create a message template
mt = MessageTemplate.MatchConversationId("book-trade-setup");
ACLMessage msg = myAgent.receive(mt);
if(msg != null)
{
if(msg.getPerformative() == ACLMessage.REQUEST)
{
String content = msg.getContent();
System.out.println("Agent " +
myAgent.getAID().getLocalName() +
" Content = " + content
);
}
}
else
{
block();
}
}
}

Voila. We have an interface into the external world.

Hope this helps.

Thursday, January 24, 2008

OK Lets Start

First post. Multi Agent Systems and its coverage.