Wednesday, May 2, 2012

How to get all sub-elements of an element tree with Python ElementTree?

I want to find a way to get all the sub-elements of an element tree like the way ElementTree.getchildren() does, since getchildren() is deprecated since Python version 2.7, I don't want to use it anymore, though I can still use it currently.


How do i make a history calculator in android?

I am making a calculator same as windows calculator. I am stuck at the history feature. How do I code for history feauture of the calculator. What should I use in android for that? Thanks in advance.

Why the <DIV> CSS applied for Repeater Control get Distorted when placed in UpdatePanel?

i am new to AJAX i am trying to update a Repeater Control When user Click on Search Button which is out side the updatePanel using Trigger event of UpdatePanel the CSS get Distorted when Repeater Control is Placed inside UpdatePanel Whhen the Update Panel is Removed Then the CSS is applied perfectly why does it happen?


 <div class="jqueryresultsBackground">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:Repeater ID="ResultsRepeater" runat="server">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<table align="center" width="100%">
<td align="left" class="searchResFieldName" width="40%">
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/deleted.png"
Style="z-index: 1; position: absolute; margin-left: -5px;"
Visible='<%# DeletedImageVisibility(Eval("IsActive"))%>' />
<br />
<%# Eval("UnicodeFullName")%>
<td width="10%">
<td width="10%">
<td width="10%">
<td width="8%">
<td width="5%">
<td width="10%">
<td align="left" class="searchResFieldName" width="35%">
<%# Eval("EnglishFullName")%>
<td align="left">
<%# Eval("HouseNumber")%>
<br />
<%# Eval("UnicodeAddress")%>
<b><%# Eval("ConstituencyNumber")%></b>
<b><%# Eval("PartNumber")%></b>
<b><%# Eval("SerialInPart")%></b>
<b><%# Eval("Age")%></b>
<b><%# Eval("Sex")%></b>
<b><%# Eval("CardNo")%></b>
<%# Eval("Address")%>
<td align="left" class="searchResPrabhag" colspan="7">
<hr />


<asp:AsyncPostBackTrigger ControlID="SearchButton" EventName="Click" />

<asp:HiddenField ID="CurrentPageHiddenField" runat="server" />

Prolog - writing a combination of k numbers in the given list

I am trying to define a function in prolog that takes arguments of the form combination(3,[a,b,c,d],L) , the result returns


My implementation is as follows:

Z is select(X,argList),
L is Z,

unknown(X,[_|L],R) :- unknown(X,L,R).

The unknown predicate behaves as follows:
![enter image description here][1]

Please help.

How would I go about building an API converter?

I have multiple different APIs with different schemas serialised in XML or JSON which I need to output as a standardised schema.

Main features needed:

  • Serialisation to XML and JSON

  • Authentication

    • I.e.: can't get/set data unless you have the correct user+pass

  • Role/Scope limitation

    • I.e.: you can't access everything in our database, only what your role allows for

  • Get/set (conversion) between different schemas

    • I.e.: No matter the input API, you can get it formatted in whichever output API you request

Is this the sort of problem Slumber with TastyPie would be best for?

Or are there a different libraries you'd recommend? - [happy to use C#, C++ or Ruby instead if they have libraries better suited to this problem]

Test app on iPad without paying Apple

I want to test my iPad app on my device without paying for an Apple developer account. Is there any method to do that? How can I install my iPad app on my device for testing?

NFC Android: Decode an Mifare tag written with NXP NFC Writer

