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
462,618
<p>In Flex 3, buttons call their click handler when they are clicked on by the mouse, or when they have the focus and the user depresses the space bar.</p> <p>Is there a straightforward way to cause Flex 3 buttons with focus to call their click handler when the user presses the enter key?</p>
[ { "answer_id": 462695, "author": "cliff.meyers", "author_id": 41754, "author_profile": "https://Stackoverflow.com/users/41754", "pm_score": 0, "selected": false, "text": "<p>Try the \"buttonDown\" event; it may be dispatched in either case. Otherwise you are probably looking at using \"...
2009/01/20
[ "https://Stackoverflow.com/questions/462618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15079/" ]
In Flex 3, buttons call their click handler when they are clicked on by the mouse, or when they have the focus and the user depresses the space bar. Is there a straightforward way to cause Flex 3 buttons with focus to call their click handler when the user presses the enter key?
Sure, you could do something like this: ``` <mx:Script> <![CDATA[ import mx.controls.Alert; private function btn_click(event:MouseEvent):void { Alert.show("Clicked!"); } private function btn_keyDown(event:KeyboardEvent):void { if (event.key...
462,619
<p>I continuously find places where I need to use the <code>&lt;br /&gt;</code> tag because CSS can't do what I need. Isn't the <code>&lt;br /&gt;</code> considered part of the "design" and not part of document structure? What is the acceptable usage for it? Should the same rules also apply to the <code>&lt;hr /&gt;</c...
[ { "answer_id": 462635, "author": "Vaibhav", "author_id": 380, "author_profile": "https://Stackoverflow.com/users/380", "pm_score": 1, "selected": false, "text": "<p>Interesting question. I have always used <code>&lt;br/&gt;</code> as a carriage return (and hence as part of content, reall...
2009/01/20
[ "https://Stackoverflow.com/questions/462619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
I continuously find places where I need to use the `<br />` tag because CSS can't do what I need. Isn't the `<br />` considered part of the "design" and not part of document structure? What is the acceptable usage for it? Should the same rules also apply to the `<hr />`? Here is an example of where I feel forced to us...
There is nothing wrong with using <br /> or <hr />. Neither of them are deprecated tags, even in the new HTML 5 draft spec (relevant [spec info](http://dev.w3.org/html5/spec/Overview.html#the-hr-element)). In fact, it's hard to state correct usage of the <br /> tag better than the W3C itself: > > *The following examp...
462,637
<p>I have a database that was restored from a SQL 2000 instance to a SQL 2005 instance some time ago. The SQL 2000 instance had old, unused Full Text Searches defined.</p> <p>It appears that, when the file was restored, the full text searches were not restored but just deleted.</p> <p>This left the database in a funn...
[ { "answer_id": 462659, "author": "MarlonRibunal", "author_id": 10385, "author_profile": "https://Stackoverflow.com/users/10385", "pm_score": 0, "selected": false, "text": "<p>You should have repopulated your full text catalogs. By default SQL Server 2005 does not do this to give the inst...
2009/01/20
[ "https://Stackoverflow.com/questions/462637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5581/" ]
I have a database that was restored from a SQL 2000 instance to a SQL 2005 instance some time ago. The SQL 2000 instance had old, unused Full Text Searches defined. It appears that, when the file was restored, the full text searches were not restored but just deleted. This left the database in a funny state, with the...
The answer to this conundrum turns out to be very simple, at least if you don't care about your FTS indices, which I don't. ``` EXEC master.dbo.sp_detach_db @dbname = N'dbname', @keepfulltextindexfile=N'false' ``` The key here is the second flag, `@keepfulltextindexfile`, which defaults to true. By setting that to f...
462,640
<p><strong>THE SETUP</strong><br> I have a table which contains linestrings. Linestrings are made up of multiple geographic points. Each point is made up of a latitude and longitude. Note: the linestring value is stored as TEXT in the database.</p> <p>So one row in the table might look like this:<br> id: an integer<br...
[ { "answer_id": 462761, "author": "Igor Zelaya", "author_id": 22769, "author_profile": "https://Stackoverflow.com/users/22769", "pm_score": 1, "selected": false, "text": "<p>I think the easiest way to go here is using the MySQL spatial extensions. </p>\n\n<p>Particularly I have only used...
2009/01/20
[ "https://Stackoverflow.com/questions/462640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/400407/" ]
**THE SETUP** I have a table which contains linestrings. Linestrings are made up of multiple geographic points. Each point is made up of a latitude and longitude. Note: the linestring value is stored as TEXT in the database. So one row in the table might look like this: id: an integer linestring: x1, y2, x2, ...
One thing to realise is that, if there is more than one linestring that can be connected to a given linestring, it *doesn't matter which is chosen* -- the final number of linestrings in the optimised table will be the same. So in that case, a simple greedy strategy of repeatedly finding a pair of linestrings that can ...
462,641
<p>I have First/Last/Previous/Next buttons that change the selected child node of a TreeViewItem. Setting the First and Last node as selected is not a problem. For example, to select the last child node:</p> <pre><code>TreeViewItem selectedItem = (myTreeView.SelectedItem as TreeViewItem); TreeViewItem ParentItem = (se...
[ { "answer_id": 462755, "author": "Mark Carpenter", "author_id": 47645, "author_profile": "https://Stackoverflow.com/users/47645", "pm_score": 0, "selected": false, "text": "<p>It's not elegant, but it works. can anyone come up with a better solution? (\"Next\" functionality shown)</p>\n\...
2009/01/20
[ "https://Stackoverflow.com/questions/462641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47645/" ]
I have First/Last/Previous/Next buttons that change the selected child node of a TreeViewItem. Setting the First and Last node as selected is not a problem. For example, to select the last child node: ``` TreeViewItem selectedItem = (myTreeView.SelectedItem as TreeViewItem); TreeViewItem ParentItem = (selectedItem.Par...
You could replace the for loop with a IndexOf call. ``` int index = ParentItem.Items.IndexOf(MyTreeView.SelectedItem) ``` And of course it will be good to check if index + 1 is a valid collection index. And for the previous sibling it will be index - 1.
462,651
<p>How can I configure the rails logger to output its log strings in another format? I would like to get something that is more informative like:</p> <p>[Log Level] [Time] [Message]</p> <p>Debug : 01-20-2008 13:11:03.00 : Method Called</p> <p>This would really help me when I want to tail my development.log for messa...
[ { "answer_id": 466029, "author": "Bill", "author_id": 36285, "author_profile": "https://Stackoverflow.com/users/36285", "pm_score": 6, "selected": true, "text": "<p>Did some digging and found <a href=\"http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/9da4250f2c7e2cd7/...
2009/01/20
[ "https://Stackoverflow.com/questions/462651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36285/" ]
How can I configure the rails logger to output its log strings in another format? I would like to get something that is more informative like: [Log Level] [Time] [Message] Debug : 01-20-2008 13:11:03.00 : Method Called This would really help me when I want to tail my development.log for messages that only come from ...
Did some digging and found [this](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/9da4250f2c7e2cd7/d6948f578149f2f0?lnk=gst&q=logger#d6948f578149f2f0 "customize logger messages in Rails2?") post in the RubyOnRails Talk google group. So I modified it a little bit and put it at the end of my environ...
462,656
<p>Some "high risk" data operations need to be logged. In this case, the "high risk" operations are defined as writes to our ERP system. It happens that we are logging those events to our SQL Server database.</p> <p>Pseudo-code:</p> <pre><code>Public Class MyCompany.DAL.ERP { Public void WriteToERP(string msg) { ...
[ { "answer_id": 462679, "author": "Rob", "author_id": 18505, "author_profile": "https://Stackoverflow.com/users/18505", "pm_score": 0, "selected": false, "text": "<p>Maybe you could have your logging component, moved to a seperate assembly (I'm assuming this is C# code), raise an event, t...
2009/01/20
[ "https://Stackoverflow.com/questions/462656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
Some "high risk" data operations need to be logged. In this case, the "high risk" operations are defined as writes to our ERP system. It happens that we are logging those events to our SQL Server database. Pseudo-code: ``` Public Class MyCompany.DAL.ERP { Public void WriteToERP(string msg) { // ... do the write...
Hmm, IMHO logging is an infrastructure concern. You can use it in your DAL, but your logger should not use your DAL. If you remove the dependency your logger has on your DAL, then you should be able to use your logger in other projects as well.
462,663
<p>I was debugging something and discovered some strangeness in JavaScript:</p> <pre><code>alert(1=='') ==&gt; false alert(0=='') ==&gt; true alert(-1=='') ==&gt; false </code></pre> <p>It would make sense that an implied string comparison that 0 should = '0'. This is true for all non-zero values, but why not for zer...
[ { "answer_id": 462678, "author": "davethegr8", "author_id": 12930, "author_profile": "https://Stackoverflow.com/users/12930", "pm_score": 2, "selected": false, "text": "<p>Javascript, like PHP, is weakly typed*. So when you compare 0 to '', the JS engine converts them to a similar dataty...
2009/01/20
[ "https://Stackoverflow.com/questions/462663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12579/" ]
I was debugging something and discovered some strangeness in JavaScript: ``` alert(1=='') ==> false alert(0=='') ==> true alert(-1=='') ==> false ``` It would make sense that an implied string comparison that 0 should = '0'. This is true for all non-zero values, but why not for zero?
According to the Mozilla documentation on [Javascript Comparison Operators](https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Comparison_Operators) > > If the two operands are not of the same type, JavaScript converts the > operands then applies strict > comparison. If either operand is a > ...
462,677
<p>I am aware of using jconsole to attach to a java process to get memory information. Specifically I'm after getting information on the various memory pools programatically so I can tie it to a monitoring application.</p> <p>Thanks!</p>
[ { "answer_id": 462709, "author": "MattK", "author_id": 52734, "author_profile": "https://Stackoverflow.com/users/52734", "pm_score": 2, "selected": false, "text": "<p>Check out <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryPoolMXBean.html\" rel=\"nofollow n...
2009/01/20
[ "https://Stackoverflow.com/questions/462677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54777/" ]
I am aware of using jconsole to attach to a java process to get memory information. Specifically I'm after getting information on the various memory pools programatically so I can tie it to a monitoring application. Thanks!
Thanks mattk - I wound up doing basically this :-) ``` List memBeans = ManagementFactory.getMemoryPoolMXBeans(); for (Iterator i = memBeans.iterator(); i.hasNext(); ) { MemoryPoolMXBean mpool = (MemoryPoolMXBean)i.next(); MemoryUsage usage = mpool.getUsage(); String name = mpool.getName(); ...
462,696
<p><strong>Follow up to</strong>: <a href="https://stackoverflow.com/questions/421357/how-to-safely-update-a-file-that-has-many-readers-and-one-writer">How to safely update a file that has many readers and one writer?</a></p> <p>In my previous questions, I figured out that you can use FileChannel's lock to ensure an o...
[ { "answer_id": 462775, "author": "Miles D", "author_id": 3898, "author_profile": "https://Stackoverflow.com/users/3898", "pm_score": 0, "selected": false, "text": "<p>I don't think there is a perfect answer. I don't exactly know what you need to do, but can you do the writing to a new fi...
2009/01/20
[ "https://Stackoverflow.com/questions/462696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21838/" ]
**Follow up to**: [How to safely update a file that has many readers and one writer?](https://stackoverflow.com/questions/421357/how-to-safely-update-a-file-that-has-many-readers-and-one-writer) In my previous questions, I figured out that you can use FileChannel's lock to ensure an ordering on reads and writes. But ...
despite the fact that there is no bullet-proof, cross-OS, cross-FS solution, the "write to unique temp file and rename" strategy is still your best option. most platforms/filesystems attempt to make file renaming (effectively) atomic. note, you want to use a +separate+ lock file for locking. so, assuming you want to u...
462,697
<p>Let's say I have some Java code:</p> <pre><code>public class SomeClass { static { private final double PI = 3.14; private final double SOME_CONSTANT = 5.76; private final double SOME_OTHER_CONSTANT = 756.33; } //rest of class } </code></pre> <p>If a thread is initializing SomeCla...
[ { "answer_id": 462715, "author": "Dave Ray", "author_id": 40310, "author_profile": "https://Stackoverflow.com/users/40310", "pm_score": 4, "selected": false, "text": "<p>Static class initialization is guaranteed to be thread-safe by Java.</p>\n" }, { "answer_id": 462733, "aut...
2009/01/20
[ "https://Stackoverflow.com/questions/462697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1459442/" ]
Let's say I have some Java code: ``` public class SomeClass { static { private final double PI = 3.14; private final double SOME_CONSTANT = 5.76; private final double SOME_OTHER_CONSTANT = 756.33; } //rest of class } ``` If a thread is initializing SomeClass's `Class` object and is...
If the first thread hasn't finished initializing SomeClass, the second thread will block. This is detailed in the Java Language Specification in [section 12.4.2](http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4.2).
462,698
<p>I am attempting to use the .BaseStream property of the .NET2.0 SerialPort to do asynchronous reads and writes (BeginWrite/EndWrite, BeginRead/EndRead).</p> <p>I am having some success in this, but after a time, I notice (using Process Explorer) a very gradual increase in the Handles the app is using, and occasional...
[ { "answer_id": 472871, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 3, "selected": false, "text": "<p>Some suggestions:</p>\n\n<p>Since you are only sending 3 bytes, you could have a synchronous Write Operation. The ...
2009/01/20
[ "https://Stackoverflow.com/questions/462698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57220/" ]
I am attempting to use the .BaseStream property of the .NET2.0 SerialPort to do asynchronous reads and writes (BeginWrite/EndWrite, BeginRead/EndRead). I am having some success in this, but after a time, I notice (using Process Explorer) a very gradual increase in the Handles the app is using, and occasionally an extr...
Some suggestions: Since you are only sending 3 bytes, you could have a synchronous Write Operation. The delay wouldn't be much of an issue. Also don't create a new AsyncCallback all the time. Create one Read and one Write AsyncCallback and use that in every begin call.
462,699
<p>I have an array of doubles and I want the index of the highest value. These are the solutions that I've come up with so far but I think that there must be a more elegant solution. Ideas?</p> <pre><code>double[] score = new double[] { 12.2, 13.3, 5, 17.2, 2.2, 4.5 }; int topScoreIndex = score.Select((item, indx) =&g...
[ { "answer_id": 462725, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>I suggest writing your own extension method (edited to be generic with an <code>IComparable&lt;T&gt;</code> constraint...
2009/01/20
[ "https://Stackoverflow.com/questions/462699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
I have an array of doubles and I want the index of the highest value. These are the solutions that I've come up with so far but I think that there must be a more elegant solution. Ideas? ``` double[] score = new double[] { 12.2, 13.3, 5, 17.2, 2.2, 4.5 }; int topScoreIndex = score.Select((item, indx) => new {Item = it...
I suggest writing your own extension method (edited to be generic with an `IComparable<T>` constraint.) ``` public static int MaxIndex<T>(this IEnumerable<T> sequence) where T : IComparable<T> { int maxIndex = -1; T maxValue = default(T); // Immediately overwritten anyway int index = 0; foreach (T...
462,705
<p>I've got problems with setting focus to an input field after validating it.</p> <p>I've got 2 fields: from and to.</p> <pre><code> &lt;spring:message code="template.fields.label.from"/&gt;: &lt;mvc:input path="templateFields.selectorRangeFrom" onchange="validateNumber('templateFields.selectorRan...
[ { "answer_id": 462802, "author": "levik", "author_id": 4465, "author_profile": "https://Stackoverflow.com/users/4465", "pm_score": 0, "selected": false, "text": "<p>I'm not sure what returning false for <strong>onChange</strong> is supposed to mean. If you merely wish to re-focus the pro...
2009/01/20
[ "https://Stackoverflow.com/questions/462705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45020/" ]
I've got problems with setting focus to an input field after validating it. I've got 2 fields: from and to. ``` <spring:message code="template.fields.label.from"/>: <mvc:input path="templateFields.selectorRangeFrom" onchange="validateNumber('templateFields.selectorRangeFrom',true)"/> <spring:me...
**setTimeout()** allows you to defer the execution of a function for a number of milliseconds - if you use zero, this simply means, "do this as soon as you're done with whatever you're doing now" - handling the event, in your case. Try this: ``` if (! /** check field **/) { /** show error **/ setTimeout((functi...
462,735
<p>I've had someone else's pile of stuff handed to me. Among these items is a Word 2003 add-in (VSTO 2005 SE, .NET 2.0) that reportedly had been working fine in 2007, but our deployment environment calls for 2003. It installs apparently fine for Office 2003 -- no errors, shows up in add/remove -- but the toolbar is una...
[ { "answer_id": 462766, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 2, "selected": false, "text": "<p>Here are some questions for troubleshooting:</p>\n\n<ul>\n<li>What kind of add-in are you developing? A Shared Add...
2009/01/20
[ "https://Stackoverflow.com/questions/462735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25952/" ]
I've had someone else's pile of stuff handed to me. Among these items is a Word 2003 add-in (VSTO 2005 SE, .NET 2.0) that reportedly had been working fine in 2007, but our deployment environment calls for 2003. It installs apparently fine for Office 2003 -- no errors, shows up in add/remove -- but the toolbar is unavai...
EDIT: Full Trust for the add-in assembly ended up being the fix. Doesn't seem to run at anything less than Full Trust. // Ended up opening a ticket with Microsoft, and they've educated me about VSTO\_SUPPRESSDISPLAYALERTS: <http://msdn.microsoft.com/en-us/library/ms269003(VS.80).aspx> This value defaults to 1; sett...
462,741
<p>I've frequently seen a space preceding the closing slash in XML and HTML tags. The XHTML line break is probably the canonical example:</p> <pre><code>&lt;br /&gt; </code></pre> <p>instead of:</p> <pre><code>&lt;br/&gt; </code></pre> <p>The space seems superfluous. In fact, I think that it is superfluous.</p> <p...
[ { "answer_id": 462760, "author": "nicruo", "author_id": 56683, "author_profile": "https://Stackoverflow.com/users/56683", "pm_score": 0, "selected": false, "text": "<p>I think that the white space is a way to reinforce the idea that this tag is empty and it closes itself.</p>\n\n<p>Today...
2009/01/20
[ "https://Stackoverflow.com/questions/462741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13940/" ]
I've frequently seen a space preceding the closing slash in XML and HTML tags. The XHTML line break is probably the canonical example: ``` <br /> ``` instead of: ``` <br/> ``` The space seems superfluous. In fact, I think that it is superfluous. **What is the reason for writing this space?** I've read that the ...
The answer is people wish to adhere to [Appendix C of the XHTML1.0 specification](http://www.w3.org/TR/xhtml1/#guidelines). Which you only need to do if you are [serving XHTML as text/html](http://www.w3.org/TR/xhtml1/#media). Which most people do, because XHTML's real MIME type (application/html+xml) does not work in ...
462,744
<p>What is a reasonable amount of time to wait for a web request to return? I know this is maybe a little loaded as a question, but all I am trying to do is verify if a web page is available.</p> <p>Maybe there is a better way?</p> <pre><code>try { // Create the web request HttpWebRequest request = WebRequ...
[ { "answer_id": 462764, "author": "David Z", "author_id": 56541, "author_profile": "https://Stackoverflow.com/users/56541", "pm_score": 2, "selected": false, "text": "<p>Offhand I'd allow 10 seconds, but it really depends on what kind of network connection the code will be running with. ...
2009/01/20
[ "https://Stackoverflow.com/questions/462744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/178/" ]
What is a reasonable amount of time to wait for a web request to return? I know this is maybe a little loaded as a question, but all I am trying to do is verify if a web page is available. Maybe there is a better way? ``` try { // Create the web request HttpWebRequest request = WebRequest.Create(this.getUr...
You need to consider how long the consumer of the web service is going to take e.g. if you are connecting to a DB web server and you run a lengthy query, you need to make the web service timeout longer then the time the query will take. Otherwise, the web service will (erroneously) time out. I also use something like ...
462,746
<p>I'm an absolute beginner, you see. Say I have a string object on the stack and want to get the number of characters in it - its .Length property. How would I get the int32 number hidden inside?</p> <p>Many thanks in advance!</p>
[ { "answer_id": 462777, "author": "Brian Rasmussen", "author_id": 38206, "author_profile": "https://Stackoverflow.com/users/38206", "pm_score": 3, "selected": true, "text": "<p>There's really no such thing as properties in IL. There are only fields and methods. The C# property construct i...
2009/01/20
[ "https://Stackoverflow.com/questions/462746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm an absolute beginner, you see. Say I have a string object on the stack and want to get the number of characters in it - its .Length property. How would I get the int32 number hidden inside? Many thanks in advance!
There's really no such thing as properties in IL. There are only fields and methods. The C# property construct is translated to `get_PropertyName` and `set_PropertyName` methods by the compiler, so you have to call these methods to access the property. Sample (debug) IL for code ``` var s = "hello world"; var i = s....
462,747
<p>I am using the (.NET 3.5 SP1) System.Xml.Linq namespace to populate an html template document with div tags of data (and then save it to disk). Sometimes the div tags are empty and this seems to be a problem when it comes to HTML. According to my research, the DIV tag is not self-closing. Therefore, under Firefox a...
[ { "answer_id": 462785, "author": "red.clover", "author_id": 57005, "author_profile": "https://Stackoverflow.com/users/57005", "pm_score": 1, "selected": false, "text": "<p>I don't know the answer to your question using LINQ. But there is a project called <a href=\"http://www.codeplex.com...
2009/01/20
[ "https://Stackoverflow.com/questions/462747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/506/" ]
I am using the (.NET 3.5 SP1) System.Xml.Linq namespace to populate an html template document with div tags of data (and then save it to disk). Sometimes the div tags are empty and this seems to be a problem when it comes to HTML. According to my research, the DIV tag is not self-closing. Therefore, under Firefox at le...
I'm not sure why you'd end up with an empty DIV (seems a bit pointless!) But: ``` divTag.SetValue(string.Empty); ``` Should do it.
462,790
<p>I'm working in .NET with SQL server on the backend</p> <p>I have a database that I create a record in using a web control - then I need to update some of the fields.<br> I can trap the sql statement and run it in sql server successfully - however, when I try to run execute non-query I get the following error: </p> ...
[ { "answer_id": 462810, "author": "Mladen Prajdic", "author_id": 31345, "author_profile": "https://Stackoverflow.com/users/31345", "pm_score": 3, "selected": false, "text": "<p>before i even look where the error might be i suggest you stop immediatly what your doing and first go change al...
2009/01/20
[ "https://Stackoverflow.com/questions/462790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm working in .NET with SQL server on the backend I have a database that I create a record in using a web control - then I need to update some of the fields. I can trap the sql statement and run it in sql server successfully - however, when I try to run execute non-query I get the following error: Unhandled Exec...
before i even look where the error might be i suggest you stop immediatly what your doing and first go change all sql code to use parameters. if you don't your site will be open to sql injection attacks that can destroy your database. to find out where the problem is run profiler and check the stmt:starting and stmt:c...
462,793
<p>In C#, is there an inline shortcut to instantiate a List&lt;T&gt; with only one item.</p> <p>I'm currently doing:</p> <pre><code>new List&lt;string&gt;( new string[] { "title" } )) </code></pre> <p>Having this code everywhere reduces readability. I've thought of using a utility method like this:</p> <pre><code>...
[ { "answer_id": 462818, "author": "Michael Meadows", "author_id": 7643, "author_profile": "https://Stackoverflow.com/users/7643", "pm_score": 3, "selected": false, "text": "<p>Use an extension method with method chaining.</p>\n\n<pre><code>public static List&lt;T&gt; WithItems(this List&l...
2009/01/20
[ "https://Stackoverflow.com/questions/462793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23976/" ]
In C#, is there an inline shortcut to instantiate a List<T> with only one item. I'm currently doing: ``` new List<string>( new string[] { "title" } )) ``` Having this code everywhere reduces readability. I've thought of using a utility method like this: ``` public static List<T> SingleItemList<T>( T value ) { ...
Simply use this: ``` List<string> list = new List<string>() { "single value" }; ``` You can even omit the () braces: ``` List<string> list = new List<string> { "single value" }; ``` Update: of course this also works for more than one entry: ``` List<string> list = new List<string> { "value1", "value2", ... }; `...
462,805
<p>I was wondering what's the proper way of raising events from C++/CLI. In C# one s<a href="https://stackoverflow.com/questions/340610/create-empty-c-event-handlers-automatically#340638">hould first make a copy of the handler, check if it's not null, and then call it</a>. Is there a similar practice for C++/CLI?</p>
[ { "answer_id": 462847, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 5, "selected": true, "text": "<p>C++/CLI allows you to override <code>raise</code> in <a href=\"http://msdn.microsoft.com/en-us/library/5f3csfsa.asp...
2009/01/20
[ "https://Stackoverflow.com/questions/462805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21704/" ]
I was wondering what's the proper way of raising events from C++/CLI. In C# one s[hould first make a copy of the handler, check if it's not null, and then call it](https://stackoverflow.com/questions/340610/create-empty-c-event-handlers-automatically#340638). Is there a similar practice for C++/CLI?
C++/CLI allows you to override `raise` in [**custom event**](http://msdn.microsoft.com/en-us/library/5f3csfsa.aspx) handlers so you don't have to test for `null` or copy when raising the event. Of course, inside your custom `raise` you still have to do this. Example, adapted from the MSDN for correctness: ``` public ...
462,824
<p>I've been trying to switch from using PerlSetEnv to using <a href="http://perl.apache.org/docs/2.0/user/config/custom.html" rel="nofollow noreferrer">custom configuration directives</a>. I have my configuration module with a copy of <code>set_val</code> from the docs:</p> <pre><code>sub set_val { local our ($k...
[ { "answer_id": 462829, "author": "foson", "author_id": 22539, "author_profile": "https://Stackoverflow.com/users/22539", "pm_score": 3, "selected": true, "text": "<p>Controls that appear in the \"component tray\", like the Windows Forms Timer control, inherit from Component.</p>\n\n<p>To...
2009/01/20
[ "https://Stackoverflow.com/questions/462824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16777/" ]
I've been trying to switch from using PerlSetEnv to using [custom configuration directives](http://perl.apache.org/docs/2.0/user/config/custom.html). I have my configuration module with a copy of `set_val` from the docs: ``` sub set_val { local our ($key, $self, $parms, $arg) = @_; $self->{$key} = $arg; un...
Controls that appear in the "component tray", like the Windows Forms Timer control, inherit from Component. To create one with some automatic boilerplate code, right-click on a project and click Add... | Component
462,831
<p>I've written a content management system that uses a server-side regular expression to escape ampersands in the page response just prior to it being sent to the client's browser. The regular expression is mindful of ampersands that have already been escaped or are part of an HTML entity. For example, the following...
[ { "answer_id": 462897, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>I've done something similar here:<br>\n<a href=\"https://stackoverflow.com/questions/157646/best-way-to-encode-text...
2009/01/20
[ "https://Stackoverflow.com/questions/462831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57222/" ]
I've written a content management system that uses a server-side regular expression to escape ampersands in the page response just prior to it being sent to the client's browser. The regular expression is mindful of ampersands that have already been escaped or are part of an HTML entity. For example, the following: ``...
You asked for it! :D ``` /&(?!(?:[a-zA-Z][a-zA-Z0-9]*|#\d+);) (?!(?>(?:(?!<!\[CDATA\[|\]\]>).)*)\]\]>)/xm ``` The first line is your original regex. The lookahead matches if there's a CDATA closing sequence ( `]]>` ) up ahead, unless there's an opening sequence ( `<!CDATA[` ) between here and there. Assuming the do...
462,843
<p>I'm writing (in C#) a simple parser to process a scripting language that looks a lot like classic C.</p> <p>On one script file I have, the regular expression that I'm using to recognize /* block comments */ is going into some kind of infinite loop, taking 100% CPU for ages.</p> <p>The Regex I'm using is this:</p> ...
[ { "answer_id": 462914, "author": "codybartfast", "author_id": 53252, "author_profile": "https://Stackoverflow.com/users/53252", "pm_score": 2, "selected": false, "text": "<p>You may want to try the option Singleline rather than Multiline, then you don't need to worry about \\r\\n. With ...
2009/01/20
[ "https://Stackoverflow.com/questions/462843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30280/" ]
I'm writing (in C#) a simple parser to process a scripting language that looks a lot like classic C. On one script file I have, the regular expression that I'm using to recognize /\* block comments \*/ is going into some kind of infinite loop, taking 100% CPU for ages. The Regex I'm using is this: ``` /\*([^*]|[\r\n...
Some problems I see with your regex: There's no need for the `|[\r\n]` sequences in your regex; a negated character class like `[^*]` matches everything except `*`, including line separators. It's only the `.` (dot) metacharacter that doesn't match those. Once you're inside the comment, the only character you have to...
462,853
<p>I have a library that I would like to license and distribute.</p> <p>I know how to license a class/library for runtime. I've done that several times, actually. I know how to license a user control. I've also done that several times. </p> <p>What's got me stumped is how to license a library (that has no drag/drop u...
[ { "answer_id": 463026, "author": "Jerry", "author_id": 53531, "author_profile": "https://Stackoverflow.com/users/53531", "pm_score": 4, "selected": true, "text": "<p>I finally found the answer. This one isn't as apparent as I thought it would be.</p>\n\n<p>Instead of looking for DesignTi...
2009/01/20
[ "https://Stackoverflow.com/questions/462853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53531/" ]
I have a library that I would like to license and distribute. I know how to license a class/library for runtime. I've done that several times, actually. I know how to license a user control. I've also done that several times. What's got me stumped is how to license a library (that has no drag/drop user control or co...
I finally found the answer. This one isn't as apparent as I thought it would be. Instead of looking for DesignTime or RunTime attributes, you need to see if a debugger is attached. Drop this in the constructor (with the appropriate attributes on your class), and you're off and running!! ``` if (System.Diagnostics.De...
462,856
<p><strong>UPDATE</strong>:</p> <p>So it turns out that we may have found a bug in Visual Studio 2003 (I know...no surprise). We found out that if the solutions were added to the repository using Visual Studio (using Add Solution to Source Control) everything went fine...go figure.</p> <hr> <p>So we're converting o...
[ { "answer_id": 462872, "author": "Yes - that Jake.", "author_id": 5287, "author_profile": "https://Stackoverflow.com/users/5287", "pm_score": 0, "selected": false, "text": "<p>The solution should be to rebind Solution1 to the source control server each time it's added to a new project. (...
2009/01/20
[ "https://Stackoverflow.com/questions/462856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6212/" ]
**UPDATE**: So it turns out that we may have found a bug in Visual Studio 2003 (I know...no surprise). We found out that if the solutions were added to the repository using Visual Studio (using Add Solution to Source Control) everything went fine...go figure. --- So we're converting our VSS repository (if it can be ...
We had a similar problem and were approaching it very much like @Toby Allen mentions in his answer, via client specs. However, in time this becomes very painful (setting up a new team member becomes more and more difficult as client specs become more and more convoluted; also automation is much more complicated because...
462,877
<p>I am having a problem with ActiveRecord inserting the DATETIME as per the documentation; "Active Record automatically timestamps create and update operations if the table has fields named created_at/created_on or updated_at/updated_on." I have a column named created_at but ActiveRecord is not inserting the DATETIME....
[ { "answer_id": 462966, "author": "Noah Goodrich", "author_id": 20178, "author_profile": "https://Stackoverflow.com/users/20178", "pm_score": 1, "selected": false, "text": "<p>If the created_at field type is <a href=\"http://dev.mysql.com/doc/refman/5.0/en/timestamp.html\" rel=\"nofollow ...
2009/01/20
[ "https://Stackoverflow.com/questions/462877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20189/" ]
I am having a problem with ActiveRecord inserting the DATETIME as per the documentation; "Active Record automatically timestamps create and update operations if the table has fields named created\_at/created\_on or updated\_at/updated\_on." I have a column named created\_at but ActiveRecord is not inserting the DATETIM...
You have a created\_at column, but ActiveRecord is not creating a timestamp? What's the column type of your created\_at column? Perhaps you could show us your migration? Also, if you tell Rails to use UTC (default in 2.2, I think), the time values will be correct, regardless of different server locales. And, lastly: ...
462,879
<p>I have a <code>List&lt;List&lt;int&gt;&gt;</code>. I would like to convert it into a <code>List&lt;int&gt;</code> where each int is unique. I was wondering if anyone had an elegant solution to this using LINQ.</p> <p>I would like to be able to use the Union method but it creates a new List&lt;> everytime. So I'd...
[ { "answer_id": 462901, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>How about:</p>\n\n<pre><code>HashSet&lt;int&gt; set = new HashSet&lt;int&gt;();\nforeach (List&lt;int&gt; list in lis...
2009/01/20
[ "https://Stackoverflow.com/questions/462879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57230/" ]
I have a `List<List<int>>`. I would like to convert it into a `List<int>` where each int is unique. I was wondering if anyone had an elegant solution to this using LINQ. I would like to be able to use the Union method but it creates a new List<> everytime. So I'd like to avoid doing something like this: ``` List<int>...
``` List<List<int>> l = new List<List<int>>(); l.Add(new List<int> { 1, 2, 3, 4, 5, 6}); l.Add(new List<int> { 4, 5, 6, 7, 8, 9 }); l.Add(new List<int> { 8, 9, 10, 11, 12, 13 }); var result = (from e in l from e2 in e select e2).Distinct(); ``` ### Update 09.2013 But these days I would ...
462,898
<p>I have two related clases JPA-annotated. Alarm and Status. One Alarm can have one Status.</p> <p>What I need is to be able to delete one Status and "propagate" a null value to the Alarms that are in that Status that has been deleted.</p> <p>That is, I need the foreign key to be defined as "<strong>on delete set ...
[ { "answer_id": 468434, "author": "Romain Linsolas", "author_id": 26457, "author_profile": "https://Stackoverflow.com/users/26457", "pm_score": 0, "selected": false, "text": "<p>Are you sure with your @OneToOne?\nIt seems to me that you'd rather use @ManyToOne (as a status can be affected...
2009/01/20
[ "https://Stackoverflow.com/questions/462898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12388/" ]
I have two related clases JPA-annotated. Alarm and Status. One Alarm can have one Status. What I need is to be able to delete one Status and "propagate" a null value to the Alarms that are in that Status that has been deleted. That is, I need the foreign key to be defined as "**on delete set null**". ``` @Entity pub...
Just add that using the Hibernate annotation: ``` @OnDelete(action=OnDeleteAction.CASCADE) ``` generates the foreign key as : "ON UPDATE NO ACTION ON DELETE CASCADE;" But there is no action=OnDeleteAction.SET\_NULL Moreover, I don't like to tie my code to Hibernate if possible (but I can live with it if it works)....
462,903
<p>I'm writing what boils down to a document editor. When the application is closing, I need to prompt the user to save changes. This is easy enough. My question is when is it appropriate to <em>not</em> prompt the user, and instead simply discard unsaved data and close.</p> <p>In the FormClosing event, the CloseReaso...
[ { "answer_id": 462927, "author": "recursive", "author_id": 44743, "author_profile": "https://Stackoverflow.com/users/44743", "pm_score": 3, "selected": true, "text": "<p>I think <code>TaskManagerClosing</code> should be the only reason that does not prompt, if any. Personally, I would w...
2009/01/20
[ "https://Stackoverflow.com/questions/462903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27414/" ]
I'm writing what boils down to a document editor. When the application is closing, I need to prompt the user to save changes. This is easy enough. My question is when is it appropriate to *not* prompt the user, and instead simply discard unsaved data and close. In the FormClosing event, the CloseReason enum includes: ...
I think `TaskManagerClosing` should be the only reason that does not prompt, if any. Personally, I would want to be prompted in the event of `WindowsShutDown`. If I'm shutting down Windows with an unsaved document somewhere, it means I've forgotten about it.
462,931
<p>I'm trying to get the footer in my site to look like this:</p> <pre> Wilgrove Baptist Church Home | About | Ministries 1234 S. Main st. John G. Smith, Sr. Pastor Contact Us | Site Map somwhere, ID 55555 </pre> <p>My problem is getting it laid out into the 3 columns. An...
[ { "answer_id": 462948, "author": "alex", "author_id": 50564, "author_profile": "https://Stackoverflow.com/users/50564", "pm_score": -1, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>&lt;div style=\"float:left; padding:10px;\"&gt;left&lt;/div&gt;\n&lt;div style=\"float:left; ...
2009/01/20
[ "https://Stackoverflow.com/questions/462931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
I'm trying to get the footer in my site to look like this: ``` Wilgrove Baptist Church Home | About | Ministries 1234 S. Main st. John G. Smith, Sr. Pastor Contact Us | Site Map somwhere, ID 55555 ``` My problem is getting it laid out into the 3 columns. Any suggestions...
Quite easily done using floats: ``` <div id="footer"> <p class="left">Left aligned text here<br />Next line here</p> <p class="right">Right aligned text here<br />Next line here</p> <p class="centered">Center Text here<br />Next line here</p> </div> ``` and the CSS: ``` .left{ text-align:left; float:lef...
462,945
<p>How can I dynamically load a usercontrol in ASP.NET if I dont have access to a Page object (say I'm in a utility class)?</p> <p>Normally you would do :</p> <pre><code>Page.LoadControl("~/controls/MyControl.ascx"); </code></pre>
[ { "answer_id": 462954, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 1, "selected": false, "text": "<p>The only way to load a user control properly (that is to say in a way that will initiate its life-cycle) is to add ...
2009/01/20
[ "https://Stackoverflow.com/questions/462945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
How can I dynamically load a usercontrol in ASP.NET if I dont have access to a Page object (say I'm in a utility class)? Normally you would do : ``` Page.LoadControl("~/controls/MyControl.ascx"); ```
You could add a control from your utility class to the current page, using the following code: ``` Page currentPage = HttpContext.Current.Handler as Page; if (currentPage != null) { currentPage.Controls.Add( currentPage.LoadControl("~/controls/MyControl.ascx")); } ``` It works, but I would not recommend ...
462,955
<p>I have a web app built against asp.net 2.0, but keep getting the following warning:</p> <p>Namespace or type specified in the project-level Imports 'System.Xml.Linq' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sur...
[ { "answer_id": 463066, "author": "Ricardo Villamil", "author_id": 19314, "author_profile": "https://Stackoverflow.com/users/19314", "pm_score": 0, "selected": false, "text": "<p>Have you checked in your web.config file?</p>\n" }, { "answer_id": 463093, "author": "brendan", ...
2009/01/20
[ "https://Stackoverflow.com/questions/462955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4782/" ]
I have a web app built against asp.net 2.0, but keep getting the following warning: Namespace or type specified in the project-level Imports 'System.Xml.Linq' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the impo...
Open your web.config and remove the reference to Linq in there. You should need to delete these lines from under the "assemblies" section: ``` <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, ...
462,962
<p>I have a nested SQL query that is exhibiting results which I can't understand. The query joins the PARTNER and USER tables via the PARTNER_USER table. A partner is basically a collection of users, and the objective of this query is to figure out when the 20th user registered with the partner that has ID 34:</p> <pr...
[ { "answer_id": 462973, "author": "Frederik Gheysels", "author_id": 55774, "author_profile": "https://Stackoverflow.com/users/55774", "pm_score": 1, "selected": false, "text": "<p>Whe you use the = operator to compare with the results of a subquery, your subquery may return only a single ...
2009/01/20
[ "https://Stackoverflow.com/questions/462962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I have a nested SQL query that is exhibiting results which I can't understand. The query joins the PARTNER and USER tables via the PARTNER\_USER table. A partner is basically a collection of users, and the objective of this query is to figure out when the 20th user registered with the partner that has ID 34: ``` selec...
JPunyon is right. One or the other query has to run first, and then have its results trimmed after the fact. If you look at the queries as written, the outer query has to know the result of the inner query to apply its where clause. However, when you specify ``` where np.partner_id = p.partner_id ``` in the inn...
462,967
<p>I'm trying to display a video feed which is provided as a server side playlist (ASX) by another party. The playlist contains some unsupported features, such as repeat:</p> <pre><code>&lt;ASX VERSION="3.0"&gt; &lt;REPEAT COUNT="4"&gt; &lt;EntryRef href="http://some-ad-network.com/ad.asx" /&gt; &lt;Entry&gt...
[ { "answer_id": 462973, "author": "Frederik Gheysels", "author_id": 55774, "author_profile": "https://Stackoverflow.com/users/55774", "pm_score": 1, "selected": false, "text": "<p>Whe you use the = operator to compare with the results of a subquery, your subquery may return only a single ...
2009/01/20
[ "https://Stackoverflow.com/questions/462967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5/" ]
I'm trying to display a video feed which is provided as a server side playlist (ASX) by another party. The playlist contains some unsupported features, such as repeat: ``` <ASX VERSION="3.0"> <REPEAT COUNT="4"> <EntryRef href="http://some-ad-network.com/ad.asx" /> <Entry> <Ref href="http://video-host/c...
JPunyon is right. One or the other query has to run first, and then have its results trimmed after the fact. If you look at the queries as written, the outer query has to know the result of the inner query to apply its where clause. However, when you specify ``` where np.partner_id = p.partner_id ``` in the inn...
462,970
<p>I have the code below to convert a 32 bit BCD value (supplied in two uint halves) to a uint binary value.</p> <p>The values supplied can be up to 0x9999, to form a maximum value of 0x99999999. </p> <p>Is there a better (ie. quicker) way to achieve this? </p> <pre><code> /// &lt;summary&gt; /// Convert two ...
[ { "answer_id": 463012, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "<p>Your code seems rather complicated; do you require the specific error checking?</p>\n\n<p>Otherwise, you could jus...
2009/01/20
[ "https://Stackoverflow.com/questions/462970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57220/" ]
I have the code below to convert a 32 bit BCD value (supplied in two uint halves) to a uint binary value. The values supplied can be up to 0x9999, to form a maximum value of 0x99999999. Is there a better (ie. quicker) way to achieve this? ``` /// <summary> /// Convert two PLC words in BCD format (forming 8...
If you unroll the loop, remember to keep the bit shift. ``` value = ( lo & 0xF); value += ((lo >> 4 ) & 0xF) * 10; value += ((lo >> 8 ) & 0xF) * 100; value += ((lo >> 12) & 0xF) * 1000; value += ( hi & 0xF) * 10000; value += ((hi >> 4 ) & 0xF) * 100000; value += ((hi >> 8 ) & 0xF) * 1000000; value += ((...
462,974
<p>Some Git commands take commit ranges and one valid syntax is to separate two commit names with two dots <code>..</code>, and another syntax uses three dots <code>...</code>.</p> <p>What are the differences between the two?</p>
[ { "answer_id": 463027, "author": "Pieter", "author_id": 49401, "author_profile": "https://Stackoverflow.com/users/49401", "pm_score": 9, "selected": true, "text": "<p>It depends on whether you're using a <code>log</code> command or a <code>diff</code> command. In the <code>log</code> cas...
2009/01/20
[ "https://Stackoverflow.com/questions/462974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/825/" ]
Some Git commands take commit ranges and one valid syntax is to separate two commit names with two dots `..`, and another syntax uses three dots `...`. What are the differences between the two?
It depends on whether you're using a `log` command or a `diff` command. In the `log` case, it's in the `man git-rev-parse` documentation: > > To exclude commits reachable from a commit, a prefix ^ notation is used. E.g. ^r1 r2 means commits reachable from r2 but exclude the ones reachable from r1. > > > This set op...
462,976
<p>Just tried to execute a small Lua script, but unfortunately I'm doing something wrong. I've no more ideas what the fault might be.</p> <pre><code>function checkPrime( n ) for i = 2, n-1, 1 do if n % i == 0 then return false end end return true end </code></pre> <p>The interp...
[ { "answer_id": 462990, "author": "Derek P.", "author_id": 45615, "author_profile": "https://Stackoverflow.com/users/45615", "pm_score": -1, "selected": false, "text": "<p>Have you tried wrapping \"n% i == 0\" in parentheses? Stupid question, but sometimes overlooked!</p>\n" }, { ...
2009/01/20
[ "https://Stackoverflow.com/questions/462976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35903/" ]
Just tried to execute a small Lua script, but unfortunately I'm doing something wrong. I've no more ideas what the fault might be. ``` function checkPrime( n ) for i = 2, n-1, 1 do if n % i == 0 then return false end end return true end ``` The interpreter says: ``` lua: /hom...
There is probably some version problem, check your version of lua. The usage of '%' as an infix operator for modulo can only be used in Lua 5.1, in 5.0 it is not supported yet. Try using `math.mod` instead: ``` if math.mod(n,i) == 0 then ``` **Edit**: Also note that in 5.1, `math.mod` still exists, but it has been r...
462,982
<p>I'm trying to copy a CGImageRef to the clipboard pasteboard. I found a function that claims it should do this by creating a destination from (zero sized), adding the image to the destination, finalizing, then PasteboardPutItemFlavor the ref into the clipboard.</p> <p>However it doesn't work, so two questions:</p> ...
[ { "answer_id": 473107, "author": "Brian Postow", "author_id": 53491, "author_profile": "https://Stackoverflow.com/users/53491", "pm_score": 1, "selected": true, "text": "<p>Ok, I'm answering my own question here, but here's what I've found: </p>\n\n<p>Apple wants you to use PDF for paste...
2009/01/20
[ "https://Stackoverflow.com/questions/462982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53491/" ]
I'm trying to copy a CGImageRef to the clipboard pasteboard. I found a function that claims it should do this by creating a destination from (zero sized), adding the image to the destination, finalizing, then PasteboardPutItemFlavor the ref into the clipboard. However it doesn't work, so two questions: 1. **Is** this...
Ok, I'm answering my own question here, but here's what I've found: Apple wants you to use PDF for pasteboards. So if you swap out Pict with PDF, it pretty muc just works. However, MS Word (what I was testing with) only started to allow pasting of PDF in the newest version (Which I don't have). So, that's the solut...
463,018
<p>I have a table where one of the left column shrinks when I set the nested element's style to <em>width:80%</em>. The column shrinks and truncates the input elements right edge. You can see what I'm talking about by removing the style from the input element.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHT...
[ { "answer_id": 463039, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 4, "selected": true, "text": "<p>The problem that you are having is because you are setting the <code>&lt;input&gt;</code>'s width to be a perce...
2009/01/20
[ "https://Stackoverflow.com/questions/463018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29043/" ]
I have a table where one of the left column shrinks when I set the nested element's style to *width:80%*. The column shrinks and truncates the input elements right edge. You can see what I'm talking about by removing the style from the input element. ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...
The problem that you are having is because you are setting the `<input>`'s width to be a percentage of a cell that has no width. So the cell is becoming smaller to make up for the text on the other cell and once that's done the input is getting 80% of whatever is left. Your options: 1) Set a width in pixels for the...
463,029
<p>I have seen two ways of acquiring and disposing resources. Either:</p> <pre><code>Resource resource = getResource(); try { /* do something with resource */ } finally { resource.close(); } </code></pre> <p>or:</p> <pre><code>Resource resource = null; try { resource = getResource(); /* do something with resource */...
[ { "answer_id": 463075, "author": "ForYourOwnGood", "author_id": 48728, "author_profile": "https://Stackoverflow.com/users/48728", "pm_score": -1, "selected": false, "text": "<p>If <i>getResource()</i> throws an exception then <i>resource</i> will be null, <i>getResource()</i> does not re...
2009/01/20
[ "https://Stackoverflow.com/questions/463029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
I have seen two ways of acquiring and disposing resources. Either: ``` Resource resource = getResource(); try { /* do something with resource */ } finally { resource.close(); } ``` or: ``` Resource resource = null; try { resource = getResource(); /* do something with resource */ } finally { if (resource != null) re...
In C#, just use the using statement: ``` using (Resource resource = GetResource()) { /* Do something */ } ``` This is the idiomatic way of cleaning up resources, and relies on the resource in question implementing the `IDisposable` interface. (Java now has a similar try-with-resources statement, for resources im...
463,030
<p>I am creating windows installer project using Visual Studio 2005.</p> <p>Is there an option make it so that my project does NOT have an uninstall option in Add/Remove programs?</p> <p>One of my customers has asked me to do this.. <strong>Here's Why</strong>: Because the installer is a patch to an existing program....
[ { "answer_id": 463090, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 2, "selected": false, "text": "<p>There might be, but to be honest, that's a horrible, horrible idea. It's not your call to tell a user what they can ...
2009/01/20
[ "https://Stackoverflow.com/questions/463030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/814/" ]
I am creating windows installer project using Visual Studio 2005. Is there an option make it so that my project does NOT have an uninstall option in Add/Remove programs? One of my customers has asked me to do this.. **Here's Why**: Because the installer is a patch to an existing program. After uninstalling, the progr...
You just need to set ARPSYSTEMCOMPONENT=1 in the Property table of the installer using [Orca](http://www.microsoft.com/DownLoads/details.aspx?familyid=6A35AC14-2626-4846-BB51-DDCE49D6FFB6&displaylang=en) (Can't be done directly in Visual Studio from what I know) This is commonly used when a program installs dependenci...
463,032
<p>I was browsing through "Text Processing in Python" and tried its <a href="http://gnosis.cx/TPiP/038.code" rel="nofollow noreferrer">example</a> about Schwartzian sort. </p> <p>I used following structure for sample data which also contains empty lines. I sorted this data by fifth column:<br> 383230 -49 -78 1 <strong...
[ { "answer_id": 463081, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 2, "selected": true, "text": "<p>I don't know what is the question, so I'll try to clarify things in a general way.</p>\n\n<p>This algorithm sorts lines b...
2009/01/20
[ "https://Stackoverflow.com/questions/463032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25547/" ]
I was browsing through "Text Processing in Python" and tried its [example](http://gnosis.cx/TPiP/038.code) about Schwartzian sort. I used following structure for sample data which also contains empty lines. I sorted this data by fifth column: 383230 -49 -78 1 **100034** '06 text' 9562 'text' 720 'text' 867 3350...
I don't know what is the question, so I'll try to clarify things in a general way. This algorithm sorts lines by getting the 4th field and placing it in front of the lines. Then built-in `sort()` will use this field to sort. Later the original line is restored. The lines empty or shorter than 5 fields fall into the `...
463,034
<p>What's the best way to use a UISlider to change the volume of the iPhone in an app?</p> <hr> <p>I've tried using that Bill (<a href="https://stackoverflow.com/questions/463034/iphone-sdk-uislider-to-change-volume#463970">Using a UISlider to change volume</a>)</p> <p>But nothing appears on the screen using the cod...
[ { "answer_id": 463970, "author": "Bill Heyman", "author_id": 57349, "author_profile": "https://Stackoverflow.com/users/57349", "pm_score": 0, "selected": false, "text": "<p>Use an MPVolumeView to display a slider that allows the user to modify the system volume.</p>\n" }, { "answ...
2009/01/20
[ "https://Stackoverflow.com/questions/463034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53677/" ]
What's the best way to use a UISlider to change the volume of the iPhone in an app? --- I've tried using that Bill ([Using a UISlider to change volume](https://stackoverflow.com/questions/463034/iphone-sdk-uislider-to-change-volume#463970)) But nothing appears on the screen using the code: ``` MPVolumeView *volumeV...
[Using a UISlider to change volume](https://stackoverflow.com/questions/463034/iphone-sdk-uislider-to-change-volume#465649) ^ I tried that lostintransit, however this is not changing the **ringer volume**. It comes up on the iphone screen, but doesn't change anything. Even using the demo project provided.
463,054
<p>If I have a USER table like</p> <pre><code>class | age -------------- 1 20 3 56 2 11 1 12 2 20 </code></pre> <p>Then I can easily get the youngest user in each class via</p> <pre><code>select class, min(age) from user group by class; </code></pre> <p>Similarly, by replacing mi...
[ { "answer_id": 463087, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 0, "selected": false, "text": "<p>It's pretty easy in SQL Server:</p>\n\n<blockquote>\n<pre><code>select \n *\nfrom(\n select \n *,\n row_n...
2009/01/20
[ "https://Stackoverflow.com/questions/463054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
If I have a USER table like ``` class | age -------------- 1 20 3 56 2 11 1 12 2 20 ``` Then I can easily get the youngest user in each class via ``` select class, min(age) from user group by class; ``` Similarly, by replacing min with max, I can get the oldest. But how can I g...
``` SELECT a.class, ( SELECT b.age FROM users b WHERE b.class = a.class ORDER BY age LIMIT 1,1 ) as age FROM users a GROUP BY a.class ``` Would get the 2nd youngest in each class. If you wanted the 10th youngest, you'd do `LIMIT 9,1` and if you wanted the 10th oldest, you'd do `ORDER BY age DES...
463,067
<p>Taking <a href="http://youtube.com" rel="nofollow noreferrer">http://youtube.com</a>, <a href="http://justin.tv" rel="nofollow noreferrer">http://justin.tv</a>, <a href="http://ustream.tv" rel="nofollow noreferrer">http://ustream.tv</a> as examples, is it possible to do the following:</p> <ul> <li>Open the third pa...
[ { "answer_id": 463087, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 0, "selected": false, "text": "<p>It's pretty easy in SQL Server:</p>\n\n<blockquote>\n<pre><code>select \n *\nfrom(\n select \n *,\n row_n...
2009/01/20
[ "https://Stackoverflow.com/questions/463067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Taking <http://youtube.com>, <http://justin.tv>, <http://ustream.tv> as examples, is it possible to do the following: * Open the third party page in a pop up window * Analyze the height and width of the element * Resize AND offset the window contents to the size of the element This would be specifically useful when e...
``` SELECT a.class, ( SELECT b.age FROM users b WHERE b.class = a.class ORDER BY age LIMIT 1,1 ) as age FROM users a GROUP BY a.class ``` Would get the 2nd youngest in each class. If you wanted the 10th youngest, you'd do `LIMIT 9,1` and if you wanted the 10th oldest, you'd do `ORDER BY age DES...
463,072
<p>Im new with php. Have some questions on how to build. I include everything in index.php. Ex:</p> <pre> ob_start.. html... functions etc.. if ($_GET['page'] == "forum") include('forum.php'); elseif ($_GET['page'] == "profile") include('profile.php'); else error...etc /html... </pre> <p>I do it this way because I ...
[ { "answer_id": 463082, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 1, "selected": false, "text": "<p>Check out <a href=\"https://stackoverflow.com/questions/115629/simplest-php-routing-framework\"><code>this que...
2009/01/20
[ "https://Stackoverflow.com/questions/463072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Im new with php. Have some questions on how to build. I include everything in index.php. Ex: ``` ob_start.. html... functions etc.. if ($_GET['page'] == "forum") include('forum.php'); elseif ($_GET['page'] == "profile") include('profile.php'); else error...etc /html... ``` I do it this way because I dont like to ...
Check out [`this question`](https://stackoverflow.com/questions/115629/simplest-php-routing-framework). The accepted answer has a good take on the most popular routing options. Personally, I use something resembling the `Front Controller` way.
463,105
<p>This is a long text. Please bear with me. Boiled down, the question is: <strong>Is there a workable in-place radix sort algorithm</strong>?</p> <hr> <h2>Preliminary</h2> <p>I've got a huge number of <em>small fixed-length</em> strings that only use the letters “A”, “C”, “G” and “T” (yes, you've guessed it: <a hre...
[ { "answer_id": 463158, "author": "dsimcha", "author_id": 23903, "author_profile": "https://Stackoverflow.com/users/23903", "pm_score": 7, "selected": true, "text": "<p>Well, here's a simple implementation of an MSD radix sort for DNA. It's written in D because that's the language that I...
2009/01/20
[ "https://Stackoverflow.com/questions/463105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1968/" ]
This is a long text. Please bear with me. Boiled down, the question is: **Is there a workable in-place radix sort algorithm**? --- Preliminary ----------- I've got a huge number of *small fixed-length* strings that only use the letters “A”, “C”, “G” and “T” (yes, you've guessed it: [DNA](https://en.wikipedia.org/wik...
Well, here's a simple implementation of an MSD radix sort for DNA. It's written in D because that's the language that I use most and therefore am least likely to make silly mistakes in, but it could easily be translated to some other language. It's in-place but requires `2 * seq.length` passes through the array. ```cp...
463,118
<p>I want to get a list of all of the user databases from an mssql server instance. What's the best way to do this? </p> <p>I know I can select from sys.databases, but I don't see any way to filter out system databases besides hardcoding a list of names to exclude.</p> <p>I need the script to work on 2000/2005 and 20...
[ { "answer_id": 463154, "author": "Joe", "author_id": 57135, "author_profile": "https://Stackoverflow.com/users/57135", "pm_score": 0, "selected": false, "text": "<p>Not sure if you can offhand. One note -- on 2k you'll have to use master.dbo.sysdatabases and not master.sys.databases (wh...
2009/01/20
[ "https://Stackoverflow.com/questions/463118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to get a list of all of the user databases from an mssql server instance. What's the best way to do this? I know I can select from sys.databases, but I don't see any way to filter out system databases besides hardcoding a list of names to exclude. I need the script to work on 2000/2005 and 2008. If the appr...
Was looking in to this again today and decided to profile what Management Studio was doing to populate the Object Explorer details. ![Object Explorer > System Databases](https://i.stack.imgur.com/wT2KJ.png) Turns out the solution Microsoft have implemented is pretty simplistic and boils down to the following: ``` SE...
463,122
<p>If I write a sproc in this format, will sql server do this effeciently or should the sql 'weaving' be done on the server side (.net)?</p> <p>Note: this is just a rough idea of what my query looks like, there are more 'if' clauses the build up my query that I execute using 'exec'</p> <pre><code>declare @sql nvarcha...
[ { "answer_id": 463131, "author": "Joe", "author_id": 57135, "author_profile": "https://Stackoverflow.com/users/57135", "pm_score": 0, "selected": false, "text": "<p>Do you have a good reason for doing this as dynamic SQL?</p>\n\n<p>I've done what you have before in SQL server and it work...
2009/01/20
[ "https://Stackoverflow.com/questions/463122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
If I write a sproc in this format, will sql server do this effeciently or should the sql 'weaving' be done on the server side (.net)? Note: this is just a rough idea of what my query looks like, there are more 'if' clauses the build up my query that I execute using 'exec' ``` declare @sql nvarchar(4000) declare @orde...
Instead of building up a SQL string, why not just use a case statement in the order by? e.g. (assuming one is sorting by first and/or last name on a table with FirstName and LastName fields) ``` order by case when @sortExpression = 'lastname asc' then CAST(LastName as sql_variant) when @sortExpression = 'first...
463,132
<p>I have a text and I need to take the content in a defined pattern. A content between <em>MARK1</em> and <em>MARK2</em> and content after <em>MARK2</em>. However, those marks can repeat and I need to take all their ocurrences. In the example below:</p> <pre><code>text: "textA textB _MARK1_ textC _MARK2_ textD _MARK1...
[ { "answer_id": 463156, "author": "Isaac Dealey", "author_id": 50355, "author_profile": "https://Stackoverflow.com/users/50355", "pm_score": 0, "selected": false, "text": "<p>I don't think you'll be able to achieve this with a single expression. Likely you'll need to break it down into an...
2009/01/20
[ "https://Stackoverflow.com/questions/463132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57238/" ]
I have a text and I need to take the content in a defined pattern. A content between *MARK1* and *MARK2* and content after *MARK2*. However, those marks can repeat and I need to take all their ocurrences. In the example below: ``` text: "textA textB _MARK1_ textC _MARK2_ textD _MARK1_ textE textF _MARK2_ textG textH t...
That would be: ``` /(_MARK1_(.*?)_MARK2_((?:(?!_MARK1_).)*))/g ``` At least, it works on RegEx Coach on your test case. Of course, you need to iterate on each match. Note it might not work on all flavors of regex: JavaScript, for example, has no lookahead assertions.
463,143
<p>I am trying to find a plugin or a solid way to narrow a list of items as a user types.</p> <p>Essentially there would be a list that is always visible containing product names for users to scroll through. At the bottom would be a form where you can type in the name of a product. As you type the list is narrowed dow...
[ { "answer_id": 463210, "author": "David", "author_id": 53192, "author_profile": "https://Stackoverflow.com/users/53192", "pm_score": 6, "selected": true, "text": "<p>Here's a quick example of an approach that can work:</p>\n<p>HTML:</p>\n<pre><code>&lt;ul id=&quot;products&quot;&gt;\n ...
2009/01/20
[ "https://Stackoverflow.com/questions/463143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42648/" ]
I am trying to find a plugin or a solid way to narrow a list of items as a user types. Essentially there would be a list that is always visible containing product names for users to scroll through. At the bottom would be a form where you can type in the name of a product. As you type the list is narrowed down. I have...
Here's a quick example of an approach that can work: HTML: ``` <ul id="products"> <li>Apple</li> <li>Banana</li> <li>Mango</li> </ul> <input id="filter" /> ``` jQuery: ``` var $products = $('#products li'); $('#filter').keyup(function() { var re = new RegExp($(this).val(), "i"); // "i" means it's c...
463,144
<p><strong>Note: solution at the end</strong></p> <p>If I attempt to do a HTTP POST of over 1024 characters, it fails. Why? Here is a minimal example:</p> <p>recipient.php:</p> <pre><code>&lt;?php if (strlen(file_get_contents('php://input')) &gt; 1000 || strlen($HTTP_RAW_POST_DATA) &gt; 1000) { echo "This was a...
[ { "answer_id": 463190, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 2, "selected": false, "text": "<h2>First thoughts...</h2>\n\n<p>The manual page for <a href=\"http://php.net/curl_setopt\" rel=\"nofollow noreferrer\">c...
2009/01/20
[ "https://Stackoverflow.com/questions/463144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8005/" ]
**Note: solution at the end** If I attempt to do a HTTP POST of over 1024 characters, it fails. Why? Here is a minimal example: recipient.php: ``` <?php if (strlen(file_get_contents('php://input')) > 1000 || strlen($HTTP_RAW_POST_DATA) > 1000) { echo "This was a triumph."; } ?> ``` sender.php: ``` <?php func...
You can convince PHP's curl backend to stop doing the 100-continue-thing by setting an explicit request header: ``` curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); ``` This way you can post a request however long you would ever want and curl will not do the dual phase post. I've [blogged about this](http://...
463,155
<p>Please demonstrate how the ternary operator works with a regular if/else block. Example:</p> <pre><code>Boolean isValueBig = value &gt; 100 ? true : false; </code></pre> <hr> <p><strong>Exact Duplicate:</strong> <a href="https://stackoverflow.com/questions/392932/how-do-i-use-the-ternary-operator">How do I use th...
[ { "answer_id": 463160, "author": "Sampson", "author_id": 54680, "author_profile": "https://Stackoverflow.com/users/54680", "pm_score": 2, "selected": false, "text": "<p><strong>PHP Example</strong></p>\n\n<pre><code>&lt;?php\n\n // Example usage for: Ternary Operator\n $action = (empty...
2009/01/20
[ "https://Stackoverflow.com/questions/463155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57006/" ]
Please demonstrate how the ternary operator works with a regular if/else block. Example: ``` Boolean isValueBig = value > 100 ? true : false; ``` --- **Exact Duplicate:** [How do I use the ternary operator?](https://stackoverflow.com/questions/392932/how-do-i-use-the-ternary-operator)
``` Boolean isValueBig = ( value > 100 ) ? true : false; Boolean isValueBig; if( value > 100 ) { isValueBig = true; } else { isValueBig = false; } ```
463,176
<p>Is there a way, in C# code, to send an email without having to know the SMTP server configuration, etc on the server, or have any of that stuff set up?</p> <p>The code I'm developing will be deployed to a live server, but I know nothing about the configuration, so I can't predict what the SMTP server will be.</p>
[ { "answer_id": 463195, "author": "Ray Booysen", "author_id": 42124, "author_profile": "https://Stackoverflow.com/users/42124", "pm_score": 2, "selected": true, "text": "<p>The best answer is if you know nothing until live, can you move all the settings into web.config? This will allow c...
2009/01/20
[ "https://Stackoverflow.com/questions/463176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23341/" ]
Is there a way, in C# code, to send an email without having to know the SMTP server configuration, etc on the server, or have any of that stuff set up? The code I'm developing will be deployed to a live server, but I know nothing about the configuration, so I can't predict what the SMTP server will be.
The best answer is if you know nothing until live, can you move all the settings into web.config? This will allow configuration up until the last minute. Below is some code to dump into your web.config file. I would question as to why you don't have access to this information though ``` <system.net> <mailSettings>...
463,177
<p>From what I've already read this appears to be impossible, but I wanted to see if anyone out there has a secret trick up their sleeve or at least a definitive "no". </p> <p>Supposedly a master page is really just a control for a content page to use, not actually the "master" of a content page. If I wanted to go f...
[ { "answer_id": 463205, "author": "mbillard", "author_id": 810, "author_profile": "https://Stackoverflow.com/users/810", "pm_score": 2, "selected": true, "text": "<p>I don't know if you can between pages (.aspx) but it can definitely be done using UserControls.</p>\n\n<p>ASP.Net pages eac...
2009/01/20
[ "https://Stackoverflow.com/questions/463177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25847/" ]
From what I've already read this appears to be impossible, but I wanted to see if anyone out there has a secret trick up their sleeve or at least a definitive "no". Supposedly a master page is really just a control for a content page to use, not actually the "master" of a content page. If I wanted to go from one cont...
I don't know if you can between pages (.aspx) but it can definitely be done using UserControls. ASP.Net pages each have their own URL so what you're trying to do is to go from one URL to another without any postback, that's just not how it's supposed to work. --- **Using user controls (.ascx):** Create a page that ...
463,194
<p>I'm currently working on a project where I need to consume a Java webservice. If I connect to the service using old webservices (asmx) it works fine. However, If I try to do the same thing with a WCF client I get the following error:</p> <p>The content type text/xml; charset=utf-8 of the response message does not ...
[ { "answer_id": 463296, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 1, "selected": false, "text": "<p>While it isn't <em>required</em> by the SOAP 1.2 specification, it is recommended (i.e. <strong>SHOULD</strong>) that...
2009/01/20
[ "https://Stackoverflow.com/questions/463194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17902/" ]
I'm currently working on a project where I need to consume a Java webservice. If I connect to the service using old webservices (asmx) it works fine. However, If I try to do the same thing with a WCF client I get the following error: The content type text/xml; charset=utf-8 of the response message does not match the c...
Based on your error message, it simply means that your Server response message is SOAP 1.1, while you expect SOAP 1.2. You'll have to change to SOAP 1.1 on the client (using BasicHttpBinding, at least do it to test and see if it works that way).
463,197
<p>I've got an empty DIV element in which I append images by using function createElement("img") and append them with appendChild. So now I've got DIV element full of images.</p> <p>I would like to use one button to clean this DIV and add new images in it simultaneously. Thanks for your help</p>
[ { "answer_id": 463207, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 2, "selected": false, "text": "<p>what do you mean by clean? If you just want to empty it, you can do</p>\n\n<pre><code>document.getElementById(...
2009/01/20
[ "https://Stackoverflow.com/questions/463197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46866/" ]
I've got an empty DIV element in which I append images by using function createElement("img") and append them with appendChild. So now I've got DIV element full of images. I would like to use one button to clean this DIV and add new images in it simultaneously. Thanks for your help
Are you just looking for method `replaceChild? Or you could remove all child elements before adding new images:` ``` // assuming yor div is in variable divelement while (divelement.firstChild) divelement.removeChild(divelement.firstChild); ```
463,228
<p><strong>GetType() returns null</strong> when the type exists in an unreferenced assembly. For example, when the following is called "localType" is always null (even when using the full namespace name of the class):</p> <pre><code>Type localType = Type.GetType("NamespaceX.ProjectX.ClassX"); </code></pre> <p>I don'...
[ { "answer_id": 463325, "author": "toad", "author_id": 48759, "author_profile": "https://Stackoverflow.com/users/48759", "pm_score": 1, "selected": false, "text": "<p>From the <a href=\"http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx\" rel=\"nofollow noreferrer\">MSDN</a> documentat...
2009/01/20
[ "https://Stackoverflow.com/questions/463228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52682/" ]
**GetType() returns null** when the type exists in an unreferenced assembly. For example, when the following is called "localType" is always null (even when using the full namespace name of the class): ``` Type localType = Type.GetType("NamespaceX.ProjectX.ClassX"); ``` I don't see any reason why Type.GetType should...
Use [`LoadFrom`](http://msdn.microsoft.com/en-us/library/1009fa28.aspx) to load the unreferenced assembly from it's location. And then call [`GetType`](http://msdn.microsoft.com/en-us/library/y0cd10tb.aspx). ``` Assembly assembly = Assembly.LoadFrom("c:\ProjectX\bin\release\ProjectX.dll"); Type type = assembly.GetType...
463,233
<p>I have a hierarchy that I'd like to query with LinqToSql:</p> <p>Country -> Region -> City -> ZipCode</p> <p>Each entity holds both a reference to it's parent (eg. Region.Country) and a collection of it's children (eg. Region.Cities).</p> <p>I'd like to eager load each entity's parent along with Countries and Reg...
[ { "answer_id": 463703, "author": "Christopher Edwards", "author_id": 29411, "author_profile": "https://Stackoverflow.com/users/29411", "pm_score": 1, "selected": false, "text": "<p>That's one sticky piece of code, and I wouldn't have answered this due to lack of relevant skill if anyone ...
2009/01/20
[ "https://Stackoverflow.com/questions/463233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32588/" ]
I have a hierarchy that I'd like to query with LinqToSql: Country -> Region -> City -> ZipCode Each entity holds both a reference to it's parent (eg. Region.Country) and a collection of it's children (eg. Region.Cities). I'd like to eager load each entity's parent along with Countries and Regions but lazy load citie...
You're going to want to use the linq designer to set up relationships between your objects. This gets you out of writing join after join after join by creating properties. * between a Country and its Regions * between a Region and its Cities * between a Country and its Localizations * between a Region and its Localiza...
463,235
<p>I have a Apache + Haproxy + Mongrel Cluster setup. I want to receive alerts whenever my Mongrel queue length gets too high. </p> <p>How to I get the current Mongrel Queue length and make it available for alerting tools such as Monit and Nagios?</p> <p>I know that Haproxy has the information about Mongrel queue as ...
[ { "answer_id": 735477, "author": "md.", "author_id": 77493, "author_profile": "https://Stackoverflow.com/users/77493", "pm_score": 0, "selected": false, "text": "<p>New Relic's RPM product (www.newrelic.com) maintains information on Mongrel queue length. They have an API that you may be ...
2009/01/20
[ "https://Stackoverflow.com/questions/463235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17494/" ]
I have a Apache + Haproxy + Mongrel Cluster setup. I want to receive alerts whenever my Mongrel queue length gets too high. How to I get the current Mongrel Queue length and make it available for alerting tools such as Monit and Nagios? I know that Haproxy has the information about Mongrel queue as it intelligently ...
Add this to your haproxy config ``` stats uri /haproxy/hastats ``` Then use lynx to get the stats like this: (assuming haproxy runs on port 10000 - adjust to suit) ``` lynx --dump http://my-server:10000/haproxy/hastats ``` Each there will be a line for each of your server entries in the haproxy config fi...
463,258
<p>I wrote a VB script that creates an .xls file, based on .xlt file. Then it calls a macro from the .xls file that populates it with information from a database. In the last step the script saves the .xls file on the disk.</p> <p>I did this before with VB and Excel 2003. Now I upgraded to Excel 2007 and before it sav...
[ { "answer_id": 463409, "author": "Geoff", "author_id": 55487, "author_profile": "https://Stackoverflow.com/users/55487", "pm_score": 0, "selected": false, "text": "<p>Do you really need to save it with the macros included? If not, use:\nActiveWorkbook.SaveAs Filename:=\"E:\\Work\\Send M...
2009/01/20
[ "https://Stackoverflow.com/questions/463258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I wrote a VB script that creates an .xls file, based on .xlt file. Then it calls a macro from the .xls file that populates it with information from a database. In the last step the script saves the .xls file on the disk. I did this before with VB and Excel 2003. Now I upgraded to Excel 2007 and before it saves the fil...
Merging responses from the two duplicate questions the poster asked: 1 = [Preventing False.xls when saving files in Excel](http://www.excelforum.com/excel-programming/501828-preventing-false-xls-when-automating-saveas.html) 2 = You are using named parameters in the .SaveAs wrong. When writing out the named paramete...
463,268
<p>This is the same question as <a href="https://stackoverflow.com/questions/174888/asp-net-iis6-how-to-search-the-servers-mime-map">this</a> but I'm looking for a classic ASP solution.</p> <p>I have a third party control to provide secure downloads but it expects you to provide the response.contenttype value. I'm try...
[ { "answer_id": 463409, "author": "Geoff", "author_id": 55487, "author_profile": "https://Stackoverflow.com/users/55487", "pm_score": 0, "selected": false, "text": "<p>Do you really need to save it with the macros included? If not, use:\nActiveWorkbook.SaveAs Filename:=\"E:\\Work\\Send M...
2009/01/20
[ "https://Stackoverflow.com/questions/463268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7736/" ]
This is the same question as [this](https://stackoverflow.com/questions/174888/asp-net-iis6-how-to-search-the-servers-mime-map) but I'm looking for a classic ASP solution. I have a third party control to provide secure downloads but it expects you to provide the response.contenttype value. I'm trying to have the brows...
Merging responses from the two duplicate questions the poster asked: 1 = [Preventing False.xls when saving files in Excel](http://www.excelforum.com/excel-programming/501828-preventing-false-xls-when-automating-saveas.html) 2 = You are using named parameters in the .SaveAs wrong. When writing out the named paramete...
463,273
<p>Following the directions at <a href="https://stackoverflow.com/questions/462270/get-file-icon-used-by-shell">this question</a>, I have some code running to extract icons from files and display them in a ListView set to details mode. I want to icons to display at 16 x 16, but when I have the ImageList size set to tha...
[ { "answer_id": 463303, "author": "Stefan", "author_id": 19307, "author_profile": "https://Stackoverflow.com/users/19307", "pm_score": 5, "selected": true, "text": "<p>You have to use 2 imagelists, one for smallimages and one for largeimages to get the best result I think. (The listview h...
2009/01/20
[ "https://Stackoverflow.com/questions/463273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1912/" ]
Following the directions at [this question](https://stackoverflow.com/questions/462270/get-file-icon-used-by-shell), I have some code running to extract icons from files and display them in a ListView set to details mode. I want to icons to display at 16 x 16, but when I have the ImageList size set to that the icons th...
You have to use 2 imagelists, one for smallimages and one for largeimages to get the best result I think. (The listview has two properties, LargeImageList and SmallImageList) Edit (found new information that worked when I tried): This version are using interpolation to get the smaller thumb, should be better. ```vb ...
463,282
<h2>I challenge you :)</h2> <p>I have a process that someone already implemented. I will try to describe the requirements, and I was hoping I could get some input to the "best way" to do this.</p> <hr /> <p>It's for a financial institution.</p> <p>I have a routing framework that will allow me to recieve files and s...
[ { "answer_id": 463425, "author": "Rasmus Faber", "author_id": 5542, "author_profile": "https://Stackoverflow.com/users/5542", "pm_score": 1, "selected": false, "text": "<p>When you receive the file, parse it and put the information in the database.</p>\n\n<p>Make one table with a record ...
2009/01/20
[ "https://Stackoverflow.com/questions/463282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/86/" ]
I challenge you :) ------------------ I have a process that someone already implemented. I will try to describe the requirements, and I was hoping I could get some input to the "best way" to do this. --- It's for a financial institution. I have a routing framework that will allow me to recieve files and send reques...
Simplify as much as possible. The batches (trying to process them as units, and their various sizes) appear to be discardable in terms of the simplest process. It sounds like the rows are atomic, not the batches. Feed all the lines as separate atomic transactions through an asynchronous FIFO message queue, with a goo...
463,285
<p>I am new with learning the possibilities of Linq to XML and I recently have found that I can query an xml like a data base (I am quite fascinated by it now).</p> <p>My question is How can I query an xml file and save the result in another xml file?:</p> <pre><code> string url = "employees.xml"; XElement employee...
[ { "answer_id": 463301, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 1, "selected": false, "text": "<p>Well, you could do this by creating an XDocument/XElement instance and then populating it with the results of your qu...
2009/01/20
[ "https://Stackoverflow.com/questions/463285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am new with learning the possibilities of Linq to XML and I recently have found that I can query an xml like a data base (I am quite fascinated by it now). My question is How can I query an xml file and save the result in another xml file?: ``` string url = "employees.xml"; XElement employees= XElement.Load(url)...
Well, you could do this by creating an XDocument/XElement instance and then populating it with the results of your query (by passing the query to the constructor of the XDocument/XElement), and then saving that. However, you might want to consider using an XSLT transformation instead, as that is really what you are tr...
463,292
<p>I have a name of table or view in PostgreSQL database and need to delete in in single pgSQL command. How can i afford it?</p> <p>I was able to select form system table to find out if there any table with such a name but stuck with procedural part:</p> <pre><code>SELECT count(*) FROM pg_tables where tablename='user...
[ { "answer_id": 463314, "author": "empi", "author_id": 49048, "author_profile": "https://Stackoverflow.com/users/49048", "pm_score": 5, "selected": true, "text": "<pre><code>DROP TABLE user_statistics;\n\nDROP VIEW user_statistics;\n</code></pre>\n\n<p>complete syntax:</p>\n\n<p><a href=\...
2009/01/20
[ "https://Stackoverflow.com/questions/463292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2313/" ]
I have a name of table or view in PostgreSQL database and need to delete in in single pgSQL command. How can i afford it? I was able to select form system table to find out if there any table with such a name but stuck with procedural part: ``` SELECT count(*) FROM pg_tables where tablename='user_statistics'; ```
``` DROP TABLE user_statistics; DROP VIEW user_statistics; ``` complete syntax: [DROP TABLE](http://www.postgresql.org/docs/7.4/interactive/sql-droptable.html) [DROP VIEW](http://www.postgresql.org/docs/8.1/static/sql-dropview.html) And if you want a complete function, i tried something like this: ``` CREATE OR ...
463,295
<p>I'm using Java - Ibatis and mySQL with Flex/Flash on the front-end. I have one requirement that is to be able to dynamically add creterias and table to a query depending on the user role. here is an example</p> <p>Same object calling same SQL but different result based on role</p> <p>Role 1 : Fully Access to emp...
[ { "answer_id": 463371, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 0, "selected": false, "text": "<p>The problem with using role within the query is that you have to then supply it as an argument to the query for possibly...
2009/01/20
[ "https://Stackoverflow.com/questions/463295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using Java - Ibatis and mySQL with Flex/Flash on the front-end. I have one requirement that is to be able to dynamically add creterias and table to a query depending on the user role. here is an example Same object calling same SQL but different result based on role Role 1 : Fully Access to employees ``` SELECT ...
``` SELECT * FROM Employee A <isNotEmpty property="ROLE" > inner join SECURE_LIST B on B.EmployeeID = A.EmployeeID </isNotEmpty> <dynamic prepend="WHERE"> <isNotEmpty property="ROLE" prepend="AND"> B.ROLE_ID = #ROLE# </isNotEmpty> </dynamic> ``` A little simpler than creating DAOs but ...
463,299
<p>I have a windows forms app with a textbox control that I want to only accept integer values. In the past I've done this kind of validation by overloading the KeyPress event and just removing characters which didn't fit the specification. I've looked at the MaskedTextBox control but I'd like a more general solution t...
[ { "answer_id": 463316, "author": "Perpetualcoder", "author_id": 37494, "author_profile": "https://Stackoverflow.com/users/37494", "pm_score": 2, "selected": false, "text": "<p>you could use <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.control.textchanged.aspx\" ...
2009/01/20
[ "https://Stackoverflow.com/questions/463299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2191/" ]
I have a windows forms app with a textbox control that I want to only accept integer values. In the past I've done this kind of validation by overloading the KeyPress event and just removing characters which didn't fit the specification. I've looked at the MaskedTextBox control but I'd like a more general solution that...
Two options: 1. Use a [`NumericUpDown`](http://msdn.microsoft.com/en-us/library/system.windows.forms.numericupdown(v=vs.110).aspx) instead. NumericUpDown does the filtering for you, which is nice. Of course it also gives your users the ability to hit the up and down arrows on the keyboard to increment and decrement th...
463,302
<p>What would you consider to be the best exception type to throw when an extension method is called on a null instance (where the extension method does not allow it)? Since extension methods are nothing but static methods you could argue that it should be ArgumentNullException, but on the other hand they're used like ...
[ { "answer_id": 463313, "author": "mqp", "author_id": 55943, "author_profile": "https://Stackoverflow.com/users/55943", "pm_score": 2, "selected": false, "text": "<p>From the user's standpoint, the method looks and acts like an instance method, so if I were them, I would expect to see a N...
2009/01/20
[ "https://Stackoverflow.com/questions/463302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46187/" ]
What would you consider to be the best exception type to throw when an extension method is called on a null instance (where the extension method does not allow it)? Since extension methods are nothing but static methods you could argue that it should be ArgumentNullException, but on the other hand they're used like ins...
In general, exceptions included, you should treat an extension method as if it were a normal static method. In this case you should throw an ArgumentNullException. Throwing a NullReferenceException here is a bad idea for a few reasons * A null reference did not actually occur so seeing one is counterintuitive * Throw...
463,333
<p>I have any number of anchor links on a page that need to execute the same block of JavaScript code on click, and that code needs to be associated with one value. There are several of these on each page. I usually use a hidden input to store the value in a one-to-one relationship, but what is the best way to associat...
[ { "answer_id": 463369, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": 0, "selected": false, "text": "<p>Do you want to set the values in your html code? Otherwise, you can dynamically add the values to the dom nodes thems...
2009/01/20
[ "https://Stackoverflow.com/questions/463333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have any number of anchor links on a page that need to execute the same block of JavaScript code on click, and that code needs to be associated with one value. There are several of these on each page. I usually use a hidden input to store the value in a one-to-one relationship, but what is the best way to associate s...
If your already using Mootools, a good way to do this is using the element's [data storage](http://mootools.net/docs/Element/Element#Element:store). ``` window.addEvent('domready', function() { $$('a.classname').each(function(el) { el.store('productID', /*get this however you want*/); el.addEvent('click', f...
463,341
<p>I am trying to retrieve a list of date strings ordered by date like this...</p> <pre><code>SELECT DISTINCT CONVERT(Varchar(10), GeneratedDate, 101) AS GeneratedDate FROM dbo.ProviderProcessGeneratedDate ORDER BY GeneratedDate </code></pre> <p>This orders by the varchar that I converted the dates to.</p> <p>exampl...
[ { "answer_id": 463352, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 1, "selected": false, "text": "<pre><code> SELECT DISTINCT Convert(DATETIME,CONVERT(Varchar(10), GeneratedDate, 101)) \n AS ...
2009/01/20
[ "https://Stackoverflow.com/questions/463341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6161/" ]
I am trying to retrieve a list of date strings ordered by date like this... ``` SELECT DISTINCT CONVERT(Varchar(10), GeneratedDate, 101) AS GeneratedDate FROM dbo.ProviderProcessGeneratedDate ORDER BY GeneratedDate ``` This orders by the varchar that I converted the dates to. example... 02/01/2008 02/15/2008 ...
The reason your first query gave a different order from what you wanted is... - You use the field "GeneratedDate" to create your string - You then alias that result field to "GeneratedDate" - You then order by "GeneratedDate" without specifying the table - So the result field is being used for ordering Th...
463,349
<p>What exactly does JPA's fetch strategy control? I can't detect any difference between eager and lazy. In both cases JPA/Hibernate does not automatically join many-to-one relationships.</p> <p>Example: Person has a single address. An address can belong to many people. The JPA annotated entity classes look like:</p> ...
[ { "answer_id": 463386, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 0, "selected": false, "text": "<p>Two things occur to me.</p>\n\n<p>First, are you sure you mean ManyToOne for address? That means multiple people will ...
2009/01/20
[ "https://Stackoverflow.com/questions/463349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
What exactly does JPA's fetch strategy control? I can't detect any difference between eager and lazy. In both cases JPA/Hibernate does not automatically join many-to-one relationships. Example: Person has a single address. An address can belong to many people. The JPA annotated entity classes look like: ``` @Entity p...
JPA doesn't provide any specification on mapping annotations to select fetch strategy. In general, related entities can be fetched in any one of the ways given below * SELECT => one query for root entities + one query for related mapped entity/collection of each root entity = (n+1) queries * SUBSELECT => one query for...
463,377
<p>I'm wondering how others handle this situation... and how to apply the Don't Repeat Yourself (DRY) principle to this situation.</p> <p>I find myself constantly PIVOTing or writing CASE statements in T-SQL to present Months as columns. I generally have some fields that will include (1) a date field and (2) a value f...
[ { "answer_id": 463395, "author": "gkrogers", "author_id": 54501, "author_profile": "https://Stackoverflow.com/users/54501", "pm_score": 1, "selected": false, "text": "<p>It's late and I might be missing something obvious here, but will a Months table with a row for each month help you do...
2009/01/20
[ "https://Stackoverflow.com/questions/463377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
I'm wondering how others handle this situation... and how to apply the Don't Repeat Yourself (DRY) principle to this situation. I find myself constantly PIVOTing or writing CASE statements in T-SQL to present Months as columns. I generally have some fields that will include (1) a date field and (2) a value field. When...
This isn't exactly what you're looking for, but I've done a lot of repetitive `UNPIVOT`, and typically, I would code-gen this, with some kind of standardized naming and use CTEs heavily: ``` WITH P AS ( SELECT Some Data ,[234] -- These are stats ,[235] FROM Whatever ) ,FINAL_UNPIVO...
463,383
<p>I'm creating a jquery time entry in an onready() handler and hiding it in another onready() handler in jquery. (The reason that the code is being called in two different onread() handlers is that the time entry is being created via a reusable Django widget renderer and hidden via local screen application logic.)</p...
[ { "answer_id": 463408, "author": "Ironicnet", "author_id": 47213, "author_profile": "https://Stackoverflow.com/users/47213", "pm_score": 0, "selected": false, "text": "<p>Can't do this?</p>\n\n<pre><code>$(document).ready(function(){\n var id = \"#id_testTimePicker\";\n $(id).timeE...
2009/01/20
[ "https://Stackoverflow.com/questions/463383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36680/" ]
I'm creating a jquery time entry in an onready() handler and hiding it in another onready() handler in jquery. (The reason that the code is being called in two different onread() handlers is that the time entry is being created via a reusable Django widget renderer and hidden via local screen application logic.) The j...
In the second ready handler, include a call to ".show()" before calling timeEntry, then ".hide()" it again afterwards. That said, it seems odd that timeEntry would care if it was visible or not. It really shouldn't matter, so I would guess it's a bug in timeEntry. EDIT: If you don't know in the second handler if it s...
463,398
<p>I have a Repeater control which in some of its cells contains a UserControl which contains a DropDownList. On the ItemDataBound event of the Repeater control I'm assigning an event to the DropDownList like so:</p> <pre><code>protected void MyRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { ... ...
[ { "answer_id": 463582, "author": "Ken Browning", "author_id": 53162, "author_profile": "https://Stackoverflow.com/users/53162", "pm_score": 3, "selected": false, "text": "<p>Your event is not being raised in a PostBack because your event handler has not been attached (it is only attached...
2009/01/20
[ "https://Stackoverflow.com/questions/463398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a Repeater control which in some of its cells contains a UserControl which contains a DropDownList. On the ItemDataBound event of the Repeater control I'm assigning an event to the DropDownList like so: ``` protected void MyRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { ... MyControl myC...
Your event is not being raised in a PostBack because your event handler has not been attached (it is only attached during the iteration of the page life-cycle when your repeater is databound). If you attach your event handler declaratively in the markup such as: ``` <asp:Repeater ID="Repeater1" runat="server"> <...
463,400
<p>I created a Mnesia database / Schema on machine1. The node was named mypl@machine1. I then moved all files to machine2, because machine1 broke down. Everything runs fine as long as the code is running with the name "mypl@machine1". Obviously this is somewhat confugsing, because it is now running on machine2.</p> <p...
[ { "answer_id": 464465, "author": "Hynek -Pichi- Vychodil", "author_id": 49197, "author_profile": "https://Stackoverflow.com/users/49197", "pm_score": 2, "selected": false, "text": "<p>Workaround is migration. Just start mnesia cluster and migrate all your tables and schema to other node....
2009/01/20
[ "https://Stackoverflow.com/questions/463400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49407/" ]
I created a Mnesia database / Schema on machine1. The node was named mypl@machine1. I then moved all files to machine2, because machine1 broke down. Everything runs fine as long as the code is running with the name "mypl@machine1". Obviously this is somewhat confugsing, because it is now running on machine2. If I star...
I don't think this can be done online on a single node(anyone?), but it is possible to do via a backup/restore in addition to running two nodes and adding table copies. In the [Mnesia User's guide](http://erlang.org/doc/apps/mnesia/part_frame.html) section 6.9.1 you'll find some code that uses mnesia:traverse\_backup t...
463,406
<p>I have a temp table I am creating a query off of in the following format. That contains a record for every CustomerID, Year, and Month for several years.</p> <h2>#T</h2> <p>Customer | CustomerID | Year | Month</p> <p>ex.</p> <pre><code>Foo | 12345 | 2008 | 12 Foo | 12345 | 2008 | 11 Bar | 11224 | 2007 | 7 </...
[ { "answer_id": 463484, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 1, "selected": false, "text": "<p>The problem is that there are two rows in <code>#T</code> with CustomerID = 12345. Each of those rows joins w...
2009/01/20
[ "https://Stackoverflow.com/questions/463406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203/" ]
I have a temp table I am creating a query off of in the following format. That contains a record for every CustomerID, Year, and Month for several years. #T -- Customer | CustomerID | Year | Month ex. ``` Foo | 12345 | 2008 | 12 Foo | 12345 | 2008 | 11 Bar | 11224 | 2007 | 7 ``` When I join this temp table to...
You're specifying the date on the event table but not on the join -- so it's joining all records from the temp table with a matching customerid. Try this: ``` SELECT COUNT(e.EventID), T.Customer, T.Year, T.Month FROM [Event] e INNER JOIN #T T ON ( T.CustomerID = e.CustomerID and T.Year = year(e.DateOpened) and...
463,416
<p>What are the underlying transformations that are necessary to convert data in a little-endian system into network byte order? For 2 byte and 4 byte data there are well-known functions (such as htons, ntohl, etc.) to encapsulate the changes, what happens for strings of 1 byte data (if anything)?</p> <p>Also, Wikiped...
[ { "answer_id": 463438, "author": "Doug Currie", "author_id": 33252, "author_profile": "https://Stackoverflow.com/users/33252", "pm_score": 4, "selected": true, "text": "<p>Let's say you have the ASCII text \"BigE\" in an array <code>b</code> of bytes. </p>\n\n<pre><code>b[0] == 'B'\nb[1]...
2009/01/20
[ "https://Stackoverflow.com/questions/463416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43371/" ]
What are the underlying transformations that are necessary to convert data in a little-endian system into network byte order? For 2 byte and 4 byte data there are well-known functions (such as htons, ntohl, etc.) to encapsulate the changes, what happens for strings of 1 byte data (if anything)? Also, Wikipedia implies...
Let's say you have the ASCII text "BigE" in an array `b` of bytes. ``` b[0] == 'B' b[1] == 'i' b[2] == 'g' b[3] == 'E' ``` This is network order for the string as well. If it was treated as a 32 bit integer, it would be ``` 'B' + ('i' << 8) + ('g' << 16) + ('E' << 24) ``` on a little endian platform and ```...
463,421
<p>I've a table [File] that has the following schema</p> <pre><code>CREATE TABLE [dbo].[File] ( [FileID] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](256) NOT NULL, CONSTRAINT [PK_File] PRIMARY KEY CLUSTERED ( [FileID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, AL...
[ { "answer_id": 463435, "author": "Miyagi Coder", "author_id": 46780, "author_profile": "https://Stackoverflow.com/users/46780", "pm_score": 0, "selected": false, "text": "<p>Using the Exists function might clean things up a little.</p>\n\n<pre><code>if (Exists(select * from table_name wh...
2009/01/20
[ "https://Stackoverflow.com/questions/463421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've a table [File] that has the following schema ``` CREATE TABLE [dbo].[File] ( [FileID] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](256) NOT NULL, CONSTRAINT [PK_File] PRIMARY KEY CLUSTERED ( [FileID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS ...
If you are searching heavily on the Name field, you will probably want it indexed (as unique, and maybe even clustered if this is the *primary* search field). As you don't use the @FileID from the first select, I would just select count(\*) from file where Name = @Name and see if it is greater than zero (this will prev...
463,424
<p>I have a base UserControl (BaseControl.cs) which has an OK and Cancel buttons on it. When the buttons are clicked, an event is fired. Typically other UserControl objects inherit from the BaseControl. Finally the descendant UserControl objects are placed on a WinForm, where they hook into the events for clicking Ok...
[ { "answer_id": 463432, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 0, "selected": false, "text": "<p>You would typically create a <code>protected virtual Validate()</code> method, which gets called in the BaseControl's event...
2009/01/20
[ "https://Stackoverflow.com/questions/463424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9382/" ]
I have a base UserControl (BaseControl.cs) which has an OK and Cancel buttons on it. When the buttons are clicked, an event is fired. Typically other UserControl objects inherit from the BaseControl. Finally the descendant UserControl objects are placed on a WinForm, where they hook into the events for clicking Ok/Canc...
The standard pattern for implementing events is to use a virtual "OnXxx" method, like this: ``` public event EventHandler OkClick; protected virtual void OnOkClick(EventArgs e) { if (OkClick != null) OkClick(this, e); } ``` Now any time your base control wants to fire the "OkClick" event, it simply calls: ``` O...
463,458
<p>Well right now I have a page (page2.php) and at the top it does some validation checking and if something fails it bounces back to page1.php. The problem is that page1.php is loaded by a post meaning it is the end result of a form. This means that all the post data I originally have on page1.php is lost.</p> <p>S...
[ { "answer_id": 463465, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 3, "selected": false, "text": "<p>You can post data back with <a href=\"http://us2.php.net/curl\" rel=\"nofollow noreferrer\"><code>cURL</code><...
2009/01/20
[ "https://Stackoverflow.com/questions/463458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428190/" ]
Well right now I have a page (page2.php) and at the top it does some validation checking and if something fails it bounces back to page1.php. The problem is that page1.php is loaded by a post meaning it is the end result of a form. This means that all the post data I originally have on page1.php is lost. So here is my...
You can post data back with [`cURL`](http://us2.php.net/curl) or re-structure to do the validation at the top of `page1.php` and if it doesn't fail, take to `page2.php`. If you are doing some sort of multi-step form, you could save all the data in a session and populate fields if there's matching data in the session. N...
463,460
<p>Given a string with replacement keys in it, how can I most efficiently replace these keys with runtime values, using <strong>Java</strong>? I need to do this often, fast, and on reasonably long strings (say, on average, 1-2kb). The form of the keys is my choice, since I'm providing the templates here too.</p> <p>...
[ { "answer_id": 463479, "author": "Michael Myers", "author_id": 13531, "author_profile": "https://Stackoverflow.com/users/13531", "pm_score": 4, "selected": true, "text": "<p>The appendReplacement method in <a href=\"http://java.sun.com/javase/6/docs/api/java/util/regex/Matcher.html\" rel...
2009/01/20
[ "https://Stackoverflow.com/questions/463460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23309/" ]
Given a string with replacement keys in it, how can I most efficiently replace these keys with runtime values, using **Java**? I need to do this often, fast, and on reasonably long strings (say, on average, 1-2kb). The form of the keys is my choice, since I'm providing the templates here too. Here's an example (please...
The appendReplacement method in [Matcher](http://java.sun.com/javase/6/docs/api/java/util/regex/Matcher.html) looks like it might be useful, although I can't vouch for its speed. Here's the sample code from the Javadoc: ``` Pattern p = Pattern.compile("cat"); Matcher m = p.matcher("one cat two cats in the yard"); Str...
463,463
<p>I am reading the book 'Practical Common Lisp' by Peter Seibel.</p> <p>In Chapter 6, &quot;Variables&quot; sections &quot;Lexical Variables and Closures&quot; and &quot;Dynamic, a.k.a. Special, Variables&quot;. <a href="http://www.gigamonkeys.com/book/variables.html" rel="nofollow noreferrer">http://www.gigamonkeys.c...
[ { "answer_id": 463837, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 6, "selected": true, "text": "<p>When a variable is <strong>lexically scoped</strong>, the system looks to where the function is <strong>defined</strong>...
2009/01/20
[ "https://Stackoverflow.com/questions/463463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48486/" ]
I am reading the book 'Practical Common Lisp' by Peter Seibel. In Chapter 6, "Variables" sections "Lexical Variables and Closures" and "Dynamic, a.k.a. Special, Variables". <http://www.gigamonkeys.com/book/variables.html> My problem is that the examples in both sections show how (let ...) can shadow global variables ...
When a variable is **lexically scoped**, the system looks to where the function is **defined** to find the value for a free variable. When a variable is **dynamically scoped**, the system looks to where the function is **called** to find the value for the free variable. Variables in Common Lisp are all lexical by defau...
463,482
<p>I'm trying to extract the query's name-value pairs from a URL using J2ME, but it doesn't make it easy. J2ME doesn't have the java.net.URL class nor does String have a split method.</p> <p>Is there a way to extract name-value pairs from a URL using J2ME? Any open source implementations would be welcome too.</p>
[ { "answer_id": 463497, "author": "omermuhammed", "author_id": 33121, "author_profile": "https://Stackoverflow.com/users/33121", "pm_score": -1, "selected": false, "text": "<p>A URL Encoder/Decoder is really simple and easy to write. You can also look up any open source HTML to WML transc...
2009/01/20
[ "https://Stackoverflow.com/questions/463482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/680/" ]
I'm trying to extract the query's name-value pairs from a URL using J2ME, but it doesn't make it easy. J2ME doesn't have the java.net.URL class nor does String have a split method. Is there a way to extract name-value pairs from a URL using J2ME? Any open source implementations would be welcome too.
Here's my stab at it, some similarity to David's answer. ``` String url = "http://www.stackoverflow.com?name1=value1&name2=value2&name3=value3"; String[] names = new String[10]; String[] values = new String[10]; int s = url.indexOf("?"); // Get start index of first name int e = 0, idx = 0; ...
463,487
<p>Using WiX (Windows Installer XML) I have created an MSI installer which installs Word templates into the users Application Data folder, e.g. on Windows XP </p> <pre><code>C:\Documents and Settings\&lt;user&gt;\Application Data\Microsoft\Templates </code></pre> <p>I'm retrieving the path to this folder from the reg...
[ { "answer_id": 463524, "author": "Wim Coenen", "author_id": 52626, "author_profile": "https://Stackoverflow.com/users/52626", "pm_score": 4, "selected": true, "text": "<p>You should use <a href=\"http://msdn.microsoft.com/en-us/library/aa367565(VS.85).aspx\" rel=\"nofollow noreferrer\">[...
2009/01/20
[ "https://Stackoverflow.com/questions/463487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40347/" ]
Using WiX (Windows Installer XML) I have created an MSI installer which installs Word templates into the users Application Data folder, e.g. on Windows XP ``` C:\Documents and Settings\<user>\Application Data\Microsoft\Templates ``` I'm retrieving the path to this folder from the registry: ``` <Property Id="APPDIR...
You should use [[AppDataFolder]](http://msdn.microsoft.com/en-us/library/aa367565(VS.85).aspx) instead. I can't find anything about "appdir" in the [windows installer property reference](http://msdn.microsoft.com/en-us/library/aa370905(VS.85).aspx). **Edit** after question edit: The [shell folders key (great blogpost ...
463,488
<p>I have this javascript code working in firefox, chrome, and safari</p> <pre><code>for (idx in all_auction_ids){ alert(all_auction_ids[idx]); }; </code></pre> <p>for the above, instead of getting the values in <code>all_auction_ids</code>, the first value I get is text of type function that looks like a for loo...
[ { "answer_id": 463513, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 3, "selected": false, "text": "<p>JavaScript's for/in construct is traditionally for iterating over object member names, not array indices. The more forw...
2009/01/20
[ "https://Stackoverflow.com/questions/463488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56454/" ]
I have this javascript code working in firefox, chrome, and safari ``` for (idx in all_auction_ids){ alert(all_auction_ids[idx]); }; ``` for the above, instead of getting the values in `all_auction_ids`, the first value I get is text of type function that looks like a for loop! But if I run the code below, it w...
JavaScript's for/in construct is traditionally for iterating over object member names, not array indices. The more forward-thinking browsers have added features like hidden properties to help cases like Array enumerate in the way you would expect, but IE stilll does it the old-school way and gives you Object members li...
463,493
<p>Ok, so I'm trying to get some UDP code working and I'm barely green when it comes to network programming using C. I'm using the sample file from <a href="http://beej.us/guide/bgnet/examples/listener.c" rel="nofollow noreferrer">here</a></p> <p>Basically I'm just listening for incoming UDP packets on a given port an...
[ { "answer_id": 463517, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 5, "selected": true, "text": "<p>You should not be passing the address of the socket structure length to <code>sendto()</code> - it requires the actual...
2009/01/20
[ "https://Stackoverflow.com/questions/463493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57290/" ]
Ok, so I'm trying to get some UDP code working and I'm barely green when it comes to network programming using C. I'm using the sample file from [here](http://beej.us/guide/bgnet/examples/listener.c) Basically I'm just listening for incoming UDP packets on a given port and then I want to send some data back the same w...
You should not be passing the address of the socket structure length to `sendto()` - it requires the actual length (i.e., `"addr_len"`, not `"&addr_len"`). The reason you pass the *address* of the length to `recvfrom()` is that it is changed by that function if the real address happens to be shorter. In other words, ...
463,499
<p>I know that I can <code>Map(x =&gt; x.GroupName).WithUniqueConstraint()</code> for a single property.</p> <p>But how do create a composite unique constraint in fluent nHibernate (where the unique constraint operates on the combination of two columns)?</p>
[ { "answer_id": 480933, "author": "mookid8000", "author_id": 6560, "author_profile": "https://Stackoverflow.com/users/6560", "pm_score": 3, "selected": false, "text": "<p>Use <code>SetAttribute</code> in your mapping file like so:</p>\n\n<pre><code>Map(x =&gt; x.Something).SetAttribute(\"...
2009/01/20
[ "https://Stackoverflow.com/questions/463499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24954/" ]
I know that I can `Map(x => x.GroupName).WithUniqueConstraint()` for a single property. But how do create a composite unique constraint in fluent nHibernate (where the unique constraint operates on the combination of two columns)?
In the latest version that I have used, it is`UniqueKey("KeyName")`that does this. ``` Map(x => x.Something).UniqueKey("KeyName"); Map(x => x.SomeOtherThing).UniqueKey("KeyName"); ```
463,501
<p>Will it make any difference if I grab a Dr Watson crash dump on a hung process, instead of ADPlus hang dump?</p> <p>Thank you Surya</p>
[ { "answer_id": 463611, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 1, "selected": false, "text": "<p>Dr. Watson will only generate a crash dump if the process actually crashes. If the process only hangs without a crash,...
2009/01/20
[ "https://Stackoverflow.com/questions/463501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Will it make any difference if I grab a Dr Watson crash dump on a hung process, instead of ADPlus hang dump? Thank you Surya
I created a full dump with adplus -hang and drwtsn32 and used dumpchk to compare the two. Both are full dumps, but the flags used are different (on XP sp3) Drwatson: ``` 0002 MiniDumpWithFullMemory 0004 MiniDumpWithHandleData ``` Hang Mode ADPlus: ``` 0002 MiniDumpWithFullMemory 0004 MiniDumpWithHandleData 0020 Mi...
463,503
<p>I have a web application that was originally written on .Net 1.1 Framework. I have since tried you upgrade it to .Net 3.5 Framework. I am now getting this javascript error throw on my page and for the life of me can't figure out exactly why.</p> <p>I have target the application for the .Net 3.5 framework, and even...
[ { "answer_id": 463518, "author": "chris", "author_id": 4782, "author_profile": "https://Stackoverflow.com/users/4782", "pm_score": 0, "selected": false, "text": "<p>I'd guess there's a missing javascript library - check your access logs to see what requests are generating a 404.</p>\n" ...
2009/01/20
[ "https://Stackoverflow.com/questions/463503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1768/" ]
I have a web application that was originally written on .Net 1.1 Framework. I have since tried you upgrade it to .Net 3.5 Framework. I am now getting this javascript error throw on my page and for the life of me can't figure out exactly why. I have target the application for the .Net 3.5 framework, and even deleted an...
I tend to use FireBug in Firefox - it allows you to see the contents of each dynamic .js file - you'll probably find that one of them is producing either a 404 or a 500 Internal Server Error. Without knowing which AJAX framework you're using, I can't really help all that much, but I'd take a look at the httpHandlers d...
463,506
<p>I can get the element like this <code>$("#txtEmail")</code> but I'm not sure how to get the actual value.</p>
[ { "answer_id": 463514, "author": "Spencer Ruport", "author_id": 52551, "author_profile": "https://Stackoverflow.com/users/52551", "pm_score": 6, "selected": false, "text": "<p>Use the .val() method.</p>\n\n<p>Also I think you meant to use <code>$(\"#txtEmail\")</code> as <code>$(\"txtEma...
2009/01/20
[ "https://Stackoverflow.com/questions/463506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
I can get the element like this `$("#txtEmail")` but I'm not sure how to get the actual value.
There's a `.val()` method: If you've got an input with an id of `txtEmail` you can use the following code to access the value of the text box: ``` $("#txtEmail").val() ``` You can also use the `val(string)` method to set that value: ``` $("#txtEmail").val("something") ```
463,535
<p>I am implementing an HTML form with some checkbox input elements, and I want to have a Select All or DeSelect All button. However, <em>I do not want to rely on the name</em> of the input element (like <a href="http://www.plus2net.com/javascript_tutorial/checkbox-checkall.php" rel="noreferrer">this example</a>) but r...
[ { "answer_id": 463551, "author": "Spencer Ruport", "author_id": 52551, "author_profile": "https://Stackoverflow.com/users/52551", "pm_score": 0, "selected": false, "text": "<p>If jQuery is an option you can do this rather easily.</p>\n\n<p>See the documentation on <a href=\"http://docs.j...
2009/01/20
[ "https://Stackoverflow.com/questions/463535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32174/" ]
I am implementing an HTML form with some checkbox input elements, and I want to have a Select All or DeSelect All button. However, *I do not want to rely on the name* of the input element (like [this example](http://www.plus2net.com/javascript_tutorial/checkbox-checkall.php)) but rather the **type** because I have mult...
This should do it: ``` <script> function checkUncheck(form, setTo) { var c = document.getElementById(form).getElementsByTagName('input'); for (var i = 0; i < c.length; i++) { if (c[i].type == 'checkbox') { c[i].checked = setTo; } } } </script> <form id='myForm'> <input type='ch...
463,557
<p>Is there any way to convert the following Backus–Naur form (BNF) grammar into a .Net regex? (I'm not stuck on the BNF, but I thought it might be the best way to explain what I was trying to do).</p> <pre><code>&lt;field&gt; ::= "&lt;&lt;" &lt;fieldname&gt; &lt;options&gt; "&gt;&gt;" &lt;options&gt; ::= "" | "(" &...
[ { "answer_id": 463601, "author": "Joe", "author_id": 21950, "author_profile": "https://Stackoverflow.com/users/21950", "pm_score": 0, "selected": false, "text": "<p>I've been pondering an answer, and sort of hoping someone would jump me so I could stop. :)</p>\n\n<p>The recursive nature ...
2009/01/20
[ "https://Stackoverflow.com/questions/463557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
Is there any way to convert the following Backus–Naur form (BNF) grammar into a .Net regex? (I'm not stuck on the BNF, but I thought it might be the best way to explain what I was trying to do). ``` <field> ::= "<<" <fieldname> <options> ">>" <options> ::= "" | "(" <option> ")" <option> ::= "" | <optio...
BNF is used to describe context-free languages, which regex can't normally describe. What separates context-free languages and regex is that context-free langauges can have recursion on both sides at the same time. A classic example is the balanced parenthesis problem. ``` paren = paren paren | '(' paren ')' <-...
463,569
<p>For some reason when I check on Google Webmaster Tool's "Analyze robots.txt" to see which urls are blocked by our robots.txt file, it's not what I'm expecting. Here is a snippet from the beginning of our file:</p> <pre><code>Sitemap: http://[omitted]/sitemap_index.xml User-agent: Mediapartners-Google Disallow: /sc...
[ { "answer_id": 463575, "author": "Webjedi", "author_id": 1975, "author_profile": "https://Stackoverflow.com/users/1975", "pm_score": -1, "selected": false, "text": "<p>Did you recently make this change to your robots.txt file? In my experience it <em>seems</em> that google caches that ...
2009/01/20
[ "https://Stackoverflow.com/questions/463569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
For some reason when I check on Google Webmaster Tool's "Analyze robots.txt" to see which urls are blocked by our robots.txt file, it's not what I'm expecting. Here is a snippet from the beginning of our file: ``` Sitemap: http://[omitted]/sitemap_index.xml User-agent: Mediapartners-Google Disallow: /scripts User-ag...
The reason why they are ignored is that you have the fully qualified URL in the `robots.txt` file for `Disallow` entries while the [specification](http://www.robotstxt.org/robotstxt.html) doesn't allow it. (You should only specify relative paths, or absolute paths using /). Try the following: ``` Sitemap: /sitemap_ind...
463,572
<p>I have a table with arbitrary columns and rows. This fact is irrelevant though really, all I want to do is develop a function that will turn a row (or multiple rows) into a series of text inputs containing the data in the table (or empty if no data in cell).</p> <p>I can't find any examples of people explicitly doi...
[ { "answer_id": 463587, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 6, "selected": true, "text": "<p>Iterate over the table cells in the rows, and replace the contents with text inputs:</p>\n\n<pre><code>function ed...
2009/01/20
[ "https://Stackoverflow.com/questions/463572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33604/" ]
I have a table with arbitrary columns and rows. This fact is irrelevant though really, all I want to do is develop a function that will turn a row (or multiple rows) into a series of text inputs containing the data in the table (or empty if no data in cell). I can't find any examples of people explicitly doing this, s...
Iterate over the table cells in the rows, and replace the contents with text inputs: ``` function editRow(row) { $('td',row).each(function() { $(this).html('<input type="text" value="' + $(this).html() + '" />'); }); } ``` You need to pass the relevant row/rows into the function obviously.
463,592
<p>I'm new to Object-Oriented programming and the perldoc page on CPAN.pm confuses the hell out of me. My program needs to download a couple of modules if they don't already exist. Is this basically just:</p> <pre><code>CPAN::Shell-&gt;install("Module::Name::Here"); </code></pre> <p>or is there more to it? Does that ...
[ { "answer_id": 463603, "author": "Keltia", "author_id": 16143, "author_profile": "https://Stackoverflow.com/users/16143", "pm_score": 1, "selected": false, "text": "<p>Basically using CPAN is the following:</p>\n\n<pre><code>perl -MCPAN -e shell\n</code></pre>\n\n<p>if this is the first ...
2009/01/20
[ "https://Stackoverflow.com/questions/463592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm new to Object-Oriented programming and the perldoc page on CPAN.pm confuses the hell out of me. My program needs to download a couple of modules if they don't already exist. Is this basically just: ``` CPAN::Shell->install("Module::Name::Here"); ``` or is there more to it? Does that download the package, unarchi...
*the perldoc page on CPAN.pm confuses the hell out of me.* Yes, documentation of the CPAN API is still a bit lacking. It wasn't every really designed for programmatic use by others. You might have better luck with [CPANPLUS](https://metacpan.org/module/CPANPLUS#API-REFERENCE), if that's available to you. *My program...
463,595
<p>I have an app that, while running, needs to poll its own memory usage. It would be ideal if it could list out the memory usage for each object instantiated. I know this can be achieved by WMI, but I was hoping for something that doesn't rely on WMI.</p>
[ { "answer_id": 463609, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 2, "selected": false, "text": "<p>You could listen on perfmon counters, which will give you plenty of data (GC activity / physical memory usage / ma...
2009/01/20
[ "https://Stackoverflow.com/questions/463595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51841/" ]
I have an app that, while running, needs to poll its own memory usage. It would be ideal if it could list out the memory usage for each object instantiated. I know this can be achieved by WMI, but I was hoping for something that doesn't rely on WMI.
Two functions you might find useful are: ``` GC.GetTotalMemory(); Process.PagedMemorySize64(); ``` My experience has been that GC.GetTotalMemory() is not terribly reliable. It often reports memory usage that is much smaller than the actual memory usage. I've seen it report that I'm using only 8 gigabytes when my...
463,597
<p>I have an xml and it has nodes with i:nil="true" in it. What does that mean?</p> <p>For example:</p> <pre><code>&lt;FirstName i:nil="true" /&gt; </code></pre> <p>Does that mean something different than:</p> <pre><code>&lt;FirstName /&gt; </code></pre> <p>If so, what is the difference?</p>
[ { "answer_id": 463612, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 3, "selected": false, "text": "<p>nil is an attribute, defined in the <code>i</code> namespace. For this FirstName node, the attribute has the value...
2009/01/20
[ "https://Stackoverflow.com/questions/463597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32892/" ]
I have an xml and it has nodes with i:nil="true" in it. What does that mean? For example: ``` <FirstName i:nil="true" /> ``` Does that mean something different than: ``` <FirstName /> ``` If so, what is the difference?
This means FirstName is null ``` <FirstName i:nil="true" /> ``` This means FirstName = "" ``` <FirstName /> ``` Assumption made on FirstName is of string type.