qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
204,095
<p>I would like to create (in code) tree of controls that would render as a table with several TBODY tags, i.e.:</p> <p> </p> <pre><code>&lt;TBODY&gt; &lt;TR&gt; &lt;TD&gt;&lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt; &lt;TD&gt;&l...
[ { "answer_id": 204103, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 3, "selected": true, "text": "<p>How are you generating your data? You could use a templated control like a Repeater or ListView as that gives you f...
2008/10/15
[ "https://Stackoverflow.com/questions/204095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28154/" ]
I would like to create (in code) tree of controls that would render as a table with several TBODY tags, i.e.: ``` <TBODY> <TR> <TD></TD> </TR> <TR> <TD></TD> </TR> </TBODY> ``` I tried both Table and HtmlTable controls but had no success. Any clues?
How are you generating your data? You could use a templated control like a Repeater or ListView as that gives you full control of the HTML you're generating. If you're wanting to create the controls purely in C# you can use the HtmlGenericControl (<http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htm...
204,115
<p>So there seems to be this problem with GNU Make's $(wildcard) function keeping a directory open on Windows. See (unasnwered) post "<a href="http://www.cygwin.com/ml/cygwin/2003-06/msg01182.html" rel="nofollow noreferrer">make is holding a directory open</a>". Google does not provide much information on the topic.</p...
[ { "answer_id": 220331, "author": "Charles Duffy", "author_id": 14122, "author_profile": "https://Stackoverflow.com/users/14122", "pm_score": 2, "selected": false, "text": "<p>Sounds like a file descriptor leak, all right -- harmless for very-short-lived processes (like make) on UNIX, but...
2008/10/15
[ "https://Stackoverflow.com/questions/204115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2095/" ]
So there seems to be this problem with GNU Make's $(wildcard) function keeping a directory open on Windows. See (unasnwered) post "[make is holding a directory open](http://www.cygwin.com/ml/cygwin/2003-06/msg01182.html)". Google does not provide much information on the topic. In short: the Makefile uses the $(wildcar...
I did find a **workaround** for the problem, which at least lets me work in peace. The problem was that the `$(wildcard)` function was used to collect the sources files. My clean rule, however, only deletes a directory - no need for the collecting to take please. So I basically put the part of the Makefile that needs ...
204,123
<p>I am cloning a hidden table row then populating it and after validation I want to show the row using a jquery effect ... say .show("slow")</p> <pre><code>var baseRow = $("#tasks tr#baseTaskLine"); var newRow = baseRow.clone(); var lastRow = $("#tasks tr[id^='TaskLine_']" + dayClass + ":last"); var newRowId; if (la...
[ { "answer_id": 204142, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 4, "selected": true, "text": "<p>This is not going to work this way. Table rows and cells are not meant to be displayed as blocks so the show/fade ef...
2008/10/15
[ "https://Stackoverflow.com/questions/204123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18349/" ]
I am cloning a hidden table row then populating it and after validation I want to show the row using a jquery effect ... say .show("slow") ``` var baseRow = $("#tasks tr#baseTaskLine"); var newRow = baseRow.clone(); var lastRow = $("#tasks tr[id^='TaskLine_']" + dayClass + ":last"); var newRowId; if (lastRow.length =...
This is not going to work this way. Table rows and cells are not meant to be displayed as blocks so the show/fade effects are not going to work on table rows directly. You could, however, put a <div> in each of the cells, something like this: ``` <table> <tr id="row1"><td><div>Cell1:1</div></td><td><div>Cell2:1</div>...
204,128
<p>I am new to Hudson, perhaps someone knows the solution: I am trying to checkout the parent pom from the VSS in Hudson (vss plugin installed) and now I get class cast exception:</p> <pre><code>FATAL: hudson.maven.MavenModuleSetBuild cannot be cast to hudson.model.Build java.lang.ClassCastException: hudson.maven.Mav...
[ { "answer_id": 222199, "author": "PEELY", "author_id": 17641, "author_profile": "https://Stackoverflow.com/users/17641", "pm_score": 0, "selected": false, "text": "<p>Looks like it's a bug in that version of Hudson. Have you tried a slightly older or newer version? IIRC they provide very...
2008/10/15
[ "https://Stackoverflow.com/questions/204128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15045/" ]
I am new to Hudson, perhaps someone knows the solution: I am trying to checkout the parent pom from the VSS in Hudson (vss plugin installed) and now I get class cast exception: ``` FATAL: hudson.maven.MavenModuleSetBuild cannot be cast to hudson.model.Build java.lang.ClassCastException: hudson.maven.MavenModuleSetBui...
Looks like Shashi filed this as Hudson issue [2665](http://issues.hudson-ci.org/browse/HUDSON-2665) which remains open.
204,140
<p>How can I move items from one list box control to another listbox control using JavaScript in ASP.NET?</p>
[ { "answer_id": 204161, "author": "Remy Sharp", "author_id": 22617, "author_profile": "https://Stackoverflow.com/users/22617", "pm_score": 5, "selected": false, "text": "<p>If you're happy to use jQuery, it's very, very simple.</p>\n\n<pre><code>$('#firstSelect option:selected').appendTo(...
2008/10/15
[ "https://Stackoverflow.com/questions/204140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
How can I move items from one list box control to another listbox control using JavaScript in ASP.NET?
This code assumes that you have an anchor or that will trigger to movement when it is clicked: ``` document.getElementById('moveTrigger').onclick = function() { var listTwo = document.getElementById('secondList'); var options = document.getElementById('firstList').getElementsByTagName('option'); while(op...
204,164
<p>I have a problem with a Delphi 2009 project : It can't initialize Indy 10 ! This code worked fine before in Delphi 2007 (although we might have been using an older revision of Indy, but I suspect that has not much to do with it);</p> <p>The initial call to IdWinsock2.InitializeWinSock(), raises this exception (with...
[ { "answer_id": 207060, "author": "Argalatyr", "author_id": 18484, "author_profile": "https://Stackoverflow.com/users/18484", "pm_score": 0, "selected": false, "text": "<p>This may be overly simplistic, but have you tried changing the order in which the relevant units are listed in your u...
2008/10/15
[ "https://Stackoverflow.com/questions/204164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12170/" ]
I have a problem with a Delphi 2009 project : It can't initialize Indy 10 ! This code worked fine before in Delphi 2007 (although we might have been using an older revision of Indy, but I suspect that has not much to do with it); The initial call to IdWinsock2.InitializeWinSock(), raises this exception (with error cod...
I finally found an answer to this : The affected applications contained a bit of code-hooking that randomly damaged parts of System.dcu! (FYI : We're using a Delphi 2009 beta version of madshi's madCodeHook library). As soon as we switched to another code-hooking library, these symptoms disapeared... I guess that's wha...
204,169
<p>I have a very simple question. I want to test whether a particular port is currently under use or not. For this, I want to bind a TCP socket to the port, if the connection is refused means the port is in use and if not that mean the port is free.</p> <p>Can someone please tell me how can I write the TCP socket code...
[ { "answer_id": 204219, "author": "Anonymous", "author_id": 15073, "author_profile": "https://Stackoverflow.com/users/15073", "pm_score": -1, "selected": false, "text": "<p>You might want to look at the source code of netstat. I believe there is a netstat in Solaris as well.</p>\n" }, ...
2008/10/15
[ "https://Stackoverflow.com/questions/204169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27778/" ]
I have a very simple question. I want to test whether a particular port is currently under use or not. For this, I want to bind a TCP socket to the port, if the connection is refused means the port is in use and if not that mean the port is free. Can someone please tell me how can I write the TCP socket code in C? I a...
The call to bind function will return -1 if there is an error. This includes the case where the address is already in use. ``` #include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #define PORT 12345 int main() { struct sockaddr_in addr; int fd; fd = socket(AF_INET, SOCK_STREAM, 0); if(fd == -1...
204,170
<p>So I need to update a text field. Neither the UPDATE statement or the WRITETEXT statement work when used below</p> <pre><code>CREATE TABLE MyTable (IDField int, MyField text) INSERT INTO MyTable (IDField) SELECT 1 DECLARE @Data1 varchar(8000), @Data2 varchar(8000), @ptrval binary(16) SELECT @Data1 = REPLICATE('1...
[ { "answer_id": 204255, "author": "Jim Birchall", "author_id": 989, "author_profile": "https://Stackoverflow.com/users/989", "pm_score": 4, "selected": true, "text": "<p>Try using UPDATETEXT instead</p>\n\n<pre><code>WRITETEXT MyTable.MyField @ptrval @Data1 \nUPDATETEXT MyTable.MyField @p...
2008/10/15
[ "https://Stackoverflow.com/questions/204170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10422/" ]
So I need to update a text field. Neither the UPDATE statement or the WRITETEXT statement work when used below ``` CREATE TABLE MyTable (IDField int, MyField text) INSERT INTO MyTable (IDField) SELECT 1 DECLARE @Data1 varchar(8000), @Data2 varchar(8000), @ptrval binary(16) SELECT @Data1 = REPLICATE('1',8000) SELECT ...
Try using UPDATETEXT instead ``` WRITETEXT MyTable.MyField @ptrval @Data1 UPDATETEXT MyTable.MyField @ptrval 8000 NULL @Data2 ``` The insert offset is zero based so 8000 should write into the 8001st character. The delete offset is null as a value of NULL deletes all data from the insert\_offset position to the end ...
204,172
<p>How can I turn off certificate revocation for a WCF service's client? The client proxy was generated by wsdl.exe and inherits SoapHttpClientProtocol.</p>
[ { "answer_id": 204209, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 4, "selected": true, "text": "<p>I think you're looking for <code>ServicePointManager.ServerCertificateValidationCallback</code>:</p>\n<blockquote>\n<p><a href=\...
2008/10/15
[ "https://Stackoverflow.com/questions/204172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19956/" ]
How can I turn off certificate revocation for a WCF service's client? The client proxy was generated by wsdl.exe and inherits SoapHttpClientProtocol.
I think you're looking for `ServicePointManager.ServerCertificateValidationCallback`: > > <http://msdn.microsoft.com/en-gb/library/system.net.servicepointmanager.servercertificatevalidationcallback.aspx> > > > Which takes a `RemoteCertificateValidationCallback` Delegate: > > <http://msdn.microsoft.com/en-gb/lib...
204,186
<p>In writing some test code I have found that Selector.select() can return without Selector.selectedKeys() containing any keys to process. This is happening in a tight loop when I register an accept()ed channel with</p> <pre>SelectionKey.OP_READ | SelectionKey.OP_CONNECT</pre> <p>as the operations of interest.</p> ...
[ { "answer_id": 205354, "author": "Alexander", "author_id": 16724, "author_profile": "https://Stackoverflow.com/users/16724", "pm_score": 4, "selected": true, "text": "<p>Short answer: remove <code>OP_CONNECT</code> from the list of operations you are interested in for the accepted connec...
2008/10/15
[ "https://Stackoverflow.com/questions/204186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28164/" ]
In writing some test code I have found that Selector.select() can return without Selector.selectedKeys() containing any keys to process. This is happening in a tight loop when I register an accept()ed channel with ``` SelectionKey.OP_READ | SelectionKey.OP_CONNECT ``` as the operations of interest. According to the ...
Short answer: remove `OP_CONNECT` from the list of operations you are interested in for the accepted connection -- an accepted connection is already connected. I managed to reproduce the issue, which might be exactly what's happening to you: ``` import java.net.*; import java.nio.channels.*; public class MyNioServer...
204,208
<p>I want to detect and replace malformed UTF-8 characters with blank space using a Perl script while loading the data using SQL*Loader. How can I do this? </p>
[ { "answer_id": 204223, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>EDIT: (Removed bit about SQL Loader as it seems to no longer be relevant.)</p>\n\n<p>One problem is going to be worki...
2008/10/15
[ "https://Stackoverflow.com/questions/204208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to detect and replace malformed UTF-8 characters with blank space using a Perl script while loading the data using SQL\*Loader. How can I do this?
Consider Python. It allows to extend codecs with user-defined error handlers, so you can replace undecodable bytes with anything you want. ``` import codecs codecs.register_error('spacer', lambda ex: (u' ', ex.start + 1)) s = 'spam\xb0\xc0eggs\xd0bacon'.decode('utf8', 'spacer') print s.encode('utf8') ``` This prints...
204,226
<p>I am connecting to CRM with the intention of retrieving a list of picklist values. On my development machine I am working under my own login name and all works fine. On the test server, the code executes under the NETWORK SERVICE account. When it connects to the CRM web service everything is great. When it connects ...
[ { "answer_id": 215513, "author": "Rihan Meij", "author_id": 29287, "author_profile": "https://Stackoverflow.com/users/29287", "pm_score": 2, "selected": true, "text": "<p>I suspect it might be a Kerberos / delegation issue, to make sure it is try replacing DefaultCredentials with\nnew Sy...
2008/10/15
[ "https://Stackoverflow.com/questions/204226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21862/" ]
I am connecting to CRM with the intention of retrieving a list of picklist values. On my development machine I am working under my own login name and all works fine. On the test server, the code executes under the NETWORK SERVICE account. When it connects to the CRM web service everything is great. When it connects to ...
I suspect it might be a Kerberos / delegation issue, to make sure it is try replacing DefaultCredentials with new System.Security.Net.NetworkCredentials("username","password","domain"); See if that still gives you a 401. This is the quick way I normally try to see if it is kerbos/security related. I need a bit more...
204,303
<p>I'm starting to investigate T4 for Code Generation.</p> <p>I get that you have a basic template in which you can embed little chunks of c#/vb which can perform clever stuff...</p> <pre><code>&lt;#@ template language="VB" debug="True" hostspecific="True" #&gt; &lt;#@ output extension=".vb" debug="True" hostspecific...
[ { "answer_id": 204367, "author": "Enrico Campidoglio", "author_id": 26396, "author_profile": "https://Stackoverflow.com/users/26396", "pm_score": 2, "selected": true, "text": "<p>It seems that you can mix static output with template code in Class Blocks. Here is an example with C#:</p>\n...
2008/10/15
[ "https://Stackoverflow.com/questions/204303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11356/" ]
I'm starting to investigate T4 for Code Generation. I get that you have a basic template in which you can embed little chunks of c#/vb which can perform clever stuff... ``` <#@ template language="VB" debug="True" hostspecific="True" #> <#@ output extension=".vb" debug="True" hostspecific="True" #> Imports System <#Fo...
It seems that you can mix static output with template code in Class Blocks. Here is an example with C#: ``` <#@ template language="C#" #> <# HelloWorld(); #> <#+ private string _field = "classy"; private void HelloWorld() { for(int i = 1; i <= 3; i++) { #> Hello <#=_field#> World <#= i #>! ...
204,305
<p>I have an asp.net server control (with the asp: in its definition). The button has been set to do post back.</p> <p>On the server side, I have the on click event handler e.g btnSave_click()</p> <p>On the client side, I have a javascript function to be invoked on the click event e.g btnSave.Attributes.Add("onclick"...
[ { "answer_id": 204325, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 3, "selected": true, "text": "<p>First client side, second server-side.</p>\n\n<p>So you can use it.</p>\n\n<p>I also use it in some cases, like:</p>\n\n<pre><c...
2008/10/15
[ "https://Stackoverflow.com/questions/204305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13370/" ]
I have an asp.net server control (with the asp: in its definition). The button has been set to do post back. On the server side, I have the on click event handler e.g btnSave\_click() On the client side, I have a javascript function to be invoked on the click event e.g btnSave.Attributes.Add("onclick","javascript: re...
First client side, second server-side. So you can use it. I also use it in some cases, like: ``` close.Attributes["OnClick"] = "return confirm('Are you sure?')"; ``` In this case if the user presses 'No' then the server-side event handler does not even play a role.
204,308
<p>I regularly want to check if an object has a member or not. An example is the creation of a singleton in a function. For that purpose, you can use <code>hasattr</code> like this:</p> <pre><code>class Foo(object): @classmethod def singleton(self): if not hasattr(self, 'instance'): self.in...
[ { "answer_id": 204318, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "<p>It depends on which case is \"typical\", because exceptions should model, well, atypical conditions. So, if the typical c...
2008/10/15
[ "https://Stackoverflow.com/questions/204308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7136/" ]
I regularly want to check if an object has a member or not. An example is the creation of a singleton in a function. For that purpose, you can use `hasattr` like this: ``` class Foo(object): @classmethod def singleton(self): if not hasattr(self, 'instance'): self.instance = Foo() re...
These are two different methodologies: №1 is LBYL (look before you leap) and №2 is EAFP (easier to ask forgiveness than permission). Pythonistas typically suggest that EAFP is better, with arguments in style of "what if a process creates the file between the time you test for it and the time you try to create it yours...
204,316
<p>According to this</p> <p><a href="http://perldoc.perl.org/UNIVERSAL.html" rel="noreferrer">http://perldoc.perl.org/UNIVERSAL.html</a></p> <p>I shouldn't use UNIVERSAL::isa() and should instead use $obj->isa() or CLASS->isa().</p> <p>This means that to find out if something is a reference in the first place and th...
[ { "answer_id": 204352, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "<p>To directly answer your question, the answer is at the bottom of the page you linked to, namely that if a package defines...
2008/10/15
[ "https://Stackoverflow.com/questions/204316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2386199/" ]
According to this <http://perldoc.perl.org/UNIVERSAL.html> I shouldn't use UNIVERSAL::isa() and should instead use $obj->isa() or CLASS->isa(). This means that to find out if something is a reference in the first place and then is reference to this class I have to do ``` eval { $poss->isa("Class") } ``` and check...
The primary problem is that if you call `UNIVERSAL::isa` directly, you are bypassing any classes that have overloaded `isa`. If those classes rely on the overloaded behavior (which they probably do or else they would not have overridden it), then this is a problem. If you invoke `isa` directly on your blessed object, t...
204,320
<p>Is there a way to declare a variable as Nullable in c#?</p> <pre><code>struct MyStruct { int _yer, _ner; public MyStruct() { _yer = Nullable&lt;int&gt;; //This does not work. _ner = 0; } } </code></pre>
[ { "answer_id": 204326, "author": "Joel Cunningham", "author_id": 5360, "author_profile": "https://Stackoverflow.com/users/5360", "pm_score": 1, "selected": false, "text": "<p>Try declaring your variable like this:</p>\n\n<pre><code>int? yer;\n</code></pre>\n" }, { "answer_id": 20...
2008/10/15
[ "https://Stackoverflow.com/questions/204320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
Is there a way to declare a variable as Nullable in c#? ``` struct MyStruct { int _yer, _ner; public MyStruct() { _yer = Nullable<int>; //This does not work. _ner = 0; } } ```
\_yer must be declare as int? or Nullable<int>. ``` int? _yer; int _ner; public MyStruct(int? ver, int ner) { _yer = ver; _ner = ner; } } ``` Or like this: ``` Nullable<int> _yer; int _ner; public MyStruct(Nullable<int> ver, int ner) { _yer = ver; _ner...
204,360
<p>What's the term for this design?</p> <pre><code>object.method1().method2().method3() </code></pre> <p>..when all methods return *this?</p> <p>I found the term for this a while ago, but lost it meanwhile. I have no clue how to search for this on google :) Also if anyone can think of a better title for the question...
[ { "answer_id": 204364, "author": "Joel Cunningham", "author_id": 5360, "author_profile": "https://Stackoverflow.com/users/5360", "pm_score": 4, "selected": true, "text": "<p>Looks to me like you are describing a fluent interface. Ive also heard it referred to as pipelineing or chaining.<...
2008/10/15
[ "https://Stackoverflow.com/questions/204360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21240/" ]
What's the term for this design? ``` object.method1().method2().method3() ``` ..when all methods return \*this? I found the term for this a while ago, but lost it meanwhile. I have no clue how to search for this on google :) Also if anyone can think of a better title for the question, feel free to change it. Thank...
Looks to me like you are describing a fluent interface. Ive also heard it referred to as pipelineing or chaining. Update-Gishu: <http://martinfowler.com/bliki/FluentInterface.html>
204,369
<p>Recently our company has started measuring the cyclomatic complexity (CC) of the functions in our code on a weekly basis, and reporting which functions have improved or worsened. So we have started paying a lot more attention to the CC of functions.</p> <p>I've read that CC could be informally calculated as 1 + th...
[ { "answer_id": 204385, "author": "JacquesB", "author_id": 7488, "author_profile": "https://Stackoverflow.com/users/7488", "pm_score": 2, "selected": false, "text": "<p>CC is not a panacea for measuring quality. Clearly a repeated statement is not \"better\" than a loop, even if a loop ha...
2008/10/15
[ "https://Stackoverflow.com/questions/204369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7261/" ]
Recently our company has started measuring the cyclomatic complexity (CC) of the functions in our code on a weekly basis, and reporting which functions have improved or worsened. So we have started paying a lot more attention to the CC of functions. I've read that CC could be informally calculated as 1 + the number of...
1. Yes. Your first example has a decision point and your second does not, so the first has a higher CC. 2. Yes-maybe, your first example has multiple decision points and thus a higher CC. (See below for explanation.) 3. Yes-maybe. Obviously they have the same number of decision points, but there are different ways to c...
204,396
<p>When returning objects from a class, when is the right time to release the memory?</p> <p>Example,</p> <pre><code>class AnimalLister { public: Animal* getNewAnimal() { Animal* animal1 = new Animal(); return animal1; } } </code></pre> <p>If i create an instance of Animal Lister and get Animal ref...
[ { "answer_id": 204408, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 5, "selected": false, "text": "<p>I advise returning a <code>std::tr1::shared_ptr</code> (or <code>boost::shared_ptr</code>, if your C++ implementation doe...
2008/10/15
[ "https://Stackoverflow.com/questions/204396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28202/" ]
When returning objects from a class, when is the right time to release the memory? Example, ``` class AnimalLister { public: Animal* getNewAnimal() { Animal* animal1 = new Animal(); return animal1; } } ``` If i create an instance of Animal Lister and get Animal reference from it, then where am i s...
I advise returning a `std::tr1::shared_ptr` (or `boost::shared_ptr`, if your C++ implementation does not have TR1) instead of a raw pointer. So, instead of using `Animal*`, use `std::tr1::shared_ptr<Animal>` instead. Shared pointers handle reference tracking for you, and delete the object automatically if there are no...
204,398
<p>Let's have the following class hierarchy:</p> <pre><code>public class ParentClass implements SomeInterface { } public class ChildClass extends ParentClass { } </code></pre> <p>Then let's have these two instances:</p> <pre><code>ParentClass parent; ChildClass child; </code></pre> <p>Then we have the following TR...
[ { "answer_id": 204409, "author": "John Topley", "author_id": 1450, "author_profile": "https://Stackoverflow.com/users/1450", "pm_score": 2, "selected": false, "text": "<p>It's not possible and doing so would violate the implied IS-A relationship between ChildClass and ParentClass. Why do...
2008/10/15
[ "https://Stackoverflow.com/questions/204398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/446104/" ]
Let's have the following class hierarchy: ``` public class ParentClass implements SomeInterface { } public class ChildClass extends ParentClass { } ``` Then let's have these two instances: ``` ParentClass parent; ChildClass child; ``` Then we have the following TRUE statements ``` (parent instanceof SomeInterfa...
No it is not possible, and your intent to do so is a good hint that something is flawed in your class hierarchy. Workaround: change the class hierarchy, eg. like this: ``` interface SomeInterface {} abstract class AbstractParentClass {} class ParentClass extends AbstractParentClass implements SomeInterface {} class...
204,404
<p>We're developing an EPiServer-based website and trying to deploy our latest build onto a WinXP IIS6 box.</p> <p>When browsing to site, we're getting the following stack trace</p> <pre><code>[ClassFactoryException: ClassFactory not initialized] EPiServer.BaseLibrary.ClassFactory.get_Instance() +123 EPiServer....
[ { "answer_id": 428061, "author": "aanund", "author_id": 7335, "author_profile": "https://Stackoverflow.com/users/7335", "pm_score": 0, "selected": false, "text": "<p>I am going out on a limb and guessing here, but did you by chance do development on EPiServer 5 SP 2 and deploy on EPiServ...
2008/10/15
[ "https://Stackoverflow.com/questions/204404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12277/" ]
We're developing an EPiServer-based website and trying to deploy our latest build onto a WinXP IIS6 box. When browsing to site, we're getting the following stack trace ``` [ClassFactoryException: ClassFactory not initialized] EPiServer.BaseLibrary.ClassFactory.get_Instance() +123 EPiServer.BaseLibrary.Context.g...
The configuration file is written for IIS7 but you build in webserver in Studio want a IIS6 sonfig file. I have wrote abut this in ny EPiServer notes <http://epiwiki.se/troubleshooting/classfactory-not-initialized>
204,406
<p>I am trying to convert all DateTime values in a DataTable to strings. Here is the method I use:</p> <pre><code>private static void ConvertDateTimesToStrings(DataTable dataTable) { if (dataTable == null) { return; } for (int rowIndex = 0; rowIndex &lt; dataTable.Rows.Count; rowIndex++ ) ...
[ { "answer_id": 204419, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 4, "selected": false, "text": "<p>This simply won't work, because you haven't changed the underlaying data type.</p>\n\n<p>You have a DataTable, with a column w...
2008/10/15
[ "https://Stackoverflow.com/questions/204406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
I am trying to convert all DateTime values in a DataTable to strings. Here is the method I use: ``` private static void ConvertDateTimesToStrings(DataTable dataTable) { if (dataTable == null) { return; } for (int rowIndex = 0; rowIndex < dataTable.Rows.Count; rowIndex++ ) { for (in...
It may have determined that the column data type is date time and is reboxing the values to datetime when you save the value back in there. Try this... Create a new column on the datatable as a TypeOf(String), and save the string value into that column. When all the values have been copied, drop the date time column.
204,444
<p>As can be seen in the Mozilla changlog for JavaScript 1.7 they have added destructuring assignment. Sadly I'm not very fond of the syntax (why write a and b twice?):</p> <pre><code>var a, b; [a, b] = f(); </code></pre> <p>Something like this would have been a lot better:</p> <pre><code>var [a, b] = f(); </code>...
[ { "answer_id": 205254, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 2, "selected": false, "text": "<p>You don't need the dummy \"_\" variable. You can directly create \"global\" variables by using the window object sco...
2008/10/15
[ "https://Stackoverflow.com/questions/204444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13995/" ]
As can be seen in the Mozilla changlog for JavaScript 1.7 they have added destructuring assignment. Sadly I'm not very fond of the syntax (why write a and b twice?): ``` var a, b; [a, b] = f(); ``` Something like this would have been a lot better: ``` var [a, b] = f(); ``` That would still be backwards compatib...
First off, `var [a, b] = f()` works just fine in JavaScript 1.7 - try it! Second, you can smooth out the usage syntax *slightly* using `with()`: ``` var array = [1,2]; with (assign(array, { var1: null, var2: null })) { var1; // == 1 var2; // == 2 } ``` Of course, this won't allow you to modify the values of e...
204,461
<p>Suppose you have:</p> <pre><code>A-B-C </code></pre> <p>Now your build/test fails. The fix should be merged in A. My current work-flow is like this:</p> <pre><code>$ git commit -m "fixA" A-B-C-fixA $ git rebase -i A~1 </code></pre> <p>And squash fixA in A, result in: </p> <pre><code>A'-B-C </code></pre> <p>...
[ { "answer_id": 4607280, "author": "Jo Liss", "author_id": 525872, "author_profile": "https://Stackoverflow.com/users/525872", "pm_score": 5, "selected": true, "text": "<p><em>If you're just looking for the easy solution for fixing up earlier commits, read the question! It explains it all...
2008/10/15
[ "https://Stackoverflow.com/questions/204461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277510/" ]
Suppose you have: ``` A-B-C ``` Now your build/test fails. The fix should be merged in A. My current work-flow is like this: ``` $ git commit -m "fixA" A-B-C-fixA $ git rebase -i A~1 ``` And squash fixA in A, result in: ``` A'-B-C ``` Is there a command to do something like: ``` A-B-C + (index with fix fo...
*If you're just looking for the easy solution for fixing up earlier commits, read the question! It explains it all. But since Elmarco was asking for a slick way, here we go:* As of Git 1.7.0, there is an `--autosquash` option for [`rebase`](https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html), which does ...
204,467
<p>I have trouble using Perl grep() with a string that <em>may</em> contain chars that are interpreted as regular expressions quantifiers. </p> <p>I got the following error when the grep pattern is "g++" because the '+' symbols are interpreted as quantifiers. Here is the output of for program that follows:</p> <pre><...
[ { "answer_id": 204474, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 6, "selected": true, "text": "<p>The standard way is to use the <code>\\Q</code> escape indicator before your variable, to tell Perl not to parse t...
2008/10/15
[ "https://Stackoverflow.com/questions/204467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18804/" ]
I have trouble using Perl grep() with a string that *may* contain chars that are interpreted as regular expressions quantifiers. I got the following error when the grep pattern is "g++" because the '+' symbols are interpreted as quantifiers. Here is the output of for program that follows: ``` 1..3 ok 1 - grep, patte...
The standard way is to use the `\Q` escape indicator before your variable, to tell Perl not to parse the contents as a regular expression: ``` return grep (!/\Q$filter/, @output); ``` Altering that line in your code yields: ``` 1..3 ok 1 - grep, pattern not found ok 2 - grep, pattern found ok 3 - grep, pattern fou...
204,468
<p>So I have the following:</p> <pre><code>public class Singleton { private Singleton(){} public static readonly Singleton instance = new Singleton(); public string DoSomething(){ ... } public string DoSomethingElse(){ ... } } </code></pre> <p>Using reflection how can I invoke the DoSomething Method? </p...
[ { "answer_id": 204508, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>Untested, but should work...</p>\n\n<pre><code>string methodName = \"DoSomething\"; // e.g. read from XML\nMethodInfo ...
2008/10/15
[ "https://Stackoverflow.com/questions/204468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6204/" ]
So I have the following: ``` public class Singleton { private Singleton(){} public static readonly Singleton instance = new Singleton(); public string DoSomething(){ ... } public string DoSomethingElse(){ ... } } ``` Using reflection how can I invoke the DoSomething Method? Reason I ask is because I s...
Untested, but should work... ``` string methodName = "DoSomething"; // e.g. read from XML MethodInfo method = typeof(Singleton).GetMethod(methodName); FieldInfo field = typeof(Singleton).GetField("instance", BindingFlags.Static | BindingFlags.Public); object instance = field.GetValue(null); method.Invoke(instance,...
204,476
<p>What is the correct (most efficient) way to define the <code>main()</code> function in C and C++ — <code>int main()</code> or <code>void main()</code> — and why? And how about the arguments? If <code>int main()</code> then <code>return 1</code> or <code>return 0</code>?</p> <hr> <p><em>There are numerous duplicates ...
[ { "answer_id": 204483, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 10, "selected": true, "text": "<p>The return value for <code>main</code> indicates how the program exited. Normal exit is represented by a 0 return valu...
2008/10/15
[ "https://Stackoverflow.com/questions/204476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25632/" ]
What is the correct (most efficient) way to define the `main()` function in C and C++ — `int main()` or `void main()` — and why? And how about the arguments? If `int main()` then `return 1` or `return 0`? --- *There are numerous duplicates of this question, including:* * [What are the valid signatures for C's `main(...
The return value for `main` indicates how the program exited. Normal exit is represented by a 0 return value from `main`. Abnormal exit is signaled by a non-zero return, but there is no standard for how non-zero codes are interpreted. As noted by others, `void main()` is prohibited by the C++ standard and should not be...
204,488
<p>I am trying to create a new contact using Dynamic Entity. The sample i found in CRM SDK had this code.</p> <pre><code>// Set the properties of the contact using property objects. StringProperty firstname = new StringProperty(); firstname.Name = "firstname"; firstname.Value = "Jesper"; ...
[ { "answer_id": 204849, "author": "SaaS Developer", "author_id": 7215, "author_profile": "https://Stackoverflow.com/users/7215", "pm_score": 0, "selected": false, "text": "<p>I believe the issue is that you are referencing the dynamic entity class in the Microsoft.Crm.Sdk assembly. The s...
2008/10/15
[ "https://Stackoverflow.com/questions/204488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2245/" ]
I am trying to create a new contact using Dynamic Entity. The sample i found in CRM SDK had this code. ``` // Set the properties of the contact using property objects. StringProperty firstname = new StringProperty(); firstname.Name = "firstname"; firstname.Value = "Jesper"; StringProper...
Here is an article from Microsoft that makes an attempt to discuss this topic: <http://community.dynamics.com/blogs/cscrmblog/archive/2008/06/23/web-services-amp-dlls-or-what-s-up-with-all-the-duplicate-classes.aspx> This is not a bug that you are running into but more of a difference in design between the way the tw...
204,505
<p>I use LINQ to Objects instructions on an ordered array. Which operations shouldn't I do to be sure the order of the array is not changed?</p>
[ { "answer_id": 204512, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": false, "text": "<p>Are you actually talking about SQL, or about arrays? To put it another way, are you using LINQ to SQL or LINQ to Obje...
2008/10/15
[ "https://Stackoverflow.com/questions/204505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28216/" ]
I use LINQ to Objects instructions on an ordered array. Which operations shouldn't I do to be sure the order of the array is not changed?
I examined the methods of [System.Linq.Enumerable](http://msdn.microsoft.com/en-us/library/system.linq.enumerable_methods.aspx), discarding any that returned non-IEnumerable results. I checked the remarks of each to determine how the order of the result would differ from order of the source. Preserves Order Absolutely...
204,538
<p>I am having a listbox in ASP.net. I am populating the listbox values from another listbox in a page dynamically. During postbacks the values of output listbox are not persisted. (while going to another page and come back to this page).</p> <p>Please suggest some good answer. EnableViewstate = "true" is not working....
[ { "answer_id": 204551, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 3, "selected": true, "text": "<p>Are you doing anything in Page_Load that should be in a </p>\n\n<pre><code>if(!IsPostBack) {}\n</code></pre>\n\n<p>Init...
2008/10/15
[ "https://Stackoverflow.com/questions/204538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
I am having a listbox in ASP.net. I am populating the listbox values from another listbox in a page dynamically. During postbacks the values of output listbox are not persisted. (while going to another page and come back to this page). Please suggest some good answer. EnableViewstate = "true" is not working.
Are you doing anything in Page\_Load that should be in a ``` if(!IsPostBack) {} ``` Initialization code in load needs to only be called when the page is first loaded, not on postbacks. If you are going to another page and then coming back to this page, I think you need to preserve the information yourself in the S...
204,549
<p>I need to insert some data into a table in Oracle. </p> <p>The only problem is one of the fields is a timestamp(6) type and it is required data. I don't care about what actually goes in here I just need to get the right syntax for an entry so that the database will accept it.</p> <p>I'm using the gui web client to...
[ { "answer_id": 204620, "author": "Mike Woodhouse", "author_id": 1060, "author_profile": "https://Stackoverflow.com/users/1060", "pm_score": 4, "selected": false, "text": "<p>I dunno if this helps at all, but in SQL*Plus I did this:</p>\n\n<pre><code>create table x ( a timestamp(6));\nins...
2008/10/15
[ "https://Stackoverflow.com/questions/204549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22061/" ]
I need to insert some data into a table in Oracle. The only problem is one of the fields is a timestamp(6) type and it is required data. I don't care about what actually goes in here I just need to get the right syntax for an entry so that the database will accept it. I'm using the gui web client to enter data howev...
I dunno if this helps at all, but in SQL\*Plus I did this: ``` create table x ( a timestamp(6)); insert into x values ( current_timestamp ); select * from x; ``` getting me this: ``` T --------------------------------------------------------------------------- 15-OCT-08 02.01.25.604309 PM ``` So it looks like tha...
204,557
<p>I'm working on scripts that apply database schema updates. I've setup all my SQL update scripts using start transaction/commit. I pass these scripts to psql on the command line.</p> <p>I now need to apply multiple scripts at the same time, and in one transaction. So far the only solution I've come up with is to rem...
[ { "answer_id": 204592, "author": "MysticSlayer", "author_id": 28139, "author_profile": "https://Stackoverflow.com/users/28139", "pm_score": 4, "selected": true, "text": "<p>Well you have the possibility to use nested transactions inside postgresql using SavePoints.</p>\n\n<p>Take this co...
2008/10/15
[ "https://Stackoverflow.com/questions/204557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5801/" ]
I'm working on scripts that apply database schema updates. I've setup all my SQL update scripts using start transaction/commit. I pass these scripts to psql on the command line. I now need to apply multiple scripts at the same time, and in one transaction. So far the only solution I've come up with is to remove the st...
Well you have the possibility to use nested transactions inside postgresql using SavePoints. Take this code example: ``` CREATE TABLE t1 (a integer PRIMARY KEY); CREATE FUNCTION test_exception() RETURNS boolean LANGUAGE plpgsql AS $$BEGIN INSERT INTO t1 (a) VALUES (1); INSERT INTO t1 (a) VALUES (2); INSERT ...
204,564
<p>Is there any way to get the custom attributes of a specific object I am receiving in a method?</p> <p>I do not want nor can to iterate over Type.GetMembers() and search for my member. I have the object, which is also a member, that has the attribute.</p> <p>How do I get the attribute?</p> <pre><code>class Custom ...
[ { "answer_id": 204573, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 1, "selected": false, "text": "<p>You cannot do this without at least 1 Reflection call. After that, save the value somehow.</p>\n\n<p>Example:</p>\n\n<pr...
2008/10/15
[ "https://Stackoverflow.com/questions/204564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2130892/" ]
Is there any way to get the custom attributes of a specific object I am receiving in a method? I do not want nor can to iterate over Type.GetMembers() and search for my member. I have the object, which is also a member, that has the attribute. How do I get the attribute? ``` class Custom { [Availability] pri...
No. Objects don't have attributes - members do. By the time you're in the "Do" method, there's no record of the fact that you called Do(MyObject) vs Do(MyOtherFieldWhichHasTheSameValue). If you need to look up the attributes on a member, you'll basically have to pass in the relevant MemberInfo, not what it happens to ...
204,576
<p>In my MFC program I am using a splitter to create two panes. I now want to split one of these panes in half again and put in another view, can someone talk me through how to do it or point me in the direction of some code?</p> <p>I would prefer to code it myself so I am not interested in custom derived classes unle...
[ { "answer_id": 204584, "author": "pmlarocque", "author_id": 7419, "author_profile": "https://Stackoverflow.com/users/7419", "pm_score": 0, "selected": false, "text": "<p>I am not an expert in MFC, but can't you just put a splitter in one of the panes you made with the first splitter ? th...
2008/10/15
[ "https://Stackoverflow.com/questions/204576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18664/" ]
In my MFC program I am using a splitter to create two panes. I now want to split one of these panes in half again and put in another view, can someone talk me through how to do it or point me in the direction of some code? I would prefer to code it myself so I am not interested in custom derived classes unless they ar...
In `CMainFrame::OnCreateClient` ``` // Create splitter with 2 rows and 1 col m_wndSplitter.CreateStatic(this, 2, 1); // Create a view in the top row m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CView1), CSize(100, 100), pContext); // Create a 2 column splitter that will go in the bottom row of the first m_wndSplitter2...
204,611
<p>I am working with Crystal Reports and MS SQL Server. I need to remap the crystal report to point to a different database on the same SQL Server. Is there an automated way of doing this, or do I have to remap for every single report? I am currently doing this by adding a new data connection, and then updating the sto...
[ { "answer_id": 209010, "author": "Jas", "author_id": 777, "author_profile": "https://Stackoverflow.com/users/777", "pm_score": 0, "selected": false, "text": "<p>You can get any of the info from the current report connection info. So if your not changing servers, then set the crystalServe...
2008/10/15
[ "https://Stackoverflow.com/questions/204611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am working with Crystal Reports and MS SQL Server. I need to remap the crystal report to point to a different database on the same SQL Server. Is there an automated way of doing this, or do I have to remap for every single report? I am currently doing this by adding a new data connection, and then updating the stored...
You'll find hereafter the procedure I use (I simplified it on the fly, suppressing our own objects and global variables). This procedure allows to redirect a report from an original connection used at development time to the active SQL server. It is written in VB and uses 2 main objects: 1. The original report object ...
204,616
<p>We are in the process of moving our SVN repositories from one machine to another one, and with it will come a new domain name for the new repo. The problem is, that within the repository, there are lots of svn:externals references to other projects within the repository. So for example, we have projectA, which has...
[ { "answer_id": 204736, "author": "conny", "author_id": 23023, "author_profile": "https://Stackoverflow.com/users/23023", "pm_score": 0, "selected": false, "text": "<p>You could:</p>\n\n<p>a) check out the old revision, and change your hosts-file to point the old name to the new address, ...
2008/10/15
[ "https://Stackoverflow.com/questions/204616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14302/" ]
We are in the process of moving our SVN repositories from one machine to another one, and with it will come a new domain name for the new repo. The problem is, that within the repository, there are lots of svn:externals references to other projects within the repository. So for example, we have projectA, which has in t...
As you indicated that you still want to be able to check out older revisions, the only solution is really to "rewrite" the entire history (solution D mentioned earlier). To do this, you should: 1) Dump the contents of the *entire* repository using [svnadmin dump](http://svnbook.red-bean.com/en/1.1/re31.html "svnadmin...
204,627
<p>I'm trying to start using LINQ and specifically LINQ to SQL but I'm having some difficulties</p> <p>I've tried this with SqlMetal and now using the database table designer in Visual Studio and I keep getting similar errors, like in this code, using the data context I created with the database layout designer in VS2...
[ { "answer_id": 204631, "author": "Sam", "author_id": 7021, "author_profile": "https://Stackoverflow.com/users/7021", "pm_score": 2, "selected": false, "text": "<p>Shouldn't you <strong>use</strong> the dc you create somewhere in your query?</p>\n\n<p>Something like:</p>\n\n<pre><code>pro...
2008/10/15
[ "https://Stackoverflow.com/questions/204627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26140/" ]
I'm trying to start using LINQ and specifically LINQ to SQL but I'm having some difficulties I've tried this with SqlMetal and now using the database table designer in Visual Studio and I keep getting similar errors, like in this code, using the data context I created with the database layout designer in VS2008. ``` ...
Try ``` var user = from u in dc.User where u.UserName == usn select u; ```
204,646
<p>Does anyone have a simple, efficient way of checking that a string doesn't contain HTML? Basically, I want to check that certain fields only contain plain text. I thought about looking for the &lt; character, but that can easily be used in plain text. Another way might be to create a new System.Xml.Linq.XElement ...
[ { "answer_id": 204664, "author": "ICR", "author_id": 214, "author_profile": "https://Stackoverflow.com/users/214", "pm_score": 6, "selected": false, "text": "<p>The following will match any matching set of tags. i.e. &lt;b>this&lt;/b></p>\n\n<pre><code>Regex tagRegex = new Regex(@\"&lt;\...
2008/10/15
[ "https://Stackoverflow.com/questions/204646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203/" ]
Does anyone have a simple, efficient way of checking that a string doesn't contain HTML? Basically, I want to check that certain fields only contain plain text. I thought about looking for the < character, but that can easily be used in plain text. Another way might be to create a new System.Xml.Linq.XElement using: `...
I just tried my XElement.Parse solution. I created an extension method on the string class so I can reuse the code easily: ``` public static bool ContainsXHTML(this string input) { try { XElement x = XElement.Parse("<wrapper>" + input + "</wrapper>"); return !(x.DescendantNodes().Count() == 1 &...
204,653
<p>Using a web service is often an excellent architectural approach. And, with the advent of WCF in .Net, it's getting even better.</p> <p>But, in my experience, some people seem to think that web services should always be used in the data access layer for calls to the database. I don't think that web services are the...
[ { "answer_id": 204680, "author": "Jared", "author_id": 1980, "author_profile": "https://Stackoverflow.com/users/1980", "pm_score": 3, "selected": false, "text": "<p>If you are just coding a tiny (less than 50 users) web application for your intranet, a web service seems overkill. Especia...
2008/10/15
[ "https://Stackoverflow.com/questions/204653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27637/" ]
Using a web service is often an excellent architectural approach. And, with the advent of WCF in .Net, it's getting even better. But, in my experience, some people seem to think that web services should always be used in the data access layer for calls to the database. I don't think that web services are the universal...
Web Services are an absolutely horrible choice for data access. It's a ton of overhead and complexity for almost zero benefit. If your app is going to run on one machine, why deny it the ability to do in-process data access calls? I'm not talking about directly accessing the database from your UI code, I'm talking abo...
204,670
<p>If I query a table with a condition on the key field as in:</p> <pre><code> var user = from u in dc.Users where u.UserName == usn select u; </code></pre> <p>I know that I will either get zero results or one result. Should I still go ahead and retrieve the results using ...
[ { "answer_id": 204678, "author": "Danimal", "author_id": 2757, "author_profile": "https://Stackoverflow.com/users/2757", "pm_score": 4, "selected": false, "text": "<p>Why not something like</p>\n\n<pre><code>var user = dc.Users.SingleOrDefault(u=&gt; u.UserName==usn);\n</code></pre>\n" ...
2008/10/15
[ "https://Stackoverflow.com/questions/204670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26140/" ]
If I query a table with a condition on the key field as in: ``` var user = from u in dc.Users where u.UserName == usn select u; ``` I know that I will either get zero results or one result. Should I still go ahead and retrieve the results using a for-each or is there ano...
Try something like this: ``` var user = (from u in dc.Users where u.UserName == usn select u).FirstOrDefault(); ``` The [FirstOrDefault](http://msdn.microsoft.com/en-us/library/bb549141.aspx) method returns the first element of a sequence that satisfies a specified condition or ...
204,676
<p>I'm about to release a set of Eclipse plug-ins as Open Source and noticed that most source code released under the LGPL/EPL contains a header banner in each file that refers to the license or contains the license itself.</p> <p>Since adding these banners to each file manually seems to be a daunting and error-prone ...
[ { "answer_id": 204928, "author": "idrosid", "author_id": 17876, "author_profile": "https://Stackoverflow.com/users/17876", "pm_score": 3, "selected": false, "text": "<p>Concerning best practises, I believe you should have your license text in a separate file and have a build tool (ie ant...
2008/10/15
[ "https://Stackoverflow.com/questions/204676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4445/" ]
I'm about to release a set of Eclipse plug-ins as Open Source and noticed that most source code released under the LGPL/EPL contains a header banner in each file that refers to the license or contains the license itself. Since adding these banners to each file manually seems to be a daunting and error-prone task. How ...
Concerning best practises, I believe you should have your license text in a separate file and have a build tool (ie ant) to add it at the beginning of all other files. Since you are talking about an open source project you would need a build process anyway for thinks like generating the javadocs, publishing releases et...
204,682
<p>I want to limit the number of words a person can enter in a text field. How can I track the number of words (by using a second field) in that field as each word is entered?</p>
[ { "answer_id": 206708, "author": "Ichorus", "author_id": 27247, "author_profile": "https://Stackoverflow.com/users/27247", "pm_score": 0, "selected": false, "text": "<p>From <a href=\"http://www.mediacollege.com\" rel=\"nofollow noreferrer\">Media College</a> :</p>\n\n<p><a href=\"http:/...
2008/10/15
[ "https://Stackoverflow.com/questions/204682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to limit the number of words a person can enter in a text field. How can I track the number of words (by using a second field) in that field as each word is entered?
use this js (using jquery): ``` $('#newKeywords').bind('change', function() { $('#wordsLong').text($('#newKeywords').val().split(' ').length + 1); }); ``` and this html: ``` <textarea id="newKeywords"></textarea> <div>The text consists of <span id="wordsLong"></span> keywords.</div> ```
204,695
<p>I'm writing a page that can use a couple of different themes, and I'm going to store some information about each theme in the web.config. </p> <p>Is it more efficient to create a new sectionGroup and store everything together, or just put everything in appSettings?</p> <p><b>configSection solution</b></p> <pre><...
[ { "answer_id": 204703, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 3, "selected": false, "text": "<p>There will be no measurable difference in terms of efficiency.</p>\n\n<p>AppSettings is great if all you need are name/valu...
2008/10/15
[ "https://Stackoverflow.com/questions/204695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3018/" ]
I'm writing a page that can use a couple of different themes, and I'm going to store some information about each theme in the web.config. Is it more efficient to create a new sectionGroup and store everything together, or just put everything in appSettings? **configSection solution** ``` <configSections> <secti...
For more complex configuration setup, I would use a custom configuration section that clearly defines the roles of each section for example ``` <appMonitoring enabled="true" smtpServer="xxx"> <alertRecipients> <add name="me" email="me@me.com"/> </alertRecipient> </appMonitoring> ``` In your configuration cla...
204,711
<p>Of the two methods below, which do you prefer to read?<br> Is there another (better?) way to check if a flag is set?</p> <pre><code> bool CheckFlag(FooFlag fooFlag) { return fooFlag == (this.Foo &amp; fooFlag); } </code></pre> <p>And</p> <pre><code> bool CheckFlag(FooFlag fooFlag) { return (this.Fo...
[ { "answer_id": 204723, "author": "Enrico Murru", "author_id": 68336, "author_profile": "https://Stackoverflow.com/users/68336", "pm_score": 2, "selected": false, "text": "<p>i prefer the first one because it's more readable.</p>\n" }, { "answer_id": 204725, "author": "coder1"...
2008/10/15
[ "https://Stackoverflow.com/questions/204711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14484/" ]
Of the two methods below, which do you prefer to read? Is there another (better?) way to check if a flag is set? ``` bool CheckFlag(FooFlag fooFlag) { return fooFlag == (this.Foo & fooFlag); } ``` And ``` bool CheckFlag(FooFlag fooFlag) { return (this.Foo & fooFlag) != 0; } ``` --- Please vo...
The two expressions do different things (if fooFlag has more than one bit set), so which one is better really depends on the behavior you want: ``` fooFlag == (this.Foo & fooFlag) // result is true iff all bits in fooFlag are set (this.Foo & fooFlag) != 0 // result is true if any bits in fooFlag are set ```
204,733
<p>I am constructing a search page with a textbox and a button for now, and probably a dropdown to filter results later on. I have my button's PostBackUrl set to my search page (~/search.aspx). Is there an easy way to pass the value in the text box to the search page?</p>
[ { "answer_id": 204776, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 0, "selected": false, "text": "<p>you may be able to use useSubmitBehavior=\"true\" and put a method=\"get\" on the form. that way it will use the brow...
2008/10/15
[ "https://Stackoverflow.com/questions/204733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
I am constructing a search page with a textbox and a button for now, and probably a dropdown to filter results later on. I have my button's PostBackUrl set to my search page (~/search.aspx). Is there an easy way to pass the value in the text box to the search page?
If you have the PostBackUrl set on your button, then the search box field on your first page, and any other form fields on that page, are already being posted to your search page. The trick is getting access to them in the code-behind for your search.aspx page. ``` if (Page.PreviousPage != null) { TextBox SourceTe...
204,737
<p>I have a lot of castle xml configs where properties like connectionstring are also held under .Net configuration sections.</p> <p>I'd like to be able to read out the properties using the container but can't see a mechanism to do it.</p> <p>ie </p> <pre><code>&lt;castle&gt; &lt;configuration&gt; &lt;properti...
[ { "answer_id": 204835, "author": "Ronnie", "author_id": 193, "author_profile": "https://Stackoverflow.com/users/193", "pm_score": 1, "selected": false, "text": "<p>Aren't you thinking about this the wrong way round?</p>\n\n<p>Surely the object that is using the connection string should h...
2008/10/15
[ "https://Stackoverflow.com/questions/204737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a lot of castle xml configs where properties like connectionstring are also held under .Net configuration sections. I'd like to be able to read out the properties using the container but can't see a mechanism to do it. ie ``` <castle> <configuration> <properties> <connectionString>Data Source=MyS...
You could do this a few different ways - for a strongly typed solution the obvious approach would be to implement a custom configuration class, then wire up the properties of the class with the properties in the windsor config (read-only properties with a bunch of constructor arguments would probably be best, so other ...
204,739
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword">Why does C# not provide the C++ style ‘friend’ keyword?</a> </p> </blockquote> <p>I'd like the private member variables of a class to be accessibl...
[ { "answer_id": 204744, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 9, "selected": true, "text": "<p>There's no direct equivalent of \"friend\" - the closest that's available (and it isn't very close) is <a href=\"http:...
2008/10/15
[ "https://Stackoverflow.com/questions/204739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22185/" ]
> > **Possible Duplicate:** > > [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword) > > > I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ...
There's no direct equivalent of "friend" - the closest that's available (and it isn't very close) is [InternalsVisibleTo](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx). I've only ever used this attribute for testing - where it's very handy! **Example:** To be...
204,742
<p>Right now I'm working on a web application that receives a significant amount of data from a database that has a potential to return null results. When going through the cyclomatic complexity for the application a number of functions are weighing in between 10 - 30. For the most part the majority of the functions wi...
[ { "answer_id": 204769, "author": "jim", "author_id": 27628, "author_profile": "https://Stackoverflow.com/users/27628", "pm_score": 2, "selected": false, "text": "<p>The first question is: Why are you \"hung\" up on CC ? It's a tool to evaluate how dense the code is and a rule of thumb s...
2008/10/15
[ "https://Stackoverflow.com/questions/204742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1185/" ]
Right now I'm working on a web application that receives a significant amount of data from a database that has a potential to return null results. When going through the cyclomatic complexity for the application a number of functions are weighing in between 10 - 30. For the most part the majority of the functions with ...
What about using [Extension Methods](http://msdn.microsoft.com/en-us/library/bb384936.aspx). ``` Imports System.Runtime.CompilerServices Module Extensions <Extension()> _ Public Function TryGetString(ByVal row As IDataRecord, i As Integer) As String If row.IsDBNull(i) Then Return null ...
204,746
<p>For a web application, I want to build a WHERE clause AND submit it to the server. There I will append it to a query. The clause will be something like</p> <pre><code>LASTNAME LIKE 'Pep%' AND (DOB BETWEEN '19600101' AND '19601231 OR SALARY&lt;35000) </code></pre> <p>Can you propose a regular expression to validate...
[ { "answer_id": 204750, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 4, "selected": false, "text": "<p>This is a monumentally bad idea. I would suggest you build a filter system instead where the user can select all k...
2008/10/15
[ "https://Stackoverflow.com/questions/204746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28207/" ]
For a web application, I want to build a WHERE clause AND submit it to the server. There I will append it to a query. The clause will be something like ``` LASTNAME LIKE 'Pep%' AND (DOB BETWEEN '19600101' AND '19601231 OR SALARY<35000) ``` Can you propose a regular expression to validate the clause before submitting...
This is a monumentally bad idea. I would suggest you build a filter system instead where the user can select all kinds of options in a form, and then you build the correct sql server-side instead of opening yourself up to all kinds of injection attacks. As an example of what might go wrong, consider this: ``` LASTNAM...
204,759
<p>Is there a way to perform an HTTP GET request within a Visual Basic script? I need to get the contents of the response from a particular URL for processing.</p>
[ { "answer_id": 204851, "author": "Svante Svenson", "author_id": 19707, "author_profile": "https://Stackoverflow.com/users/19707", "pm_score": 7, "selected": true, "text": "<pre><code>Dim o\nSet o = CreateObject(\"MSXML2.XMLHTTP\")\no.open \"GET\", \"http://www.example.com\", False\no.sen...
2008/10/15
[ "https://Stackoverflow.com/questions/204759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/271/" ]
Is there a way to perform an HTTP GET request within a Visual Basic script? I need to get the contents of the response from a particular URL for processing.
``` Dim o Set o = CreateObject("MSXML2.XMLHTTP") o.open "GET", "http://www.example.com", False o.send ' o.responseText now holds the response as a string. ```
204,765
<p>For debugging purposes, I need to recursively search a directory for all files which start with a UTF-8 byte order mark (BOM). My current solution is a simple shell script:</p> <pre><code>find -type f | while read file do if [ "`head -c 3 -- "$file"`" == $'\xef\xbb\xbf' ] then echo "found BOM in: $f...
[ { "answer_id": 211855, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 3, "selected": false, "text": "<p>If you accept some false positives (in case there are non-text files, or in the unlikely case there is a ZWNBSP in the m...
2008/10/15
[ "https://Stackoverflow.com/questions/204765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19163/" ]
For debugging purposes, I need to recursively search a directory for all files which start with a UTF-8 byte order mark (BOM). My current solution is a simple shell script: ``` find -type f | while read file do if [ "`head -c 3 -- "$file"`" == $'\xef\xbb\xbf' ] then echo "found BOM in: $file" fi do...
What about this one simple command which not just finds but clears the nasty BOM? :) ``` find . -type f -exec sed '1s/^\xEF\xBB\xBF//' -i {} \; ``` I love "find" :) **Warning** The above will **modify** binary files which contain those three characters. If you want just to show BOM files, use this one: ``` grep -...
204,779
<p>I'm VERY new to WPF, and still trying to wrap my head around binding in XAML.</p> <p>I'd like to populate a combobox with the values of a string collection in my.settings. I can do it in code like this:</p> <p>Me.ComboBox1.ItemsSource = My.Settings.MyCollectionOfStrings</p> <p>...and it works.</p> <p>How can I d...
[ { "answer_id": 204855, "author": "Enrico Campidoglio", "author_id": 26396, "author_profile": "https://Stackoverflow.com/users/26396", "pm_score": 5, "selected": true, "text": "<p><strong>Yes</strong>, you can (and should for the most part) declare bindings in XAML, since that's one of th...
2008/10/15
[ "https://Stackoverflow.com/questions/204779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/641985/" ]
I'm VERY new to WPF, and still trying to wrap my head around binding in XAML. I'd like to populate a combobox with the values of a string collection in my.settings. I can do it in code like this: Me.ComboBox1.ItemsSource = My.Settings.MyCollectionOfStrings ...and it works. How can I do this in my XAML? is it possib...
**Yes**, you can (and should for the most part) declare bindings in XAML, since that's one of the most powerful features in WPF. In your case, to bind the ComboBox to one of your custom settings you would use the following XAML: ``` <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/win...
204,784
<p>Given two absolute paths, e.g.</p> <pre><code>/var/data/stuff/xyz.dat /var/data </code></pre> <p>How can one create a relative path that uses the second path as its base? In the example above, the result should be: <code>./stuff/xyz.dat</code></p>
[ { "answer_id": 204847, "author": "Keeg", "author_id": 21059, "author_profile": "https://Stackoverflow.com/users/21059", "pm_score": 3, "selected": false, "text": "<p>If you know the second string is part of the first:</p>\n\n<pre><code>String s1 = \"/var/data/stuff/xyz.dat\";\nString s2 ...
2008/10/15
[ "https://Stackoverflow.com/questions/204784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23424/" ]
Given two absolute paths, e.g. ``` /var/data/stuff/xyz.dat /var/data ``` How can one create a relative path that uses the second path as its base? In the example above, the result should be: `./stuff/xyz.dat`
It's a little roundabout, but why not use URI? It has a relativize method which does all the necessary checks for you. ``` String path = "/var/data/stuff/xyz.dat"; String base = "/var/data"; String relative = new File(base).toURI().relativize(new File(path).toURI()).getPath(); // relative == "stuff/xyz.dat" ``` Plea...
204,801
<p>I believe the following VB.Net code is the equivalent of the proceeding C# code; however the VB.Net test fails - the event handling Lambda is never called.</p> <p>What is going on?</p> <p>VB.Net version - fails:</p> <pre class="lang-vb prettyprint-override"><code>&lt;TestFixture()&gt; _ Public Class TestClass ...
[ { "answer_id": 204992, "author": "Gareth D", "author_id": 3580, "author_profile": "https://Stackoverflow.com/users/3580", "pm_score": 5, "selected": true, "text": "<blockquote>\n <p><strong>Note:</strong> This relates to older versions of VB.net Prior to Visual Studio 2010 and VB.net 10...
2008/10/15
[ "https://Stackoverflow.com/questions/204801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3580/" ]
I believe the following VB.Net code is the equivalent of the proceeding C# code; however the VB.Net test fails - the event handling Lambda is never called. What is going on? VB.Net version - fails: ```vb <TestFixture()> _ Public Class TestClass <Test()> _ Public Sub EventTest() Dim eventClass As New ...
> > **Note:** This relates to older versions of VB.net Prior to Visual Studio 2010 and VB.net 10 > > > The difference is that in VB.Net a lambda expression must return a value i.e. they must be functions not subs. The lambda expression `eventRaised = true` is being interpreted as a boolean expression rather than a...
204,813
<p>In the past people used to wrap HTML comment tags around blocks of JavaScript in order to prevent "older" browsers from displaying the script. Even Lynx is smart enough to ignore JavaScript, so why do some people keep doing this? Are there any valid reasons these days?</p> <pre><code>&lt;script type="text/javascrip...
[ { "answer_id": 204825, "author": "MarkR", "author_id": 13724, "author_profile": "https://Stackoverflow.com/users/13724", "pm_score": 7, "selected": true, "text": "<p>No, absolutely not. Any user agent, search engine spider, or absolutely anything else these days is smart enough to ignore...
2008/10/15
[ "https://Stackoverflow.com/questions/204813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12579/" ]
In the past people used to wrap HTML comment tags around blocks of JavaScript in order to prevent "older" browsers from displaying the script. Even Lynx is smart enough to ignore JavaScript, so why do some people keep doing this? Are there any valid reasons these days? ``` <script type="text/javascript"> <!-- //some j...
No, absolutely not. Any user agent, search engine spider, or absolutely anything else these days is smart enough to ignore Javascript if it can't execute it. There was only a very brief period when this was at all helpful, and it was around 1996.
204,814
<p>Wow, I just got back a huge project in C# from outsourced developers and while going through my code review my analysis tool revealed bunches of what it considered bad stuff. One of the more discouraging messages was:</p> <pre><code>Exceptions.DontSwallowErrorsCatchingNonspecificExceptionsRule : 2106 defects </c...
[ { "answer_id": 204826, "author": "Maxime Rouiller", "author_id": 24975, "author_profile": "https://Stackoverflow.com/users/24975", "pm_score": 4, "selected": false, "text": "<p>I sometimes use a WebControl that is not compulsory for a page to display. If it fails, I don't want to prevent...
2008/10/15
[ "https://Stackoverflow.com/questions/204814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18893/" ]
Wow, I just got back a huge project in C# from outsourced developers and while going through my code review my analysis tool revealed bunches of what it considered bad stuff. One of the more discouraging messages was: ``` Exceptions.DontSwallowErrorsCatchingNonspecificExceptionsRule : 2106 defects ``` The develope...
While there are some reasonable reasons for ignoring exceptions; however, generally it is only specific exceptions that you are able to safely ignore. As noted by [Konrad Rudolph](https://stackoverflow.com/questions/204814/is-there-any-valid-reason-to-ever-ignore-a-caught-exception#204827), you might have to catch and ...
204,823
<p>I'm required to write documentation for my current project that lists all .c files and for each one lists every .h file which is directly or indirectly included by that file.</p> <p>This is a large project, and although we have Makefiles which theoretically have this information, those Makefiles are sometimes incor...
[ { "answer_id": 204893, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p><code>gcc -M file.c</code> does what you need.</p>\n" }, { "answer_id": 204930, "author": "Mark Baker", "au...
2008/10/15
[ "https://Stackoverflow.com/questions/204823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1694/" ]
I'm required to write documentation for my current project that lists all .c files and for each one lists every .h file which is directly or indirectly included by that file. This is a large project, and although we have Makefiles which theoretically have this information, those Makefiles are sometimes incorrect (we i...
What I do in my Makefile is ``` SRCS=$(wildcard *.c) depend: $(SRCS) gcc -M $(CFLAGS) $(SRCS) >depend include depend ``` This means that if any of the source files are updated, the depend rule will run, and use gcc -M to update the file called depend. This is then included in the makefile to provide the depend...
204,829
<p>Situation:</p> <ul> <li>text: a string</li> <li>R: a regex that matches part of the string. This might be expensive to calculate. </li> </ul> <p>I want to both delete the R-matches from the text, and see what they actually contain. Currently, I do this like:</p> <pre><code>import re ab_re = re.compile("[ab]"...
[ { "answer_id": 204961, "author": "Hamish Downer", "author_id": 3189, "author_profile": "https://Stackoverflow.com/users/3189", "pm_score": 0, "selected": false, "text": "<p>You could use split with capturing parantheses. If you do, then the text of all groups in the pattern are also ret...
2008/10/15
[ "https://Stackoverflow.com/questions/204829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15842/" ]
Situation: * text: a string * R: a regex that matches part of the string. This might be expensive to calculate. I want to both delete the R-matches from the text, and see what they actually contain. Currently, I do this like: ``` import re ab_re = re.compile("[ab]") text="abcdedfe falijbijie bbbb laifsjelifjl" ab_re...
``` import re r = re.compile("[ab]") text = "abcdedfe falijbijie bbbb laifsjelifjl" matches = [] replaced = [] pos = 0 for m in r.finditer(text): matches.append(m.group(0)) replaced.append(text[pos:m.start()]) pos = m.end() replaced.append(text[pos:]) print matches print ''.join(replaced) ``` Outputs: ...
204,852
<p>I have an xsd like this </p> <pre><code>&lt;xsd:complexType name="A"&gt; &lt;xsd:complexContent&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="options"&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence&gt; ...
[ { "answer_id": 205247, "author": "csgero", "author_id": 21764, "author_profile": "https://Stackoverflow.com/users/21764", "pm_score": 3, "selected": false, "text": "<p>Simply add an <code>&lt;xsd:sequence&gt;</code> with the required elements:</p>\n\n<pre><code>&lt;xsd:complexType name=\...
2008/10/15
[ "https://Stackoverflow.com/questions/204852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22763/" ]
I have an xsd like this ``` <xsd:complexType name="A"> <xsd:complexContent> <xsd:sequence> <xsd:element name="options"> <xsd:complexType> <xsd:sequence> <xsd:element name="Day"> ...
Here's the schema I came up with: ``` <?xml version="1.0" encoding="utf-8"?> <xs:schema id="inheritance" targetNamespace="http://test.com" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:test="http://test.com" > <xs:element name="Time"> <xs:complexType> ...
204,877
<p>What does the following mean?</p> <pre><code>Class.Function(variable := 1 + 1) </code></pre> <p>What is this operator called, and what does it do? </p>
[ { "answer_id": 204902, "author": "Nescio", "author_id": 14484, "author_profile": "https://Stackoverflow.com/users/14484", "pm_score": 0, "selected": false, "text": "<p>It assigns the optional parameter \"variable\" the value 2.</p>\n" }, { "answer_id": 204935, "author": "Ikke...
2008/10/15
[ "https://Stackoverflow.com/questions/204877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40/" ]
What does the following mean? ``` Class.Function(variable := 1 + 1) ``` What is this operator called, and what does it do?
It is used to assign optional variables, without assigning the previous ones. ``` sub test(optional a as string = "", optional b as string = "") msgbox(a & b) end sub ``` you can now do ``` test(b:= "blaat") 'in stead of test("", "blaat") ```
204,886
<p>you can request the http header to check if a web page has been edited by looking at its date but how about dynamic pages such as - php, aspx- which grabs its data from a database?</p>
[ { "answer_id": 204898, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 0, "selected": false, "text": "<p>You can if it uses the http response headers correctly but it's often overlooked.</p>\n\n<p>Otherwise storing a local md5-h...
2008/10/15
[ "https://Stackoverflow.com/questions/204886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459737/" ]
you can request the http header to check if a web page has been edited by looking at its date but how about dynamic pages such as - php, aspx- which grabs its data from a database?
Even though you might think it's outdated I've always found Simon Willison's article on [Conditional GET](http://simonwillison.net/2003/Apr/23/conditionalGet/) to be more than useful. The example is in PHP but it is so simple that you can adapt it to other languages. Here it is the example: ``` function doConditionalG...
204,933
<p>I read an excel sheet into a datagrid.From there , I have managed to read the grid's rows into a DataTable object.The DataTable object has data because when I make equal a grid's datasource to that table object , the grid is populated.</p> <p>My Problem : I want to use the table object and manipulate its values usi...
[ { "answer_id": 204964, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>Putting the data into a database will take time - since you already have it in memory, perhaps LINQ-to-Objects (wi...
2008/10/15
[ "https://Stackoverflow.com/questions/204933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I read an excel sheet into a datagrid.From there , I have managed to read the grid's rows into a DataTable object.The DataTable object has data because when I make equal a grid's datasource to that table object , the grid is populated. My Problem : I want to use the table object and manipulate its values using SQL ser...
Change your temp table from #table to ##table in both places. Using ## means a global temp table that stays around. You'll need to Drop it after you have completed your task. Command = " Drop Table ##table"
204,942
<p>We have an application that installs SQL Server Express from the command line and specifies the service account as the LocalSystem account via the parameter SQLACCOUNT="NT AUTHORITY\SYSTEM".</p> <p>This doesn't work with different languages because the account name for LocalSystem is different. There's a table list...
[ { "answer_id": 204955, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 1, "selected": false, "text": "<p>This should do something similar to what you posted. I'm not sure how to get specific properties of WMI objects of...
2008/10/15
[ "https://Stackoverflow.com/questions/204942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5449/" ]
We have an application that installs SQL Server Express from the command line and specifies the service account as the LocalSystem account via the parameter SQLACCOUNT="NT AUTHORITY\SYSTEM". This doesn't work with different languages because the account name for LocalSystem is different. There's a table listing the di...
You can use .NET's built-in [System.Security.Principal.SecurityIdentifier](http://msdn.microsoft.com/en-us/library/system.security.principal.securityidentifier.aspx) class for this purpose: by translating it into an instance of [NtAccount](http://msdn.microsoft.com/en-us/library/system.security.principal.ntaccount.aspx...
204,950
<p>I have just installed the Krypton Toolkit 3.0.6 from component Factory. I find that in the create new Project Dialog Box , Krypton Form does not show up as an option. I am sure it used to show up ( and I have actually used it in an earlier version of krypton toolkit).But after the new install it does not.</p>
[ { "answer_id": 205039, "author": "Judah Gabriel Himango", "author_id": 536, "author_profile": "https://Stackoverflow.com/users/536", "pm_score": 1, "selected": false, "text": "<p>The \"New Krypton Form\" used to show up not inside the \"new project\" dialog, but inside the \"new item\" d...
2008/10/15
[ "https://Stackoverflow.com/questions/204950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have just installed the Krypton Toolkit 3.0.6 from component Factory. I find that in the create new Project Dialog Box , Krypton Form does not show up as an option. I am sure it used to show up ( and I have actually used it in an earlier version of krypton toolkit).But after the new install it does not.
For the sake of completeness and accuracy , I am posting the actual code for inheriting from a krypton form. ``` public partial class Form1 : ComponentFactory.Krypton.Toolkit.KryptonForm ```
204,963
<p>I'm quite confused by something. I've got 2 select lists, and if you choose an option in the first, I then load the 2nd with a certain set of options. I clear this out and repopulate it every time you change the selection in the first select element. Now, on postback, I need to know the value of the option that w...
[ { "answer_id": 205039, "author": "Judah Gabriel Himango", "author_id": 536, "author_profile": "https://Stackoverflow.com/users/536", "pm_score": 1, "selected": false, "text": "<p>The \"New Krypton Form\" used to show up not inside the \"new project\" dialog, but inside the \"new item\" d...
2008/10/15
[ "https://Stackoverflow.com/questions/204963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/232/" ]
I'm quite confused by something. I've got 2 select lists, and if you choose an option in the first, I then load the 2nd with a certain set of options. I clear this out and repopulate it every time you change the selection in the first select element. Now, on postback, I need to know the value of the option that was sel...
For the sake of completeness and accuracy , I am posting the actual code for inheriting from a krypton form. ``` public partial class Form1 : ComponentFactory.Krypton.Toolkit.KryptonForm ```
204,970
<p>Suppose I have following string:</p> <pre><code>String asd = "this is test ass this is test" </code></pre> <p>and I want to split the string using "ass" character sequence.</p> <p>I used:</p> <pre><code>asd.split("ass"); </code></pre> <p>It doesn't work. What do I need to do?</p>
[ { "answer_id": 205004, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>It seems to work fine for me:</p>\n\n<pre><code>public class Test\n{\n public static void main(String[] args) {\n ...
2008/10/15
[ "https://Stackoverflow.com/questions/204970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25778/" ]
Suppose I have following string: ``` String asd = "this is test ass this is test" ``` and I want to split the string using "ass" character sequence. I used: ``` asd.split("ass"); ``` It doesn't work. What do I need to do?
``` public class Splitter { public static void main(final String[] args) { final String asd = "this is test ass this is test"; final String[] parts = asd.split("ass"); for (final String part : parts) { System.out.println(part); } } } ``` Prints: ``` this is test ...
204,983
<p>If you want to associate some constant value with a class, here are two ways to accomplish the same goal:</p> <pre><code>class Foo { public: static const size_t Life = 42; }; class Bar { public: enum {Life = 42}; }; </code></pre> <p>Syntactically and semantically they appear to be identical from the clien...
[ { "answer_id": 204999, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "<p>They're not identical:</p>\n\n<pre><code>size_t *pLife1 = &amp;Foo::Life;\nsize_t *pLife2 = &amp;Bar::Life;\n</code></pre>\...
2008/10/15
[ "https://Stackoverflow.com/questions/204983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/241536/" ]
If you want to associate some constant value with a class, here are two ways to accomplish the same goal: ``` class Foo { public: static const size_t Life = 42; }; class Bar { public: enum {Life = 42}; }; ``` Syntactically and semantically they appear to be identical from the client's point of view: ``` si...
The `enum` hack used to be necessary because many compilers didn't support in-place initialization of the value. Since this is no longer an issue, go for the other option. Modern compilers are also capable of optimizing this constant so that no storage space is required for it. The only reason for not using the `stati...
204,991
<p>I'm not quite sure how this happened, but somehow a completely empty hierarchy of directories has ended up in my repository:</p> <pre><code>com/ com/companyname/ com/companyname/blah/ com/sun/ com/sun/java/ com/sun/java/jax_rpc_ri/ </code></pre> <p>I think what happened was that these directories did have files in...
[ { "answer_id": 205038, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 6, "selected": true, "text": "<p>AFAIK the CVS protocol does not allow to remove directories. You should go to the server console and remove them fr...
2008/10/15
[ "https://Stackoverflow.com/questions/204991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
I'm not quite sure how this happened, but somehow a completely empty hierarchy of directories has ended up in my repository: ``` com/ com/companyname/ com/companyname/blah/ com/sun/ com/sun/java/ com/sun/java/jax_rpc_ri/ ``` I think what happened was that these directories did have files in them, but then a develope...
AFAIK the CVS protocol does not allow to remove directories. You should go to the server console and remove them from the real physical repository. --- <http://www.network-theory.co.uk/docs/cvsmanual/Removingdirectories.html> > > **You don't remove the directory itself; > there is no way to do that.** > > >
205,001
<p>What's the best way to remove a page frame automatically?</p> <p>I've used this type of code before:</p> <pre><code>&lt;script language="JavaScript"&gt; setTimeout ("changePage()", 3000); function changePage() { if (self.parent.frames.length != 0) self.parent.location="http://www.example.com"; } &lt;/script&gt; </...
[ { "answer_id": 205055, "author": "Peter Bailey", "author_id": 8815, "author_profile": "https://Stackoverflow.com/users/8815", "pm_score": 0, "selected": false, "text": "<p>Do it this way if you want the frame-breaking step to not appear in the history</p>\n\n<pre><code>if ( self.location...
2008/10/15
[ "https://Stackoverflow.com/questions/205001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28260/" ]
What's the best way to remove a page frame automatically? I've used this type of code before: ``` <script language="JavaScript"> setTimeout ("changePage()", 3000); function changePage() { if (self.parent.frames.length != 0) self.parent.location="http://www.example.com"; } </script> ```
Do you mean if someone has put a frame around your content? If so, you need the following any where in your HTML page to jump out of the iframe: ``` <script type="text/javascript"> if (window.top.location != window.location) { window.top.location = window.location; } </script> ```
205,040
<p>In my SQL database, I have a one-to-many relationship, something like this:</p> <pre> Teacher Student John Alex John Mike John Sean Bob Jack Gary George Gary Paul </pre> <p>I'd like to display a table listing each teacher, with their students as a comma-delimited list, like this:</p> <pr...
[ { "answer_id": 207440, "author": "gbn", "author_id": 27535, "author_profile": "https://Stackoverflow.com/users/27535", "pm_score": 1, "selected": false, "text": "<p>Add a grouping on teacher, and use the .net Join to append the detail rows</p>\n\n<p>Join is demonstrated for multi-value p...
2008/10/15
[ "https://Stackoverflow.com/questions/205040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16911/" ]
In my SQL database, I have a one-to-many relationship, something like this: ``` Teacher Student John Alex John Mike John Sean Bob Jack Gary George Gary Paul ``` I'd like to display a table listing each teacher, with their students as a comma-delimited list, like this: ``` Teacher Studen...
I've found a simpler, straight-forward method to do this -- add an expression as follows: ``` =Join(LookUpSet(Fields!TeacherName.Value, Fields!TeacherName.Value, Fields!StudentName.Value, "YourTeacherDataSet"), ",") ```
205,064
<p>On Unix, is there any way that one process can change another's environment variables (assuming they're all being run by the same user)? A general solution would be best, but if not, what about the specific case where one is a child of the other?</p> <p>Edit: How about via gdb?</p>
[ { "answer_id": 205074, "author": "Mike G.", "author_id": 18901, "author_profile": "https://Stackoverflow.com/users/18901", "pm_score": 1, "selected": false, "text": "<p>If your unix supports the /proc filesystem, then it's trivial to READ the env - you can read the environment, commandli...
2008/10/15
[ "https://Stackoverflow.com/questions/205064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
On Unix, is there any way that one process can change another's environment variables (assuming they're all being run by the same user)? A general solution would be best, but if not, what about the specific case where one is a child of the other? Edit: How about via gdb?
Via gdb: ``` (gdb) attach process_id (gdb) call putenv ("env_var_name=env_var_value") (gdb) detach ``` This is quite a nasty hack and should only be done in the context of a debugging scenario, of course.
205,073
<p>This is probably a simple answer but I can't find it. I have a table with a column of integers and I want to ensure that when a row is inserted that the value in this column is greater than zero. I could do this on the code side but thought it would be best to enforce it on the table.</p> <p>Thanks!</p> <p>I was...
[ { "answer_id": 205093, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 3, "selected": false, "text": "<p>Create a database constraint:</p>\n\n<pre><code>ALTER TABLE Table1 ADD CONSTRAINT Constraint1 CHECK (YourCol &gt; 0)\n<...
2008/10/15
[ "https://Stackoverflow.com/questions/205073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2357/" ]
This is probably a simple answer but I can't find it. I have a table with a column of integers and I want to ensure that when a row is inserted that the value in this column is greater than zero. I could do this on the code side but thought it would be best to enforce it on the table. Thanks! I was in error with my l...
You can use a check constraint on the column. IIRC the syntax for this looks like: ``` create table foo ( [...] ,Foobar int not null check (Foobar > 0) [...] ) ``` As the poster below says (thanks Constantin), you should create the check constraint outside the table definition and give it a meaningful nam...
205,087
<p>We are using jQuery <a href="http://jquery.com/demo/thickbox/" rel="noreferrer">thickbox</a> to dynamically display an iframe when someone clicks on a picture. In this iframe, we are using <a href="http://devkick.com/lab/galleria/demo_01.htm" rel="noreferrer">galleria</a> a javascript library to display multiple pi...
[ { "answer_id": 205221, "author": "Pier Luigi", "author_id": 27789, "author_profile": "https://Stackoverflow.com/users/27789", "pm_score": 9, "selected": true, "text": "<p>I answered a similar question (see <a href=\"https://stackoverflow.com/questions/164085/javascript-callback-when-ifra...
2008/10/15
[ "https://Stackoverflow.com/questions/205087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9140/" ]
We are using jQuery [thickbox](http://jquery.com/demo/thickbox/) to dynamically display an iframe when someone clicks on a picture. In this iframe, we are using [galleria](http://devkick.com/lab/galleria/demo_01.htm) a javascript library to display multiple pictures. The problem seems to be that `$(document).ready` in...
I answered a similar question (see [Javascript callback when IFRAME is finished loading?](https://stackoverflow.com/questions/164085/javascript-callback-when-iframe-is-finished-loading)). You can obtain control over the iframe load event with the following code: ``` function callIframe(url, callback) { $(document....
205,112
<p>Is there any way to print in memory collection or variable size in WPF? </p> <p>I am using the following code in which I print the ListView control. But when the content is larger than the vertical scroll bar takes over and cuts the content. </p> <pre><code> PrintDialog printDialog = new PrintDialog(); ...
[ { "answer_id": 205148, "author": "Artur Carvalho", "author_id": 1013, "author_profile": "https://Stackoverflow.com/users/1013", "pm_score": -1, "selected": false, "text": "<p>Interesting, Is the ListView virtualized? If it is, the object are not drawn, that is a possibility. Take a look ...
2008/10/15
[ "https://Stackoverflow.com/questions/205112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3797/" ]
Is there any way to print in memory collection or variable size in WPF? I am using the following code in which I print the ListView control. But when the content is larger than the vertical scroll bar takes over and cuts the content. ``` PrintDialog printDialog = new PrintDialog(); printDialog.Show...
To print multiple pages you just need to use a class that implements DocumentPaginator FixedDocument is one of the more complex implementations, FlowDocument is a simpler one. ``` FlowDocument fd = new FlowDocument(); foreach(object item in items) { fd.Blocks.Add(new Paragraph(new Run(item.ToString()))); } fd.Pr...
205,114
<p>I have an asp.net 2.0 page that contains 2 <code>UpdatePanels</code>.</p> <p>The first panel contains a <code>TreeView</code> control, when I select a node in the three view control it triggers an update of the second <code>UpdatePanel</code> only. This much is behaving correctly.</p> <p>There are two buttons on t...
[ { "answer_id": 205464, "author": "Dave Anderson", "author_id": 371, "author_profile": "https://Stackoverflow.com/users/371", "pm_score": 0, "selected": false, "text": "<p>I think you're right about the AJAX partial page postback that it doesn't update the hidden input __ViewState.</p>\n\...
2008/10/15
[ "https://Stackoverflow.com/questions/205114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18107/" ]
I have an asp.net 2.0 page that contains 2 `UpdatePanels`. The first panel contains a `TreeView` control, when I select a node in the three view control it triggers an update of the second `UpdatePanel` only. This much is behaving correctly. There are two buttons on the page outside of an update panel (previous/next)...
From [UpdatePanel Control Overview [asp.net]](http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx) > > ### Controls that Are Not Compatible with UpdatePanel Controls > > > The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside an ...
205,154
<p>I'm exploring git to see how it might work for my company. I've got git installed and I need to know a couple things:</p> <ul> <li>How can I set up a git server on my computer to act as my central repo?</li> <li>I'm trying to figure out how to manage my workflow with just the GUI on Windows (using the GUI is a requ...
[ { "answer_id": 205295, "author": "Grant Limberg", "author_id": 27314, "author_profile": "https://Stackoverflow.com/users/27314", "pm_score": 2, "selected": false, "text": "<p>In order to get started, you're going to have to use the command line. </p>\n\n<p>First you'll want to initializ...
2008/10/15
[ "https://Stackoverflow.com/questions/205154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
I'm exploring git to see how it might work for my company. I've got git installed and I need to know a couple things: * How can I set up a git server on my computer to act as my central repo? * I'm trying to figure out how to manage my workflow with just the GUI on Windows (using the GUI is a requirement). How do I ta...
In order to get started, you're going to have to use the command line. First you'll want to initialize a local repo in place. cd to the folder your files that you want under version control and issue: ``` git init ``` You've now initialized a git repository in that foleder. Now you need to add all of the files to ...
205,158
<p>Sorry, that title just hurts. I'm wondering if there is a Linq to collections extension method that collapses the following code segment into a single line:</p> <pre><code>public IEnumerable&lt;Child&gt; GetAllChildren(IEnumerable&lt;Parent&gt; parents){ var result = new List&lt;Child&gt;(); foreach(Parent p...
[ { "answer_id": 205169, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 3, "selected": false, "text": "<p>This will work:</p>\n\n<pre><code>public IEnumerable&lt;Child&gt; GetAllChildren(IEnumerable&lt;Parent&gt; parents...
2008/10/15
[ "https://Stackoverflow.com/questions/205158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Sorry, that title just hurts. I'm wondering if there is a Linq to collections extension method that collapses the following code segment into a single line: ``` public IEnumerable<Child> GetAllChildren(IEnumerable<Parent> parents){ var result = new List<Child>(); foreach(Parent parent in parents) foreach(Chi...
Here's the obligatory method form. ``` return parents .SelectMany(p => p.Children); ``` And for two levels: ``` return oldies .SelectMany(grand => grand.Children) .SelectMany(parent => parent.Children); ```
205,159
<p>I would like to execute <code>ls</code> in a Perl program as part of a CGI script. For this I used <code>exec(ls)</code>, but this does not return from the <code>exec</code> call.</p> <p>Is there a better way to get a listing of a directory in Perl?</p>
[ { "answer_id": 205168, "author": "holli", "author_id": 18606, "author_profile": "https://Stackoverflow.com/users/18606", "pm_score": 3, "selected": false, "text": "<p>In order to get the output of a system command you need to use backticks.</p>\n\n<pre><code>$listing = `ls`;\n</code></pr...
2008/10/15
[ "https://Stackoverflow.com/questions/205159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28280/" ]
I would like to execute `ls` in a Perl program as part of a CGI script. For this I used `exec(ls)`, but this does not return from the `exec` call. Is there a better way to get a listing of a directory in Perl?
Exec doesn't return at all. If you wanted that, use system. If you just want to read a directory, open/read/close-dir may be more appropriate. ``` opendir my($dh), $dirname or die "Couldn't open dir '$dirname': $!"; my @files = readdir $dh; closedir $dh; #print files... ```
205,182
<p>Is there a way of reusing the same resultMap multiple times in a single query.</p> <p>For example, suppose I have a "foo" resultMap:</p> <pre><code>&lt;resultMap id="foo" class="Foo"&gt; &lt;result property="Bar" column="bar" /&gt; &lt;/resultMap&gt; </code></pre> <p>Is there a way to define another resultMap t...
[ { "answer_id": 205257, "author": "James Rose", "author_id": 9703, "author_profile": "https://Stackoverflow.com/users/9703", "pm_score": 3, "selected": true, "text": "<p>Almost. If you select the ID of the Foo in your query, you can have the Fizz result map execute a SELECT for that ID, ...
2008/10/15
[ "https://Stackoverflow.com/questions/205182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4094/" ]
Is there a way of reusing the same resultMap multiple times in a single query. For example, suppose I have a "foo" resultMap: ``` <resultMap id="foo" class="Foo"> <result property="Bar" column="bar" /> </resultMap> ``` Is there a way to define another resultMap that reuses the above for different columns? Somethi...
Almost. If you select the ID of the Foo in your query, you can have the Fizz result map execute a SELECT for that ID, which will use the Foo result map. `<result property="Foo1" column="bar1Id" select="selectFoo"/>` (Assuming you have a `selectFoo` query defined.) But that's extremely slow with large result sets, sin...
205,188
<p>There seems to be lots of different ways to register assemblies with the GAC, as in, they 'work'. However, what's the "proper" way of doing it?</p> <p>In response to Lou Franco (and gacutil):</p> <p>I'm using Gacutil for development, but it seems to me to be not the proper way to install it, since gacutil isn't i...
[ { "answer_id": 205192, "author": "Robert P", "author_id": 18097, "author_profile": "https://Stackoverflow.com/users/18097", "pm_score": 0, "selected": false, "text": "<p>use gacutil. </p>\n\n<p>Advantages: seems to always work.\nDisadvantages:</p>\n\n<ul>\n<li>must package an additional...
2008/10/15
[ "https://Stackoverflow.com/questions/205188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18097/" ]
There seems to be lots of different ways to register assemblies with the GAC, as in, they 'work'. However, what's the "proper" way of doing it? In response to Lou Franco (and gacutil): I'm using Gacutil for development, but it seems to me to be not the proper way to install it, since gacutil isn't included in the bas...
With Wix I would do something like this: ``` <DirectoryRef Id="MyDirectory" > <Component Id="MyComponent" Guid="PUT-GUID-HERE" DiskId="1"> <File Id="MyAssembly" Name="MyAssembly.dll" Assembly=".net" KeyPath="yes" Source="MyAssembly.dll" /> </Component> </DirectoryRef> ``` When you use the attribute ...
205,190
<p>Clearly the following is incorrect.</p> <pre><code>INSERT INTO `aTable` (`A`,`B`) VALUES((SELECT MAX(`A`) FROM `aTable`)*2),'name'); </code></pre> <p>I get the value:</p> <p>SQL query: </p> <pre><code>INSERT INTO `aTable` (`A`, `B` ) VALUES ( ( SELECT MAX(`A`) FROM `aTable` ) *2 , 'name' ) </code></p...
[ { "answer_id": 205195, "author": "stephenbayer", "author_id": 18893, "author_profile": "https://Stackoverflow.com/users/18893", "pm_score": 2, "selected": false, "text": "<p>I think you need to drop the \"VALUES\", and have a valid select statement.</p>\n\n<p><a href=\"http://dev.mysql.c...
2008/10/15
[ "https://Stackoverflow.com/questions/205190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/144/" ]
Clearly the following is incorrect. ``` INSERT INTO `aTable` (`A`,`B`) VALUES((SELECT MAX(`A`) FROM `aTable`)*2),'name'); ``` I get the value: SQL query: ``` INSERT INTO `aTable` (`A`, `B` ) VALUES ( ( SELECT MAX(`A`) FROM `aTable` ) *2 , 'name' ) ``` MySQL said: 1093 - You can't specify target tab...
try: ``` insert into aTable select max(a)^2, 'name' from aTable; ``` or ``` insert into aTable select max(a)^2, 'name' from aTable group by B; ``` If you need a join, you can do this: ``` insert into aTable select max(a)^2, 'name' from aTable, bTable; ``` My "Server version" is "5.0.51b-community-nt MySQL Comm...
205,239
<p>Consider the following interface in Java:</p> <pre><code>public interface I { public final String KEY = "a"; } </code></pre> <p>And the following class:</p> <pre><code>public class A implements I { public String KEY = "b"; public String getKey() { return KEY; } } </code></pre> <p>Why is ...
[ { "answer_id": 205249, "author": "Bill K", "author_id": 12943, "author_profile": "https://Stackoverflow.com/users/12943", "pm_score": 5, "selected": false, "text": "<p>You are hiding it, it's a feature of \"Scope\". Any time you are in a smaller scope, you can redefine all the variables...
2008/10/15
[ "https://Stackoverflow.com/questions/205239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24545/" ]
Consider the following interface in Java: ``` public interface I { public final String KEY = "a"; } ``` And the following class: ``` public class A implements I { public String KEY = "b"; public String getKey() { return KEY; } } ``` Why is it possible for class A to come along and overrid...
Despite the fact that you are shadowing the variable it's quite interesting to know that you can change final fields in java as you can read [here](http://www.javaspecialists.co.za/archive/Issue096.html): > > **Java 5 - "final" is not final anymore** > > > Narve Saetre from Machina Networks in Norway sent me a note...
205,240
<p>Is it possible with Axis2 and Eclipse to generate a Web Service client and have it use java types that you already have in packages instead of creating it's own types. Reason being of course if I have type A already created and it creates it's own Type A I can't just assign variable of type A to variable of type B....
[ { "answer_id": 205356, "author": "Michael Sharek", "author_id": 1958, "author_profile": "https://Stackoverflow.com/users/1958", "pm_score": 1, "selected": false, "text": "<p>You are generating the web service client from wsdl, correct?</p>\n\n<p>The only thing that the wsdl2java tool kno...
2008/10/15
[ "https://Stackoverflow.com/questions/205240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28288/" ]
Is it possible with Axis2 and Eclipse to generate a Web Service client and have it use java types that you already have in packages instead of creating it's own types. Reason being of course if I have type A already created and it creates it's own Type A I can't just assign variable of type A to variable of type B. Th...
If you really want to reuse existing classes, you can call the Axis2 API directly without generating a client using wsdl2java. Below is some relatively simple code to call a web service. You just need to fill in the web service endpoint, method QName, expected return Class(es), and arguments to the service. You could r...
205,270
<p>My MFC application using the "ESRI MapObjects LT2" ActiveX plugin throws an ASSERT at me when closing it. The error occurs in <code>cmdtarg.cpp</code>:</p> <pre><code>CCmdTarget::~CCmdTarget() { #ifndef _AFX_NO_OLE_SUPPORT if (m_xDispatch.m_vtbl != 0) ((COleDispatchImpl*)&amp;m_xDispatch)-&gt;Disconnect...
[ { "answer_id": 205449, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 2, "selected": false, "text": "<p>That looks like a reference count. Could this \"target\" be referenced by something else, something that's not releas...
2008/10/15
[ "https://Stackoverflow.com/questions/205270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27596/" ]
My MFC application using the "ESRI MapObjects LT2" ActiveX plugin throws an ASSERT at me when closing it. The error occurs in `cmdtarg.cpp`: ``` CCmdTarget::~CCmdTarget() { #ifndef _AFX_NO_OLE_SUPPORT if (m_xDispatch.m_vtbl != 0) ((COleDispatchImpl*)&m_xDispatch)->Disconnect(); ASSERT(m_dwRef <= 1); //...
The following solved it for me: In the window that contains the control, add an OnDestroy() handler: ``` void CMyWnd::OnDestroy() { // Apparently we have to disconnect the (ActiveX) Map control manually // with this undocumented method. COleControlSite* pSite = GetOleControlSite(MY_DIALOG_CONTROL_ID); ...
205,287
<p>I am writing an XML document in C#.</p> <p>I have something like this...</p> <pre><code>string output = "REAPP DUE NO OF M CASE NBR APPL NBR DATE GRPS M CASE NBR APPL NBR DATE GRPS _ _ _"; </code></pre> <p>and I do t...
[ { "answer_id": 205298, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 3, "selected": true, "text": "<p>GridView has a DataKeyNames property. When you bind a data source to the grid, you set the DataKeyNames (usually wit...
2008/10/15
[ "https://Stackoverflow.com/questions/205287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6161/" ]
I am writing an XML document in C#. I have something like this... ``` string output = "REAPP DUE NO OF M CASE NBR APPL NBR DATE GRPS M CASE NBR APPL NBR DATE GRPS _ _ _"; ``` and I do this... ``` objXmlTextWri...
GridView has a DataKeyNames property. When you bind a data source to the grid, you set the DataKeyNames (usually with just one name, your PK field). You don't show the PK, but you can get to it from code-behind.
205,299
<p>I tried the following code in LINQPad and got the results given below:</p> <pre><code>List&lt;string&gt; listFromSplit = new List&lt;string&gt;("a, b".Split(",".ToCharArray())).Dump(); listFromSplit.ForEach(delegate(string s) { s.Trim(); }); listFromSplit.Dump(); </code></pre> <blockquote> <p>"a" and " b"</...
[ { "answer_id": 205306, "author": "Sciolist", "author_id": 16045, "author_profile": "https://Stackoverflow.com/users/16045", "pm_score": 4, "selected": false, "text": "<p>you're just creating a trimmed string, not assigning anything to it.</p>\n\n<pre><code>var s = \" asd \";\ns.Trim()...
2008/10/15
[ "https://Stackoverflow.com/questions/205299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5351/" ]
I tried the following code in LINQPad and got the results given below: ``` List<string> listFromSplit = new List<string>("a, b".Split(",".ToCharArray())).Dump(); listFromSplit.ForEach(delegate(string s) { s.Trim(); }); listFromSplit.Dump(); ``` > > "a" and " b" > > > so the letter b didn't get the white-sp...
The String.Trim() method returns a string representing the updated string. It does not update the string object itself, but rather creates a new one. You could do this: ``` s = s.Trim(); ``` However you cannot update a collection while enumerating through it so you'd want to either fill a new List while enumerating...
205,340
<p>I'm getting odd results from a <code>MySQL SELECT</code> query involving a <code>LEFT JOIN</code>, and I can't understand whether my understanding of <code>LEFT JOIN</code> is wrong or whether I'm seeing a genuinely odd behavior.</p> <p>I have a two tables with a many-to-one relationship: For every record in <code>...
[ { "answer_id": 205365, "author": "thoroughly", "author_id": 8943, "author_profile": "https://Stackoverflow.com/users/8943", "pm_score": 2, "selected": false, "text": "<p>I think you mean to group by d.dateId.</p>\n" }, { "answer_id": 205370, "author": "leif", "author_id":...
2008/10/15
[ "https://Stackoverflow.com/questions/205340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28299/" ]
I'm getting odd results from a `MySQL SELECT` query involving a `LEFT JOIN`, and I can't understand whether my understanding of `LEFT JOIN` is wrong or whether I'm seeing a genuinely odd behavior. I have a two tables with a many-to-one relationship: For every record in `table 1` there are 0 or more records in `table 2...
You need to `GROUP BY d.dateID`. In two of your cases, `s.DateID` is `NULL` (`LEFT JOIN`) and these are combined together. I think you will also find that this is invalid (ANSI) SQL, because d.date is not part of a `GROUP BY` or the result of an aggregate operation, and should not be able to be `SELECT`ed.
205,351
<p>This case arises in a real-life situation where invalid data was in (and continuing to come into) an Oracle database which is extracted into a data processing system in Focus. Focus would choke and die on some rows with invalid time portions. The Oracle DBA would then go and copy the datetime into the affected col...
[ { "answer_id": 205412, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 1, "selected": false, "text": "<p>I cannot seem to find the bug in a quick Metalink search (if you haven't opened a SR with Oracle yet, I'd suggest d...
2008/10/15
[ "https://Stackoverflow.com/questions/205351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18255/" ]
This case arises in a real-life situation where invalid data was in (and continuing to come into) an Oracle database which is extracted into a data processing system in Focus. Focus would choke and die on some rows with invalid time portions. The Oracle DBA would then go and copy the datetime into the affected column f...
Oracle generally doesn't allow it. The OCI layer can bypass the data type validation - Oracle basically trusts that what you put in those seven bytes make up a valid date. Similarly, at the OCI layer, Oracle can pass back seven bytes of 'date' and it is up to the client software to do whatever it wishes with those byte...
205,359
<p>This is similar to my previous posting. But this time I want to call a function that exists on the main mxml page.</p> <p>This is my main mxml page:</p> <p>main.mxml</p> <pre><code>&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*"&gt; &lt;mx:Script&gt; &lt;![...
[ { "answer_id": 205462, "author": "Brandon", "author_id": 23133, "author_profile": "https://Stackoverflow.com/users/23133", "pm_score": 3, "selected": true, "text": "<p>Add this to menu: </p>\n\n<pre><code> &lt;mx:Metadata&gt;\n [Event(name=\"buttonClicked\", type=\"flash.events...
2008/10/15
[ "https://Stackoverflow.com/questions/205359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24563/" ]
This is similar to my previous posting. But this time I want to call a function that exists on the main mxml page. This is my main mxml page: main.mxml ``` <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*"> <mx:Script> <![CDATA[ public function changeTex...
Add this to menu: ``` <mx:Metadata> [Event(name="buttonClicked", type="flash.events.Event")] </mx:Metadata> <mx:Button x="10" y="10" width="80" label="Show" id="btnOne" click="this.showLabel=true;dispatchEvent(new Event("buttonClicked"));"/> ``` Change main to: ``` <ns1:menu id="buttons" buttonC...
205,375
<p>I have a String such as: </p> <pre><code>Cerepedia, una apliación web </code></pre> <p>I would like to transform it into something URL valid such as: </p> <pre><code>Cerepedia,unaaplicacionweb </code></pre> <p><strong>Note:</strong> the special character transformation and spaces removal. </p> <p>By the way, ar...
[ { "answer_id": 205404, "author": "extraneon", "author_id": 24582, "author_profile": "https://Stackoverflow.com/users/24582", "pm_score": 2, "selected": false, "text": "<p>Have you looked at <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLEncoder.html\" rel=\"nofollow norefe...
2008/10/15
[ "https://Stackoverflow.com/questions/205375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
I have a String such as: ``` Cerepedia, una apliación web ``` I would like to transform it into something URL valid such as: ``` Cerepedia,unaaplicacionweb ``` **Note:** the special character transformation and spaces removal. By the way, are commas allowed in URLs?
Have you looked at [URLEncoder](http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLEncoder.html)? That seems to do what you need it to do. Though the special characters will be transformed to escaped entities and not stripped from their "special" properties.
205,382
<p>I have the following C# which simply replaces parts of the input string that look like EQUIP:19d005 into URLs, like this:</p> <pre><code>input = Regex.Replace(input, @"(EQUIP:)(\S+)", @"&lt;a title=""View equipment item $2"" href=""/EquipmentDisplay.asp?eqnum=$2""&gt;$1$2&lt;/a&gt;", RegexOptions.IgnoreCase); </cod...
[ { "answer_id": 205413, "author": "John Fiala", "author_id": 9143, "author_profile": "https://Stackoverflow.com/users/9143", "pm_score": 0, "selected": false, "text": "<p>Assuming that input is a string:</p>\n\n<p><code>input = Regex.Replace(input.ToUpper, @\"(EQUIP:)(\\S+)\", @\"&lt;a ti...
2008/10/15
[ "https://Stackoverflow.com/questions/205382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7508/" ]
I have the following C# which simply replaces parts of the input string that look like EQUIP:19d005 into URLs, like this: ``` input = Regex.Replace(input, @"(EQUIP:)(\S+)", @"<a title=""View equipment item $2"" href=""/EquipmentDisplay.asp?eqnum=$2"">$1$2</a>", RegexOptions.IgnoreCase); ``` The HTML ends up looking ...
OK, 2 solutions, one inline: ``` input = Regex.Replace(input, @"(EQUIP:)(\S+)", m => string.Format(@"<a title=""View equipment item {1}"" href=""/EquipmentDisplay.asp?eqnum={2}"">{0}{1}</a>", m.Groups[1].Value, m.Groups[2].Value, m.Groups[2].Value.ToUpper()), RegexOptions.IgnoreCase); ``` The other using a separate ...
205,393
<p>Is it possible to reload a page that was loaded thru link_to_remote? I'm doing this in my controller: <br></p> <pre><code>def create if captchas_verified do_something else render :action=&gt;'new' end </code></pre> <p>But when the captchas is wrong, it do not render a form that is inside of the new template....
[ { "answer_id": 206115, "author": "jdl", "author_id": 9465, "author_profile": "https://Stackoverflow.com/users/9465", "pm_score": 1, "selected": false, "text": "<p>Something like this should do what you want.</p>\n\n<pre><code>render :update do |page| page &lt;&lt; 'window.location.reload...
2008/10/15
[ "https://Stackoverflow.com/questions/205393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18642/" ]
Is it possible to reload a page that was loaded thru link\_to\_remote? I'm doing this in my controller: ``` def create if captchas_verified do_something else render :action=>'new' end ``` But when the captchas is wrong, it do not render a form that is inside of the new template. By the way, in the webserver...
You need to `render :update`, rather than `render :action`. I do this sort of thing all the time. Similar to the response from jdl you can use inline rjs (don't know if that's the right term) to render the page. ``` render(:update) do |page| page.replace_html("div_to_update", :partial => "name_of_template", :object...
205,431
<p>I'm trying to draw images on the iPhone using with rounded corners, a la the contact images in the Contacts app. I've got code that generally work, but it occasionally crashes inside of the UIImage drawing routines with an <code>EXEC_BAD_ACCESS</code> - <code>KERN_INVALID_ADDRESS</code>. I thought this might be rela...
[ { "answer_id": 205643, "author": "Lounges", "author_id": 8918, "author_profile": "https://Stackoverflow.com/users/8918", "pm_score": 2, "selected": false, "text": "<p>I cant offer any insight into your crash, but I thought I would offer another option for rounding the corners. I had a s...
2008/10/15
[ "https://Stackoverflow.com/questions/205431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24168/" ]
I'm trying to draw images on the iPhone using with rounded corners, a la the contact images in the Contacts app. I've got code that generally work, but it occasionally crashes inside of the UIImage drawing routines with an `EXEC_BAD_ACCESS` - `KERN_INVALID_ADDRESS`. I thought this might be related to the [cropping ques...
Here is an even easier method that is available in iPhone 3.0 and up. Every View-based object has an associated layer. Each layer can have a corner radius set, this will give you just what you want: ``` UIImageView * roundedView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"wood.jpg"]]; // Get the Layer ...
205,435
<p>I keep getting an NHibernate.PersistentObjectException when calling session.Save() which is due to an uninitialized proxy passed to save(). If I fiddle with my cascade settings I can make it go away, but then child objects aren't being saved.</p> <p>The only other fix I have found is by adding the following to my ...
[ { "answer_id": 1126196, "author": "Joe", "author_id": 74776, "author_profile": "https://Stackoverflow.com/users/74776", "pm_score": 2, "selected": false, "text": "<p>Are you trying to work with a child object that is in a list on a root aggregate entity? If you are, you need to work wit...
2008/10/15
[ "https://Stackoverflow.com/questions/205435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4590/" ]
I keep getting an NHibernate.PersistentObjectException when calling session.Save() which is due to an uninitialized proxy passed to save(). If I fiddle with my cascade settings I can make it go away, but then child objects aren't being saved. The only other fix I have found is by adding the following to my DefaultSave...
Are you trying to work with a child object that is in a list on a root aggregate entity? If you are, you need to work with the root, traverse to the child, make the changes, and save the *root*, not the child.
205,440
<p>I like to know if there is a way to read the user input inside a batch file, because i have a file named: "fif.bat" that recives two parameters (just call them <strong><em>paramA</em></strong> and <strong><em>paramB</em></strong>) so i execute the file like this:</p> <pre><code>fif paramA paramB </code></pre> <p>I...
[ { "answer_id": 205461, "author": "David Webb", "author_id": 3171, "author_profile": "https://Stackoverflow.com/users/3171", "pm_score": 0, "selected": false, "text": "<p>You can prompt for user input in a batch file using <code>SET /P</code> for example:</p>\n\n<pre><code>SET /P paramB=\...
2008/10/15
[ "https://Stackoverflow.com/questions/205440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20601/" ]
I like to know if there is a way to read the user input inside a batch file, because i have a file named: "fif.bat" that recives two parameters (just call them ***paramA*** and ***paramB***) so i execute the file like this: ``` fif paramA paramB ``` I have to change paramA every month, but i call this file lot of ti...
I think this might be what you're looking for: ``` @ECHO OFF SET /p paramA=Parameter A: ECHO you typed %paramA% PAUSE ``` Line one stops commands in batch file from being echoed to the console Line two prompts the user with "Parameter A:" and waits for user to enter a value and press enter. The value goes into a var...
205,447
<p>I've got a model in CakePHP that doesn't have a table, called Upload. I've got a validation in this Model for a field called source_id.</p> <p>I've got a form that builds a nice looking $this-data, giving me a well formated set, including:</p> <pre><code>$this-&gt;data['Upload']['source_id'] </code></pre> <p>Howe...
[ { "answer_id": 205459, "author": "Justin", "author_id": 43, "author_profile": "https://Stackoverflow.com/users/43", "pm_score": 4, "selected": true, "text": "<p>I'm dumb. You have to trigger a validation check, either with a save() or</p>\n\n<pre><code>$this-&gt;Upload-&gt;set($this-&gt;...
2008/10/15
[ "https://Stackoverflow.com/questions/205447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43/" ]
I've got a model in CakePHP that doesn't have a table, called Upload. I've got a validation in this Model for a field called source\_id. I've got a form that builds a nice looking $this-data, giving me a well formated set, including: ``` $this->data['Upload']['source_id'] ``` However, the validation rule I have set...
I'm dumb. You have to trigger a validation check, either with a save() or ``` $this->Upload->set($this->data); $this->Upload->validates(); ``` Working now.
205,458
<p>For years, I've been using named blocks to limit the scope of temporary variables. I've never seen this done anywhere else, which makes me wonder if this is a bad idea. Especially since the Eclipse IDE flags these as warnings by default.</p> <p>I've used this to good effect, I think, in my own code. But since it...
[ { "answer_id": 205470, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": false, "text": "<p>I'd just go straight for refactoring into smaller methods. If a method is big enough that it needs breaking up like t...
2008/10/15
[ "https://Stackoverflow.com/questions/205458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18078/" ]
For years, I've been using named blocks to limit the scope of temporary variables. I've never seen this done anywhere else, which makes me wonder if this is a bad idea. Especially since the Eclipse IDE flags these as warnings by default. I've used this to good effect, I think, in my own code. But since it is un-idioma...
I'd just go straight for refactoring into smaller methods. If a method is big enough that it needs breaking up like this, it really needs breaking up into multiple methods if *at all* possible. While limiting scope is nice, this isn't really what named blocks are for. It's unidiomatic, which is very rarely a good thin...
205,468
<p>Hey everyone, I am researching a project where we would need to keep a value encrypted from the client all the way to a black box system without decrypting it at any point in between. We are using SSL between the browser and web server, but the values are automatically decrypted at the web server, which is what we ...
[ { "answer_id": 205484, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": false, "text": "<p>you'll want to take a look at <a href=\"http://en.wikipedia.org/wiki/Public-key_cryptography\" rel=\"nofollow noreferrer\">p...
2008/10/15
[ "https://Stackoverflow.com/questions/205468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15815/" ]
Hey everyone, I am researching a project where we would need to keep a value encrypted from the client all the way to a black box system without decrypting it at any point in between. We are using SSL between the browser and web server, but the values are automatically decrypted at the web server, which is what we need...
you'll want to take a look at [public key encryption](http://en.wikipedia.org/wiki/Public-key_cryptography). SSL protects your session (browser <-> server) but not the full transport. i'd suggest encrypting your data once it's received from the client, then sending the encrypted data all the way in. here's a terrible ...
205,521
<p>I'm trying to write a regex to replace all spaces that are not included in quotes so something like this:</p> <pre><code>a = 4, b = 2, c = "space here" </code></pre> <p>would return this:</p> <pre><code>a=4,b=2,c="space here" </code></pre> <p>I spent some time searching this site and I found a similar q/a ( <a h...
[ { "answer_id": 205581, "author": "Rômulo Ceccon", "author_id": 23193, "author_profile": "https://Stackoverflow.com/users/23193", "pm_score": 2, "selected": false, "text": "<p>I consider this very clean:</p>\n\n<pre><code>mystring.scan(/((\".*?\")|([^ ]))/).map { |x| x[0] }.join\n</code><...
2008/10/15
[ "https://Stackoverflow.com/questions/205521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to write a regex to replace all spaces that are not included in quotes so something like this: ``` a = 4, b = 2, c = "space here" ``` would return this: ``` a=4,b=2,c="space here" ``` I spent some time searching this site and I found a similar q/a ( [Split a string by spaces -- preserving quoted substr...
This seems to work: ``` result = string.gsub(/( |(".*?"))/, "\\2") ```