i`m messing around with some nfc tags, I have written plain text to them with the application 'TagWriter' made by the company nxp. Is it possible to make an application that can read this plain text? or is this impossible due certain authorizations keys of the nxp app? or has someone done this before?

any suggestion is appreciated

Replacing specific characters in first column of text

I have a text file and I'm trying to replace a specific character (.) in the first column to another character (-). Every field is delimited by comma. Some of the lines have the last 3 columns empty, so they have 3 commas at the end.

Example of text file:


What I tried was using awk to replace '.' in the first column with '-', then print out the contents.

ETA: Tried out sarnold's suggestion and got the output I want.

ETA2: I could have a longer first column. Is there a way to change ONLY the first 3 '.' in the first column to '-', so I get the output


What is corresponding c++ data type to SQL numeric(18,0) data type?

What is corresponding c++ data type to SQL numeric(18,0) data type?

I need a datatype in C++ to store numeric(18,0) of SQL in it.

How can I get the memory of one process in Linux

Why I use 'top' in Linux to show my memory of one process,I get that the storage of the process do only increase and do not decrease except I close the all process.I don't know why,though I use 'free' only behind 'malloc'.
How can I get the correct actual REAL-TIME storage of my process?
thanks all.

Missing start boundary Exception when sending messages with an attachment file in Tomcat

I've found a number of possible matches to this problem but none that work for me.

I'm using Apache Camel to deliver a file as an email attachement. It works perfectly using the following maven goals:


I'm using java 1.6. My deployment container is tomcat6. In tomcat6 and tomcat7 I get the following exception:

org.springframework.mail.MailSendException: Failed messages: javax.mail.MessagingException: Missing start boundary; message exception details (1) are:
Failed message 1:
javax.mail.MessagingException: Missing start boundary
at javax.mail.internet.MimeMultipart.parsebm(

The advice on the web suggests this is a class loader problem. Its either that the activation-1.1.jar or mail-1.4.4.jar files are not being found, or the mailcap file in mail-1.4.4.jar is not being found.

I've tried putting these jar files in tomcat/lib. I've tried copying the mailcap from the jar file into the META-INF directory of the exploded war. Neither of these make a difference.


Windows: Apache Tomcat/7.0.5 JDK 1.6.0_27-b07 Apache Camel 2.8.0-fuse-00-08

Linux - the versions that come with ubuntu 10.04 LTS - I'll check these later and add.

This is a simplified version of my camel routes:

<route id="uploadFileForm">
<from uri="jetty:"/>
<to uri="velocity:form.html"/>
<route id="uploadFile">
<from uri="jetty:"/>
<to uri="log:mail?showBody=true&amp;showHeaders=true"/>
<to uri="smtp://localhost"/>
<setHeader headerName="content-type"><constant>text/plain</constant></setHeader>
<setBody><constant>Message Sent</constant></setBody>

This is what the log shows:

[4 - seda://mail-ws-audio-files] mail                           INFO  Exchange[ExchangePattern:InOut, Headers:{Connection=Keep-Alive, CamelHttpServletRequest=org.eclipse.jetty.servlets.MultiPartFilter$Wrapper@bb32c5, upfile=D:downloads!37SQFTS.pdf, CamelHttpPath=/fup, subject=BBC Premier League Update - Edition 1, CamelHttpQuery=null, CamelHttpServletResponse=HTTP/1.1 200 

, UntilMessage=until 10:30 GMT when a second bulletin is available (Mon-Fri only), Host=localhost:9095, User-Agent=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E), Accept-Encoding=gzip, deflate, bulletin_type=am,, cc=admin@localhost, breadcrumbId=ID-B1-L0N336601-58958-1335935026761-0-2, CamelHttpUrl=http://localhost:9095/fup, Content-Length=24896, Referer=http://localhost:9095/premier,, Accept=image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/, application/, application/msword, */*, Accept-Language=en-GB, Content-Type=multipart/form-data; boundary=---------------------------7dc3a8371906f6, CamelHttpUri=/fup, Cache-Control=no-cache, CamelHttpMethod=POST}, BodyType:String, Body:Dear Partner,

please find attached the latest edition of our file.

Any ideas?

after deploy my ajax website missing ajax control

I have website using ajax control ,On development machine its working fine but after deployee ajax control is not showing or missing .my deployement server is windows 2008.

Please help me in fixing this..

reading error dialog in java

i need to read some error message in java, i tried to do this in getErrorStream and then readLine, but i got exeption.
i added a link to a picture of the error message i want to read


Hide password text

I have a textbox using UseSystemPasswordChar, so it will not display the password that the user enters. The issue is that the password is still able to be read by something like Spy++. I'm looking for a way to hide this like they do in the password fields in the Services.msc > Log On tab.

python django - no module psycopg2.extension even after installing compiled version psycopg2-2.4.5.win32-py2.7.?exe

I am using python django on windows,and trying to deploy to heroku . When i tried to install psycopg2 using pip,

     pip install psycopg2 

i got error :

unable to find vcvarsall.bat

Then i found that i need to install visual studio 2008 (or) i can directly download and install compiled version , so downlaoded from this link :

Filename i downloaded : psycopg2-2.4.5.win32-py2.7.?exe

Even after installing this i am getting error : no module named psycopg2.extensions

So, what more should i do ?

            D:\mycode\python\mysite>heroku run python syncdb
Running python syncdb attached to terminal... up, run.1
Traceback (most recent call last):
File "", line 10, in <module>
File "/app/.heroku/venv/lib/python2.7/site- packages/django/core/management/__i", line 443, in execute_from_command_line
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i", line 382, in execute
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i", line 69, in load_command_class
module = import_module('' % (app_name, name))
File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/"
, line 35, in import_module
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/commands/", line 8, in <module>
from import custom_sql_for_model, emit_post_sync_
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/sql
.py", line 6, in <module>
from django.db import models
File "/app/.heroku/venv/lib/python2.7/site- packages/django/db/", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/", line92, in __getitem__
backend = load_backend(db['ENGINE'])
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/", line24, in load_backend
return import_module('.base', backend_name)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/"
, line 35, in import_module
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/", line 13, in <module>
from django.db.backends.postgresql_psycopg2.creation import DatabaseCreation

File "/app/.heroku/venv/lib/python2.7/site- packages/django/db/backends/postgre
sql_psycopg2/", line 1, in <module>
import psycopg2.extensions
ImportError: No module named psycopg2.extensions


While isntalling psycopg2 both by pip and easy_install, installdidnt work as i got this error : unable to find vcvarsall.bat with some msg : no previsouly included directores matching 'doc\src_build'


is it possible to communicate over webservices in web2py application?

I have to develop one web2py application which will run on one machine (lets say SERVER), this machine will have MySql database also installed and running.
Users can connect remotely to the Web2py app over Https(Lets say it CLIENT)
There is one more system running over the network(Lets say N/W Panel) which can send the data to the SERVER and which will be further saved to the MySql database and Web2Py application will display the updated data to the CLIENT.
So the scenarios are:
1. SERVER can act like a client when CLIENT can request some data from N/W Panel (here N/W Panel acts as Server) using Web2Py application.
2. N/W Panel can act like a client when it gets some updated data from different devices and needs to save to the MySql database which is running on SERVER(here SERVER acts as Server).

Now My question is how to achieve it using web services as it is a bi-directional communication between SERVER and N/W Panel AND how to integrate with Web2Py application?
Web services can be SOAP OR REST.


Search an XML file using Javascript then retrieving specific attributes based on matched string

I've looked through this entire site as various ways in searching through an XML file using a value taken from a html input field and have managed to do this, however when it finds the match thats all I can do is display a message saying "Match Found!".

What I'd like to do is be able to search the XML file using the search string value put into the html input field, then once its found a match pull the rest of the information for that specific node - as in all the attributes.

Example of my XML file:

<dvd year="1979" rating="18" director="ridley scott">Alien</dvd>

The title of the film being "Alien" so that would be the search string.

Any ideas how this could be done? I'm guessing it has something to do with loading into a javascript array maybe. Just to make anyone who answers aware none of the examples I've seen thus far have been that clear on the exact code that would achieve this.

Thanks in advance for the help!!

How to add one image onto another in java

I have an image with a plain background. Now I need to place another image onto it at (x, y) location. How is it possible?

common constant variables in Zend Framework

Where is the best place to create a class that contain all the application constant variables ?

is it :
- Bootstrap

- In the Application Common library

How to use manytomany field in symfony2?

I am stuck at a point from last 2 days. I am having two entities Subjects and Teachers. There is a manytomany relation between two. i have created a manytomany field in teacher entity like this :-

* @ORM\ManyToMany(targetEntity="College\StudentBundle\Entity\Subjects", inversedBy="assets", cascade={"persist"})
* @ORM\JoinTable(name="employee_subjects")

private $subjects;

which resulted in a third table. My subject entity contains only 3 fields, ID, Department_id and name, Now I want to open a regester form for a teacher where i want add the subjects he can teach, for this i created the subjecttype form ist like this :-

namespace College\StudentBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

class SubjectsType extends AbstractType
public function buildForm(FormBuilder $builder, array $options)
// ->add('name', 'entity', array('class' => 'CollegeStudentBundle:Subjects', 'property'=>'name', 'multiple' => false, ))
->add('departmentId', 'entity', array('class' => 'CollegeStudentBundle:Department', 'property'=>'name', 'multiple' => false, ))

public function getName()
return 'college_studentbundle_subjectstype';

And here is my teacher form where i included the subject:-

namespace College\HumanResourceBundle\Form;

use College\StudentBundle\Form\SubjectsType;
use College\StudentBundle\Entity;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

class HumanResourceType extends AbstractType
public function buildForm(FormBuilder $builder, array $options)
->add('joining_date', 'date', array('years' => range(date('Y') - 10, date('Y'))))
->add('usertype', 'entity', array('class' => 'CollegeUserBundle:Usertype', 'property'=>'name', 'multiple' => false, ))

->add('subjects', 'collection', array('type' => new SubjectsType()));

public function getName()
return 'College_humanresourcebundle_humanresourcetype';

It is not working properly, I want, when i add new teacher it should display subject at the bottom where i can assign subjects to the teacher which gets saved in manytomany table.