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
504,551
<p>I am having virtually the same problem as this: </p> <p><a href="https://stackoverflow.com/questions/433281/c-update-combobox-bound-to-generic-list">C# Update combobox bound to generic list</a></p> <p>However, I am trying to change the displayed strings; not add, remove, or sort. I have tried the BindingList solut...
[ { "answer_id": 504596, "author": "YonahW", "author_id": 3821, "author_profile": "https://Stackoverflow.com/users/3821", "pm_score": 2, "selected": false, "text": "<p>instead of <code>SearchComboBox.Refresh();</code></p>\n\n<p>try <code>SearchComboBox.RefreshItems();</code></p>\n\n<p>or <...
2009/02/02
[ "https://Stackoverflow.com/questions/504551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55638/" ]
I am having virtually the same problem as this: [C# Update combobox bound to generic list](https://stackoverflow.com/questions/433281/c-update-combobox-bound-to-generic-list) However, I am trying to change the displayed strings; not add, remove, or sort. I have tried the BindingList solution provided in the referenc...
If you were to change the entire object, meaning your entire SearchData object, then the bindinglist would have knowledge of this change, and therefore the correct events would internaly get fired, and the combobox would update. HOWEVER, since you're only updating one property, the bindinglist has no idea that somethin...
504,558
<p>how can I paint all rows in a datagrid with the value of field "age" = 30 in red?</p> <p>I work in WinCE.</p> <p><em>Thanks for any help!</em></p>
[ { "answer_id": 508452, "author": "Quibblesome", "author_id": 1143, "author_profile": "https://Stackoverflow.com/users/1143", "pm_score": 0, "selected": false, "text": "<p>I'd suggest going back to the example ctacke linked to and specifically looking at:</p>\n\n<pre><code>DataGridCustomC...
2009/02/02
[ "https://Stackoverflow.com/questions/504558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43907/" ]
how can I paint all rows in a datagrid with the value of field "age" = 30 in red? I work in WinCE. *Thanks for any help!*
try something like. I set `Datagrid1.Datasource = Datatable1.DefaultView` where Datatable1 is a Datatable that contains a column named "Age" Sorry, is in VB Private Sub paintColors() ``` Dim vI As Int64 DataGrid1.SelectionBackColor = Color.OrangeRed Dim vI As Int64 = 0 For vI = 0 To Datatable1.De...
504,559
<p>My boilerplate listener:</p> <pre><code>class MyMouseMotionListener implements MouseMotionListener { public void mouseDragged(MouseEvent e) { System.out.println("Dragged..."); } public void mouseMoved(MouseEvent e) { System.out.println("Moved..."); }} </code></pre> <p>Simple enough, but what do I add it t...
[ { "answer_id": 504587, "author": "basszero", "author_id": 287, "author_profile": "https://Stackoverflow.com/users/287", "pm_score": 2, "selected": false, "text": "<p>UPDATE: You could poll MouseInfo for position but you'll never get button state. You will need to use native code to get b...
2009/02/02
[ "https://Stackoverflow.com/questions/504559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25661/" ]
My boilerplate listener: ``` class MyMouseMotionListener implements MouseMotionListener { public void mouseDragged(MouseEvent e) { System.out.println("Dragged..."); } public void mouseMoved(MouseEvent e) { System.out.println("Moved..."); }} ``` Simple enough, but what do I add it to in order to listen to sy...
You can subscribe to all mouse events within your Java container hierarchy using [`Toolkit.addAWTEventListener(AWTEventListener listener, long eventMask)`](http://docs.oracle.com/javase/8/docs/api/java/awt/Toolkit.html#addAWTEventListener-java.awt.event.AWTEventListener-long-). The `eventMask` parameter determines whic...
504,585
<p>I have run into a few cases where i have been asked to deploy an application (C#, .Net 2.0) to a server and users need to test the application over the network. I have found the following that works with out any hitches other than a warning telling you "hey your running this over a network are you sure you want to d...
[ { "answer_id": 504591, "author": "GWLlosa", "author_id": 18071, "author_profile": "https://Stackoverflow.com/users/18071", "pm_score": 3, "selected": false, "text": "<p>Try using <a href=\"http://en.wikipedia.org/wiki/ClickOnce\" rel=\"nofollow noreferrer\">ClickOnce</a> deployment. We ...
2009/02/02
[ "https://Stackoverflow.com/questions/504585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59376/" ]
I have run into a few cases where i have been asked to deploy an application (C#, .Net 2.0) to a server and users need to test the application over the network. I have found the following that works with out any hitches other than a warning telling you "hey your running this over a network are you sure you want to do t...
The problem with granting FullTrust, is that [it really really means *full* trust](http://blogs.msdn.com/eugene_bobukh/archive/2005/05/06/415217.aspx). If your app has any sort of identity/security control, the granting fulltrust will bypass all of that. I guess otherwise, you're "exposing" your machine to files runni...
504,598
<p>I can't seem to find any way to add a horizontal separator in a MenuStrip. Visual Studio complains Cannot add ToolStropSeparator to MenuStrip.</p> <p>Any idea's how I can do this?</p>
[ { "answer_id": 504628, "author": "GWLlosa", "author_id": 18071, "author_profile": "https://Stackoverflow.com/users/18071", "pm_score": 6, "selected": true, "text": "<p>I'm able to run code like this:</p>\n\n<pre><code>this.menuMain.Items.Add(new ToolStripSeparator());\n</code></pre>\n\n<...
2009/02/02
[ "https://Stackoverflow.com/questions/504598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12243/" ]
I can't seem to find any way to add a horizontal separator in a MenuStrip. Visual Studio complains Cannot add ToolStropSeparator to MenuStrip. Any idea's how I can do this?
I'm able to run code like this: ``` this.menuMain.Items.Add(new ToolStripSeparator()); ``` without any trouble... What kind of error are you getting?
504,614
<p>I'm trying to generate a CSS class that will help me define a "page break".</p> <p>I know that if I use <code>@media:print .MyDiv{ width:100%; height:100%; }</code>, I can then set the class of a <code>div</code> to <code>MyDiv</code> and it will be -- as best as possible -- 1 page of print.</p> <p>This is great, ...
[ { "answer_id": 504621, "author": "Mark Biek", "author_id": 305, "author_profile": "https://Stackoverflow.com/users/305", "pm_score": 5, "selected": true, "text": "<p>This is for print, right?</p>\n\n<p>Can't you just use this?</p>\n\n<pre><code>&lt;p style=\"page-break-before: always\"&g...
2009/02/02
[ "https://Stackoverflow.com/questions/504614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53531/" ]
I'm trying to generate a CSS class that will help me define a "page break". I know that if I use `@media:print .MyDiv{ width:100%; height:100%; }`, I can then set the class of a `div` to `MyDiv` and it will be -- as best as possible -- 1 page of print. This is great, but I have encountered a new item that I don't kno...
This is for print, right? Can't you just use this? ``` <p style="page-break-before: always"></p> ``` There are some other options to [page-break-before](http://www.w3schools.com/cssref/pr_print_pagebb.asp) that are worth knowing about too.
504,616
<p>I'm building a form to do the following:</p> <ul> <li>Print a table of users and permissions, pulling from MySQL. Each permission a user has is a checked box, and each one they lack is an unchecked box.</li> <li>Allow an administrator to check and uncheck boxes to grant or remove permissions.</li> <li>When the form ...
[ { "answer_id": 504639, "author": "Andy", "author_id": 26693, "author_profile": "https://Stackoverflow.com/users/26693", "pm_score": 2, "selected": false, "text": "<p>This might be what you are looking for:\n<a href=\"http://php.net/manual/en/function.array-diff.php\" rel=\"nofollow noref...
2009/02/02
[ "https://Stackoverflow.com/questions/504616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4376/" ]
I'm building a form to do the following: * Print a table of users and permissions, pulling from MySQL. Each permission a user has is a checked box, and each one they lack is an unchecked box. * Allow an administrator to check and uncheck boxes to grant or remove permissions. * When the form is submitted, show a confir...
This might be what you are looking for: [array\_diff()](http://php.net/manual/en/function.array-diff.php)
504,633
<p>I have a big image that has to go in the background. </p> <p>Say the image is a square. Now when someone does a mouseover on any of the square's corners, the image should change to the green version of the image.</p> <p>Actually the background image is going to remain, but I have to somehow overlay the green ima...
[ { "answer_id": 504695, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 1, "selected": false, "text": "<p>It should be possible for you to use CSS to place the corner images overlaid into each of the corners of your background ...
2009/02/02
[ "https://Stackoverflow.com/questions/504633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
I have a big image that has to go in the background. Say the image is a square. Now when someone does a mouseover on any of the square's corners, the image should change to the green version of the image. Actually the background image is going to remain, but I have to somehow overlay the green image slice over the b...
``` <div class="image"> <div class="top left" onmouseover="javascript: cornerHover();" /> <div class="top right" onmouseover="javascript: cornerHover();" /> <div class="bottom left" onmouseover="javascript: cornerHover();" /> <div class="bottom right" onmouseover="javascript: cornerHover();" /> </div> ...
504,641
<p>I have a name in a database, lets say its "DFectuoso" and some legacy system stored DFectuoso_randomnameofafile.doc.</p> <p>Now I want to find all the filed "DFectuoso" owns and display links to them in a PHP page.</p> <p>What would be the way to start on this?</p>
[ { "answer_id": 504659, "author": "Henrik Paul", "author_id": 2238, "author_profile": "https://Stackoverflow.com/users/2238", "pm_score": 3, "selected": true, "text": "<p>I'd try with <a href=\"http://php.net/glob\" rel=\"nofollow noreferrer\"><code>glob()</code></a> in combination with <...
2009/02/02
[ "https://Stackoverflow.com/questions/504641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47846/" ]
I have a name in a database, lets say its "DFectuoso" and some legacy system stored DFectuoso\_randomnameofafile.doc. Now I want to find all the filed "DFectuoso" owns and display links to them in a PHP page. What would be the way to start on this?
I'd try with [`glob()`](http://php.net/glob) in combination with [`readfile()`](http://php.net/readfile). Off the top of my head: ``` $findname = 'DFectuoso'; foreach (glob('/path/to/somewhere/'.$findname.'*') as $file) { provide_a_link_to($file); } ``` and just pass the file with `readfile()`. Remember, if you ...
504,642
<p>Please help me convert this line to C#.</p> <pre><code>objManagementBaseObject.SetPropertyValue("hDefKey", CType("&amp;H" &amp; Hex(RegistryHive.LocalMachine), Long)) </code></pre> <p>Related References in C#: System.Management</p> <p>Thank you.</p> <p>Additional Info:</p> <p>Code was originally in VB.</p>
[ { "answer_id": 504675, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": true, "text": "<p>It looks like <code>RegistryHive.LocalMachine</code> is just an enum value, in which case passing it through Hex() i...
2009/02/02
[ "https://Stackoverflow.com/questions/504642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54627/" ]
Please help me convert this line to C#. ``` objManagementBaseObject.SetPropertyValue("hDefKey", CType("&H" & Hex(RegistryHive.LocalMachine), Long)) ``` Related References in C#: System.Management Thank you. Additional Info: Code was originally in VB.
It looks like `RegistryHive.LocalMachine` is just an enum value, in which case passing it through Hex() is just a waste of time: ``` objManagmentBaseObject.SetPropertyValue("hDefKey", (long)RegistryHive.LocalMachine); ```
504,645
<p>I have a <code>List&lt;T&gt;</code> that I want to search not for a given item but for an item satisfying a given condition. Given an item in the list I can test which of 4 conditions is true:</p> <ul> <li>the desired item must be to the left</li> <li>the desired item must be to the right</li> <li>this is the desir...
[ { "answer_id": 504661, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": "<p>Are you sure of those conditions? Normally that works if the list is sorted, in which case perhaps you want to use...
2009/02/02
[ "https://Stackoverflow.com/questions/504645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
I have a `List<T>` that I want to search not for a given item but for an item satisfying a given condition. Given an item in the list I can test which of 4 conditions is true: * the desired item must be to the left * the desired item must be to the right * this is the desired item * the desired can't be in the list A...
**New edit:** I'll leave the extra binary searches below, as they'll be useful for others, and here's a final option which is I think what you actually want. Your delegate should return a positive number if the item it's looking for is "less than" the one specified, a negative number if it's "greater than" the one spec...
504,648
<p>I need to union two sets of XElements into a single, unique set of elements. Using the .Union() extension method, I just get a "union all" instead of a union. Am I missing something?</p> <pre><code>var elements = xDocument.Descendants(w + "sdt") .Union(otherDocument.Descendants(w + "sdt") ...
[ { "answer_id": 504719, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 0, "selected": false, "text": "<p>It's really hard to troubleshoot your \"left join\" observation without seeing what it is you are using to come to that con...
2009/02/02
[ "https://Stackoverflow.com/questions/504648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to union two sets of XElements into a single, unique set of elements. Using the .Union() extension method, I just get a "union all" instead of a union. Am I missing something? ``` var elements = xDocument.Descendants(w + "sdt") .Union(otherDocument.Descendants(w + "sdt") .S...
Your first impulse was almost correct.:) As per **David B**, if you do not tell LINQ exactly how you define equality and then give it a bunch of XElements, it will compare them by reference. Fortunately, you can tell it to use different criteria by specifying an IEqualityComparer‹XElement› (basically, an object that ha...
504,681
<p>I am posting a very simple form using a method I have used frequently in the past. It may be easier to show my code rather than type a lengthy explanation. Here's the HTML:</p> <pre><code>&lt;% Html.BeginForm("CreateMarketingType", "ListMaintenance"); %&gt; &lt;div id="ListMaintenanceContainer"&gt; &lt;...
[ { "answer_id": 504731, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 8, "selected": true, "text": "<p>None of your inputs have a name attribute. No name = not in the FormCollection.</p>\n" }, { "answer_id": 2730...
2009/02/02
[ "https://Stackoverflow.com/questions/504681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1284/" ]
I am posting a very simple form using a method I have used frequently in the past. It may be easier to show my code rather than type a lengthy explanation. Here's the HTML: ``` <% Html.BeginForm("CreateMarketingType", "ListMaintenance"); %> <div id="ListMaintenanceContainer"> <table> <tr> ...
None of your inputs have a name attribute. No name = not in the FormCollection.
504,692
<p>I have been wondering whether there is any code out there that enables representing SQL in the form of some object tree that can be assembled, modified and then finally rendered to valid SQL?</p> <p>Off the top of my head it could look something like that...</p> <pre><code>var stmnt = new Statement(); stmnt .Add...
[ { "answer_id": 504698, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 3, "selected": false, "text": "<p>Hibernate has its own Hibernate Query Language (HQL) that represents SQL-like constructs as objects.</p>\n" }, { ...
2009/02/02
[ "https://Stackoverflow.com/questions/504692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51428/" ]
I have been wondering whether there is any code out there that enables representing SQL in the form of some object tree that can be assembled, modified and then finally rendered to valid SQL? Off the top of my head it could look something like that... ``` var stmnt = new Statement(); stmnt .AddMaster("Customer") ...
The python package SQLAlchemy has an ORM layer, but it also has an SQL generation layer. [I realise you tagged this post c# and .net, but I thought you might like to see what else is out there] Here is some example code: ``` from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey from sqlalchemy...
504,729
<p>I have a </p> <pre><code>List&lt;InputField&gt; </code></pre> <p>but I need a </p> <pre><code>List&lt;IDataField&gt; </code></pre> <p>Is there a way to cast this in c#? Or use Linq to get same result?</p> <p>I have two classes that implement the same interface:</p> <pre><code>interface IDataField { } class...
[ { "answer_id": 504736, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 4, "selected": false, "text": "<pre><code>List&lt;InputField&gt; raw = (from i .... select i).ToList();\nList&lt;IDataField&gt; result = raw.OfType&lt;IDataF...
2009/02/02
[ "https://Stackoverflow.com/questions/504729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/946/" ]
I have a ``` List<InputField> ``` but I need a ``` List<IDataField> ``` Is there a way to cast this in c#? Or use Linq to get same result? I have two classes that implement the same interface: ``` interface IDataField { } class InputField : IDataField { } class PurchaseField : IDataField { } ``` This Lis...
Both .OfType<T> and .Cast<T> will return a list of T, but the meaning of the two methods is different. list.OfType() **filters** the original list and returns all items which are of type T, and skips the ones that are not of that type. list.Cast() **casts** all items in the original list to type T, and throws an exce...
504,773
<p>Let's say my program is always passed a string of characters that represents a data table in Wiki syntax. Something like:</p> <pre><code> {||Client:||ABC|-|Contact:||Joe Smith|-|Current revision:||1.0||} </code></pre> <p>I don't want each one of my specific Wiki table objects (e.g., ClientContactTable, CustomerO...
[ { "answer_id": 504784, "author": "Jonas Kölker", "author_id": 58668, "author_profile": "https://Stackoverflow.com/users/58668", "pm_score": 0, "selected": false, "text": "<p>I'd go with a map from strings to strings.</p>\n\n<p>It's not particularly OO, but it'll do the job, unless there'...
2009/02/02
[ "https://Stackoverflow.com/questions/504773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
Let's say my program is always passed a string of characters that represents a data table in Wiki syntax. Something like: ``` {||Client:||ABC|-|Contact:||Joe Smith|-|Current revision:||1.0||} ``` I don't want each one of my specific Wiki table objects (e.g., ClientContactTable, CustomerOrderTable, etc.) to know ho...
You want to implement [`System.Runtime.IFormatter`](http://msdn.microsoft.com/en-us/library/system.runtime.serialization.iformatter.aspx) to create a generic WikiTable serialization formatter. To help you out with this, you can inherit from the [`System.Runtime.Formatter`](http://msdn.microsoft.com/en-us/library/system...
504,792
<p>I am attempting to seek in a movie using ffmpeg's av_seek_frame method however I'm having the most trouble determining how to generate a time-stamp to seek to. Assuming I want to seek x amount of frames either forward or backward and I know what frame the movie is currently on, how would I go about doing this?</p>
[ { "answer_id": 529661, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>Simple answer: You should have an AVFormatContext object lying around. Its <code>duration</code> property tells you how lon...
2009/02/02
[ "https://Stackoverflow.com/questions/504792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61663/" ]
I am attempting to seek in a movie using ffmpeg's av\_seek\_frame method however I'm having the most trouble determining how to generate a time-stamp to seek to. Assuming I want to seek x amount of frames either forward or backward and I know what frame the movie is currently on, how would I go about doing this?
Here is how i did it: ``` // Duration of one frame in AV_TIME_BASE units int64_t timeBase; void open(const char* fpath){ ... timeBase = (int64_t(pCodecCtx->time_base.num) * AV_TIME_BASE) / int64_t(pCodecCtx->time_base.den); ... } bool seek(int frameIndex){ if(!pFormatCtx) return false; ...
504,803
<p>Is it like...</p> <pre><code>var obj = new Object(); obj.function1 = function(){ //code } </code></pre> <p>or something like that?</p>
[ { "answer_id": 504811, "author": "Christian Nunciato", "author_id": 32129, "author_profile": "https://Stackoverflow.com/users/32129", "pm_score": 4, "selected": false, "text": "<p>Generally use the <a href=\"http://www.w3schools.com/jsref/jsref_prototype_math.asp\" rel=\"noreferrer\">pro...
2009/02/02
[ "https://Stackoverflow.com/questions/504803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18309/" ]
Is it like... ``` var obj = new Object(); obj.function1 = function(){ //code } ``` or something like that?
``` var newObj = { met1 : function () { alert('hello'); } }; ``` Then, the method can be called like such : ``` newObj.met1(); ``` Btw, when declaring a new object, use the object literal (`{}`), not the `new Object()` constructor.
504,806
<p>Trying to hit two elements with one <code>load()</code> and not successful in what I am trying. This is what I have now to refresh a section on the page and it works fine.</p> <pre><code>$('#refreshme_'+request).load("http://www.example.com/add_list/"); </code></pre> <p>I tried this </p> <pre><code>$('#refreshme...
[ { "answer_id": 504811, "author": "Christian Nunciato", "author_id": 32129, "author_profile": "https://Stackoverflow.com/users/32129", "pm_score": 4, "selected": false, "text": "<p>Generally use the <a href=\"http://www.w3schools.com/jsref/jsref_prototype_math.asp\" rel=\"noreferrer\">pro...
2009/02/02
[ "https://Stackoverflow.com/questions/504806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60461/" ]
Trying to hit two elements with one `load()` and not successful in what I am trying. This is what I have now to refresh a section on the page and it works fine. ``` $('#refreshme_'+request).load("http://www.example.com/add_list/"); ``` I tried this ``` $('#refreshme_'+request, .xPlanner).load("http://www.example.c...
``` var newObj = { met1 : function () { alert('hello'); } }; ``` Then, the method can be called like such : ``` newObj.met1(); ``` Btw, when declaring a new object, use the object literal (`{}`), not the `new Object()` constructor.
504,810
<p>In a C project (POSIX), how do I get the fully qualified name for the current system?</p> <p>For example, I can get just the hostname of my machine by doing <code>gethostname()</code> from unistd.h. This might give me <code>machine3</code> in return, but I'm actually looking for <code>machine3.somedomain.com</code>...
[ { "answer_id": 504836, "author": "Jack L.", "author_id": 61664, "author_profile": "https://Stackoverflow.com/users/61664", "pm_score": -1, "selected": false, "text": "<p>The easy way, try uname()</p>\n\n<p>If that does not work, use gethostname() then gethostbyname() and finally gethostb...
2009/02/02
[ "https://Stackoverflow.com/questions/504810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4924/" ]
In a C project (POSIX), how do I get the fully qualified name for the current system? For example, I can get just the hostname of my machine by doing `gethostname()` from unistd.h. This might give me `machine3` in return, but I'm actually looking for `machine3.somedomain.com` for example. How do I go about getting th...
To get a fully qualified name for a machine, we must first get the local hostname, and then lookup the canonical name. The easiest way to do this is by first getting the local hostname using `uname()` or `gethostname()` and then performing a lookup with `gethostbyname()` and looking at the `h_name` member of the struc...
504,814
<p>It seems to me there is no way to detect whether a drag operation was successful or not, but there must be some way. Suppose that I want to perform a "move" from the source to the destination. If the user releases the mouse over some app or control that cannot accept the drop, how can I tell?</p> <p>For that matter...
[ { "answer_id": 504875, "author": "cz_dl", "author_id": 28248, "author_profile": "https://Stackoverflow.com/users/28248", "pm_score": 4, "selected": true, "text": "<p>I'm not sure if that can help you, but DoDragDrop method returns final DragDropEffects value. </p>\n\n<pre><code>var ret =...
2009/02/02
[ "https://Stackoverflow.com/questions/504814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238948/" ]
It seems to me there is no way to detect whether a drag operation was successful or not, but there must be some way. Suppose that I want to perform a "move" from the source to the destination. If the user releases the mouse over some app or control that cannot accept the drop, how can I tell? For that matter, how can ...
I'm not sure if that can help you, but DoDragDrop method returns final DragDropEffects value. ``` var ret = DoDragDrop( ... ); if(ret == DragDropEffects.None) //not successfull else // etc. ```
504,817
<p>I have a view that has a background image and a <code>CGPath</code> that gets changed as the user touches the screen. Drawing the image with <code>CGContextDrawImage()</code> and then drawing the path on top is not fast enough and it hinders the touch event performance. What I would like to have is to have a bitmap ...
[ { "answer_id": 505166, "author": "philsquared", "author_id": 32136, "author_profile": "https://Stackoverflow.com/users/32136", "pm_score": 0, "selected": false, "text": "<p>Actually that's pretty much the way it works already. The context passed to drawRect draws into a CALayer, which is...
2009/02/02
[ "https://Stackoverflow.com/questions/504817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46026/" ]
I have a view that has a background image and a `CGPath` that gets changed as the user touches the screen. Drawing the image with `CGContextDrawImage()` and then drawing the path on top is not fast enough and it hinders the touch event performance. What I would like to have is to have a bitmap buffer and only draw the ...
If the background image isn't changing (I can't tell for sure if it is), then you should put the background image in a different CoreAnimation layer, with the layer containing the path on top of it. That lets the GPU handle the compositing, rather than doing it all in your -drawRect. The background image can then be ca...
504,820
<p>I am creating a database connection object, and I'm not sure what the best way would be...</p> <p>If I create a dbConnection class which establishes the connection (using mysql_connect) can I then call mysql_query from anywhere in the main script?</p> <p>what about from inside OTHER classes? Do i need to pass the ...
[ { "answer_id": 504842, "author": "Justin Bennett", "author_id": 271, "author_profile": "https://Stackoverflow.com/users/271", "pm_score": 1, "selected": false, "text": "<p>Rather than create your own database abstraction class, I would recommend giving <a href=\"http://www.woyano.com/jv/...
2009/02/02
[ "https://Stackoverflow.com/questions/504820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am creating a database connection object, and I'm not sure what the best way would be... If I create a dbConnection class which establishes the connection (using mysql\_connect) can I then call mysql\_query from anywhere in the main script? what about from inside OTHER classes? Do i need to pass the object or attri...
Rather than create your own database abstraction class, I would recommend giving [ezSQL](http://www.woyano.com/jv/ezsql) a try. The author did an excellent job of making it very easy to use. The data structures returned from the queries done by the class are far more flexible than those returned by mysql\_query and it ...
504,823
<p>Has anyone of you ever implemented a <a href="http://en.wikipedia.org/wiki/Fibonacci_heap" rel="noreferrer">Fibonacci-Heap</a>? I did so a few years back, but it was several orders of magnitude slower than using array-based BinHeaps.</p> <p>Back then, I thought of it as a valuable lesson in how research is not alwa...
[ { "answer_id": 508221, "author": "A. Rex", "author_id": 3508, "author_profile": "https://Stackoverflow.com/users/3508", "pm_score": 8, "selected": true, "text": "<p><strike>The <a href=\"http://www.boost.org/\" rel=\"noreferrer\">Boost C++ libraries</a> include an implementation of Fibon...
2009/02/02
[ "https://Stackoverflow.com/questions/504823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25318/" ]
Has anyone of you ever implemented a [Fibonacci-Heap](http://en.wikipedia.org/wiki/Fibonacci_heap)? I did so a few years back, but it was several orders of magnitude slower than using array-based BinHeaps. Back then, I thought of it as a valuable lesson in how research is not always as good as it claims to be. However...
The [Boost C++ libraries](http://www.boost.org/) include an implementation of Fibonacci heaps in `boost/pending/fibonacci_heap.hpp`. This file has apparently been in `pending/` for years and by my projections will never be accepted. Also, there have been bugs in that implementation, which were fixed by my acquaintance ...
504,833
<p>This question might be kind of elementary, but here goes:</p> <p>I have a SQL Server database with a 4 GB log file. The DB is 16GB and is backed up nightly.</p> <p>Can I truncate the log regularly because the entire DB+Log is backed up each night?</p>
[ { "answer_id": 504847, "author": "Glennular", "author_id": 14753, "author_profile": "https://Stackoverflow.com/users/14753", "pm_score": 3, "selected": true, "text": "<p>you can something like this to you maintenance schedule to run every night before the backup. This will try to shrink...
2009/02/02
[ "https://Stackoverflow.com/questions/504833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/335036/" ]
This question might be kind of elementary, but here goes: I have a SQL Server database with a 4 GB log file. The DB is 16GB and is backed up nightly. Can I truncate the log regularly because the entire DB+Log is backed up each night?
you can something like this to you maintenance schedule to run every night before the backup. This will try to shrink/truncate your log file to 1 meg ``` BACKUP LOG DBNAME TO disk = 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\DBNAME.log' DBCC SHRINKFILE('DBNAME_Log', 1) ```
504,839
<p>I know that I can do this in Rails:</p> <pre><code>&lt;%="hello" %&gt; </code></pre> <p>but is there any way to do this</p> <pre><code>&lt;% echo "hello" %&gt; </code></pre> <p>and get it to show up in the response?</p>
[ { "answer_id": 504869, "author": "phresus", "author_id": 56808, "author_profile": "https://Stackoverflow.com/users/56808", "pm_score": 0, "selected": false, "text": "<p>You're looking for \"print\" or \"puts\", depending on whether or not you want a newline (probably not). Almost every ...
2009/02/02
[ "https://Stackoverflow.com/questions/504839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8047/" ]
I know that I can do this in Rails: ``` <%="hello" %> ``` but is there any way to do this ``` <% echo "hello" %> ``` and get it to show up in the response?
Have you tried `concat`. I have seen this when wandering in Rails documentation. Not sure at all since I am very new to Rails.
504,843
<p>Okay, this is the code:</p> <pre><code>[lblMessage setText: txtEnter.text]; [lblMessage sizeToFit]; scrollingTextView.contentSize = lblMessage.frame.size; float width = (lblMessage.frame.size.width) + (480); [UIView beginAnimations:@"pan" context:nil]; [UIView setAnimationDuration:durationValue]; [UIView setAnima...
[ { "answer_id": 505295, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 2, "selected": true, "text": "<p>Core Animation animations are performed on a separate thread. When you enclose the change in contentOffset in a beg...
2009/02/02
[ "https://Stackoverflow.com/questions/504843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53677/" ]
Okay, this is the code: ``` [lblMessage setText: txtEnter.text]; [lblMessage sizeToFit]; scrollingTextView.contentSize = lblMessage.frame.size; float width = (lblMessage.frame.size.width) + (480); [UIView beginAnimations:@"pan" context:nil]; [UIView setAnimationDuration:durationValue]; [UIView setAnimationRepeatCoun...
Core Animation animations are performed on a separate thread. When you enclose the change in contentOffset in a beginAnimations / commitAnimations block, that change will be animated gradually. The scrolling text view rotation that occurs next, outside of the animation block, will be performed instantly. Since both are...
504,848
<p>I am developing a chained installer including the .msi installation of Crystal Reports Basic (10.5) using Inno Setup. I cannot find any deployment guidance to determine if this is already installed on the target PC, though it appears I can call the .msi multiple times and it always attempts to install (never goes t...
[ { "answer_id": 505295, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 2, "selected": true, "text": "<p>Core Animation animations are performed on a separate thread. When you enclose the change in contentOffset in a beg...
2009/02/02
[ "https://Stackoverflow.com/questions/504848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1145/" ]
I am developing a chained installer including the .msi installation of Crystal Reports Basic (10.5) using Inno Setup. I cannot find any deployment guidance to determine if this is already installed on the target PC, though it appears I can call the .msi multiple times and it always attempts to install (never goes to th...
Core Animation animations are performed on a separate thread. When you enclose the change in contentOffset in a beginAnimations / commitAnimations block, that change will be animated gradually. The scrolling text view rotation that occurs next, outside of the animation block, will be performed instantly. Since both are...
504,849
<p>I recorded a script using the Selenium IDE extension for Firefox, and I would like to add the command waitForCondition. I see it takes two arguments: script and timeout. In Selenium IDE, I have 3 text fields for each command: the command name (I assume "waitForCondition"), the target, and the value. Where and how sh...
[ { "answer_id": 504856, "author": "IAdapter", "author_id": 30453, "author_profile": "https://Stackoverflow.com/users/30453", "pm_score": 3, "selected": true, "text": "<pre><code>\nwaitForCondition\nvar value = selenium.getText(\"foo\"); value.match(/bar/);\n3000\n</code></pre>\n" }, {...
2009/02/02
[ "https://Stackoverflow.com/questions/504849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5295/" ]
I recorded a script using the Selenium IDE extension for Firefox, and I would like to add the command waitForCondition. I see it takes two arguments: script and timeout. In Selenium IDE, I have 3 text fields for each command: the command name (I assume "waitForCondition"), the target, and the value. Where and how shoul...
``` waitForCondition var value = selenium.getText("foo"); value.match(/bar/); 3000 ```
504,852
<p>I'm creating an XML document and I want to store URLs inside the a node like so:</p> <pre><code>&lt;ns:url&gt;http://example.com&lt;/ns:ulr&gt; </code></pre> <p>My question is, do I need to encode/escape the URL in anyway?</p> <p>If I do, the will the .Net XmlDocument object handle this for me?</p>
[ { "answer_id": 504862, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 0, "selected": false, "text": "<p>I doubt there will be any need to escape it in general. However, you might have some application level requirement to do so...
2009/02/02
[ "https://Stackoverflow.com/questions/504852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18107/" ]
I'm creating an XML document and I want to store URLs inside the a node like so: ``` <ns:url>http://example.com</ns:ulr> ``` My question is, do I need to encode/escape the URL in anyway? If I do, the will the .Net XmlDocument object handle this for me?
In general most DOM implementations (including XmlDocument) should handle any necessary escaping of text content by default.
504,857
<p>I don't understand what could be the uses of lvalue subroutines? What is it that I can't accomplish with normal subroutines? Could you please post some examples?</p> <p>Thanks</p>
[ { "answer_id": 504975, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 3, "selected": false, "text": "<p>They provide a different interface, that in some circumstances can be more intuitive. Unlike traditional setters,...
2009/02/02
[ "https://Stackoverflow.com/questions/504857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
I don't understand what could be the uses of lvalue subroutines? What is it that I can't accomplish with normal subroutines? Could you please post some examples? Thanks
LValues are recommended to be avoided. They're fun and all, but they confuse new users who make assumptions about how all subs work, and thus it should be avoided in code when a better way is available. Sometimes it can be extremely practical to use an LValue result to do dirty work. ``` substr( $string, $start, $st...
504,879
<p>I’m maintaining a site in ASP, one of the tasks is to set the focus on textbox on a page. Here is what I have tried:</p> <pre><code>&lt;script type="text/javascript"&gt; &lt;!-- document.psForm['password'].focus(); //AND document.getElementById("password").focus(); --&gt; &lt;/script&gt; </code></pre> <p>I didn't...
[ { "answer_id": 504886, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;body onload=\"javascript:docuument.psForm.password.focus();\"&gt;\n</code></pre>\n\n<p>should be</p>\n...
2009/02/02
[ "https://Stackoverflow.com/questions/504879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50018/" ]
I’m maintaining a site in ASP, one of the tasks is to set the focus on textbox on a page. Here is what I have tried: ``` <script type="text/javascript"> <!-- document.psForm['password'].focus(); //AND document.getElementById("password").focus(); --> </script> ``` I didn't think this would work... and it doesn't: `...
Try this: Add: ``` id="password" ``` to the input tag, then use: ``` document.getElementById("password").focus(); ```
504,887
<p>We have an app that uses simple one way binding with a GridView to display some data. Well, now we need to allow the user to change some of that data, so I've been trying to get two way data binding to work in the GridView. So far everything displays correctly, but editing cells in the GridView seems to do nothing a...
[ { "answer_id": 504936, "author": "Bubblewrap", "author_id": 57497, "author_profile": "https://Stackoverflow.com/users/57497", "pm_score": 4, "selected": true, "text": "<p>When you use Dependency Properties, the Setters will not be called by bindings, instead they change the value directl...
2009/02/02
[ "https://Stackoverflow.com/questions/504887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12567/" ]
We have an app that uses simple one way binding with a GridView to display some data. Well, now we need to allow the user to change some of that data, so I've been trying to get two way data binding to work in the GridView. So far everything displays correctly, but editing cells in the GridView seems to do nothing at a...
When you use Dependency Properties, the Setters will not be called by bindings, instead they change the value directly (using SetValue or something similar). Try adding a PropertyChangedCallback, and set a breakpoint in there to see if the value is changed from the GridView. ``` public static readonly DependencyPrope...
504,892
<p>I thought this would have done it...</p> <pre><code>$rowfetch = $DBS-&gt;{Row}-&gt;GetCharValue("meetdays"); $rowfetch = /[-]/gi; printline($rowfetch); </code></pre> <p>But it seems that I'm missing a small yet critical piece of the regex syntax.</p> <p><code>$rowfetch</code> is always something along the lines o...
[ { "answer_id": 504902, "author": "user54650", "author_id": 54650, "author_profile": "https://Stackoverflow.com/users/54650", "pm_score": 5, "selected": true, "text": "<pre><code>$rowfetch =~ s/-//gi\n</code></pre>\n\n<p>That's what you need for your second line there. You're just findin...
2009/02/02
[ "https://Stackoverflow.com/questions/504892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42229/" ]
I thought this would have done it... ``` $rowfetch = $DBS->{Row}->GetCharValue("meetdays"); $rowfetch = /[-]/gi; printline($rowfetch); ``` But it seems that I'm missing a small yet critical piece of the regex syntax. `$rowfetch` is always something along the lines of: ``` ------S -M-W--- --T-TF- ``` etc... to re...
``` $rowfetch =~ s/-//gi ``` That's what you need for your second line there. You're just finding stuff, not actually changing it without the "s" prefix. You also need to use the regex operator "=~" for this.
504,899
<p>I have a form with thousands of checkboxes, and when one is checked, I want to check all the boxes below it. This works:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form name="myform"&gt; &lt;input type="checkbox" name="box1" onClick="redrawboxes(this);"&gt;1&lt;br&gt; &lt;input type="checkbox" name="box2" onClick...
[ { "answer_id": 504912, "author": "IAdapter", "author_id": 30453, "author_profile": "https://Stackoverflow.com/users/30453", "pm_score": 2, "selected": false, "text": "<p>i might get down voted for this, but try using jquery. it has selectors optimized for that.</p>\n" }, { "answe...
2009/02/02
[ "https://Stackoverflow.com/questions/504899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27876/" ]
I have a form with thousands of checkboxes, and when one is checked, I want to check all the boxes below it. This works: ``` <html> <body> <form name="myform"> <input type="checkbox" name="box1" onClick="redrawboxes(this);">1<br> <input type="checkbox" name="box2" onClick="redrawboxes(this);">2<br> ... </form> </body>...
Both of the jQuery suggestions are pretty good. For DOM wrangling like this, you're really better off using a good library. And the comment about the dubious wisdom of putting thousands of checkboxes on a form is pretty good as well... But, on the off-chance that you do have a good reason for doing this, and you can...
504,904
<p>So lets say I have this interface:</p> <pre><code>public interface IBox { public void setSize(int size); public int getSize(); public int getArea(); //...and so on } </code></pre> <p>And I have a class that implements it:</p> <pre><code>public class Rectangle implements IBox { private int size; /...
[ { "answer_id": 504921, "author": "IAdapter", "author_id": 30453, "author_profile": "https://Stackoverflow.com/users/30453", "pm_score": 3, "selected": false, "text": "<p>you could do</p>\n\n<pre><code>Ibox myBox = new Rectangle();\n</code></pre>\n\n<p>that way you are using this object a...
2009/02/02
[ "https://Stackoverflow.com/questions/504904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49153/" ]
So lets say I have this interface: ``` public interface IBox { public void setSize(int size); public int getSize(); public int getArea(); //...and so on } ``` And I have a class that implements it: ``` public class Rectangle implements IBox { private int size; //Methods here } ``` If I wanted to ...
Interfaces are a way to make your code more flexible. What you do is this: ``` Ibox myBox=new Rectangle(); ``` Then, later, if you decide you want to use a different kind of box (maybe there's another library, with a better kind of box), you switch your code to: ``` Ibox myBox=new OtherKindOfBox(); ``` Once you g...
504,909
<p>I am looking for a way to do daily deployments and keep the database scripts in line with releases. </p> <p>Currently, we have a fairly decent way of deploying our source, we have unit code coverage, continuous integration and rollback procedures. </p> <p>The problem is keeping the database scripts in line with a...
[ { "answer_id": 504950, "author": "Hamish Smith", "author_id": 15572, "author_profile": "https://Stackoverflow.com/users/15572", "pm_score": 3, "selected": false, "text": "<p>Read <a href=\"http://odetocode.com/Blogs/scott/archive/2008/01/31/11710.aspx\" rel=\"nofollow noreferrer\">K.Scot...
2009/02/02
[ "https://Stackoverflow.com/questions/504909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6088/" ]
I am looking for a way to do daily deployments and keep the database scripts in line with releases. Currently, we have a fairly decent way of deploying our source, we have unit code coverage, continuous integration and rollback procedures. The problem is keeping the database scripts in line with a release. Everyone...
For this very problem I chose to use a migration tool: [Migratordotnet](http://code.google.com/p/migratordotnet/). With migrations (in any tool) you have a simple class used to perform your changes and undo them. Here's an example: ``` [Migration(62)] public class _62_add_date_created_column : Migration { public ...
504,920
<p>I have two tables named <code>foo</code> and <code>bar</code>, hypothetically speaking.</p> <p>foo has columns <code>foo_id</code>, <code>foo_fluff</code> bar has columns <code>bar_id</code>, <code>foo_id</code>, <code>timestamp</code></p> <p>I need a query which will retrieve return one row for any foo_id that th...
[ { "answer_id": 504959, "author": "jjclarkson", "author_id": 46425, "author_profile": "https://Stackoverflow.com/users/46425", "pm_score": 0, "selected": false, "text": "<pre><code>SELECT timestamp FROM bar GROUP BY foo_id ORDER BY timestamp DESC\n</code></pre>\n\n<p>Just join the foo tab...
2009/02/02
[ "https://Stackoverflow.com/questions/504920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40882/" ]
I have two tables named `foo` and `bar`, hypothetically speaking. foo has columns `foo_id`, `foo_fluff` bar has columns `bar_id`, `foo_id`, `timestamp` I need a query which will retrieve return one row for any foo\_id that the table bar contains, with the latest timestamp. So, if bar has three rows, two of which hav...
I think this is what you are looking for (unless it must be a subquery and not a join) ``` select max(bar.timestamp), foo.foo_fluff from foo inner join bar on foo.foo_id = bar.foo_id group by foo.foo_fluff ```
504,948
<p>Is it safe and predictable to reuse pointers after freeing the data they point to?</p> <p>For example:</p> <pre><code>char* fileNames[] = { "words.txt", "moreWords.txt" }; char** words = NULL; int* wordsCount = NULL; for ( i = 0; i &lt; 2; ++i ) { data = fopen( fileNames[i], "r" ); words = readWords( data ...
[ { "answer_id": 504965, "author": "Andrew Rollings", "author_id": 40410, "author_profile": "https://Stackoverflow.com/users/40410", "pm_score": 2, "selected": false, "text": "<p>Yes. That is safe. (Ugly, but safe :) )</p>\n" }, { "answer_id": 504979, "author": "Andrew Grant", ...
2009/02/02
[ "https://Stackoverflow.com/questions/504948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40906/" ]
Is it safe and predictable to reuse pointers after freeing the data they point to? For example: ``` char* fileNames[] = { "words.txt", "moreWords.txt" }; char** words = NULL; int* wordsCount = NULL; for ( i = 0; i < 2; ++i ) { data = fopen( fileNames[i], "r" ); words = readWords( data ); wordsCount = coun...
What you're doing is fine: because, after you release a pointer, you're reinitializing it before you reuse it. If the question is "is it safe to reuse a pointer **value** after freeing it" then the answer is "no". If the question is "is it safe to reuse a pointer **variable** after freeing its value" then the answer ...
504,972
<p>Does <code>String.ToLower()</code> return the same reference (e.g. without allocating any new memory) if all the characters are already lower-case?</p> <p>Memory allocation is cheap, but running a quick check on zillions of short strings is even cheaper. Most of the time the input I'm working with is already lowe...
[ { "answer_id": 505003, "author": "cgreeno", "author_id": 6088, "author_profile": "https://Stackoverflow.com/users/6088", "pm_score": 2, "selected": false, "text": "<p>String is an immutable. String.ToLower() will always return new instance thereby generating another instance on every ToL...
2009/02/02
[ "https://Stackoverflow.com/questions/504972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
Does `String.ToLower()` return the same reference (e.g. without allocating any new memory) if all the characters are already lower-case? Memory allocation is cheap, but running a quick check on zillions of short strings is even cheaper. Most of the time the input I'm working with is already lower-case, but I want to m...
I expect so, yes. A quick test agrees (but this is not evidence): ``` string a = "abc", b = a.ToLower(); bool areSame = ReferenceEquals(a, b); // false ``` In general, try to work with **comparers** that do what you want. For example, if you want a case-insensitive dictionary, use one: ``` var lookup = new Dictiona...
504,977
<p>I am creating an abstract class. I want each of my derived classes to be forced to implement a specific signature of constructor. As such, I did what I would have done has I wanted to force them to implement a method, I made an abstract one.</p> <pre><code>public abstract class A { abstract A(int a, int b); } <...
[ { "answer_id": 505005, "author": "Jamie Penney", "author_id": 68230, "author_profile": "https://Stackoverflow.com/users/68230", "pm_score": 5, "selected": false, "text": "<p>Change that constructor in class A to</p>\n\n<pre><code>protected A(int a, int b)\n{\n // Some initialisation c...
2009/02/02
[ "https://Stackoverflow.com/questions/504977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52622/" ]
I am creating an abstract class. I want each of my derived classes to be forced to implement a specific signature of constructor. As such, I did what I would have done has I wanted to force them to implement a method, I made an abstract one. ``` public abstract class A { abstract A(int a, int b); } ``` However I...
You cannot have an abstract constructor because abstract means you must override it in any non-abstract child class and you cannot override a constructor. If you think about it, this makes sense, since you always call the constructor of the child class (with the new operator) and never the base class. Generally speak...
505,007
<p>i know there is a variable, function, or stored procedure that you can use to find the path that SQL Server is installed to:</p> <p>e.g.:</p> <pre><code>c:\Program Files\Microsoft SQL Server\MSSQL.7\MSSQL </code></pre> <p>or </p> <pre><code>m:\CustomInstance\MSSQL </code></pre> <hr> <p>In reality, i'm hoping t...
[ { "answer_id": 505026, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 0, "selected": false, "text": "<p>what happens when you run this</p>\n\n<pre><code>select filename from sysaltfiles\nwhere name = db_name()\n</code></pre>\...
2009/02/02
[ "https://Stackoverflow.com/questions/505007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
i know there is a variable, function, or stored procedure that you can use to find the path that SQL Server is installed to: e.g.: ``` c:\Program Files\Microsoft SQL Server\MSSQL.7\MSSQL ``` or ``` m:\CustomInstance\MSSQL ``` --- In reality, i'm hoping to SELECT for the default backup path. But since i doubt t...
How to select the installation path ----------------------------------- **Note**: ***xp\_instance\_regread*** doesn't read the registry key you specify, but instead converts that key path into the appropriate path for the specific SQL Server instance you're running on. In other words: **xp\_regread** fails where **xp\...
505,021
<p>I'm working in a C++ unmanaged project.</p> <p>I need to know how can I take a string like this "some data to encrypt" and get a byte[] array which I'm gonna use as the source for Encrypt.</p> <p>In C# I do</p> <pre><code> for (int i = 0; i &lt; text.Length; i++) buffer[i] = (byte)text[i]; </code></pre> <p>...
[ { "answer_id": 505047, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 7, "selected": true, "text": "<p>If you just need read-only access, then <a href=\"http://en.cppreference.com/w/cpp/string/basic_string/c_...
2009/02/02
[ "https://Stackoverflow.com/questions/505021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58434/" ]
I'm working in a C++ unmanaged project. I need to know how can I take a string like this "some data to encrypt" and get a byte[] array which I'm gonna use as the source for Encrypt. In C# I do ``` for (int i = 0; i < text.Length; i++) buffer[i] = (byte)text[i]; ``` What I need to know is how to do the same b...
If you just need read-only access, then [`c_str()`](http://en.cppreference.com/w/cpp/string/basic_string/c_str) will do it: ``` char const *c = myString.c_str(); ``` If you need read/write access, then you can copy the string into a vector. vectors manage dynamic memory for you. You don't have to mess with allocatio...
505,023
<p>I'm trying to read/write to a <code>FM24CL64-GTR FRAM</code> chip that is connected over a I2C bus on address <code>0b 1010 011</code>.</p> <p>When I'm trying to write 3 bytes (data address 2 bytes, + data one byte), I get a kernel message (<code>[12406.360000] i2c-adapter i2c-0: sendbytes: NAK bailout.</code>), as...
[ { "answer_id": 505134, "author": "Matthew Eshleman", "author_id": 49956, "author_profile": "https://Stackoverflow.com/users/49956", "pm_score": 3, "selected": false, "text": "<p>I do not have experience with that particular device, but in our experience many I2C devices have \"quirks\" t...
2009/02/02
[ "https://Stackoverflow.com/questions/505023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4829/" ]
I'm trying to read/write to a `FM24CL64-GTR FRAM` chip that is connected over a I2C bus on address `0b 1010 011`. When I'm trying to write 3 bytes (data address 2 bytes, + data one byte), I get a kernel message (`[12406.360000] i2c-adapter i2c-0: sendbytes: NAK bailout.`), as well as the write returns != 3. See code b...
The NAK was a big hint: the WriteProtect pin was externally pulled up, and had to be driven to ground, after that a single write of the address followed by data-bytes is successful (first code segment). For reading the address can be written out first (using write()), and then sequential data can be read starting from...
505,024
<p>I've got most of the code for writing a value to the windows registry, however when I change the path to a dummy key and value that I've set up for testing it fails. My code is below:</p> <pre><code> HKEY hKey; LPCTSTR sk = TEXT("SOFTWARE\TestSoftware"); LONG openRes = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ...
[ { "answer_id": 505068, "author": "Brian Sweeney", "author_id": 2170994, "author_profile": "https://Stackoverflow.com/users/2170994", "pm_score": 6, "selected": true, "text": "<p>I feel silly. The solution is that need to properly escape the slash in the string as follows:</p>\n\n<pre><c...
2009/02/02
[ "https://Stackoverflow.com/questions/505024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2170994/" ]
I've got most of the code for writing a value to the windows registry, however when I change the path to a dummy key and value that I've set up for testing it fails. My code is below: ``` HKEY hKey; LPCTSTR sk = TEXT("SOFTWARE\TestSoftware"); LONG openRes = RegOpenKeyEx(HKEY_LOCAL_MACHINE, sk, 0, KEY_ALL_...
I feel silly. The solution is that need to properly escape the slash in the string as follows: ``` LPCTSTR sk = TEXT("SOFTWARE\\TestSoftware"); ``` Hopefully someone finds this useful...
505,028
<p>I'm trying to find a way to place a colon ( : ) into a string, two characters from the end of the string.</p> <p>Examples of $meetdays:<br> 1200 => 12:00<br>900 => 9:00<br>1340 =>13:40</p> <p>Not sure if this should be a regular expression or just another function that I'm not aware of.</p>
[ { "answer_id": 505037, "author": "falstro", "author_id": 46991, "author_profile": "https://Stackoverflow.com/users/46991", "pm_score": 1, "selected": false, "text": "<p>You could try this:</p>\n\n<pre><code>s/..$/:$&amp;/\n</code></pre>\n\n<p>it matches two-characters at the end of the s...
2009/02/02
[ "https://Stackoverflow.com/questions/505028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42229/" ]
I'm trying to find a way to place a colon ( : ) into a string, two characters from the end of the string. Examples of $meetdays: 1200 => 12:00 900 => 9:00 1340 =>13:40 Not sure if this should be a regular expression or just another function that I'm not aware of.
``` s/(?=..$)/:/ ``` Don't use roe's suggestion of `$&`. perldoc perlvar: > > The use of this variable anywhere in a program imposes a considerable performance penalty on all regular expression matches. See "BUGS". > > >
505,040
<p>I am currently in my final year at school, studying for a Higher National Diploma in Computer Studies, and basically in this final semester, we need to develop a Software Project, that basically incorporates a <em>whole</em> system.</p> <p>Now, what I'm thinking of doing is something along the lines of <a href="htt...
[ { "answer_id": 505071, "author": "user54650", "author_id": 54650, "author_profile": "https://Stackoverflow.com/users/54650", "pm_score": 1, "selected": false, "text": "<p>It's very feasible.</p>\n\n<p>I suggest starting with the back-end system and objects that respond to \"compiled\" ro...
2009/02/02
[ "https://Stackoverflow.com/questions/505040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44084/" ]
I am currently in my final year at school, studying for a Higher National Diploma in Computer Studies, and basically in this final semester, we need to develop a Software Project, that basically incorporates a *whole* system. Now, what I'm thinking of doing is something along the lines of [Robocode](https://robocode.s...
When I began working with WPF (which is much the same as Silverlight) I ended up spending a lot of time figuring out how to do things. It is a very different way of making a GUI than what else I've tried and there seems to be a billion different ways to do things. My point is, that if you have no experience with WPF/Si...
505,054
<p>Since there is no Linq to DB2 yet (c'mon IBM!), and I want to deal with IQueryables or IEnumerables in my code, how would I convert a DataTable to an IQueryable? Or an IEnumerable?</p> <p>I have an interface and a class that matches the columns in the datatable...</p> <pre><code>IQueryable&lt;IMyData&gt; GetAS400D...
[ { "answer_id": 505136, "author": "Nicolas Dorier", "author_id": 19803, "author_profile": "https://Stackoverflow.com/users/19803", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://blogs.msdn.com/adonet/archive/2009/01/26/entity-framework-enabled-providers-lists.aspx\" rel=\"...
2009/02/02
[ "https://Stackoverflow.com/questions/505054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16426/" ]
Since there is no Linq to DB2 yet (c'mon IBM!), and I want to deal with IQueryables or IEnumerables in my code, how would I convert a DataTable to an IQueryable? Or an IEnumerable? I have an interface and a class that matches the columns in the datatable... ``` IQueryable<IMyData> GetAS400Data(..parameters..) { D...
``` table.AsEnumerable()... table.AsEnumerable().AsQueryable()... ``` However, you'd need to write your own translation (`Select`) to your type; and the `IQueryable<T>` would still be using LINQ-to-Objects; the only purpose (in this scenario) of using `IQueryable<T>` over `IEnumerable<T>` would be to use expressions...
505,074
<p>It seems that every PHP function I read about for comparing arrays (<code>array_diff()</code>, <code>array_intersect()</code>, etc) compares for the <strong>existence</strong> of array elements.</p> <p>Given two multidimensional arrays with identical structure, how would you list the differences in <strong>values</s...
[ { "answer_id": 505097, "author": "Ian P", "author_id": 10853, "author_profile": "https://Stackoverflow.com/users/10853", "pm_score": 2, "selected": false, "text": "<p>One way is to write a function to do something similar to this..</p>\n\n<pre><code>function compareArray ($array1, $array...
2009/02/02
[ "https://Stackoverflow.com/questions/505074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4376/" ]
It seems that every PHP function I read about for comparing arrays (`array_diff()`, `array_intersect()`, etc) compares for the **existence** of array elements. Given two multidimensional arrays with identical structure, how would you list the differences in **values**? Example ------- ### Array 1 ``` [User1] => Ar...
One way is to write a function to do something similar to this.. ``` function compareArray ($array1, $array2) { foreach ($array1 as $key => $value) { if ($array2[$key] != $value) { return false; } } return true; } ``` You could easily augment that function to return an array of differences...
505,119
<p>I am trying to use the aspnet___regsql utility to install all the membership tables in a database on my local SQL Express 2008 instance. I can connect without problems in Management Studio, but when I try to list the databases in the aspnet_regsql interface i get an error message saying:</p> <pre>Failed to query a ...
[ { "answer_id": 505327, "author": "Tomas Aschan", "author_id": 38055, "author_profile": "https://Stackoverflow.com/users/38055", "pm_score": 4, "selected": true, "text": "<p>I have solved the problem by bypassing the graphic interface and performing the same action directly in the command...
2009/02/02
[ "https://Stackoverflow.com/questions/505119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38055/" ]
I am trying to use the aspnet\_\_\_regsql utility to install all the membership tables in a database on my local SQL Express 2008 instance. I can connect without problems in Management Studio, but when I try to list the databases in the aspnet\_regsql interface i get an error message saying: ``` Failed to query a list...
I have solved the problem by bypassing the graphic interface and performing the same action directly in the command prompt, with flags specifying all options. They should look like this: **Connect using SQL Authentication** ``` C:\>Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe -S myHostingServer -A all...
505,140
<p>k... Strager was able to help me a bit. However, it's still not working quite right. Need someone that knows both MVC and jQuery please...</p> <p>I have a page that has a image that when clicked on will launch a dialog box that gives the ability to upload a file. Once the dialog closes the image is supposed to refr...
[ { "answer_id": 505158, "author": "Glennular", "author_id": 14753, "author_profile": "https://Stackoverflow.com/users/14753", "pm_score": 1, "selected": false, "text": "<p>What is #image shouldn't it be find('img')? Or give the IMG an ID of 'image'.</p>\n" }, { "answer_id": 5051...
2009/02/02
[ "https://Stackoverflow.com/questions/505140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55862/" ]
k... Strager was able to help me a bit. However, it's still not working quite right. Need someone that knows both MVC and jQuery please... I have a page that has a image that when clicked on will launch a dialog box that gives the ability to upload a file. Once the dialog closes the image is supposed to refresh with w...
What is #image shouldn't it be find('img')? Or give the IMG an ID of 'image'.
505,143
<p>I have something like <code>boost::shared_ptr&lt;Type&gt; t(makeSomething(), mem_fun(&amp;Type::deleteMe))</code> I now need to call C styled function that requires a pointer to <code>Type</code>. How do I get it from <code>boost::shared_ptr</code>?</p>
[ { "answer_id": 505152, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 7, "selected": false, "text": "<p>Use the <a href=\"http://www.boost.org/doc/libs/1_37_0/libs/smart_ptr/shared_ptr.htm#get\" rel=\"noreferrer\"><co...
2009/02/02
[ "https://Stackoverflow.com/questions/505143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have something like `boost::shared_ptr<Type> t(makeSomething(), mem_fun(&Type::deleteMe))` I now need to call C styled function that requires a pointer to `Type`. How do I get it from `boost::shared_ptr`?
Use the [`get()`](http://www.boost.org/doc/libs/1_37_0/libs/smart_ptr/shared_ptr.htm#get) method: ``` boost::shared_ptr<foo> foo_ptr(new foo()); foo *raw_foo = foo_ptr.get(); c_library_function(raw_foo); ``` Make sure that your `shared_ptr` doesn't go out of scope before the library function is done with it -- other...
505,145
<p>I would like suggestions on how to inject a record into my DropdownList to give an "All" option. Here is my code, data coming from the Northwind database.</p> <pre><code>&lt;asp:DropDownList ID="ddlRegion" runat="server" DataSourceID="SqlDataSource1" DataTextField="RegionDescription" DataValueField="RegionID" ...
[ { "answer_id": 505149, "author": "Tron", "author_id": 22290, "author_profile": "https://Stackoverflow.com/users/22290", "pm_score": 3, "selected": true, "text": "<p>Just add the All item in the ASPX, and then set AppendDataBoundItems=true and it will keep the statically defined items wit...
2009/02/02
[ "https://Stackoverflow.com/questions/505145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59941/" ]
I would like suggestions on how to inject a record into my DropdownList to give an "All" option. Here is my code, data coming from the Northwind database. ``` <asp:DropDownList ID="ddlRegion" runat="server" DataSourceID="SqlDataSource1" DataTextField="RegionDescription" DataValueField="RegionID" AutoPost...
Just add the All item in the ASPX, and then set AppendDataBoundItems=true and it will keep the statically defined items with the data bound items.
505,151
<p>Normally, when I use Visual Studio to do a build, I see warnings and errors shown in the output pane, e.g.</p> <pre><code>1&gt;------ Build started: Project: pdcuda, Configuration: Release x64 ------ Compiling... foo.cpp Linking... foo.obj : error LNK2001: unresolved external symbol "foo" ========== Build: 0 succee...
[ { "answer_id": 505349, "author": "michael", "author_id": 31207, "author_profile": "https://Stackoverflow.com/users/31207", "pm_score": 0, "selected": false, "text": "<p>did you tried to reset IDE\ndevenv.exe /resetsettings\nor\ndevenv.exe /resetuserdata</p>\n" }, { "answer_id": 5...
2009/02/02
[ "https://Stackoverflow.com/questions/505151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25050/" ]
Normally, when I use Visual Studio to do a build, I see warnings and errors shown in the output pane, e.g. ``` 1>------ Build started: Project: pdcuda, Configuration: Release x64 ------ Compiling... foo.cpp Linking... foo.obj : error LNK2001: unresolved external symbol "foo" ========== Build: 0 succeeded, 1 failed, 0 ...
Final solution: reinstall the OS.
505,167
<p>I have a WinForms app that I am trying to make full screen (somewhat like what VS does in full screen mode).</p> <p>Currently I am setting <code>FormBorderStyle</code> to <code>None</code> and <code>WindowState</code> to <code>Maximized</code> which gives me a little more space, but it doesn't cover over the taskba...
[ { "answer_id": 505171, "author": "Tron", "author_id": 22290, "author_profile": "https://Stackoverflow.com/users/22290", "pm_score": 2, "selected": false, "text": "<p>You need to set your window to be topmost.</p>\n" }, { "answer_id": 505403, "author": "Stefan", "author_id...
2009/02/02
[ "https://Stackoverflow.com/questions/505167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a WinForms app that I am trying to make full screen (somewhat like what VS does in full screen mode). Currently I am setting `FormBorderStyle` to `None` and `WindowState` to `Maximized` which gives me a little more space, but it doesn't cover over the taskbar if it is visible. What do I need to do to use that ...
To the base question, the following will do the trick (hiding the taskbar) ``` private void Form1_Load(object sender, EventArgs e) { this.TopMost = true; this.FormBorderStyle = FormBorderStyle.None; this.WindowState = FormWindowState.Maximized; } ``` But, interestingly, if you swap those last two lines t...
505,172
<p>I have a SOAP service that exposes a method</p> <pre><code>TradeDetail getTradeDetail() </code></pre> <p>TradeDetail stores 5 fields, transaction number, dates etc</p> <p>I need to add a couple of fields to TradeDetail. I want to keep backward compatibility (for a while) and it looks as if my options are limited ...
[ { "answer_id": 505171, "author": "Tron", "author_id": 22290, "author_profile": "https://Stackoverflow.com/users/22290", "pm_score": 2, "selected": false, "text": "<p>You need to set your window to be topmost.</p>\n" }, { "answer_id": 505403, "author": "Stefan", "author_id...
2009/02/02
[ "https://Stackoverflow.com/questions/505172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16828/" ]
I have a SOAP service that exposes a method ``` TradeDetail getTradeDetail() ``` TradeDetail stores 5 fields, transaction number, dates etc I need to add a couple of fields to TradeDetail. I want to keep backward compatibility (for a while) and it looks as if my options are limited to creating a new class with the ...
To the base question, the following will do the trick (hiding the taskbar) ``` private void Form1_Load(object sender, EventArgs e) { this.TopMost = true; this.FormBorderStyle = FormBorderStyle.None; this.WindowState = FormWindowState.Maximized; } ``` But, interestingly, if you swap those last two lines t...
505,175
<p>I need to get a list of weeks for a given month, with Monday as the start day.</p> <p>So for example, for the month of February 2009, this method would return:</p> <pre><code>2/2/2009 2/9/2009 2/16/2009 2/23/2009 </code></pre>
[ { "answer_id": 505188, "author": "Glennular", "author_id": 14753, "author_profile": "https://Stackoverflow.com/users/14753", "pm_score": 0, "selected": false, "text": "<p>Just change the response line to what ever you need to do with it</p>\n\n<pre><code>protected void PrintDay(int year,...
2009/02/02
[ "https://Stackoverflow.com/questions/505175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2596/" ]
I need to get a list of weeks for a given month, with Monday as the start day. So for example, for the month of February 2009, this method would return: ``` 2/2/2009 2/9/2009 2/16/2009 2/23/2009 ```
``` // Get the weeks in a month DateTime date = DateTime.Today; // first generate all dates in the month of 'date' var dates = Enumerable.Range(1, DateTime.DaysInMonth(date.Year, date.Month)).Select(n => new DateTime(date.Year, date.Month, n)); // then filter the only the start of weeks var weekends = from d in ...
505,180
<p>I've got a UINavigationController and i've changed it to white using the Tint property of the navigation bar in Interface Builder. But the text in buttons and the title is still the default color, white, and so gets lost against the white background. Anyone know how to work around this?</p>
[ { "answer_id": 684338, "author": "Steven Fisher", "author_id": 22927, "author_profile": "https://Stackoverflow.com/users/22927", "pm_score": 1, "selected": false, "text": "<p>Can't you iterate the contents of the UINavigationBar view to find the buttons in the awakeFromNib?</p>\n" }, ...
2009/02/02
[ "https://Stackoverflow.com/questions/505180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56817/" ]
I've got a UINavigationController and i've changed it to white using the Tint property of the navigation bar in Interface Builder. But the text in buttons and the title is still the default color, white, and so gets lost against the white background. Anyone know how to work around this?
As of iOS 5 this it much easier, using the UIBarButtonItem appearance proxy: ``` NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIColor blackColor], UITextAttributeTextColor, [UIColor clearColor], ...
505,215
<p>I have been binding textboxes in a winform with C# to a dataset. Whenever the data doesn't validate with what the database except it silently forces the focus to remain on the textbox. How can I catch the validation error and tell the user about it (and free the focus)? The BindingSource event OnDataError isn't fire...
[ { "answer_id": 505267, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 1, "selected": false, "text": "<p>Never rely on just what \"Visual studio has done for me\" if you don't fully understand what it's doing. I would strongly...
2009/02/02
[ "https://Stackoverflow.com/questions/505215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12243/" ]
I have been binding textboxes in a winform with C# to a dataset. Whenever the data doesn't validate with what the database except it silently forces the focus to remain on the textbox. How can I catch the validation error and tell the user about it (and free the focus)? The BindingSource event OnDataError isn't fired.
I had a similar problem once. The focus remained in the textbox which was binded to some numeric database field when the user modified text in a textbox and then deleted it so the text property was an empty string. I solved it with something like: ``` textbox.DataBindings["Text"].NullValue = ""; ``` It solved the pr...
505,226
<p>I've been using <a href="http://www.iunknown.com/2007/06/vibrant_ink_vis.html" rel="noreferrer">John Lam's Vibrant Ink</a> VS color scheme lately and wanted to tweak it so it highlights the method names for a class with a different color. Turns out there is no option in VS for that. </p> <p>Resharper has <a href="h...
[ { "answer_id": 516257, "author": "jlew", "author_id": 7450, "author_profile": "https://Stackoverflow.com/users/7450", "pm_score": 0, "selected": false, "text": "<p>I can't really answer how hard it is or whether there's any open source, but to get it done, you want to take a looki at Cus...
2009/02/02
[ "https://Stackoverflow.com/questions/505226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
I've been using [John Lam's Vibrant Ink](http://www.iunknown.com/2007/06/vibrant_ink_vis.html) VS color scheme lately and wanted to tweak it so it highlights the method names for a class with a different color. Turns out there is no option in VS for that. Resharper has [a feature](http://www.jetbrains.com/resharper/f...
Well as Brian has already said... [My PaintIt plugin](http://www.rorybecker.co.uk/PaintIt.html) will give you some idea as to what can be done with the [DXCore](http://devexpress.com/Products/Visual_Studio_Add-in/DXCore/). Also there are some other "Decorative plugins" on our "[Community Plugin Site](http://code.goog...
505,231
<p>I have some code like, this code is used <strong>very</strong> heavily:</p> <pre><code>using (HttpWebResponse r = _GetHttpWebResponse(uri, body, method, contentType, headers)) { /* do something with the response */ /* call r.Close() explicitly? */ } </code></pre> <p>The code works fine today, but the conn...
[ { "answer_id": 505241, "author": "Sean Bright", "author_id": 21926, "author_profile": "https://Stackoverflow.com/users/21926", "pm_score": 5, "selected": false, "text": "<p>When <code>Dispose()</code> is called on <code>WebResponse</code> (<code>HttpWebReponse</code>'s base class), it ca...
2009/02/02
[ "https://Stackoverflow.com/questions/505231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8411/" ]
I have some code like, this code is used **very** heavily: ``` using (HttpWebResponse r = _GetHttpWebResponse(uri, body, method, contentType, headers)) { /* do something with the response */ /* call r.Close() explicitly? */ } ``` The code works fine today, but the connections to the server stay open for qui...
If you have significant code inside the using after you have finished consuming the response then sure calling close is ok. However you might want to consider refactoring your code so that code that doesn't need the response isn't inside the using block. That said closeing the response doesn't necessarily close the co...
505,235
<pre><code>&lt;form action="/cgi-bin/Lib.exe" method=POST name="checks"&gt; &lt;input type=checkbox name="user1" value="'$NAME'"&gt; &lt;input type=checkbox name="user2" value="'$NAME'"&gt; &lt;input type=checkbox name="user3" value="'$NAME'"&gt; &lt;input type="button" value="User 1"...
[ { "answer_id": 505256, "author": "Luca Matteis", "author_id": 50394, "author_profile": "https://Stackoverflow.com/users/50394", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;form onsubmit=\"somefunction(this);\" ...\n\nfunction somefunction(f) {\n var user1 = f.user1;\n ...
2009/02/02
[ "https://Stackoverflow.com/questions/505235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52256/" ]
``` <form action="/cgi-bin/Lib.exe" method=POST name="checks"> <input type=checkbox name="user1" value="'$NAME'"> <input type=checkbox name="user2" value="'$NAME'"> <input type=checkbox name="user3" value="'$NAME'"> <input type="button" value="User 1" onclick="somefunction()"> ``` F...
I'd propose few improvements to sktrdie's reply. This will avoid submitting form on errors. ``` <form action="".... onsubmit="return somefunction(this);"> function somefunction(f) { var user1 = f.user1; var user2 = f.user2; // etc.. if(user2.checked) { alert("you are not user1"); retu...
505,262
<p>Where or when would one would use namespace aliasing like</p> <pre><code> using someOtherName = System.Timers.Timer; </code></pre> <p>It seems to me that it would just add more confusion to understanding the language.</p>
[ { "answer_id": 505268, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 8, "selected": true, "text": "<p>That is a type alias, not a namespace alias; it is useful to disambiguate - for example, against:</p>\n\n<pre><code...
2009/02/02
[ "https://Stackoverflow.com/questions/505262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54009/" ]
Where or when would one would use namespace aliasing like ``` using someOtherName = System.Timers.Timer; ``` It seems to me that it would just add more confusion to understanding the language.
That is a type alias, not a namespace alias; it is useful to disambiguate - for example, against: ``` using WinformTimer = System.Windows.Forms.Timer; using ThreadingTimer = System.Threading.Timer; ``` (ps: thanks for the choice of `Timer` ;-p) Otherwise, if you use both `System.Windows.Forms.Timer` and `System.Tim...
505,289
<p>File foo.txt exists on the remote machine at: /home/user/foo.txt</p> <p>It doesn't exist on the local machine.</p> <p>I want to delete foo.txt using rsync.</p> <p>I do not know (and assume for the purposes of this question that I cannot find out) what other files are in /home/user on either the local or remote ma...
[ { "answer_id": 505318, "author": "David Z", "author_id": 56541, "author_profile": "https://Stackoverflow.com/users/56541", "pm_score": 6, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>rsync -rv --delete --include=foo.txt '--exclude=*' /home/user/ user@remote:/home/user/\n</co...
2009/02/02
[ "https://Stackoverflow.com/questions/505289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20903/" ]
File foo.txt exists on the remote machine at: /home/user/foo.txt It doesn't exist on the local machine. I want to delete foo.txt using rsync. I do not know (and assume for the purposes of this question that I cannot find out) what other files are in /home/user on either the local or remote machines, so I can't just ...
Try this: ``` rsync -rv --delete --include=foo.txt '--exclude=*' /home/user/ user@remote:/home/user/ ``` (highly recommend running with `--dry-run` first to test it) Although it seems like it would be easier to use ssh... ``` ssh user@remote "rm /home/user/foo.txt" ```
505,291
<p>I'm playing around and try to make a Coloring book for my children and I have a lots of black and white line drawings that I use as backgrounds so they they can paint on them. </p> <p>Now, I want to add a FILL-function so they can point and click somewhere where its white in the drawing and then let the function fi...
[ { "answer_id": 505318, "author": "David Z", "author_id": 56541, "author_profile": "https://Stackoverflow.com/users/56541", "pm_score": 6, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>rsync -rv --delete --include=foo.txt '--exclude=*' /home/user/ user@remote:/home/user/\n</co...
2009/02/02
[ "https://Stackoverflow.com/questions/505291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19307/" ]
I'm playing around and try to make a Coloring book for my children and I have a lots of black and white line drawings that I use as backgrounds so they they can paint on them. Now, I want to add a FILL-function so they can point and click somewhere where its white in the drawing and then let the function fill the who...
Try this: ``` rsync -rv --delete --include=foo.txt '--exclude=*' /home/user/ user@remote:/home/user/ ``` (highly recommend running with `--dry-run` first to test it) Although it seems like it would be easier to use ssh... ``` ssh user@remote "rm /home/user/foo.txt" ```
505,305
<p>If I've got Foo with a property of type Bar. Both are persisted in a database which can be retrieved by an ID. (The IDs are actually used in the line of business by customer service claims. So they're not just index placeholders.) I could take the approach shown with b1 or b2.</p> <p>Chaining entities together ...
[ { "answer_id": 505313, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 0, "selected": false, "text": "<p>Take a look at the way MSFT implemented LINQ to SQL. They let you set either/or. Their mapper is smart enough to ...
2009/02/02
[ "https://Stackoverflow.com/questions/505305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
If I've got Foo with a property of type Bar. Both are persisted in a database which can be retrieved by an ID. (The IDs are actually used in the line of business by customer service claims. So they're not just index placeholders.) I could take the approach shown with b1 or b2. Chaining entities together scares me sinc...
As a general rule I try to avoid chaining, because it usually introduces unncessary tight coupling. All depends on the context, but in terms of business objects it might be a good idea to keep the entities loosely coupled so they can grow independently. In the example you provide I don't think tight coupling is warran...
505,314
<p>When trying to use the code presented here <a href="https://stackoverflow.com/questions/220767/auto-refreshing-div-with-jquery/500871">link text</a> I ran into some problems, which was suggested to open up a new question for this problem. Im an using that code here <a href="http://togethr.org/test/test.php" rel="nof...
[ { "answer_id": 505332, "author": "IAdapter", "author_id": 30453, "author_profile": "https://Stackoverflow.com/users/30453", "pm_score": 1, "selected": false, "text": "<p>try something like this</p>\n\n<pre><code>function getRandom() {\n $(\"#random\").hide(\"slow\");\n $(\"#random\...
2009/02/02
[ "https://Stackoverflow.com/questions/505314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When trying to use the code presented here [link text](https://stackoverflow.com/questions/220767/auto-refreshing-div-with-jquery/500871) I ran into some problems, which was suggested to open up a new question for this problem. Im an using that code here [link text](http://togethr.org/test/test.php) trying to create a ...
You're having problems because the div's content is loaded before the hiding animation is complete. You can solve it using another callback, like this: (This is very similar to what Mark wrote, but with anonymous functions) ``` $(document).ready(function(){ setInterval(function(){ $("#random:not(:animated)")....
505,353
<p>I have multiple dropdownlist in a page and would like to disable all if user selects a checkbox which reads disable all. So far I have this code and it is not working. Any suggestions?</p> <pre><code>foreach (Control c in this.Page.Controls) { if (c is DropDownList) ((DropDownList)(c)).Enabled = false; ...
[ { "answer_id": 505365, "author": "bechbd", "author_id": 30383, "author_profile": "https://Stackoverflow.com/users/30383", "pm_score": 4, "selected": false, "text": "<p>It would be easiest if you put all the controls you want to disable in a panel and then just enable/disable the panel.</...
2009/02/02
[ "https://Stackoverflow.com/questions/505353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58135/" ]
I have multiple dropdownlist in a page and would like to disable all if user selects a checkbox which reads disable all. So far I have this code and it is not working. Any suggestions? ``` foreach (Control c in this.Page.Controls) { if (c is DropDownList) ((DropDownList)(c)).Enabled = false; } ```
Each control has child controls, so you'd need to use recursion to reach them all: ``` protected void DisableControls(Control parent, bool State) { foreach(Control c in parent.Controls) { if (c is DropDownList) { ((DropDownList)(c)).Enabled = State; } DisableControls(c, State);...
505,374
<p>I would like suggestions on how to inject a record into my DataList to give an "All" option. Here is my code, data coming from the Northwind database.</p> <pre><code>&lt;asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatLayout="Flow" ShowFooter="False" ShowHeader="False" ...
[ { "answer_id": 505422, "author": "Kasper", "author_id": 23499, "author_profile": "https://Stackoverflow.com/users/23499", "pm_score": 0, "selected": false, "text": "<p>I am not sure, but the Feature ID GUID shown <a href=\"http://stsadm.blogspot.com/2007/08/enumerate-features.html\" rel=...
2009/02/02
[ "https://Stackoverflow.com/questions/505374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59941/" ]
I would like suggestions on how to inject a record into my DataList to give an "All" option. Here is my code, data coming from the Northwind database. ``` <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatLayout="Flow" ShowFooter="False" ShowHeader="False" RepeatDirectio...
A SearchCenter is created from a special site template that you can identify from the [WebTemplate](http://www.codeplex.com/sharepointinstaller/Thread/View.aspx?ThreadId=34752) property on the SPWeb object. It will carry the value 'SRCHCEN'.
505,391
<blockquote> <p>Write a program that sums the sequence of integers as well as the smallest in the sequence. Assume that the first integer read with scanf specifies the number of values remaining to be entered. For example the sequence entered:</p> <p>Input: 5 100 350 400 550 678</p> <p>Output: T...
[ { "answer_id": 505395, "author": "Jason Punyon", "author_id": 6212, "author_profile": "https://Stackoverflow.com/users/6212", "pm_score": 2, "selected": false, "text": "<p>No. 5 is the number of integers you have to read into the list.</p>\n" }, { "answer_id": 505398, "autho...
2009/02/02
[ "https://Stackoverflow.com/questions/505391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61710/" ]
> > Write a program that sums the sequence > of integers as well as the smallest in > the sequence. Assume that the first > integer read with scanf specifies the > number of values remaining to be > entered. For example the sequence > entered: > > > Input: 5 100 350 400 550 678 > > > Output: The sum of the s...
First thing, the 5 is not considered part of the list, it's the count for the list. Hence it shouldn't be included in the calculations. Since this is homework, here's the pseudo-code. Your job is to understand the pseudo-code first (run it through your head with sample inputs) then turn this into C code and try to get...
505,427
<p>I want to display a list of images and a description on a webpage using ASP.net MVC. The images are stored in a SQL Server DB and i'm getting them back as a byte[].</p> <p>However, I don't understand how I can display a series of images on a page. I want to do something like this:</p> <pre><code>&lt;% foreach(Prod...
[ { "answer_id": 505432, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 0, "selected": false, "text": "<p>Each image will have to be sent separately (which means creating an IMG request from the browser for each) or you ...
2009/02/02
[ "https://Stackoverflow.com/questions/505427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61712/" ]
I want to display a list of images and a description on a webpage using ASP.net MVC. The images are stored in a SQL Server DB and i'm getting them back as a byte[]. However, I don't understand how I can display a series of images on a page. I want to do something like this: ``` <% foreach(Product p in Model.Products)...
Rather than creating a new HttpHandler you can just write a controller action that returns the contents of the image file. Then add images to the page with their src attribute set to the action you created. EDIT: Note that streaming images as byte[] from a database is inefficient compared to serving static files.
505,434
<p>This question is similar to <a href="https://stackoverflow.com/questions/461912/jquery-finish-one-animation-then-start-the-other-one">this one about animation queues</a>, but the answers in that thread are very specific and not easily generalised.</p> <p>In my web application, messages are reported back to the user...
[ { "answer_id": 505432, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 0, "selected": false, "text": "<p>Each image will have to be sent separately (which means creating an IMG request from the browser for each) or you ...
2009/02/02
[ "https://Stackoverflow.com/questions/505434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
This question is similar to [this one about animation queues](https://stackoverflow.com/questions/461912/jquery-finish-one-animation-then-start-the-other-one), but the answers in that thread are very specific and not easily generalised. In my web application, messages are reported back to the user (info boxes, errors ...
Rather than creating a new HttpHandler you can just write a controller action that returns the contents of the image file. Then add images to the page with their src attribute set to the action you created. EDIT: Note that streaming images as byte[] from a database is inefficient compared to serving static files.
505,465
<p>Is there any gcc option I can set that will give me the line number of the segmentation fault?</p> <p>I know I can:</p> <ol> <li>Debug line by line</li> <li>Put printfs in the code to narrow down.</li> </ol> <p>Edits:</p> <ol> <li><code>bt</code> / <code>where</code> on gdb give No stack.</li> <li><a href="https...
[ { "answer_id": 505483, "author": "rck", "author_id": 5070, "author_profile": "https://Stackoverflow.com/users/5070", "pm_score": 7, "selected": true, "text": "<p>I don't know of a gcc option, but you should be able to run the application with gdb and then when it crashes, type <code>wher...
2009/02/02
[ "https://Stackoverflow.com/questions/505465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16071/" ]
Is there any gcc option I can set that will give me the line number of the segmentation fault? I know I can: 1. Debug line by line 2. Put printfs in the code to narrow down. Edits: 1. `bt` / `where` on gdb give No stack. 2. [Helpful suggestion](https://stackoverflow.com/a/77336/24874)
I don't know of a gcc option, but you should be able to run the application with gdb and then when it crashes, type `where` to take a look at the stack when it exited, which should get you close. ``` $ gdb blah (gdb) run (gdb) where ``` Edit for completeness: You should also make sure to build the application with ...
505,467
<p>I have an unusual idea to use git as a backup system. So let's say I have a directory ./backup/myfiles and I want to back that up using git. To keep things clean I don't want to have a .git directory in the myfiles folder, so I thought I could create ./backup/git_repos/myfiles. From looking at the git docs, I've tri...
[ { "answer_id": 505499, "author": "Abie", "author_id": 53166, "author_profile": "https://Stackoverflow.com/users/53166", "pm_score": 1, "selected": false, "text": "<p>Assuming your <code>myfiles</code> directories already exists and has some content, could you live with this:</p>\n\n<pre>...
2009/02/02
[ "https://Stackoverflow.com/questions/505467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/161922/" ]
I have an unusual idea to use git as a backup system. So let's say I have a directory ./backup/myfiles and I want to back that up using git. To keep things clean I don't want to have a .git directory in the myfiles folder, so I thought I could create ./backup/git\_repos/myfiles. From looking at the git docs, I've tried...
``` git --git-dir=../repo --work-tree=. add foo ``` This will do what you want but will obviously suck when you have to specify it with every git command you ever use. You can export `GIT_WORK_TREE=.` and `GIT_DIR=../backup` and Git will pick them up on each command. That will only comfortably allow you to work in a...
505,471
<p>When writing a C# application whose #1 priority is to <b>never crash</b>, how often should I used a try-catch block?</p> <p>Can I encapsulate all the statements in a method in try-catch blocks?</p> <pre><code>public void SomeMethod() { try { // entire contents of the function // library cal...
[ { "answer_id": 505487, "author": "Matt Briggs", "author_id": 10771, "author_profile": "https://Stackoverflow.com/users/10771", "pm_score": 2, "selected": false, "text": "<p>There is performance overhead for try blocks, if you do that your entire function will run slower then it otherwise...
2009/02/02
[ "https://Stackoverflow.com/questions/505471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/609/" ]
When writing a C# application whose #1 priority is to **never crash**, how often should I used a try-catch block? Can I encapsulate all the statements in a method in try-catch blocks? ``` public void SomeMethod() { try { // entire contents of the function // library calls // function c...
The only down side is when an exception is actually thrown. There is no overhead for wrapping the code, except for when exceptions occur. Also, you don't want to use try/catch for control flow. Consider this (bad code): ``` try { FileStream fs = File.Open("somefile.txt", FileMode.Open); } catch (Exception ex) ...
505,476
<p>So... when I go:</p> <pre><code>cout&lt;&lt;stringName&lt;&lt;endl; </code></pre> <p>I get:</p> <pre><code>NT </code></pre> <p>But when I go:</p> <pre><code>cout&lt;&lt;stringName.c_str()&lt;&lt;endl; </code></pre> <p>I get:</p> <pre><code>NTNT </code></pre> <p>Why?</p>
[ { "answer_id": 505484, "author": "SoapBox", "author_id": 36384, "author_profile": "https://Stackoverflow.com/users/36384", "pm_score": 1, "selected": false, "text": "<p>This is not a problem with <code>c_str()</code>, but probably related to some other anomaly in the rest of the program....
2009/02/02
[ "https://Stackoverflow.com/questions/505476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45581/" ]
So... when I go: ``` cout<<stringName<<endl; ``` I get: ``` NT ``` But when I go: ``` cout<<stringName.c_str()<<endl; ``` I get: ``` NTNT ``` Why?
A quick test with the following code: ``` #include <string> #include <iostream> using namespace std; int main(void) { string str = "NT"; cout << str.c_str() << endl; return 0; } ``` produces one instance of NT so it looks like you probably have another output call somewhere.
505,515
<p>This is a detail question for C#.</p> <p>Suppose I've got a class with an object, and that object is protected by a lock:</p> <pre><code>Object mLock = new Object(); MyObject property; public MyObject MyProperty { get { return property; } set { property = value; } } </code></pre...
[ { "answer_id": 505542, "author": "SoapBox", "author_id": 36384, "author_profile": "https://Stackoverflow.com/users/36384", "pm_score": 1, "selected": false, "text": "<p>In the code example you posted, a get is never preformed.</p>\n\n<p>In a more complicated example:</p>\n\n<pre><code>My...
2009/02/02
[ "https://Stackoverflow.com/questions/505515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21981/" ]
This is a detail question for C#. Suppose I've got a class with an object, and that object is protected by a lock: ``` Object mLock = new Object(); MyObject property; public MyObject MyProperty { get { return property; } set { property = value; } } ``` I want a polling thread to ...
No, your code won't lock access to the members of the object returned from `MyProperty`. It only locks `MyProperty` itself. Your example usage is really two operations rolled into one, roughly equivalent to this: ``` // object is locked and then immediately released in the MyProperty getter MyObject o = MyProperty; ...
505,523
<p>I am using this code where I am invoking the <code>run</code> method of a List of classes that I loaded dynamically from dlls:</p> <pre><code>for (int i = 0; i &lt; robotList.Count; i++) { Type t = robotList[i]; //robotList is a List&lt;Type&gt; object o = Activator.CreateInstance(t); t.InvokeMember("ru...
[ { "answer_id": 505554, "author": "Rex M", "author_id": 67, "author_profile": "https://Stackoverflow.com/users/67", "pm_score": 5, "selected": true, "text": "<p>If you know that all your dynamically loaded types implement Run, could you just require they all implement IRunable and get rid...
2009/02/03
[ "https://Stackoverflow.com/questions/505523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44084/" ]
I am using this code where I am invoking the `run` method of a List of classes that I loaded dynamically from dlls: ``` for (int i = 0; i < robotList.Count; i++) { Type t = robotList[i]; //robotList is a List<Type> object o = Activator.CreateInstance(t); t.InvokeMember("run", BindingFlags.Default | Binding...
If you know that all your dynamically loaded types implement Run, could you just require they all implement IRunable and get rid of the reflection part? ``` Type t = robotList[i]; IRunable o = Activator.CreateInstance(t) as IRunable; if (o != null) { o.Run(); //do this in another thread of course, see below } ```...
505,540
<p>Simple enough, it would seem, but it turns out not to be - mainly due to the fact that the View can't possibly know which way through Model and Controller you got there. Regardless, it is a problem that needs a solution:</p> <p>I have a login link, that takes the user to a form to enter username and password. When ...
[ { "answer_id": 505689, "author": "Chaddeus", "author_id": 61320, "author_profile": "https://Stackoverflow.com/users/61320", "pm_score": 2, "selected": false, "text": "<p>One way would be to build the links that send the user to the login form, with returnUrl=/PageToReturnTo (<code>&lt;a ...
2009/02/03
[ "https://Stackoverflow.com/questions/505540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38055/" ]
Simple enough, it would seem, but it turns out not to be - mainly due to the fact that the View can't possibly know which way through Model and Controller you got there. Regardless, it is a problem that needs a solution: I have a login link, that takes the user to a form to enter username and password. When the user c...
The solution is to use HttpContext.Current.Request.RawUrl like this: ``` <%= Html.ActionLink("log on", "LogIn", new { controller = "User", returnUrl = HttpContext.Current.Request.RawUrl }) %> ``` Or with an extension method from [MVC futures](http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=2235...
505,559
<p>I've been trying to learn Python, and while I'm enthusiastic about using closures in Python, I've been having trouble getting some code to work properly:</p> <pre><code>def memoize(fn): def get(key): return (False,) def vset(key, value): global get oldget = get def newget(ky...
[ { "answer_id": 505594, "author": "Jonas Kölker", "author_id": 58668, "author_profile": "https://Stackoverflow.com/users/58668", "pm_score": 1, "selected": false, "text": "<p>You want to put <code>global get</code> at the beginning of <em>every</em> function (except <code>get</code> itsel...
2009/02/03
[ "https://Stackoverflow.com/questions/505559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658/" ]
I've been trying to learn Python, and while I'm enthusiastic about using closures in Python, I've been having trouble getting some code to work properly: ``` def memoize(fn): def get(key): return (False,) def vset(key, value): global get oldget = get def newget(ky): ...
The problem is in your scoping, not in your closures. If you're up for some heavy reading, then you can try <http://www.python.org/dev/peps/pep-3104/>. If that's not the case, here's the simple explanation: The problem is in the statement `global get` . `global` refers to the outermost scope, and since there isn't an...
505,562
<p>I have a script which combines a number of files into one, and it breaks when one of the files has UTF8 encoding. I figure that I should be using the <code>utf8_decode()</code> function when reading the files, but I don't know how to tell which need decoding.</p> <p>My code is basically:</p> <pre><code>$output = '...
[ { "answer_id": 505582, "author": "cbrulak", "author_id": 29505, "author_profile": "https://Stackoverflow.com/users/29505", "pm_score": 1, "selected": false, "text": "<p>How are you going to handle the non-ASCII characters from the UTF-8 or 16 or 32 file?</p>\n\n<p>I ask because I think y...
2009/02/03
[ "https://Stackoverflow.com/questions/505562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
I have a script which combines a number of files into one, and it breaks when one of the files has UTF8 encoding. I figure that I should be using the `utf8_decode()` function when reading the files, but I don't know how to tell which need decoding. My code is basically: ``` $output = ''; foreach ($files as $filename)...
Try using the [`mb_detect_encoding` function](http://www.php.net/manual/en/function.mb-detect-encoding.php). This function will examine your string and attempt to "guess" what its encoding is. You can then convert it as desired. As [brulak suggested](https://stackoverflow.com/questions/505562/detect-file-encoding-in-ph...
505,566
<p>I know I can open config files that are related to an assembly with the static <code>ConfigurationManager.OpenExe(exePath)</code> method but I just want to open a config that is not related to an assembly. Just a standard .NET config file.</p>
[ { "answer_id": 505583, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 3, "selected": false, "text": "<p>The config file is just an XML file, you can open it by:</p>\n\n<pre><code>private static XmlDocument loadConfigDo...
2009/02/03
[ "https://Stackoverflow.com/questions/505566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21682/" ]
I know I can open config files that are related to an assembly with the static `ConfigurationManager.OpenExe(exePath)` method but I just want to open a config that is not related to an assembly. Just a standard .NET config file.
the articles posted by Ricky are very good, but unfortunately they don't answer your question. To solve your problem you should try this piece of code: ``` ExeConfigurationFileMap configMap = new ExeConfigurationFileMap(); configMap.ExeConfigFilename = @"d:\test\justAConfigFile.config.whateverYouLikeExtension"; Confi...
505,567
<p>Sooooo I'm writing a script interpreter. And basically, I want some classes and functions stored in a DLL, but I want the DLL to look for functions within the programs that are linking to it, like,</p> <pre><code> program dll ---------------------------------------------------- send code to dll...
[ { "answer_id": 505587, "author": "cbrulak", "author_id": 29505, "author_profile": "https://Stackoverflow.com/users/29505", "pm_score": -1, "selected": false, "text": "<p>You could always load the dll at runtime with <a href=\"http://msdn.microsoft.com/en-us/library/ms684175.aspx\" rel=\"...
2009/02/03
[ "https://Stackoverflow.com/questions/505567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61721/" ]
Sooooo I'm writing a script interpreter. And basically, I want some classes and functions stored in a DLL, but I want the DLL to look for functions within the programs that are linking to it, like, ``` program dll ---------------------------------------------------- send code to dll-----> pars...
[This link](http://www.cygwin.com/cygwin-ug-net/dll.html) explains how to do it in a basic way. In a big picture view, when you make a dll, you are making a library which is loaded at runtime. It contains a number of symbols which are exported. These symbols are typically references to methods or functions, plus compi...
505,593
<p>Thread to wait <strong>infinitely</strong> in a loop until a <strong>flag state</strong> change, then call function.</p> <p><strong>pseudo code illustration:</strong></p> <pre><code>while (true) { while (!flag) { sleep(1); } clean_upfunction(); } </code></pre> <p><strong>Currently</str...
[ { "answer_id": 505603, "author": "Nick", "author_id": 26240, "author_profile": "https://Stackoverflow.com/users/26240", "pm_score": 4, "selected": true, "text": "<p>For Windows (which you have this tagged for), you want to look at <a href=\"http://msdn.microsoft.com/en-us/library/ms68703...
2009/02/03
[ "https://Stackoverflow.com/questions/505593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51078/" ]
Thread to wait **infinitely** in a loop until a **flag state** change, then call function. **pseudo code illustration:** ``` while (true) { while (!flag) { sleep(1); } clean_upfunction(); } ``` **Currently**: * Using the multithreaded versions of the [**C run-time libraries only**](http...
For Windows (which you have this tagged for), you want to look at [WaitForSingleObject](http://msdn.microsoft.com/en-us/library/ms687032.aspx). Use a Windows Event (with CreateEvent), then wait on it; the other thread should call SetEvent. All native Windows, no MFC or anything else required.
505,617
<p>I have a flag attribute enumeration that is behind a web service as follows:</p> <pre><code>[Serializable,Flags] public enum AccessLevels { None = 0, Read = 1, Write = 2, Full = Read | Write } </code></pre> <p>My problem is the consumer of my web service does not have the original constant values o...
[ { "answer_id": 505628, "author": "rbrayb", "author_id": 9922, "author_profile": "https://Stackoverflow.com/users/9922", "pm_score": 0, "selected": false, "text": "<p>I had a similar problem and got round it by adding another web service to return the currect flag values first.</p>\n\n<p>...
2009/02/03
[ "https://Stackoverflow.com/questions/505617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22240/" ]
I have a flag attribute enumeration that is behind a web service as follows: ``` [Serializable,Flags] public enum AccessLevels { None = 0, Read = 1, Write = 2, Full = Read | Write } ``` My problem is the consumer of my web service does not have the original constant values of the enum. The resulting ...
I have done extensive research on this and found that it is not possible to serialize enumeration constants through a web service. Note that to accomplish your goal you don't need the enumerations None or Full. These two enumerations can be implied with read / write combination: You could assume full access if your Ac...
505,626
<p>I'm aware that you can set an <code>onclick</code> handler like this:</p> <pre><code>my_a = document.createElement('a'); my_a.onclick = somefunction; </code></pre> <p>... but what if <code>somefunction</code> takes a parameter? For the sake of simplicity, let's say I need to pass it the string <code>&quot;x&quot;</c...
[ { "answer_id": 505633, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 2, "selected": false, "text": "<p>You want to use what is called an <strong>anonymous function</strong>:</p>\n\n<pre><code>my_a.onclick = function() {\n ...
2009/02/03
[ "https://Stackoverflow.com/questions/505626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91385/" ]
I'm aware that you can set an `onclick` handler like this: ``` my_a = document.createElement('a'); my_a.onclick = somefunction; ``` ... but what if `somefunction` takes a parameter? For the sake of simplicity, let's say I need to pass it the string `"x"`. Is it possible to dynamically set the `onclick` handler to `s...
Then you would create an anonymous function: ``` my_a = document.createElement('a'); my_a.onclick = function() { somefunction(x); }; ``` If you also like to refer to `this` in `somefunction`, you could use a library like [Prototype][1], then you would do something like: ``` my_a = document.createElement('a'); my_a....
505,641
<p>I am just starting to learn design patterns and I have two questions related to the Decorator...</p> <p>I was wondering why the decorator pattern suggests that the decorator implement all public methods of the component of which it decorates?</p> <p>Can't the decorator class just be used to provide the additional ...
[ { "answer_id": 505658, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 5, "selected": true, "text": "<p>I think you have have misunderstood Decorator. You're thinking of a simple case of extending a concrete class with ...
2009/02/03
[ "https://Stackoverflow.com/questions/505641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61742/" ]
I am just starting to learn design patterns and I have two questions related to the Decorator... I was wondering why the decorator pattern suggests that the decorator implement all public methods of the component of which it decorates? Can't the decorator class just be used to provide the additional behaviors, and th...
I think you have have misunderstood Decorator. You're thinking of a simple case of extending a concrete class with additional functionality. In this case, yes in most OO languages the derived class can simply allow its superclass to handle any unimplemented methods. ``` class Base { function foo() { return "foo...
505,642
<p>In terms of performance , what would be better. Using PHP to echo all the HTML output so I can pepper it with the various bits of working code and variables or escape HTML to php periodically throughout the documents.</p> <p>I know there may be some readability issues but I'm not to worried about that.</p> <p>Than...
[ { "answer_id": 505650, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 3, "selected": false, "text": "<p>It falls into the realm of micro optimizations. The largest part of your time falls into initializing the PHP engi...
2009/02/03
[ "https://Stackoverflow.com/questions/505642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58314/" ]
In terms of performance , what would be better. Using PHP to echo all the HTML output so I can pepper it with the various bits of working code and variables or escape HTML to php periodically throughout the documents. I know there may be some readability issues but I'm not to worried about that. Thanks all! Example ...
It's all about which you find the most readable. Of course, this will vary with each situation. If you were doing an entire page, and there were large sections which did not have any PHP in it, then I'd break out of PHP and just write the plain HTML, whereas if there was a section which had a lot of PHP variables, I'd ...
505,677
<p>How to change the background color of UL 'li' on click?</p> <p>EDIT i can change li "a" but what about the entire <strong>li</strong></p> <p>this works:</p> <pre><code> $(".clickableUL").click(function() { $(this).find("li a").addClass("active"); }); </code></pre> <p>but find("li") does nothin...
[ { "answer_id": 505693, "author": "roborourke", "author_id": 42147, "author_profile": "https://Stackoverflow.com/users/42147", "pm_score": 4, "selected": true, "text": "<pre><code>// javascript\n$(\"li&gt;a\").click(function(){\n $(this).parent().toggleClass(\"clicked\");\n});\n\n/* CSS...
2009/02/03
[ "https://Stackoverflow.com/questions/505677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49632/" ]
How to change the background color of UL 'li' on click? EDIT i can change li "a" but what about the entire **li** this works: ``` $(".clickableUL").click(function() { $(this).find("li a").addClass("active"); }); ``` but find("li") does nothing. I want the LI highlighted not just the text of the...
``` // javascript $("li>a").click(function(){ $(this).parent().toggleClass("clicked"); }); /* CSS */ li { background: blue; } li.clicked { background: red; } ``` You could also use `display: block;` on the `<a>` to make it fill the `<li>` unless you want it to stay changed. EDIT: d'oh! just realised you could al...
505,686
<p><a href="http://www.scala-lang.org/node/117" rel="noreferrer">Scala Mixins</a></p>
[ { "answer_id": 505757, "author": "Logan Capaldo", "author_id": 61289, "author_profile": "https://Stackoverflow.com/users/61289", "pm_score": 5, "selected": true, "text": "<p>No, but it can be faked to varying degrees with templates:</p>\n\n<pre><code>template&lt;typename AbsIterator&gt; ...
2009/02/03
[ "https://Stackoverflow.com/questions/505686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61342/" ]
[Scala Mixins](http://www.scala-lang.org/node/117)
No, but it can be faked to varying degrees with templates: ``` template<typename AbsIterator> class RichIterator : public AbsIterator { public: template<typename FuncType> void foreach(FuncType f) { while( hasNext() ) f( next() ); } }; class StringIterator { std::string m_s; int i; public: typedef char T...
505,744
<p>I'm new to WPF and come from a WinForms background and have a fairly basic question about binding vs event handling. </p> <p>To try and maintain some separation of responsibility I've have a bunch of <code>Presentation</code> objects which simply have <code>Dependency Properties</code> to hold the UI data parts of ...
[ { "answer_id": 505776, "author": "MrTelly", "author_id": 56092, "author_profile": "https://Stackoverflow.com/users/56092", "pm_score": 0, "selected": false, "text": "<p>I reckon you're on the right track, as DependencyProperties have built in mechanisms for handling change they get rid o...
2009/02/03
[ "https://Stackoverflow.com/questions/505744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4403/" ]
I'm new to WPF and come from a WinForms background and have a fairly basic question about binding vs event handling. To try and maintain some separation of responsibility I've have a bunch of `Presentation` objects which simply have `Dependency Properties` to hold the UI data parts of a business object, the business ...
[Look here](http://msdn.microsoft.com/en-us/magazine/dd419663.aspx) this present the pattern Model View ViewModel, this permit you to take full advantages on the binding, and Command of WPF, without disturb your business objects (like implementing WPF stuff like INotifyPropertyChanged on your business objects)
505,747
<p>I'm writing an SQL Query, where a few of the columns returned need to be calculated depending on quite a lot of conditions.</p> <p>I'm currently using nested case statements, but its getting messy. Is there a better (more organised and/or readable) way?</p> <p>(I am using Microsoft SQL Server, 2005)</p> <hr> <p>...
[ { "answer_id": 505756, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 3, "selected": false, "text": "<p>a user-defined function may server better, at least to hide the logic - esp. if you need to do this in more than o...
2009/02/03
[ "https://Stackoverflow.com/questions/505747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59587/" ]
I'm writing an SQL Query, where a few of the columns returned need to be calculated depending on quite a lot of conditions. I'm currently using nested case statements, but its getting messy. Is there a better (more organised and/or readable) way? (I am using Microsoft SQL Server, 2005) --- A simplified example: ``...
You could try some sort of COALESCE trick, eg: ``` SELECT COALESCE( CASE WHEN condition1 THEN calculation1 ELSE NULL END, CASE WHEN condition2 THEN calculation2 ELSE NULL END, etc... ) ```
505,759
<p>I'm trying to make a crossplatform C# application using C#, mono/GTK# on Linux and .NET/GTK# on Windows, however the startup sequence seems to need to be slightly different under the two platforms:</p> <p>Under Linux:</p> <pre><code>public static void Main (string[] args) { Gdk.Threads.Init (); // etc... <...
[ { "answer_id": 526549, "author": "Sandeep Datta", "author_id": 39648, "author_profile": "https://Stackoverflow.com/users/39648", "pm_score": 0, "selected": false, "text": "<p>Umm, have you tried decorating your Main method with the [STAThread] attribute?</p>\n\n<p>e.g. </p>\n\n<pre><cod...
2009/02/03
[ "https://Stackoverflow.com/questions/505759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]
I'm trying to make a crossplatform C# application using C#, mono/GTK# on Linux and .NET/GTK# on Windows, however the startup sequence seems to need to be slightly different under the two platforms: Under Linux: ``` public static void Main (string[] args) { Gdk.Threads.Init (); // etc... ``` Under Windows: ...
Gtk+ on Win32 does not properly support threading. You need to do all your GUI calls from the same thread as you did called Gtk.Main(). It's not actually as bad as it sounds. There's a trick you can use to dispatch functions to the main thread. Just use GLib.Idle.Add() from any thread and the function will be called ...
505,761
<p>When using ADO.Net Data Services client to refresh an entity by calling the <code>LoadProperty</code>:</p> <pre><code>ctx.BeginLoadProperty(this, "Owner", (IAsyncResult ar) =&gt; ... </code></pre> <p>It throws an error on the server if the property is <code>null</code></p> <blockquote> <p>Error: Exception Throw...
[ { "answer_id": 531068, "author": "ChrisHDog", "author_id": 25719, "author_profile": "https://Stackoverflow.com/users/25719", "pm_score": 2, "selected": false, "text": "<p>I've received a \"Resource not found for segment 'Property'\" error also. Mine appears to be that in the where claus...
2009/02/03
[ "https://Stackoverflow.com/questions/505761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59273/" ]
When using ADO.Net Data Services client to refresh an entity by calling the `LoadProperty`: ``` ctx.BeginLoadProperty(this, "Owner", (IAsyncResult ar) => ... ``` It throws an error on the server if the property is `null` > > Error: Exception Thrown: System.Data.Services.DataServiceException: > Resource not found ...
Querying on primary keys generate an exception when the key does not exist. The workaround is to add a dummy true expression in the condition (eg : 1==1 && item.Id == XXX). Without the dummy expression the ADO.NET request is: > > http: //localhost//test.svc/Role(XXX) > > > With the dummy condition, the request i...
505,780
<p>I have a set of records in my MS SQL table. With Date as the primary key. But the Dates are only for working days and not the continues days. Eg:</p> <p>1/3/2000 12:00:00 AM 5209.540000000 5384.660000000 5209.540000000 5375.110000000 1/4/2000 12:00:00 AM 5533.980000000 5533.980000000 5376.430000000 5491...
[ { "answer_id": 505799, "author": "DarkwingDuck", "author_id": 51948, "author_profile": "https://Stackoverflow.com/users/51948", "pm_score": 1, "selected": false, "text": "<p>You need to break this down into 2 parts. First is updating your existing data, and second is ensuring all new dat...
2009/02/03
[ "https://Stackoverflow.com/questions/505780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20951/" ]
I have a set of records in my MS SQL table. With Date as the primary key. But the Dates are only for working days and not the continues days. Eg: 1/3/2000 12:00:00 AM 5209.540000000 5384.660000000 5209.540000000 5375.110000000 1/4/2000 12:00:00 AM 5533.980000000 5533.980000000 5376.430000000 5491.010000000 1/5/2000 12...
There are a few ways of doing this. Here is one. ``` CREATE TABLE MyTable ( MyDate datetime NOT NULL PRIMARY KEY, Col2 decimal(14,4) NOT NULL, Col3 decimal(14,4) NOT NULL, Col4 decimal(14,4) NOT NULL, Col5 decimal(14,4) NOT NULL ) GO INSERT INTO MyTable SELECT '1/3/2000 12:00:00 AM', 5209.54000000...
505,811
<p>I have a borderless and transparent window in WPF, with some fancy decoration at the bottom. There's a custom footer with some non conventional curves and what not showing the company logo. This window needs to be resizable with a grip in the bottom right corner like conventional windows.</p> <p>Anyways, I have put...
[ { "answer_id": 505845, "author": "Peter McG", "author_id": 57465, "author_profile": "https://Stackoverflow.com/users/57465", "pm_score": 6, "selected": true, "text": "<p>The appearance of a resize grip is controlled via the <a href=\"http://msdn.microsoft.com/en-us/library/system.windows...
2009/02/03
[ "https://Stackoverflow.com/questions/505811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36234/" ]
I have a borderless and transparent window in WPF, with some fancy decoration at the bottom. There's a custom footer with some non conventional curves and what not showing the company logo. This window needs to be resizable with a grip in the bottom right corner like conventional windows. Anyways, I have put my own Re...
The appearance of a resize grip is controlled via the [ResizeMode](http://msdn.microsoft.com/en-us/library/system.windows.window.resizemode.aspx) dependency property on the Window. If this is set to CanResizeWithGrip: ```xml <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2...
505,838
<p>This is basic stuff, but I'm somewhat unfamiliar with VBA and the Word/Access object models.</p> <p>I have a two column database of about 117000 records. The columns are 'surname' and 'count'. I want a user to be able to type SMITH in a textbox and hit submit. I then want to run something like</p> <p><code>SELECT ...
[ { "answer_id": 505933, "author": "Joel Spolsky", "author_id": 4, "author_profile": "https://Stackoverflow.com/users/4", "pm_score": 4, "selected": true, "text": "<p>First of all, be careful naming the column 'count' -- this is a keyword in SQL and might cause problems. Similarly, don't c...
2009/02/03
[ "https://Stackoverflow.com/questions/505838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51498/" ]
This is basic stuff, but I'm somewhat unfamiliar with VBA and the Word/Access object models. I have a two column database of about 117000 records. The columns are 'surname' and 'count'. I want a user to be able to type SMITH in a textbox and hit submit. I then want to run something like `SELECT table.count FROM table...
First of all, be careful naming the column 'count' -- this is a keyword in SQL and might cause problems. Similarly, don't call the table 'table'. Here is some sample code which shows one way of doing it: ``` ' This example uses Microsoft ActiveX Data Objects 2.8, ' which you have to check in Tools | References ' Cre...
505,839
<p>Is there a way to set the Default Layout Orientation when printing XPSs using the WPF XPS Viewer?</p> <p>My fixed document XPS has its page orientation set to Landscape, the Page Media Size has a width that is longer that its height and it displays correctly in the Viewer as Landscape. Its just that when you hit th...
[ { "answer_id": 551505, "author": "dirkgently", "author_id": 66692, "author_profile": "https://Stackoverflow.com/users/66692", "pm_score": 0, "selected": false, "text": "<p>This is not really a problem with MXDW but one with the way drivers work on Windows. The user choice(s) is/are saved...
2009/02/03
[ "https://Stackoverflow.com/questions/505839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6042/" ]
Is there a way to set the Default Layout Orientation when printing XPSs using the WPF XPS Viewer? My fixed document XPS has its page orientation set to Landscape, the Page Media Size has a width that is longer that its height and it displays correctly in the Viewer as Landscape. Its just that when you hit the print bu...
Fill the field of the PrintTicket: ``` PrintDialog pd = new PrintDialog(); PrintTicket pt = new PrintTicket(); pt.PageOrientation = PageOrientation.Landscape; pd.PrintTicket = pd.PrintQueue.MergeAndValidatePrintTicket(pd.PrintQueue.DefaultPrintTicket, pt).ValidatedPrintTicket; if (pd.ShowDialog() == true) ...
505,840
<p>What would be the most idiomatic way to do the following in JavaScript:</p> <p>If <code>myParam</code> is not passed into <code>MyFunc</code> by the caller, then I want to set it to a default value. But first I want to try and get it from another object, which may not yet exist:</p> <pre><code>function MyFunc(myPar...
[ { "answer_id": 505849, "author": "Luca Matteis", "author_id": 50394, "author_profile": "https://Stackoverflow.com/users/50394", "pm_score": 5, "selected": true, "text": "<p>If myObj is a global it needs to reference the window object, otherwise it will throw an error if <code>myObj</code...
2009/02/03
[ "https://Stackoverflow.com/questions/505840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/785/" ]
What would be the most idiomatic way to do the following in JavaScript: If `myParam` is not passed into `MyFunc` by the caller, then I want to set it to a default value. But first I want to try and get it from another object, which may not yet exist: ``` function MyFunc(myParam) { if (!myParam) { if (!my...
If myObj is a global it needs to reference the window object, otherwise it will throw an error if `myObj` is undefined. ``` myParam = myParam || (window.myObj ? window.myObj.mParam : 10); ``` or ``` myParam = myParam || (window.myObj && window.myObj.mParam) || 10; ``` This works as well: ``` myParam = myParam ||...
505,848
<p>I know the regex for doing a global replace,</p> <pre><code> %s/old/new/g </code></pre> <p>How do you go about doing an interactive search-replace in <a href="http://en.wikipedia.org/wiki/Vim_%28text_editor%29" rel="noreferrer">Vim</a>?</p>
[ { "answer_id": 505857, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 3, "selected": false, "text": "<p>I usually use the find/substitute/next/repeat command :-)</p>\n\n<pre><code>/old&lt;CR&gt;3snew&lt;ESC&gt;n.n.n.n.n.n...
2009/02/03
[ "https://Stackoverflow.com/questions/505848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43756/" ]
I know the regex for doing a global replace, ``` %s/old/new/g ``` How do you go about doing an interactive search-replace in [Vim](http://en.wikipedia.org/wiki/Vim_%28text_editor%29)?
Add the flag **c** (in the vim command prompt): ``` :%s/old/new/gc ``` will give you a yes/no prompt at each occurrence of 'old'. !["old" is highlighted in the text; at the bottom of the window it says "replace with new (y/n/a/q/l/^E/^y)?)"](https://i.stack.imgur.com/LwYPG.jpg) Vim's built-in help offers useful in...