instruction stringlengths 0 30k ⌀ |
|---|
This is slightly off topic of programming but still has to do with my programming project. I'm writing an app that uses a custom proxy server. I would like to write the server in C# since it would be easier to write and maintain, but I am concerned about the licensing cost of Windows Server + CALS vs a Linux server (... |
JTable Sort |
|java| |
I know that Jtable can sort by a single column. But is it possible to allow for multiple column sort or do i need to write the code myself?
Thanks in advance |
|java|swing| |
If the Flash application is non-interactive, there are many tools that can get non-realtime capture (but completely smooth and perfect) to either an AVI file or a series of PNGs.
If it is interactive and you absolutely need realtime capture, FRAPS might actually be able to do the job, at least on Vista, where its no... |
Although XSLT is based on functional programming ideas, it is not a full functional programming language, it lacks the ability to treat functions as a first class data type.
From [Wikipedia on XSLT][1]:
> As a language, XSLT is influenced by
> functional languages, and by
> text-based pattern matching languages... |
XSLT is declarative as opposed to stateful.
Although XSLT is based on functional programming ideas, it is not a full functional programming language, it lacks the ability to treat functions as a first class data type. It has elements like lazy evaluation to reduce unneeded evaluation and also the absence of explic... |
The origin of 80-column text formatting is earlier than 80-column terminals - the IBM punch card dates back to [1928](http://www-03.ibm.com/ibm/history/history/year_1928.html)! This is reminiscent of the [(apocryphal)](http://www.snopes.com/history/american/gauge.asp) story that the US railway gauge was determined by ... |
Finding common blocks |
|algorithm| |
I have two files (f1 and f2) containing some text (or binary data).<br>
How can I quickly find common blocks?
e.g.<br>
f1: ABC DEF<br>
f2: XXABC XEF
output:
common blocks:<br>
length 4: "ABC " in f1@0 and f2@2
length 2: "EF" in f1@5 and f2@8 |
How to check if a php script is still running |
|php|queue|process|monitoring| |
I have a PHP script that listens on a queue. Theoretically, it's never supposed to die. Is there something like Ruby's God ( http://god.rubyforge.org/ ) for PHP? |
I have a PHP script that listens on a queue. Theoretically, it's never supposed to die. Is there something to check if it's still running? Something like Ruby's God ( http://god.rubyforge.org/ ) for PHP? |
|php|monitoring|process|queue| |
I have a PHP script that listens on a queue. Theoretically, it's never supposed to die. Is there something to check if it's still running? Something like Ruby's God ( http://god.rubyforge.org/ ) for PHP?
God is language agnostic but it would be nice to have a solution that works on windows as well. |
ASP.NET and Timers |
|asp.net|multithreading|timer| |
Consider this code...
using System.Threading;
//...
Timer someWork = new Timer(
delegate(object state) {
//Do some work here...
},
null, 0, 60000);
HttpContext.Current.Application["SomeWorkItem"] = someWork;
Could this be dangerous? Caching a timer in... |
According to Microsoft, Generics are faster than casting (boxing unboxing).
Tony Northrup - co-author of MCTS 70-536: Application Development Foundation - states in the same book the following:
> I haven’t been able to reproduce the
> performance benefits of generics;
> however, according to Microsoft,
> gener... |
Background color stretches accross entire width of ul |
|css| |
I have a simple list I am using for a horizontal menu:
<ul>
<h1>Menu</h1>
<li><a href="/" class="selected">Home</a></li>
<li><a href="/Home">Forum</a></li>
</ul>
When I add a background color to the selected class, only the text gets the color, I want it to stretch the entire d... |
Precise layout of a class or structure is not guaranteed in C++, which is why you should not make assumptions about the size of it from the outside (that means if you're not a compiler).
Probably it works, until you find a compiler on which it doesn't, or you throw some vtable into the mix. |
In a more declarative way, depending on the criteria matching the items to remove you could use:
[theArray filterUsingPredicate:aPredicate]
@Nathan should be very efficient |
The first step to resolving conflicts is to recognize that people are different. Even the most mild mannered programmer's patience can be tried in pair programming, it can be very stressful. Some people withdraw when they are confronted by conflict, others get aggressive.
The best way of approaching pair program... |
If you already have a constructor, why not just initialize it there with n1=0; n2=0; -- that's certainly the more *normal* way.
Edit: Actually, as paercebal has shown, ctor initialization is even better. |
The a element is an inline element, meaning it only applies to the text it encloses. If you want the background color to stretch across horizontally, apply the selected class to a block level element. Applying the class to the li element should work fine.
Alternatively, you could add this to the selected class' CSS:... |
If you are afraid that the link is visible in the Page, create a javascript document that sends a POST request to the server. |
Eclipse has a launch configuration type for running JUnit tests in the context of an Eclipse (i.e. OSGi) application:
http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.pde.doc.user/guide/tools/launchers/junit_launcher.htm
If you need to run tests as part of automated bu ilds,
|
Eclipse has a launch configuration type for running JUnit tests in the context of an Eclipse (i.e. OSGi) application:
http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.pde.doc.user/guide/tools/launchers/junit_launcher.htm
|
|c#|asp.net| |
I am currently writing a small calendar in ASP.Net C#. Currently to produce the rows of the weeks I do the following for loop:
var iWeeks = 6;
for (int w = 0; w < iWeeks; w++) {
This works fine, however, some month will only have 5 weeks and in some rare cases, 4.
How can I calculate the number of row... |
How about checking which week the first and last days will be in? |
I don't really like the flvPlayback-component, it's hard to handle both implementation wise and somewhat tricky to skin nicely and it's also quite bloated. So I'd opt to use either the JW Flash Media Player as recommended by Michael above or rolling my own entirely. |
Bartosz/To clarify "This worked okay, but there was no easy way of checking if x[3][24] was supposed to exist or not"
x['some show][3][24] would return season 3, episode 24 of "some show". If there was no season 3, I want the pseudo-dict to raise tvdb_seasonnotfound, if "some show" doesn't exist, then raise tvdb_sho... |
Bartosz/To clarify "This worked okay, but there was no easy way of checking if x[3][24] was supposed to exist or not"
`x['some show'][3][24]` would return season 3, episode 24 of "some show". If there was no season 3, I want the pseudo-dict to raise tvdb_seasonnotfound, if "some show" doesn't exist, then raise tvdb_... |
Delivering email can be like black magic sometimes. The reverse DNS is really important.
I have found it to be very helpful to carefully track NDRs. I direct all of my NDRs to a single address and I have a windows service parsing them out (Google ListNanny). I put as much information from the NDR as I can into ... |
There still is an ugly solution (which is far inferior to using a framework or addEventListener/attachEvent) that is to save the current onload event:
function addOnLoad(fn)
{
var old = window.onload;
window.onload = function()
{
old();
fn();
};
... |
The language attribute was used in HTML 3.2. HTML 4.0 introduced type (which is consistent with other elements that refer to external media) and deprecated language.
Use type. Do not use language.
In HTML, there is no difference between attribute values delimited using single or double quotes (except that you can... |
The language attribute was used in HTML 3.2. HTML 4.0 introduced type (which is consistent with other elements that refer to external media, such as <code><style></code>) and <a href="http://www.w3.org/TR/html401/conform.html#deprecated">deprecated</a> language.
Use <a href="http://www.w3.org/TR/html401/interact/... |
The language attribute was used in HTML 3.2. HTML 4.0 introduced type (which is consistent with other elements that refer to external media, such as <code><style></code>) and <a href="http://www.w3.org/TR/html401/conform.html#deprecated">deprecated</a> language.
Use <a href="http://www.w3.org/TR/html401/interact/... |
The language attribute was used in HTML 3.2. HTML 4.0 introduced type (which is consistent with other elements that refer to external media, such as <code><style></code>) and make it required. It also <a href="http://www.w3.org/TR/html401/conform.html#deprecated">deprecated</a> language.
Use <a href="http://www.w... |
The language attribute was used in HTML 3.2. HTML 4.0 introduced type (which is consistent with other elements that refer to external media, such as <code><style></code>) and made it required. It also <a href="http://www.w3.org/TR/html401/conform.html#deprecated">deprecated</a> language.
Use <a href="http://www.w... |
|language-agnostic|url|naming-conventions| |
|language-agnostic|url|seo|naming-conventions| |
In my experience, compiler optimizations rarely improve more than a few percent between versions at most; if you really need more performance, that few percent just isn't going to cut it--you're going to have to get down and dirty in the code if you want more.
Remember, compilers are extremely dumb, and can usually ... |
Why do I get "java.net.BindException: Only one usage of each socket address" if netstat says something else? |
|jetty|sockets|java| |
- I start up my application which uses a Jetty server, using port 9000.
- I then shut down my application with Ctrl-C
- I check with "netstat -a" and see that the port 9000 is no longer being used.
- I restart my application and get:
> [ERROR,9/19 15:31:08] java.net.BindException: Only one usage o... |
|java|sockets|jetty| |
- I start up my application which uses a Jetty server, using port 9000.
- I then shut down my application with Ctrl-C
- I check with "netstat -a" and see that the port 9000 is no longer being used.
- I restart my application and get:
> [ERROR,9/19 15:31:08] java.net.BindException: Only one usage of ... |
navigator.onLine
That should do what you're asking.
You probably want to check that in whatever code you have that updates the page. Eg:
if (navigator.onLine){
updatePage()
}else{
displayOfflineWarning()
} |
What is the best method of inter-process communication between Java and .NET 3.5? |
|c#|.net|java|ipc| |
A third-party application reads some Java code from an XML file, and runs it when a certain event happens. In Java, I want to tell a .NET 3.5 application, running on the same machine, that this event occurred. The total data transferred each time is probably a few characters.
What is the best way of using Java to te... |
Stateful web services are a pain to maintain. The mechanism I have seen for them is to have the first call return an id (basically a transaction id) that is used in subsequent calls. A problem with that is that the web service isn't really stateful so it has to load all the information that it needs from some other d... |
looking for a good summary of SQL 2005 Partitioning |
|sql-server|sqlpartitions| |
I'm looking at [this][1] as a baseline explanation of the SQL 2005 Enterprise partitioning. Is there a resource that goes deeper into fine points and considerations of this issue. Some more examples would be useful too.
My main scenario is a time based partition system. With one partition that has the most accessed ... |
I just implemented the jquery autocomplete textbox in one of my asp.net project. I only had to import the js file and drop some code into my aspx page. Could you be more detailled about what sample you are trying to run? |
2^(x+y) = 2^x * 2^y
2^10 ~ 1,000
2^20 ~ 1,000,000
2^30 ~ 1,000,000,000
2^40 ~ 1,000,000,000,000
(etc.)
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128
2^8 = 256
2^9 = 512
So, 2^31 (signed int max) is 2^30 (about 1 bill... |
I can compile your code sample fine, you should check your designer file to make sure everything is ok. |
I can compile your code sample fine, you should check your designer file to make sure everything is ok.
EDIT: the only other thing I can think of is that this is some sort of reference problem. Is your System.Web.Extensions reference using the correct version for your targeted framework? (should be 3.5.0.0 for .net ... |
In the case you mention, it doesn't affect callers of your API, which is why it's not commonly done (and isn't necessary in the header). It only affects the implementation of your function.
It's not particularly a bad thing to do, but the benefits aren't that great given that it doesn't affect your API, and it adds... |
First, try using SQL Profiler to generate a .trc file of activity in your database for a normal workload over a few hours. And then use the "Database Engine Tuning Advisor" on the SQL Server Management Studio Tools menu to see if it suggests any additional indexes, composite indexes, or covering indexes that may be be... |
Use of 'const' for function parameters |
|c++|constants| |
How far do you go with const? Do you just make functions const when necessary or do you go the whole hog and use it everywhere? For example, imagine a simple mutator that takes a single boolean parameter:
`void SetValue(const boolen b) { my_val_ = b; }`
Is that const actually useful? Personally I opt to use it... |
|c++|constants| |
I wouldn't put const on parameters like that - everyone already knows that a boolean (as opposed to a boolean&) is constant, so adding it in will make people think "wait, what?" or even that you're passing the parameter by reference. |
the thing to remember with const is that it is much easier to make things const from the start, than it is to try and put them in later.
Use const when you want something to be unchanged - its an added hint that describes what your function does and what to expect. I've seen many an C API that could do with some of ... |
See also [this question][1]
[1]: http://stackoverflow.com/questions/56168/test-cases-and-assertion-statements#56174 |
Ah, a tough one. On one side, a declaration is a contract and it really does not make sense to pass a const argument by value. On the other hand, if you look at the function implementation, you give the compiler more chances to optimize if you declare an argument constant. |
If you want to do this properly, you should definitely look into setting up a local SVN repository. I would also highly recommend setting up a continuous integration (CI) server such as cruise control, which would automatically run any tests against your PHP code when ever you check in to svn. Your CI server could al... |
Having separare class for persisting Employee looks more OO. And more flexible, because you potentially may want to have DBEmployeeMrg, FileSystemEmployeeMrg, InMemoryEmployeeMgr and MockEmployeeMgr for testing - all those classes may implement inteface EmployeeMrg in different way.
For your code to be shorter you m... |
Tips for avoiding big ball of mud with ASP.NET WebForms |
|asp.net|webforms| |
Although ASP.NET MVC seems to have all the hype these days, WebForms are still quite pervasive. How do you keep your project sane? Let's collect some tips here. |
I think Michal Kralik best answer in my opinion based on server performance. Doing subselects or stored procedures for such simple logic really is not worth it.
The only way I would improve on Michal's logic is if you are doing this query multiple times in one script. In this case I would query for the 0's first, ... |
Hmmm. From the Excel menu choose Window -> Compare side by side? |
Replace one URL with another |
|php| |
In PHP, replace one URL with another within a string e.g.
'New post on the site <a href="http://stackoverflow.com/xyz1">http://stackoverflow.com/xyz1</a></p>'
becomes:
'New post on the site <a href="http://yahoo.com/abc1">http://yahoo.com/abc1</a></p>'
Must work for repeating strings as above. Appreciate this is... |
In PHP, replace one URL with another within a string e.g.
New post on the site <a href="http://stackoverflow.com/xyz1">http://stackoverflow.com/xyz1</a></p>
becomes:
New post on the site <a href="http://yahoo.com/abc1">http://yahoo.com/abc1</a></p>
Must work for repeating strings as above. Apprecia... |
Commit early, commit often.
Or in this case... Merge early, merge often. |
You could do something like this:
>>> import re
>>> pattern = re.compile(r'\s*("[^"]*"|.*?)\s*,')
>>> def split(line):
... return [x[1:-1] if x[:1] == x[-1:] == '"' else x
... for x in pattern.findall(line.rstrip(',') + ',')]
...
>>> split("foo, bar, baz")
['foo', 'b... |
Forget my previous post, I've got a better idea.
sub match_positions {
my ($regex, $string) = @_;
return if not $string =~ /$regex/;
return ($-[0], $+[0]);
}
sub match_all_positions {
my ($regex, $string) = @_;
my @ret;
while ($string =~ /$regex/g) ... |
In the web.config, you can set safe="false" for the SafeControl tag for the webpart. This will cause the web part to render an error message until you set it back to true.
http://technet.microsoft.com/en-us/library/cc287909.aspx
|
How do you multiply two 64bit numbers in Assembly? |
|assembly| |
As the title states, I need to multiply two 64bit numbers in Assembly, or two 16digit hexidecimal numbers.
Help please? I'm only allowed to use registers %eax, %ebx, %ecx, %edx, and the stack. |
|assembly| |
As the title states, I need to multiply two 64bit numbers in Assembly, or two 16digit hexidecimal numbers.
Help please? I'm only allowed to use registers %eax, %ebx, %ecx, %edx, and the stack.
EDIT: Oh, I'm using ATT Syntax on the x86
EDIT2: Not allowed to decompile into assembly... |
If you are talking 'cloud computing' here, the answer would be to localize each transaction to the place where it happens in the cloud. There is no need for entire cloud to be consistent, as that would kill performance (as you noted). Simply, keep track of what is changed and where and handle multiple small transaction... |
I think you'd benefit from using + which means "1 or more", instead of * meaning "any number including zero". |
Are you resizing larger, or smaller? By a small % or by a larger factor like 2x, 3x? What do you mean by quality for your application? And what type of images - photographs, hard-edged line drawings, or what? Writing your own low-level pixel grinding code or trying to do it as much as possible with existing libr... |
- I start up my application which uses a Jetty server, using port 9000.
- I then shut down my application with Ctrl-C
- I check with "netstat -a" and see that the port 9000 is no longer being used.
- I restart my application and get:
> [ERROR,9/19 15:31:08] java.net.BindException: Only one usage of ea... |