instruction stringlengths 0 30k ⌀ |
|---|
Enums are generally messy in c# so when using .NET 2.0 its common to wrap the syntax with generics to avoid having to write such clumsy code.
In .NET 1.1 you can do something like the below, although it's not much tidier than the original snippet:
protected bool CharEnumEqualsCharObj(TransactionStatus... |
Is there any way to enable the mousewheel (for scrolling) in Java apps? |
|java| |
Ideally I'd like a way to enable the mousewheel for scrolling in old compiled java runtime apps, but java code to explicitly utilize it for an individual app would suffice. |
If you didn't have the ability to alter the warning levels, you could just bind the parameter value to a dummy value and document that they are for future use. |
If you didn't have the ability to alter the warning levels, you could just bind the parameter value to a dummy value and document that they are for future use |
If you didn't have the ability to alter the warning levels, you could just bind the parameter value to a dummy value and document that they are for future use. |
Timeout exception for a query using ADO.Net |
|ado.net|c#|timeout| |
This is a sample code for executing a query. Sometimes, while executing time consuming queries, it throws a timeout exception.
I cannot use any of these techniques:
1) Increase timeout.
2) Run it asynchronously with a callback. This needs to run in a synchronous manner.
please suggest any other techinques to ke... |
|c#|ado.net|timeout| |
This is a sample code for executing a query. Sometimes, while executing time consuming queries, it throws a timeout exception.
I **cannot** use any of these techniques:
1) Increase timeout.
2) Run it asynchronously with a callback. This needs to run in a synchronous manner.
please suggest any other techinques t... |
We're using ScrumWorks for about 30 people. They have a free edition.
http://danube.com/scrumworks
|
Tp guard against infinite loops, you'd need to put it in a separate process so that it could be killed.
To guard against creating threads, you'd need to extend SecurityManager (the default implementation allows untrusted code to access non-root thread groups).
Java security does allow you to prevent access to the... |
Tp guard against infinite loops, you'd need to put it in a separate process so that it could be killed.
To guard against creating threads, you'd need to extend SecurityManager (the default implementation allows untrusted code to access non-root thread groups).
Java security does allow you to prevent access to the... |
It will be based upon the parent element, so as to respect the cascade. If it is helpful, I always do my font sizes this way:
body {
font: normal 100% "Arial","Helvetica",sans-serif;
}
p, li, td {
font-size: .85em;
}
li p, td p {
font-size: 1em;
}
Go 100% on th... |
It will be based upon the parent element, so as to respect the cascade. If it is helpful, I always do my font sizes this way:
body {
font: normal 100% "Arial","Helvetica",sans-serif;
}
p, li, td {
font-size: .85em;
}
li p, td p {
font-size: 1em;
}
Go 100% on th... |
You could checkout [pyprocessing](http://pyprocessing.berlios.de/) which will be included in the standard library as of 2.6. It allows you to run tasks on multiple processes using an API similar to threading. |
Mark the class with [Serializable], although I'm not sure how well a IList<string> member will be handled by the serializer.
__EDIT__
The post below is correct, because your custom exception has constructor that takes parameters, you must implement ISerializable.
If you used a default constructor and exposed t... |
For me, these 3 kinds cover most of my needs:
shared_ptr - reference-counted, deallocation when the counter reaches zero
weak_ptr - same as above, but it's a 'slave' for a shared_ptr, can't deallocate
scoped_ptr - when the creation and deallocation happen inside the same function, or when the object has to be ... |
It is possible. Dynamic code generation is even mainstream in some areas like software rendering and graphics.
I strongly suggest that you read on the SSA representation of code. That's a representation where each primitive is turned into the so called three operand form, and each variable is only assigned once (hen... |
It is possible. Dynamic code generation is even mainstream in some areas like software rendering and graphics. You find a lot of use in all kinds of script languages, in dynamic compilation of byte-code in machine code (.NET, Java, as far as I know Perl. Recently JavaScript joined the club as well).
You also find i... |
It is possible. Dynamic code generation is even mainstream in some areas like software rendering and graphics. You find a lot of use in all kinds of script languages, in dynamic compilation of byte-code in machine code (.NET, Java, as far as I know Perl. Recently JavaScript joined the club as well).
You also find i... |
**Set up Capistrano to deploy** You'll want to learn capistrano if you don't already know it, and use it to deploy your code in an automated way. This will involve setting up your shared directory and shared resources like database.yml.
**Install C Based MySQL gem** If you don't have all the required libs, this can ... |
keep in mind, What you measure is what you get. loc says nothing about productivity or efficency.
rate a programmer by lines of code and you will get.. lines of code.
the same argument goes for other metrics.
otoh.. http://www.crap4j.org/ is a very conservative and useful metric. it sets complexity in relation ... |
You need to use the [maven-plugin-testing-harness][1],
<pre><code lang="xml">
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>1.1</version>
<scope>test</... |
Whatever you are about to do - I'd not go down the tomcat specific road.
If you really need to locate different ports, configure them to your webapp through the usual configuration means - e.g. specifying <Environment> values. You'd not have any automatic discovery, but also it won't break on tomcats next update.
... |
Both are patterns trying to separate presentation and business logic, decoupling business logic from UI aspects
Architecturally, MVP is Page Controller based approach where MVC is Front Controller based approach.
That means that in MVP standard web form page life cycle is just enhanced by extracting the business... |
Both are patterns trying to separate presentation and business logic, decoupling business logic from UI aspects
Architecturally, MVP is Page Controller based approach where MVC is Front Controller based approach.
That means that in MVP standard web form page life cycle is just enhanced by extracting the business l... |
I agree with your sentiments. Coming from Microsoft development tools (and eclipse) to XCode is kind of harsh. XCode just feels... unfinished in some respects. It certainly doesn't have the polish that I come to expect from VS and Eclipse.
The SDK is similar, much of it is poorly documented, and there are a lot o... |
static_cast, aside from manipulating pointers to classes, can also be used to perform conversions explicitly defined in classes, as well as to perform standard conversions between fundamental types:
double d = 3.14159265;
int i = static_cast<int>(d);
|
From SQL Server Management Studio:
1. open the object explorer
2. expand the database server
3. expand "Management"
4. double-click on "Activity Monitor"
5. locate the process using the desired database
6. right-click on process
7. click "Kill Process"
|
Handling different ConnectionStates before opening SqlConnection |
|c#|.net|sql-server|database| |
If you need to open a SqlConnection before issuing queries, can you simply handle all non-Open ConnectionStates in the same way? For example:
if (connection.State != ConnectionState.Open)
{
connection.Open();
}
I read somewhere that for ConnectionState.Broken the connection... |
You could work out the items during the MouseDown event of the control. Check that it is the right mouse button too. |
The major technological drawback of MethodB I saw is that when applying generic code to it, we must double the code to handle both the const and the non-const version. For example:
Let's say T is an order-able object (ie, we can compare to objects of type T with operator <), and let's say we want to find the max bet... |
Unless you're going to put a full url, don't use http:// or file://
Sound can load an mp3 file from a full or relative url. You just need to make sure your url is correct and valid.
For example, if the full path to the file is http://www.something.com/assets/the_song.mp3, a path of "/assets/the_song.mp3" would wo... |
Good PHP ORM Library? |
|php|database|orm| |
Does anyone know of a good object-relational-mapping library for PHP? I know of PDO/ADO, but they seem to only provide abstraction of differences between database vendors not an actual mapping between the domain model and the relational model. I'm looking for a PHP library that functions similarly to the way Hibernat... |
Whenever you deal with real live environments, you would want your developers to be able to understand your repository as easily as possible. A good way to do this is by adhering to the recommended Subversion standard layout. |
Set the visibility on the button to 'none';
<pre><code>
btnSubmit.Attributes("onClick") = document.getElementById('btnName').style.display = 'none';</code></pre>
Not only does it prevent the double submission, but it is a clear indicator to the user that you don't want the button pressed more than once. |
Have you looked in to Doctrine?
http://www.doctrine-project.org/
Also, check out Xyster.. It's based on the Data Mapper pattern.
http://xyster.devweblog.org/
|
Maybe those two will help:
- [Listutorial][1]
- [CssPlay Menus][2]
[1]: http://css.maxdesign.com.au/listutorial/
[2]: http://www.cssplay.co.uk/menus/ |
To get the current directory, you can use this:
CD > tmpFile
SET /p myvar= < tmpFile
DEL tmpFile
echo test: %myvar%
It's using a temp-file though, so it's not the most pretty, but it certainly works! 'CD' puts the current directory in 'tmpFile', 'SET' loads the content of tmpFile. |
To get the current directory, you can use this:
CD > tmpFile
SET /p myvar= < tmpFile
DEL tmpFile
echo test: %myvar%
It's using a temp-file though, so it's not the most pretty, but it certainly works! 'CD' puts the current directory in 'tmpFile', 'SET' loads the content of tmpFile.
Here is a ... |
Definately a good idea, nothing worse that a page which a developer is binding a dataGrid in the Page_Load every time but also submitting the viewstate!
It's also a really good idea if you are planning on using the UpdatePanel from the AJAX Extensions, it means you're submitting less during the UpdatePanel request.
... |
>>> import re
>>> re.split(r"(\s+)", "This is the string i want to split")
['This', ' ', 'is', ' ', 'the', ' ', 'string', ' ', 'i', ' ', 'want', ' ', 'to', ' ', 'split']
Using the capturing parentheses in re.split() causes the function to return the separators as well. |
First make sure that equals is implemented correctly. From [an IBM DeveloperWorks article][1]:
> - Symmetry: For two references, a and b, a.equals(b) if and only if b.equals(a)
> - Reflexivity: For all non-null references, a.equals(a)
> - Transitivity: If a.equals(b) and b.equals(c), then a.equals(c)
Then make... |
Just a quick note for completing other more detailed answer (in term of code):
If I consider the question [how-do-i-create-a-hash-table-in-java][1] and especially the [jGuru FAQ entry][2], I believe some other criteria upon which a hash code could be judged are:
- synchronization (does the algo support concurrent... |
Buy a fire-safe.
This is not just a good idea for storing backups, but a good idea period.
|
Buy a fire-safe.
This is not just a good idea for storing backups, but a good idea period.
Exactly what media you put in it is the subject of other answers here.
But, from the perspective of recovering from a fire, having a washable medium is good. As long as the temperature doesn't get too high CDs and DVDs see... |
If you're not going to write the code, are you going to be comfortable with someone else's generated code?
Is it cheaper in both time and $$$ in the long run to write your own code or code generator?
I wrote a code generator that would build 100's of classes (java) that would output XML data from database in a D... |
You need to use the [maven-plugin-testing-harness][1],
<pre><code lang="xml">
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>1.1</version>
<scope>test</... |
My guess is because the class is a dumb data transfer object merely used to pass arguments to a method.
This class itself doesn't have any operations defined on it, thus what sort of polymorphism would you expect? For example, the existing methods will only know about the properties of this class, which are all sett... |
Need a mod_rewrite thingy |
|apache|mod-rewrite| |
I want to take the url:
http://www.mydomain.com/signup-12345
And actually give them:
http://www.mydomain.com/signup/?aff=12345
I have NO history with mod_rewrite, HELP! |
How do I use mod_rewrite to change the path and filename of a URL |
Don't use browser detection:
* Browser detection is not 100% reliable at the best of times, but things get worse than this:
* There are lots of variants of browsers (MSIE customisations etc)
* Browsers can lie about their identity (Opera actually has this feature built-in)
* Gateways hide or obfuscate the browser... |
Adding a new dynamic web project to the workspace seems to 'unlock' the feature. |
Bear in mind that merely decompressing a ZIP file may result in <a href="http://en.wikipedia.org/wiki/Decompression_bomb">a security vulnerability</a>. |
We do incorporate GUI testing in our project, and it has its side effects. The developers however have one critical design principle: *Keep the GUI layer as thin as possible!*
That means *no logic* in the GUI classes. Separate this in presentation models responsible for input validation etc.
For testing on a Un... |
There is a plugin called FasterCSV that handles this wonderfully. |
[This page at sun][1] lists one way to specify a JRE. Specifically,
<OBJECT
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="200" height="200">
<PARAM name="code" value="Applet1.class">
</OBJECT>
> The classid attribute identifies which
> version of Java Plug-in to use... |
For the server-side solution (which your question was originally ambiguous about), [this page at sun][1] lists one way to specify a JRE. Specifically,
<OBJECT
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="200" height="200">
<PARAM name="code" value="Applet1.class">
</OB... |
Implement ISerializable, and follow the [normal pattern](http://msdn.microsoft.com/en-us/library/system.runtime.serialization.iserializable%28VS.71%29.aspx) for doing this.
You need to tag the class with the [Serializable] attribute, and add support for that interface, and also add the implied constructor (described... |
Here's an article that discusses various webscrapers that will generate feeds: http://www.masternewmedia.org/news/2006/03/09/how_to_create_a_rss.htm
If you don't care to click through, here are the services the author discusses:
* http://www.feedyes.com/
* http://www.feed43.com/
* http://www.feedfire.com/site/i... |
Some options:
1. Change your logging so that it dumps to a file instead of standard output.
2. Increase the maximum heap size with `-Xmx <some number>M`, like `-Xmx 256M`. |
Is your dev machine Win64? I've had problems with win64 builds of apps that go away if you set the build platform to x86. |
When you profile, display the execution plan. Identify queries that are performing costly table scans and re-index those tables to minimize this cost.
Try these references:
[Optimizing SQL][1] <br />
[How to Optimize Queries][2]
[1]: http://www.bcarter.com/optimsql.htm
[2]: http://www.serverwatch.com... |
After you profile, put the queries you see as troublesome into SQL Query Analyzer and display the execution plan. Identify portions of the queries that are performing costly table scans and re-index those tables to minimize this cost.
Try these references:
[Optimizing SQL][1] <br />
[How to Optimize Queries][2... |
If you're trying to add the assembly to the ".NET" tab in the Visual Studio "Add References" dialog box, there's a registry setting you need to make. [KB30149 explains it in greater detail.][1] The short version: You need to add an entry to the `HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders` regist... |
With tortoise SVN, it's quite easy: you can select several files (may be from search results, so they don't have to be in the same directory), select "properties" in the TortoiseSVN menu, add the needed property (there is a drop-down list of the mostly used properties, in this case "svn:executable") and set the value (... |
You can edit the page in SharePoint designer, convert the List View web part to an XSLT Data View. (by right click + "Convert to XSLT Data View").
Then you can edit the XSLT - find the `A` tag and add an attribute `target="_blank"` |
What type of logging are you using? Is there some way you can override the default logging behavior to just disregard all log messages? |
If you want to have the data source to always be on the safe side of concurrency, you should have at least one pointer that is always safe for him to use.
So the Observer object should have a lifetime that isn't ended before that of the data source.
This can be done by only adding Observers, but never removing the... |
|linux|optimization|compiler-construction|gcc|macros| |
Yup it's a pickle.
I've managed to solve this by extending the memcache class with a custom class (say ExtendedMemcache) which has a protected property which will contain a hash table of group to key values.
The ExtendedMemcache->set method accepts 3 args ($strGroup, $strKey, $strValue)
When you call set, it wi... |
(general comment - other answers cover the details)
There's no reason that you should lose portability by using them.
You always have the option of creating a simple nil-effect "inline" or macro that will allow you to compile on other platforms with other compilers.
You just won't get the benefit of the optimi... |
I prefer single line statements with out brackets, I know that there is the danger that I can forget to add them when I insert a new line of code, but I cannot remember the last time this happened. My editor (vim) prevents me to write things like this:
<pre><code>
if (x)
x = x + 1;
printf("%d\n", x);
</c... |
These are macros that give hints to the compiler about which way a branch may go. The macros expand to GCC specific extensions, if they're available.
GCC uses these to to optimize for branch prediction. For example, if you have something like the following
if (unlikely(x)) {
dosomething();
}
... |
Table-driven methods are schemes that allow you to look up information in a table rather than using logic statements (i.e. case, if). In simple cases, it's quicker and easier to use logic statements, but as the logic chain becomes more complex, table-driven code is simpler than complicated logic, easier to modify and m... |
Bash prompt in OS X terminal broken |
|macos|unix|bash| |
I am using bash in os X Terminal app, and my custom $PS1 breaks when I scroll through my history.
PS1="${BLUE}\u${CYAN}@${RED}\h${BLUE}\w\n\[${red}\$${NC}\]"
also tried
PS1="${BLUE}\u${CYAN}@${RED}\h${BLUE}\w\r\n\[${red}\$${NC}\]"
The problem seems to be in the newline. I have used this bash prompt o... |
You should really specify the language / framework you're using.
In the simplest case, I suppose it should be easy to detect `assert(true)` strings with simple `grep`-ping. |
I'm using maven in anger at work. It's a harsh mistress. It makes things easy as long as you're doing things many other people have and, this is important, as long as you're doing them the way maven thinks you should be doing them. Step off that narrow path and it will fight you every step of the way.
I've been impr... |
On POSIX systems there is the endian.h, which can be determined what encoding your system uses. From there it's something like this:
unsigned int change_endian(unsinged int x)
{
unsigned char *ptr = (unsigned char *)&x;
return (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3];
... |
You could always try a test run with garbage for the application configuration values.
Any tests that pass are suspect? |
We do exactly what you do in our projects, and we use maven. You'd want to use maven to have a standardized layout and way to build your project. You never have to store all those jar dependencies in SVN or keep them somewhere special, maven does that for you. Maven also serves as a means to get other developers to ... |
If the problem seems to be with the newline, try putting \r\n instead of just \n and see if it makes a difference. |
You should be able to associate .sh files with \CYGWIN\usr\bin\bash.exe. The script will have to change its own working directory, I suggest sticking something like this at the top:
cd `dirname "$0"` |
Combine the strategies to reduce the disadvantages of a single approach. I work in embedded systems so the following solution is based on the fact that int & bitwise operators are fast, low memory & low in flash usage.
Place the enum in a namespace to prevent the constants from polluting the global namespace.
... |
What is the best Linux distribution for Vmware server? |
|linux| |
In terms of Webserver and low package size installation. |
Until I started using the EntLib ExceptionBlock, I was using them to log errors before throwing them. Kind of nasty when you think I could have handled them at that point, but at the time it was better to have them fail nastily in UAT (after logging them) rather than cover a flow-on bug. |
If you're using FastMM4 as your Memory Manager, you can check that the class is not **TFreeObject**.
Or, in a more standard case, use a routine that will verify that your object is what it says it is by **checking the class VMT**.
There have been such ValidateObj functions hannging around for some time (by Ray Li... |