instruction stringlengths 0 30k ⌀ |
|---|
Other than doing a deep-copy your best bet might be to lock the collection:
List<string> theList = (List<String> )callingForm.Invoke(callingForm.delegateGetKillStrings);
lock(theList.SyncRoot) {
foreach(string s in theList) {
// Do some Jazz
}
... |
So I'm not quite sure what you're asking, but the Parallel Extensions team has put together some stuff that might fit the bill. See this blog post in particular, about <a href="http://blogs.msdn.com/pfxteam/archive/2008/08/12/8852005.aspx">enumerating parallel collections</a>. It also contains a link to download the Pa... |
In an Async method, Exceptions aren't thrown, but rather passed through to the callback in the EventArgs object. |
I would learn both. They are both up and coming technologies. Learning RESTful coding is a real benefit in any language.
I use GRAILS at work and RoR for side projects. I can say that the RoR community is much larger (I'm talking about RoR vs Grails not RoR vs Java) and very helpful.
Short Answer: They are simila... |
When people arrive @ www.mysmallwebsite.com I would just redirect to http://www.myIsv.com/myWebSite/
<?php header('Location: http://www.myIsv.com/myWebSite/'); ?>
This is all I would have in www.mysmqllwebsite.com/index.php<br />
This way you dont have to worry about browsedr compatibility, or weather the sess... |
I think the most concise way to answer the question in to consider the role of the pointer in C. The pointer is a lightweight yet powerful mechanism that gives you immense freedom at the cost of immense capacity to shoot yourself in the foot.
In C the responsibility of ensuring your pointers point to memory you own ... |
The only options you have is
1. Run the application as root on the iphone
2. Set the applications setuid bit and owner root.
I can't see any of them being blessed by Apple.
I guess it depends on what you want to do with the privileges, if you're lucky there might be more fine grained privileges available,... |
I think that definition lists are pretty close semantically to name/value pairs.
<dl>
<dt>Name</dt>
<dd>Value</dd>
</dl> |
I think that definition lists are pretty close semantically to name/value pairs.
<dl>
<dt>Name</dt>
<dd>Value</dd>
</dl>
[Definition lists - misused or misunderstood?][1]
[1]:http://www.maxdesign.com.au/presentation/definition |
How can I create a loop in an onClick event? |
|javascript|ruby|ruby-on-rails|ajax|loops| |
I want to write an onClick event which submits a form several times, iterating through selected items in a multi-select field, submitting once for each.
**How do I code the loop?**
I'm working in Ruby on Rails and using **remote_function()** to generate the javascript for the ajax call. |
Apart from syntactic sugar, a reference is a const pointer (not pointer to const thing, a const pointer). You must establish what it refers to when you declare the reference variable, an you cannot change it later. |
Apart from syntactic sugar, a reference is a const pointer (not pointer to const). You must establish what it refers to when you declare the reference variable, an you cannot change it later. |
Apart from syntactic sugar, a reference is a const pointer (not pointer to const thing, a const pointer). You must establish what it refers to when you declare the reference variable, an you cannot change it later. |
Some tips at [Getting started with Silverlight Development][1]
[1]: http://stackoverflow.com/questions/60620/getting-started-with-silverlight-development |
It's perfectly reasonable to use tables for what seems to be tabular data. |
**I'd say go with Silverlight first!**
I have programmed with WPF and Silverlight before.
But as Silverlight is a _subset_ of WPF if you go in too deep and try to switch to writing Silverlight applications, you'll be scratching your heads looking for that "tag" you learned to love in WPF but is not available in S... |
You can run your JSUnit from inside Nant using the JSUnit server, it's written in java and there is not a Nant task but you can run it from the command prompt, the results are logged as XML and you can them integrate them with your build report process.
This won't be part of your Nunit result but an extra report.
We ... |
One other approach is to work with your XMPP server vendor. Most have internal APIs that make injecting presence possible from third party applications. For example, [Jabber XCP](http://www.jabber.com/CE/JabberXCP) provides an API for this that's really easy to use. |
One other approach is to work with your XMPP server vendor. Most have internal APIs that make injecting presence possible from third party applications. For example, [Jabber XCP](http://www.jabber.com/CE/JabberXCP) provides an API for this that's really easy to use.
(Disclosure: I work for Jabber, Inc, the company... |
haystack.find(needle), but there should be a searcher field.
I know that dependency injection is all the rage, so it doesn't surprise me that @Mike Stone's haystack.find(needle, searcher) has been accepted. But I disagree: the choice of what searcher is used seems to me a decision for the haystack.
Consider two ... |
Yes, but your list will be broken after you remove it.
In this specific case, traverse the list again and get that pointer! In general, if you are asking this question, there probably exists a bug in what you are doing. |
Deleting a middle node from a single linked list when pointer to the previous node is not available |
|c|data-structures| |
Is it possible to delete a middle node in the single linked list when the only information available we have is the pointer to the node to be deleted and not the pointer to the previous node? |
|c|data-structures|homework| |
|data-structures|homework| |
|c|data-structures| |
Is it possible to delete a middle node in the single linked list when the only information available we have is the pointer to the node to be deleted and not the pointer to the previous node?After deletion the previous node should point to the node next to deleted node. |
I get a "An attempt was made to load a program with an incorrect format" error on a SQL Server replication project |
|c#|sql-server|replication| |
The exact error is as follows
"Could not load file or assembly 'Microsoft.SqlServer.Replication, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. An attempt was made to load a program with an incorrect format."
I've recently started working on this project again aft... |
The only issue with the solution is that it is possible to create a subclass of Exception which does not implement a constructor with a single string parameter, so the MethodMissingException might be thrown.
static void TestException<E>(string message) where E : Exception, new()
{
try
{
... |
I've found the solution. I've recently upgraded my machine to Windows 2008 Server 64-bit. The SqlServer.Replication namespace was written for 32-bit platforms. All I needed to do to get it running again was to set the Target Platform in the Project Build Properties to X86. |
[http://en.wikipedia.org/wiki/N-gram#Google_use_of_N-gram][1]
[1]: http://en.wikipedia.org/wiki/N-gram#Google_use_of_N-gram |
In principle they start with nothing. Only when somebody explicitly tells them to include their website they can start crawling this site and use the links on that site to search more.
However, in practice the creator(s) of a search engine will put in some arbitrary sites they can think of. For example, their own bl... |
Parsing a log file with regular expressions |
|regex|c#| |
I'm currently working on a parser for our internal log files (generated by log4php, log4net and log4j). So far I have a nice regular expression to parse the logs, except for one annoying bit: Some log messages span multiple lines, which I can't get to match properly. The regex I have now is this:
(?<date>\d{2}/\... |
I'm currently working on a parser for our internal log files (generated by log4php, log4net and log4j). So far I have a nice regular expression to parse the logs, except for one annoying bit: Some log messages span multiple lines, which I can't get to match properly. The regex I have now is this:
(?<date>\d{2}/\... |
# C++: Template Metaprogramming
uses the classic enum hack
template<unsigned n>
struct factorial {
enum { result = n * factorial<n - 1>::result };
};
template<>
struct factorial<0> {
enum { result = 1 };
};
usage
int x = factorial<4>::result; |
# C++: Template Metaprogramming
Uses the classic enum hack.
template<unsigned int n>
struct factorial {
enum { result = n * factorial<n - 1>::result };
};
template<>
struct factorial<0> {
enum { result = 1 };
};
Usage.
unsigned int x = factorial<4>::r... |
How do I get SQL Server Integration Services to use a different database connection for Package Configuration |
|ssis|sql-server|connection-manager| |
I have an SSIS Package that sets some variable data from a SQL Server Package Configuration Table. (Selecting the "Specify configuration setings directly" option)
This works well when I'm using the Database connection that I specified when developing the package. However when I run it on a server (64 bit) in the tes... |
|sql-server|ssis|connection-manager| |
I have an SSIS Package that sets some variable data from a SQL Server Package Configuration Table. (Selecting the "Specify configuration setings directly" option)
This works well when I'm using the Database connection that I specified when developing the package. However when I run it on a server (64 bit) in the tes... |
Also, Enumeration is like an Iterator, not an Iterable. A Collection is Iterable. An Iterator is not.
You can't do this:
Vector<X> list = …
Iterator<X> i = list.iterator();
for (X x : i) {
x.doStuff();
}
So it wouldn't make sense to do this:
Vector<X> list = …
Enumeratio... |
Rolling your own message loop, any pitfalls? |
|.net|winforms| |
This question is slightly related to [this question about exception handling][1]. The workaround I found there consists of rolling my own message loop.
So my Main method now looks basically like this:
[STAThread]
static void Main() {
// this is needed so there'll actually an exception be thrown by... |
This question is slightly related to [this question about exception handling][1]. The workaround I found there consists of rolling my own message loop.
So my Main method now looks basically like this:
[STAThread]
static void Main() {
// this is needed so there'll actually an exception be thrown by... |
If I'm writing a form I usually use this:
<form ... class="editing">
<div class="field">
<label>Label</label>
<span class="edit"><input type="text" value="Value" ... /></span>
<span class="view">Value</span>
</div>
...
</form>
Then in ... |
try catch **finally** is pretty important construct. You can be sure that even if an exception is thrown, the code in finally block will be executed. It's very important in handling external resources to release them. Garbage collection won't do that for you. In finally part you shouldn't have *return* statements or th... |
try catch **finally** is pretty important construct. You can be sure that even if an exception is thrown, the code in finally block will be executed. It's very important in handling external resources to release them. Garbage collection won't do that for you. In finally part you shouldn't have *return* statements or th... |
try catch **finally** is pretty important construct. You can be sure that even if an exception is thrown, the code in finally block will be executed. It's very important in handling external resources to release them. Garbage collection won't do that for you. In finally part you shouldn't have *return* statements or th... |
haystack can contain stuffs
one type of stuff is needle
finder is something that is responsible for searching of stuff
finder can accept a pile of stuffs as the source of where to find thing
finder can also accept a stuff description of thing that it need to find
so, preferably, for a flexible solution you would... |
I happen to like this one, among others: [ReadySet][1].
He sells a pro version too.
[1]: http://readyset.tigris.org/ |
There is already a question addressing this topic:
http://stackoverflow.com/questions/44905/c-switch-statement-limitations-why |
There is already a question addressing this topic:
http://stackoverflow.com/questions/44905/c-switch-statement-limitations-why
EDIT:
My main purpose in pointing that out, gentlebeasts, is that two questions of near-identical name add confusion to the pool of questions. |
The initial suggestion was to transform:
a -> b -> c
to:
a ->, c
If you keep the information around, say, a map from address of node to address of the next node then you can fix the chain the next time to traverse the list. If need to delete multiple items before the next traversal then you need to keep tr... |
For bzr, if you just copy the .bzr directory to another location, it'll work. It doesn't store any information about the path it's in or the host it's on, so you can copy it wherever and expect it to work out OK. |
You'll have to march down the list to find the previous node. That will make deleting in general O(n**2). If you are the only code doing deletes, you may do better in practice by caching the previous node, and starting your search there, but whether this helps depends on the pattern of deletes. |
An etag is an arbitrary string that the server sends to the client that the client will send back to the server the next time the file is requested.
The etag should be computable on the server based on the file. Sort of like a checksum, but you might not want to checksum every file sending it out.
<pre>
server ... |
An etag is an arbitrary string that the server sends to the client that the client will send back to the server the next time the file is requested.
The etag should be computable on the server based on the file. Sort of like a checksum, but you might not want to checksum every file sending it out.
<pre>
server ... |
In order to get to the previous list item, you would need to traverse the list from the beginning until you find an entry with a `next` pointer that points to your current item. Then you'd have a pointer to each of the items that you'd have to modify to remove the current item from the list - simply set `previous->next... |
You might be able to find some inspiration here: http://blog.html.it/layoutgala/ |
Is there a good admin generator for Ruby on Rails? |
|ruby|ruby-on-rails| |
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python) background, they both have excellent admin generators. Seems like this is missing in Rails.
For those who aren't familiar with Symfony or Django, they both allow you to specify some metadata around your models to automatically (dynamic... |
My quick answer (as I've not coded it yet) would be to create another function that creates a POST using XMLHTTPRequest and the specific parameters for a single call. Then inside your onClick() handler call that function as you loop through your selected items.
I would suggest that you do a Proof of Concept just usi... |
[Why tables for layout is stupid: problems defined, solutions offered][1].
[1]: http://www.hotdesign.com/seybold/ |
I think at least the designers should start using the Expression Suite.
The developers should be somewhat familiar with the tools but just enough to enable them to communicate better with the designers. |
I'll second [Fire Lancer's][1] answer - creating your own threads is an excellent way to process big tasks or to handle a task that would otherwise be "blocking" to the rest of synchronous app, **but** you have to have a clear understanding of the problem that you must solve and develope in a way that clearly defines t... |
I've been using this [free color schemer][1] to help me determine some nice layouts. You give it a base color and it will give you a lot of complements.
EDIT: Gah! Curse you jko and your god-like typing abilities! At least we have the same reference though. 8^D
[1]: http://www.colorschemer.com/online.html |
My stick figures come out wrong, but the following links have kept me artistically aligned for many years:
- [Color tools for the design impaired][1]
- [Color Scheme Generator][2]
To web 2.0-ize it, just put a lens flare on your logo & mark it BETA - you'll be fine.
[1]: http://www.figby.com/archives/20... |
My list includes:
.Net Rocks!
RunAs Radio
TWiT
Stackoverflow (but then again, we wouldn't be in Beta if we didn't)
Channel 9
Hanselminutes
Pretty much the same as everybody else. Just goes to show you why podcasts are important to developing your art.
|
@Creighton:
In Haskell there is a library function called <b>product</b>:
prouduct list = foldr 1 (*) list
or simply:
product = foldr 1 (*)
so the "idiomatic" factorial
fac n = foldr 1 (*) [1..n]
would simply be
fac n = product [1..n]
|
I've been doing .NET development using Parallels for over a year now, using WinXP Pro and can't complain, it runs fast (just as it would on a regular machine) and I get the best of all worlds --> a tip, use spaces, so have windows running in one desk and ur mac stuff on the other, and with just a keystroke u move from ... |
For color schemes, I like browsing [Colour Lovers][1]. There are thousands of user-submitted color schemes to pick through for ideas and you can easily create your own scheme if you'd like. A lot of times I use it just for the color palette to create just the right color (it outputs the color in hex, RGB, HSV and CMY... |
You answered in your comment:
> equals returned false but identity hash code was same, assume o1 == o2
Unfortunately you cannot assume that. Most of the time that is going to work, but in some exceptionnal cases, it won't. And you cannot know when. When such a case appear, it would lead to lose instances in Tree... |
I think this is going to be quite difficult without code.
Two options come to mind:
* Find out what Windows messages IE sends to open the favorites screen and replay these in your application. You would first need to see if IE is running and if it is bring it to the foreground. If not then start the process. May... |
Further to David Fenton's comments
Your administrative rule will be something like this:
If the data that is in the database is just being used by one user, for their own work (alone), then they can keep it in their own network share.
If the data that is in the database is for being used by more than one perso... |
It's fairly simple to make a plugin using NPAPI. The key header files you'll need from the Gecko distribution are npapi.h and npupp.h. You'll export functions from your plugin DLL or shared library with the names NP\_Initialize, NP\_Shutdown, NP\_GetMIMEDescription, and NP\_GetValue, and you'll need to also fill in t... |
Here's how my school did it:
base:
algebra
trigonometry
analytic geometry
track 1 track 2 track 3
calc 1 linear algebra statistics
calc 2 discrete math 1
calc 3 (mul... |
Here's how my school did it:
base:
algebra
trigonometry
analytic geometry
track 1 track 2 track 3
calc 1 linear algebra statistics
calc 2 discrete math 1
calc 3 (mul... |
One approach would be to insert a null for the data. Whenever you traverse the list, you keep track of the previous node. If you find null data, you fix up the list, and go to the next node.
|
I'm not super knowledgeable in Mock frameworks so please correct me if I'm wrong but couldn't you possibly have two different Mock objects to cover the situations that you mention? Such as
public static class MockClassWithEmptyStaticInit {
public static void staticInit() {
}
}
and
publ... |
Video training for expression blend:
- [Total Training Expression Blend][1]
- [http://expression.microsoft.com/en-us/cc136536.aspx][2]
- [http://windowsclient.net/learn/videos_wpf.aspx][3]
[1]: http://www.totaltraining.com/prod/microsoft/expression.asp?utm_source=msft&utm_medium=inbox_dvd&utm_campaign... |
Since there are not so many good WPF tools, knowing Blend is a pretty useful skill. However I wouldn't consider it as *requirement*. The whole idea of WPF is to distribute work between coders and designers. IMO developer is not required to know Blend throughout, but basic skills are required to understand designer's ne... |
Pitfall 1:
Thread.Sleep(100);
Never. Use WaitMessage().
Otherwise, it is possible roll out your own message loop, but in your scenario it seems somewhat pointless.
You may also want to examine Application.Run() code (with .Net Reflector, for instance). |
[This page][1] seems to imply that the correct configuration element is:
<pre><code><attribute name="MaxCapacity">20000</attribute></code></pre>
However, I've only ever used EHCache myself.
[1]: http://www.junlu.com/msg/179368.html |
I ALMOST understand how email works, but I'm missing something. |
|email|pop|smtp| |
For the past few weeks, I've been trying to learn about just how email works. I understand the process of a client receiving mail from a server using POP pretty well. I also understand how a client computer can use SMTP to ask an SMTP server to send a message. However, I'm still missing something...
The way I und... |
Also, Enumeration is like an Iterator, not an Iterable. A Collection is Iterable. An Iterator is not.
You can't do this:
Vector<X> list = …
Iterator<X> i = list.iterator();
for (X x : i) {
x.doStuff();
}
So it wouldn't make sense to do this:
Vector<X> list = …
Enumeratio... |
It doesn't make sense for `Enumeration` to implement `Iterable`. `Iterable` is a factory method for `Iterator`. `Enumeration` is analogous to `Iterator`, and only maintains state for a single enumeration.
So, be careful trying to wrap an `Enumeration` as an `Iterable`. If someone passes me an `Iterable`, I will assu... |
Concurrent collections in C# |
|concurrency|c#| |