Programming

For unit testing in lisp

Monday, August 8th, 2011 | Lisp | No Comments

I started using lisp-unit. As shown in the examples it is very easy to use.

Tags: ,

Report from PyCon India 2010

Tuesday, September 28th, 2010 | Community, FOSS, Python | 2 Comments

So I am back from PyCon India 2010. I missed last year, so was waiting for this year’s event. Met many faces after very long time and to be in a place with so many other python lovers is always a nice experience. The total attendance was around 700 but the venue was too big for that number , so except the lunch time, corridors had lesser number of people discussing. The selection of the talks were also matching the environment as they came from different directions. We saw talks with hardware accessibility to web development to GUI application toolkits, network programming, scientific computing, terminal based works etc. 

Day 1 started a bit late, David Goodger gave the keynote, it was fun. Next talk I liked was from Dhananjay Nene on “Functional Programming with Python“, he managed to show many things within the short time. 
I stood in the queue for lunch as soon as possible, it was late, too much crowd at the same time, but the taste of the food was delicious.  During and after the lunch I was discussing with Jace about Wing IDE, I had a thought of buying that previously also but the price is high for me. Wait, not anymore, they gave a 90% discount for the PyCon India :) Started using it right away with vi mode and it works like a charm.
After lunch, thought of going in Mahendra M’s Twisted programming talk, but the room was full, no place for standing also. So hoped over to the auditorium for Vijay Kumar B.’s Device Interfacing with Python and ZIO , it was one of the best talk I ever attended.
Met DP and Jacob after long time :) 
This was first time my laptop’s X crashed while trying to use the projector, so after few tries I started my talk with the black terminal on the big screen :) newt widgets looked great on that screen though :)
Day 2: I came a bit late as I had to meet few seniors from my college in the city (event was in a far corner of the city), I spent the day mostly in the corridors talking with people. I met so many Pune based python lovers there :) Strangely enough few speakers were absconding from the talks, so the organizers had to innovate to fill in.  
At the very end we had first AGM of Indian Python Software Society, too much fun in that :p. I applied for membership, I still need two votes. I also resumed my work on “Python for you and me” 2nd edition. You can also read ml-IN or zh-CN translation of the book.
Any python lover from the country should attend this event, next year it will be in Chennai. Photos will come later this week.

Tags: , , ,

lekhonee-gnome 0.9.1 is released

Thursday, April 29th, 2010 | Community, FOSS, News | 1 Comment

I am happy to announce the release of lekhonee-gnome 0.9.1 . You can download the source or check for koji builds for F12 or F13. New features are like:

  • Supports multiple WordPress accounts
  • Tabbed UI for different modes
  • Now supports adding <br> tag using tool button
  • Preview mode (more details on this below)
  • Advertisement message is disabled for this release
  • Stopped segfault(s) in couple of corner cases
  • Supports <video> and <audio> tags in Visual and preview mode (you may have to write the details in HTML mode)
  • Can watch youtube videos in Preview mode (not an actual feature :p )

So the main two new features are multiple account handling and Preview mode. In the preview mode you can see how the post will look like in your blog with the theme you are having. To fetch the blog style please click on the small download style/theme button in the toolbar (this button will only come in the toolbar if you don’t have cached theme downloaded in your system), though you need internet connection for this mode to work.

Tags: , , ,

How to do XMLRPC calls in Vala using libsoup (tutorial)

Monday, March 22nd, 2010 | FOSS, Tutorial | No Comments

This is small tutorial showing how one can do XMLRPC in Vala using libsoup.
We will call a default demo.sayHello method in WordPress, this will just return a string “Hello!”.

The code:


using Soup;

public void main(string[] args) {
var message = xmlrpc_request_new("http://kushaldas.wordpress.com/xmlrpc.php","demo.sayHello");
var session = new SessionSync();
session.send_message(message);

string data = message.response_body.flatten().data;
Value v = Value(typeof(string));
try {
xmlrpc_parse_method_response(data, -1,v);
}
catch(Error e) {
debug("Error while processing the response");
}
string msg = v.get_string();
debug("Got: %s\n", msg);

}

At the very first line we mention that we are using the libsoup, then using xmlrpc_request_new method we create a message. It requires the URL and method name strings. It also takes optional arguments to the method (which we will see in the next example). Then in the next few lines we are creating a SessionSync object and call the method using send_message method. The response stays in the same message object we created before. We get the response as string in the variable data.

xmlrpc_parse_method_response takes the response as a string in the first argument, next is the length(size) of the response (Note: I used -1 so that it will take the size of data, it comes handy when the response contains unicode chars) and 3rd argument is the Value where it will store the parsed result. string msg = v.get_string() gives us the final result , which we print using debug.

Now to compile the code I gave the following command

$ valac --pkg libsoup-2.4 --thread xmlrpc-test.vala

The output

$ ./xmlrpc-test
** (process:28319): DEBUG: xmlrpc-test.vala:17: Got: Hello!

In the next example we will try to add two numbers using another demo method given by wordpress. The code is given below


using Soup;

public void main(string[] args) {
var message = xmlrpc_request_new("http://kushaldas.wordpress.com/xmlrpc.php","demo.addTwoNumbers",typeof(int),20,typeof(int),30);
var session = new SessionSync();
session.send_message(message);

string data = message.response_body.flatten().data;
Value v = Value(typeof(int));
try {
xmlrpc_parse_method_response(data, -1,v);
}
catch(Error e) {
debug("Error while processing the response");
}
int msg = v.get_int();
debug("Got: %d\n", msg);

}

Here while creating the message, we passed the required arguments to the method demo.addTwoNumbers, it goes as type and value pair, so we wrote typeof(int) and then the integer value.

Compilation and result


[kdas@d80 vala]$ valac --pkg libsoup-2.4 xmlrpc-test2.vala --thread
[kdas@d80 vala]$ ./xmlrpc-test2
** (process:28565): DEBUG: xmlrpc-test2.vala:17: Got: 50

A small tip: If you don’t know the return type , use type_name() to find out.
Thanks to the people in #vala who are continuously helping me to understand more of it.

The post is brought to you by lekhonee v0.8

Tags: , ,

How one can start learning PyKDE ?

Wednesday, April 1st, 2009 | FOSS, KDE, problem, Python | 4 Comments

Dear lazyweb,

How one can start learning PyKDE ? For PyQt , reading a few very basic examples given with the source and then reading Qt-help docs seems to be fine. But the KDE libs are much bigger, though one can find a suitable class to work with, how to use that is still not so easy for a newbie.

When it comes to the GUI, it is again not clear to me that which approach one should take , design everything in code ? or one can use qt-designer for that.

Kushal

Tags: , , , ,

My way of testing language

Sunday, September 21st, 2008 | Haskell, problem | 36 Comments

A very bad expression:

23462376427 ^ 2132323

Question is which computer languages can give me the answer without much trouble ? Haskell did.

Update: For Python the correct expression is 23462376427 ** 2132323

Tags: ,

Search

Archives

Categories