How to make this method return boolean value, depending on query return. False - nothing, True - data exists. Before i just returned int from uniqueQuote.Count() but does not look like great method. Thank you!
private bool CheckEnquiryUser(int enquiryId, Guid userId)
{
int selectedEnquiryId = enquiryId;
Guid currentUserId = userId;
Entities ctx3 = new Entities();
var uniqueQuote = from quot in ctx3.Enquiries.Include("aspnet_Users")
where quot.EnquiryId == selectedEnquiryId &&
quot.aspnet_Users.UserId == currentUserId
select quot;
bool exist = uniqueQuote;
return exist;
We use JUnit 3 at work and there is no ExpectedException annotation. I wanted to add a utility to our code to wrap this:
try {
someCode();
fail("some error message");
} catch (SomeSpecificExceptionType ex) {
}
So I tried this:
public static class ExpectedExceptionUtility {
public static <T extends Exception> void checkForExpectedException(String message, ExpectedExceptionBlock<T> block) {
try {
block.exceptionThrowingCode();
fail(message);
} catch (T ex) {
}
}
}
However, Java cannot use generic exception types in a catch block, I think.
How can I do something like this, working around the Java limitation?
Is there a way to check that the ex variable is of type T?
I wonder if this is possible with straight SQL on MySQL. I need to do SELECT COUNT(*) FROM on each table in the database and output results in one result set.
Is it possible to do with just SQL?
My program is written in C++. compiled with gcc, using -g3 -O0 -ggdb flags. When it crashes, I want to open its core dump. Does it create core dump file, or I need to do something to enable core dump creation, in the program itself, or on computer where it is executed? Where this file is created, and what is its name?
Hello there,
I'm working with a page that has several links that contain the same href text, and I need to select the second anchor element on the page that contains said href text. Here's a simplified version of the link structure of the page:
<a href="same/link/to/stuff/">same link</a>
<a href="same/link/to/stuff/">same link</a>
How do I fashion my selector so that it only selects the second anchor in the above example?
Thanks!!
Hi,
I'm looking at Silverlight architectures and RIA Services looks interesting, but I am a bit concerned about its prelease status and how the feature set will change.
We need our client app to be as responsive as possible over a slow network link, so a high priority is a solid sync system for pushing model state changes from the client back to the server. Will RIA Services help us in this regard or will I have to roll my own logic to do this ? Are there any other frameworks that can assist with this? Is the feature set involved in these requirements liable to change much in the next couple of months?
If it makes any difference, our frontend is 100% Silverlight, so we dont need to worry about exposing SOAP APIs from the server or anything like that. It appears to me that RIA so far is a bit more mature for Silverlight use. Is this correct?
Some mac apps, like iTunes and Spotify, react to the play/pause/next/previous buttons on some Apple keyboards.
Presumably they're tapping into some sort of NSNotification, how can I do the same?
I am aware of array_walk() and array_map(). However when using the former like so (on an old project) it failed
array_walk($_POST, 'mysql_real_escape_string');
Warning: mysql_real_escape_string()
expects parameter 2 to be resource,
string given.
So I went with this slightly more ugly version
foreach($_POST as $key => $value) {
$_POST[$key] = mysql_real_escape_string($value);
}
So why didn't the first way work? What is the best way to map values of an array to a function?
I am writing an abstract superclass where literally every method is going to be overridden. There is some default functionality I could implement, but most of the time it's enough to leave the implementation to the subclass writer.
Since just about every method is going to be overwritten, how much should I make virtual and how much should I just leave as regular methods? In the current incarnation, everything is virtual, but I still haven't let this loose to anyone to use, so the design is flexible.
What advantages/disadvantages are there to virtual functions? Links to good reading material about this would be appreciated.
Hello everyone.
The Cocoa framework has a convention to always call self = [super init] in the init method of an inherited class, because [super init] may return a new instance.
What will happen if I do this?
@interface MyClass : NSObject /* or any other class */ {
int ivar_;
}
@end
@implementation MyClass
- (id)init {
ivar_ = 12345;
if ((self = [super init])) {
NSLog(@"ivar_'s value is %d", ivar_);
}
return self;
}
@end
In the case when [super init] returns a new instance, what will I see in the console? ivar_'s value is 0?
I can't think of a way to check this myself, because I don't know which class may return a new instance from its init method. Also, can't seem to find explicit clarification for this scenario in the docs.
Could anyone help me out? Thanks!
I'm implementing a checking system in C++. It runs executables with different tests. If the solution is not correct, it can take forever for it to finish with certain hard tests. That's why I want to limit the execution time to 5 seconds.
I'm using system() function to run executables:
system("./solution");
.NET has a great WaitForExit() method, what about native C++?. I'm also using Qt, so Qt-based solutions are welcome.
So is there a way to limit external process' execution time to 5 seconds?
Thanks
Are you able to use open id to log into the local development server with google app engine sdk version 1.4.1 and python 2.5?
When I execute this
self.redirect(users.create_login_url(continue_url, None, openid_url))
I get redirected to http://localhost/_ah/login rather than the openid url.
The openid url and continue url are valid.
My app.yaml looks like this
- url: /_ah/login_required
script: do_openid_login.py
- url: /users/(.*)
script: routers/user_router.py
login: required
If I browse to http://localhost/users/ I am also redirected to http://localhost/_ah/login rather than http://localhost/_ah/login_required
Is there a config issue or does openid not work locally?
I need a way to get user home directory in C++ program running on Linux. If the same code works on Unix, it would be nice. I don't want to use HOME environment value.
AFAIK, root home directory is /root. Is it OK to create some files/folders in this directory, in the case my program is running by root user?
I have a simple MySQL table thats contains a list of categories, level is determined by parent_id:
id name parent_id
---------------------------
1 Home 0
2 About 1
3 Contact 1
4 Legal 2
5 Privacy 4
6 Products 1
7 Support 1
I'm attempting to make a breadcrumb trail. So i have the 'id' of the child, I want to get all available parents (iterating up the chain until we reach 0 "Home"). There could be any number or child rows going to an unlimited depth.
Currently I am using an SQL call for each parent, this is messy. Is there a way in SQL to do this all on one query?
I have noticed that the quality of the images produced by the JPEGEncoder does not match that of other encoders available (i.e. php's built in image compression functions from the gd library)
Any explanation ? or hints/workarounds for improving the quality of compressed images by JPEGEncoder ??
Hi:
My program uses sockets for inter-process communication. There is one server listening on a socket port(B) on localhost waiting for a list of TCP clients to connect. And on the other end of the server is another a socket(A) that sends out data to internet. The server is designed to take everything the TCP clients send him and forward to a server on the internet. My question is if two of the TCP clients happened to send data at the same time, is this going to be a problem for the server's outgoing socket(A)?
Thanks
I have to develop a new (desktop) app for a small business. This business currently has an Access database with millions of records. The file size is about 1.5 GB. The boss told me that searching on this DB is very slow. The DB consists of a single table with about 20 fields.
I also think the overall DB design isn't great. I thought to use another DB server with a new design to improve both performance and efficiency.
Considering this is a relatively small business, I don't want to spend much for a DB license, so I want to ask you what would you do.
Continue to use Access, maybe improving and optimizing the DB in some way
Buy a DB server license (in this case, which one?)
? (any idea?)
let's say I have a list
li = [{'q':'apple','code':'2B'},
{'q':'orange','code':'2A'},
{'q':'plum','code':'2A'}]
What is the most efficient way to return the count of unique "codes" in this list?
In this case, the unique codes is 2, because only 2B and 2A are unique.
I could put everything in a list and compare, but is this really efficient?
.NET contains its own equality comparison functionality, however I don't really understand how it works.
If the desired Equals() and == behaviour is to verify that every field of an object is equal to every field of another object, is it necessary to override Equals() with a method that does this explicitly?
Hi guys,
Is it possible to assign multiple provisions to an iDevice? To be honest, I'm not sure if I'm using the correct terminology, but basically, I'm developing an iPad app for a company and I've only been testing it in the simulator because I don't have a registration to the developer program and they haven't setup their enterprise registration yet either. And I'm sure you all know how limited the simulator is...
I don't really care about the $99 it costs to join, but what I'm worried about is having my iDevices locked permanently to my personal registration and unable to switch back and forth to the enterprise registration.
I'd appreciate it if someone can explain to me how the registrations work. And keep in mind, I'm a dummy. :)
Thanks in advance!