instruction stringlengths 0 30k ⌀ |
|---|
From my experience, the only thing that matters is which one is easier to mock in unit tests. I always felt Singleton is easier and natural to mock out. If your organization lets you use JMockit, it doesn't matter since you can overcome these concerns. |
I use [wireshark][1]. Very good and free.
[1]: http://www.wireshark.org/ |
I think it depends on the content of the site. Sites like SOFlow, Forums, and other sites have an emphasis on reading lots of details, so having more real estate to do so is a big benefit in my mind. The less vertical scroll, the better.
However, for sites a little less demanding on the reading level, even blogs or ... |
[Wireshark][1] is a really good and mature network sniffer. It's been around for years.
* Deep inspection of hundreds of protocols, with more being added all the time
* Live capture and offline analysis
* Decryption support for many protocols, including IPsec, ISAKMP, Kerberos, SNMPv3, SSL/TLS, WEP, and WPA/WPA2
... |
For virtualization, I'd try Sun's [Virtual Box][1]. I use it in Windows XP and Windows Vista and it works great, I expect performance would be similar running on a Mac.
As for which OS to run, I would stick with Windows XP Pro. You'll not need to dedicate as much RAM to the VM as you would if you ran Vista.
... |
[search for color on useit][1]
[search for color on boxesandarrows][2]
There has been loads of research on this sort of stuff and most of it is conflicting a couple of good jump off points are listed above.
Generally lighter backgrounds and good contrast are favoured by all researchers but the details get nig... |
I would say that using the right combination of colors is user-friendly. Make sure your colors coordinate with each other and you should be fine.
A tool I use a lot is kuler (http://kuler.adobe.com). It'll help you pick colors that work well with each other.
|
[ColorSchemer][1] will suggest good schemes for you.
If you want to try something out on your own, try [Color Combinations][2].
[1]: http://www.colorschemer.com/online.html
[2]: http://www.colorcombos.com/ |
Wireshark, aka Ethereal comes with a fair amount of TCP sniffing functionality.
[http://www.wireshark.org/][1]
[1]: http://www.wireshark.org/ |
Creating static final constants in a separate class can get you into trouble. The Java compiler will actually optimize this and place the actual value of the constant into any class that references it.
If you later change the 'Constants' class and you don't do a hard re-compile on other classes that reference that ... |
What is a symbol? |
|c|c++| |
Can someone describe what a symbol table is in a C and C++ application? |
What is a symbol table? |
|c++|c|programming-languages| |
You could pluginize it (use script/generate plugin).
Then in your init.rb just do something like:
ActiveRecord::Base.send(:include, PluginName::Sendable)
ActionController::Base.send(:include, PluginName::SendableController)
And along with your self.included that should work just fine.
Check out s... |
Something like this might do the trick
<pre>
import java.io.IOException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.lang... |
This is my version, which, unlike the OP's version, doesn't assume that `std::basic_string` has its data in contiguous region:
#include <string>
using std::string;
static char const* digits("0123456789ABCDEF");
string
tohex(string const& data)
{
string result(data.size... |
I've always been partial to:
ctrl-E # move cursor to end of line
ctrl-A # move cursor to beginning of line
I also use <code>shopt -s cdable_vars</code>, then you can create bash variables to common directories. So, for my company's source tree, I create a bunch of variables like:
export Dcentmain... |
@Mendelt Siebenga
Strings are corner-stone objects in programming languages. Different languages implement strings differently. An implementation of `join()` strongly depends on underlying implementation of strings. Pseudocode doesn't reflect underlying implementation.
Consider `join()` in Python. It can be easil... |
Take a look at Microsoft SQL Server Compact Edition. I believe you can work with MDF files without having to run a server. All code runs in process. I believe it has some limitations but it may work for you and I think it's free. |
I would look more at the uninstalling of AVG as the culprit. OneCare does not care or even notice SQL Server instances as far as I can tell where as AVG does.
I would look into your SQL Server instance and check the jobs. One or more may have been added by AVG. You should remove them. You might also want to dr... |
You need to wrap the code in a session scope, like this:
using(new SessionScope())
{
a.Save();
b.Save();
c.Save();
}
Read more [here][1].
[1]: http://www.castleproject.org/activerecord/documentation/v1rc1/usersguide/scopes.html |
The [first hit](http://www.rubyinside.com/trollop-command-line-option-parser-for-ruby-944.html) on google for "[processing command line options in ruby](http://www.google.com/search?q=processing%20command%20line%20options%20in%20ruby&sourceid=mozilla2&ie=utf-8&oe=utf-8)" is an article about [Trollop](http://trollop.rub... |
> +1 for SQL Server Compact. It's free and there's no 'engine' in the sense of a full-time service, but you do have to deploy a runtime (it's just two .dll files).
Does linq to sql work with that though? |
The easiest way to create a wizard dialog is to use one of the third-party versions available that handle all of the "hard stuff" (the page navigation, UI framework, etc.) for you. The one I like the most is from [Divelements][1]; they have both a WinForms and a WPF version.
[1]: http://divelements.co.uk/net/ |
Don't do lazy loading over a service interface. Define explicit DTO's and consume those as your data contracts in WCF.
You can use NHibernate (or other ORMs) to properly fetch the objects you need to construct the DTOs. |
Do you have to create your member object after you declare the transaction? That's the only difference I can see between your code and [the documentation][1].
[1]: http://www.castleproject.org/ActiveRecord/documentation/v1rc1/usersguide/scopes.html |
Ben's got it. That doc is a little confusing. Refer to the last block [on the page][1], "Nested transactions".
[1]: http://www.castleproject.org/ActiveRecord/documentation/v1rc1/usersguide/scopes.html |
How to detect file ends in newline? |
|svn|bash|text-files| |
Over at [Can you modify text files when committing to subversion?](http://stackoverflow.com/questions/38664/can-you-modify-text-files-when-committing-to-subversion) [Grant](http://stackoverflow.com/questions/38664/can-you-modify-text-files-when-committing-to-subversion#38666) suggested that I block commits instead.
... |
@Mendelt Siebenga
Strings are corner-stone objects in programming languages. Different languages implement strings differently. An implementation of `join()` strongly depends on underlying implementation of strings. Pseudocode doesn't reflect underlying implementation.
Consider `join()` in Python. It can be easil... |
If you are talking about .Net, then don't forget the [ThreadPool][1]. The thread pool is also what asynch functions often use. Spawning to much threads can actually hurt your performance. A thread pool is designed to spawn just enough threads to do the work the fastest. So do use a thread pool instead of spwaning your ... |
The use of threads makes you think more about the way your application needs threading and can in the long run make it easier to improve / control your performance.
Async methods are faster to use but they are a bit magic - a lot of things happen to make them possible - so it's probable that at some point you will n... |
Using [GCC][1]
__asm__("movl %edx, %eax\n\t"
"addl $2, %eax\n\t");
Using [VC++][2]
__asm {
mov eax, edx
add eax, 2
}
[1]: http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
[2]: http://msdn.microsoft.com/en-us/library/4ks26t93(VS.71).aspx |
I actually think both of them kinda suck. Using [tortoiseSVN][1] is a far better solution in my opinion. It's far more robust and tends to just work better, I've always had integration issues with subclipse and subversive.
[1]: http://tortoisesvn.tigris.org/ |
I'll add [Moq][1] to the list for mocking to the list. Much less syntax than most other mocking frameworks.
[1]: http://code.google.com/p/moq/ |
Getting user photo from SPUser using WSS Object model |
|sharepoint|wss|user|photo| |
I'm trying to retrieve a user on sharepoint's user photo through the WSS 3.0 object model. I've been browsing the web for solutions, but so far I've been unable to find a way to do it. Is it possible, and if so how? |
|sharepoint|user|wss|photo| |
This is what we use for our team:
**Issue Tracking:** Redmine - This is an awesome, free, Issue/Project management tool. It is a ruby on rails app however, so you'll need a proper environment to get it up and running.
**Source Control:** Subversion with tortoiseSVN - subversion is an awesome source control solut... |
I would suggest looking at [SOUNDEX][1] to find similar words in your database.
[1]: http://en.wikipedia.org/wiki/Soundex |
I would suggest looking at [SOUNDEX][1] to find similar words in your database.
You can also access google own dictionary by using the [Google API spelling suggestion request][2].
[1]: http://en.wikipedia.org/wiki/Soundex
[2]: http://code.google.com/apis/soapsearch/reference.html#1_3 |
Soundex and "Porter stemming" (soundex is trivial, not sure about porter stemming). |
Hm. Works fine on mine, so let's see if we can work out how your setup is different...
It looks as though it's having trouble populating the control; my first guess would be that this is because the code makes so many assumptions about the lists it's talking to. Can you check that you've got a plain vanilla Team sit... |
`eval()` function was covered in other responses here. I agree you should limit use of `eval` unless it is absolutely needed. Instead of having PHP code in db you could have just a class name that has method called, say, `execute()`. Whenever you need to run your custom PHP code just instantiate the class of name you j... |
I've had the _EXACT_ same issue!
I used to use project references, but it all seems to go bad, when as you say, you have many projects referencing it.
I now compile to a DLL, and set the CopyLocal property for the DLL reference to false after the first build (otherwise I find it can override sub projects and just... |
`Page_Load` fires before `btnSubmit_Click`.
If you want to do something after your postback events have fired use `Page_PreRender`.
//this will work because YourName has now been set by the click event
protected void Page_PreRender(object sender, EventArgs e)
{
if (Page.IsPostBack)
... |
Check [this](http://en.wikipedia.org/wiki/Levenshtein_distance) article on wikipedia about the Levenshtein distance. Make sure you take a good look at Possible improvements. |
Setting viewstate on postback |
|asp.net|postback| |
iTunes warning message on quit due to scripting |
|itunes|powershell| |
Wrote the following in PowersHell as a quick iTunes demonstration:
$iTunes = New-Object -ComObject iTunes.Application
$LibrarySource = $iTunes.LibrarySource
foreach ($PList in $LibrarySource.Playlists)
{
write-host $PList.name
}
This works well and pulls back a list of playlist name... |
|powershell|itunes| |
Wrote the following in PowersHell as a quick iTunes demonstration:
$iTunes = New-Object -ComObject iTunes.Application
$LibrarySource = $iTunes.LibrarySource
foreach ($PList in $LibrarySource.Playlists)
{
write-host $PList.name
}
This works well and pulls back a list of playlist name... |
If you want to purchase a book, I believe Software Requirements by Karl Weigers (sp?) has templates for a few documents as an appendix. Unfortunately, I'm at work and that particular book is at home. If someone has it handy, they might be able to confirm that. |
If you want to purchase a book, [Software Requirements by Karl Wiegers][1] has templates for a few documents as an appendix. Unfortunately, I'm at work and that particular book is at home. If someone has it handy, they might be able to confirm that.
[1]: http://www.amazon.com/Software-Requirements-Second-Pro-Bes... |
I've done exactly as hazzen commented (using an embedded DSL in a scripting language). It was a mildly interesting exercise, but except for the most basic tests of e.g. parsing, it wasn't terribly useful. Most of my most interesting tests have to do with more sophisticated relationships than one can easily express in B... |
[This page][1] has a sample of how you can remove non-alphanumeric chars:
-- Put something like this into a user function:
DECLARE @cString VARCHAR(32)
DECLARE @nPos INTEGER
SELECT @cString = '90$%45623 *6%}~:@'
SELECT @nPos = PATINDEX('%[^0-9]%', @cString)
WHILE @nPos > 0
BE... |
In Ruby, converting to lowercase and stripping everything not alphabetic:
def isPalindrome( string )
( test = string.downcase.gsub( /[^a-z]/, '' ) ) == test.reverse
end
But that feels like cheating, right? No pointers or anything! So here's a C version too, but without the lowercase and characte... |
Why not create your own #define and get in the habit of using it?
I.e.
<pre><code>#define SafeDelete(mem) { delete mem; mem = NULL; }
#define SafeDeleteArray(mem) { delete [] mem; mem = NULL; }</code></pre>
Obviously you can name it whatever you like. deleteZ, deletesafe, whatever you're comfortable with.
... |
For source code management, centralized systems such as subversion are superior for scientific use due to the clear single point of truth (SPOT). Logging of changes and ability to recall versions of any file, without having chase down where to find something, has huge record-keeping advantages. Tools like git and mon... |
The time complexities would be worse, though. A good queue implementation does everything in constant time. |
Maybe I'm missing something, but why don't you just use:
// open your connection
long start = System.currentTimeMillis();
// send request, wait for response (the simple socket calls are all blocking)
long end = System.currentTimeMillis();
System.out.println("Round trip response time = " + (en... |
Make sure your compiler optimization is turned on to the highest working level.
You know, flags like '-O1' to '-03' in gcc. |
yes, but you can't delink it. If you don't care about corrupting memory, go ahead ;-) |
At the cost of more memory you can create a full 256-entry table of the hex codes:
static const char _hex2asciiU_value[256][2] =
{ {'0','0'}, {'0','1'}, /* ..., */ {'F','E'},{'F','F'} };
Then direct index into the table, no bit fiddling required.
const char *pHexVal = pHex[*pChar];
pszHex... |
Not if you want to maintain the traversability of the list. You need to update the previous node to link to the next one.
How'd you end up in this situation, anyway? What are you trying to do that makes you ask this question? |
I would say it depends on what exact interval you are trying measure, the amount of time from the last byte of the request that you send until the first byte of the response that you receive? Or until the entire response is received? Or are you trying to measure the server-side time only?
If you're trying to measu... |
I didn't see anything odd in the event viewer or any db's for avg in SQLServer. btw I installed SQL server after AVG. it's curious anyway. I'll just make a VM and do a fresh install of SQLExpress so I can finish a few projects.
it's been over a year so it's time for the annual reformat and reinstall ;-) |
Throwing an exception for failure is one good way to proceed, and if you're returning a lot of different values, you can return a tuple. For the specific case you're citing, I often take an intermediate approach: return the modified string on success, and return <tt>None</tt> on failure. I'm enough of an unreconstruc... |
The [optparse](http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html) library is part of the standard distribution, so you'll be able to use it without requiring any third party stuff.
I haven't used it personally, but [rails seems to use it extensively](http://github.com/rails/rails/search?q=optparse&choic... |
davidg recommends using dicts. I'd go one step further and use sets:
months = set('January', 'February', ..., 'December')
Now you can test whether a value matches one of the values in the set like this:
if m in months:
like dF, though, I usually just use string constants in place of enums. |
Powershell
function factorial( [int] $n )
{
$result = 1;
if ( $n -gt 1 )
{
$result = $n * ( factorial ( $n - 1 ) )
}
$result
} |
PowerShell
function factorial( [int] $n )
{
$result = 1;
if ( $n -gt 1 )
{
$result = $n * ( factorial ( $n - 1 ) )
}
$result
}
Here's a one-liner:
$n..1 | % {$result = 1}{$result *= $_}{$result} |
Don't bother digging up your OSX DVD as they've released a new version (3.1) of XCode since then.
First, you'll want to join [Apple Developer Connection](https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/promo?source=ADCLOG&code=ADCLOG-NEX) (it's free, and you need it to access their version of MSDN) - ... |
I think tables are best used for tabular data, which it seems you have there.
If you do not want to use tables, the best thing would be to use definition lists(`<dl> and <dt>`). Here is how to style them to look like your old `<td>` layout.
<http://www.maxdesign.com.au/presentation/definition/dl-table-display.htm... |
Have you tried the Exception.GetBaseException Method? This returns the exception which created the Application.TreadException. You could then use the same process to go up the chain to get all exceptions.
[exception.getbaseexception Method][1]
[1]: http://msdn.microsoft.com/en-us/library/system.exception.getb... |
use the float: property eg:
css:
.left
{
float:left;
padding-right:20px
}
html:
<div class="left">
Name<br/>
AnotherName
</div>
<div>
Value<br />
AnotherValue
</div> |
Section 3.3.4 of the iPhone SDK Agreement suggests that you mustn't work outside your sandbox.
Given that [Apple has been somewhat arbitrary on which applications they permit](http://speirs.org/2008/09/12/app-store-im-out/), you should definitely double-check with them *before* you start developing.
Compared to 2... |
Spawning threads is only going to waste resources if you start spawning tons of them, one or two extra threads isn't going to effect the platforms proformance, infact System currently has over 70 threads for me, and msn is using 32 (I really have no idea how a messenger can use that many threads, exspecialy when its mi... |
Spawning threads is only going to waste resources if you start spawning tons of them, one or two extra threads isn't going to effect the platforms proformance, infact System currently has over 70 threads for me, and msn is using 32 (I really have no idea how a messenger can use that many threads, exspecialy when its mi... |
I am trying to set a ViewState-variable when a button is pressed, but it only works the second time i click the button. Here is the codebehind:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
lblInfo.InnerText = String.Format("Hello {0} at {1}!", YourName, DateTime.Now.ToLo... |
|asp.net|viewstate|postback| |
You can submit your site to search engines using their [site submission forms](http://www.google.com/addurl/) - this will get you into their system. When you actually get crawled after that is impossible to say - from experience it's usually about a week or so for an initial crawl (homepage, couple of other pages 1-lin... |
Actually what Google does is very much non-trivial and also at first counter-intuitive. They don't do anything like check against a dictionary, but rather they make use of statistics to identify "similar" queries that returned more results than your query, the exact algorithm is of course not known.
There are differ... |
How do I detect if a Windows server is available after a reboot? |
|windows|system-administration|reboot| |
I want to automate a Windows 2000+ server reboot process using Task Scheduler or similar tool to remotely reboot a server and wait for it to come back up. I can issue `shutdown` or `psshutdown` to remotely reboot, but I want something better than `sleep` to wait for it to come back. I need to verify it is back online... |
One solution appears to be Web Deployment Projects (WDPs), an add-on for Visual Studio (and msbuild) available that builds a web project to a directory and can optionally merge assemblies and alter the web.config file. The output of building a WDP is all the files necessary to deploy the site in one directory.
More ... |
Yes - The Internet Explorer Developer Toolbar
http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en |
Yes -
<a href="http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en
">The Internet Explorer Developer Toolbar</a> |
Yes - The Internet Explorer Developer Toolbar
http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en |
Yes - The Internet Explorer Developer Toolbar
[Download details: Internet Explorer Developer Toolbar](http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en)
|
I've never used _declspec(dllimport) when I was programming in Windows. You should be able to simply declare
extern "C" char* MyNewVariable;
and link to the .libb created when DLL was compiled. |
Your remote restart script could start the server, wait n minutes, then query your RFC service. You could also have a local script on the server do the same thing. |
I suppose it depends on the level of language quality that you are aiming to achieve.
By trying to minimise repetition of code that deals with these real language strings, you are just exposing yourself to a whole other layer of logic in the syntaxes and structures of different languages. There would be a massive am... |