Saturday, 17 August 2013

onclick event not working, instead it triggering while page load

onclick event not working, instead it triggering while page load

In the following code I simply want the number of matched element by tag
name, But it returns 0 and it alerts while page load (not on click as I
want). Cannot find any mistake over an hour
<!DOCTYPE HTML>
<HTML>
<head>
<script language="javascript">
document.getElementById("all").onclick = alert(
document.getElementsByTagName("a").length);
</script>
</head>
<body>
<div id="all" class="a">Click</div>
<div class="a"></div>
<div class="a"></div>
</body>
</HTML>
I'm a total newbie in JavaScript

Facebook onComplete callback not being triggered in Fragment

Facebook onComplete callback not being triggered in Fragment

I am making a request to the Facebook API using the Facebook SDK. I am
trying to retrieve a graph user however it doesnt matter what I do. The
callback is not being triggered.
How do I trigger the OnActivityResult of the fragment?
public class SampleFragment
extends Fragment
{
FacebookUtils instance;
private TextView labelText;
private ProfilePictureView prof;
private Button button;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View contentView = inflater.inflate(R.layout.fragment_sample,
container, false);
labelText = ((TextView) contentView.findViewById(R.id.label_text));
prof =
(ProfilePictureView)contentView.findViewById(R.id.selection_profile_pic);
button= ((Button) contentView.findViewById(R.id.button));
Bundle bundle = getArguments();
String label = bundle.getString("label");
labelText.setText(label);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
// If the session is open, make an API call to get user data
// and define a new callback to handle the response
Request request = Request.newMeRequest(session, new
Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response
response) {
// If the response is successful
Toast.makeText(getActivity(),user.getFirstName(),Toast.LENGTH_LONG).show();
if (session == Session.getActiveSession()) {
if (user != null) {
prof.setProfileId(user.getId());
AppMsg.makeText(getActivity(),user.getFirstName(),AppMsg.STYLE_CONFIRM).show();
//user id
//profileName = user.getName();//user's
profile name
//userNameView.setText(user.getName());
}
}
}
});
Request.executeBatchAsync(request);
}
}
});
return contentView;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(getActivity(),
requestCode, resultCode, data);
}

Jquery easy slider not working

Jquery easy slider not working

i have used easy slider for my slideshow. i have tried this code but not
working. How to fix this?

Select FKs unique by first occurence, append other occurences values to a field

Select FKs unique by first occurence, append other occurences values to a
field

I have this working but I'm sure sure there's a better way to accomplish
this in Django.
This is for a movie app so theres titles and people who act in each, many
to many.
I have a titlepeople model with information such as:
id, people_fk, title_fk, role_title
On movies where a cast member has alot of roles I need to display their
information like: Tom Hanks: Gardener, Police Man #1, Another Role #4
Is there anyway I can optimize the below way of doing this so the code
isn't so lengthy?
cast_unique = list()
for person in cast:
#if not in the unique list, add them
if person.people not in [p.people for p in cast_unique]:
cast_unique.append(person)
else:
# if in the list, append the role information
if person.role_title:
for c in cast_unique:
if c.people == person.people:
# append role info
c.role_title = '{0} / {1}'.format(c.role_title,
person.role_title)
Thanks in advance.

What is the difference between Cortex-A8 and Cortex-M3 ARM Processors

What is the difference between Cortex-A8 and Cortex-M3 ARM Processors

I am just asking about the major differences between ARM Cortex-A8 and
Cortex-M3 processors.

Hibernate C3P0 hangs when reaches maxpoolsize even with maxidletime set

Hibernate C3P0 hangs when reaches maxpoolsize even with maxidletime set

Not really understanding these setting too well at the moment, wondering
if someone could point me in the right direction.
I have the following, which I thought was basically saying
1: Minimum number of pooled connections = 5 2: Maximum number of pooled
connections = 10 3: How long an idle connection should stay open, 5
seconds (at which point it's closed and becomes available again.
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/testdb" />
<property name="user" value="root" />
<property name="password" value="password" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="10" />
<property name="maxIdleTime" value="5" />
<property name="maxStatements" value="0" />
</bean>
But in my simple little test app, that runs a simple select where id = 1
on a test table, as soon as I get to my 11th 'search', it app hangs.
Why am I maxed to just 10 connections, even if I wait well over 5 seconds,
why are none of the connections freed up?
-- Snippets of my classes:
public Object readObject(SessionFactory sessionFactory, String hql,
Map<String,Object> args) {
session = this.openHibernateSession(sessionFactory);
Query query = session.createQuery(hql);
Iterator<Entry<String, Object>> it = args.entrySet().iterator();
while (it.hasNext()) {
Entry<String, Object> entry = it.next();
query.setParameter(entry.getKey(), entry.getValue());
}
@SuppressWarnings("unchecked")
List<Object> list = query.list();
this.closeHibernateSession(sessionFactory); // I don't even know if I
should need this!
if (list!=null && list.size() > 0) {
return list.get(0);
} else {
log4j.warn("readObject: List is NULL.");
return null;
}
}
protected Session openHibernateSession(SessionFactory sessionFactory) {
Session session = null;
try {
session = sessionFactory.getCurrentSession();
} catch (HibernateException ex) {
session = sessionFactory.openSession();
}
return session;
}
protected void closeHibernateSession(SessionFactory sessionFactory){
Session session;
try {
if (sessionFactory.getCurrentSession()!=null) {
session = sessionFactory.getCurrentSession();
session.close();
}
} catch (HibernateException ex) {
log4j.warn("Failed to close current session, set session to
null.", ex);
session = null;
}
}
Cheers in advance.

Please help me the question was very hard.

Please help me the question was very hard.

A(-1,-6),B(3,12),C(k,6).Find the value of k if AB is perpendicular to AC