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
306,839
<p>Is there a way to reuse a 3rd party control reference?</p> <p>For example, I have this referenced in my App.xaml</p> <pre><code>xmlns:cust="clr-namespace:ThirdParty.Controls;assembly=ThirdParty.Controls" </code></pre> <p>I don't want to repeat this 3rd party control xml namespace on each page/control that needs a...
[ { "answer_id": 306990, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 3, "selected": true, "text": "<p>Two options I am thinking </p>\n\n<p>1) Wrap that control into a UserControl and then use your UserControl in all the pla...
2008/11/20
[ "https://Stackoverflow.com/questions/306839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29676/" ]
Is there a way to reuse a 3rd party control reference? For example, I have this referenced in my App.xaml ``` xmlns:cust="clr-namespace:ThirdParty.Controls;assembly=ThirdParty.Controls" ``` I don't want to repeat this 3rd party control xml namespace on each page/control that needs a control from the library. Is t...
Two options I am thinking 1) Wrap that control into a UserControl and then use your UserControl in all the places. 2) Declare the third party control as a Resource somewhere and then use DynamicResource reference to that on your other places. The second option can be implemented as bellow. Where ever you want the ...
306,840
<p>I have a working makefile that builds with mingw32. Now i renamed that makefile to Makefile.w32 (source -> <a href="http://pastie.org/319964" rel="nofollow noreferrer">http://pastie.org/319964</a>)</p> <p>Now i have a Makefile with the following. The problem is, it does not build my source</p> <pre><code>all: ...
[ { "answer_id": 306854, "author": "Sherm Pendley", "author_id": 27631, "author_profile": "https://Stackoverflow.com/users/27631", "pm_score": 3, "selected": true, "text": "<p>\"make Makefile.w32\" is looking for a <strong>target</strong> named Makefile.w32, not a make file by that name. T...
2008/11/20
[ "https://Stackoverflow.com/questions/306840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a working makefile that builds with mingw32. Now i renamed that makefile to Makefile.w32 (source -> <http://pastie.org/319964>) Now i have a Makefile with the following. The problem is, it does not build my source ``` all: make mingw32 clean: @echo "causes an infinite loop -> make mingw32 clean" ming...
"make Makefile.w32" is looking for a **target** named Makefile.w32, not a make file by that name. To run make and tell it to read the make file "Makefile.w32", use the -f switch: ``` make -f Makefile.w32 ``` **Edit**: Incidentally, why do you launch a separate instance of make in the "all" target, if all you want is...
306,862
<p>Today my colleagues and me have a discussion about the usage of the <code>final</code> keyword in Java to improve the garbage collection.</p> <p>For example, if you write a method like:</p> <pre><code>public Double doCalc(final Double value) { final Double maxWeight = 1000.0; final Double totalWeight = maxWe...
[ { "answer_id": 306869, "author": "benjismith", "author_id": 22979, "author_profile": "https://Stackoverflow.com/users/22979", "pm_score": 4, "selected": false, "text": "<p>Well, I don't know about the use of the \"final\" modifier in this case, or its effect on the GC.</p>\n\n<p>But I <e...
2008/11/20
[ "https://Stackoverflow.com/questions/306862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34856/" ]
Today my colleagues and me have a discussion about the usage of the `final` keyword in Java to improve the garbage collection. For example, if you write a method like: ``` public Double doCalc(final Double value) { final Double maxWeight = 1000.0; final Double totalWeight = maxWeight * value; return totalWei...
Here's a slightly different example, one with final reference-type fields rather than final value-type local variables: ``` public class MyClass { public final MyOtherObject obj; } ``` Every time you create an instance of MyClass, you'll be creating an outgoing reference to a MyOtherObject instance, and the GC ...
306,863
<p>I know this isn't really what XPath is for but if I have a HashMap of XPath expressions to values how would I go about building an XML document. I've found dom-4j's DocumentHelper.makeElement(branch, xpath) except it is incapable of creating attributes or indexing. Surely a library exists that can do this?</p> <pr...
[ { "answer_id": 306869, "author": "benjismith", "author_id": 22979, "author_profile": "https://Stackoverflow.com/users/22979", "pm_score": 4, "selected": false, "text": "<p>Well, I don't know about the use of the \"final\" modifier in this case, or its effect on the GC.</p>\n\n<p>But I <e...
2008/11/20
[ "https://Stackoverflow.com/questions/306863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I know this isn't really what XPath is for but if I have a HashMap of XPath expressions to values how would I go about building an XML document. I've found dom-4j's DocumentHelper.makeElement(branch, xpath) except it is incapable of creating attributes or indexing. Surely a library exists that can do this? ``` Map xM...
Here's a slightly different example, one with final reference-type fields rather than final value-type local variables: ``` public class MyClass { public final MyOtherObject obj; } ``` Every time you create an instance of MyClass, you'll be creating an outgoing reference to a MyOtherObject instance, and the GC ...
306,871
<p>A table exists that someone else loaded. I need to query against the table, but the lack of indexes makes the query plan abysmal. What I would like to do is detect if there is an index for a particular column, so that I can created it if it does not exist, and not create it if it is already there.</p> <p>Thanks.<...
[ { "answer_id": 306881, "author": "BQ.", "author_id": 4632, "author_profile": "https://Stackoverflow.com/users/4632", "pm_score": 2, "selected": false, "text": "<p>Become familiar with querying the SYS schema:</p>\n\n<pre><code>Select * from sys.all_ind_columns where table_name=:TabName a...
2008/11/20
[ "https://Stackoverflow.com/questions/306871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7734/" ]
A table exists that someone else loaded. I need to query against the table, but the lack of indexes makes the query plan abysmal. What I would like to do is detect if there is an index for a particular column, so that I can created it if it does not exist, and not create it if it is already there. Thanks. Evil
You can query `DBA_/ALL_/USER_IND_COLUMNS`, i.e. ``` SQL> SELECT index_name 2 FROM dba_ind_columns 3 WHERE table_owner = 'SCOTT' 4 AND table_name = 'EMP' 5 AND column_name = 'EMPNO'; INDEX_NAME ------------------------------ PK_EMP ``` Of course, you may want to expand the query a bit. This wi...
306,877
<p>I wanted to deserialize an XML message containing an element that can be marked <code>nil="true"</code> into a class with a property of type <code>int?</code>. The only way I could get it to work was to write my own <code>NullableInt</code> type which implements <code>IXmlSerializable</code>. Is there a better way t...
[ { "answer_id": 306980, "author": "Phil Jenkins", "author_id": 35496, "author_profile": "https://Stackoverflow.com/users/35496", "pm_score": 4, "selected": true, "text": "<p>I think you need to prefix the nil=\"true\" with a namespace in order for XmlSerializer to deserialise to null. </p...
2008/11/20
[ "https://Stackoverflow.com/questions/306877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12006/" ]
I wanted to deserialize an XML message containing an element that can be marked `nil="true"` into a class with a property of type `int?`. The only way I could get it to work was to write my own `NullableInt` type which implements `IXmlSerializable`. Is there a better way to do it? I wrote up the full problem and the w...
I think you need to prefix the nil="true" with a namespace in order for XmlSerializer to deserialise to null. [MSDN on xsi:nil](http://msdn.microsoft.com/en-us/library/ybce7f69(VS.80).aspx) ``` <?xml version="1.0" encoding="UTF-8"?> <entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="array"> ...
306,880
<pre><code>ArrayList &lt;String&gt; list = new ArrayList(); list.add("behold"); list.add("bend"); list.add("bet"); list.add("bear"); list.add("beat"); list.add("become"); list.add("begin"); </code></pre> <p>There is a way to search for the regexp bea.* and get the indexes like in ArrayList.indexOf ?</p> <p>EDIT: re...
[ { "answer_id": 306950, "author": "SCdF", "author_id": 1666, "author_profile": "https://Stackoverflow.com/users/1666", "pm_score": 1, "selected": false, "text": "<p>I do not believe there is a Java API way of doing this, nor is there a Apache Commons way of doing this. It would not be dif...
2008/11/20
[ "https://Stackoverflow.com/questions/306880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14015/" ]
``` ArrayList <String> list = new ArrayList(); list.add("behold"); list.add("bend"); list.add("bet"); list.add("bear"); list.add("beat"); list.add("become"); list.add("begin"); ``` There is a way to search for the regexp bea.\* and get the indexes like in ArrayList.indexOf ? EDIT: returning the items is fine but I...
Herms got the basics right. If you want the Strings and not the indexes then you can improve by using the Java 5 foreach loop: ``` import java.util.regex.Pattern; import java.util.ListIterator; import java.util.ArrayList; /** * Finds the index of all entries in the list that matches the regex * @param list The list...
306,896
<p>Is it possible to use EventListener to Listen to a variable and detect when the value of that variable changes? Thanks.</p>
[ { "answer_id": 306912, "author": "Herms", "author_id": 1409, "author_profile": "https://Stackoverflow.com/users/1409", "pm_score": 1, "selected": false, "text": "<p>You used to be able to do something similar in AS2 using Object.watch. I don't see a direct equivalent, but it looks like ...
2008/11/20
[ "https://Stackoverflow.com/questions/306896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34797/" ]
Is it possible to use EventListener to Listen to a variable and detect when the value of that variable changes? Thanks.
This is quite easy to do if you wrap it all into a class. We will be using getter/setter methods. The setter method will dispatch and event whenever it is called. (Note: Setters and Getters are treated like properties). You merely assign a value, as opposed to calling a method (e.g `someVar = 5` instead of `someVar(5...
306,901
<p>When I run a wxPython application, it prints the string &ldquo;Redirecting output to win32trace remote collector&rdquo;and I must open PythonWin's trace collector tool to view that trace output.</p> <p>Since I'm not interested in collecting this output, how should I disable this feature?</p>
[ { "answer_id": 306925, "author": "joeforker", "author_id": 36330, "author_profile": "https://Stackoverflow.com/users/36330", "pm_score": 1, "selected": false, "text": "<p>This message deceived me into thinking win32trace was preventing me from seeing uncaught exceptions in the regular co...
2008/11/20
[ "https://Stackoverflow.com/questions/306901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36330/" ]
When I run a wxPython application, it prints the string “Redirecting output to win32trace remote collector”and I must open PythonWin's trace collector tool to view that trace output. Since I'm not interested in collecting this output, how should I disable this feature?
You can even pass that when you instantiate your wx.App(): ``` if __name__ == "__main__": app = wx.App(redirect=False) #or 0 app.MainLoop() ``` [wxPython wx.App docs](http://wxpython.org/docs/api/wx.App-class.html#__init__)
306,906
<p>I would like to find all the rows in a table and match on an exact case sensitive string. Unfortunately, my table has the case insensitive collation. </p> <p>What is the most efficient way to perform this.</p> <p>Eg.</p> <p>I would like the following to return no rows:</p> <pre><code>select * from sysobject wher...
[ { "answer_id": 306918, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 4, "selected": true, "text": "<p>Here is a snippet of code that works, its really tricky to do this in a safe and efficient way. The double match is ...
2008/11/20
[ "https://Stackoverflow.com/questions/306906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
I would like to find all the rows in a table and match on an exact case sensitive string. Unfortunately, my table has the case insensitive collation. What is the most efficient way to perform this. Eg. I would like the following to return no rows: ``` select * from sysobject where name = 'Sysbinobjs' ``` For th...
Here is a snippet of code that works, its really tricky to do this in a safe and efficient way. The double match is to avoid a table scan (look at the execution plan). The varbinary casting forces a length and case match. So trailing spaces are treated properly and casing is treated properly. **Note** the type being ...
306,924
<p>Is it possible to set the size of a checkbox using CSS or HTML across browsers? </p> <p><code>width</code> and <code>size</code> work in IE6+, but not with Firefox, where the checkbox stays 16x16 even if I set a smaller size.</p>
[ { "answer_id": 306977, "author": "localshred", "author_id": 29690, "author_profile": "https://Stackoverflow.com/users/29690", "pm_score": 3, "selected": false, "text": "<p>My understanding is that this isn't easy at all to do cross-browser. Instead of trying to manipulate the checkbox co...
2008/11/20
[ "https://Stackoverflow.com/questions/306924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39474/" ]
Is it possible to set the size of a checkbox using CSS or HTML across browsers? `width` and `size` work in IE6+, but not with Firefox, where the checkbox stays 16x16 even if I set a smaller size.
It's a little ugly (due to the scaling up), but it works on most newer browsers: ```css input[type=checkbox] { /* Double-sized Checkboxes */ -ms-transform: scale(2); /* IE */ -moz-transform: scale(2); /* FF */ -webkit-transform: scale(2); /* Safari and Chrome */ -o-transform: scale(2); /* Opera */ t...
306,937
<p>What is the cast expression equivalent of VB.NET's CType in Visual Basic 6?</p>
[ { "answer_id": 306939, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 0, "selected": false, "text": "<p>Ctype() I believe. The C* (CDate(), CStr(), etc) are holdovers for the most part. </p>\n" }, { "answer_id": ...
2008/11/20
[ "https://Stackoverflow.com/questions/306937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35286/" ]
What is the cast expression equivalent of VB.NET's CType in Visual Basic 6?
There are a number of them depending on the type you are casting to ``` cint() Cast to integer cstr() cast to string clng() cast to long cdbl() cast to double cdate() cast to date ``` It also has implicit casting so you can do this myString=myInt
306,938
<p>We currently have an appserver setup where EVERYTHING is off of one big context root, and we copy class files and restart app servers to deploy. Not ideal. I'm trying to set up an ant script to do the build and deploy using wdeploy, and everything works, except I need my servlet to forward to jsps outside of the con...
[ { "answer_id": 306939, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 0, "selected": false, "text": "<p>Ctype() I believe. The C* (CDate(), CStr(), etc) are holdovers for the most part. </p>\n" }, { "answer_id": ...
2008/11/20
[ "https://Stackoverflow.com/questions/306938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12386/" ]
We currently have an appserver setup where EVERYTHING is off of one big context root, and we copy class files and restart app servers to deploy. Not ideal. I'm trying to set up an ant script to do the build and deploy using wdeploy, and everything works, except I need my servlet to forward to jsps outside of the contex...
There are a number of them depending on the type you are casting to ``` cint() Cast to integer cstr() cast to string clng() cast to long cdbl() cast to double cdate() cast to date ``` It also has implicit casting so you can do this myString=myInt
306,945
<p>I have a very long-running stored procedure in SQL Server 2005 that I'm trying to debug, and I'm using the 'print' command to do it. The problem is, I'm only getting the messages back from SQL Server at the very end of my sproc - I'd like to be able to flush the message buffer and see these messages immediately duri...
[ { "answer_id": 307005, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 9, "selected": true, "text": "<p>Use the <a href=\"http://msdn.microsoft.com/en-us/library/ms178592.aspx\" rel=\"noreferrer\"><code>RAISERROR</code><...
2008/11/20
[ "https://Stackoverflow.com/questions/306945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16942/" ]
I have a very long-running stored procedure in SQL Server 2005 that I'm trying to debug, and I'm using the 'print' command to do it. The problem is, I'm only getting the messages back from SQL Server at the very end of my sproc - I'd like to be able to flush the message buffer and see these messages immediately during ...
Use the [`RAISERROR`](http://msdn.microsoft.com/en-us/library/ms178592.aspx) function: ``` RAISERROR( 'This message will show up right away...',0,1) WITH NOWAIT ``` You shouldn't completely replace all your prints with raiserror. If you have a loop or large cursor somewhere just do it once or twice per iteration or ...
306,992
<p>I have found an example for encrypting a web.config during installation <a href="http://madtechnology.wordpress.com/2007/05/04/using-wix-to-secure-a-connection-string/" rel="nofollow noreferrer">here</a>, but my app is a windows service. The <code>aspnetreg_iis</code> method works only for web.config files.</p> <p...
[ { "answer_id": 307080, "author": "AJ.", "author_id": 27457, "author_profile": "https://Stackoverflow.com/users/27457", "pm_score": 2, "selected": false, "text": "<p>You should be able to do it within a custom action. The catch that I've found is that loading an assembly for an ExeConfig...
2008/11/20
[ "https://Stackoverflow.com/questions/306992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1865/" ]
I have found an example for encrypting a web.config during installation [here](http://madtechnology.wordpress.com/2007/05/04/using-wix-to-secure-a-connection-string/), but my app is a windows service. The `aspnetreg_iis` method works only for web.config files. I know how to programatically encrypt the config file, but...
You should be able to do it within a custom action. The catch that I've found is that loading an assembly for an ExeConfigurationFileMap will throw an exception, but you can handle that by adding an AssemblyResolve handler to the AppDomain. This is kind of a hack-up from a rich-client app I wrote to encrypt/decrypt pro...
306,996
<p>When writeing unit tests for a single class that contains other objects what's the best way to use </p> <p>mock objects to avoid tests dependant on other classes. </p> <p>Example 1:</p> <pre><code>public class MyClass { protected MyObject _obj; public MyClass() { _obj = new MyObject(); } p...
[ { "answer_id": 307184, "author": "Paul Sonier", "author_id": 28053, "author_profile": "https://Stackoverflow.com/users/28053", "pm_score": 0, "selected": false, "text": "<p>Have you tried deriving a UTMyClass from MyClass? </p>\n" }, { "answer_id": 307185, "author": "Brian R...
2008/11/20
[ "https://Stackoverflow.com/questions/306996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When writeing unit tests for a single class that contains other objects what's the best way to use mock objects to avoid tests dependant on other classes. Example 1: ``` public class MyClass { protected MyObject _obj; public MyClass() { _obj = new MyObject(); } public object DoSomething() ...
I recommend that you take a look at dependency injection. One thing is using mock objects, but unless you're using something like TypeMock, which basically lets you modify you code on the fly, you want to have a way to inject the instances your class depends on if you want to get rid of the dependencies. So in examples...
307,004
<p>On several of my usercontrols, I change the cursor by using</p> <pre><code>this.Cursor = Cursors.Wait; </code></pre> <p>when I click on something.</p> <p>Now I want to do the same thing on a WPF page on a button click. When I hover over my button, the cursor changes to a hand, but when I click it, it doesn't cha...
[ { "answer_id": 307020, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 9, "selected": true, "text": "<p>Do you need the cursor to be a \"wait\" cursor only when it's over that particular page/usercontrol? If not, I'd sugge...
2008/11/20
[ "https://Stackoverflow.com/questions/307004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
On several of my usercontrols, I change the cursor by using ``` this.Cursor = Cursors.Wait; ``` when I click on something. Now I want to do the same thing on a WPF page on a button click. When I hover over my button, the cursor changes to a hand, but when I click it, it doesn't change to the wait cursor. I wonder i...
Do you need the cursor to be a "wait" cursor only when it's over that particular page/usercontrol? If not, I'd suggest using [Mouse.OverrideCursor](http://msdn.microsoft.com/en-us/library/system.windows.input.mouse.overridecursor.aspx): ``` Mouse.OverrideCursor = Cursors.Wait; try { // do stuff } finally { Mou...
307,013
<p>This is for .NET. IgnoreCase is set and MultiLine is NOT set.</p> <p>Usually I'm decent at regex, maybe I'm running low on caffeine...</p> <p>Users are allowed to enter HTML-encoded entities (&lt;lt;, &lt;amp;, etc.), and to use the following HTML tags:</p> <pre><code>u, i, b, h3, h4, br, a, img </code></pre> <p...
[ { "answer_id": 307031, "author": "Sherm Pendley", "author_id": 27631, "author_profile": "https://Stackoverflow.com/users/27631", "pm_score": 2, "selected": false, "text": "<p>Attributes are the major problem with using regexes to try to work with HTML. Consider the sheer number of potent...
2008/11/20
[ "https://Stackoverflow.com/questions/307013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16306/" ]
This is for .NET. IgnoreCase is set and MultiLine is NOT set. Usually I'm decent at regex, maybe I'm running low on caffeine... Users are allowed to enter HTML-encoded entities (<lt;, <amp;, etc.), and to use the following HTML tags: ``` u, i, b, h3, h4, br, a, img ``` Self-closing <br/> and <img/> are allowed, wi...
Here's a function I wrote for this task: ``` static string SanitizeHtml(string html) { string acceptable = "script|link|title"; string stringPattern = @"</?(?(?=" + acceptable + @")notag|[a-zA-Z0-9]+)(?:\s[a-zA-Z0-9\-]+=?(?:(["",']?).*?\1?)?)*\s*/?>"; return Regex.Replace(html, stringPattern, "sausage"); }...
307,014
<p>A client of mine has told me the program I made for them won't connect to a SQL server named instance, I have a standard SQL server with no named instance so I'm wondering how I can test this. A named instance connection string look like the one below, could the backslash be were my code fails?</p> <p>Driver={SQL N...
[ { "answer_id": 307034, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "<p>Scott,\nAt the risk of stating the obvious, have you tried setting up a named instance in your own development environment...
2008/11/20
[ "https://Stackoverflow.com/questions/307014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
A client of mine has told me the program I made for them won't connect to a SQL server named instance, I have a standard SQL server with no named instance so I'm wondering how I can test this. A named instance connection string look like the one below, could the backslash be were my code fails? Driver={SQL Native Clie...
We have SQL servers with named instances. Examples: myservername\sql2005. Backslash is fine, in the conection string server name will be "myservername\sql2005", works 100% fine. You can have a "regular instance" on the same server, will be "myservername" PS just unit test your function making connection string returns...
307,015
<p>This isn't working. Can this be done in find? Or do I need to xargs?</p> <pre><code>find -name 'file_*' -follow -type f -exec zcat {} \| agrep -dEOE 'grep' \; </code></pre>
[ { "answer_id": 307023, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 4, "selected": false, "text": "<pre><code>find . -name \"file_*\" -follow -type f -print0 | xargs -0 zcat | agrep -dEOE 'grep'\n</code></pre>\n" }, ...
2008/11/20
[ "https://Stackoverflow.com/questions/307015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34594/" ]
This isn't working. Can this be done in find? Or do I need to xargs? ``` find -name 'file_*' -follow -type f -exec zcat {} \| agrep -dEOE 'grep' \; ```
The job of interpreting the pipe symbol as an instruction to run multiple processes and pipe the output of one process into the input of another process is the responsibility of the shell (/bin/sh or equivalent). In your example you can either choose to use your top level shell to perform the piping like so: ``` fin...
307,019
<p>The following query returns strange results for me:</p> <pre><code>SELECT `Statistics`.`StatisticID`, COUNT(`Votes`.`StatisticID`) AS `Score`, COUNT(`Views`.`StatisticID`) AS `Views`, COUNT(`Comments`.`StatisticID`) AS `Comments` FROM `Statistics` LEFT JOIN `Votes` ON `Votes`.`StatisticID` = `Statis...
[ { "answer_id": 307137, "author": "jishi", "author_id": 33663, "author_profile": "https://Stackoverflow.com/users/33663", "pm_score": 2, "selected": false, "text": "<p>When joining like this, you will duplicate the data as many times as you find mathing rows in the other tables. This is f...
2008/11/20
[ "https://Stackoverflow.com/questions/307019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2025/" ]
The following query returns strange results for me: ``` SELECT `Statistics`.`StatisticID`, COUNT(`Votes`.`StatisticID`) AS `Score`, COUNT(`Views`.`StatisticID`) AS `Views`, COUNT(`Comments`.`StatisticID`) AS `Comments` FROM `Statistics` LEFT JOIN `Votes` ON `Votes`.`StatisticID` = `Statistics`.`Statist...
Assuming you have an id field or similar on the votes/views/comments: ``` SELECT `Statistics`.`StatisticID`, COUNT(DISTINCT `Votes`.`VoteID`) AS `Score`, COUNT(DISTINCT `Views`.`ViewID`) AS `Views`, COUNT(DISTINCT `Comments`.`CommentID`) AS `Comments` FROM `Statistics` LEFT JOIN `Votes` ON `Votes`.`Sta...
307,024
<p>A link that stands out is <a href="http://www.devdaily.com/blog/post/jfc-swing/handling-main-mac-menu-in-swing-application/" rel="noreferrer">http://www.devdaily.com/blog/post/jfc-swing/handling-main-mac-menu-in-swing-application/</a> however the menu bar under Mac OS X displays as the package name as opposed to the...
[ { "answer_id": 307293, "author": "Matt Solnit", "author_id": 6198, "author_profile": "https://Stackoverflow.com/users/6198", "pm_score": 3, "selected": false, "text": "<p>You need to set the \"com.apple.mrj.application.apple.menu.about.name\" system property in the main thread, not in th...
2008/11/20
[ "https://Stackoverflow.com/questions/307024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39693/" ]
A link that stands out is <http://www.devdaily.com/blog/post/jfc-swing/handling-main-mac-menu-in-swing-application/> however the menu bar under Mac OS X displays as the package name as opposed to the application name. I'm using the code in the above link without any luck, so I'm unsure if anything's changed in recent M...
@Kezzer I think I see what's going on. If you put the main() method in a *different class*, then everything works. So you need something like: ``` public class RootGUILauncher { public static void main(String[] args) { try { System.setProperty("apple.laf.useScreenMenuBar", "true"); ...
307,027
<p>I'm wondering if this is a good design. I have a number of tables that require address information (e.g. street, post code/zip, country, fax, email). Sometimes the same address will be repeated multiple times. For example, an address may be stored against a supplier, and then on each purchase order sent to them. ...
[ { "answer_id": 307042, "author": "JohnFx", "author_id": 30018, "author_profile": "https://Stackoverflow.com/users/30018", "pm_score": 2, "selected": false, "text": "<p>Do you want to keep a historical record of what address was originally on the purchase order? </p>\n\n<p>If yes go with ...
2008/11/20
[ "https://Stackoverflow.com/questions/307027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14663/" ]
I'm wondering if this is a good design. I have a number of tables that require address information (e.g. street, post code/zip, country, fax, email). Sometimes the same address will be repeated multiple times. For example, an address may be stored against a supplier, and then on each purchase order sent to them. The su...
I actually use this as one of my interview questions. The following is a good place to start: ``` Addresses --------- AddressId (PK) Street1 ... (etc) ``` and ``` AddressTypes ------------ AddressTypeId AddressTypeName ``` and ``` UserAddresses (substitute "Company", "Account", whatever for Users) ------------- ...
307,030
<p>I have a working make, I have platform code and like several makes for each os in the folder. Right now I have one makefile which works. I renamed it to Makefile.ws and wrote this in Makefile</p> <pre><code>all: make -f Makefile.w32 clean: make -f Makefile.w32 clean </code></pre> <p>I ran it and got this ...
[ { "answer_id": 307062, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 0, "selected": false, "text": "<p>Have you tried calling the secondary makefile using</p>\n\n<p><code>$(MAKE) -f ...</code></p>\n\n<p>instead of</p>\n\n<...
2008/11/20
[ "https://Stackoverflow.com/questions/307030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a working make, I have platform code and like several makes for each os in the folder. Right now I have one makefile which works. I renamed it to Makefile.ws and wrote this in Makefile ``` all: make -f Makefile.w32 clean: make -f Makefile.w32 clean ``` I ran it and got this error ``` > "make" make ...
First, what make are you running? Cygwin or MinGW, or something else? ``` make -f Makefile.w32 make[1]: Entering directory `/c/nightly/test' make -f Makefile.w32 make[3]: Makefile.w32: No such file or directory ``` "Entering directory" is a hint. Why is it entering /c/nightly/test? Is there a Makefile.w32 there? ...
307,048
<p>Suddenly my Flex Apps can no longer connect to salesforce.com via its API, I am getting a security sandbox violation. Login credentials are correct, I have tried them via a different means, and I have obfuscated them below.</p> <p>This was working fine earlier today and I have not been coding since then.</p> <p>A...
[ { "answer_id": 307764, "author": "Chris", "author_id": 34942, "author_profile": "https://Stackoverflow.com/users/34942", "pm_score": 0, "selected": false, "text": "<p>Did you recently upgrade to flash player 10? Flash player 10 changes the way policy files work to some degree, and the cr...
2008/11/20
[ "https://Stackoverflow.com/questions/307048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24039/" ]
Suddenly my Flex Apps can no longer connect to salesforce.com via its API, I am getting a security sandbox violation. Login credentials are correct, I have tried them via a different means, and I have obfuscated them below. This was working fine earlier today and I have not been coding since then. Anyone else come ac...
You have to make sure to load the policy from the /services tree, the default policy at the root won't help you. You need to load this policy <https://www.salesforce.com/services/crossdomain.xml>
307,056
<p>What rules apply to the name that ends up in the exports section of an PE (Portable Executable)? Roughly, I see names starting with an '_' underscore, a '?' question mark or an '@' at-sign. What do those mean, and what about the rest of the name?</p> <p>Also - How can I reverse the naming convention into something ...
[ { "answer_id": 307074, "author": "PatrickvL", "author_id": 12170, "author_profile": "https://Stackoverflow.com/users/12170", "pm_score": 0, "selected": false, "text": "<p>I should have looked a little longer before asking this - as I just found an answer to this:</p>\n\n<p>It's called 'n...
2008/11/20
[ "https://Stackoverflow.com/questions/307056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12170/" ]
What rules apply to the name that ends up in the exports section of an PE (Portable Executable)? Roughly, I see names starting with an '\_' underscore, a '?' question mark or an '@' at-sign. What do those mean, and what about the rest of the name? Also - How can I reverse the naming convention into something more usab...
I think you are refering to "dll name mangling" [name mangling](http://cplus.about.com/gi/dynamic/offsite.htm?zi=1/XJ&sdn=cplus&cdn=compute&tm=4&gps=352_1578_1062_840&f=00&su=p284.9.336.ip_p504.1.336.ip_&tt=2&bt=1&bts=0&zu=http%3A//theory.uwinnipeg.ca/gnu/gcc/gxxint_15.html) It's used to make sure exports names are u...
307,060
<p>The function <a href="http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx" rel="noreferrer">CreateFileMapping</a> can be used to allocate space in the pagefile (if the first argument is <code>INVALID_HANDLE_VALUE</code>). The allocated space can later be memory mapped into the process virtual address space...
[ { "answer_id": 307106, "author": "Kieveli", "author_id": 15852, "author_profile": "https://Stackoverflow.com/users/15852", "pm_score": 3, "selected": true, "text": "<p>From the CreateFileMappingFunction:</p>\n\n<pre><code>A single file mapping object can be shared by multiple processes.\...
2008/11/20
[ "https://Stackoverflow.com/questions/307060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/755/" ]
The function [CreateFileMapping](http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx) can be used to allocate space in the pagefile (if the first argument is `INVALID_HANDLE_VALUE`). The allocated space can later be memory mapped into the process virtual address space. Why would I want to do this instead of u...
From the CreateFileMappingFunction: ``` A single file mapping object can be shared by multiple processes. ``` Can the Virtual memory be shared across multiple processes?
307,070
<p>I want to offload a block of code in my main process to child process to make it run concurrently. I also want to have the PID of the spawned child process so I can monitor and kill it if necessary.</p>
[ { "answer_id": 307088, "author": "Chris Lloyd", "author_id": 42413, "author_profile": "https://Stackoverflow.com/users/42413", "pm_score": 6, "selected": true, "text": "<p>You can use the <code>fork</code> kernel method. Here is an example:</p>\n\n<pre><code>#!/usr/bin/env ruby\nputs \"T...
2008/11/20
[ "https://Stackoverflow.com/questions/307070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42413/" ]
I want to offload a block of code in my main process to child process to make it run concurrently. I also want to have the PID of the spawned child process so I can monitor and kill it if necessary.
You can use the `fork` kernel method. Here is an example: ``` #!/usr/bin/env ruby puts "This is the master process." child_pid = fork do puts "This is the child process" exit end puts "The PID of the child process is #{child_pid}" ``` The `fork` method returns the PID of the process it forks and executes any c...
307,073
<p>Consider the "double-check idiom for lazy initialization of instance fields":</p> <blockquote><pre>// Item 71 in Effective Java copied from <a href="http://java.sun.com/developer/technicalArticles/Interviews/bloch_effective_08_qa.html" rel="nofollow noreferrer">this interview with Bloch</a>. private volatile FieldT...
[ { "answer_id": 307144, "author": "InverseFalcon", "author_id": 39455, "author_profile": "https://Stackoverflow.com/users/39455", "pm_score": 2, "selected": false, "text": "<p>I think this should be safe, but only because you're storing the field in a local variable. After this is done, ...
2008/11/20
[ "https://Stackoverflow.com/questions/307073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39489/" ]
Consider the "double-check idiom for lazy initialization of instance fields": > > ``` > // Item 71 in Effective Java copied from [this interview with Bloch](http://java.sun.com/developer/technicalArticles/Interviews/bloch_effective_08_qa.html). > private volatile FieldType field; > FieldType getField() { > FieldT...
Yes, this is thread safe. The synchronized block is to prevent multiple threads from unnecessarily calling `computeFieldValue()`. Since `field` is volatile, the accesses in `reset` and `getField` are all well-ordered. If the first check is non-null, `getField` is done; `result` is returned. Otherwise, a lock is acqu...
307,082
<p>What is the shortest chunk of C++ you can come up with to safely clean up a <code>std::vector</code> or <code>std::list</code> of pointers? (assuming you have to call delete on the pointers?)</p> <pre><code>list&lt;Foo*&gt; foo_list; </code></pre> <p>I'd rather not use Boost or wrap my pointers with smart pointers....
[ { "answer_id": 307090, "author": "John Dibling", "author_id": 241536, "author_profile": "https://Stackoverflow.com/users/241536", "pm_score": 3, "selected": false, "text": "<pre><code>template&lt; typename T &gt;\nstruct delete_ptr : public std::unary_function&lt;T,bool&gt;\n{\n bool o...
2008/11/20
[ "https://Stackoverflow.com/questions/307082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23524/" ]
What is the shortest chunk of C++ you can come up with to safely clean up a `std::vector` or `std::list` of pointers? (assuming you have to call delete on the pointers?) ``` list<Foo*> foo_list; ``` I'd rather not use Boost or wrap my pointers with smart pointers.
Since we are throwing down the gauntlet here... "Shortest chunk of C++" ``` static bool deleteAll( Foo * theElement ) { delete theElement; return true; } foo_list . remove_if ( deleteAll ); ``` I think we can trust the folks who came up with STL to have efficient algorithms. Why reinvent the wheel?
307,084
<p>The .net framework 3.5 (or vista) provides me with an English voice (David I think) to use with the Speech.Synthesis api. I need a french voice to use with a french dictation practice app I am building for my kids to use to improve their french spelling. The api allows me to change culture when creating a voice, but...
[ { "answer_id": 307090, "author": "John Dibling", "author_id": 241536, "author_profile": "https://Stackoverflow.com/users/241536", "pm_score": 3, "selected": false, "text": "<pre><code>template&lt; typename T &gt;\nstruct delete_ptr : public std::unary_function&lt;T,bool&gt;\n{\n bool o...
2008/11/20
[ "https://Stackoverflow.com/questions/307084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1400/" ]
The .net framework 3.5 (or vista) provides me with an English voice (David I think) to use with the Speech.Synthesis api. I need a french voice to use with a french dictation practice app I am building for my kids to use to improve their french spelling. The api allows me to change culture when creating a voice, but th...
Since we are throwing down the gauntlet here... "Shortest chunk of C++" ``` static bool deleteAll( Foo * theElement ) { delete theElement; return true; } foo_list . remove_if ( deleteAll ); ``` I think we can trust the folks who came up with STL to have efficient algorithms. Why reinvent the wheel?
307,094
<p>I have a couple of tables that I want to map to classes. The tables look like this:</p> <pre><code>Asset --------- AssetId AssetName Product --------- ProductId ProductName AssetId Disposal --------- DisposalId AssetId DisposalDate </code></pre> <p>Basically what I want to do is join the Product Table to the Dis...
[ { "answer_id": 309281, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 1, "selected": false, "text": "<p>Have you got your Disposals mapped to Products?</p>\n\n<p>Your schema doesn't unique relate a Disposal to a Product....
2008/11/20
[ "https://Stackoverflow.com/questions/307094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
I have a couple of tables that I want to map to classes. The tables look like this: ``` Asset --------- AssetId AssetName Product --------- ProductId ProductName AssetId Disposal --------- DisposalId AssetId DisposalDate ``` Basically what I want to do is join the Product Table to the Disposal table on AssetId so ...
The clean way: ``` <class name="Product" table="Product" lazy="false"> <id name="ProductId" column="ProductId" type="int"> <generator class="native" /> </id> <property name="ProductName" column="ProductName"/> <many-to-one name name="Asset" class="Asset" column="AssetId" /> </class> <class...
307,096
<p>When using tables in a CSS-based layout, I've noticed if I have a table with 4 columns (2 on the side are small for spacing, 2 in the middle are for content), when I type content in one of the two middle columns, it will stay at the top, which is perfect.</p> <p>However, if I type content in the other middle column...
[ { "answer_id": 307105, "author": "Andrew Flanagan", "author_id": 39034, "author_profile": "https://Stackoverflow.com/users/39034", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if I understand the problem entirely but you could look at the <a href=\"http://www.w3schools.com/...
2008/11/20
[ "https://Stackoverflow.com/questions/307096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
When using tables in a CSS-based layout, I've noticed if I have a table with 4 columns (2 on the side are small for spacing, 2 in the middle are for content), when I type content in one of the two middle columns, it will stay at the top, which is perfect. However, if I type content in the other middle column, and pres...
I believe the solution would be to create a rule which aligns text to the top of table cells. ``` td { vertical-align:top; } ``` As an alternative, you can use column groups and columns to specify the vertical alignment of different columns. An example: ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitiona...
307,098
<p>i get a Keyword not supported: '192.168.1.1;initial catalog'. error when trying to do this </p> <p><code>Dim cn As New SqlConnection(str)</code> </p> <p>where str is the connection string starts with '192.168.1.1;initial catalog' ... I have not specified the provider in the connection string</p>
[ { "answer_id": 307114, "author": "lomaxx", "author_id": 493, "author_profile": "https://Stackoverflow.com/users/493", "pm_score": 5, "selected": true, "text": "<p>you need to provide a properly formatted connectionstring such as:</p>\n\n<pre><code>Dim str As String\nstr = \"Data Source=m...
2008/11/20
[ "https://Stackoverflow.com/questions/307098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i get a Keyword not supported: '192.168.1.1;initial catalog'. error when trying to do this `Dim cn As New SqlConnection(str)` where str is the connection string starts with '192.168.1.1;initial catalog' ... I have not specified the provider in the connection string
you need to provide a properly formatted connectionstring such as: ``` Dim str As String str = "Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;" Dim cn As New SqlConnection(str) ```
307,120
<p>I need to set a system environment variable from a Bash script that would be available outside of the current scope. So you would normally export environment variables like this:</p> <pre><code>export MY_VAR=/opt/my_var </code></pre> <p>But I need the environment variable to be available at a system level though. ...
[ { "answer_id": 307145, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 4, "selected": false, "text": "<p>Not really - once you're running in a subprocess you can't affect your parent.</p>\n<p>There two possibilities:</p...
2008/11/20
[ "https://Stackoverflow.com/questions/307120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18228/" ]
I need to set a system environment variable from a Bash script that would be available outside of the current scope. So you would normally export environment variables like this: ``` export MY_VAR=/opt/my_var ``` But I need the environment variable to be available at a system level though. Is this possible?
This is the only way I know to do what you want: In foo.sh, you have: ``` #!/bin/bash echo MYVAR=abc123 ``` And when you want to get the value of the variable, you have to do the following: ``` $ eval "$(foo.sh)" # assuming foo.sh is in your $PATH $ echo $MYVAR #==> abc123 ``` Depending on what you want to do, ...
307,122
<p>I have the following code for a UDF but it errors with the message:</p> <blockquote> <p>Msg 156, Level 15, State 1, Procedure CalendarTable, Line 39 Incorrect syntax near the keyword 'OPTION'.</p> </blockquote> <p>is it because of my WITH statement as I can run the same code fine in a stored procedure?</p> ...
[ { "answer_id": 307166, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 0, "selected": false, "text": "<p>Are you missing a closing bracket here? (the closing bracket for \"AS RETURN (\"</p>\n" }, { "answer_id": 3...
2008/11/20
[ "https://Stackoverflow.com/questions/307122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/258/" ]
I have the following code for a UDF but it errors with the message: > > Msg 156, Level 15, State 1, Procedure > CalendarTable, Line 39 Incorrect > syntax near the keyword 'OPTION'. > > > is it because of my WITH statement as I can run the same code fine in a stored procedure? ``` SET ANSI_NULLS ON GO SET QUOTE...
No, you can't use the OPTION keyword. From the documentation: "MAXRECURSION can be used to prevent a poorly formed recursive CTE from entering into an infinite loop. The following example intentionally creates an infinite loop and uses the MAXRECURSION hint to limit the number of recursion levels to two." If you expl...
307,128
<p>I'm having trouble with this code:</p> <pre><code>NSRect itemFrame; id item; // code to assign item goes here. itemFrame.origin.y -= [item respondsToSelector:@selector(selectedHeight)] ? [item selectedHeight] : [self defaultSelectedHeight]; </code></pre> <p>This is the problematic bit:</p> <pre><code>[item sele...
[ { "answer_id": 307146, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 1, "selected": false, "text": "<p>You need to look at the declaration of your <code>selectedHeight</code> method. The problem is either that the...
2008/11/20
[ "https://Stackoverflow.com/questions/307128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm having trouble with this code: ``` NSRect itemFrame; id item; // code to assign item goes here. itemFrame.origin.y -= [item respondsToSelector:@selector(selectedHeight)] ? [item selectedHeight] : [self defaultSelectedHeight]; ``` This is the problematic bit: ``` [item selectedHeight] ``` The compiler is ass...
you want `[[item selectedHeight] floatValue]`, assuming that the selectedHeight returns an `NSNumber`.
307,141
<p>I need to test for general URLs using any protocol (http, https, shttp, ftp, svn, mysql and things I don't know about).</p> <p>My first pass is this:</p> <pre><code>\w+://(\w+\.)+[\w+](/[\w]+)(\?[-A-Z0-9+&amp;@#/%=~_|!:,.;]*)? </code></pre> <p>(<a href="http://perldoc.perl.org/perlre.html" rel="nofollow noreferre...
[ { "answer_id": 307142, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": 2, "selected": false, "text": "<p>adding that RegEx as a wiki answer:</p>\n\n<pre><code>[\\w+-]+://([a-zA-Z0-9]+\\.)+[[a-zA-Z0-9]+](/[%\\w]+)(\\?[-A-Z0-9+&amp;...
2008/11/20
[ "https://Stackoverflow.com/questions/307141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
I need to test for general URLs using any protocol (http, https, shttp, ftp, svn, mysql and things I don't know about). My first pass is this: ``` \w+://(\w+\.)+[\w+](/[\w]+)(\?[-A-Z0-9+&@#/%=~_|!:,.;]*)? ``` ([PCRE](http://perldoc.perl.org/perlre.html) and [.NET](http://msdn.microsoft.com/en-us/library/hs600312.as...
According to [RFC2396](http://www.faqs.org/rfcs/rfc2396.html): ``` ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? ```
307,148
<p>Vim is acting slow when I scroll. The cursor skips some lines when I'm pressing j/k continually.</p> <p>I'm using xterm and urxvt. In both vim acts like this.</p> <p>This happens locally, with small or big files. I do use Control + F/B they work just fine.</p> <p>EDIT: ttyfast in small files did the trick but in ...
[ { "answer_id": 307175, "author": "Jeremy Cantrell", "author_id": 18866, "author_profile": "https://Stackoverflow.com/users/18866", "pm_score": 7, "selected": true, "text": "<p>Have you tried the 'ttyfast' option? See:</p>\n\n<pre><code>:help 'ttyfast'\n</code></pre>\n\n<p>for help, and:<...
2008/11/20
[ "https://Stackoverflow.com/questions/307148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36532/" ]
Vim is acting slow when I scroll. The cursor skips some lines when I'm pressing j/k continually. I'm using xterm and urxvt. In both vim acts like this. This happens locally, with small or big files. I do use Control + F/B they work just fine. EDIT: ttyfast in small files did the trick but in bigger is the same. When...
Have you tried the 'ttyfast' option? See: ``` :help 'ttyfast' ``` for help, and: ``` :set ttyfast ``` to enable it. Also, what version are you using? And have you tried this with no customizations to see if something you've set is interfering? Run it like this to omit any of your vimrc settings and plugins: ``...
307,179
<p>Is this defined by the language? Is there a defined maximum? Is it different in different browsers?</p>
[ { "answer_id": 307194, "author": "Peter Bailey", "author_id": 8815, "author_profile": "https://Stackoverflow.com/users/8815", "pm_score": 9, "selected": false, "text": "<p><strong>&gt;= ES6:</strong></p>\n<pre><code>Number.MIN_SAFE_INTEGER;\nNumber.MAX_SAFE_INTEGER;\n</code></pre>\n<p><s...
2008/11/20
[ "https://Stackoverflow.com/questions/307179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5657/" ]
Is this defined by the language? Is there a defined maximum? Is it different in different browsers?
JavaScript has two number types: [`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) and [`BigInt`](https://developer.mozilla.org/en-US/docs/Glossary/BigInt). The most frequently-used number type, `Number`, is a 64-bit floating point [IEEE 754](https://en.wikipedia.org/...
307,183
<p>In .NET is there a function that tests if a string is syntactically a correct path? I specifically don't want it to test if the path actually exists.</p> <p>my current take on this is a regex:</p> <pre><code>([a-zA-Z]:|\\)?\\?([^/\\:*?"&lt;&gt;|]+[/\\])*[^/\\:*?"&lt;&gt;|]* </code></pre> <p>matches:</p> <pre><co...
[ { "answer_id": 307196, "author": "Aaron Palmer", "author_id": 24908, "author_profile": "https://Stackoverflow.com/users/24908", "pm_score": 2, "selected": true, "text": "<p>I'd suggest just using a regex for this since you specifically don't want to test if the path exists.</p>\n\n<p>Her...
2008/11/20
[ "https://Stackoverflow.com/questions/307183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
In .NET is there a function that tests if a string is syntactically a correct path? I specifically don't want it to test if the path actually exists. my current take on this is a regex: ``` ([a-zA-Z]:|\\)?\\?([^/\\:*?"<>|]+[/\\])*[^/\\:*?"<>|]* ``` matches: ``` c:\ bbbb \\bob/john\ ..\..\ ``` rejects: ``` xy: c...
I'd suggest just using a regex for this since you specifically don't want to test if the path exists. Here's something [google helped me dig up](http://regexlib.com/REDetails.aspx?regexp_id=425): ``` RegEx="^([a-zA-Z]\:|\\\\[^\/\\:*?"<>|]+\\[^\/\\:*?"<>|]+)(\\[^\/\\:*?"<>|]+)+(\.[^\/\\:*?"<>|]+)$" ``` You could com...
307,198
<p>I want to store a URL prefix in an Windows environment variable. The ampersands in the query string makes this troublesome though.</p> <p>For example: I have a URL prefix of <code>http://example.com?foo=1&amp;bar=</code> and want to create a full URL by providing a value for the <code>bar</code> parameter. I then w...
[ { "answer_id": 307218, "author": "wimh", "author_id": 33499, "author_profile": "https://Stackoverflow.com/users/33499", "pm_score": -1, "selected": false, "text": "<p>I think this should do it:</p>\n\n<pre><code>for /f \"tokens=*\" %i in (%myvar%) do set %myvar%=%~i\n</code></pre>\n\n<p>...
2008/11/20
[ "https://Stackoverflow.com/questions/307198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488/" ]
I want to store a URL prefix in an Windows environment variable. The ampersands in the query string makes this troublesome though. For example: I have a URL prefix of `http://example.com?foo=1&bar=` and want to create a full URL by providing a value for the `bar` parameter. I then want to launch that URL using the "st...
This is not a limitation of the environment variable, but rather the command shell. Enclose the entire assignment in quotes: ``` set "myvar=http://example.com?foo=1&bar=" ``` Though if you try to echo this, it will complain as the shell will see a break in there. You can echo it by enclosing the var name in quotes...
307,232
<p>I am very curious about the possibility of providing immutability for java beans (by beans here I mean classes with an empty constructor providing getters and setters for members). Clearly these classes are not immutable and where they are used to transport values from the data layer this seems like a real proble...
[ { "answer_id": 307283, "author": "Michael Rutherfurd", "author_id": 33889, "author_profile": "https://Stackoverflow.com/users/33889", "pm_score": 2, "selected": false, "text": "<p>Some comments (not necessarily problems):</p>\n\n<ol>\n<li>The Date class is itself mutable so you are corre...
2008/11/20
[ "https://Stackoverflow.com/questions/307232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39476/" ]
I am very curious about the possibility of providing immutability for java beans (by beans here I mean classes with an empty constructor providing getters and setters for members). Clearly these classes are not immutable and where they are used to transport values from the data layer this seems like a real problem. On...
I think I'd use the delegation pattern - make an ImmutableDate class with a single DateBean member that must be specified in the constructor: ``` public class ImmutableDate implements DateBean { private DateBean delegate; public ImmutableDate(DateBean d) { this.delegate = d; } public Date getDat...
307,236
<p>Can any one give me a scripts (HTML/CSS/Javascript) that can reproduce this error on <code>IE 7.0</code>? I am trying to fix this bug in my page where I get this warning but could not exactly found the problem. Line number does not match with the source either. </p> <p>I thought the better approach would be to crea...
[ { "answer_id": 307249, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>If you make your code follow the jslint.com rules, it will go away.\nIt will also point you at exactly where the issue is i...
2008/11/20
[ "https://Stackoverflow.com/questions/307236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3627/" ]
Can any one give me a scripts (HTML/CSS/Javascript) that can reproduce this error on `IE 7.0`? I am trying to fix this bug in my page where I get this warning but could not exactly found the problem. Line number does not match with the source either. I thought the better approach would be to create a bug and then wor...
As Shog said, that error will occur when you try to call a method on an object which doesn't have that method. This is most often caused by an object being null when you expect it to, well, not be null. ``` var myEl = document.getElementById('myElement'); myEl.appendChild(...) ``` The above example will cause that ...
307,243
<p>Ok, one for the SO hive mind...</p> <p>I have code which has - until today - run just fine on many systems and is deployed at many sites. It involves threads reading and writing data from a serial port. </p> <p>Trying to check out a new device, my code was swamped with 995 ERROR_OPERATION_ABORTED errors calling G...
[ { "answer_id": 307281, "author": "Will Dean", "author_id": 987, "author_profile": "https://Stackoverflow.com/users/987", "pm_score": 2, "selected": false, "text": "<p>How are you setting over the OVERLAPPED structure before the ReadFile? - I always zero them (other than the hEvent, obvio...
2008/11/20
[ "https://Stackoverflow.com/questions/307243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1737/" ]
Ok, one for the SO hive mind... I have code which has - until today - run just fine on many systems and is deployed at many sites. It involves threads reading and writing data from a serial port. Trying to check out a new device, my code was swamped with 995 ERROR\_OPERATION\_ABORTED errors calling GetOverlappedResu...
How are you setting over the OVERLAPPED structure before the ReadFile? - I always zero them (other than the hEvent, obviously), which is perhaps part superstition, but I have a feeling that it's caused me a problem in the past. I'm afraid blaming the driver (if it's non-MS and not just a tiny tweak from the reference)...
307,250
<p>I have a field in my form labeled "Name" that will contain both the First &amp; Last name.</p> <p>Our existing dynamic server (to which the form is being POSTed to), expects two separate fields (first name, last name). </p> <p>Can I use Javascript to split the user input into two separate variables before the form...
[ { "answer_id": 307266, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "<p>You can do something like this:</p>\n\n<pre><code>var yourForm = document.getElementById('yourFormId');\nyourform.onsubmi...
2008/11/20
[ "https://Stackoverflow.com/questions/307250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32154/" ]
I have a field in my form labeled "Name" that will contain both the First & Last name. Our existing dynamic server (to which the form is being POSTed to), expects two separate fields (first name, last name). Can I use Javascript to split the user input into two separate variables before the form is posted to the ser...
I would process this on the server end to make sure the data that is passed is accurate from what was posted. It's relatively easy programmatically to split the name, but the problem is how do you define your separator. Most would agree to split it wherever there is a white-space character, but what if they enter a thr...
307,273
<p>I have the whole MVC-Model set up and use HTML views as templates. But I have german strings in there that I would like to translate to other languages at some point.</p> <p>What is the best way to do this? I know I have to use Zend_Translate, but do I have to implement a single call to a translate function for eve...
[ { "answer_id": 308170, "author": "Stefan Gehrig", "author_id": 11354, "author_profile": "https://Stackoverflow.com/users/11354", "pm_score": 5, "selected": true, "text": "<p>First of all, I'd suggest to use complete phrases as the basis for your translation. With words you always have th...
2008/11/20
[ "https://Stackoverflow.com/questions/307273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9535/" ]
I have the whole MVC-Model set up and use HTML views as templates. But I have german strings in there that I would like to translate to other languages at some point. What is the best way to do this? I know I have to use Zend\_Translate, but do I have to implement a single call to a translate function for every word t...
First of all, I'd suggest to use complete phrases as the basis for your translation. With words you always have the problem that languages are not consistent when it comes to sentence structure. Then you have to choose one of the available Zend\_Transalate adapters: Array, Csv, Gettext, Ini, Tbx, Tmx, Qt, Xliff or Xm...
307,287
<p>I have a question about implementing caching (memoization) using arrays in Haskell. The following pattern works:</p> <pre><code>f = (fA !) where fA = listArray... </code></pre> <p>But this does not (the speed of the program suggests that the array is getting recreated each call or something):</p> <pre><code>f ...
[ { "answer_id": 307399, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 3, "selected": false, "text": "<p>The best way to find what is going on is to tell the compiler to output its intermediate representation with <code>-v4</...
2008/11/20
[ "https://Stackoverflow.com/questions/307287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a question about implementing caching (memoization) using arrays in Haskell. The following pattern works: ``` f = (fA !) where fA = listArray... ``` But this does not (the speed of the program suggests that the array is getting recreated each call or something): ``` f n = (fA ! n) where fA = listArray......
The best way to find what is going on is to tell the compiler to output its intermediate representation with `-v4`. The output is voluminous and a bit hard to read, but should allow you to find out exactly what the difference in the generated code is, and how the compiler arrived there. You will probably notice that `...
307,292
<p>I have been bitten by a poorly architected solution. It is not thread safe! </p> <p>I have several shared classes and members in the solution, and during development all was cool...<br> BizTalk has sunk my battle ship. </p> <p>We are using a custom BizTalk Adapter to call my assemblies. The Adapter is calling ...
[ { "answer_id": 307310, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "<p>Why not just put a lock around the code you want to execute sequentially?\nIt will be a bottleneck, but it should w...
2008/11/20
[ "https://Stackoverflow.com/questions/307292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1048/" ]
I have been bitten by a poorly architected solution. It is not thread safe! I have several shared classes and members in the solution, and during development all was cool... BizTalk has sunk my battle ship. We are using a custom BizTalk Adapter to call my assemblies. The Adapter is calling my code and running th...
Using app domains you could do something like this: ``` public class Loader { private string connectionString; private string fileName; private Stream stream; private DataFile dataFile; public Loader(Stream stream, string fileName, string connectionString) { this.connectionString = co...
307,294
<p>SOLVED: Nevermind, the links were visited, and the border definition was missing for visited links (as someone pointed out, thanks). As for the color being first place in the border definition, the snippet comes from the IE Developper Toolbar, this is not directly my code. Anyway, thank you guys !</p> <p>Why does t...
[ { "answer_id": 307297, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 3, "selected": true, "text": "<p>You might want to set up the style for Visited link too.</p>\n\n<p>And, I do not think you should use <code>*...
2008/11/20
[ "https://Stackoverflow.com/questions/307294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39474/" ]
SOLVED: Nevermind, the links were visited, and the border definition was missing for visited links (as someone pointed out, thanks). As for the color being first place in the border definition, the snippet comes from the IE Developper Toolbar, this is not directly my code. Anyway, thank you guys ! Why does the link in...
You might want to set up the style for Visited link too. And, I do not think you should use `*{...}` It works fine in FF3. Change to that : ``` #main A:link, A:Visited { COLOR: #437fda; BORDER-BOTTOM: #437fda 1px dashed; TEXT-DECORATION: none } ``` And change : ``` * { PADDING-RIGHT: 0px; PADDING-LEFT: 0px...
307,305
<p>What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound.</p>
[ { "answer_id": 307316, "author": "Rizwan Kassim", "author_id": 35335, "author_profile": "https://Stackoverflow.com/users/35335", "pm_score": 3, "selected": false, "text": "<p>pyMedia's sound example does <a href=\"http://pymedia.org/tut/play_wav.html\" rel=\"noreferrer\">just that</a>. T...
2008/11/20
[ "https://Stackoverflow.com/questions/307305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound.
[The Snack Sound Toolkit](http://www.speech.kth.se/snack/) can play wav, au and mp3 files. ``` s = Sound() s.read('sound.wav') s.play() ```
307,322
<p>Let's say I have some code like this:<br /></p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;Title&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;?php if (!$someCondition){ die(); } else{ #Do something } ?&gt; &lt;/body&gt; &lt;html&gt; </code></pre> <p>I hope the purpose of this code is straightforward. If...
[ { "answer_id": 307325, "author": "stalepretzel", "author_id": 1615, "author_profile": "https://Stackoverflow.com/users/1615", "pm_score": 0, "selected": false, "text": "<p>One method, which works but is not exactly what I'm looking for, would be to replace <code>die()</code> with <code>d...
2008/11/20
[ "https://Stackoverflow.com/questions/307322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
Let's say I have some code like this: ``` <html> <head><title>Title</title></head> <body> <?php if (!$someCondition){ die(); } else{ #Do something } ?> </body> <html> ``` I hope the purpose of this code is straightforward. If a certain condition is met (ie can't connect to database), then the program should d...
You should be separating out your header and footer into an separate files and functions. This makes the UI much easier to maintain and keeps things consistent for rendering the view. Couple that with using [Exception handling](http://us.php.net/Exceptions) and you're golden. ``` <?php printHeader(); // outputs the h...
307,334
<p>I was wondering if anyone has seen this issue before.</p> <p>I have two button on a webpage. When I navigate away from the page and hit the back button to return the value of one button is placed in the value of the other.</p> <p>E.g</p> <pre><code>&lt;input class="SmallData" type="submit" id="logButton" value="L...
[ { "answer_id": 310674, "author": "Thomas Hansen", "author_id": 29746, "author_profile": "https://Stackoverflow.com/users/29746", "pm_score": 0, "selected": false, "text": "<p>Mght it be because of having two submit buttons...?</p>\n\n<p>Just my \"random\" suggestion though... :)</p>\n" ...
2008/11/20
[ "https://Stackoverflow.com/questions/307334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39511/" ]
I was wondering if anyone has seen this issue before. I have two button on a webpage. When I navigate away from the page and hit the back button to return the value of one button is placed in the value of the other. E.g ``` <input class="SmallData" type="submit" id="logButton" value="Log In" tabindex="93"></input> ...
Try giving each input element a name="some\_unique\_name" attribute -- see if that helps Safari differentiate.
307,338
<p>how to create a good plugin engine for standalone executables created with pyInstaller, py2exe or similar tools? </p> <p>I do not have experience with py2exe, but pyInstaller uses an import hook to import packages from it's compressed repository. Of course I am able to import dynamically another compressed reposito...
[ { "answer_id": 307517, "author": "monkut", "author_id": 24718, "author_profile": "https://Stackoverflow.com/users/24718", "pm_score": 3, "selected": true, "text": "<p>When compiling to exe, your going to have this issue.</p>\n\n<p>The only option I can think of to allow users access with...
2008/11/20
[ "https://Stackoverflow.com/questions/307338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369629/" ]
how to create a good plugin engine for standalone executables created with pyInstaller, py2exe or similar tools? I do not have experience with py2exe, but pyInstaller uses an import hook to import packages from it's compressed repository. Of course I am able to import dynamically another compressed repository created...
When compiling to exe, your going to have this issue. The only option I can think of to allow users access with thier plugins to use any python library is to include all libraries in the exe package. It's probably a good idea to limit supported libraries to a subset, and list it in your documentation. Up to you. I'...
307,343
<p>Is it possible to forward declare an standard container in a header file? For example, take the following code:</p> <pre><code>#include &lt;vector&gt; class Foo { private: std::vector&lt;int&gt; container_; ... }; </code></pre> <p>I want to be able to do something like this:</p> <pre><code>namespace std...
[ { "answer_id": 307349, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 4, "selected": false, "text": "<p>I don't think so because the compiler would have no way of knowing how much space to allocate for the <code>containe...
2008/11/20
[ "https://Stackoverflow.com/questions/307343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
Is it possible to forward declare an standard container in a header file? For example, take the following code: ``` #include <vector> class Foo { private: std::vector<int> container_; ... }; ``` I want to be able to do something like this: ``` namespace std { template <typename T> class vector; } clas...
Declaring `vector` in the `std` namespace is **undefined behavior**. So, your code might work, but it also might not, and the compiler is under no obligation to tell you when your attempt won't work. That's a gamble, and I don't know that avoiding the inclusion of a standard C++ header is worth that. See the following...
307,348
<p>I need to create a custom control to display bmp images with alpha channel. The background can be painted in different colors and the images have shadows so I need to truly "paint" the alpha channel.</p> <p>Does anybody know how to do it?</p> <p>I also want if possible to create a mask using the alpha channel info...
[ { "answer_id": 307374, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 1, "selected": false, "text": "<p>You need to do an <a href=\"http://en.wikipedia.org/wiki/Alpha_Blend\" rel=\"nofollow noreferrer\">alpha blend</a> wi...
2008/11/20
[ "https://Stackoverflow.com/questions/307348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14053/" ]
I need to create a custom control to display bmp images with alpha channel. The background can be painted in different colors and the images have shadows so I need to truly "paint" the alpha channel. Does anybody know how to do it? I also want if possible to create a mask using the alpha channel information to know w...
The way I usually do this is via a DIBSection - a device independent bitmap that you can modify the pixels of directly. Unfortunately there isn't any MFC support for DIBSections: you have to use the Win32 function CreateDIBSection() to use it. Start by loading the bitmap as 32-bit RGBA (that is, four bytes per pixel: ...
307,352
<p>I just ran across the following error (and found the solution online, but it's not present in Stack Overflow):</p> <blockquote> <p>(.gnu.linkonce.[stuff]): undefined reference to [method] [object file]:(.gnu.linkonce.[stuff]): undefined reference to `typeinfo for [classname]'</p> </blockquote> <p>Why mig...
[ { "answer_id": 307381, "author": "cdleary", "author_id": 3594, "author_profile": "https://Stackoverflow.com/users/3594", "pm_score": 6, "selected": false, "text": "<p>This occurs when declared (non-pure) virtual functions are missing bodies. In your class definition, something like:</p>\...
2008/11/21
[ "https://Stackoverflow.com/questions/307352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
I just ran across the following error (and found the solution online, but it's not present in Stack Overflow): > > (.gnu.linkonce.[stuff]): undefined > reference to [method] [object > file]:(.gnu.linkonce.[stuff]): > undefined reference to `typeinfo for > [classname]' > > > Why might one get one of these "und...
One possible reason is because you are declaring a virtual function without defining it. When you declare it without defining it in the same compilation unit, you're indicating that it's defined somewhere else - this means the linker phase will try to find it in one of the other compilation units (or libraries). An e...
307,362
<p>I'm trying to get this:</p> <pre><code>//C.h #ifndef C_H #define C_H #include "c.h" class C { public: C(); int function(int, int); }; #endif </code></pre> <p>which is defined in this:</p> <pre><code>//c.cpp #include "c.h" C::C() { } int C::function(int a, int b) { return a * b; } </code><...
[ { "answer_id": 307373, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 0, "selected": false, "text": "<p>Which compiler / development environment are you using? Is this from the command line or an IDE?</p>\n\n<p>You need t...
2008/11/21
[ "https://Stackoverflow.com/questions/307362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to get this: ``` //C.h #ifndef C_H #define C_H #include "c.h" class C { public: C(); int function(int, int); }; #endif ``` which is defined in this: ``` //c.cpp #include "c.h" C::C() { } int C::function(int a, int b) { return a * b; } ``` to work in this: ``` //crp.cpp #includ...
It looks like your link phase is trying to create an executable from just crp.obj, **NOT** crp.obj and c.obj. How are you compling it? It should be something like (in the case of Borland, as mentioned in edit): ``` bcc32 -ecrp.exe crp.cpp c.cpp ``` You also don't need the include line within c.h, the only thing sto...
307,365
<p>I'm trying to attach a PDF attachment to an email being sent with System.Net.Mail. The attachment-adding part looks like this:</p> <pre><code>using (MemoryStream pdfStream = new MemoryStream()) { pdfStream.Write(pdfData, 0, pdfData.Length); Attachment a = new Attachment(pdfStream, string.Format("...
[ { "answer_id": 307401, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 5, "selected": true, "text": "<p>Have you tried doing a <code>pdfStream.Seek(0,SeekOrigin.Begin)</code> before creating the attachment to reset the st...
2008/11/21
[ "https://Stackoverflow.com/questions/307365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24952/" ]
I'm trying to attach a PDF attachment to an email being sent with System.Net.Mail. The attachment-adding part looks like this: ``` using (MemoryStream pdfStream = new MemoryStream()) { pdfStream.Write(pdfData, 0, pdfData.Length); Attachment a = new Attachment(pdfStream, string.Format("Receipt_{0}_{1}...
Have you tried doing a `pdfStream.Seek(0,SeekOrigin.Begin)` before creating the attachment to reset the stream to the beginning?
307,370
<p>I'm have a ADO DataSet that I'm loading from its XML file via ReadXml. The data and the schema are in separate files.</p> <p>Right now, it takes close to 13 seconds to load this DataSet. I can cut this to 700 milliseconds if I don't read the DataSet's schema and just let ReadXml infer the schema, but then the res...
[ { "answer_id": 336093, "author": "Robert Rossney", "author_id": 19403, "author_profile": "https://Stackoverflow.com/users/19403", "pm_score": 1, "selected": true, "text": "<p>It's not an answer, exactly (though it's better than nothing, which is what I've gotten so far), but after a long...
2008/11/21
[ "https://Stackoverflow.com/questions/307370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19403/" ]
I'm have a ADO DataSet that I'm loading from its XML file via ReadXml. The data and the schema are in separate files. Right now, it takes close to 13 seconds to load this DataSet. I can cut this to 700 milliseconds if I don't read the DataSet's schema and just let ReadXml infer the schema, but then the resulting DataS...
It's not an answer, exactly (though it's better than nothing, which is what I've gotten so far), but after a long time struggling with this problem I discovered that it's completely absent when my program's not running inside Visual Studio. Something I didn't mention before, which makes this even more mystifying, is ...
307,391
<p>I am using an ASP.NET <code>ModalPopupExtender</code> on a page and would like to prevent the dialog from hiding when the user presses the ok button in certain conditions. But I can't seem to find a way.</p> <p>What I am looking for is something like this</p> <pre><code>ajax:ModalPopupExtender ... OnOkScript=&quot;...
[ { "answer_id": 307396, "author": "localshred", "author_id": 29690, "author_profile": "https://Stackoverflow.com/users/29690", "pm_score": 2, "selected": false, "text": "<p>You can use either the <a href=\"http://validator.w3.org/\" rel=\"nofollow noreferrer\">W3 HTML Validator</a> or <a ...
2008/11/21
[ "https://Stackoverflow.com/questions/307391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/698/" ]
I am using an ASP.NET `ModalPopupExtender` on a page and would like to prevent the dialog from hiding when the user presses the ok button in certain conditions. But I can't seem to find a way. What I am looking for is something like this ``` ajax:ModalPopupExtender ... OnOkScript="return confirm('You sure?')" ... ``...
You can use either the [W3 HTML Validator](http://validator.w3.org/) or [HTML Tidy online](http://infohound.net/tidy/).
307,411
<p>I'm new to jQuery, and I'm totally struggling with using jQuery UI's <code>sortable</code>.</p> <p>I'm trying to put together a page to facilitate grouping and ordering of items.</p> <p>My page has a list of groups, and each group contains a list of items. I want to allow users to be able to do the following: </p...
[ { "answer_id": 310508, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 6, "selected": true, "text": "<p>Can you include the syntax you used for <code>connectWith</code>? Did you place the list of other groups inside b...
2008/11/21
[ "https://Stackoverflow.com/questions/307411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1245/" ]
I'm new to jQuery, and I'm totally struggling with using jQuery UI's `sortable`. I'm trying to put together a page to facilitate grouping and ordering of items. My page has a list of groups, and each group contains a list of items. I want to allow users to be able to do the following: > > 1. Reorder the groups > 2...
Can you include the syntax you used for `connectWith`? Did you place the list of other groups inside brackets(even if it's a selector)? That is: ``` ...sortable({connectWith:['.group'], ... } ```
307,423
<p>I have the following two files and would like the second to extend the first:</p> <ol> <li>wwwroot\site\application.cfc</li> <li>wwwroot\site\dir\application.cfc</li> </ol> <p>However, when I go to declare the component for the second file, I'm not sure what to put in the extends attribute. <strong>My problem is ...
[ { "answer_id": 307441, "author": "Peter Boughton", "author_id": 9360, "author_profile": "https://Stackoverflow.com/users/9360", "pm_score": 4, "selected": false, "text": "<p>Sean Corfield has <a href=\"http://corfield.org/blog/index.cfm/do/blog.entry/entry/Extending_Your_Root_Application...
2008/11/21
[ "https://Stackoverflow.com/questions/307423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3420/" ]
I have the following two files and would like the second to extend the first: 1. wwwroot\site\application.cfc 2. wwwroot\site\dir\application.cfc However, when I go to declare the component for the second file, I'm not sure what to put in the extends attribute. **My problem is that several dev sites (with a shared SV...
The following code is working for me. One thing I noticed though is that the application.cfc seems to get cached, so changes to the parent application cfc might not be reflected. I got around this by doing a trivial change to the child application cfc. ``` <cfcomponent output="false"> <cfset variables.higherPa...
307,433
<p>Working to get DateTimes for any time zone. I'm using DateTimeOffset, and a string, and an XmlElement attribute. When I do, I get the following error:</p> <blockquote> <p>[InvalidOperationException: 'dateTime' is an invalid value for the XmlElementAttribute.DataType property. dateTime cannot be converted t...
[ { "answer_id": 307453, "author": "user35559", "author_id": 35559, "author_profile": "https://Stackoverflow.com/users/35559", "pm_score": 0, "selected": false, "text": "<p>The datatype of the property <code>creationTimeX</code> is string while the XmlSerialization datatype is <code>DateTi...
2008/11/21
[ "https://Stackoverflow.com/questions/307433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36627/" ]
Working to get DateTimes for any time zone. I'm using DateTimeOffset, and a string, and an XmlElement attribute. When I do, I get the following error: > > [InvalidOperationException: 'dateTime' > is an invalid value for the > XmlElementAttribute.DataType property. > dateTime cannot be converted to > System.Strin...
Take a look at this StackOverflow question about serializing dates and UTC: [Best practices for DateTime serialization in .Net framework 3.5/SQL Server 2008](https://stackoverflow.com/questions/65164/best-practices-for-datetime-serialization-in-net-framework-35sql-server-2008) No need to create a special property jus...
307,437
<p>I have two directories in the same parent directory. Call the parent directory <strong>base</strong> and the children directories <strong>alpha</strong> and <strong>bravo</strong>. I want to replace <strong>alpha</strong> with <strong>bravo</strong>. The simplest method is:</p> <pre><code>rm -rf alpha mv bravo a...
[ { "answer_id": 307447, "author": "Chris Charabaruk", "author_id": 5697, "author_profile": "https://Stackoverflow.com/users/5697", "pm_score": 0, "selected": false, "text": "<p>I don't believe there's any atomic way to do this. Your best bet is to do something like this:</p>\n\n<pre><code...
2008/11/21
[ "https://Stackoverflow.com/questions/307437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20903/" ]
I have two directories in the same parent directory. Call the parent directory **base** and the children directories **alpha** and **bravo**. I want to replace **alpha** with **bravo**. The simplest method is: ``` rm -rf alpha mv bravo alpha ``` The mv command is atomic, but the rm -rf is not. Is there a simple way ...
You can do this if you use symlinks: Let's say alpha is a symlink to directory alpha\_1, and you want to switch the symlink to point to alpha\_2. Here's what that looks like before the switch: ``` $ ls -l lrwxrwxrwx alpha -> alpha_1 drwxr-xr-x alpha_1 drwxr-xr-x alpha_2 ``` To make alpha refer to alpha\_2, use ln -...
307,438
<p>In the footer of my page, I would like to add something like "last updated the xx/xx/200x" with this date being the last time a certain mySQL table has been updated.</p> <p>What is the best way to do that? Is there a function to retrieve the last updated date? Should I access to the database every time I need this...
[ { "answer_id": 307458, "author": "Kieveli", "author_id": 15852, "author_profile": "https://Stackoverflow.com/users/15852", "pm_score": -1, "selected": false, "text": "<p>Cache the query in a global variable when it is not available.</p>\n\n<p>Create a webpage to force the cache to be rel...
2008/11/21
[ "https://Stackoverflow.com/questions/307438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39474/" ]
In the footer of my page, I would like to add something like "last updated the xx/xx/200x" with this date being the last time a certain mySQL table has been updated. What is the best way to do that? Is there a function to retrieve the last updated date? Should I access to the database every time I need this value?
In later versions of MySQL you can use the `information_schema` database to tell you when another table was updated: ``` SELECT UPDATE_TIME FROM information_schema.tables WHERE TABLE_SCHEMA = 'dbname' AND TABLE_NAME = 'tabname' ``` This does of course mean opening a connection to the database. --- An alterna...
307,471
<p>i am creating a system. What i want to know is if a msg is unsupported what should it do? should i throw saying unsupported msg? should i return 0 or -1? or should i set an errno (base->errno_). Some messages i wouldnt care if there was an error (such as setBorderColour). Others i would (addText or perhaps save if i...
[ { "answer_id": 307481, "author": "Pyrolistical", "author_id": 21838, "author_profile": "https://Stackoverflow.com/users/21838", "pm_score": 0, "selected": false, "text": "<p>Personally when it comes to output graphics, I feel a silent fail is fine. It just makes your picture wrong.</p>\...
2008/11/21
[ "https://Stackoverflow.com/questions/307471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i am creating a system. What i want to know is if a msg is unsupported what should it do? should i throw saying unsupported msg? should i return 0 or -1? or should i set an errno (base->errno\_). Some messages i wouldnt care if there was an error (such as setBorderColour). Others i would (addText or perhaps save if i c...
Generally if it's C++, prefer exceptions unless performance is critical or unless you may be running in an environment (e.g. an embedded platform) that does not support exceptions. Exceptions are by far the best choice for debugging because they are very noticeable when they occur and are ignored. Further, exceptions a...
307,486
<p>I want to create a unique id but <code>uniqid()</code> is giving something like <code>'492607b0ee414'</code>. What i would like is something similar to what tinyurl gives: <code>'64k8ra'</code>. The shorter, the better. The only requirements are that it should not have an obvious order and that it should look pretti...
[ { "answer_id": 307575, "author": "Chris", "author_id": 34942, "author_profile": "https://Stackoverflow.com/users/34942", "pm_score": 4, "selected": false, "text": "<p>There are two ways to obtain a reliably unique ID: Make it so long and variable that the chances of a collision are spect...
2008/11/21
[ "https://Stackoverflow.com/questions/307486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6037/" ]
I want to create a unique id but `uniqid()` is giving something like `'492607b0ee414'`. What i would like is something similar to what tinyurl gives: `'64k8ra'`. The shorter, the better. The only requirements are that it should not have an obvious order and that it should look prettier than a seemingly random sequence ...
Make a small function that returns random letters for a given length: ``` <?php function generate_random_letters($length) { $random = ''; for ($i = 0; $i < $length; $i++) { $random .= chr(rand(ord('a'), ord('z'))); } return $random; } ``` Then you'll want to call that until it's unique, in ps...
307,494
<p>I would like to do something like the following:</p> <pre><code>def add(a, b): #some code def subtract(a, b): #some code operations = [add, subtract] operations[0]( 5,3) operations[1](5,3) </code></pre> <p>In python, is it possible to assign something like a function pointer?</p>
[ { "answer_id": 307538, "author": "Joe Ganley", "author_id": 35678, "author_profile": "https://Stackoverflow.com/users/35678", "pm_score": 6, "selected": true, "text": "<p>Did you try it? What you wrote works exactly as written. Functions are first-class objects in Python.</p>\n" }, {...
2008/11/21
[ "https://Stackoverflow.com/questions/307494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64/" ]
I would like to do something like the following: ``` def add(a, b): #some code def subtract(a, b): #some code operations = [add, subtract] operations[0]( 5,3) operations[1](5,3) ``` In python, is it possible to assign something like a function pointer?
Did you try it? What you wrote works exactly as written. Functions are first-class objects in Python.
307,500
<p>I have a table structure that looks like:</p> <pre><code>&lt;table&gt; &lt;tr id="row1"&gt; &lt;td&gt; &lt;div&gt;row 1 content1&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;row 1 content2&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;row 1 content3&lt;/div&gt; &lt;/td&gt; &lt;/t...
[ { "answer_id": 307509, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 6, "selected": true, "text": "<p>jQuery always returns a set of elements. Sometimes, the set is empty. Sometimes, it contains only one element. The beauty of t...
2008/11/21
[ "https://Stackoverflow.com/questions/307500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419/" ]
I have a table structure that looks like: ``` <table> <tr id="row1"> <td> <div>row 1 content1</div> </td> <td> <div>row 1 content2</div> </td> <td> <div>row 1 content3</div> </td> </tr> <tr id="row2"> <td> <div>row 2 content1</div> </td> <td> <div>row 2 content2</...
jQuery always returns a set of elements. Sometimes, the set is empty. Sometimes, it contains only one element. The beauty of this is that you can write code to work the same way regardless of how many elements are matched: ``` $("selector").each(function() { this.style.backgroundColor = "red"; }); ``` Fun!
307,502
<p>When you run <code>top</code> and see all running processes, I've always wanted to know just what everything actually means. e.g. all the various single-letter state codes for a running process (R = Running, S = Sleeping, etc...)</p> <p>Where can I find this?</p>
[ { "answer_id": 307506, "author": "SMB", "author_id": 26029, "author_profile": "https://Stackoverflow.com/users/26029", "pm_score": 4, "selected": false, "text": "<p>You can use the command <a href=\"https://www.man7.org/linux/man-pages/man1/top.1.html\" rel=\"nofollow noreferrer\"><code>...
2008/11/21
[ "https://Stackoverflow.com/questions/307502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39529/" ]
When you run `top` and see all running processes, I've always wanted to know just what everything actually means. e.g. all the various single-letter state codes for a running process (R = Running, S = Sleeping, etc...) Where can I find this?
The [man page](https://www.man7.org/linux/man-pages/man1/top.1.html) says what the state codes are mapped to, but not what they actually mean. From the `top` man page: ``` 'D' = uninterruptible sleep 'R' = running 'S' = sleeping 'T' = traced or stopped 'Z' = zombie ``` 'R' is the easiest; the process is ready to run...
307,503
<p>I've got a few Unix shell scripts where I need to check that certain environment variables are set before I start doing stuff, so I do this sort of thing:</p> <pre><code>if [ -z "$STATE" ]; then echo "Need to set STATE" exit 1 fi if [ -z "$DEST" ]; then echo "Need to set DEST" exit 1 fi </code></...
[ { "answer_id": 307527, "author": "Vincent Van Den Berghe", "author_id": 39259, "author_profile": "https://Stackoverflow.com/users/39259", "pm_score": 5, "selected": false, "text": "<pre><code>${MyVariable:=SomeDefault}\n</code></pre>\n\n<p>If <code>MyVariable</code> is set and not null, ...
2008/11/21
[ "https://Stackoverflow.com/questions/307503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2994/" ]
I've got a few Unix shell scripts where I need to check that certain environment variables are set before I start doing stuff, so I do this sort of thing: ``` if [ -z "$STATE" ]; then echo "Need to set STATE" exit 1 fi if [ -z "$DEST" ]; then echo "Need to set DEST" exit 1 fi ``` which is a lot of...
### Parameter Expansion The obvious answer is to use one of the special forms of parameter expansion: ``` : ${STATE?"Need to set STATE"} : ${DEST:?"Need to set DEST non-empty"} ``` Or, better (see section on 'Position of double quotes' below): ``` : "${STATE?Need to set STATE}" : "${DEST:?Need to set DEST non-empt...
307,512
<pre><code>public static IQueryable&lt;TResult&gt; ApplySortFilter&lt;T, TResult&gt;(this IQueryable&lt;T&gt; query, string columnName) where T : EntityObject { var param = Expression.Parameter(typeof(T), "o"); var body = Expression.PropertyOrField(param,columnName); var sortExpression = Expression.Lambda(body...
[ { "answer_id": 307599, "author": "JTew", "author_id": 25372, "author_profile": "https://Stackoverflow.com/users/25372", "pm_score": 3, "selected": false, "text": "<p>It seems that <a href=\"http://msdn.microsoft.com/en-us/library/bb882637.aspx\" rel=\"noreferrer\">this</a> is the way to ...
2008/11/21
[ "https://Stackoverflow.com/questions/307512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25372/" ]
``` public static IQueryable<TResult> ApplySortFilter<T, TResult>(this IQueryable<T> query, string columnName) where T : EntityObject { var param = Expression.Parameter(typeof(T), "o"); var body = Expression.PropertyOrField(param,columnName); var sortExpression = Expression.Lambda(body, param); return query....
We did something similar (not 100% the same, but similar) in a LINQ to SQL project. Here's the code: ``` public static IQueryable<T> OrderBy<T>(this IQueryable<T> source, string ordering, params object[] values) { var type = typeof(T); var property = type.GetProperty(ordering); var parameter = Expression.P...
307,514
<p>Can you program/configure Visual Studio to produce custom intellisense for your own server controls.</p> <p>eg can you get it to do this:</p> <p><a href="http://www.yart.com.au/test/vs.gif" rel="nofollow noreferrer">alt text http://www.yart.com.au/test/vs.gif</a></p> <p>for a tag of your own like:</p> <pre><code...
[ { "answer_id": 307557, "author": "x0n", "author_id": 6920, "author_profile": "https://Stackoverflow.com/users/6920", "pm_score": 1, "selected": false, "text": "<p>Bluevision have a nice plugin for Visual Studio to do this for you. Last time I looked, it was free. (yep, it's still free!)<...
2008/11/21
[ "https://Stackoverflow.com/questions/307514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24696/" ]
Can you program/configure Visual Studio to produce custom intellisense for your own server controls. eg can you get it to do this: [alt text http://www.yart.com.au/test/vs.gif](http://www.yart.com.au/test/vs.gif) for a tag of your own like: ``` <MyCompany:MyTag ... ```
You should be getting this for free (default behavior of control). Are the references all in place while you are typing the custom control? There is an attribute to hide properties from intellisense: ``` [EditorBrowsableAttribute (EditorBrowsableState.Never)] ``` Use the description attribute to provide additional...
307,531
<p>With code like the following, sometimes the child controls correctly finish their animation and sometimes they stop at random places in the middle. Why don't they work correctly?</p> <pre><code>var t:Tween; t = new Tween(child1,"x",Elastic.easeOut,0,100,2,true); t = new Tween(child1,"y", Elastic.easeOut,0,100,2,tr...
[ { "answer_id": 307535, "author": "Eric", "author_id": 4540, "author_profile": "https://Stackoverflow.com/users/4540", "pm_score": 2, "selected": false, "text": "<p>Each tween must be assigned to a separate variable in global scope. The following code behaves reliably:</p>\n\n<pre><code>...
2008/11/21
[ "https://Stackoverflow.com/questions/307531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4540/" ]
With code like the following, sometimes the child controls correctly finish their animation and sometimes they stop at random places in the middle. Why don't they work correctly? ``` var t:Tween; t = new Tween(child1,"x",Elastic.easeOut,0,100,2,true); t = new Tween(child1,"y", Elastic.easeOut,0,100,2,true); t = new Tw...
You can also create an array in the scope of your class, then just push tweens onto that array. Although this might cause the tweens in the array to never get garbage collected, even after they finish, so you might want to empty the array yourself at points in which you know all the tweens have finished.
307,579
<p>I've got two branches that are fully merged together.</p> <p>However, after the merge is done, I realise that one file has been messed up by the merge (someone else did an auto-format, gah), and it would just be easier to change to the new version in the other branch, and then reinsert my one line change after bring...
[ { "answer_id": 307872, "author": "madlep", "author_id": 14160, "author_profile": "https://Stackoverflow.com/users/14160", "pm_score": 12, "selected": true, "text": "<p>Run this from the branch where you want the file to end up:</p>\n<pre><code>git checkout otherbranch myfile.txt\n</code>...
2008/11/21
[ "https://Stackoverflow.com/questions/307579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14160/" ]
I've got two branches that are fully merged together. However, after the merge is done, I realise that one file has been messed up by the merge (someone else did an auto-format, gah), and it would just be easier to change to the new version in the other branch, and then reinsert my one line change after bringing it ov...
Run this from the branch where you want the file to end up: ``` git checkout otherbranch myfile.txt ``` General formulas: ``` git checkout <commit_hash> <relative_path_to_file_or_dir> git checkout <remote_name>/<branch_name> <file_or_dir> ``` Some notes (from comments): * Using the commit hash, you can pull file...
307,581
<p>Relatively new to rails and trying to model a very simple family "tree" with a single Person model that has a name, gender, father_id and mother_id (2 parents). Below is basically what I want to do, but obviously I can't repeat the :children in a has_many (the first gets overwritten).</p> <pre><code>class Person &l...
[ { "answer_id": 307660, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 3, "selected": false, "text": "<p>I believe you can achieve the relationships you want using :has_one.</p>\n\n<pre><code>class Person &lt; ActiveRe...
2008/11/21
[ "https://Stackoverflow.com/questions/307581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13636/" ]
Relatively new to rails and trying to model a very simple family "tree" with a single Person model that has a name, gender, father\_id and mother\_id (2 parents). Below is basically what I want to do, but obviously I can't repeat the :children in a has\_many (the first gets overwritten). ``` class Person < ActiveRecor...
Found a simple answer on IRC that seems to work (thanks to Radar): ``` class Person < ActiveRecord::Base belongs_to :father, :class_name => 'Person' belongs_to :mother, :class_name => 'Person' has_many :children_of_father, :class_name => 'Person', :foreign_key => 'father_id' has_many :children_of_mother, :clas...
307,582
<p>I have code running in a loop and it's saving state based on the current time. Sometimes this can be just milliseconds apart, but for some reason it seems that DateTime.Now will always return values of at least 10 ms apart even if it's only 2 or 3 ms later. This presents a major problem since the state i'm saving de...
[ { "answer_id": 307592, "author": "Rohan West", "author_id": 38686, "author_profile": "https://Stackoverflow.com/users/38686", "pm_score": -1, "selected": false, "text": "<p>You could use DateTime.Now.Ticks, read the artical on <a href=\"http://msdn.microsoft.com/en-us/library/system.date...
2008/11/21
[ "https://Stackoverflow.com/questions/307582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have code running in a loop and it's saving state based on the current time. Sometimes this can be just milliseconds apart, but for some reason it seems that DateTime.Now will always return values of at least 10 ms apart even if it's only 2 or 3 ms later. This presents a major problem since the state i'm saving depen...
Curiously, your code works perfectly fine on my quad core under Win7, generating values exactly 2 ms apart almost every time. So I've done a more thorough test. Here's my example output for `Thread.Sleep(1)`. The code prints the number of ms between consecutive calls to `DateTime.UtcNow` in a loop: ![sleep 1](https:/...
307,596
<p>Does anyone know how to calculate time difference in C++ in milliseconds? I used <a href="http://linux.die.net/man/3/difftime" rel="noreferrer"><code>difftime</code></a> but it doesn't have enough precision for what I'm trying to measure.</p>
[ { "answer_id": 307604, "author": "SoapBox", "author_id": 36384, "author_profile": "https://Stackoverflow.com/users/36384", "pm_score": 2, "selected": false, "text": "<p>You can use <a href=\"http://www.manpagez.com/man/2/gettimeofday/\" rel=\"nofollow noreferrer\"><code>gettimeofday</cod...
2008/11/21
[ "https://Stackoverflow.com/questions/307596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23084/" ]
Does anyone know how to calculate time difference in C++ in milliseconds? I used [`difftime`](http://linux.die.net/man/3/difftime) but it doesn't have enough precision for what I'm trying to measure.
You have to use one of the more specific time structures, either timeval (microsecond-resolution) or timespec (nanosecond-resolution), but you can do it manually fairly easily: ``` #include <time.h> int diff_ms(timeval t1, timeval t2) { return (((t1.tv_sec - t2.tv_sec) * 1000000) + (t1.tv_usec - t2.t...
307,610
<p>I keep seeing people say that exceptions are slow, but I never see any proof. So, instead of asking if they are, I will ask how do exceptions work behind the scenes, so I can make decisions of when to use them and whether they are slow.</p> <p>From what I know, exceptions are the same as doing a return bunch of tim...
[ { "answer_id": 307621, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 4, "selected": false, "text": "<p>There are a number of ways you could implement exceptions, but typically they will rely on some underlying support fro...
2008/11/21
[ "https://Stackoverflow.com/questions/307610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I keep seeing people say that exceptions are slow, but I never see any proof. So, instead of asking if they are, I will ask how do exceptions work behind the scenes, so I can make decisions of when to use them and whether they are slow. From what I know, exceptions are the same as doing a return bunch of times, except...
Instead of guessing, I decided to actually look at the generated code with a small piece of C++ code and a somewhat old Linux install. ``` class MyException { public: MyException() { } ~MyException() { } }; void my_throwing_function(bool throwit) { if (throwit) throw MyException(); } void another...
307,619
<p>My code works (yeah!) which sends json to a server.. would appreciate any thoughts on refactoring</p> <p>1) My C# code sends this json to the server</p> <p>{\"firstName\":\"Bill\",\"lastName\":\"Gates\",\"email\":\"asdf@hotmail.com\",\"deviceUUID\":\"abcdefghijklmnopqrstuvwxyz\"}</p> <p>Which I have to get rid of...
[ { "answer_id": 307652, "author": "Rick Strahl", "author_id": 11197, "author_profile": "https://Stackoverflow.com/users/11197", "pm_score": 2, "selected": true, "text": "<p>Are you sure you have those slashes in there? That's the debugger view which C# encodes the string for display, but ...
2008/11/21
[ "https://Stackoverflow.com/questions/307619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26086/" ]
My code works (yeah!) which sends json to a server.. would appreciate any thoughts on refactoring 1) My C# code sends this json to the server {\"firstName\":\"Bill\",\"lastName\":\"Gates\",\"email\":\"asdf@hotmail.com\",\"deviceUUID\":\"abcdefghijklmnopqrstuvwxyz\"} Which I have to get rid of the slashes on the serv...
Are you sure you have those slashes in there? That's the debugger view which C# encodes the string for display, but the real values coming out of JavaScriptSerializer don't have any slashes in the identifier. The only thing that gets escaped is the JSON value content...
307,623
<p>I'm writing some RSS feeds in PHP and stuggling with character-encoding issues. Should I utf8_encode() before or after htmlentities() encoding? For example, I've got both ampersands and Chinese characters in a description element, and I'm not sure which of these is proper:</p> <pre><code>$output = utf8_encode(htmle...
[ { "answer_id": 307630, "author": "SoapBox", "author_id": 36384, "author_profile": "https://Stackoverflow.com/users/36384", "pm_score": 1, "selected": false, "text": "<p>You want to do <code>$output = htmlentities(utf8_encode($source));</code>. This is because you want to convert your in...
2008/11/21
[ "https://Stackoverflow.com/questions/307623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17307/" ]
I'm writing some RSS feeds in PHP and stuggling with character-encoding issues. Should I utf8\_encode() before or after htmlentities() encoding? For example, I've got both ampersands and Chinese characters in a description element, and I'm not sure which of these is proper: ``` $output = utf8_encode(htmlentities($sour...
It's important to pass the character set to the htmlentities function, as the default is ISO-8859-1: ``` utf8_encode(htmlentities($source,ENT_COMPAT,'utf-8')); ``` You should apply htmlentities first as to allow utf8\_encode to encode the entities properly. (EDIT: I changed from my opinion before that the order did...
307,636
<p>I am able to create and execute a DTS package that copies tables from a remote Oracle database to a local SQL server, but want to setup the connection to the Oracle database as a linked server.</p> <p>The DTS package currently uses the <em>Microsoft OLE DB Provider for Oracle</em> with the following properties:</p>...
[ { "answer_id": 319018, "author": "Oppositional", "author_id": 2029, "author_profile": "https://Stackoverflow.com/users/2029", "pm_score": 6, "selected": true, "text": "<p>I was able to setup a linked server to a remote Oracle database, which ended up being a multi-step process:</p>\n\n<o...
2008/11/21
[ "https://Stackoverflow.com/questions/307636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2029/" ]
I am able to create and execute a DTS package that copies tables from a remote Oracle database to a local SQL server, but want to setup the connection to the Oracle database as a linked server. The DTS package currently uses the *Microsoft OLE DB Provider for Oracle* with the following properties: * Data Source: `SER...
I was able to setup a linked server to a remote Oracle database, which ended up being a multi-step process: 1. Install Oracle ODBC drivers on SQL Server. 2. Create System DSN to Oracle database on SQL Server. 3. Create linked server on SQL server using System DSN. **Step 1: Install Oracle ODBC drivers on server** a....
307,650
<p>How can I remove duplicate values from an array in PHP?</p>
[ { "answer_id": 307655, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 9, "selected": true, "text": "<p>Use <a href=\"http://php.net/array_unique\" rel=\"noreferrer\">array_unique()</a>.</p>\n\n<p>Example:</p>\n\n<pre><code>...
2008/11/21
[ "https://Stackoverflow.com/questions/307650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39539/" ]
How can I remove duplicate values from an array in PHP?
Use [array\_unique()](http://php.net/array_unique). Example: ``` $array = array(1, 2, 2, 3); $array = array_unique($array); // Array is now (1, 2, 3) ```
307,656
<p>I have a C#.net winform program which runs with a SQL Server database. I am using LINQ-to-SQL. Is it possible to rollback the call to one or more stored procedures inside a transaction within my program using LINQ-to-SQL? </p> <p>Initially I thought it would make sense to manage the transaction inside the stored...
[ { "answer_id": 307682, "author": "Andre Gallo", "author_id": 14401, "author_profile": "https://Stackoverflow.com/users/14401", "pm_score": -1, "selected": false, "text": "<p>Although I'm not using stored procs, you coudl have something like that:</p>\n\n<pre><code> public Response&lt;...
2008/11/21
[ "https://Stackoverflow.com/questions/307656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a C#.net winform program which runs with a SQL Server database. I am using LINQ-to-SQL. Is it possible to rollback the call to one or more stored procedures inside a transaction within my program using LINQ-to-SQL? Initially I thought it would make sense to manage the transaction inside the stored procedure bu...
Another alternative to `DbTransaction` is [`TransactionScope`](http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope(VS.85).aspx) - this provides a much simpler programming model, and is extensible to multiple simultaneous databases and other feeds (via DTC) - but at the cost of a small amount of...
307,657
<p>I am (unfortunately) developing an application in Excel 2000 VBA. I believe I have discovered that any error raised within a Custom Class property, function, or sub debugs as if the error were raised at the point in the VBA code where the property is called. That is, the VBE debugger does not take me to the point ...
[ { "answer_id": 307680, "author": "dbb", "author_id": 25675, "author_profile": "https://Stackoverflow.com/users/25675", "pm_score": 0, "selected": false, "text": "<p>This \"feature\" is the same in Excel 2003 and I'd be surprised if it's different in 2007.</p>\n" }, { "answer_id":...
2008/11/21
[ "https://Stackoverflow.com/questions/307657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39396/" ]
I am (unfortunately) developing an application in Excel 2000 VBA. I believe I have discovered that any error raised within a Custom Class property, function, or sub debugs as if the error were raised at the point in the VBA code where the property is called. That is, the VBE debugger does not take me to the point in th...
For Office 2003 you will get this behaviour when the debugger is configured to break on unhandled errors (the default configuration). If you want it to break on the Err.Raise line, you need to configure it to break on all errors (Tools/Options/General/Error Trapping/Break on All Errors). I believe it's the same for O...
307,658
<p>I find myself running scripts and copy-pasting the output of these runs into emails or into some other documents. Is there a way such that I can make the copy-to-clipboard step a part of the script itself? Most of my scripts are either Perl or bat files and I work on Windows. </p> <p>Thanks.</p>
[ { "answer_id": 307668, "author": "digitalsanctum", "author_id": 22436, "author_profile": "https://Stackoverflow.com/users/22436", "pm_score": 0, "selected": false, "text": "<p>Not sure about the clipboard but you can pipe the output to a text file but doing something like this:</p>\n\n<p...
2008/11/21
[ "https://Stackoverflow.com/questions/307658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27928/" ]
I find myself running scripts and copy-pasting the output of these runs into emails or into some other documents. Is there a way such that I can make the copy-to-clipboard step a part of the script itself? Most of my scripts are either Perl or bat files and I work on Windows. Thanks.
There's a [utility called clip.exe](http://www.labnol.org/software/tutorials/copy-dos-command-line-output-clipboard-clip-exe/2506/) that you can use. Just pipe the output of your script or any other command into clip.exe (First, put it on your path somewhere. If you don't have a usual place for these kindss of utilitie...
307,664
<p>Say I have a user control like the one below, how would I bind something to the <code>ActualWidth</code> of the "G1" grid from outside of the control?</p> <pre><code>&lt;UserControl x:Class="Blah"&gt; &lt;WrapPanel&gt; &lt;Grid x:Name="G1"&gt; ... &lt;/Grid&gt; &lt;Grid&gt; ... &lt;/Gr...
[ { "answer_id": 307677, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 1, "selected": false, "text": "<p>If you want to bind to an external control where you use this user control, declare a <code>DependencyProperty</code> at...
2008/11/21
[ "https://Stackoverflow.com/questions/307664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36074/" ]
Say I have a user control like the one below, how would I bind something to the `ActualWidth` of the "G1" grid from outside of the control? ``` <UserControl x:Class="Blah"> <WrapPanel> <Grid x:Name="G1"> ... </Grid> <Grid> ... </Grid> </WrapPanel> </UserControl> ```
If you mean with outside the control, not as Content of the control, you can use `ElementName` in the Binding like so: ``` {Binding ElementName=G1, Path=ActualWidth} ``` If you mean outside the control in another Xaml file, then you can try to use the Path property if your control is in the scope of the other contro...
307,669
<p>I am trying to write an rspec test for a controller that accesses a model Group.</p> <pre> @request.env['HTTP_REFERER'] = group_url(@mock_group) ### Line 49 </pre> <p>I get this:</p> <pre> NoMethodError in 'ActsController responding to create should redirect to :back' You have a nil object when you didn't expect...
[ { "answer_id": 322163, "author": "Tim Harding", "author_id": 38021, "author_profile": "https://Stackoverflow.com/users/38021", "pm_score": 0, "selected": false, "text": "<p>Look at this. I think it is relevant.</p>\n\n<p><a href=\"http://jakescruggs.blogspot.com/2008/11/if-you-use-mocha-...
2008/11/21
[ "https://Stackoverflow.com/questions/307669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to write an rspec test for a controller that accesses a model Group. ``` @request.env['HTTP_REFERER'] = group_url(@mock_group) ### Line 49 ``` I get this: ``` NoMethodError in 'ActsController responding to create should redirect to :back' You have a nil object when you didn't expect it! The error occ...
This happens because url\_for depends on stuff that's initialized during request processing. I assume your test looks something like this: ``` it "should do whatever when referrer is group thing" do @request.env["HTTP_REFERER"] = url_for(@mock_group) get :some_action "something".should == "something" end ``` u...
307,674
<p>How can I remove duplicate values from a multi-dimensional array in PHP?</p> <p>Example array:</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; abc [1] =&gt; def ) [1] =&gt; Array ( [0] =&gt; ghi [1] =&gt; jkl ) [2] =&gt; Array ( [0] =&gt;...
[ { "answer_id": 307701, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 4, "selected": false, "text": "<p>The user comments on the <a href=\"http://php.net/array_unique\" rel=\"noreferrer\">array_unique()</a> documentation ha...
2008/11/21
[ "https://Stackoverflow.com/questions/307674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39539/" ]
How can I remove duplicate values from a multi-dimensional array in PHP? Example array: ``` Array ( [0] => Array ( [0] => abc [1] => def ) [1] => Array ( [0] => ghi [1] => jkl ) [2] => Array ( [0] => mno [1] => pql ) [3] => Arr...
Here is another way. No intermediate variables are saved. We used this to de-duplicate results from a variety of overlapping queries. ``` $input = array_map("unserialize", array_unique(array_map("serialize", $input))); ```
307,679
<p>On PHP, they have a way to restrict file size AFTER uploading, but not BEFORE uploading. I use the <a href="http://malsup.com/jquery/form/" rel="noreferrer">Malsup jQuery Form Plugin</a> for my form posting, and it supports image file posting.</p> <p>I was wondering if perhaps there's a restriction where I can set ...
[ { "answer_id": 307687, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": 3, "selected": false, "text": "<p>I don't think it's possible unless you use a flash, activex or java uploader.</p>\n\n<p>For security reasons ajax / ...
2008/11/21
[ "https://Stackoverflow.com/questions/307679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
On PHP, they have a way to restrict file size AFTER uploading, but not BEFORE uploading. I use the [Malsup jQuery Form Plugin](http://malsup.com/jquery/form/) for my form posting, and it supports image file posting. I was wondering if perhaps there's a restriction where I can set how many bytes can pass through that A...
This is a copy from my answers in a very similar question: [How to check file input size with jQuery?](https://stackoverflow.com/questions/1601455/check-file-input-size-with-jquery/3937404#3937404) --- You actually don't have access to the filesystem (for example reading and writing local files). However, due to the ...
307,688
<p>What is a simple way of downloading a file from a URL path?</p>
[ { "answer_id": 307697, "author": "vbroto", "author_id": 20837, "author_profile": "https://Stackoverflow.com/users/20837", "pm_score": 7, "selected": false, "text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/ez801hhe.aspx\" rel=\"noreferrer\"><code>System.Net.WebClient.Down...
2008/11/21
[ "https://Stackoverflow.com/questions/307688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20837/" ]
What is a simple way of downloading a file from a URL path?
``` using (var client = new WebClient()) { client.DownloadFile("http://example.com/file/song/a.mpeg", "a.mpeg"); } ```
307,695
<p>Being new to Cocoa, and probably not knowing all of the potential classes available that already have this functionality neatly wrapped in an OO class, here's an algorithm inquiry. What's the best bet to count how many times a particular key occurs in an array of multiple <code>NSDictionary</code> instances?</p> <p...
[ { "answer_id": 307745, "author": "Brian C. Lane", "author_id": 27461, "author_profile": "https://Stackoverflow.com/users/27461", "pm_score": 2, "selected": false, "text": "<p>You may want to rethink how you are structuring your data. I'd track something like this while adding to the NSAr...
2008/11/21
[ "https://Stackoverflow.com/questions/307695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Being new to Cocoa, and probably not knowing all of the potential classes available that already have this functionality neatly wrapped in an OO class, here's an algorithm inquiry. What's the best bet to count how many times a particular key occurs in an array of multiple `NSDictionary` instances? Essentially my data ...
``` NSDictionary * dict1 = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:1], @"foo", [NSNumber numberWithInt:2], @"bar", nil]; NSDictionary * dict2 = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:1], ...
307,706
<p>Is there any easy way to add a using statement to every class I create in a project without having to write</p> <pre><code>using SomeNamespace; </code></pre> <p>in every file?</p> <p>[edit] I could add a template I realise but I'm talking about doing it for every file in an existing project.</p>
[ { "answer_id": 307710, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 0, "selected": false, "text": "<p>I believe you can do something like:</p>\n\n<pre><code>&lt;system.web&gt;\n &lt;pages&gt;\n &lt...
2008/11/21
[ "https://Stackoverflow.com/questions/307706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6084/" ]
Is there any easy way to add a using statement to every class I create in a project without having to write ``` using SomeNamespace; ``` in every file? [edit] I could add a template I realise but I'm talking about doing it for every file in an existing project.
Note the web.config settings only work for code inside of page markup not in CodeFile/CodeBehind pages, so that's not really a solution. Another way to do this is to create an empty page with just the right setup you want - namespaces, plus possibly a common base class etc. and then create a page template from that. ...
307,709
<p>When working with Silverlight, I've noticed that Firefox will cache the XAP file, so if I do an update, a user may be stuck using an outdated version. Is there a way to force the browser to either re-download the XAP file every time, or maybe only force it to after an update has been published? Or is there a setti...
[ { "answer_id": 307781, "author": "Jarett Millard", "author_id": 15882, "author_profile": "https://Stackoverflow.com/users/15882", "pm_score": 2, "selected": false, "text": "<p>You could send HTTP headers to prevent it from caching:</p>\n\n<pre><code>Cache-control: no-cache\nPragma: no-ca...
2008/11/21
[ "https://Stackoverflow.com/questions/307709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12172/" ]
When working with Silverlight, I've noticed that Firefox will cache the XAP file, so if I do an update, a user may be stuck using an outdated version. Is there a way to force the browser to either re-download the XAP file every time, or maybe only force it to after an update has been published? Or is there a setting in...
The query string works perfectly, but I wouldn't use *DateTime.Now*, because it forces the user to re-download the app every time. Instead, we use the following: ``` protected void Page_Load(object sender, EventArgs e) { var versionNumber = Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.myA...
307,729
<pre><code>class Ball: a = [] def __init__(self): pass def add(self,thing): self.a.append(thing) def size(self): print len(self.a) for i in range(3): foo = Ball() foo.add(1) foo.add(2) foo.size() </code></pre> <p>I would expect a return of :</p> <pre><code>2 2 2 </code></pre> <p>But I ...
[ { "answer_id": 307741, "author": "Rizwan Kassim", "author_id": 35335, "author_profile": "https://Stackoverflow.com/users/35335", "pm_score": 3, "selected": true, "text": "<p><em>doh</em></p>\n\n<p>I just figured out why.</p>\n\n<p>In the above case, the a is a class attribute, not a data...
2008/11/21
[ "https://Stackoverflow.com/questions/307729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35335/" ]
``` class Ball: a = [] def __init__(self): pass def add(self,thing): self.a.append(thing) def size(self): print len(self.a) for i in range(3): foo = Ball() foo.add(1) foo.add(2) foo.size() ``` I would expect a return of : ``` 2 2 2 ``` But I get : ``` 2 4 6 ``` Why is this? I've f...
*doh* I just figured out why. In the above case, the a is a class attribute, not a data attribute - those are shared by all Balls(). Commenting out the a=[] and placing it into the **init** block means that it's a data attribute instead. (And, I couldn't access it then with foo.a, which I shouldn't do anyhow.) It see...
307,737
<p>I've got this problem with dynamically created TextBox.</p> <p>When the TextBox is created in PageLoad, it's TextChanged event was fired.<br> But when I dynamically delete and recreated the TextBox, the TextChanged was not fired.</p> <p>This is the code:</p> <p><strong>.aspx file</strong></p> <pre><code>&lt;body...
[ { "answer_id": 307817, "author": "Howard Pinsley", "author_id": 7961, "author_profile": "https://Stackoverflow.com/users/7961", "pm_score": 1, "selected": false, "text": "<p>I had a similar problem. I think the issue is that dynamically created controls are not kept in view state and do...
2008/11/21
[ "https://Stackoverflow.com/questions/307737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36036/" ]
I've got this problem with dynamically created TextBox. When the TextBox is created in PageLoad, it's TextChanged event was fired. But when I dynamically delete and recreated the TextBox, the TextChanged was not fired. This is the code: **.aspx file** ``` <body> <form id="form1" runat="server"> <div> ...
Event handling is done by ASP.NET by matching up control's ID & the request parameters. In your case, the TextBox created during txtTextChanged() will have an auto ID because you don't specify any explicit ID. That ID will be posted back during the text changed event. After page load event, ASP.NET will try to find a...
307,763
<p>In VB6, ActiveX DLL is listed as a project template but in VS 2005+ there is no such thing. Where is my good old ActiveX DLL template? Many thanks in advance.</p>
[ { "answer_id": 307803, "author": "David", "author_id": 39552, "author_profile": "https://Stackoverflow.com/users/39552", "pm_score": 1, "selected": false, "text": "<p>Try this: <a href=\"http://msmvps.com/blogs/pauldomag/archive/2006/08/16/107758.aspx\" rel=\"nofollow noreferrer\">http:/...
2008/11/21
[ "https://Stackoverflow.com/questions/307763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8203/" ]
In VB6, ActiveX DLL is listed as a project template but in VS 2005+ there is no such thing. Where is my good old ActiveX DLL template? Many thanks in advance.
A couple of concepts; .NET Assemblies are the functional equivalent to ActiveX DLLs in the .NET langauges. .NET Classes and method can be decorated with attribute that have various meaning in different context. A .NET Assembly can be turned into a ActiveX/COM DLL (or OCX) by using various attributes to assign the corre...
307,765
<p>I was thinking along the lines of using <code>typeid()</code> but I don't know how to ask if that type is a subclass of another class (which, by the way, is abstract)</p>
[ { "answer_id": 307779, "author": "Howard Pinsley", "author_id": 7961, "author_profile": "https://Stackoverflow.com/users/7961", "pm_score": -1, "selected": false, "text": "<p>In c# you can simply say:</p>\n\n<pre><code>if (myObj is Car) {\n\n}\n</code></pre>\n" }, { "answer_id": ...
2008/11/21
[ "https://Stackoverflow.com/questions/307765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39189/" ]
I was thinking along the lines of using `typeid()` but I don't know how to ask if that type is a subclass of another class (which, by the way, is abstract)
You really shouldn't. If your program needs to know what class an object is, that usually indicates a design flaw. See if you can get the behavior you want using virtual functions. Also, more information about what you are trying to do would help. I am assuming you have a situation like this: ``` class Base; class A ...
307,766
<p>I'm trying to convert a Web Site to the Web Application project model and I'm running into compile errors that do not seem to be covered by the guidance I found at <a href="http://msdn.microsoft.com/en-us/library/aa983476.aspx" rel="nofollow noreferrer">Converting a Web Site Project to a Web Application Project</a>....
[ { "answer_id": 307779, "author": "Howard Pinsley", "author_id": 7961, "author_profile": "https://Stackoverflow.com/users/7961", "pm_score": -1, "selected": false, "text": "<p>In c# you can simply say:</p>\n\n<pre><code>if (myObj is Car) {\n\n}\n</code></pre>\n" }, { "answer_id": ...
2008/11/21
[ "https://Stackoverflow.com/questions/307766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7961/" ]
I'm trying to convert a Web Site to the Web Application project model and I'm running into compile errors that do not seem to be covered by the guidance I found at [Converting a Web Site Project to a Web Application Project](http://msdn.microsoft.com/en-us/library/aa983476.aspx). The issue is that standard ASP.NET con...
You really shouldn't. If your program needs to know what class an object is, that usually indicates a design flaw. See if you can get the behavior you want using virtual functions. Also, more information about what you are trying to do would help. I am assuming you have a situation like this: ``` class Base; class A ...