What would you say are these kind of questions good way to improve your skills or just waste of time since they have no application in real life(or not).
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3
How can I match the following pattern?
"anything123.anythingelse"
Alphanum of any length, with exactly 1 "." in the middle, and then alphanum of any length?
Thanks.
Hello, I have a class called User which has 2 properties : login/password. I am trying to authenticate a user in my application using hibernate criteria but my request doesn't work.
[EDIT] The returned value is NULL. I have two users in my database for testing.
Here is my code :
@Override
public User authenticate(String login, String password)
throws NullPointerException {
Session session = this.getSession();
User user = (User) session
.createCriteria(User.class)
.add(
Restrictions.and(
Property.forName("login").eq(login),
Property.forName("password").eq(password)
)).uniqueResult();
if (user == null){
throw new NullPointerException("User not found");
}
return user;
}
Can someone tells me what is wrong with my code?
Happy new Year 2011 !!
var array1:Array = new Array();
var array2:Array = new Array();
var obj1:Object = new Object();
array1.push(obj1);
array2.push(obj1);
if i change something in obj1 will array1[0] and array2[0] also change?
How can I get a specific value from an object?
I'm trying to get a value of an instance
for eg.
ListOfPpl newListOfPpl = new ListOfPpl(id, name, age);
Object item = newListOfPpl;
How can I get a value of name from an Object item??
Even if it is easy or does not interest you can anyone help me??
Edited: I was trying to build a binary tree contains the node of ListOfPpl, and need to sort it in the lexicographic. Here's my code for insertion on the node. Any clue??
public void insert(Object item){
Node current = root;
Node follow = null;
if(!isEmpty()){
root = new Node(item, null, null);
return;
}boolean left = false, right = false;
while(current != null){
follow = current;
left = false;
right = false;
//I need to compare and sort it
if(item.compareTo(current.getFighter()) < 0){
current = current.getLeft();
left = true;
}else {
current = current.getRight();
right = true;
}
}if(left)
follow.setLeft(new Node(item, null, null));
else
follow.setRight(new Node(item, null, null));
}
Hello!
I want to make a loop on a variable that can be altered inside of the loop.
first_var.sort.each do |first_id, first_value|
second_var.sort.each do |second_id, second_value_value|
difference = first_value - second_value
if difference >= 0
second_var.delete(second_id)
else
second_var[second_id] += first_value
if second_var[second_id] == 0
second_var.delete(second_id)
end
first_var.delete(first_id)
end
end
end
How do I do this, because this doesn't work?
do you got the solution for your problem ?
im working on the exact same thing and cant get it to work...
if u could post the solution, it would be much appreciated :o
greetingz
msn: [email protected]
steam : [email protected]
I recently got hired as a web developer, and the project that I am overseeing has a formatting issue on one of the pages because one of the divs is out of whack. It is a fairly complex page with quite a bit of php, and from what I can gather, I am missing a </div> tag somewhere, and accordingly everything is messed up.
I am currently using notepad++, which is decent at lining up divs, meaning that if you click on the opening div tag, it will highlight purple and also highlight the closing one. But it seems as though if you have div tags that span several lines (hundreds) it won't work.
Has anyone else run into a similar situation? Is there a better editor I could be using that would do a better job of helping me with my div issue? Or do I have to go through and line up the divs 1 by 1? (there are like over 100). Please let me know!! Thanks
Good Day,
I have a small form with a combo box (ASP.NET Drop Down List control) and a text box (with a DIV id txtName). When the selected index of the combo box changes, I want to clear out the text box.
I understand that:
$("#txtName").val(''); clears the text box value
The thing is the combo box. It contains a list of integers representing the months of the year. The drop down control is called ddlMonths.
$("#ddlMonths").change(function() {
$("#txtName").val('');
});
I thought by using change, an onSelectedIndexChange event handler would be associated with this control.
I also tried (because I've ran into the client id being mangled in ASP.NET w/ jQuery) this:
$("#<%=ddlMonths.ClientID%>").change(function() {
$("#<%=txtName.ClientID%>").val('');
});
and neither approach seems to be working. Am I missing something?
TIA,
coson
I know how to detect if a particular GET method is in the url:
$username = $_GET['username'];
if ($username) {
// whatever
}
But how can I detect something like this:
http://www.mysite.com?username=me&action=editpost
How can I detect the "&action" above?
My comments on this answer got me thinking about the issues of constness and sorting. I played around a bit and reduced my issues to the fact that this code:
#include <vector>
int main() {
std::vector <const int> v;
}
will not compile - you can't create a vector of const ints. I suppose I should have known this, but I've never needed to create such a thing before. However, it seems like a useful construct to me, and I wonder if there is any way round this problem - I want to add things to a vector (or whatever), but they should not be changed once added.
There's probably some embarrassingly simple solution to this, but it's something I'd never considered before.
hi, i am using NServices to send an object of the class MyMusicMessage as blow:
[Serializable]
public class MyMusicMessage:IMessage
{
public Guid EventId { set; get; }
public byte[] MusicBytes { set; get; }
}
when the size of MusicBytes is about 200k, it can be sent well.
but when the size is more than 300K,there is a "MessageQueueException".
is there any limit to the object size in NServiceBus?
thanks.
I have the following interface:
public interface MyFunctor {
int myFunction(int x);
}
And I created a class which implements this interface :
public class Myfunction1 implements MyFunctor {
}
But it show me the error :
implement all abstract method
Please help me.
Hi,
Is there a way to dynamically create a selectItem list? I dont really want to have to create lots of bean code to make my lists return List<SelectItem>...
I tried this:
<ice:selectManyCheckbox>
<ui:repeat var="product" value="#{productListingService.list}">
<f:selectItem itemLabel="#{product.description}" value="#{product.id}"/>
</ui:repeat>
</ice:selectManyCheckbox>
but it doesnt work.
Any ideas?
Hello,
I have one page which uses <ui:insert> called master.xhtml which uses one managedbean named MasterBean.java and its of viewScoped. It calls webservice and has all useful data which will be useful in master.xhtml as well as page which is built using master.xhtml (which uses <ui:include>). When i visit data.xhtml (which uses template as master.xhtml) and which uses managed bean as DataBean.java which is also of view scoped, how do i use MasterBean? If i directly use #{Masterbean.property}, won't it create a new instance again? or will it use the bean which is already in view scope? Also how do i use MasterBean in DataBean in such a way that existing MasterBean's instance is used in DataBean. I don't want new instance of MasterBean in DataBean.
Thanks in advance. If i am not clear please let me know.
I'm trying to build a pager where it's just Next / Previous buttons that call a jquery function that post a JSON request. Inside the function, the current page "index" is retrieved from a hidden field and passed to the controller. Inside the controller, I reset the index if I'm on the last page of data. How would I pass the new index value back to the view? Or is there a better way to do what i'm trying to do?
Thanks
IF both methods are declared as virtual, shouldn't both instances of Method1() that are called be the derived class's Method1()?
I am seeing BASE then DERIVED called each time. I am doing some review for an interview and I want to make sure I have this straight. xD
class BaseClass
{
public:
virtual void Method1() { cout << "Method 1 BASE" << endl; }
};
class DerClass: public BaseClass
{
public:
virtual void Method1() { cout << "Method 1 DERVIED" << endl; }
};
DerClass myClass;
((BaseClass)myClass).Method1();
myClass.Method1();
Method 1 BASE
Method 1 DERVIED
hi,
i have a blog application were Post belongsTo Category and Category hasMany Post
Post can have a Category or not - in latter case NULL value is present in Post.category_id field.
Now i would like to have following category count with single SQL query
category|post_count
--------------
PHP | 2
JavaScript | 4
SomeOtherCat | 1
NULL | 3
The clue here is that i also want to count posts without category (NULL row above). Is it posibble with one SQL query?
Hi,
list<Dog*> dog;
.............
............
So I added many dog objects to it.
If I call dog.pop_front();
Does memory automatically gets deallocated ?
Hello,
I am creating a website and i want to allow personalization to individual users upto some extent like changing font family, background color etc. The problem with this is that, my default css file that i load has already default classes for everything. Now when i fetch the background color from my database, then if there is null value for background color then default css class of mystylesheet.css should be loaded and if the value is not null, then i want to override this with my default css. How is it possible? Thanks in advance :)