instruction stringlengths 0 30k ⌀ |
|---|
Alternatives to System.exit(1) |
|java|process| |
For various reasons calling System.exit is frowned upon when writing Java Applications, so how can I notify the calling process that not everything is going according to plan? |
For various reasons calling System.exit is frowned upon when writing Java Applications, so how can I notify the calling process that not everything is going according to plan?
**Edit:** The 1 is a standin for any non-zero exit code. |
|java|processes| |
Can you force either a scalar or array ref to be an array in Perl? |
|perl|scalar|array| |
I have a perl variable `$results` that gets returned from a service. The value is supposed to be an array, and `$results` should be an array reference. However, when the array has only one item in it, `$results` will be set to that value, and not a referenced array that contains that one item.
I want to do a `fore... |
|perl|arrays|scalar| |
I have a perl variable `$results` that gets returned from a service. The value is supposed to be an array, and `$results` should be an array reference. However, when the array has only one item in it, `$results` will be set to that value, and not a referenced array that contains that one item.
I want to do a `fore... |
|perl|arrays|reference|scalar| |
Windows built-in ZIP compression script-able? |
|windows|batch-file|script|vbscript|zip| |
Is the zip compression that is built into Windows XP/Vista/2003/2008 able to be scripted at all? What executable would I have to call from a BAT/CMD file? or is it possible to do it with VBScript?
I realize that this is possible using WinZip, 7-zip and other external apps, but I'm looking for something that requires... |
|windows|batch-file|vbscript|scripting|zip| |
I don't think you'll find it in the C spec, more likely the spec for your OS. My experience in Linux has been that it's always the lowest. |
If you are actually looking for Charting libraries and not for Node/Edge Graph libraries I would suggest splurging on Big Faceless Graph library ([BFG][1]). It's way easier to use than JFreeChart, looks nicer, runs faster, has more output options, really no comparison.
[1]: http://big.faceless.org/products/grap... |
The best way would be to add a common base class, otherwise you can fall back to reflection. |
You could just write a 'brute force' command line tool that comments out the #includes one by one and tests whether the compile still works. Let me know when you've got it to work. ;0) |
I'll counter this with another question - why does this matter? You shouldn't be comparing the file descriptor with anything (unless checking for stdin/stdout/stderr) or doing math with it. As long as it fits in an int (and its guaranteed to) that's all you really need to know. |
I've tried various techniques and had most success with [SWFUpload](http://swfupload.org).
You create and interact with an SWFUpload object using Javascript, but uses a (hidden) Flash file for file selection, uploading and upload progress monitoring. You can specify a wide range of Javascript event handlers (<code>u... |
This may be a bit off topic (I'm replying specifically to your question about source control and graphics), but you *can* put binary data (images etc.) into source control (and in my opinion in a lot of cases should) -- they just take up more disk space and you can't use a diff view to analyze what has changed in any m... |
Steve M is right; C has no notion of sockets, and its file I/O functions use a [pointer to a] FILE object, not a descriptor. |
How to discover USB storage devices and writable CD/DVD drives (C#) |
|c#|.net-2.0| |
How can I discover any USB storage devices and/or CD/DVD writers available at a given time (using C# .Net2.0).
I would like to present users with a choice of devices onto which a file can be stored for physically removal - i.e. not the hard drive. |
Solaris :)
On a serious note, there is no Linux distro dedicated to Java, so it would be about the same.
[OpenSolaris][1] on the other hand (in my *very* humble experience) would be a bit faster, and you would have bonus of Dtrace as a tool. (Not that you can't find similar tools in Linux, but Dtrace should be s... |
Referring to [the bible](http://plan9.bell-labs.com/cm/cs/cbook/):
- Your addition operation causes the int to be converted to an unsigned int.
- Assuming two's complement representation and equally sized types, the bit pattern does not change.
- Conversion from unsigned int to signed int is implementation d... |
Top on my list are:
1. Software Engineering Radio
2. Java Posse
Sometimes I also listen to:
The ASP.NET podcast
I keep an eye on iTunes U as some courses have the perfect price (free) from top-notch Universities around the world. E.g. Computer Language Engineering from MIT. |
Be aware that classes that descend from NumberFormat (and most other Format descendants) are not synchronized. It is a common (but dangerous) practice to create format objects and store them in static variables in a util class. In practice, it will pretty much always work until it starts experiencing significant load. |
You could try looking at the lower tier offerings from AT&T and Comcast. Probably 1.5 Mbps for the basic level (which I imagine most people get).
The "test your bandwidth" sites may have some stats on this, too. |
It would depend on the geography that you are targeting. For example, in India, you can safely assume it would be a number below 256kbps. |
[Speedtest.net][1] has a lot of stats broken down by country, region, city and ISP. Not sure about accuracy, since it's only based on the people using their "bandwidth measurement" service.
[1]: http://speedtest.net/global.php |
There are a lot of factors involved (server bandwidth, local ISP, network in between, etc) which make it difficult to give a hard answer. With my current ISP, I typically get 200-300 kB/sec. Although when the planets align I've gotten as much as 2 MB/sec (the "quoted" peak downlink speed). That was with parallel str... |
How to promote WCF to a non-techie? |
|c#|.net|web-services|wcf| |
How would you describe and promote WCF as a technology to a non-technical client/manager/CEO/etc?
What are competing solutions or ideas that they might bring up(such as those they read about in their magazines touting new technology)?
What is WCF *not* good for that you've seen people try to shoehorn it into?
... |
|c#|.net|web-services|wcf|soa| |
In vim is there a way to delete without putting text in the register? |
|vim|vi| |
Using vim I often want to replace a block of code with a block that I just yanked.
But when I delete the block of code that is to be replaced, that block itself goes into the register which erases the block I just yanked. So I've got in the habit of yanking, then inserting, then deleting what I didn't want, but with l... |
I guess if you could store this information with Javascrit and cookies for the functionality of remembering the bookmarks and even add a splash of Ajax if you wanted to interact with a database.
CSS would only be able todo the styling bit. You would have to give the bookmarked anchor a class found in ur css file.
... |
If A, B, C and D have nothing in common then adding a base class won't really get you anything. It will just be an empty class and in effect will be the same as object.
I'd just create an ErrorItem class without the generics, make Item an object and do some casting when you want to use the objects referenced. If you... |
It depends on when you want to determine this. You could print the "value" of, say, a label control (which has no "value" property) to the debugger like:
debug.print("Value for cmdTest is ["+format(cmdTest)+"]"
Which will give you something like:
> Value for cmdTest is [False]
As it turns out, the defa... |
It depends on when you want to determine this. You could print the "value" of, say, a label control (which has no "value" property) to the debugger like:
debug.print "Value for cmdTest is ["+format(cmdTest)+"]"
Which will give you something like:
> Value for cmdTest is [False]
As it turns out, the defa... |
|version-control|decentralized-version-co|distributed| |
|version-control|distributed|dvcs| |
Changing CURRENT save/default directory in Delphi 2007 without using Save-As |
|delphi|delphiide| |
I have a project group that contains a project I'm working on as well as some related component / packages. I prefer to have the database links active at design time, and though I know how to write the code to change database files location, I'm just using ".\data" for that in this case, for a few different reasons, m... |
|ide|delphi| |
Mootools: Drag and Drop problem |
|mootools|javascript|drag|dragdrop|drop| |
|javascript|dragdrop|mootools| |
|javascript|drag-and-drop|mootools| |
I've asked this question to the forums on the Mootools website and one person said that my class selection was corrupted before an admin came along and changed my post status to invalid. Needless to say this did not help much. I then posted to a google group for mootools with no response. My question is why doesn't ... |
I had a REALLY hard to track down bug years ago that was caused by this. The code was something like
Object problemMethod() {
Object rtn = null;
try {
rtn = somethingThatThrewAnException();
}
finally {
doSomeCleanup();
return rtn;
}
}
What... |
I use dynamic instantiation in my custom framework. My application controller needs to instantiate a sub-controller based on the request, and it would be simply ridiculous to use a gigantic, ever-changing switch statement to manage the loading of those controllers. As a result, I can add controller after controller to ... |
> with loss tolerant
Do you mean "with loss tolerance" ?
Basically, UDP is not "loss tolerant". You can send 100 packets to someone, and they might only get 95 of those packets, and some might be in the wrong order.
For things like video streaming, and multiplayer gaming, where it is better to miss a packet th... |
Having small, obtainable goals is one of the greatest ways to learn any skill. Programming is no different. Python is a great language to start with because it is easy to learn, clean and can still do advanced things. Python is only limited by your imagination.
One way to really get someone interested is to giv... |
I would recommend [GenX][1] as a streaming XML writer, I use this in [Programmer's Notepad][2] and it works a treat, you can see examples of use in the source code. Extremely fast, and it produces good UTF-8 XML. Memory usage while you use it should remain roughly constant.
[1]: http://www.tbray.org/ongoing/When/2... |
Twitter for work updates |
|project-management|project-planning|knowledge|knowledge-management| |
If you are sending work/progress reports to the project lead on a daily or weekly basis, I wondered if you would consider using [Twitter][1] or similar services for this updates.
Say if you're working remotly or with a distributed team and the project lead has a hard time getting an overview about the topics people ... |
|project-management|project-planning|knowledge-management|knowledge| |
If you are sending work/progress reports to the project lead on a daily or weekly basis, I wondered if you would consider using [Twitter][1] or similar services for this updates.
Say if you're working remotly or with a distributed team and the project lead has a hard time getting an overview about the topics people ... |
Involve the graphic designer in early design and architecture sessions.
You want to involve them to reveal misaligned assumptions and to establish a pattern of working together rather than throwing things back and forth over the wall.
|
I also would not recommend using office apps on a server except for data access to mdb files.
I can definitely understand that there are times where it is necessary. In thoses cases
I would recommend the following:
- Create a separate server where that is the only function. (Let's you reboot with minimum im... |
What to do with queries who don´t have a representation in a domain model? |
|orm| |
I use the following bit of Python to launch p4merge and use it with git :
#!/usr/bin/python
import sys
import os
os.system('/Applications/p4merge.app/Contents/MacOS/p4merge "%s" "%s"' % (sys.argv[2], sys.argv[5]))
I'm not sure how mercurial looks to launch an external diff tool though ? Hopef... |
Well, first do this command:
:h d
Then you will realize that you can delete into a specific register. That way you won't alter what is in your default register. |
In light of your update:
var inputs = document.getElementsByTagName('input');
var lastTextBox = null;
for(var i = 0; i < inputs.length; i++)
{
if(inputs[i].getAttribute('type') == 'text')
{
inputs[i].onfocus = function() {
lastTextBox = this;
}
... |
For the specific example that you gave, if I understand the question then this might work:
*Highlight what you want to put somewhere else
*delete (d)
*Highlight the code that you want it to replace
*paste (p) |
I figured it out myself. The type you're looking for is "HTML" not RichHTML. |
I vote for the "sneak in refactorings" approach, which is, I believe, the way refactoring is meant to be done in the first place. It's probably a bad idea to refactor just for the sake of "cleaning up the code." This means that you're making changes for no real reason. Refactoring is, by definition, modifying the wi... |
Use your favorite JS toolkit to add a "highlight" (or whatever) class to the item containing (or contained in) the anchor.
Something like:
jQuery(location.hash).addClass('highlight');
Of course, you'd need to call that onready or click if you want it triggered by other links on the page, and you'll want to... |
You can also pass the arguments inside the ant task
<arg value="-J-Dhttp.proxyHost=your.proxy.here"/>
<arg value="-J-Dhttp.proxyPort=##"/>
If going the offline link route. Download the package list by going to the URL of the Java API (http://java.sun.com/j2se/1.5.0/docs/api/package-list) and saving it a... |
Hide directories in wxGenericDirCtrl |
|wxwidgets|wxpython| |
.NET has a pretty straight forward way to read and watch STDOUT. <br />
I guess this would be the cleanest way, since it is not dependent on any external files, just the path to rsync. I would not be too surprised if there is a wrapper library out there either. If not, write and open source it :) |
You can use an instance of the string formatter object passed in to the drawstring method to centre the text.
see <http://msdn.microsoft.com/en-us/library/21kdfbzs.aspx> and <http://msdn.microsoft.com/en-us/library/system.drawing.stringformat.aspx> |
Here's some code. This assumes you are doing this on a form, or a UserControl.
Graphics g = this.CreateGraphics();
SizeF size = g.MeasureString("string to measure");
int nLeft = Convert.ToInt32((this.ClientRectangle.Width / 2) - (size.Width / 2));
int nTop = Convert.ToInt32((this.ClientRecta... |
Check out I think it is called Delta Sync. It is a windows gui for rsync (i believe) |
Check out I think it is called DeltaCopy. It is a windows gui for rsync (i believe)
Looked it up. DeltaCopy http://www.download.com/DeltaCopy/3000-2242_4-10471616.html |
Printing from a .NET Service |
|.net|c#|windows|service|printing| |
I am working on a project right now that involves receiving a message from another application, formatting the contents of that message, and sending it to a printer. Technology of choice is C# windows service. The output could be called a report, I suppose, but a reporting engine is not necessary. A simple templatin... |
|c#|.net|windows|service|printing| |
I am working on a project right now that involves receiving a message from another application, formatting the contents of that message, and sending it to a printer. Technology of choice is C# windows service. The output could be called a report, I suppose, but a reporting engine is not necessary. A simple templatin... |
I've asked this question to the forums on the Mootools website and one person said that my class selection was corrupted before an admin came along and changed my post status to invalid. Needless to say this did not help much. I then posted to a google group for mootools with no response. My question is why doesn't ... |
How can I "unaccept" a drag in Flex? |
|apache-flex|dragdrop| |
Once I've called <code>DragManager.acceptDrag</code> is there any way to "unaccept" the drag? Say that I have a view which can accept drag and drop, but only in certain areas. Once the user drags over one of these areas I call <code>DragManager.acceptDrag(this)</code> (from a <code>DragEvent.DRAG_OVER</code> handler), ... |
Here is a related discussion as to [**why String.Format is static**][1] that will highlight some reasons.
[1]: http://stackoverflow.com/questions/23228/why-is-stringformat-static |
When should a method be static? |
|static|language-agnostic| |
In addition, are there any performance advantages to static methods over instance methods?
I came across the following recently: http://www.cafeaulait.org/course/week4/22.html
I would be very interested in the feedback of the Stack Overflow community on this. |
|language-agnostic|static| |
In addition, are there any performance advantages to static methods over instance methods?
I came across the following recently: http://www.cafeaulait.org/course/week4/22.html :
> When should a method be static?
>
> 1. Neither reads from nor writes to instance fields
> 2. Independent of the state of the obj... |