qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
283,141 | <p>I just came across <a href="https://stackoverflow.com/questions/139686/should-local-variable-initialisation-be-mandatory#283127">this question</a> about initializing local variables. Many of the answers debated simplicity/readability <em>vs.</em> robustness. As a developer of (remotely deployed) embedded systems, I always favor robustness and tend to follow several seemingly conflicting rules:</p>
<ul>
<li><p>Handle every error to the best of your ability in a way that allows the device to continue running.</p></li>
<li><p>Design the code to fail <em>as soon as possible</em> after a programming or fatal error occurs.</p></li>
</ul>
<p>We've all been trained to validate input to prevent the device from breaking as a result of user (or other external) input; always assume data may be invalid and test it accordingly.</p>
<p><strong>What other <em>specific</em> practices do you follow to ensure robustness?</strong> Examples are helpful, but I'm also interested in <em>techniques</em> that are universally applicable.</p>
| [
{
"answer_id": 283159,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 2,
"selected": false,
"text": "\"hmm why is this 0 at the beginning...\""
},
{
"answer_id": 283163,
"author": "Nate",
"aut... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29157/"
] |
283,143 | <p>I was trying to figure out how to implement method_missing in C# 4, based on all of 2 blog posts floating around on IDynamicObject. </p>
<p>What I want to do is have a Business Logic Layer that has a Repository, and if the method is missing from the Business Logic Layer, just call the Repository and pass through its result. So i have a class that looks like this:</p>
<pre><code>public class CustomerServices : IDynamicObject
{
protected CustomerRepository _Repository = new CustomerRepository();
MetaObject IDynamicObject.GetMetaObject(Expression parameter)
{
return new RepositoryMetaObject<CustomerRepository>(_Repository, parameter);
}
}
</code></pre>
<p>In RepositoryMetaObect I implement the Call method like so:</p>
<pre><code> public override MetaObject Call(CallAction action, MetaObject[] args)
{
typeof(T).GetMethod(action.Name).Invoke(_Repository, getParameterArray(args));
return this;
}
</code></pre>
<p>(The rest of RepositoryMetaObject code probably isn't interesting, but I've included it here: <a href="http://pastie.org/312842" rel="noreferrer">http://pastie.org/312842</a>)</p>
<p>The problem I think is that I'm never doing anything with the result of the Invoke, I'm just returning the MetaObject itself. </p>
<p>Now when I do this:</p>
<pre><code> dynamic service = new CustomerServices();
var myCustomer = service.GetByID(1);
</code></pre>
<p>GetByID is called, but if I try to access a property on myCustomer, is just hangs. </p>
<p>Can anyone please help?</p>
<p>Complete code can be downloaded ehre: <a href="https://dl.getdropbox.com/u/277640/BusinessLogicLayer.zip" rel="noreferrer">https://dl.getdropbox.com/u/277640/BusinessLogicLayer.zip</a></p>
| [
{
"answer_id": 353847,
"author": "Mik Kardash",
"author_id": 17980,
"author_profile": "https://Stackoverflow.com/users/17980",
"pm_score": 0,
"selected": false,
"text": "return this;\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24616/"
] |
283,145 | <p>I have a solution in Visual Studio 2008 which has multiple projects. One of the projects is a WCF project. Sometimes I just want to debug other projects, but when I press F5, Visual Studio has wcfsvchost.exe launched to host the WCF project even it is not "StartUp Project". </p>
<p>Currently, every time I debugging other projects, I Have to Unload the WCF project to prevent the annoying WcfSvcHost.exe host pop up. However, it is not convenient. Anybody know better idea to prevent WCF project to be hosted in debugging mode?</p>
| [
{
"answer_id": 283171,
"author": "CheGueVerra",
"author_id": 17787,
"author_profile": "https://Stackoverflow.com/users/17787",
"pm_score": 2,
"selected": false,
"text": "<!--<PublishUrl>http://localhost/WindowsFormsApplication1/</PublishUrl>\n<Install>true</Install>\n<InstallFrom>Web</In... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] |
283,156 | <p>So my program needs to go through a plain text file line by line essentially:</p>
<pre><code>Read line 1:
Do commands
loop
Read line2:
Do Commands
loop
</code></pre>
<p>etc until its done with the entire file does anyone know any good coding examples for this, all the tutorials seem to show open and writing/reading textfiles but nothing on how to do it line by line.</p>
| [
{
"answer_id": 283162,
"author": "Sani Singh Huttunen",
"author_id": 26742,
"author_profile": "https://Stackoverflow.com/users/26742",
"pm_score": 0,
"selected": false,
"text": "Using f As System.IO.FileStream = System.IO.File.OpenRead(\"somefile.txt\")\n Using s As System.IO.StreamRe... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,165 | <p>Are there any known hash algorithms which input a vector of int's and output a single int that work similarly to an inner product?</p>
<p>In other words, I am thinking about a hash algorithm that might look like this in C++:</p>
<pre><code>// For simplicity, I'm not worrying about overflow, and assuming |v| < 7.
int HashVector(const vector<int>& v) {
const int N = kSomethingBig;
const int w[] = {234, 739, 934, 23, 828, 194}; // Carefully chosen constants.
int result = 0;
for (int i = 0; i < v.size(); ++i) result = (result + w[i] * v[i]) % N;
return result;
}
</code></pre>
<p>I'm interested in this because I'm writing up a paper on an algorithm that would benefit from any previous work on similar hashes. In particular, it would be great if there is anything known about the collision properties of a hash algorithm like this.</p>
<p>The algorithm I'm interested in would hash integer vectors, but something for float vectors would also be cool.</p>
<p><strong>Clarification</strong></p>
<p>The hash is intended for use in a hash table for fast key/value lookups. There is no security concern here.</p>
<p>The desired answer is something like a set of constants that provably work particularly well for a hash like this - analogous to a multiplier and modulo which works better than others as a pseudorandom number generator.</p>
<p>For example, some choices of constants for a linear congruential pseudorandom generator are known to give optimal cycle lengths and have easy-to-compute modulos. Maybe someone has done research to show that a certain set of multiplicative constants, along with a modulo constant, in a vector hash can reduce the chance of collisions amongst nearby integer vectors.</p>
| [
{
"answer_id": 283291,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 1,
"selected": false,
"text": "class tuple:\n def __hash__(self):\n value = 0x345678\n for item in self:\n value = c_mul(1000... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3561/"
] |
283,166 | <p>How do I do the above? There is mktime function but that treats the input as expressed in local time but how do i perform the conversion if my input tm variable happens to be in UTC.</p>
| [
{
"answer_id": 9088549,
"author": "Tom",
"author_id": 223201,
"author_profile": "https://Stackoverflow.com/users/223201",
"pm_score": 3,
"selected": false,
"text": "timegm()"
},
{
"answer_id": 15301457,
"author": "liberforce",
"author_id": 518853,
"author_profile": "h... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24560/"
] |
283,169 | <p>Suppose I have some code:</p>
<pre><code>let listB = [ 1; 2; 3 ]
</code></pre>
<p>Using Lisp notation, how do I do a <code>car</code> and <code>cadr</code> against this list? I know cons is <code>::</code>.</p>
<p>Or in Scheme, <code>first</code> and <code>rest</code>?</p>
| [
{
"answer_id": 283184,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 4,
"selected": true,
"text": "> let sample = [1;2;3;4];;\n\nval sample : int list\n\n> List.head sample;;\n\nval it : int = 1\n\n> List.tail s... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26227/"
] |
283,180 | <p>I've got a lot of pages in my site, I'm trying to think of a nice way to separate these into areas that are a little more isolated than just simple directories under my base web project. Is there a way to put my web forms into a separate class library? If so, how is it done?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 283192,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 3,
"selected": true,
"text": "Page"
},
{
"answer_id": 47885349,
"author": "Nayas Subramanian",
"author_id": 4315441,
"author_profile":... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11908/"
] |
283,185 | <p>Is it possible to retrieve the CPUID and MAC address of a client machine from a Ruby on Rails application?. Are there any plugins available for this?</p>
| [
{
"answer_id": 13275392,
"author": "fqxp",
"author_id": 253954,
"author_profile": "https://Stackoverflow.com/users/253954",
"pm_score": 2,
"selected": false,
"text": "arp"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,193 | <p>I have a list of email address which I want to distribute evenly by domain.</p>
<p>For example:</p>
<p>let the list be, </p>
<pre><code>a@a.com
b@a.com
c@a.com
a@b.com
b@b.com
c@c.com
</code></pre>
<p>The output should be </p>
<pre><code>a@a.com
a@b.com
c@c.com
b@a.com
b@b.com
c@a.com
</code></pre>
<p>The source list is not sorted by domain as in example, but can be sorted by domain, if that can help. What would be an efficient (single/two pass?) algorithm of doing this?</p>
<p>raj</p>
| [
{
"answer_id": 283200,
"author": "Xenph Yan",
"author_id": 264,
"author_profile": "https://Stackoverflow.com/users/264",
"pm_score": 0,
"selected": false,
"text": "$sortedList = array();\n$tempList\n$emailList = array('a@a.com', 'b@a.com', 'c@b.com', 'd@b.com', 'e@c.com', 'f@a.com');\n\n... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25453/"
] |
283,202 | <p>we are writing tests for a COM library written in VB 6.0.The problem we are facing is that, we are unable to access events declared in VB( withevents). We get exception, "object does not support set of events". How can we overcome this problem?</p>
| [
{
"answer_id": 295316,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "Option Explicit\n\nPublic Event SavedSuccessfully()\n\nPublic Sub Execute(ByVal vAge As Integer, ByVal vName As String, ByVal ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,205 | <p>I am an intermediate C programmer. If you have made any coding mistake that you came to know later that it was the most hazardous / harmful to the total application please share that code or description. I want to know this because in future I may come across such situations and I want to have your advice to avoid such mistakes.</p>
| [
{
"answer_id": 283212,
"author": "Daniel Kreiseder",
"author_id": 31406,
"author_profile": "https://Stackoverflow.com/users/31406",
"pm_score": 5,
"selected": false,
"text": "if (c = 1) // insert code here\n"
},
{
"answer_id": 283215,
"author": "Community",
"author_id": -... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31116/"
] |
283,209 | <p>do I have to register the HttpVerb constraint in my route definition (when i'm registering routes) if i have decorated my action method with the [AcceptVerbs(..)] attribute already?</p>
<p>eg. i have this.</p>
<pre><code>[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(FormCollection formCollection)
{ .. }
</code></pre>
<p>do i need to add this to the route that refers to this action, as a constraint?</p>
| [
{
"answer_id": 285850,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 6,
"selected": true,
"text": "Create"
},
{
"answer_id": 2549310,
"author": "MrByte",
"author_id": 19710,
"author_profile": "https://Stack... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
283,214 | <p>Is there an application , which can parse a given set of stored procedures (SQL Server 2000) and gets all tables and associated columns that are being used in it.
The stored procedure can have tables from different databases.</p>
<p>Output should be like
TableA
columnA
columnC
columnD</p>
<p>TableB
columnE
columnF
columnG</p>
<p>I have written an small application using Database Edition GDR Any one interested can refer to <a href="http://tsqlparsergdr.codeplex.com" rel="nofollow noreferrer">http://tsqlparsergdr.codeplex.com</a> </p>
| [
{
"answer_id": 283272,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": -1,
"selected": false,
"text": "[...]\n@MyDate datetime\n\nAS\n\n IF (day(@MyDate) = 1)\n BEGIN\n SELECT * FROM MyFirstTable\n RETURN\... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21195/"
] |
283,222 | <p>What's the best way to take some plain text (not PHP code) which contains PHP-style variables, and then substitute in the value of the variable. This is kinda hard to describe, so here's an example.</p>
<pre><code>// -- myFile.txt --
Mary had a little $pet.
// -- parser.php --
$pet = "lamb";
// open myFile.txt and transform it such that...
$newContents = "Mary had a little lamb.";
</code></pre>
<p>I've been considering using a regex or perhaps <code>eval()</code>, though I'm not sure which would be easiest. This script is only going to be running locally, so any worries regarding security issues and <code>eval()</code> do not apply <em>(i think?)</em>.</p>
<p>I'll also just add that I can get all the necessary variables into an array by using <code>get_defined_vars()</code>:</p>
<pre><code>$allVars = get_defined_vars();
echo $pet; // "lamb"
echo $allVars['pet']; // "lamb"
</code></pre>
| [
{
"answer_id": 283231,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 2,
"selected": false,
"text": "$allVars = get_defined_vars();\n$file = file_get_contents('myFile.txt');\n\nforeach ($allVars as $var => $val) {\n $file = ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
283,239 | <p>In my models, there are lots of attributes and methods that perform some calculation based on the model instance's attributes. I've been having the methods return nil if the attributes that the calculations depend on are nil. As a consequence of this design decision, I'm doing a lot of nil checks before displaying these values in my views. </p>
<p>I thought about having these methods return zero instead of nil when they don't have enough information, but I chose nil because zero is a valid computation result and nil implies that there was not enough information.</p>
<p>Should I return 0 instead of nil? Is there any other pattern that I could use to avoid doing a bunch of nil checks in my views? </p>
| [
{
"answer_id": 283319,
"author": "Patrick McKenzie",
"author_id": 15046,
"author_profile": "https://Stackoverflow.com/users/15046",
"pm_score": 3,
"selected": false,
"text": "Food"
},
{
"answer_id": 285056,
"author": "nickh",
"author_id": 34478,
"author_profile": "htt... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36049/"
] |
283,251 | <p>I need to read account number from Maestro/Mastercard with smart card reader. I am using Java 1.6 and its javax.smartcardio package. I need to send APDU command which will ask EMV application stored on card's chip for PAN number. Problem is, I cannot find regular byte array to construct APDU command which will return needed data anywhere... </p>
| [
{
"answer_id": 283452,
"author": "Rasmus Faber",
"author_id": 5542,
"author_profile": "https://Stackoverflow.com/users/5542",
"pm_score": 0,
"selected": false,
"text": "byte[] readFile(CardChannel channel) throws CardException {\n CommandAPDU command = new CommandAPDU(0xB0, 0x60, 0x10, ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,263 | <p>I'm putting a crontab job for updating with apt-get once a day (running Debian Lenny, there are updates almost daily). But almost all examples i've seen of this cron job invoke the -d flag. </p>
<p>This elicits 4 questions:</p>
<ul>
<li>Why should I only download the
packages and not install them?</li>
<li>Doesn't this defeat the purpose of
running it automatically?</li>
<li>Don't I have to go in and actually
install the updates later?</li>
<li>Is it safe for me to run the cron
job without the -d flag?</li>
</ul>
| [
{
"answer_id": 286517,
"author": "Darren Greaves",
"author_id": 151,
"author_profile": "https://Stackoverflow.com/users/151",
"pm_score": 1,
"selected": false,
"text": "/usr/bin/apt-get update && /usr/bin/apt-get -s -u upgrade\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50/"
] |
283,275 | <p>I want to store a large result set from database in memory. Every record has variable length and access time must be as fast as arrays. What is the best way to implement this? I was thinking of keeping offsets in a separate table and storing all of the records consecutively? Is it odd? (Programming Language: Delphi)</p>
| [
{
"answer_id": 283650,
"author": "Steve",
"author_id": 22712,
"author_profile": "https://Stackoverflow.com/users/22712",
"pm_score": 0,
"selected": false,
"text": "type\n pMyRecord : ^TMyRecord;\n...\n...\n...\nvar\n p : pMyRecord;\n...\n...\nNew(p);\nwith p^ do\nbegin\n ...\n ...\ne... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36830/"
] |
283,284 | <p>When I create a TFS report of a query with the Excel integration features (we are using Excel 2003), Excel resets formatting of all cells after clicking the "Refresh" button in the TFS Toolbar.</p>
<p>Our team likes to print this report and drag it into our weekly meeting as it accurately lists all our open tasks. Bad formatting is a pain, though: Vertical alignment set to "bottom" and no borders on cells makes it nearly impossible to know when one Task/Bug starts and the other ends...</p>
| [
{
"answer_id": 298088,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 3,
"selected": true,
"text": "tfpt.exe"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2260/"
] |
283,294 | <p>I found a lot of info about how to debug simple Python programs with Emacs. But what if I want to debug a Django application?
I run the development server and I would like to somehow attach to the process from Emacs and then set breakpoints, etc. Similar to Visual Studio's "attach to process". How to do that?</p>
| [
{
"answer_id": 284607,
"author": "Ben",
"author_id": 3553,
"author_profile": "https://Stackoverflow.com/users/3553",
"pm_score": 4,
"selected": false,
"text": "import pdb; pdb.set_trace()"
},
{
"answer_id": 286703,
"author": "Chad",
"author_id": 37309,
"author_profile... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5475/"
] |
283,297 | <p>I have a dll that must be useable from C etc, so I cant use string objects etc as a normal would, but I'm not sure on how to do this safely..</p>
<pre><code>const char *GetString()
{
std::stringstream ss;
ss << "The random number is: " << rand();
return ss.str().c_str();
}
</code></pre>
<p>could the c string be destroyed when ss falls off the stack? I'm assuming so...</p>
<p>Another option may be to create a new string on the heap, but what is going to deallocate that?</p>
<pre><code>const char *GetString()
{
std::stringstream ss;
ss << "The random number is: " << rand();
char *out = new char[ss.str().size()];
strcpy(ss.str().c_str(), out);
return out;//is out ever deleted?
}
</code></pre>
<p>The same goes for pointers to other things as well as strings.</p>
| [
{
"answer_id": 283314,
"author": "Pieter",
"author_id": 5822,
"author_profile": "https://Stackoverflow.com/users/5822",
"pm_score": 0,
"selected": false,
"text": "CreateString()\n"
},
{
"answer_id": 283317,
"author": "n-alexander",
"author_id": 23420,
"author_profile"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6266/"
] |
283,299 | <p>I have a large array with a range of integers that are mostly continuous, eg 1-100, 110-160, etc. All integers are positive.
What would be the best algorithm to compress this?<br/><br/>
I tried the deflate algorithm but that gives me only 50% compression.
Note that the algorithm cannot be lossy.</p>
<p>All numbers are unique and progressively increasing.</p>
<p>Also if you can point me to the java implementation of such algorithm that would be great.</p>
| [
{
"answer_id": 1081758,
"author": "brianegge",
"author_id": 14139,
"author_profile": "https://Stackoverflow.com/users/14139",
"pm_score": 4,
"selected": false,
"text": "None 1.0\nDeflate 0.50\nFiltered 0.34\nBZip2 0.11\nLzma 0.06\n"
},
{
"answer_id": 10... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14316/"
] |
283,316 | <p>I'm having a problem where a jQuery setting against an .html() property on a selected element is returning the error 'nodeName' is null or not an object. This only occurs on IE6 and IE7, but not FF2, FF3, Opera (latest Nov 12,2008) or Safari (again, latest).</p>
| [
{
"answer_id": 283328,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "'nodeName' is null or not an object\n"
},
{
"answer_id": 283340,
"author": "Rob",
"author_id": 34224,
"aut... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,348 | <p>I'm trying to use the Visitor Pattern and I have as follows:</p>
<pre><code>public class EnumerableActions<T> : IEnumerableActions<T>
{
private IEnumerable<T> itemsToActOn;
public EnumerableActions ( IEnumerable<T> itemsToActOn )
{
this.itemsToActOn = itemsToActOn;
}
public void VisitAllItemsUsing ( IVisitor<T> visitor )
{
foreach (T t in itemsToActOn)
{
visitor.Visit ( t );// after this, the item is unaffected.
}
}
</code></pre>
<p>The visitor :</p>
<pre><code>internal class TagMatchVisitor : IVisitor<Tag>
{
private readonly IList<Tag> _existingTags;
public TagMatchVisitor ( IList<Tag> existingTags )
{
_existingTags = existingTags;
}
#region Implementation of IVisitor<Tag>
public void Visit ( Tag newItem )
{
Tag foundTag = _existingTags.FirstOrDefault(tg => tg.TagName.Equals(newItem.TagName, StringComparison.OrdinalIgnoreCase));
if (foundTag != null)
newItem = foundTag; // replace the existing item with this one.
}
#endregion
}
</code></pre>
<p>And where I'm calling the visitor :</p>
<pre><code>IList<Tag> tags = ..get the list;
tags.VisitAllItemsUsing(new TagMatchVisitor(existingTags));
</code></pre>
<p>So .. where am I losing the reference ?
after newItem = foundTag - I expect that in the foreach in the visitor I would have the new value - obviously that's not happening.</p>
<p><strong>Edit</strong> I think I found the answer - in a foreach the variable is readonly.</p>
<p><a href="http://discuss.joelonsoftware.com/default.asp?dotnet.12.521767.19" rel="nofollow noreferrer">http://discuss.joelonsoftware.com/default.asp?dotnet.12.521767.19</a></p>
| [
{
"answer_id": 283359,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": true,
"text": "IList<T>"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5246/"
] |
283,350 | <p>In Erlang, every process has a group leader, and when a process wants to print something (i.e. it calls the io library or does something similar), it will send a message to its group leader.</p>
<p>My question is, where can I find the specification of these messages? Or in general, the specification of what a group leader should do?</p>
<p>I managed to find out with some experimenting that sometimes the process sends an <code>{io_request, Sender, GroupLeader, Request}</code> term, and the answer is an <code>{io_reply, GroupLeader, ok}</code> term, but there may be other cases.</p>
| [
{
"answer_id": 296496,
"author": "archaelus",
"author_id": 9040,
"author_profile": "https://Stackoverflow.com/users/9040",
"pm_score": 4,
"selected": true,
"text": " {io_request, From, ReplyAs, Request}\n %From is the process to send the reply to, \n %ReplyAs is any term the caller de... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17916/"
] |
283,374 | <p>To recap for those .NET gurus who might not know the Java API:</p>
<p><a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html" rel="nofollow noreferrer">ConcurrentHashMap</a> in Java has atomic methods (i.e. require no external locking) for common Map modification operations such as:</p>
<pre><code>putIfAbsent(K key, V value)
remove(Object key, Object value)
replace(K key, V value)
</code></pre>
<p>It also allows iteration over the keyset without locking (it takes a copy at the start of iteration) and <code>get()</code> operations can generally be interleaved with calls to <code>put()</code> without blocking (it uses fine grained lock striping <a href="http://en.wiktionary.org/wiki/IIRC" rel="nofollow noreferrer">IIRC</a>).</p>
<p>Anyway, my question is: <strong>does .NET have an equivalent Dictionary implementation?</strong></p>
<p>I guess more generally, I'd be keen to know if .NET has a more general set of thread safe collection libraries. Or concurrency utilities in general - equivalent to <a href="http://en.wikipedia.org/wiki/Doug_Lea" rel="nofollow noreferrer">Doug Lea</a>'s <code>java.util.concurrent</code> libraries.</p>
| [
{
"answer_id": 283400,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "ConcurrentDictionary"
},
{
"answer_id": 283441,
"author": "Marc Gravell",
"author_id": 23354,
"autho... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1853/"
] |
283,375 | <p>Let's say I'm running a simple server and have <code>accept()</code>ed a connection from a client.</p>
<p>What is the best way to tell when the client has disconnected? Normally, a client is supposed to send a close command, but what if it disconnects manually or loses network connection altogether? How can the server detect or handle this?</p>
| [
{
"answer_id": 1525680,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": " Try\n Clients.Client.Send(BufferByte)\n Catch verror As Exception\n BufferString = verr... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4924/"
] |
283,377 | <p>Consider the following signature in C#:</p>
<pre><code>double Divide(int numerator, int denominator);
</code></pre>
<p>Is there a performance difference between the following implementations?</p>
<pre><code>return (double)numerator / denominator;
return numerator / (double)denominator;
return (double)numerator / (double)denominator;
</code></pre>
<p>I'm assuming that both of the above return the same answer.</p>
<p>Have I missed any other equivalent solution?</p>
| [
{
"answer_id": 283386,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "static double A(int numerator, int denominator)\n{ return (double)numerator / denominator; }\n\nstatic double B(int nu... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24874/"
] |
283,392 | <p>At the moment I have a set of divs, generated dynamically by php and all having their ids starting with 'itembox', with a count number appended. I have a droppable garbage bin area on the page so that the user can delete an individual itembox by fdragging and dropping on to the bin.</p>
<p>My problem is that the droppable won't seem to activate when I drag the original, while it will function (perfectly) when I have helper: 'clone' set. Unfortunately, though, when dragging, the cloning function takes its clone from the first iteration of the itembox, no matter which itembox is actually dragged.</p>
<p>So I'm looking for a solution to either make the droppable accept an original or force the cloning function to take its clone from the itembox actually dragged.</p>
| [
{
"answer_id": 283978,
"author": "Tamas Czinege",
"author_id": 8954,
"author_profile": "https://Stackoverflow.com/users/8954",
"pm_score": 2,
"selected": true,
"text": "$('#mydroppable').droppable(\n{\n accept: function() { return true; },\n drop: function () { alert(\"Dropped!\");... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28527/"
] |
283,406 | <p>What is the difference between <code>atan</code> and <code>atan2</code> in C++?</p>
| [
{
"answer_id": 283408,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 8,
"selected": true,
"text": "std::atan2"
},
{
"answer_id": 284624,
"author": "Laserallan",
"author_id": 11758,
"author_profile": "http... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] |
283,416 | <p>PostgreSQL allows the creation of 'Partial Indexes' which are basically indexes with conditional predicates. <a href="http://www.postgresql.org/docs/8.2/static/indexes-partial.html" rel="nofollow noreferrer">http://www.postgresql.org/docs/8.2/static/indexes-partial.html</a> </p>
<p>While testing, I found that they are performing very well for a case where the query is accessing only certain 12 rows in a table with 120k rows. </p>
<p>But before we deploy this, are there any disadvantages or caveats we should be aware of?</p>
| [
{
"answer_id": 388158,
"author": "cope360",
"author_id": 48044,
"author_profile": "https://Stackoverflow.com/users/48044",
"pm_score": 3,
"selected": false,
"text": "Orders"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21029/"
] |
283,417 | <p>I have a toolstrip containing, among other things, a ToolStripComboBox and a ToolStripButton. I want to add a ContextMenuStrip to both of them, but I don't have direct access to the toolstrip or its other contents, so I can't set the context menu of the toolstrip.</p>
<p>Setting the ContextMenuStrip for the ToolStripComboBox is easy:</p>
<pre><code>myToolStripComboBox.ComboBox.ContextMenuStrip = myContextMenu;
</code></pre>
<p>but there's no obvious equivalent for the ToolStripButton. How do I add a ContextMenuStrip to a ToolStripButton?</p>
| [
{
"answer_id": 354468,
"author": "AlexeyMK",
"author_id": 5021,
"author_profile": "https://Stackoverflow.com/users/5021",
"pm_score": 0,
"selected": false,
"text": "toolstrip"
},
{
"answer_id": 1774863,
"author": "Jason D",
"author_id": 215962,
"author_profile": "http... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] |
283,419 | <p>I've written a batch execution framework and in it I want (in some scenarios) to load an assembly from the GAC where there may be multiple versions but I just want to load the <em>latest version</em>.<br>
Is this even possible?</p>
<p>TIA</p>
| [
{
"answer_id": 283880,
"author": "csgero",
"author_id": 21764,
"author_profile": "https://Stackoverflow.com/users/21764",
"pm_score": 2,
"selected": false,
"text": "Assembly.LoadWithPartialName(string)"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36852/"
] |
283,431 | <p>My record sheet app has a menu option for creating a new, blank record sheet. When I open a sheet window, I can open new windows without a problem, using subprocess.Popen() to do it.</p>
<p>However, under Windows (I haven't tested it on other OSes yet), if I open a new window then use the "open file" dialog to populate the fields with data from a file, I'm no longer able to create new windows. Once it's populated, Windows gives me the </p>
<blockquote>
<p>'foo.py' is not recognized as an internal or external command, operable
program or batch file.</p>
</blockquote>
<p>I don't understand what would cause Windows to suddenly not recognize the Popen() call. I don't have any code that would affect it in any way that I'm aware of.</p>
| [
{
"answer_id": 283545,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 3,
"selected": true,
"text": "subprocess.Popen([r'C:\\Python2.5\\python.exe', r'C:\\path\\to\\foo.py'])\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18676/"
] |
283,454 | <p>I have been working with hibernate/JPA on JBoss for some months now and have one question that I can't find an answer or solution for.</p>
<p>It seems like when creating new entity beans I'm not able to do a query before I at least have called EntityManager.persist(entityBean), or else I get the following error:</p>
<p><code>TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing</code></p>
<p>An example:</p>
<pre><code>Job job = new Job();
Collection<Task> tasks = job.getTasks();
//entityManager.persist(job);
ActionPlan actionPlan = (ActionPlan) entityManager.createNamedQuery("ActionPlan.findByCommand").
setParameter("type", RunOperation.Install).getSingleResult();
Task task = Task.getTask(actionPlan);
task.setActionPlan(actionPlan);
tasks.add(task);
task.setJob(job);
</code></pre>
<p>My problem is that I can't call createNamedQuery without first persisting 'job' (the line that is commented out). ActionPlan has a relation to Job, but the NamedQuery (findByCommand) does not join on Job. What bothers me is that I need to persist Job in order to query the database, when the new created Job is not even interesting in this context.<br>
Moving the call to persist() to the end of the snippet yields the above mentioned error.</p>
<p>I'm aware that the object I'm working on is not persisted, but persisting makes it impossible to rollback if an error occurs.</p>
<p>I believe there is a solution for this, so if someone has the answer I would be very thankful. What am I missing?</p>
| [
{
"answer_id": 283628,
"author": "Georgy Bolyuba",
"author_id": 4052,
"author_profile": "https://Stackoverflow.com/users/4052",
"pm_score": 2,
"selected": false,
"text": "Session sess = factory.openSession();\nTransaction tx;\ntry {\ntx = sess.beginTransaction();\n //do some work\n ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16152/"
] |
283,456 | <p>Anyone know a good and effective way to search/match for a byte pattern in an byte[] array and then return the positions.</p>
<p>For example</p>
<pre><code>byte[] pattern = new byte[] {12,3,5,76,8,0,6,125};
byte[] toBeSearched = new byte[] {23,36,43,76,125,56,34,234,12,3,5,76,8,0,6,125,234,56,211,122,22,4,7,89,76,64,12,3,5,76,8,0,6,125}
</code></pre>
| [
{
"answer_id": 283469,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": -1,
"selected": false,
"text": " [STAThread]\n static void Main(string[] args)\n {\n byte[] pattern = new byte[] {12,3,5,76,8,0,6,125... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36504/"
] |
283,460 | <p>While connecting .NET to sybase server I got this error message:</p>
<blockquote>
<p>[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified</p>
</blockquote>
<p>This has worked properly before. System DSN with same details worked and data connection through vs.net also worked.</p>
<p>I am using VS.NET 2005.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 292261,
"author": "user37887",
"author_id": 37887,
"author_profile": "https://Stackoverflow.com/users/37887",
"pm_score": -1,
"selected": false,
"text": "regedit"
},
{
"answer_id": 5034297,
"author": "SqlRyan",
"author_id": 8114,
"author_profile": "http... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,464 | <p>Is there any such thing as a virtual Lineprinter.I mean a software emulation of a printer, that outputs to screen.</p>
<p>I have a project to change the output of print job. My past experience with a lineprinter was tedious rounds of</p>
<pre><code>loop:
print
walk down two flights
check the output
walk back up two flights
edit code
got loop:
</code></pre>
<p>Anyone who thinks a lineprinter can be installed in a programmers office has not used a LinePrinter!</p>
<p>Googles just turning up printer emulation, as in printers that emulate other printers or virtual printer ports!</p>
| [
{
"answer_id": 292261,
"author": "user37887",
"author_id": 37887,
"author_profile": "https://Stackoverflow.com/users/37887",
"pm_score": -1,
"selected": false,
"text": "regedit"
},
{
"answer_id": 5034297,
"author": "SqlRyan",
"author_id": 8114,
"author_profile": "http... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15710/"
] |
283,465 | <p>What's your preferred way of wrapping lines of code, especially when it comes to long argument lists?</p>
<p>There has been several questions relating to wrapping lines (such as <a href="https://stackoverflow.com/questions/268284/when-writing-code-do-you-wrap-text-or-not">When writing code do you wrap text or not?</a> and <a href="https://stackoverflow.com/questions/276022/line-width-formatting-standard">Line width formatting standard</a>), but I haven't been able to find one which covers where to wrap a line of code.</p>
<p>Let's say we have a line of code that keeps going and going like this example:</p>
<pre><code>int SomeReturnValue = SomeMethodWithLotsOfArguments(Argument1, Argument2, Argument3, Argument4);
</code></pre>
<p><strong>How should that be wrapped?</strong></p>
<p>Here's a few ways I can think of, and some of their downsides:</p>
<pre><code>int SomeReturnValue = SomeMethodWithLotsOfArguments(Argument1, Argument2,
Argument3, Argument4);
</code></pre>
<p>I personally don't prefer that option because the formatting seems to visually separate the argument list from the method I am trying to call, especially since there is an assignment equals sign ("=") right above the orphanged arguments on the new line.</p>
<p>So, for a while I went with the following approach:</p>
<pre><code>int SomeReturnValue = SomeMethodWithLotsOfArguments(Argument1,
Argument2,
Argument3,
Argument4);
</code></pre>
<p>Here, the arguments are all bundled together, all on the side of the method's first argument. However, one catch is that the argument list won't always line up in the second line onwards because of the number of spaces that the tab indents. (And typing extra spaces for formatting would be too time consuming.)</p>
<p>An <a href="https://stackoverflow.com/questions/268284/when-writing-code-do-you-wrap-text-or-not#269025">answer</a> in the one of the previous questions suggested the following format:</p>
<pre><code>int SomeReturnValue = SomeMethodWithLotsOfArguments(
Argument1,
Argument2,
Argument3,
Argument4
);
</code></pre>
<p>I actually like this format, due to its visual appeal, but it also it does visually separate the arguments from the method that the list belongs to. Also, I prefer to have a single method call not take up too many lines.</p>
<p>So, my question is, <em>without getting into the issue of preventing a code of line from getting too long in the first place</em>, <strong>how would you recommend wrapping lines of code?</strong> Specifically, <strong>where is a good place to break a line of code, when it comes to long argument lists?</strong></p>
| [
{
"answer_id": 283483,
"author": "Dheer",
"author_id": 17266,
"author_profile": "https://Stackoverflow.com/users/17266",
"pm_score": 4,
"selected": false,
"text": "int SomeReturnValue = SomeMethodWithLotsOfArguments(\n Argument1,\n Argument2,\n Argument3,\n Argument4\n);\n"
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17172/"
] |
283,468 | <p>In C# you can use verbatim strings like this:</p>
<pre><code>@"\\server\share\file.txt"
</code></pre>
<p>Is there something similar in JavaScript?</p>
| [
{
"answer_id": 283642,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 5,
"selected": true,
"text": "public void Alert(string message)\n{\n message = message.Replace(\"\\\\\", \"\\\\\\\\\")\n .Replace(\"\\r\... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4830/"
] |
283,470 | <p>i get the following error when trying to run a flex application (which has been working fine!). I was playing around with some different setttings trying to optimize the compiled size. I've put these settings back to the defaults as much as I thought but still getting issues.</p>
<p>I remember getting this error before but cant seem to remember how I fixed it - nor any useful information about how to fix it again! </p>
<p>Anybody know?</p>
<p>VerifyError: Error #1014: Class IAutomationObject could not be found.</p>
<pre><code>at flash.display::MovieClip/nextFrame()
at mx.managers::SystemManager/deferredNextFrame()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:299]
at mx.managers::SystemManager/preloader_initProgressHandler()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2225]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::Preloader/timerHandler()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\preloaders\Preloader.as:398]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
</code></pre>
| [
{
"answer_id": 283642,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 5,
"selected": true,
"text": "public void Alert(string message)\n{\n message = message.Replace(\"\\\\\", \"\\\\\\\\\")\n .Replace(\"\\r\... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] |
283,471 | <p>I know you can do it file by file.</p>
<p>Is there any way to do this in one step for all files in a project?</p>
| [
{
"answer_id": 283474,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "Imports System\nImports EnvDTE\nImports EnvDTE80\nImports EnvDTE90\nImports System.Diagnostics\n\nPublic Module Organi... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
283,476 | <p>I am wondering what is the "best practice" to break long strings in C# source code. Is this string </p>
<pre><code>"string1"+
"string2"+
"string3"
</code></pre>
<p>concatenated during compiling or in run time?</p>
| [
{
"answer_id": 283491,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "string x = \"string1string2string3\"\nstring y = \"string1\" + \"string2\" + \"string3\"\n"
},
{
"answer_id": 283... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] |
283,477 | <p>Suppose I have the following directory layout in a Maven project:</p>
<pre><code>src/
|-- main
| |-- bin
| | |-- run.cmd
| | `-- run.sh
| |-- etc
| | |-- common-spring.xml
| | |-- log4j.xml
| | `-- xml-spring.xml
| `-- java
| `-- com
...
</code></pre>
<p>I would like to build a zip file that, when unzipped, produces something like this:</p>
<pre><code>assembly
|-- bin
| |-- run.cmd
| `-- run.sh
|-- etc
| |-- common-spring.xml
| |-- log4j.xml
| `-- xml-spring.xml
`-- lib
|-- dependency1.jar
|-- dependency2.jar
...
</code></pre>
<p>where `run.xx' are executable shell scripts that will call my main application and <em>put all dependencies on the classpath</em>.</p>
<p>Is this possible with some of the `official' Maven plugins, e.g. maven-assembly-plugin?</p>
| [
{
"answer_id": 283564,
"author": "jassuncao",
"author_id": 1009,
"author_profile": "https://Stackoverflow.com/users/1009",
"pm_score": 5,
"selected": true,
"text": "...\n<build>\n<plugins>\n <plugin>\n <groupId>org.codehaus.mojo</groupId>\n <artifactId>appassembler-maven-plugin</a... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1428/"
] |
283,484 | <p>Is there anything similar to getElementById in actionscript? </p>
<p>I'm trying to make a prototype of a flash page wich gets it's data from a xhtml file. I want to have both an accessible html version (for search engines, textreaders and people without flash) and a flash version (because the customer insists to use flash even though a html-css-ajax solution would do quite nicely). </p>
<p>What I need is a simple way of getting the text or attributes from the html with a certain id, like <code><h1 id="flashdataTitle">This is the title</h1></code> etc. I'm guessing a few ways it might be possible:</p>
<ul>
<li>Somehow use an ExternalInterface.call and do the DOM trickery in JavaScript (wich is probably what I will do, because I'm very familiar with JS and a complete newbie with flash/actionscript, unless you have a better solution)</li>
<li>Load the xhtml with the Actionscript XML class, and manually traverse the XML looking for the correct id attribute (but this is probably very slow)</li>
<li>Use XPath with the XML class in actionscript. (I'd like some hints on how to do this, if this is the reccomended way)</li>
<li>There is actually an Actionscript equivalent to getElementById to use with the XML?</li>
<li>Allthough my employer hope we don't have to do this: I could rewrite the server side code to output the relevant texts and image urls in a flash-friendly format.</li>
</ul>
<p>What is the most effective, easiest to implement, and robust-crossbrowser way of doing this? Any totally different ideas?</p>
<p>Please post any ideas even if you think the question have been answered, I'd like to explore all the different possibilities, and allso what disadvantages the proposed solutions have.</p>
| [
{
"answer_id": 283552,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": true,
"text": "import mx.xpath.XPathAPI;\n\nvar elementId:String = \"flashdataTitle\";\nvar elementPath:String = \"//h1[@id'\" + elementId... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26115/"
] |
283,486 | <p>We are experiencing a strange bug on our website which we think is related to the software installed on user's computers. We have an e-mail link on a lot of pages, which is created using Javascript (so spambots won't get it).</p>
<p>It seems the link is "clicked" automatically on some user's machines. Some users then discard the window by clicking Send on the e-mail window that pops up, resulting in a ton of e-mails to us.</p>
<p>When inspecting the Apache log, nothing weird can be seen in the browser string. Can this be a download accelerator/prefetcher gone haywire? Any other theories as to what this might be?</p>
<p>The link in the HTML is written like this (it is autogenerated by Smarty):</p>
<pre><code><script type="text/javascript" language="javascript">
<!--
{document.write(String.fromCharCode(60,97,32,104,114,101,
102,61,34,109,97,105,108,116,111,58,115,117,112,112,111,114,
116,64,112,114,111,118,101,46,110,111,63,115,117,98,106,101,99,
116,61,82,101,102,101,114,97,110,115,101,110,117,109,109,101,114,
37,50,48,49,53,48,48,34,32,62,83,101,110,100,32,115,112,38,111,115,
108,97,115,104,59,114,115,109,38,97,114,105,110,103,59,108,46,60,47,97,62))}
//-->
</script>
</code></pre>
| [
{
"answer_id": 1361093,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 0,
"selected": false,
"text": "mailto:"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1606/"
] |
283,489 | <p>I'm using maven 2.0.9 with Eclipse 3.3.2.</p>
<p>I'm used to launching a fresh build once per day by a <code>mvn clean install</code>.
Then, if I refresh my Eclipse project, it will be "polluted" by files from Maven's <em>target</em> directory.</p>
<p>That's very annoying while performing searches, getting resources by "open resource" and so on.</p>
<p>Is there a way to avoid Eclipse looking in this folder?</p>
| [
{
"answer_id": 5539274,
"author": "Marx",
"author_id": 691183,
"author_profile": "https://Stackoverflow.com/users/691183",
"pm_score": 5,
"selected": false,
"text": "<plugin>\n <artifactId>maven-clean-plugin</artifactId>\n <configuration>\n <excludeDefaultDirectories>true</e... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3122/"
] |
283,492 | <p>I'm tring to build a library for simplifing late binding calls in C#, and I'm getting trouble tring with reference parameteres. I have the following method to add a parameter used in a method call</p>
<pre><code> public IInvoker AddParameter(ref object value)
{
//List<object> _parameters = new List<object>();
_parameters.Add(value);
//List<bool> _isRef = new List<bool>();
_isRef.Add(true);
return this;
}
</code></pre>
<p>And that doesn't work with value types, because they get boxed as an object, thus they are not modified. E.g:</p>
<pre><code>int param1 = 2;
object paramObj = param1;
//MulFiveRef method multiplies the integer passed as a reference parameter by 5:
//void MulFiveRef(ref int value) { value *= 5; }
fi.Method("MulFiveRef").AddParameter(ref paramObj);
</code></pre>
<p>That doesn't work. The late binding call is successful, and the inner List which holds the parameteres (_parameters ) does get modified, but not the value outside the call.</p>
<p>Does anyone knows a simple way to overcome this limitation?
The AddParameter signature cannot be modified, as with late binding calls, you cannot know in advance the Type of the parameters (and either way you insert all the parameters for a call inside an object array prior to making the call)</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 283499,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "value"
},
{
"answer_id": 283500,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "ht... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10136/"
] |
283,497 | <p>Should I use the <code>change</code> or <code>textInput</code> event to capture user input on a TextInput control? Why?</p>
| [
{
"answer_id": 283767,
"author": "hasseg",
"author_id": 4111,
"author_profile": "https://Stackoverflow.com/users/4111",
"pm_score": 7,
"selected": true,
"text": "textInput"
},
{
"answer_id": 309663,
"author": "Ross Henderson",
"author_id": 37446,
"author_profile": "ht... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36817/"
] |
283,513 | <p>We just shifted from VB to C# and I am having some troubles..!</p>
<p>Why can't I create a private static const void?? </p>
<p>why is it not working?</p>
<pre><code> private static const void MyVoid(void void)
{
try
{
this.void void = new void(void + void);
return this.void;
}
catch (void)
{
Response.Write(void);
}
}
</code></pre>
| [
{
"answer_id": 283517,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 2,
"selected": false,
"text": "void"
},
{
"answer_id": 283526,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://S... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36864/"
] |
283,523 | <p>I have a C# application where i want to implement a logic for a programm which will open the word document and go to a certain place in the page and create a Table and put values in that. Can any one tell me how to implement this. I am using Visual studio 2005 </p>
| [
{
"answer_id": 10769658,
"author": "Gary Kindel",
"author_id": 44597,
"author_profile": "https://Stackoverflow.com/users/44597",
"pm_score": 3,
"selected": false,
"text": "using word = Microsoft.Office.Interop.Word; \npublic static void ExportToWord(DataGridView dgv)\n ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,525 | <p>This line:</p>
<pre><code>strcat(query,*it);
</code></pre>
<p>(where <code>*it</code> is an iterator to a string)</p>
<p>Keeps giving me this error:</p>
<blockquote>
<p>no matching function for call to ``strcat(char[200], const std::basic_string, std::allocator >&)`' </p>
</blockquote>
<p>I guess it's because <code>strcat</code> takes in a <code>char*</code> while <code>*it</code> is a string.
How do I convert it from a string to a <code>char*</code> to make it work with <code>strcat()</code> ?</p>
<p>I've tried <code>strcat(query,(*it).c_str())</code> but that just gives me a runtime error.</p>
<p>Edit: sorry, it should be converted to a <code>const char*</code></p>
| [
{
"answer_id": 283531,
"author": "tragomaskhalos",
"author_id": 31140,
"author_profile": "https://Stackoverflow.com/users/31140",
"pm_score": 3,
"selected": false,
"text": "strcat(query,(*it).c_str())"
},
{
"answer_id": 283532,
"author": "unwind",
"author_id": 28169,
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28462/"
] |
283,537 | <p>Given a method signature:</p>
<pre><code>public bool AreTheSame<T>(Expression<Func<T, object>> exp1, Expression<Func<T, object>> exp2)
</code></pre>
<p>What would be the most efficient way to say if the two expressions are the same? This only needs to work for simple expressions, by this I mean all that would be "supported" would be simple MemberExpressions, eg c => c.ID.</p>
<p>An example call might be:</p>
<pre><code>AreTheSame<User>(u1 => u1.ID, u2 => u2.ID); --> would return true
</code></pre>
| [
{
"answer_id": 283546,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "using System;\nusing System.Linq.Expressions;\nclass Test {\n public string Foo { get; set; }\n public string Ba... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32855/"
] |
283,551 | <p>I am struggling with a creating a query. It is related to a large and complicated database but for the sake of this post I have boiled the problem down to something simpler.</p>
<p>I have three tables X, Y, Z defined as</p>
<pre><code>CREATE TABLE [dbo].[X](
[ID] [bigint] NOT NULL
)
CREATE TABLE [dbo].[Y](
[ID] [nchar](10) NOT NULL
)
CREATE TABLE [dbo].[Z](
[IDX] [bigint] NOT NULL,
[IDY] [nchar](10) NOT NULL
)
</code></pre>
<p>They contain the following data</p>
<pre><code>Table X Table Y Table Z
ID ID IDX IDY
-- -- --- ---
1 A 1 A
2 B 1 B
3 C 1 A
</code></pre>
<p>I want to create a query that produces the following result</p>
<pre><code>Count IDX IDY
===== === ===
2 1 A
1 1 B
0 1 C
0 2 A
0 2 B
0 2 C
0 3 A
0 3 B
0 3 C
</code></pre>
<p>My initial thought was</p>
<pre><code>SELECT COUNT(*), X.ID, Y.ID
FROM
X
CROSS JOIN Y
FULL OUTER JOIN Z ON X.ID = Z.IDX AND Y.ID = Z.IDY
GROUP BY X.ID, Y.ID
</code></pre>
<p>but this turns out to be on the wrong road.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 283586,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 0,
"selected": false,
"text": "SELECT\n COUNT(z.idx) count,\n x.id idx,\n y.id idy\nFROM\n (x CROSS JOIN y)\n LEFT JOIN z ON z.idx = x.id AND z.idy ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,556 | <p>I am trying to find the crc that works with the following results. The byte string consists of 2 bytes (ie. 0xCE1E) and the crc is an single byte (ie. 0x03)</p>
<pre>
byte crc
CE1E 03
CE20 45
CE22 6F
0000 C0
0001 D4
FFFF 95
</pre>
<p>Can anyone help?</p>
| [
{
"answer_id": 848161,
"author": "Eyal",
"author_id": 4454,
"author_profile": "https://Stackoverflow.com/users/4454",
"pm_score": 2,
"selected": false,
"text": "CE1E % p = 03\nCE20 % p = 45\nCE22 % p = 6F\n0000 % p = C0\n0001 % p = D4\nFFFF % p = 95\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,561 | <p>Inspired by <a href="https://stackoverflow.com/questions/277106/looking-for-some-interesting-c-programming-problems">this question</a>, I wanted to try my hand at the latest <a href="http://domino.research.ibm.com/Comm/wwwr_ponder.nsf/Challenges/November2008.html" rel="nofollow noreferrer">ponder this challenge</a>, using F#</p>
<p>My approach is probably completely off course, but in the course of solving this problem, I'm trying to get a list of all the permutations of the digits 0-9.</p>
<p>I'm looking at solving it using a n-ary tree like so:</p>
<pre><code>type Node =
| Branch of (int * Node list)
| Leaf of int
</code></pre>
<p>I'm quite pleased with myself, because I've managed to work out how to generate the tree that I want. </p>
<p>My problem now is that I can't work out how to traverse this tree and extract the 'path' to each leaf as an int. Thing thing that is confusing me is that I need to match on individual Nodes, but my 'outer' function needs to take a Node list.</p>
<p>My current attempt almost does the right thing, except that it returns me the sum of all the paths...</p>
<pre><code>let test = Branch(3, [Branch(2, [Leaf(1)]);Branch(1, [Leaf(2)])])
let rec visitor lst acc =
let inner n =
match n with
| Leaf(h) -> acc * 10 + h
| Branch(h, t) -> visitor t (acc * 10 + h)
List.map inner lst |> List.sum
visitor [test] 0 //-> gives 633 (which is 321 + 312)
</code></pre>
<p>And I'm not even sure that this is tail-recursive.</p>
<p>(You're quite welcome to propose another solution for finding permutations, but I'm still interested in the solution to this particular problem)</p>
<p>EDIT: I've posted a generic permutations algorithm in F# <a href="https://stackoverflow.com/questions/286427/calculating-permutations-in-f">here</a>.</p>
| [
{
"answer_id": 283638,
"author": "Tomas Petricek",
"author_id": 33518,
"author_profile": "https://Stackoverflow.com/users/33518",
"pm_score": 4,
"selected": true,
"text": "let rec visitor lst tree = \n match tree with\n | Branch(n, sub) -> List.collect (visitor (n::lst)) sub\n | Leaf(... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] |
283,575 | <p>I'm using the ReportViewer control to display a Report within a WebForm, i've also implemented the "Export to Excel" feature, by calling the Render method of the Server Report</p>
<p>eg</p>
<pre><code>ReportViewerControl.ServerReport.Render("Excel",etc,etc,etc);
</code></pre>
<p>My problem is that the exported report contains Hyperlinks that link to other reports, I wish these to appear in the webform but not appear hence be disabled in the Exported Spreadsheet (generated by the Code above).</p>
<p>Does anyone have a way of achieving this?</p>
<p>Thanks</p>
| [
{
"answer_id": 283638,
"author": "Tomas Petricek",
"author_id": 33518,
"author_profile": "https://Stackoverflow.com/users/33518",
"pm_score": 4,
"selected": true,
"text": "let rec visitor lst tree = \n match tree with\n | Branch(n, sub) -> List.collect (visitor (n::lst)) sub\n | Leaf(... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30861/"
] |
283,589 | <p>is there a way to change an oracle user's default schema?</p>
<p>I found it in the FAQ that I can alter it in the session, but it's not what I want. E.G. the user at log on always sees another schema as default.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 283814,
"author": "Tony Andrews",
"author_id": 18747,
"author_profile": "https://Stackoverflow.com/users/18747",
"pm_score": 6,
"selected": true,
"text": "CREATE OR REPLACE TRIGGER db_logon\nAFTER logon ON DATABASE WHEN (USER = 'A')\nBEGIN\n execute immediate 'ALTER SES... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11621/"
] |
283,591 | <p>I have an website. When the user is logged the session details will loaded.
When the user logged out the session details will abandoned. (Log out by clicking the logout menu)
when the user simply closes the browser then how to destroy the session.</p>
<p>In the next time its get logging with the same session data. I need to avoid this.</p>
| [
{
"answer_id": 283622,
"author": "GeekyMonkey",
"author_id": 29900,
"author_profile": "https://Stackoverflow.com/users/29900",
"pm_score": 0,
"selected": false,
"text": "< sessionState ... timeout=\"5\" />\n"
},
{
"answer_id": 4586469,
"author": "Sunil Gosaliya",
"author_... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22162/"
] |
283,593 | <p>Currently, my Objective C classes use C++ objects by doing a <code>new</code> when the owner is created, and calling <code>delete</code> when it is destroyed. But is there another way? I'd like to be able to declare, say, an <code>auto_ptr</code> whose scope lasts the duration of the Objective C class' lifetime.</p>
| [
{
"answer_id": 284770,
"author": "wisequark",
"author_id": 33159,
"author_profile": "https://Stackoverflow.com/users/33159",
"pm_score": 1,
"selected": false,
"text": "delete"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9476/"
] |
283,608 | <p>I have quite a large list of words in a txt file and I'm trying to do a regex find and replace in Notepad++. I need to add a string before each line and after each line.. So that:</p>
<pre>
wordone
wordtwo
wordthree
</pre>
<p>become</p>
<pre>
able:"wordone"
able:"wordtwo"
able:"wordthree"
</pre>
<p>How can I do this?</p>
| [
{
"answer_id": 283613,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 9,
"selected": true,
"text": "Search = ^([A-Za-z0-9]+)$\nReplace = able:\"\\1\"\n"
},
{
"answer_id": 44923194,
"author": "Mukul Ag... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] |
283,632 | <p>I followed the commonly-linked tip for reducing an application to the system tray : <a href="http://www.developer.com/net/csharp/article.php/3336751" rel="noreferrer">http://www.developer.com/net/csharp/article.php/3336751</a> Now it works, but there is still a problem : my application is shown when it starts ; I want it to start directly in the systray. I tried to minimize and hide it in the Load event, but it does nothing.</p>
<p>Edit : I could, as a poster suggested, modify the shortcut properties, but I'd rather use code : I don't have complete control over every computer the soft is installed on.</p>
<p>I don't want to remove it completely from everywhere except the systray, I just want it to start minimized.</p>
<p>Any ideas ?</p>
<p>Thanks</p>
| [
{
"answer_id": 283640,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "NotifyIcon"
},
{
"answer_id": 283649,
"author": "lubos hasko",
"author_id": 275,
"author_profile"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6776/"
] |
283,636 | <p>We need to set up a secure certificate on an Apache reverse proxy.
We've been advised that we need to use a virtual host directive.</p>
<p>I've looked these up in the O'Reilly book bit can't find any examples that pick up https specifically.</p>
<p>Does anyone have any examples of config snippets to do this?</p>
| [
{
"answer_id": 283663,
"author": "f4nt",
"author_id": 14838,
"author_profile": "https://Stackoverflow.com/users/14838",
"pm_score": 2,
"selected": false,
"text": "<IfModule mod_ssl.c>\n SSLProxyEngine On\n ProxyPreserveHost On\n RewriteRule ^/whatever(.*)$ https://otherhos... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39447/"
] |
283,637 | <p>Can I utilise the new functionality provided by the new JavaFX APIs directly from Java to the same extent as I would be able to using JavaFX Script?</p>
<p>Are all the underlying JavaFX APIs purely Java or JavaFX Script or a mix?</p>
| [
{
"answer_id": 716236,
"author": "Marco Luglio",
"author_id": 14263,
"author_profile": "https://Stackoverflow.com/users/14263",
"pm_score": 1,
"selected": false,
"text": "import java.awt.Color;\nimport java.awt.Paint;\nimport java.awt.geom.Point2D;\n\nimport javax.swing.JFrame;\nimport j... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] |
283,645 | <p>I have a python list, say l</p>
<pre><code>l = [1,5,8]
</code></pre>
<p>I want to write a sql query to get the data for all the elements of the list, say</p>
<pre><code>select name from students where id = |IN THE LIST l|
</code></pre>
<p>How do I accomplish this?</p>
| [
{
"answer_id": 283706,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 4,
"selected": false,
"text": "myquery = \"select name from studens where id in (%s)\" % \",\".join(map(str,mylist))\n"
},
{
"answer_id": 283713,
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2220518/"
] |
283,646 | <p>I have just converted a project from Visual Studio 2003 to 2005 and although most of it 'converted' fine, I have a series of STL errors from the following line:</p>
<pre><code>void SomeFn( std::vector<CSomeObject*>::iterator it,
std::vector<CSomeObject*>::iterator itBegin = NULL,
std::vector<CSomeObject*>::iterator itEnd = NULL );
</code></pre>
<p>The Visual Studio error is as follows:</p>
<pre><code>c:\<path>\Headerfile.h(20) : error C2440: 'default argument' : cannot convert from 'int' to 'std::_Vector_iterator<_Ty,_Alloc>'
with
[
_Ty=CObject *,
_Alloc=std::allocator<CObject *>
]
No constructor could take the source type, or constructor overload resolution was ambiguous
</code></pre>
<p>I can't see anything wrong with that code and it worked perfectly in VS 2003. Any ideas?</p>
| [
{
"answer_id": 283660,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 2,
"selected": false,
"text": "std::vector<T>::iterator"
},
{
"answer_id": 283693,
"author": "PierreBdR",
"author_id": 7136,
"author... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] |
283,661 | <p>Since a few days ago, MySQL server on my Windows machine was not successful on closing itself. I found multiple instance of these lines in the MySQL error log:</p>
<pre><code>InnoDB: Operating system error number 32 in a file operation.
InnoDB: The error means that another program is using InnoDB's files.
InnoDB: This might be a backup or antivirus software or another instance
InnoDB: of MySQL. Please close it to get rid of this error.
</code></pre>
<p>I have plenty of free spaces, the server is installed for months, the version is 5.1.22-rc-community-log on Windows XP SP3, and I have used only one Windows account to create and execute MySQL service.</p>
<p>Following Greg's answer, I found through <code>ProcessExplorer</code> that there's another MySQL service running with a different name. I kill it and all run fine.</p>
| [
{
"answer_id": 11202882,
"author": "Anadi Kumar",
"author_id": 1482004,
"author_profile": "https://Stackoverflow.com/users/1482004",
"pm_score": 2,
"selected": false,
"text": "cd E:\\apps\\db\\mysql-5.5.25-win32\\bin"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8404/"
] |
283,669 | <p>I have a console application project in C# 2.0 that needs to write something to the screen in a while loop. I do not want the screen to scroll because using Console.Write or Console.Writeline method will keep displaying text on console screen incremently and thus it starts scrolling.</p>
<p>I want to have the string written at the same position. How can i do this?</p>
<p>Thanks</p>
| [
{
"answer_id": 49099413,
"author": "fishjd",
"author_id": 321747,
"author_profile": "https://Stackoverflow.com/users/321747",
"pm_score": 2,
"selected": false,
"text": " /// <summary>\n /// Writes a string at the x position, y position = 1;\n /// Tries to catch all exceptions, w... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20933/"
] |
283,672 | <p>I have a user who gets an error from ajax calls on our site.</p>
<p>The error is pasted below. </p>
<p>They get the error in FF3 Windows, but not IE.</p>
<p>Based on some searching it seems this issue is often caused by the client protocol squid (you'll notice at the end of the error, squid is mentioned).</p>
<p>My ajax code is the same used here: <a href="http://www.w3schools.com/Ajax/ajax_browsers.asp" rel="nofollow noreferrer">http://www.w3schools.com/Ajax/ajax_browsers.asp</a></p>
<p>Any ideas?</p>
<pre><code>ERROR
The requested URL could not be retrieved
While trying to process the request:
POST /library/cart/cart_ajax.php?action=refreshCartWidget&qty=dontuse& HTTP/1.1
Host: mydomain.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: identity,gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: Close
Referer: http://mydomain.com/library
Pragma: no-cache
Cache-Control: no-cache
The following error was encountered:
Invalid Request
Some aspect of the HTTP Request is invalid. Possible problems:
Missing or unknown request method
Missing URL
Missing HTTP Identifier (HTTP/1.0)
Request is too large
Content-Length missing for POST or PUT requests
Illegal character in hostname; underscores are not allowed
Your cache administrator is webmaster.
Generated Wed, 12 Nov 2008 09:28:58 GMT by ipwal3.osi-tech.com (squid/2.6.STABLE17)
</code></pre>
| [
{
"answer_id": 283686,
"author": "Till",
"author_id": 2859,
"author_profile": "https://Stackoverflow.com/users/2859",
"pm_score": 2,
"selected": false,
"text": "$.post(\n '/the/url/to/post/to',\n { some: data },\n function(data) { alert(data); }\n);\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,679 | <p>I'm not looking for the usual answer like Web-services. I'm looking for a light solution to be run in the same machine.</p>
<p>Edit: I'm looking for way in Java to call .NET methods</p>
| [
{
"answer_id": 11683074,
"author": "Mechanical snail",
"author_id": 319931,
"author_profile": "https://Stackoverflow.com/users/319931",
"pm_score": 1,
"selected": false,
"text": "javac"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36678/"
] |
283,701 | <p>What are best practices with regards to C and C++ coding standards? Should developers be allowed to willy-nilly mix them together. Are there any complications when linking C and C++ object files.</p>
<p>Should things like socket libraries that traditionally is written in C remain in C and kept in seperate source files? That is keeping c code in .c files and c++ code in .cpp files.
When mixing c and C++ after being parsed with g++ will there be any performance penalties, since typesafe checks are not done in C? but are in C++. Would would be the best way to link C and C++ source code files.</p>
| [
{
"answer_id": 283716,
"author": "Graeme Perrow",
"author_id": 1821,
"author_profile": "https://Stackoverflow.com/users/1821",
"pm_score": 3,
"selected": false,
"text": "extern \"C\""
},
{
"answer_id": 283722,
"author": "Sunlight",
"author_id": 33650,
"author_profile"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7362/"
] |
283,707 | <p>Is there a way to find the size of a file object that is currently open?</p>
<p>Specifically, I am working with the tarfile module to create tarfiles, but I don't want my tarfile to exceed a certain size. As far as I know, tarfile objects are file-like objects, so I imagine a generic solution would work.</p>
| [
{
"answer_id": 283718,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": false,
"text": "fstat"
},
{
"answer_id": 283719,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "http... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36312/"
] |
283,727 | <p>I've spent hours trying to get my code to work, its a rats nest of if/elses. Basically I want to check a country name against these two arrays:</p>
<pre><code>//if its in this array add a 'THE'
$keywords = array("bahamas","island","kingdom","republic","maldives","netherlands",
"isle of man","ivory","philippines","seychelles","usa");
//if its in this array, take THE off!
$exceptions = array("eire","hispaniola");
</code></pre>
<p>and thats it. </p>
<p>Its sending me batty, and to be honest I'm embarassed to show you my code. Lets just say it has 2 if statements, 2 else statements and 2 foreach loops. Its a blooming mess, and I was hoping someone can dumbfound me by showing me a good way of doing this? I expect there is a way using only 1 line of code, or something sickening like that.
Thank you.</p>
| [
{
"answer_id": 283742,
"author": "Stefan Gehrig",
"author_id": 11354,
"author_profile": "https://Stackoverflow.com/users/11354",
"pm_score": 2,
"selected": false,
"text": "$countryKey = strtolower($country);\nif (in_array($countryKey, $keywords)) {\n $country = 'The' . $country;\n} el... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26107/"
] |
283,728 | <p>I need to create a BAT file to run an application through telnet, but as far as I know there is no way to do this on DOS. Telnet does not allow any command to be sent to the remote machine at the very instant of the connection, and each subsequent command in the BAT file would only be executed after telnet stops. This hypothetical piece of code illustrates what I want to do:</p>
<pre><code>telnet 100.99.98.1 "C:\Application\app.exe -a -b -c"
</code></pre>
<p>And that would run the app.exe on the machine 100.99.98.1 with three parameters. Despite my efforts, nothing worked. Is there a way to do that?</p>
<p>Tks,</p>
<p>Pedrin Batista</p>
| [
{
"answer_id": 283744,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 0,
"selected": false,
"text": "start"
},
{
"answer_id": 283747,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36183/"
] |
283,737 | <p>I have an ASP.NET 1.1 application that uses the following code to write out a file in the response:</p>
<pre><code>Dim objStream As Object
objStream = Server.CreateObject("ADODB.Stream")
objStream.open()
objStream.type = 1
objStream.loadfromfile(localfile)
Response.BinaryWrite(objStream.read)
</code></pre>
<p>This code is called by a pop up window that displays this file or gives a open/save dialog in Internet Explorer. The problem is, that it seems to work fine in IE6 but in IE7 the pop up opens and then closes without displaying the file. Any one know whats wrong?</p>
| [
{
"answer_id": 1060550,
"author": "pedrofernandes",
"author_id": 127891,
"author_profile": "https://Stackoverflow.com/users/127891",
"pm_score": 0,
"selected": false,
"text": "strFilename = Server.MapPath(\"/App_Upload/\" & strFilename) \n\nWith Response\n .AddHeader(\"Content-Type\"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688440/"
] |
283,740 | <p>I am using the Zend Framework.</p>
<p>I have a controller named 'UserController' that has a public function displayAction().</p>
<p>I would like to know how I can get that action method to use a different viewer than the default display.phtml.</p>
<p>Any help is appreciated.</p>
| [
{
"answer_id": 283784,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 5,
"selected": true,
"text": "$this->render('actionName');\n"
},
{
"answer_id": 10469195,
"author": "Brian Vanderbusch",
"author_i... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15052/"
] |
283,749 | <p>At work, I'm frequently working on projects where numerous properties of certain objects have to be set during their construction or early during their lifetime. For the sake of convenience and readability, I often use the <code>With</code> statement to set these properties. I find that</p>
<pre><code>With Me.Elements
.PropertyA = True
.PropertyB = "Inactive"
' And so on for several more lines
End With
</code></pre>
<p>Looks much better than</p>
<pre><code>Me.Elements.PropertyA = True
Me.Elements.PropertyB = "Inactive"
' And so on for several more lines
</code></pre>
<p>for very long statements that simply set properties.</p>
<p>I've noticed that there are some issues with using <code>With</code> while debugging; however, <strong>I was wondering if there were any compelling reasons to avoid using <code>With</code> in practice</strong>? I've always assumed the code generated via the compiler for the above two cases is basically the same which is why I've always chosen to write what I feel to be more readable. </p>
| [
{
"answer_id": 283785,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "var x = new Whatever { PropertyA=true, PropertyB=\"Inactive\" };\n"
},
{
"answer_id": 283820,
"author": "Ste... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20/"
] |
283,751 | <p>I have the problem, that PHP replaces all spaces with underscores in POST and GET variables.</p>
<p>For example if I have the URL: <code>http://localhost/proxy.php?user name=Max</code>
the browser will convert it to <code>http://localhost/proxy.php?user%20name=Max</code>.</p>
<p>But if I give the $_GET parameters out, the key is not <code>user name</code> but <code>user_name</code> (note the underscore)!</p>
<p>Is there any possibility to change this behaviour?</p>
| [
{
"answer_id": 283781,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 6,
"selected": true,
"text": "<?php $varname.ext; /* invalid variable name */ ?>\n"
},
{
"answer_id": 689574,
"author": "Rudi",
"author_id"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30724/"
] |
283,752 | <p>I'm automating a web application (the Mantis bug tracker) and I'm getting an interesting response header from it, called Refresh:</p>
<pre><code>HTTP/1.x 200 OK
...
Refresh: 0;url=my_view_page.php
</code></pre>
<p>It seems to be acting the same way that <a href="http://en.wikipedia.org/wiki/Meta_refresh" rel="noreferrer">meta refresh</a> does, and the meta refresh technique implies that it is an equivalent of a header in HTTP.</p>
<p>Problem is, I can't find any mention of the Refresh header in the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html" rel="noreferrer">HTTP standard</a> or any other definitive documentation on how it should be parsed and what the browser should do when it encounters it.</p>
<p>What's going on here?</p>
| [
{
"answer_id": 283776,
"author": "Loki",
"author_id": 17324,
"author_profile": "https://Stackoverflow.com/users/17324",
"pm_score": 5,
"selected": false,
"text": "<meta http-equiv=\"refresh\" url=\"...\"/>"
},
{
"answer_id": 59167331,
"author": "Mike",
"author_id": 920404... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15109/"
] |
283,759 | <p>I'm converting my applications to Delphi 2009 and faced an intriguing issue with some calls that need to convert a string (wide) to AnsiString.</p>
<p>Here's an example to demonstrate the issue I'm having:</p>
<pre><code>var
s: PAnsiChar;
...
s := PAnsiChar(Application.ExeName);
</code></pre>
<p>With Delphi 2007 and previous versions, s := PChar(Application.ExeName) would return the application exe path.</p>
<p>with Delphi 2009, s := PAnsiChar(Application.ExeName) returns only 'E'.</p>
<p>My guess is that's because I'm converting a unicode string to an ansi string but how can I convert it so that a PAnsiChar gets the full string?</p>
| [
{
"answer_id": 283773,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 6,
"selected": true,
"text": "s := PAnsiChar(AnsiString(Application.ExeName));\n"
},
{
"answer_id": 283885,
"author": "smartins",
"a... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36544/"
] |
283,763 | <p>I am reading a .csv file and returning its lines in string array. One of the members is manufacturer, for which I have Toyota, Ford, etc.</p>
<p>I want to sort an array (Can be another collection) of the rows, by the value in manufacturer and alphabetical order.</p>
<p>So I'd have:</p>
<pre><code>28437 Ford Fiesta
328 Honda Civic
34949 Toyota Yaris
</code></pre>
<p>and so forth...</p>
<p>What would be the best way to do this using C# and no database? I say no database because I could insert the csv into a table in a sql server database, and then query it and return the data. But this data is going into a html table built on the fly, which would make the database approach a little long winded.</p>
| [
{
"answer_id": 283771,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "var cars = lines.Select(line => Car.ParseLine(line))\n .OrderBy(car => car.Manufacturer);\n"
},
{
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] |
283,764 | <p>In a SQL Server database, I record people's date of birth. Is there an straight-forward method of working out the person's age on a given date using SQL only? </p>
<p>Using <strong>DATEDIFF(YEAR, DateOfBirth, GETDATE())</strong> does not work as this only looks at the year part of the date. For example <strong>DATEDIFF(YEAR, '31 December 2007', '01 January 2008')</strong> returns 1.</p>
| [
{
"answer_id": 283780,
"author": "scable",
"author_id": 8942,
"author_profile": "https://Stackoverflow.com/users/8942",
"pm_score": 6,
"selected": true,
"text": "DECLARE @BirthDate DATETIME\nDECLARE @CurrentDate DATETIME\n\nSELECT @CurrentDate = '20070210', @BirthDate = '19790519'\n\nSEL... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7585/"
] |
283,766 | <p>I have an application that imports data from a pickled file. It works just fine in Windows but Mac and Linux behaviour is odd.</p>
<p>In OS X, the pickled file (file extension ".char") is unavailable as a selection unless I set the file type to *.*. Then, if I select a file that has the .char extension, it won't load, giving the error</p>
<blockquote>
<pre><code>unpickle_file = cPickle.load(char_file)
</code></pre>
<p>ValueError: could not convert string to float</p>
</blockquote>
<p>However, if I create a file that doesn't have the .char extension, that file will load up just fine.</p>
<p>In Linux, when I use the "file open" dialog, my pickled files aren't visible, whether or not they have a file extension. However, I can see them under Nautilus or Dolphin. They simply don't exist to my application though.</p>
<hr>
<p><strong>Edit</strong> Here's the save code:</p>
<pre><code>def createSaveFile(self):
"""Create the data files to be saved and save them.
Creates a tuple comprised of a dictionary of general character information
and the character's skills dictionary."""
if self.file_name:
self.save_data = ({'Name':self.charAttribs.name,
<snip>
self.charAttribs.char_skills_dict)
self.file = open(self.file_name, 'w')
cPickle.dump(self.save_data, self.file)
self.file.close()
</code></pre>
<p>Here's the open code:</p>
<pre><code> def getCharFile(self, event): # wxGlade: CharSheet.<event_handler>
"""Retrieve pickled character file from disk."""
wildcard = "Character files (*.char) | *.char | All files (*.*) | *.*"
openDialog = wx.FileDialog(None, "Choose a character file", os.getcwd(),
"", wildcard, wx.OPEN | wx.CHANGE_DIR)
if openDialog.ShowModal() == wx.ID_OK:
self.path = openDialog.GetPath()
try:
char_file = open(self.path, "r")
unpickle_file = cPickle.load(char_file)
char_data, char_skills = unpickle_file
self.displayCharacter(char_data, char_skills)
except IOError:
self.importError = wx.MessageDialog(self,
"The character file is not available!",
"Character Import Error", wx.OK | wx.ICON_ERROR)
self.importError.ShowModal()
self.importError.Destroy()
openDialog.Destroy()
</code></pre>
| [
{
"answer_id": 283802,
"author": "Adam Byrtek",
"author_id": 36656,
"author_profile": "https://Stackoverflow.com/users/36656",
"pm_score": 4,
"selected": true,
"text": "char_file = open('pickle.char', 'rb')\n"
},
{
"answer_id": 283854,
"author": "Brian",
"author_id": 9493... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18676/"
] |
283,812 | <p>With reference to <a href="https://stackoverflow.com/questions/280597/problem-with-date-daymonth-reversing-on-save">Problem with date day/month reversing on save</a></p>
<p>I have further noted that even setting the Session.LCID on the page itself is making no difference what so ever.</p>
<p>How could the environments be such that between test and live the asp site on live is reversing dates entered via SQL but not on test.</p>
<p>Both have the IUSR set to UK, both have all users set to UK, both have the SQL Account set to US English and both have Session.LCID set to 3081 (Australian English)</p>
<p>Why is test running " insert into datecolumn values '01/03/2008' and inserting '01/03/2008' and live is inserting '03/01/2008' "</p>
<p>The setups look totally identical. This must be figured out soon i'm getting quite scared that we'll never know. The problem is we may not change code or anything else. All I can do is investigate and tell them the cause. But I can't find it!</p>
<p>It's VB6/ASP and it's driving me do lally.</p>
<p>Access to the database is via a System DSN configured to use the correct SQL account.</p>
<p>What other info might you need.</p>
| [
{
"answer_id": 284028,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 2,
"selected": true,
"text": "sp_configure 'default language'"
},
{
"answer_id": 284554,
"author": "George Mastros",
"author_id": 140812... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27412/"
] |
283,816 | <p>I'm working now together with others in a grails project. I have to write some Java-classes. But I need access to an searchable object created with groovy. It seems, that this object has to be placed in the default-package. </p>
<p>My question is: <strong>Is there a way to access this object in the default-package from a Java-class in a named package?</strong></p>
| [
{
"answer_id": 283828,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 8,
"selected": true,
"text": "import Unfinished;\n"
},
{
"answer_id": 284047,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile":... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21005/"
] |
283,821 | <p>Does anyone know if there is an implementation of <code>javax.jms.QueueConnectionFactory</code> for WebSphere MQ and where to get it? I Googled it and searched IBM website but couldn't find anything. I don't want to retrieve the connection or factory from Websphere MQ via JNDI, I need my own connection factory.</p>
| [
{
"answer_id": 283839,
"author": "Stroboskop",
"author_id": 23428,
"author_profile": "https://Stackoverflow.com/users/23428",
"pm_score": 4,
"selected": true,
"text": "com.ibm.mq.jar\ncom.ibm.mqbind.jar\ncom.ibm.mqjms.jar\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4688/"
] |
283,824 | <p>I can't figure out why the following wont work, any ideas??
public interface IFieldSimpleItem
{ }</p>
<pre><code>public interface IFieldNormalItem : IFieldSimpleItem
{ }
public class Person
{
public virtual T Create<T>()
where T : IFieldSimpleItem
{
return default(T);
}
}
public class Bose : Person
{
public override T Create<T>()
where T : IFieldNormalItem //This is where the error is
{
return default(T);
}
}
</code></pre>
<p>The reason why I am doing this is due to the fact that if a developer inherits from Bose, Bose relies on the instance being creating being at least of IFieldNormalItem. Whereas the below only relies on it being IFieldSimpleItem but the above should force it to be at least IFieldNormalItem.</p>
<pre><code>public class Person
{
public virtual IFieldSimpleItem Create()
{
return null;
}
}
public class Bose : Person
{
public override IFieldSimpleItem Create()
{
return null;
}
}
</code></pre>
<p>Cheers
Anthony</p>
| [
{
"answer_id": 283837,
"author": "Grzenio",
"author_id": 5363,
"author_profile": "https://Stackoverflow.com/users/5363",
"pm_score": 1,
"selected": false,
"text": "public class Bose : Person\n{\n public virtual T CreateNormal<T>()\n where T : IFieldNormalItem //This is where th... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30572/"
] |
283,835 | <p>I am trying to establish a basic .NET Remoting communication between 2x 64bit windows machines. If Machine1 is acting as client and Machine2 as server, then everything works fine. The other way around the following exception occurs:</p>
<p>System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 172.16.7.44:6666</p>
<p>The server code:</p>
<pre><code>TcpChannel channel = new TcpChannel(6666);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(MyRemotableObject),"HelloWorld",WellKnownObjectMode.Singleton);
</code></pre>
<p>The client code:</p>
<pre><code>TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
// Create an instance of the remote object
remoteObject = (MyRemotableObject)Activator.GetObject(
typeof(MyRemotableObject), "tcp://172.16.7.44:6666/HelloWorld");
</code></pre>
<p>Any idea whats wrong with my code?</p>
| [
{
"answer_id": 283843,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": false,
"text": "netstat -an"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35061/"
] |
283,858 | <p>I have an XML input file and I'm trying to output the result of a call like: </p>
<pre><code><xsl:value-of select="Some/Value"/>
</code></pre>
<p>into an attribute. </p>
<pre><code><Output Attribute="Value should be put here"/>
</code></pre>
<p>My problem is, since I'm outputting XML, the XSL processor won't allow me to write: </p>
<pre><code><Output Attribute="<xsl:value-of select="Some/Value"/>">
</code></pre>
<p>How do you accomplish this?</p>
| [
{
"answer_id": 283868,
"author": "Phil Ross",
"author_id": 5981,
"author_profile": "https://Stackoverflow.com/users/5981",
"pm_score": 5,
"selected": false,
"text": "<Output>\n <xsl:attribute name=\"Attribute\">\n <xsl:value-of select=\"Some/Value\"/>\n </xsl:attribute>\n</Output>\n... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143/"
] |
283,869 | <p>I'm trying to add a new node to an jQuery <a href="http://news.kg/wp-content/uploads/tree/" rel="nofollow noreferrer">SimpleTree</a>, but all I seem to be able to get is "sTC.addNode is not a function"... </p>
<pre><code>var simpleTreeCollection = $('.simpleTree').simpleTree({
animate:true,
drag:false,
autoclose: false,
afterClick:function(node){},
afterDblClick:function(node){},
beforeMove:function (destination, source, pos){},
afterMove:function(destination, source, pos){},
afterAjax:function() {},
afterContextMenu:function(node){}
});
simpleTreeCollection.addNode('test', 'test');
</code></pre>
<p>Any suggestions what I might be doing wrong? Is there even the possibility to add a node?</p>
| [
{
"answer_id": 283914,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 1,
"selected": false,
"text": " //Select first child node in tree\n $('#2').click();\n //Add new node to selected node\n simpleTreeCollection... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/999/"
] |
283,888 | <p>what's the best/proper way of interacting between several windows in C# app?
Recently, I've run into a problem where one of program windows has to call method modifying main window. My solution was to create factory-like class, that would arrange all underlying model-data and organize the communication between various windows (through delegates). However, as passing one or two delegates was not a problem, I started thinking what if my other windows would need 10 delegates to interact properly with main window? Are delegates good solution? How to pass them in good way - through constructor, properties? Or maybe the need of using that many delegates is some serious design flaw itself?</p>
| [
{
"answer_id": 283933,
"author": "Sekhat",
"author_id": 1610,
"author_profile": "https://Stackoverflow.com/users/1610",
"pm_score": 0,
"selected": false,
"text": "public class MainForm : Form\n{\n}\n\npublic class OtherForm : Form\n{\n protected MainForm MainForm { get; set; }\n\n ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36890/"
] |
283,891 | <p>How can I access the WCF Service through JavaScript?
My problem is, I have to access the operation contracts through the JavaScript (my website is not Ajax enabled).<br>
Previously for calling .asmx web services,
I am using the following code snippet</p>
<pre><code>var xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttp.open("POST", URL, false);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send(payload);
xmlData = xmlHttp.responseXML;
</code></pre>
<p>where url is my webservice location.</p>
<p>Now if I am trying to consume the wcf service in the same manner, I am not able to.
Many techies are explaining through AJAX approach,
I need an approach without AJAX.</p>
| [
{
"answer_id": 284409,
"author": "user32415",
"author_id": 32415,
"author_profile": "https://Stackoverflow.com/users/32415",
"pm_score": 0,
"selected": false,
"text": "[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,893 | <p>To support multiple platforms in C/C++, one would use the preprocessor to enable conditional compiles. E.g.,</p>
<pre><code>#ifdef _WIN32
#include <windows.h>
#endif
</code></pre>
<p>How can you do this in Ada? Does Ada have a preprocessor?</p>
| [
{
"answer_id": 8264429,
"author": "Rego",
"author_id": 1005540,
"author_profile": "https://Stackoverflow.com/users/1005540",
"pm_score": 2,
"selected": false,
"text": "gnatprep"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14069/"
] |
283,894 | <p>Have you ever tried this feedback calling an external zip.py script to work? My CGITB does not show any error messages. It simply did not invoke external .py script to work. It simply skipped over to gush. I should be grateful if you can assist me in making this zip.py callable in feedback.py. </p>
<p>Regards. David </p>
<pre><code>#**********************************************************************
# Description:
# Zips the contents of a folder.
# Parameters:
# 0 - Input folder.
# 1 - Output zip file. It is assumed that the user added the .zip
# extension.
#**********************************************************************
# Import modules and create the geoprocessor
#
import sys, zipfile, arcgisscripting, os, traceback
gp = arcgisscripting.create()
# Function for zipping files. If keep is true, the folder, along with
# all its contents, will be written to the zip file. If false, only
# the contents of the input folder will be written to the zip file -
# the input folder name will not appear in the zip file.
#
def zipws(path, zip, keep):
path = os.path.normpath(path)
# os.walk visits every subdirectory, returning a 3-tuple
# of directory name, subdirectories in it, and filenames
# in it.
#
for (dirpath, dirnames, filenames) in os.walk(path):
# Iterate over every filename
#
for file in filenames:
# Ignore .lock files
#
if not file.endswith('.lock'):
gp.AddMessage("Adding %s..." % os.path.join(path, dirpath, file))
try:
if keep:
zip.write(os.path.join(dirpath, file),
os.path.join(os.path.basename(path),
os.path.join(dirpath, file)[len(path)+len(os.sep):]))
else:
zip.write(os.path.join(dirpath, file),
os.path.join(dirpath[len(path):], file))
except Exception, e:
gp.AddWarning(" Error adding %s: %s" % (file, e))
return None
if __name__ == '__main__':
try:
# Get the tool parameter values
#
infolder = gp.GetParameterAsText(0)
outfile = gp.GetParameterAsText(1)
# Create the zip file for writing compressed data. In some rare
# instances, the ZIP_DEFLATED constant may be unavailable and
# the ZIP_STORED constant is used instead. When ZIP_STORED is
# used, the zip file does not contain compressed data, resulting
# in large zip files.
#
try:
zip = zipfile.ZipFile(outfile, 'w', zipfile.ZIP_DEFLATED)
zipws(infolder, zip, True)
zip.close()
except RuntimeError:
# Delete zip file if exists
#
if os.path.exists(outfile):
os.unlink(outfile)
zip = zipfile.ZipFile(outfile, 'w', zipfile.ZIP_STORED)
zipws(infolder, zip, True)
zip.close()
gp.AddWarning(" Unable to compress zip file contents.")
gp.AddMessage("Zip file created successfully")
except:
# Return any python specific errors as well as any errors from the geoprocessor
#
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo +
"\nError Info:\n " + str(sys.exc_type) +
": " + str(sys.exc_value) + "\n"
gp.AddError(pymsg)
msgs = "GP ERRORS:\n" + gp.GetMessages(2) + "\n"
gp.AddError(msgs)
</code></pre>
| [
{
"answer_id": 284199,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 1,
"selected": false,
"text": "zip()"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36900/"
] |
283,925 | <p>Ok so I have an abstract base class called Product, a KitItem class that inherits Product and a PackageKitItem class that inherits KitItem. ie.</p>
<pre><code>Product
KitItem : Product
PackageKitItem : KitItem
</code></pre>
<p>I have my KitItems loaded and I need to load up a collection of PackageKitItems which are, effectively, shallow copies of KitItems.</p>
<p>Currently we are doing what feels to me a hacky shallow copy in the Product constructor like so:</p>
<pre><code>public Product(Product product)
{
FieldInfo[] fields = product.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
// copy each value over to 'this'
foreach (FieldInfo fi in fields)
fi.SetValue(this, fi.GetValue(product));
}
</code></pre>
<p>I've tried setting up a copy on KitItem like so:</p>
<pre><code>public KitItem ShallowCopy()
{
return (KitItem)this.MemberwiseClone();
}
</code></pre>
<p>and calling it thus:</p>
<pre><code>PackageKitItem tempPackKitItem = (PackageKitItem)packKitItem.ShallowCopy();
</code></pre>
<p>but I get an invalid cast. I'm looking for ideas for the best way to accomplish this.</p>
| [
{
"answer_id": 284021,
"author": "Leonardo Herrera",
"author_id": 7841,
"author_profile": "https://Stackoverflow.com/users/7841",
"pm_score": 0,
"selected": false,
"text": "PackageKitItem tempPackKitItem = new tempPackKitItem(kitItem);\n"
},
{
"answer_id": 284034,
"author": "... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12862/"
] |
283,931 | <p>Could somebody please explain to me what happens here?<br>
I am creating a binding in code. </p>
<p>The target object is a UserControl<br>
The target property is a boolean DependencyProperty<br>
The source object is a FrameworkElement and implements INotifyPropertyChanged<br>
The source property is of type ObservableCollection </p>
<p>What happens:</p>
<ul>
<li><p>The binding is created in code, the result BindingExpressionBase looks fine, the mode is OneWay, the target value gets set correctly (at this time)</p>
<p>Binding b = new Binding();<br>
b.Path = "SourceProperty";<br>
b.Source = SourceObject;<br>
BindingExpressionBase e = this.SetBinding(TargetProperty, b); </p></li>
<li><p>The source property then gets changed as a result of another databinding. The UserControl tries to fire the PropertyChanged event.</p></li>
<li><p>....but nobody is listening. PropertyChanged is null.</p></li>
</ul>
<p>I am sure that nothing else is assigned to the target property, so it should still be bound. Why is the binding not listening for the PropertyChanged event?</p>
| [
{
"answer_id": 284303,
"author": "jarda",
"author_id": 6601,
"author_profile": "https://Stackoverflow.com/users/6601",
"pm_score": 3,
"selected": true,
"text": "if (PropertyChanged != null) \n{ \n PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); \n} \n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/283931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6601/"
] |
283,942 | <p>I have a TObjectList with OwnsObjects = true. It contains quite a few objects. Now I want to remove the object at index Idx from that list, without freeing it.</p>
<p>Is the Extract method the only option?</p>
<p><code>ExtractedObject := TheList.Extract(TheList[Idx]);</code></p>
<p>All other methods seem to free the object. I am looking for something a little bit more efficient, that does not do a linear search every time, since I already know the index of the object. Something like an overloaded ...</p>
<p><code>ExtractedObject := TheList.Extract(Idx);</code></p>
<p>... which does not exist.</p>
| [
{
"answer_id": 284162,
"author": "Steve",
"author_id": 22712,
"author_profile": "https://Stackoverflow.com/users/22712",
"pm_score": 1,
"selected": false,
"text": " TMyObjectList = Class(TObjectList)\n private\n fNotify: Boolean;\n { Private declarations }\n procedure EnableNo... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21506/"
] |
283,943 | <p>I have a list of strings displayed by a Silverlight ItemsControl. The DataTemplate is a Border control with a TextBlock as its child. How can I access the border control corresponding to an item? For example, I might want to do this to change the background color.</p>
| [
{
"answer_id": 285017,
"author": "Bryant",
"author_id": 10893,
"author_profile": "https://Stackoverflow.com/users/10893",
"pm_score": 2,
"selected": false,
"text": "<Grid>\n <ItemsControl x:Name=\"items\">\n <ItemsControl.ItemTemplate>\n <DataTemplate>\n ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
283,950 | <p>When looking at C# code, I often see patterns like this:</p>
<pre><code>DataType[] items = GetSomeItems();
OtherDataType[] itemProps = new OtherDataType[items.Length];
int i = 0;
foreach (DataType item in items)
{
// Do some stuff with item, then finally
itemProps[i] = item.Prop;
i++;
}
</code></pre>
<p>The for-loop iterates over the objects in <code>items</code>, but also keeping a counter (<code>i</code>) for iterating over <code>itemProps</code> as well. I personally don't like this extra <code>i</code> hanging around, and instead would probably do something like:</p>
<pre><code>DataType[] items = GetSomeItems();
OtherDataType[] itemProps = new OtherDataType[items.Length];
for (int i = 0; i < items.Length; i++)
{
// Do some stuff with items[i], then finally
itemProps[i] = items[i].Prop;
}
</code></pre>
<p>Is there perhaps some benfit to the first approach I'm not aware of? Is this a result of everybody trying to use that fancy <code>foreach (...)</code> syntax? I'm interested in your opinions on this.</p>
| [
{
"answer_id": 283966,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "this[int index]"
},
{
"answer_id": 283971,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profil... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2576/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.