Hi,
When programming in VHDL, can you use a variable in a case statement? This variable will modified by one of the cases
i.e.
case task is
when 1 =>
when 2 =>
when number =>
is this OK?
What I am trying to accomplish:
Create a dynamic bubble that expands on height and width depending on the text in the bubble.
What I researched so far:
In an so article they described the measurestring to figure out the exact width or height so dynamic changes in the .cs to the width and height can be accomplished.
Is there something like this in Silverlight? Is my only option to utilize the myTxt.Text.length and then change the myGrid.height and myGrid.width to leave wasted space to accommodate all cases?
I am doing my project in software testing. Genetic algorithm is the technique I want to use to generate automatic test data\test cases in MATLAB.
Please help me in doing my project successfully.
I have an instance of dict with ints, floats, strings as keys, but the problem is when there are a as int and b as float, and float(a) == b, then their hash values are the same, and thats what I do NOT want to get because I need unique hash vales for this cases in order to get corresponding values.
Example:
d = {1:'1', 1.0:'1.0', '1':1, '1.0':1.0}
d[1] == '1.0'
d[1.0] == '1.0'
d['1'] == 1
d['1.0'] == 1.0
What I need is:
d = {1:'1', 1.0:'1.0', '1':1, '1.0':1.0}
d[1] == '1'
d[1.0] == '1.0'
d['1'] == 1
d['1.0'] == 1.0
Hello,
I am running a java app as daemon on a linux machine using a customized shell script.
Since I am new to java and linux, I want to know is it possible that the app itself resurrects itself(just like restart) and recovers from cases like app crashing, unhandled exceptions or out of memory etc.
thanks in advance
Ashish Sharma
The challenge
The shortest code by character count that will generate (pseudo)random numbers using the Middle-Square Method.
The Middle-Square Method of (pseudo)random number generation was first suggested by John Von Neumann in 1946 and is defined as follows:
Rn+1 = mid((Rn)2, m)
For example:
34562 = 11943936
mid(11943936) = 9439
94392 = 89094721
mid(89094721) = 0947
9472 = 896809
mid(896809) = 9680
96802 = 93702400
mid(93702400) = 7024
Test cases:
A seed of 8653 should give the following numbers (first 10):
8744, 4575, 9306, 6016, 1922, 6940, 1636, 6764, 7516, 4902
Hi all,
We have developed a multithreaded server that recieves data from multiple client and calls different WCF services.
There are many cases that two (or more) different clients call the server at the same and the server tries to call the remote WCF from two different threads simultaneously.
We have encountered some issues, especially when the remote WCF service is down.
Are we doing things correctly? is there a best practice for this scenario?
thanks,
Guy.
I would like to create a method in additional to the default 'foo'.titlecase that will correctly add "possessiveness" to it.
The string is a user's name (<- just did one right there! )
For example: "sam" is the user
<%= user.titlecase.possessive + ' Profile' % = #Sam's Profile
It just needs to handle edge cases like:
Steelers's Profile ( should be Steelers' Profile)
Ross's Profile ( should be Ross' Profile )
Hello,
I have 2 question about sqlmetal.exe
I generate Linq to Sql classes from command promt for all tables, except some tables?
can I add to model some tables
I want that, in some cases linq to sql classes not generated fully.
thanks.
Hi all,
I'm using Jmeter to do a load testing for a website. In that case I have faced to a problem that the jmeter does not show the errors rather than the 404 errors. so how can I give the error messages in the jmeter for the errors occur for other cases. Can some one help me. Thanks in advance.
Thilanka.
I finally got Silverlight 4 Toolkit installed , referenced and working after the difficulty of finding the right namespace described in this question.
But intellisense doesn't work fully: after I type "tk:", it doesn't pop up the various controls I have available, but if I type a control name out, e.g. DockPanel, then it works, as shown below. It will even give me intellisense after I type tk:DropPanel, which is odd.
How can I get intellisense to work in all cases for the Silverlight 4 Toolkit?
Having mostly worked with C#, I tend to think in terms of C# features which aren't available in Java. After working extensively with Java over the last year, I've started to discover Java features that I wish were in C#. Below is a list of the ones that I'm aware of. Can anyone think of other Java language features which a person with a C# background may not realize exists?
The articles http://www.25hoursaday.com/CsharpVsJava.html and http://en.wikipedia.org/wiki/Comparison_of_Java_and_C_Sharp give a very extensive list of differences between Java and C#, but I wonder whether I missed anything in the (very) long articles. I can also think of one feature (covariant return type) which I didn't see mentioned in either article.
Please limit answers to language or core library features which can't be effectively implemented by your own custom code or third party libraries.
Covariant return type - a method can be overridden by a method which returns a more specific type. Useful when implementing an interface or extending a class and you want a method to override a base method, but return a type more specific to your class.
Enums are classes - an enum is a full class in java, rather than a wrapper around a primitive like in .Net. Java allows you to define fields and methods on an enum.
Anonymous inner classes - define an anonymous class which implements a method. Although most of the usecases for this in Java are covered by delegates in .Net, there are some cases in which you really need to pass multiple callbacks as a group. It would be nice to have the choice of using an anonymous inner class.
Checked exceptions - I can see how this is useful in the context of common designs used with Java applications, but my experience with .Net has put me in a habit of using exceptions only for unrecoverable conditions. I.E. exceptions indicate a bug in the application and are only caught for the purpose of logging. I haven't quite come around to the idea of using exceptions for normal program flow.
strictfp - Ensures strict floating point arithmetic. I'm not sure what kind of applications would find this useful.
fields in interfaces - It's possible to declare fields in interfaces. I've never used this.
static imports - Allows one to use the static methods of a class without qualifying it with the class name. I just realized today that this feature exists. It sounds like a nice convenience.
Hey everyone,
On a Vista dev machine I used this code successfully to change user "Administrator" password:
directoryEntry.Invoke("SetPassword", "new");
When I moved it over to my Server 2008 dev machine that code did not work, and I was forced to use the following code:
directoryEntry.Invoke("ChangePassword", new object[] { "old", "new" });
My question is, why?
For both cases, I created my DirectoryEntry object as such:
DirectoryEntry directoryEntry = new DirectoryEntry(string.Format("WinNT://{0}/{1}", computerName, username));
Thanks! 8)
Hi
I am trying to deploy an application with two executable files one of which is the application it self.
I used the publish tub on the VS 2008 and tried to publish manually using the MageUI.exe.
in both cases I get the "Reference in the manifest does not match the identity of the downloaded assembly" error in regards to the second executable file.
Dose Any one know how to publish an application with two executable files?
Thanks,
Ahron
Hi. I am looking for a simple solution to do Exception Logging combined with Error Handling in my ASP.Net MVC 1.0 application.
I've read lots of articles, including Questions posted here on StackOverflow, which all provide varying solutions for different situations. I am still unable to come up with a solution that suits my needs.
Here are my requirements:
To be able to use the [HandleError] attribute (or something equivalent) on my Controller, to handle all exceptions that could be thrown from any of the Actions or Views. This should handle all exceptions that were not handled specifically on any of the Actions (as described in point 2). I would like to be able to specify which View a user must be redirected to in error cases, for all actions in the Controller.
I want to be able to specify the [HandleError] attribute (or something equivalent) at the top of specific Actions to catch specific exceptions and redirect users to a View appropriate to the exception. All other exceptions must still be handled by the [HandleError] attribute on the Controller.
In both cases above, I want the exceptions to be logged using log4net (or any other logging library).
How do I go about achieving the above? I've read about making all my Controllers inherit from a base controller which overrides the OnException method, and wherein I do my logging. However this will mess around with redirecting users to the appropriate Views, or make it messy.
I've read about writing my own Filter Action which implements IExceptionFilter to handle this, but this will conflict with the [HandleError] attribute.
So far, my thoughts are that the best solution is to write my own attribute that inherits from HandleErrorAttribute. That way I get all the functionality of [HandleError], and can add my own log4net logging. The solution is as follows:
public class HandleErrorsAttribute: HandleErrorAttribute {
private log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public override void OnException(ExceptionContext filterContext)
{
if (filterContext.Exception != null)
{
log.Error("Error in Controller", filterContext.Exception);
}
base.OnException(filterContext);
}
}
Will the above code work for my requirements? If not, what solution does fulfill my requirements?
What are the pros and cons of using Criteria or HQL? The Criteria API is a nice object-oriented way to express queries in Hibernate, but sometimes Criteria Queries are more difficult to understand/build than HQL.
When do you use Criteria and when HQL? What do you prefer in which use cases? Or is it just a matter of taste?
Versioning
If your events changes you would create a new version of that event, and keep the old ones. To keep your domain code form being bloated with handling of all versions of events you would basically introduce a component that converts your events from previous to newer versions, and then apply them on the domain. Remember that events are things that actually happened in your domain so in most cases the information in deprecated events are valuable.
I still haven't found any example of this.
Any help?
I have an application in Django, that needs to send a large number of emails to users in various usecases. I don't want to handle this synchronously within the application for obvious reasons.
Has anyone any recommendations for a message queuing server which integrates well with Python, or they have used on a Django project? The rest of my stack is Apache, mod_python, MySQL.
I'd like to set the title of a UIButton via code. I find myself having to call -[UIButton setTitle:forState:] for UIControlStateNormal, UIControlStateHighlighted, UIControlStateDisabled, UIControlStateSelected. And that doesn't even take into account all of the combinations of these states together.
Needless to say, this is tiresome. Is there a single call I can make that will set one string as the title for all of the states? (Since, I assume that in 95% of the cases, that's the desired behavior?)
Hi all!
Do you have any idea how to covert different Unicode characters to their closest ASCII equivalents? Like Ä - A. A googled but didn't find any suitable solution. Trick Encoding.ASCII.GetBytes("Ä")[0] didn't work. (Result was ?). I found that there is class Encoder that has Fallback property that is exactly for cases when char can't be converted, but implementations (EncoderReplacementFallback) are stupid and convert to ?.
Any ideas?
Thanks, Andrey
I have an AppEngine application that uses the blobstore to store user-provided image data. When I upload images to that application from a form in Chrome it works fine. When I try to upload an image from an Android application it fails. Both methods work fine if I am running against the development server, but the Android upload doesn't work against the live service.
This is the request from Chrome:
POST /_ah/upload/?userToken=11001/AMmfu6ZCyMQQ9YdiXal3SmSXIRTQIuSRXkNc-i3JmU0fqx_kJbUJ2OMLcS2lXhVJSK4qs7regViTKzOPz5ejoZYi0nAD5o8vNltiOViQw6DZO7_byZz3Ut0/ALBNUaYAAAAAS_lusgPMAGmpPrg0BuNsJyymX-57ob4i/ HTTP/1.1
Host: photohuntservice.appspot.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1064 Safari/532.5
Referer: http://photohuntservice.appspot.com/debug_newpuzzle?userToken=11001
Content-Length: 60360
Cache-Control: max-age=0
Origin: http://photohuntservice.appspot.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarybl05YLmLbFRf2MzN
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
------WebKitFormBoundarybl05YLmLbFRf2MzN
Content-Disposition: form-data; name="userToken"
11001
------WebKitFormBoundarybl05YLmLbFRf2MzN
Content-Disposition: form-data; name="img"; filename="Photo_020908_001.jpg"
Content-Type: image/jpeg
<image data>
------WebKitFormBoundarybl05YLmLbFRf2MzN
Content-Disposition: form-data; name="longitude"
-122.084095
------WebKitFormBoundarybl05YLmLbFRf2MzN
Content-Disposition: form-data; name="latitude"
37.422006
------WebKitFormBoundarybl05YLmLbFRf2MzN--
This is the request from my client (which is written in Java on Android, but I don't think that's relevant):
POST /_ah/upload/?userToken=11001/AMmfu6Zf9an6AU4lT9UuhIpxOZyOYb1LMwimFpeSh8zr6J1sX9F2ddJW3Qlsw0kwV3oALv-TNPWRQ6g4_Dgwk0UTwF47bbc78Yl44kDeV69MydTuR3N46S4/ALBNUaYAAAAAS_mMr3CYqTg3aVBDjhRxP0DyyRdvotyG/ HTTP/1.1
Content-Type: multipart/form-data;boundary=----WebKitFormBoundaryhdyNAhmOouRDGErG
Cache-Control: max-age=0
Accept: */*
Origin: http://photohuntservice.appspot.com
Connection: keep-alive
Referer: http://photohuntservice.appspot.com/getuploadurl?userToken=11001
Content-Length: 2638
Host: photohuntservice.appspot.com
User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)
Expect: 100-Continue
------WebKitFormBoundaryhdyNAhmOouRDGErG
Content-Disposition: form-data; name="userToken"
11001
------WebKitFormBoundaryhdyNAhmOouRDGErG
Content-Disposition: form-data; name="img";filename="PhotoHunt.jpg"
Content-Type: image/jpeg
<image data>
------WebKitFormBoundaryhdyNAhmOouRDGErG
Content-Disposition: form-data; name="latitude"
37.422006
------WebKitFormBoundaryhdyNAhmOouRDGErG
Content-Disposition: form-data; name="longitude"
-122.084095
------WebKitFormBoundaryhdyNAhmOouRDGErG--
In both cases the AppEngine Python code to catch the request is the same:
class UploadPuzzle( blobstore_handlers.BlobstoreUploadHandler ):
def post(self):
upload_files = self.get_uploads( )
The problem is that when running on the production AppEngine service self.get_uploads() returns an empty list when the request is made from my client app. Both requests return what I expect (a list with one blob_info in it) on the development server, and Chrome returns what I expect in both cases.
In one of my Selenium test cases, I try to ensure that certain pages can't be accessed. Instead, HTTP return code 403 should be given.
However, here Selenium terminates test execution with the following exception:
com.thoughtworks.selenium.SeleniumException: XHR ERROR: URL = http://user:[email protected]/admin Response_Code = 403 Error_Message = Forbidden
Any way to work around that?
I have a JAX-RS resource, which gets its paramaters as a JSON string like this:
http://some.test/aresource?query={"paramA":"value1", "paramB":"value2"}
The reason to use JSON here, is that the query object can be quite complex in real usecases.
I'd like to convert the JSON string to a Java object, dto in the example:
@GET
@Produces("text/plain")
public String getIt(@QueryParam("query") DataTransferObject dto ) {
...
}
Does JAX-RS support such a conversion from JSON passed as a query param to Java objects?
I have been reading about Nhibernate for a while and have been trying to use it for a site I'm implementing. I read the article by Billy McCafferty on NHibernate best practices but I did not see any indication on where is the best place to handle transactions.
I thought of putting that code in the Data Access Object (DAO) but then I'm not sure how to handle cases in which more than one DAO is used. What are the best places to put transaction code in your NHibernate Application?