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
186,970
<p>What ReSharper 4.0 templates for <strong>C#</strong> do you use?</p> <p>Let's share these in the following format:</p> <hr> <h2>[Title]</h2> <p><em>Optional description</em> </p> <p><strong>Shortcut:</strong> shortcut<br> <strong>Available in:</strong> [AvailabilitySetting]</p> <pre><code>// Resharper templat...
[ { "answer_id": 186974, "author": "Rinat Abdullin", "author_id": 47366, "author_profile": "https://Stackoverflow.com/users/47366", "pm_score": 4, "selected": false, "text": "<h2>Create new unit test fixture for some type</h2>\n\n<p><strong>Shortcut:</strong> ntf<br>\n<strong>Available in:...
2008/10/09
[ "https://Stackoverflow.com/questions/186970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47366/" ]
What ReSharper 4.0 templates for **C#** do you use? Let's share these in the following format: --- [Title] ------- *Optional description* **Shortcut:** shortcut **Available in:** [AvailabilitySetting] ``` // Resharper template code snippet // comes here ``` **Macros properties** (if present): * **Macro1** ...
Implement 'Dispose(bool)' Method -------------------------------- *Implement [Joe Duffy's Dispose Pattern](http://www.bluebytesoftware.com/blog/2005/04/08/DGUpdateDisposeFinalizationAndResourceManagement.aspx)* **Shortcut:** dispose **Available in:** C# 2.0+ files where type member declaration is allowed ``` publi...
187,000
<p>I have an asp.net website that allows the user to download largish files - 30mb to about 60mb. Sometimes the download works fine but often it fails at some varying point before the download finishes with the message saying that the connection with the server was reset.</p> <p>Originally I was simply using Server.T...
[ { "answer_id": 187022, "author": "kaa", "author_id": 2105, "author_profile": "https://Stackoverflow.com/users/2105", "pm_score": 2, "selected": false, "text": "<p>Will</p>\n\n<pre><code>&lt;configuration&gt;\n &lt;system.web&gt;\n &lt;httpRuntime executionTimeout=\"3600\"/&gt;\n &lt...
2008/10/09
[ "https://Stackoverflow.com/questions/187000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10135/" ]
I have an asp.net website that allows the user to download largish files - 30mb to about 60mb. Sometimes the download works fine but often it fails at some varying point before the download finishes with the message saying that the connection with the server was reset. Originally I was simply using Server.TransmitFile...
The final fix for this problem was to make a modification in the web.config file. I simply had to change sessionState mode="InProc" to sessionState mode="StateServer".
187,001
<p>Is it possible to provide WCF with a custom proxy address and custom credentials? </p> <p>I've found this answer on stackoverflow: <a href="https://stackoverflow.com/questions/105499/how-to-set-proxy-with-credentials-to-generated-wcf-client">How to set proxy with credentials to generated WCF client?</a>, but I've g...
[ { "answer_id": 187152, "author": "sebagomez", "author_id": 23893, "author_profile": "https://Stackoverflow.com/users/23893", "pm_score": 2, "selected": false, "text": "<p>The client credentials you're setting are fine in order to authenticate to your services.<br>\nFor proxy authenticati...
2008/10/09
[ "https://Stackoverflow.com/questions/187001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1313/" ]
Is it possible to provide WCF with a custom proxy address and custom credentials? I've found this answer on stackoverflow: [How to set proxy with credentials to generated WCF client?](https://stackoverflow.com/questions/105499/how-to-set-proxy-with-credentials-to-generated-wcf-client), but I've got a complication, th...
If you set the [WebRequest.DefaultWebProxy](http://msdn.microsoft.com/en-us/library/system.net.webrequest.defaultwebproxy.aspx) property to a new WebProxy with credentials, WCF will use it for all HTTP requests that it makes. (This will affect all HttpWebRequests used by the application unless explicitly overridden). ...
187,004
<p>I have a large legacy system to maintain. The codebase uses threads all over the place and those threads share a lot of mutable data. I know, sounds bad. Anyway, don't answer "rewrite the whole application from scratch" or I'll vote you down :-) I have tried to run some static analysis tools on the codebase, but non...
[ { "answer_id": 187054, "author": "Chris Vest", "author_id": 13251, "author_profile": "https://Stackoverflow.com/users/13251", "pm_score": 1, "selected": false, "text": "<p>FindBugs and professional tools based on it are your best hope, but don't count on them finding all of the concurren...
2008/10/09
[ "https://Stackoverflow.com/questions/187004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4110/" ]
I have a large legacy system to maintain. The codebase uses threads all over the place and those threads share a lot of mutable data. I know, sounds bad. Anyway, don't answer "rewrite the whole application from scratch" or I'll vote you down :-) I have tried to run some static analysis tools on the codebase, but none o...
Chris Grindstaff wrote an article [FindBugs, Part 2: Writing custom detectors](http://www.ibm.com/developerworks/java/library/j-findbug2/) in which he describes how to use the [BCEL](http://jakarta.apache.org/bcel/index.html) to add your own rules. (BCEL isn't the only bytecode library - but it is the one used by FindB...
187,018
<p>In a page, on the load event, I am dynamically creating controls for display on the page. This is all working properly. the trouble I am having is when adding extenders from the AJAX control toolkit, specifically I am trying to add rounded corners to a button control. No errors are thrown, but the AJAX Extension fun...
[ { "answer_id": 187033, "author": "Rob", "author_id": 7872, "author_profile": "https://Stackoverflow.com/users/7872", "pm_score": 2, "selected": false, "text": "<p>You need to add the \"editRoundedCorners\" to the page, or containers, Controls collection, so try adding the line:</p>\n\n<p...
2008/10/09
[ "https://Stackoverflow.com/questions/187018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16391/" ]
In a page, on the load event, I am dynamically creating controls for display on the page. This is all working properly. the trouble I am having is when adding extenders from the AJAX control toolkit, specifically I am trying to add rounded corners to a button control. No errors are thrown, but the AJAX Extension functi...
You cannot apply a RoundedCornersExtender to input elements such as TextBox or Buttons.
187,040
<p>I Have an old vbs script file being kicked off by an AutoSys job. Can I, and how do I, return an int return value to indicate success or failure?</p>
[ { "answer_id": 187051, "author": "Rob", "author_id": 7872, "author_profile": "https://Stackoverflow.com/users/7872", "pm_score": 6, "selected": false, "text": "<p>Try:</p>\n\n<pre><code>WScript.Quit n\n</code></pre>\n\n<p>Where n is the ERRORLEVEL you want to return</p>\n" }, { "...
2008/10/09
[ "https://Stackoverflow.com/questions/187040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/180142/" ]
I Have an old vbs script file being kicked off by an AutoSys job. Can I, and how do I, return an int return value to indicate success or failure?
I found the answer :0) ``` DIM returnValue returnValue = 99 WScript.Quit(returnValue) ``` This seems to work well.
187,046
<p>Has anyone seen a tool that will integrate code coverage results with SCM/VCS to attribute untested lines of code to developers? For example, is there a tool that will take NCover's Coverage.Xml, combine it with SVN blame, and produce a report that tells me things like developer who commits most untested code?</p>
[ { "answer_id": 187051, "author": "Rob", "author_id": 7872, "author_profile": "https://Stackoverflow.com/users/7872", "pm_score": 6, "selected": false, "text": "<p>Try:</p>\n\n<pre><code>WScript.Quit n\n</code></pre>\n\n<p>Where n is the ERRORLEVEL you want to return</p>\n" }, { "...
2008/10/09
[ "https://Stackoverflow.com/questions/187046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26479/" ]
Has anyone seen a tool that will integrate code coverage results with SCM/VCS to attribute untested lines of code to developers? For example, is there a tool that will take NCover's Coverage.Xml, combine it with SVN blame, and produce a report that tells me things like developer who commits most untested code?
I found the answer :0) ``` DIM returnValue returnValue = 99 WScript.Quit(returnValue) ``` This seems to work well.
187,057
<p>I want to know how the glBlendFunc works. For example, i have 2 gl textures, where the alpha is on tex1, i want to have alpha in my final image. Where the color is on tex1, i want the color from tex2 to be.</p>
[ { "answer_id": 187309, "author": "Lee Baldwin", "author_id": 5200, "author_profile": "https://Stackoverflow.com/users/5200", "pm_score": 1, "selected": false, "text": "<p>glBlendFunc applies only to how the final color fragment gets blended with the frame buffer. I think what you want i...
2008/10/09
[ "https://Stackoverflow.com/questions/187057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25893/" ]
I want to know how the glBlendFunc works. For example, i have 2 gl textures, where the alpha is on tex1, i want to have alpha in my final image. Where the color is on tex1, i want the color from tex2 to be.
Sadly, this is for openGL ES on the iPhone, so no shaders, but point taken. My problem was a very simplified version of the questions, i needed to apply a simple color ( incl alpha ), to a part of a defined texture. As Lee pointed out, texture blending is to allow alpha to show up on the framebuffer. The solution was t...
187,059
<p>I have a page with a tab control and each control has almost 15 controls. In total there are 10 tabs and about 150 controls in a page (controls like drop down list, textbox, radiobutton, listbox only).</p> <p>My requirement is that there is a button (submit) at the bottom of the page. I need to check using JavaScri...
[ { "answer_id": 187156, "author": "Chris Kimpton", "author_id": 48310, "author_profile": "https://Stackoverflow.com/users/48310", "pm_score": 0, "selected": false, "text": "<p>I would look at something based on the prototype <a href=\"http://www.prototypejs.org/api/form#method-serializeel...
2008/10/09
[ "https://Stackoverflow.com/questions/187059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
I have a page with a tab control and each control has almost 15 controls. In total there are 10 tabs and about 150 controls in a page (controls like drop down list, textbox, radiobutton, listbox only). My requirement is that there is a button (submit) at the bottom of the page. I need to check using JavaScript that at...
Assuming there's only one form on the page (if more then loop through forms and nest the below loop within). ``` var selectedCount = 0; var element; for (var i = 0; i < document.forms[0].elements.length; i++) { element = document.forms[0].elements[i]; switch (element.type) { case 'text': ...
187,069
<p>It seems the ObservableCollection only support add, remove, clear operation from the UI thread, It throw Not Support Exception if it is operated by a NO UI thread. I tried to override methods of ObservableCollection, unfortunatly, I met lots of problems. Any one can provide me a ObservableCollection sample which can...
[ { "answer_id": 187081, "author": "Mark Ingram", "author_id": 986, "author_profile": "https://Stackoverflow.com/users/986", "pm_score": 4, "selected": true, "text": "<p>Using the link provided by <a href=\"https://stackoverflow.com/questions/187069/can-not-operate-observablecollection-in-...
2008/10/09
[ "https://Stackoverflow.com/questions/187069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25749/" ]
It seems the ObservableCollection only support add, remove, clear operation from the UI thread, It throw Not Support Exception if it is operated by a NO UI thread. I tried to override methods of ObservableCollection, unfortunatly, I met lots of problems. Any one can provide me a ObservableCollection sample which can be...
Using the link provided by [Kent](https://stackoverflow.com/questions/187069/can-not-operate-observablecollection-in-multi-threads#187078), you could use the following code to modify a collection across threads: ``` while (!Monitor.TryEnter(_lock, 10)) { DoEvents(); } try { //modify collection } finally { Mo...
187,073
<p>I'm using the sortable function in jquery to sequence a faq list. Needless to say, i'm new to this concept. Anybody have any good examples of the backend for this. I have the front working fine, but updating the sequence in the database is another story. My backend is ColdFusion btw.</p> <p>Thanks in advance</p>...
[ { "answer_id": 187111, "author": "Tomasz Tybulewicz", "author_id": 17405, "author_profile": "https://Stackoverflow.com/users/17405", "pm_score": 5, "selected": true, "text": "<p>Define the faq:</p>\n\n<pre><code>&lt;div id=\"faq\"&gt;\n &lt;div id=\"q1\"&gt;...&lt;/div&gt;\n &lt;div id...
2008/10/09
[ "https://Stackoverflow.com/questions/187073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26121/" ]
I'm using the sortable function in jquery to sequence a faq list. Needless to say, i'm new to this concept. Anybody have any good examples of the backend for this. I have the front working fine, but updating the sequence in the database is another story. My backend is ColdFusion btw. Thanks in advance
Define the faq: ``` <div id="faq"> <div id="q1">...</div> <div id="q2">...</div> (...) <div id="q100">..</div> </div> ``` Make faq sortable: ``` <script type="text/javascript"> $("#faq").sortable(); </script> ``` Form submitted: ``` <form action="..." id="faq_form"> <input type="hidden" name="faqs" i...
187,076
<p>I have a CSV file that holds about 200,000 - 300,000 records. Most of the records can be separated and inserted into a MySQL database with a simple </p> <pre><code>$line = explode("\n", $fileData); </code></pre> <p>and then the values separated with</p> <pre><code>$lineValues = explode(',', $line); </code></pre> ...
[ { "answer_id": 187091, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": -1, "selected": false, "text": "<p>If you could be guaranteed that each new line beginning with a number is a valid new-line (i.e. not in the middle of a t...
2008/10/09
[ "https://Stackoverflow.com/questions/187076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24802/" ]
I have a CSV file that holds about 200,000 - 300,000 records. Most of the records can be separated and inserted into a MySQL database with a simple ``` $line = explode("\n", $fileData); ``` and then the values separated with ``` $lineValues = explode(',', $line); ``` and then inserted into the database using the...
If the csv data is in a file, you can just use fgetcsv() as others have pointed out. fgetcsv handles embedded newlines correctly. However if your csv data is in a string (like $fileData in your example) the following method may be useful as str\_getcsv() only works on a row at a time and cannot split a whole file into...
187,098
<p>I am writing a dhtml application that creates an interactive simulation of a system. The data for the simulation is generated from another tool, and there is already a very large amount of legacy data.</p> <p>Some steps in the simulation require that we play "voice-over" clips of audio. I've been unable to find an...
[ { "answer_id": 187117, "author": "Ilya Kochetov", "author_id": 15329, "author_profile": "https://Stackoverflow.com/users/15329", "pm_score": 3, "selected": false, "text": "<p>I believe that the simplest and most convenient way would be to play the sound using a small Flash clip. I apprec...
2008/10/09
[ "https://Stackoverflow.com/questions/187098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22383/" ]
I am writing a dhtml application that creates an interactive simulation of a system. The data for the simulation is generated from another tool, and there is already a very large amount of legacy data. Some steps in the simulation require that we play "voice-over" clips of audio. I've been unable to find an easy way t...
You will have to include a plug-in like Real Audio or QuickTime to handle the .wav file, but this should work... ``` //====================================================================== var soundEmbed = null; //====================================================================== function soundPlay(which) { ...
187,100
<p>I have an object that needs a test if the object data is valid. The validation itself would be called from the thread that instatiated the object, it looks like this:</p> <pre><code> { if (_step.Equals(string.Empty)) return false; if (_type.Equals(string.Empty)) return false; if (_setup.Equals(string.Empty)) ...
[ { "answer_id": 187110, "author": "Gregor", "author_id": 26153, "author_profile": "https://Stackoverflow.com/users/26153", "pm_score": 1, "selected": false, "text": "<p>I would say as a Property.</p>\n\n<pre><code>if(something.IsValid) { ...\n</code></pre>\n\n<p>looks better then</p>\n\n<...
2008/10/09
[ "https://Stackoverflow.com/questions/187100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22114/" ]
I have an object that needs a test if the object data is valid. The validation itself would be called from the thread that instatiated the object, it looks like this: ``` { if (_step.Equals(string.Empty)) return false; if (_type.Equals(string.Empty)) return false; if (_setup.Equals(string.Empty)) return false; ...
My personal opinion here would be: * If the "validate" method mutates the object in any way (which your example doesn't) then make it a method. * If the object remains un-changed after validation, make it a property.
187,125
<p>Trying to create a user account in a test. But getting a Object reference is not set to an instanve of an object error when running it.</p> <p>Here's my MemberShip provider class, it's in a class library MyCompany.MyApp.Domain.dll:</p> <pre><code>using System; using System.Collections.Generic; using System.Web.Sec...
[ { "answer_id": 187142, "author": "Chris Kimpton", "author_id": 48310, "author_profile": "https://Stackoverflow.com/users/48310", "pm_score": 0, "selected": false, "text": "<p>Is the error directly on provider.CreateUser or somewhere down the stack inside it - perhaps you could check for ...
2008/10/09
[ "https://Stackoverflow.com/questions/187125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2083160/" ]
Trying to create a user account in a test. But getting a Object reference is not set to an instanve of an object error when running it. Here's my MemberShip provider class, it's in a class library MyCompany.MyApp.Domain.dll: ``` using System; using System.Collections.Generic; using System.Web.Security; namespace MyC...
I'm quite sure you should call provider.Initialize(...) in your test code before calling CreateUser.
187,137
<p>This is my query:</p> <pre><code>$query = $this-&gt;db-&gt;query(' SELECT archives.id, archives.signature, type_of_source.description, media_type.description, origin.description FROM archives, type_of_source, media_type, origin WHERE archives...
[ { "answer_id": 187175, "author": "pilsetnieks", "author_id": 6615, "author_profile": "https://Stackoverflow.com/users/6615", "pm_score": 4, "selected": true, "text": "<p>This actually has very little to do with CodeIgniter and a lot with how mysql_fetch_assoc provides the query results.<...
2008/10/09
[ "https://Stackoverflow.com/questions/187137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4196/" ]
This is my query: ``` $query = $this->db->query(' SELECT archives.id, archives.signature, type_of_source.description, media_type.description, origin.description FROM archives, type_of_source, media_type, origin WHERE archives.type_of_source_id =...
This actually has very little to do with CodeIgniter and a lot with how mysql\_fetch\_assoc provides the query results. The solution is that you should rename the columns inside the query using `"AS"`, e.g. ``` select type_of_source.description as type_of_source_description, origin.descripotion as origin_descripotion...
187,138
<p>How would you store formatted blocks of text (line breaks, tabs, lists - etc.) in a database (nothing specific) to be displayed on the web (XHTML) while maintaining a level of abstraction so that the data can be used in other applications or if the structure of the website were to change in the future?</p>
[ { "answer_id": 187175, "author": "pilsetnieks", "author_id": 6615, "author_profile": "https://Stackoverflow.com/users/6615", "pm_score": 4, "selected": true, "text": "<p>This actually has very little to do with CodeIgniter and a lot with how mysql_fetch_assoc provides the query results.<...
2008/10/09
[ "https://Stackoverflow.com/questions/187138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23746/" ]
How would you store formatted blocks of text (line breaks, tabs, lists - etc.) in a database (nothing specific) to be displayed on the web (XHTML) while maintaining a level of abstraction so that the data can be used in other applications or if the structure of the website were to change in the future?
This actually has very little to do with CodeIgniter and a lot with how mysql\_fetch\_assoc provides the query results. The solution is that you should rename the columns inside the query using `"AS"`, e.g. ``` select type_of_source.description as type_of_source_description, origin.descripotion as origin_descripotion...
187,146
<p>Why is the order of tables important when combining an outer &amp; an inner join ? the following fails with postgres:</p> <pre><code>SELECT grp.number AS number, tags.value AS tag FROM groups grp, insrel archiverel LEFT OUTER JOIN ownrel ownrel ON grp.number = ownrel.dnumber LEFT OUTER JOIN...
[ { "answer_id": 187164, "author": "RB.", "author_id": 15393, "author_profile": "https://Stackoverflow.com/users/15393", "pm_score": 3, "selected": false, "text": "<p>Because in the first one grp is not part of the join the ON clause belongs to.</p>\n" }, { "answer_id": 187184, ...
2008/10/09
[ "https://Stackoverflow.com/questions/187146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26486/" ]
Why is the order of tables important when combining an outer & an inner join ? the following fails with postgres: ``` SELECT grp.number AS number, tags.value AS tag FROM groups grp, insrel archiverel LEFT OUTER JOIN ownrel ownrel ON grp.number = ownrel.dnumber LEFT OUTER JOIN tags tags ON tags...
I believe that you can think of this as an operator precedence issue. When you write this: ``` FROM groups grp, insrel archiverel LEFT OUTER JOIN ownrel ownrel ON grp.number = ownrel.dnumber LEFT OUTER JOIN tags tags ON tags.number = ownrel.snumber ``` I think it is interpreted by the parser like this:...
187,188
<p>We are hosting a site for a client and they want us to include the header they have on their server into the pages we are hosting. So whenever they change it, it will automatically change on our site.</p> <p>We are attempting to use the "include" tag in our JSP code. The code we are using is as follows:</p> <p><...
[ { "answer_id": 187201, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 1, "selected": false, "text": "<p>JSP includes don't support including remote files, which is why a relative URL is required: <a href=\"http://java...
2008/10/09
[ "https://Stackoverflow.com/questions/187188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26488/" ]
We are hosting a site for a client and they want us to include the header they have on their server into the pages we are hosting. So whenever they change it, it will automatically change on our site. We are attempting to use the "include" tag in our JSP code. The code we are using is as follows: `<%@ include file="w...
If you choose to do this in Java, it's nice and easy using the HttpClient from Apache Commons. ``` public static String fetchSourceHtml( String urlString ) { try { HttpClient httpClient = new HttpClient(); GetMethod getMethod = new GetMethod( urlString ); getMethod.setFollowRedirects( true ); int h...
187,189
<p>Assume the following code:</p> <pre><code>using (SqlConnection conn = new SqlConnection(connectionString)) { ... using (SqlCommand comm = new SqlCommand(...)) { .. do stuff .. if(condition) Response.Redirect("somepage.aspx"); } } </code></pre> <p>Will the Response.Redirect() exit from the ...
[ { "answer_id": 187193, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 2, "selected": false, "text": "<p>Q: Or, alternatively, is there any way to exit a using block that won't cause disposal?</p>\n\n<p>A: None.</p>\n\n<p>See th...
2008/10/09
[ "https://Stackoverflow.com/questions/187189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18907/" ]
Assume the following code: ``` using (SqlConnection conn = new SqlConnection(connectionString)) { ... using (SqlCommand comm = new SqlCommand(...)) { .. do stuff .. if(condition) Response.Redirect("somepage.aspx"); } } ``` Will the Response.Redirect() exit from the using blocks cause it to d...
From <http://msdn.microsoft.com/en-us/library/aa973248.aspx> > > Calling Response.Redirect WILL NOT > execute the finally block. Therefore, > before any redirection or transfer of > processing can occur, you must dispose > of the objects. > > > Yes, it does not directly address the Using statement, but it is ...
187,198
<p>I was thinking earlier today about an idea for a small game and stumbled upon how to implement it. The idea is that the player can make a series of moves that cause a little effect, but if done in a specific sequence would cause a greater effect. So far so good, this I know how to do. Obviously, I had to make it be ...
[ { "answer_id": 187240, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 1, "selected": false, "text": "<p>What you're describing sounds very similar to the technology tree in a game live Civilization.</p>\n\n<p>I don't know how ...
2008/10/09
[ "https://Stackoverflow.com/questions/187198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5954/" ]
I was thinking earlier today about an idea for a small game and stumbled upon how to implement it. The idea is that the player can make a series of moves that cause a little effect, but if done in a specific sequence would cause a greater effect. So far so good, this I know how to do. Obviously, I had to make it be mor...
I'm not absolutely completely sure that I understand exactly what you're saying, but as an analagous situation, say someone's inputting an endless stream of numbers on the keyboard. '117' is a magic sequence, '468' is another one, '411799' is another (which contains the first one). So if the user enters: > > 554684...
187,216
<p>What is the best way for converting phone numbers into international format (E.164) using Java?</p> <p>Given a 'phone number' and a country id (let's say an ISO country code), I would like to convert it into a standard E.164 international format phone number.</p> <p>I am sure I can do it by hand quite easily - but...
[ { "answer_id": 190179, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 3, "selected": false, "text": "<p>Speaking from experience at writing this kind of thing, it's really difficult to do with 100% reliability. I've written...
2008/10/09
[ "https://Stackoverflow.com/questions/187216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15452/" ]
What is the best way for converting phone numbers into international format (E.164) using Java? Given a 'phone number' and a country id (let's say an ISO country code), I would like to convert it into a standard E.164 international format phone number. I am sure I can do it by hand quite easily - but I would not be s...
Google provides a library for working with phone numbers. The same one they use for Android <http://code.google.com/p/libphonenumber/> ``` String swissNumberStr = "044 668 18 00" PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); try { PhoneNumber swissNumberProto = phoneUtil.parse(swissNumberStr, "CH"); } ...
187,219
<p>I'm using ccl/openmcl on Mac OS X. (latest versions of both). When the lisp prompt is displayed, using the cursor keys to navigate the current line results in escape codes, rather than movement, eg:</p> <p><code>Welcome to Clozure Common Lisp Version 1.2-r9226-RC1 (DarwinX8664)!<br> ? (^[[D</code></p> <p>Here I'v...
[ { "answer_id": 187393, "author": "Matthias Benkard", "author_id": 15517, "author_profile": "https://Stackoverflow.com/users/15517", "pm_score": 3, "selected": true, "text": "<p>If Clozure CL doesn't provide native readline/editline/whatever support or is configured not to use it, you can...
2008/10/09
[ "https://Stackoverflow.com/questions/187219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10019/" ]
I'm using ccl/openmcl on Mac OS X. (latest versions of both). When the lisp prompt is displayed, using the cursor keys to navigate the current line results in escape codes, rather than movement, eg: `Welcome to Clozure Common Lisp Version 1.2-r9226-RC1 (DarwinX8664)! ? (^[[D` Here I've pressed the `(` key, and the...
If Clozure CL doesn't provide native readline/editline/whatever support or is configured not to use it, you can run it with rlwrap, for example: ``` rlwrap openmcl ``` rlwrap can be obtained via [MacPorts](http://www.macports.org/) or directly from <http://utopia.knoware.nl/~hlub/rlwrap/>.
187,229
<p>Why does this work:</p> <pre><code>$(window).keydown(function(event){ alert(event.keyCode); }); </code></pre> <p>but not this:</p> <pre><code>$('#ajaxSearchText').keydown(function(event){ alert(event.keyCode); }); </code></pre> <p>I'm testing with Firefox 3. Interestingly, neither of them work in IE7.</p...
[ { "answer_id": 187262, "author": "Mote", "author_id": 24789, "author_profile": "https://Stackoverflow.com/users/24789", "pm_score": 1, "selected": false, "text": "<p>Try using</p>\n\n<pre><code>$('#ajaxSearchText').keyup(function(event){\n alert(event.keyCode);\n});\n</code></pre>\n\n...
2008/10/09
[ "https://Stackoverflow.com/questions/187229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
Why does this work: ``` $(window).keydown(function(event){ alert(event.keyCode); }); ``` but not this: ``` $('#ajaxSearchText').keydown(function(event){ alert(event.keyCode); }); ``` I'm testing with Firefox 3. Interestingly, neither of them work in IE7.
Checked this in Chrome, IE7 and Firefox 3.0.3. Works as it should. jQuery version 1.2.6. ``` <html> <head> <script type="text/javascript" src="jquery-1.2.6.js"></script> <script type="text/javascript"> $(function() { $("#ajaxSearchText").keydown(function(event) { al...
187,231
<p>I'm having trouble selecting elements that are part of an specific namespace. My xpath expression works in XMLSpy but fails when using the Xalan libraries..</p> <pre><code>&lt;item&gt; &lt;media:content attrb="xyz"&gt; &lt;dcterms:valid&gt;VALUE&lt;/dcterms:valid&gt; &lt;/media:content&gt; &lt;/item&gt; ...
[ { "answer_id": 187339, "author": "Ray Lu", "author_id": 11413, "author_profile": "https://Stackoverflow.com/users/11413", "pm_score": 0, "selected": false, "text": "<p>Have you tried to define the namespace of the XML blob?</p>\n\n<pre><code>&lt;item xmlns:dcterms=\"http://dcterms.exampl...
2008/10/09
[ "https://Stackoverflow.com/questions/187231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10913/" ]
I'm having trouble selecting elements that are part of an specific namespace. My xpath expression works in XMLSpy but fails when using the Xalan libraries.. ``` <item> <media:content attrb="xyz"> <dcterms:valid>VALUE</dcterms:valid> </media:content> </item> ``` My expression is `./item/media:content/dcterm...
You'll need to implement a [`org.apache.xml.utils.PrefixResolver`](http://xml.apache.org/xalan-j/apidocs/org/apache/xml/utils/PrefixResolver.html) to map the prefix to namespace URI, and then pass an instance to the `XPath` instance you use. This will allow you to use different prefixes in your XPath expressions from t...
187,237
<p>I have a .NET string which is Base64 encoded representation of an array of encrypted bytes. It is produced like this:</p> <pre><code>String Encrypt( String message ) { CryptoStream cryptostream = ... StreamWriter stream = new StreamWriter( cryptostream ); ... return Convert.ToBase64String( ... ); }...
[ { "answer_id": 187575, "author": "Jérôme Laban", "author_id": 26346, "author_profile": "https://Stackoverflow.com/users/26346", "pm_score": 0, "selected": false, "text": "<p>There is no public built-in way to stream from a string, as of .NET 3.5.</p>\n\n<p>You can implement a simple Stri...
2008/10/09
[ "https://Stackoverflow.com/questions/187237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13372/" ]
I have a .NET string which is Base64 encoded representation of an array of encrypted bytes. It is produced like this: ``` String Encrypt( String message ) { CryptoStream cryptostream = ... StreamWriter stream = new StreamWriter( cryptostream ); ... return Convert.ToBase64String( ... ); } ``` Now I wa...
I always the the [Convert](http://msdn.microsoft.com/en-us/library/system.convert.frombase64string.aspx) class to convert the string into an array of Byte. An example: ``` public static string DeCryptString(string s) { byte[] b = System.Convert.FromBase64String(s); using (MemoryStream ms = new Me...
187,245
<p>Where I work, we maintain an FTP site that needs occasional cleanup.</p> <p>Are there any tools out there to create a site map of an FTP site? It would greatly simplify clean up tasks.</p> <p>Thanks!</p>
[ { "answer_id": 187575, "author": "Jérôme Laban", "author_id": 26346, "author_profile": "https://Stackoverflow.com/users/26346", "pm_score": 0, "selected": false, "text": "<p>There is no public built-in way to stream from a string, as of .NET 3.5.</p>\n\n<p>You can implement a simple Stri...
2008/10/09
[ "https://Stackoverflow.com/questions/187245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1145/" ]
Where I work, we maintain an FTP site that needs occasional cleanup. Are there any tools out there to create a site map of an FTP site? It would greatly simplify clean up tasks. Thanks!
I always the the [Convert](http://msdn.microsoft.com/en-us/library/system.convert.frombase64string.aspx) class to convert the string into an array of Byte. An example: ``` public static string DeCryptString(string s) { byte[] b = System.Convert.FromBase64String(s); using (MemoryStream ms = new Me...
187,255
<p>I'm trying to make a select that calculates affiliate payouts.</p> <p>my approach is pretty simple.</p> <pre><code>SELECT month(payments.timestmap) ,sum(if(payments.amount&gt;=29.95,4,0)) As Tier4 ,sum(if(payments.amount&gt;=24.95&lt;=29.94,3,0)) As Tier3 ,sum(if(payments.amount&gt;=19.95&lt;=24.94,2,0)) As Tier2...
[ { "answer_id": 187270, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 4, "selected": true, "text": "<p>The second part of the expression evaluates when you use <code>AND</code> - </p>\n\n<pre><code>SELECT\n month(payments.tim...
2008/10/09
[ "https://Stackoverflow.com/questions/187255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
I'm trying to make a select that calculates affiliate payouts. my approach is pretty simple. ``` SELECT month(payments.timestmap) ,sum(if(payments.amount>=29.95,4,0)) As Tier4 ,sum(if(payments.amount>=24.95<=29.94,3,0)) As Tier3 ,sum(if(payments.amount>=19.95<=24.94,2,0)) As Tier2 FROM payments GROUP BY month(paymen...
The second part of the expression evaluates when you use `AND` - ``` SELECT month(payments.timestmap) ,sum(if(payments.amount>=29.95,4,0)) As Tier4 ,sum(if(payments.amount>=24.95 AND payments.amount<=29.94,3,0)) As Tier3 ,sum(if(payments.amount>=19.95 AND payments.amount<=24.94,2,0)) As Tier2 FROM payments GROUP BY ...
187,273
<p>Building on <a href="https://stackoverflow.com/questions/1476/how-do-you-express-binary-literals-in-python#13107">How Do You Express Binary Literals in Python</a>, I was thinking about sensible, intuitive ways to do that Programming 101 chestnut of displaying integers in base-2 form. This is the best I came up with...
[ { "answer_id": 187536, "author": "Brian", "author_id": 9493, "author_profile": "https://Stackoverflow.com/users/9493", "pm_score": 5, "selected": true, "text": "<p>For best efficiency, you generally want to process more than a single bit at a time.\nYou can use a simple method to get a f...
2008/10/09
[ "https://Stackoverflow.com/questions/187273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15842/" ]
Building on [How Do You Express Binary Literals in Python](https://stackoverflow.com/questions/1476/how-do-you-express-binary-literals-in-python#13107), I was thinking about sensible, intuitive ways to do that Programming 101 chestnut of displaying integers in base-2 form. This is the best I came up with, but I'd like ...
For best efficiency, you generally want to process more than a single bit at a time. You can use a simple method to get a fixed width binary representation. eg. ``` def _bin(x, width): return ''.join(str((x>>i)&1) for i in xrange(width-1,-1,-1)) ``` \_bin(x, 8) will now give a zero padded representation of x's l...
187,279
<p>I want to create a simple box with a header bar containing a title and some tool buttons. I have the following markup:</p> <pre><code>&lt;div style="float:left"&gt; &lt;div style="background-color:blue; padding: 1px; height: 20px;"&gt; &lt;div style="float: left; background-color:green;"&gt;title&lt;/di...
[ { "answer_id": 187311, "author": "Mote", "author_id": 24789, "author_profile": "https://Stackoverflow.com/users/24789", "pm_score": -1, "selected": false, "text": "<p>Make this <code>&lt;div style=\"background-color:blue; padding: 1px; height: 20px;&gt;</code> the parent of the 2 floatin...
2008/10/09
[ "https://Stackoverflow.com/questions/187279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26496/" ]
I want to create a simple box with a header bar containing a title and some tool buttons. I have the following markup: ``` <div style="float:left"> <div style="background-color:blue; padding: 1px; height: 20px;"> <div style="float: left; background-color:green;">title</div> <div style="float: right...
Specify width in outermost div. If that width in your content div means this is the total width of your box, simply add it to the outermost div, and (optionally) remove it from content, like this: ``` <div style="float:left; width: 200px;"> <div style="background-color:blue; padding: 1px; height: 20px;"> ...
187,284
<p>I have log4net running on my AsP.NET site. I'm able to log messages to my DB Table, but it isn't logging the ThreadContext properties. For example:</p> <pre><code>ThreadContext.Properties["Url"] = HttpContext.Current.Request.Url.ToString(); ThreadContext.Properties["HttpReferer"] = HttpContext.Current.Request.Serve...
[ { "answer_id": 187437, "author": "Chris Kimpton", "author_id": 48310, "author_profile": "https://Stackoverflow.com/users/48310", "pm_score": 0, "selected": false, "text": "<p>Can you turn on log4net verbose/debug/show sql to see what its doing at that level? Is there perhaps another bit...
2008/10/09
[ "https://Stackoverflow.com/questions/187284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1204/" ]
I have log4net running on my AsP.NET site. I'm able to log messages to my DB Table, but it isn't logging the ThreadContext properties. For example: ``` ThreadContext.Properties["Url"] = HttpContext.Current.Request.Url.ToString(); ThreadContext.Properties["HttpReferer"] = HttpContext.Current.Request.ServerVariables["HT...
So, it turns out the config was to blame. It was slightly wrong: Original: ``` <conversionPattern value="%property{log4net:HttpReferer}"/> ``` Changed: ``` <conversionPattern value="%property{HttpReferer}"/> ``` I had to take out the "log4net:" inside of property. What's odd is that one property still required...
187,287
<p>I am using link to sql, I have a connected set of objects.</p> <p>I start out and do a linq statement like this</p> <pre><code>Dim L= from II in context.InventoryItems select II Dim L2 = L.tolist </code></pre> <p>The second line was so that I could narrow down where the problem was occuring. When the second line ...
[ { "answer_id": 227888, "author": "Matt V", "author_id": 30456, "author_profile": "https://Stackoverflow.com/users/30456", "pm_score": 1, "selected": false, "text": "<p>Omer's comment brings up a very good point: is this DataContext being re-used from a previous operation? If so, you may...
2008/10/09
[ "https://Stackoverflow.com/questions/187287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2496/" ]
I am using link to sql, I have a connected set of objects. I start out and do a linq statement like this ``` Dim L= from II in context.InventoryItems select II Dim L2 = L.tolist ``` The second line was so that I could narrow down where the problem was occuring. When the second line is hit I get an error "The Entity...
For anyone interested, be careful what you do in the constructor, I was initializing some stuff in the constructor that I shouldn't have been and it caused an error on loading from the datacontext.
187,305
<p>I am using a FormView to update an existing SQL Server record. The rows from the sqldatasource display fine in the FormView and I can edit them. When I click Update, I get the ItemUpdating event but not the ItemUpdated event and the revisions are not written to the database. </p> <p>Can anyone help me in this ple...
[ { "answer_id": 187320, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 0, "selected": false, "text": "<p>If you take out the ItemUpdating event and the ItemUpdated event, does your SQL statement execute without errors?</p>\n\n<p>I...
2008/10/09
[ "https://Stackoverflow.com/questions/187305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14752/" ]
I am using a FormView to update an existing SQL Server record. The rows from the sqldatasource display fine in the FormView and I can edit them. When I click Update, I get the ItemUpdating event but not the ItemUpdated event and the revisions are not written to the database. Can anyone help me in this please.
In your ItemUpdating event handler, make sure of the following things: -If you are not using optimistic concurrency checking, remove any old values the FormView may be placing in the OldValues collection. -Make sure that all of the parameters required by your stored procedure, query, or data source have values and ar...
187,319
<p>I could use some help writing a regular expression. In my Django application, users can hit the following URL:</p> <pre><code>http://www.example.com/A1/B2/C3 </code></pre> <p>I'd like to create a regular expression that allows accepts any of the following as a valid URL:</p> <pre><code>http://www.example.com/A1 ...
[ { "answer_id": 187392, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 1, "selected": false, "text": "<pre><code>http://www\\.example\\.com/A1(/B2(/C3)?)?\n</code></pre>\n" }, { "answer_id": 187395, "author"...
2008/10/09
[ "https://Stackoverflow.com/questions/187319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10040/" ]
I could use some help writing a regular expression. In my Django application, users can hit the following URL: ``` http://www.example.com/A1/B2/C3 ``` I'd like to create a regular expression that allows accepts any of the following as a valid URL: ``` http://www.example.com/A1 http://www.example.com/A1/B2 http:...
Skip the `|`, use the `?` and `()` `http://www\.example\.com/A1(/B2(/C3)?)?` And if you replace the A1-C3 with a pattern: `http://www\.example\.com/[^/]*(/[^/]*(/[^/]*)?)?` Explanation: * it matches every string that starts with `http://www.example.com/A1` * it can match an additional `/B2` and even an additional ...
187,326
<p>Is exposing CRUD operations through SOAP web services a bad idea? My instinct tells me that it is not least of which because the overhead of doing database calls overhead could be huge. I'm struggling to find documentation for/against this (anti)pattern so I was wondering if anyone could point me to some documentati...
[ { "answer_id": 187424, "author": "Ilya Kochetov", "author_id": 15329, "author_profile": "https://Stackoverflow.com/users/15329", "pm_score": 0, "selected": false, "text": "<p>There is nothing wrong with exposing the CRUD operations via SOAP web-services per se.</p>\n\n<p>You will obvious...
2008/10/09
[ "https://Stackoverflow.com/questions/187326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9539/" ]
Is exposing CRUD operations through SOAP web services a bad idea? My instinct tells me that it is not least of which because the overhead of doing database calls overhead could be huge. I'm struggling to find documentation for/against this (anti)pattern so I was wondering if anyone could point me to some documentation ...
I think publishing a SOAP service that exposes CRUD operations to anonymous, public "users" would be a particularly bad idea. If, however, you can restrict one or both of these caveats, then I see nothing wrong with it (moreover I've implemented such services many times). * You can require, in addition to whatever met...
187,357
<p>Consider this:</p> <pre><code>var query = from r in this._db.Recipes where r.RecipesID == recipeID select new { r.RecipesID, r.RecipesName }; </code></pre> <p>How would i get individual columns in my <code>query</code> object without using a for-loop?</p> <p>Basicly: how do I translate <co...
[ { "answer_id": 187401, "author": "Chris Shaffer", "author_id": 6744, "author_profile": "https://Stackoverflow.com/users/6744", "pm_score": 0, "selected": false, "text": "<p>Sorry, misunderstood your question. As others are saying, you can use ToList() to get a List back. An alternative...
2008/10/09
[ "https://Stackoverflow.com/questions/187357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20946/" ]
Consider this: ``` var query = from r in this._db.Recipes where r.RecipesID == recipeID select new { r.RecipesID, r.RecipesName }; ``` How would i get individual columns in my `query` object without using a for-loop? Basicly: how do I translate `DataTable.Rows[0]["ColumnName"]` into Linq syn...
This is the way to go about it: ``` DataContext dc = new DataContext(); var recipe = (from r in dc.Recipes where r.RecipesID == 1 select r).FirstOrDefault(); if (recipe != null) { id = recipe.RecipesID; name = recipe.RecipesName; } ```
187,359
<p>We use Visual Studio 2008 and Surround SCM for source control. SCM drops files into each directory named ".MySCMServerInfo" which are user specific data files that shouldn't be checked into source control. They are similar to the .scc files dropped by Visual Source Safe. We also have several WAPs (Web Application ...
[ { "answer_id": 193133, "author": "Craig Quillen", "author_id": 18456, "author_profile": "https://Stackoverflow.com/users/18456", "pm_score": 0, "selected": false, "text": "<p>Using the file system hidden bit should work.</p>\n" }, { "answer_id": 296353, "author": "Charles", ...
2008/10/09
[ "https://Stackoverflow.com/questions/187359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24898/" ]
We use Visual Studio 2008 and Surround SCM for source control. SCM drops files into each directory named ".MySCMServerInfo" which are user specific data files that shouldn't be checked into source control. They are similar to the .scc files dropped by Visual Source Safe. We also have several WAPs (Web Application Proje...
I have new information about this issue. Setting the hidden bit on .MySCMServerInfo file causes Surround SCM to loose track of the modification state for files. It starts thinking files are out-of-date when they are not, and it always attemps to get new versions. Instead, set this registry key if you're using Visual S...
187,380
<p>Ruby is becoming <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html" rel="noreferrer">popular</a>, largely from the influence Ruby on Rails, but it feels like it is currently struggling through its adolescence. There are a lot of similarities between Ruby and Smalltalk -- <a href="http://ruby....
[ { "answer_id": 187400, "author": "coder1", "author_id": 3018, "author_profile": "https://Stackoverflow.com/users/3018", "pm_score": 3, "selected": false, "text": "<p>Ruby is the current buzz language. It's easier to market software built with it right now than a language developed in th...
2008/10/09
[ "https://Stackoverflow.com/questions/187380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23899/" ]
Ruby is becoming [popular](http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html), largely from the influence Ruby on Rails, but it feels like it is currently struggling through its adolescence. There are a lot of similarities between Ruby and Smalltalk -- [maglev](http://ruby.gemstone.com/) is a testament t...
I'm more of a Pythonista than a Ruby user, however the same things hold for Ruby for much the same reasons. * The architecture of Smalltalk is somewhat insular whereas Python and Ruby were built from the ground up to facilitate integration. Smalltalk never really gained a body of hybrid application support in the way ...
187,406
<pre><code>private string? typeOfContract { get { return (string?)ViewState["typeOfContract"]; } set { ViewState["typeOfContract"] = value; } } </code></pre> <p>Later in the code I use it like this:</p> <pre><code>typeOfContract = Request.QueryString["type"]; </code></pre> <p>I am getting the following error at ...
[ { "answer_id": 187416, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 9, "selected": true, "text": "<p>System.String is a reference type and already \"nullable\".</p>\n\n<p>Nullable&lt;T> and the ? suffix are for value types su...
2008/10/09
[ "https://Stackoverflow.com/questions/187406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4144/" ]
``` private string? typeOfContract { get { return (string?)ViewState["typeOfContract"]; } set { ViewState["typeOfContract"] = value; } } ``` Later in the code I use it like this: ``` typeOfContract = Request.QueryString["type"]; ``` I am getting the following error at the declaration of `typeOfContract` line s...
System.String is a reference type and already "nullable". Nullable<T> and the ? suffix are for value types such as Int32, Double, DateTime, etc.
187,414
<p>I don't really <em>get</em> lambda expressions. While they've been around since the days of ALGOL, I didn't start hearing about them until fairly recently, when Python and Ruby became very popular. Now that C# has the <code>=&gt;</code> syntax, people in my world (.NET) are talking about lamdba expressions more and...
[ { "answer_id": 187423, "author": "Chris Young", "author_id": 9417, "author_profile": "https://Stackoverflow.com/users/9417", "pm_score": 2, "selected": false, "text": "<p>The answers to <a href=\"https://stackoverflow.com/questions/150129/what-is-a-lambda\">this question</a> might be use...
2008/10/09
[ "https://Stackoverflow.com/questions/187414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7565/" ]
I don't really *get* lambda expressions. While they've been around since the days of ALGOL, I didn't start hearing about them until fairly recently, when Python and Ruby became very popular. Now that C# has the `=>` syntax, people in my world (.NET) are talking about lamdba expressions more and more. I've read the Wik...
Basically as far as C# is concerned, lambda expressions are an easy way to create a delegate (or an expression tree, but let's leave those aside for now). In C# 1 we could only create delegate instances from normal methods. In C# 2 we gained anonymous methods. In C# 3 we gained lambda expressions, which are like more ...
187,438
<p>I have currently an installed pgsql instance that is running on port <code>1486</code>. I want to change this port to <code>5433</code>, how should I proceed for this?</p>
[ { "answer_id": 187457, "author": "Neall", "author_id": 619, "author_profile": "https://Stackoverflow.com/users/619", "pm_score": 9, "selected": true, "text": "<p>There should be a line in your <code>postgresql.conf</code> file that says:</p>\n\n<pre><code>port = 1486\n</code></pre>\n\n<p...
2008/10/09
[ "https://Stackoverflow.com/questions/187438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22554/" ]
I have currently an installed pgsql instance that is running on port `1486`. I want to change this port to `5433`, how should I proceed for this?
There should be a line in your `postgresql.conf` file that says: ``` port = 1486 ``` Change that. The location of the file can vary depending on your install options. On Debian-based distros it is `/etc/postgresql/8.3/main/` On Windows it is `C:\Program Files\PostgreSQL\9.3\data` Don't forget to `sudo service pos...
187,448
<p>Using OpenXML SDK, I want to insert basic HTML snippets into a Word document.</p> <p>How would you do this:</p> <ul> <li>Manipulating XML directly ?</li> <li>Using an XSLT ?</li> <li>using AltChunk ?</li> </ul> <p>Moreover, C# or VB examples are more than welcome :)</p>
[ { "answer_id": 196887, "author": "Gaspar Nagy", "author_id": 26530, "author_profile": "https://Stackoverflow.com/users/26530", "pm_score": 2, "selected": false, "text": "<p>I'm not sure, what you actually would like to achieve. The OpenXML documents have an own html-like (WordprocessingM...
2008/10/09
[ "https://Stackoverflow.com/questions/187448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22970/" ]
Using OpenXML SDK, I want to insert basic HTML snippets into a Word document. How would you do this: * Manipulating XML directly ? * Using an XSLT ? * using AltChunk ? Moreover, C# or VB examples are more than welcome :)
Well, hard to give general advice, because it depends strongly on your input what is best. Here's a simple example inserting a paragraph into a DOCX document for each paragraph in an (X)HTML document using OpenXML SDK v2.0 and an XPathDocument: ``` void ConvertHTML(string htmlFileName, string docFileName) { ...
187,454
<p>I have the following problem using subversion:</p> <p>I'm currently working on the trunk of my project and plan to do some refactoring (which includes renaming files or moving files to different directories).</p> <p>At the same time someone else is working on the same project on a branch.</p> <p>At some time I wa...
[ { "answer_id": 187472, "author": "mspmsp", "author_id": 21724, "author_profile": "https://Stackoverflow.com/users/21724", "pm_score": 1, "selected": false, "text": "<p>It's likely that you'll have to rename them in the branch. Can you merge the revision that renamed them from the trunk ...
2008/10/09
[ "https://Stackoverflow.com/questions/187454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4497/" ]
I have the following problem using subversion: I'm currently working on the trunk of my project and plan to do some refactoring (which includes renaming files or moving files to different directories). At the same time someone else is working on the same project on a branch. At some time I want to merge the changes ...
I think this is an existing subversion [bug](http://subversion.tigris.org/issues/show_bug.cgi?id=898) - but don't hold your breath, its been open since 2002.
187,455
<p>How can I count the number of elements in an array, because contrary to logic array.count(string) does not count all the elements in the array, it just searches for the number of occurrences of string.</p>
[ { "answer_id": 187463, "author": "Trent", "author_id": 9083, "author_profile": "https://Stackoverflow.com/users/9083", "pm_score": 9, "selected": true, "text": "<p>The method len() returns the number of elements in the list.</p>\n\n<p>Syntax:</p>\n\n<pre><code>len(myArray)\n</code></pre>...
2008/10/09
[ "https://Stackoverflow.com/questions/187455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
How can I count the number of elements in an array, because contrary to logic array.count(string) does not count all the elements in the array, it just searches for the number of occurrences of string.
The method len() returns the number of elements in the list. Syntax: ``` len(myArray) ``` Eg: ``` myArray = [1, 2, 3] len(myArray) ``` Output: ``` 3 ```
187,482
<p>I'd like to use the newer <code>&lt;button&gt;</code> tag in an ASP.NET website which, among other things, allows CSS-styled text and embedding a graphic inside the button. The asp:Button control renders as <code>&lt;input type="button"&gt;</code>, is there any way to make a preexisting control render to <code>&lt;b...
[ { "answer_id": 187527, "author": "Tsvetomir Tsonev", "author_id": 25449, "author_profile": "https://Stackoverflow.com/users/25449", "pm_score": 2, "selected": false, "text": "<p>I would go with a LinkButton and style it with CSS as appropriate.</p>\n" }, { "answer_id": 187566, ...
2008/10/09
[ "https://Stackoverflow.com/questions/187482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249/" ]
I'd like to use the newer `<button>` tag in an ASP.NET website which, among other things, allows CSS-styled text and embedding a graphic inside the button. The asp:Button control renders as `<input type="button">`, is there any way to make a preexisting control render to `<button>`? From what I've read there is an inc...
This is an old question, but for those of us unlucky enough still having to maintain ASP.NET Web Forms applications, I went through this myself while trying to include Bootstrap glyphs inside of built-in button controls. As per Bootstrap documentation, the desired markup is as follows: ```html <button class="btn btn-...
187,495
<p>In my program, how can I read the properties set in AssemblyInfo.cs:</p> <pre><code>[assembly: AssemblyTitle("My Product")] [assembly: AssemblyDescription("...")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Radeldudel inc.")] [assembly: AssemblyProduct("My Product")] [assembly: AssemblyCopyrig...
[ { "answer_id": 187529, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 7, "selected": true, "text": "<p>This is reasonably easy. You have to use reflection. You need an instance of Assembly that represents the assembly wi...
2008/10/09
[ "https://Stackoverflow.com/questions/187495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
In my program, how can I read the properties set in AssemblyInfo.cs: ``` [assembly: AssemblyTitle("My Product")] [assembly: AssemblyDescription("...")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Radeldudel inc.")] [assembly: AssemblyProduct("My Product")] [assembly: AssemblyCopyright("Copyright ...
This is reasonably easy. You have to use reflection. You need an instance of Assembly that represents the assembly with the attributes you want to read. An easy way of getting this is to do: ``` typeof(MyTypeInAssembly).Assembly ``` Then you can do this, for example: ``` object[] attributes = assembly.GetCustomAttr...
187,505
<p>I have few different applications among which I'd like to share a C# enum. I can't quite figure out how to share an enum declaration between a regular application and a WCF service. </p> <p>Here's the situation. I have 2 lightweight C# destop apps and a WCF webservice that all need to share enum values. </p> <p>Cl...
[ { "answer_id": 187845, "author": "Szymon Rozga", "author_id": 7583, "author_profile": "https://Stackoverflow.com/users/7583", "pm_score": 7, "selected": true, "text": "<p>Using the Common library should be fine. Enumerations are serializable and the DataContract attributes are not needed...
2008/10/09
[ "https://Stackoverflow.com/questions/187505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5208/" ]
I have few different applications among which I'd like to share a C# enum. I can't quite figure out how to share an enum declaration between a regular application and a WCF service. Here's the situation. I have 2 lightweight C# destop apps and a WCF webservice that all need to share enum values. Client 1 has ``` ...
Using the Common library should be fine. Enumerations are serializable and the DataContract attributes are not needed. See: <http://msdn.microsoft.com/en-us/library/ms731923.aspx> > > Enumeration types. Enumerations, including flag enumerations, are > serializable. Optionally, enumeration types can be marked with ...
187,506
<p>I'm involved with updating an Access solution. It has a good amount of VBA, a number of queries, a small amount of tables, and a few forms for data entry &amp; report generation. It's an ideal candidate for Access.</p> <p>I want to make changes to the table design, the VBA, the queries, and the forms. How can I ...
[ { "answer_id": 187547, "author": "Patrick Cuff", "author_id": 7903, "author_profile": "https://Stackoverflow.com/users/7903", "pm_score": 1, "selected": false, "text": "<p>I found this tool on SourceForge: <a href=\"http://sourceforge.net/projects/avc/\" rel=\"nofollow noreferrer\">http:...
2008/10/09
[ "https://Stackoverflow.com/questions/187506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1753/" ]
I'm involved with updating an Access solution. It has a good amount of VBA, a number of queries, a small amount of tables, and a few forms for data entry & report generation. It's an ideal candidate for Access. I want to make changes to the table design, the VBA, the queries, and the forms. How can I track my changes ...
We wrote our own script in VBScript, that uses the undocumented Application.SaveAsText() in Access to export all code, form, macro and report modules. Here it is, it should give you some pointers. (Beware: some of the messages are in german, but you can easily change that.) EDIT: To summarize various comments below: ~...
187,515
<p>I have two arrays. One contains <code>id=&gt;count</code> and the other contains <code>id=&gt;name</code>. I'm trying to produce a single array that is <code>name=&gt;count</code>. Any suggestions on a straightforward way to do this?</p> <p>I have looked at the <a href="http://us2.php.net/manual/en/ref.array.php" r...
[ { "answer_id": 187533, "author": "KernelM", "author_id": 22328, "author_profile": "https://Stackoverflow.com/users/22328", "pm_score": 3, "selected": true, "text": "<p>Something like:</p>\n\n<pre><code>foreach($countA as $id =&gt; $count)\n{\n $newArray[$nameA[$id]] = $count;\n}\n</co...
2008/10/09
[ "https://Stackoverflow.com/questions/187515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
I have two arrays. One contains `id=>count` and the other contains `id=>name`. I'm trying to produce a single array that is `name=>count`. Any suggestions on a straightforward way to do this? I have looked at the [Array Functions in the PHP Manual](http://us2.php.net/manual/en/ref.array.php) and didn't see anything th...
Something like: ``` foreach($countA as $id => $count) { $newArray[$nameA[$id]] = $count; } ``` This does assume that the keys are in correspondence between the two arrays, since your requirements are ambiguous otherwise.
187,526
<p>I'd like to be able to run my aliases from my .bashrc in the "Run Application" dialog that comes up when you hit Alt+F2 in Ubuntu/Gnome.</p> <p>Does anyone know how to do this?</p>
[ { "answer_id": 198830, "author": "Anders Eurenius", "author_id": 1421, "author_profile": "https://Stackoverflow.com/users/1421", "pm_score": 3, "selected": true, "text": "<p><a href=\"http://www.freedesktop.org/wiki/Specifications\" rel=\"nofollow noreferrer\">http://www.freedesktop.org/...
2008/10/09
[ "https://Stackoverflow.com/questions/187526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26510/" ]
I'd like to be able to run my aliases from my .bashrc in the "Run Application" dialog that comes up when you hit Alt+F2 in Ubuntu/Gnome. Does anyone know how to do this?
<http://www.freedesktop.org/wiki/Specifications> is probably a good place to start. I find these quite hard to follow most of the time, but sometimes you can figure it out. Specifically, the "Desktop Entry Specification". Also, I don't think you'll be able to use any aliases from `.bashrc`, at least not without writin...
187,531
<p>I have a package that I just made and I have an "old-mode" that basically makes it work like it worked before: importing everything into the current namespace. One of the nice things about having this as a package is that we no longer have to do that. Anyway, what I would like to do is have it so that whenever any...
[ { "answer_id": 187541, "author": "moritz", "author_id": 14132, "author_profile": "https://Stackoverflow.com/users/14132", "pm_score": 4, "selected": false, "text": "<p>You write your own <code>sub import</code> in <code>package Foo</code> that will get called with the parameter list from...
2008/10/09
[ "https://Stackoverflow.com/questions/187531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12448/" ]
I have a package that I just made and I have an "old-mode" that basically makes it work like it worked before: importing everything into the current namespace. One of the nice things about having this as a package is that we no longer have to do that. Anyway, what I would like to do is have it so that whenever anyone d...
Well, as you specifically state that you want to alarm in the cases of `use Mod qw<:oldmode>;` This works better: ``` package Foo; use base qw<Exporter>; use Carp qw<carp>; ... sub import { #if ( grep { $_ eq ':oldmode' } @_ ) { # Perl 5.8 if ( @_ ~~ ':oldmode' ) { # Perl 5.10 carp( 'imp...
187,537
<p>Is there a case insensitive version of the <a href="http://docs.jquery.com/Selectors/contains" rel="noreferrer">:contains</a> jQuery selector or should I do the work manually by looping over all elements and comparing their .text() to my string?</p>
[ { "answer_id": 187557, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverflow.com/users/238", "pm_score": 8, "selected": true, "text": "<p>What I ended up doing for jQuery 1.2 is :</p>\n\n<pre><code>jQuery.extend(\n jQuery.expr[':'], { \n Contains : \"jQuer...
2008/10/09
[ "https://Stackoverflow.com/questions/187537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238/" ]
Is there a case insensitive version of the [:contains](http://docs.jquery.com/Selectors/contains) jQuery selector or should I do the work manually by looping over all elements and comparing their .text() to my string?
What I ended up doing for jQuery 1.2 is : ``` jQuery.extend( jQuery.expr[':'], { Contains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0" }); ``` This will extend jquery to have a :Contains selector that is case insensitive, the :contains selector remains unchanged. Edit: For jQuery ...
187,550
<p>I have a lot of Java source code that requires custom pre-processing. I'd like rid of it but that's not feasible right now so I'm stuck with it. Given that I have an unfortunate problem that shouldn't have existed in the first place, how do I solve it using maven? </p> <p>(For the full story, I'm replacing a python...
[ { "answer_id": 187973, "author": "Keeg", "author_id": 21059, "author_profile": "https://Stackoverflow.com/users/21059", "pm_score": 2, "selected": false, "text": "<p>Maven plugins can hook into the build process at pre-compile time yes, as for whether or not any existing ones will help I...
2008/10/09
[ "https://Stackoverflow.com/questions/187550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/974/" ]
I have a lot of Java source code that requires custom pre-processing. I'd like rid of it but that's not feasible right now so I'm stuck with it. Given that I have an unfortunate problem that shouldn't have existed in the first place, how do I solve it using maven? (For the full story, I'm replacing a python-based bui...
This is something that is very doable and I've done something very similar in the past. An example from a project of mine, where I used the antrun plug-in to execute an external program to process sources: ``` <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven...
187,552
<p>What's the best way of capturing an mp3 stream coming off of http and saving it to disk with python?</p> <p>Thus far I've tried</p> <pre><code>target = open(target_path, "w") conn = urllib.urlopen(stream_url) while True: target.write(conn.read(buf_size)) </code></pre> <p>This gives me data but its garbled or ...
[ { "answer_id": 187563, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 5, "selected": true, "text": "<p>If you're on Windows, you might accidentally be doing CRLF conversions, corrupting the binary data. Try opening <...
2008/10/09
[ "https://Stackoverflow.com/questions/187552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2906/" ]
What's the best way of capturing an mp3 stream coming off of http and saving it to disk with python? Thus far I've tried ``` target = open(target_path, "w") conn = urllib.urlopen(stream_url) while True: target.write(conn.read(buf_size)) ``` This gives me data but its garbled or wont play in mp3 players.
If you're on Windows, you might accidentally be doing CRLF conversions, corrupting the binary data. Try opening `target` in binary mode: ``` target = open(target_path, "wb") ```
187,560
<p>I am migrating a site from SharePoint 2 to 3 (in fact, from SharePoint Portal Server 2003 to Microsoft Office SharePoint Server 2007). There are a handful of 3rd party web parts and since this is a migration, not an in-place upgrade, I need to install these web parts on the new farm.</p> <p>How do I do this, given...
[ { "answer_id": 187791, "author": "AdamBT", "author_id": 22426, "author_profile": "https://Stackoverflow.com/users/22426", "pm_score": 0, "selected": false, "text": "<p>You should be able to pull them apart and either repackage them as solutions or manually deploy them. Obviously, if the...
2008/10/09
[ "https://Stackoverflow.com/questions/187560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3142/" ]
I am migrating a site from SharePoint 2 to 3 (in fact, from SharePoint Portal Server 2003 to Microsoft Office SharePoint Server 2007). There are a handful of 3rd party web parts and since this is a migration, not an in-place upgrade, I need to install these web parts on the new farm. How do I do this, given that I hav...
You can still install .CAB files with WSSv3 using the same STSADM command as you used in WSSv2 ``` STSADM -o addwppack -filename <filename.CAB> ``` However, maybe you should get in touch with the providers of these 3rd party web parts? Perhaps they will have versions for WSSv3 packaged as WSP's? Also can you be su...
187,567
<p>I used Visual Studio's Application Wizard to create a skeleton MFC program with a multi-document interface. When I start this program, it automatically creates a child frame, which I don't want it to do - I need the main frame's client area to be empty until the user chooses to open a file.</p> <p>The debugger tel...
[ { "answer_id": 187931, "author": "jeffm", "author_id": 1544, "author_profile": "https://Stackoverflow.com/users/1544", "pm_score": 3, "selected": true, "text": "<p>This worked for me -- change</p>\n\n<pre><code>if (!ProcessShellCommand(cmdInfo))\n</code></pre>\n\n<p>to</p>\n\n<pre><code>...
2008/10/09
[ "https://Stackoverflow.com/questions/187567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11575/" ]
I used Visual Studio's Application Wizard to create a skeleton MFC program with a multi-document interface. When I start this program, it automatically creates a child frame, which I don't want it to do - I need the main frame's client area to be empty until the user chooses to open a file. The debugger tells me that ...
This worked for me -- change ``` if (!ProcessShellCommand(cmdInfo)) ``` to ``` if (cmdInfo.m_nShellCommand != CCommandLineInfo::FileNew && !ProcessShellCommand(cmdInfo)) ``` in your app's InitInstance() function.
187,588
<p>We have a shrink wrap type Windows server application where we need to create a self signed certificate on the server to be used by some WCF web services. From our searches on the web, it appears that the makecert utility in the PlatformSDK from Microsoft cannot be distributed with our application, so we're looking...
[ { "answer_id": 187622, "author": "blowdart", "author_id": 2525, "author_profile": "https://Stackoverflow.com/users/2525", "pm_score": 2, "selected": false, "text": "<p>Woohoo! It's time for pinvoke for you</p>\n\n<p>crypt32 provides a <a href=\"http://msdn.microsoft.com/en-us/library/aa3...
2008/10/09
[ "https://Stackoverflow.com/questions/187588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3429/" ]
We have a shrink wrap type Windows server application where we need to create a self signed certificate on the server to be used by some WCF web services. From our searches on the web, it appears that the makecert utility in the PlatformSDK from Microsoft cannot be distributed with our application, so we're looking for...
[Unfortunately, I can't comment on anything yet, so I'll post this as an answer.] I see that this post is a bit old, but I'm in a similar boat and I found this in the Visual Studio 2008 redist.txt file: ``` Windows SDK Files Subject to the license terms for the software, the following files may be distributed unmodi...
187,619
<p>I have headers in <code>&lt;h1&gt;</code> through <code>&lt;h6&gt;</code> tags. Is there a way that I can use JavaScript to generate a table of contents for the contents that serves as anchor tags as well?</p> <p>I would like the output to be something like:</p> <pre><code>&lt;ol&gt; &lt;li&gt;Header 1&lt;/li&...
[ { "answer_id": 187634, "author": "Amir Arad", "author_id": 11813, "author_profile": "https://Stackoverflow.com/users/11813", "pm_score": -1, "selected": false, "text": "<p>after page load, cycle through the DOM and look for the elements that interest you. build a nice list of anchors and...
2008/10/09
[ "https://Stackoverflow.com/questions/187619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
I have headers in `<h1>` through `<h6>` tags. Is there a way that I can use JavaScript to generate a table of contents for the contents that serves as anchor tags as well? I would like the output to be something like: ``` <ol> <li>Header 1</li> <li>Header 1</li> <li>Header 2</li> <li>Heade...
I couldn't resist putting together a quick implementation. Add the following script anywhere on your page: ``` window.onload = function () { var toc = ""; var level = 0; document.getElementById("contents").innerHTML = document.getElementById("contents").innerHTML.replace( /<h([\d])>([...
187,621
<p>I am aware of how to setup autocompletion of python objects in the python interpreter (on unix). </p> <ul> <li>Google shows many hits for explanations on how to do this.</li> <li>Unfortunately, there are so many references to that it is difficult to find what I need to do, which is slightly different.</li> </ul> ...
[ { "answer_id": 187660, "author": "ephemient", "author_id": 20713, "author_profile": "https://Stackoverflow.com/users/20713", "pm_score": 7, "selected": true, "text": "<p>Use Python's <code>readline</code> bindings. For example,</p>\n\n<pre><code>import readline\n\ndef completer(text, st...
2008/10/09
[ "https://Stackoverflow.com/questions/187621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3045/" ]
I am aware of how to setup autocompletion of python objects in the python interpreter (on unix). * Google shows many hits for explanations on how to do this. * Unfortunately, there are so many references to that it is difficult to find what I need to do, which is slightly different. I need to know how to enable, tab...
Use Python's `readline` bindings. For example, ``` import readline def completer(text, state): options = [i for i in commands if i.startswith(text)] if state < len(options): return options[state] else: return None readline.parse_and_bind("tab: complete") readline.set_completer(completer) ...
187,640
<p>Is it good practice to have a class constructor that uses default parameters, or should I use separate overloaded constructors? For example:</p> <pre><code>// Use this... class foo { private: std::string name_; unsigned int age_; public: foo(const std::string&amp; name = "", const unsigned int age = ...
[ { "answer_id": 187650, "author": "luke", "author_id": 16434, "author_profile": "https://Stackoverflow.com/users/16434", "pm_score": 8, "selected": true, "text": "<p>Definitely a matter of style. I prefer constructors with default parameters, so long as the parameters make sense. Classe...
2008/10/09
[ "https://Stackoverflow.com/questions/187640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
Is it good practice to have a class constructor that uses default parameters, or should I use separate overloaded constructors? For example: ``` // Use this... class foo { private: std::string name_; unsigned int age_; public: foo(const std::string& name = "", const unsigned int age = 0) : name_(...
Definitely a matter of style. I prefer constructors with default parameters, so long as the parameters make sense. Classes in the standard use them as well, which speaks in their favor. One thing to watch out for is if you have defaults for all but one parameter, your class can be implicitly converted from that parame...
187,669
<p>I have a linker command file that assigns the top address of the stack into a variable </p> <pre><code>_stack = . + 0x80000; </code></pre> <p>I want to use this address in a 'c' program - I want to copy the stack to another location and then update the stack pointer to point to the new location before doing a de...
[ { "answer_id": 187722, "author": "Paul Nathan", "author_id": 26227, "author_profile": "https://Stackoverflow.com/users/26227", "pm_score": 0, "selected": false, "text": "<p><em>myFunction(&amp;_stack);</em> should pass myFunction the address of the variable * _stack*.\nElse, it will pass...
2008/10/09
[ "https://Stackoverflow.com/questions/187669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23402/" ]
I have a linker command file that assigns the top address of the stack into a variable ``` _stack = . + 0x80000; ``` I want to use this address in a 'c' program - I want to copy the stack to another location and then update the stack pointer to point to the new location before doing a destructive memory test on t...
Try ``` extern u32 _stack; U32 * stackPtr; stackPtr = &_stack; ```
187,687
<p>The following ListCellRenderer does not receive click events on the nested ComboBoxes. Do I need to enable something?</p> <pre><code>class FilterCellRenderer implements ListCellRenderer { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocu...
[ { "answer_id": 188563, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 0, "selected": false, "text": "<p>It's a little bit tricky this. I believe you need to replace the JList with a single column JTable. Then se...
2008/10/09
[ "https://Stackoverflow.com/questions/187687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
The following ListCellRenderer does not receive click events on the nested ComboBoxes. Do I need to enable something? ``` class FilterCellRenderer implements ListCellRenderer { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Fi...
Renderer components in swing work like "rubber stamps" -they are just used to render/paint a value and are not added to the parent container in the usual way (just think how a single component could be added in multiple places!). It sounds like you may want an editor rather than a renderer (an editor is a fully-fledge...
187,695
<p>I've just seen this in the MS Visual Studio docs and the part in bold doesn't make sense to me. Is it wrong or am I not understanding it properly? If you run this, b appears to hold "hello" (as I would expect) and not "h".</p> <p>Strings are <em>immutable</em>--the contents of a string object cannot be changed afte...
[ { "answer_id": 187709, "author": "user7116", "author_id": 7116, "author_profile": "https://Stackoverflow.com/users/7116", "pm_score": 3, "selected": false, "text": "<p>You've done an addition AND an assignment in one step. Strings are immutable, but also a reference type.</p>\n\n<pre><co...
2008/10/09
[ "https://Stackoverflow.com/questions/187695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've just seen this in the MS Visual Studio docs and the part in bold doesn't make sense to me. Is it wrong or am I not understanding it properly? If you run this, b appears to hold "hello" (as I would expect) and not "h". Strings are *immutable*--the contents of a string object cannot be changed after the object is c...
You've done an addition AND an assignment in one step. Strings are immutable, but also a reference type. ``` string b = "h"; b = b + "ello"; ``` We can look at the pseudo-memory like this: ``` string b = "h"; // b := 0x00001000 ["h"] string tmp1 = "ello"; // tmp1 := 0x00002000 ["ello"] string tmp2 = b ...
187,713
<p>In C++, what's the generic way to convert any floating point value (float) to <a href="http://en.wikipedia.org/wiki/Fixed-point_arithmetic" rel="noreferrer"><strong>fixed point</strong></a> (int, 16:16 or 24:8)?</p> <p><strong>EDIT:</strong> For clarification, fixed-point values have two parts to them: an integer p...
[ { "answer_id": 187808, "author": "Kevin", "author_id": 6386, "author_profile": "https://Stackoverflow.com/users/6386", "pm_score": 6, "selected": true, "text": "<p>Here you go:</p>\n\n<pre><code>// A signed fixed-point 16:16 class\nclass FixedPoint_16_16\n{\n short intPart;\n...
2008/10/09
[ "https://Stackoverflow.com/questions/187713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/209/" ]
In C++, what's the generic way to convert any floating point value (float) to [**fixed point**](http://en.wikipedia.org/wiki/Fixed-point_arithmetic) (int, 16:16 or 24:8)? **EDIT:** For clarification, fixed-point values have two parts to them: an integer part and a fractional part. The integer part can be represented b...
Here you go: ``` // A signed fixed-point 16:16 class class FixedPoint_16_16 { short intPart; unsigned short fracPart; public: FixedPoint_16_16(double d) { *this = d; // calls operator= } FixedPoint_16_16& operator=(double d) { intPart = static_cast<short>(d); ...
187,736
<p>I'm writing a command line tool to help my web app. It needs a password to connect to the service. I'd like the script to show a password prompt so I don't have to pass it as a command line argument. </p> <p>That's easy enough, but I'd like it to not echo the password to the screen as it's typed. How can I do this ...
[ { "answer_id": 187821, "author": "Gabriel Gilini", "author_id": 25853, "author_profile": "https://Stackoverflow.com/users/25853", "pm_score": 2, "selected": false, "text": "<p>I guess that there is no simple way of doing it (actually I can't think of any way) without using stty -echo.\nI...
2008/10/09
[ "https://Stackoverflow.com/questions/187736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2506/" ]
I'm writing a command line tool to help my web app. It needs a password to connect to the service. I'd like the script to show a password prompt so I don't have to pass it as a command line argument. That's easy enough, but I'd like it to not echo the password to the screen as it's typed. How can I do this with PHP? ...
Found on [sitepoint](http://www.sitepoint.com/blogs/2009/05/01/interactive-cli-password-prompt-in-php/). ``` function prompt_silent($prompt = "Enter Password:") { if (preg_match('/^win/i', PHP_OS)) { $vbscript = sys_get_temp_dir() . 'prompt_password.vbs'; file_put_contents( $vbscript, 'wscript.echo(Inp...
187,742
<p>I have this:</p> <pre><code>public string Log { get { return log; } protected set { if (log != value) { MarkModified(PropertyNames.Log, log); log = value; } } } </...
[ { "answer_id": 187769, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 2, "selected": false, "text": "<p>You need to use the <a href=\"http://msdn.microsoft.com/en-us/library/system.reflection.bindingflags.aspx\" rel=\"nofollo...
2008/10/09
[ "https://Stackoverflow.com/questions/187742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/549/" ]
I have this: ``` public string Log { get { return log; } protected set { if (log != value) { MarkModified(PropertyNames.Log, log); log = value; } } } ``` And my uti...
An alternative to the suggested changes to ReflectionHelper in other answers is to call `pi.GetSetMethod(false)` and see if the result is null.
187,770
<p>I have a database called foo and a database called bar. I have a table in foo called tblFoobar that I want to move (data and all) to database bar from database foo. What is the SQL statement to do this?</p>
[ { "answer_id": 187785, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 9, "selected": true, "text": "<p>On SQL Server? and on the same database server? Use three part naming.</p>\n\n<pre><code>INSERT INTO bar..tblFoobar( *fieldl...
2008/10/09
[ "https://Stackoverflow.com/questions/187770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
I have a database called foo and a database called bar. I have a table in foo called tblFoobar that I want to move (data and all) to database bar from database foo. What is the SQL statement to do this?
On SQL Server? and on the same database server? Use three part naming. ``` INSERT INTO bar..tblFoobar( *fieldlist* ) SELECT *fieldlist* FROM foo..tblFoobar ``` This just moves the data. If you want to move the table definition (and other attributes such as permissions and indexes), you'll have to do something else.
187,774
<p>I have XML that looks like</p> <pre><code>&lt;answers&gt; &lt;answer&gt; &lt;question-number&gt;1&lt;/question-number&gt; &lt;value&gt;3&lt;/value&gt; &lt;mean xsi:nil="1" /&gt; &lt;/answer&gt; &lt;answer&gt; &lt;question-number&gt;2&lt;/question-number&gt; &lt;value&gt;2&lt;...
[ { "answer_id": 187843, "author": "Robert Gould", "author_id": 15124, "author_profile": "https://Stackoverflow.com/users/15124", "pm_score": 0, "selected": false, "text": "<p>Something like this should work. if you have any means it will return true</p>\n\n<pre><code>&lt;xs:if test=\"/ans...
2008/10/09
[ "https://Stackoverflow.com/questions/187774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1237/" ]
I have XML that looks like ``` <answers> <answer> <question-number>1</question-number> <value>3</value> <mean xsi:nil="1" /> </answer> <answer> <question-number>2</question-number> <value>2</value> <mean>2.3</mean> </answer> <answer> <question-number>3</questi...
Here's what finally worked for me: ``` <xsl:if test="//answers/answer/mean>0"> ``` That is to say, "do there exist any answer elements for which the mean value is greater than zero". Fortunately I know that the mean value, if there is one, will in fact always be greater than zero -- unfortunately this isn't a genera...
187,777
<p>How can I get the BSSID / MAC (Media Access Control) address of the wireless access point my system is connected to using C#?</p> <p>Note that I'm interested in the BSSID of the WAP. This is different from the MAC address of the networking portion of the WAP.</p>
[ { "answer_id": 187867, "author": "Iain", "author_id": 5993, "author_profile": "https://Stackoverflow.com/users/5993", "pm_score": 6, "selected": true, "text": "<p>The following needs to be executed programmatically:</p>\n\n<pre><code>netsh wlan show networks mode=Bssid | findstr \"BSSID\...
2008/10/09
[ "https://Stackoverflow.com/questions/187777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5993/" ]
How can I get the BSSID / MAC (Media Access Control) address of the wireless access point my system is connected to using C#? Note that I'm interested in the BSSID of the WAP. This is different from the MAC address of the networking portion of the WAP.
The following needs to be executed programmatically: ``` netsh wlan show networks mode=Bssid | findstr "BSSID" ``` The above shows the access point's wireless MAC addresses which is different from: ``` arp -a | findstr 192.168.1.254 ``` This is because the access point has 2 MAC addresses. One for the wireless de...
187,779
<p>Is it possible to update IIS on Windows XP from 5.1 to 6?</p> <p>If so how?</p> <p>Thanks.</p>
[ { "answer_id": 187802, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 6, "selected": true, "text": "<p>No, it is not possible. The version of IIS is tied to a specific version of Windows.</p>\n\n<pre><code>XP = IIS 5.1\n...
2008/10/09
[ "https://Stackoverflow.com/questions/187779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12148/" ]
Is it possible to update IIS on Windows XP from 5.1 to 6? If so how? Thanks.
No, it is not possible. The version of IIS is tied to a specific version of Windows. ``` XP = IIS 5.1 2003 = IIS 6 2008 = IIS 7 ``` More information available at <http://support.microsoft.com/kb/224609>.
187,795
<p>For simplicity lets say I have two flex mxml pages. </p> <p>form.mxml<br> button.mxml</p> <p>If the form.mxml page had the following code, it should work fine:</p> <pre><code>&lt;custom:SelectView dSource="{_thedata}" id="form" visible="false"&gt; &lt;/custom:SelectView&gt; &lt;mx:LinkButton label="Show" id="lbS...
[ { "answer_id": 187889, "author": "Matt Dillard", "author_id": 863, "author_profile": "https://Stackoverflow.com/users/863", "pm_score": 0, "selected": false, "text": "<p>Your <code>button.mxml</code> class must have a reference to the instance of the 'form' class which will be affected. ...
2008/10/09
[ "https://Stackoverflow.com/questions/187795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24563/" ]
For simplicity lets say I have two flex mxml pages. form.mxml button.mxml If the form.mxml page had the following code, it should work fine: ``` <custom:SelectView dSource="{_thedata}" id="form" visible="false"> </custom:SelectView> <mx:LinkButton label="Show" id="lbShow" click="form.visible=true;> <mx:LinkButt...
You could write a custom method that handles the button click events and raises a custom event. Then in form.mxml you can handle that event. Splitting it up like this is a bit cleaner, as it makes the button.mxml file work on its own. Having Button.mxml have a direct reference to your form causes a tight-coupling betw...
187,797
<p>Say I've got a class like this:</p> <pre><code>class Test { int x; SomeClass s; } </code></pre> <p>And I instantiate it like this:</p> <pre><code>Test* t = new Test; </code></pre> <p>Is x on the stack, or the heap? What about s?</p>
[ { "answer_id": 187806, "author": "Avdi", "author_id": 20487, "author_profile": "https://Stackoverflow.com/users/20487", "pm_score": 3, "selected": false, "text": "<p>Since you've used <code>new</code>, it's all on the heap, stored [more or less] contiguously in <code>t</code>'s memory ar...
2008/10/09
[ "https://Stackoverflow.com/questions/187797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12828/" ]
Say I've got a class like this: ``` class Test { int x; SomeClass s; } ``` And I instantiate it like this: ``` Test* t = new Test; ``` Is x on the stack, or the heap? What about s?
Each time you "instantiate" an object/symbol using a new (we are speaking C++ here), a new memory zone will be allocated for this object. If not, it will be put on the "local" memory zone. The problem is that I have no standard definition for "local" memory zone. An example ---------- This means that, for example: ...
187,799
<p>Let me start by saying I'm a huge fan of the elegance of this pattern -- I have a group of basic entities that I have implemented builders for (specifically for testing). However I have found (and this may be the caveat) that as my program evolved I kept having to go back and re-work the builders. In the end, it r...
[ { "answer_id": 218542, "author": "Enrico Campidoglio", "author_id": 26396, "author_profile": "https://Stackoverflow.com/users/26396", "pm_score": 1, "selected": false, "text": "<p>If the test data builders become too complex to maintain, I would recommend switching to a <strong>mocking f...
2008/10/09
[ "https://Stackoverflow.com/questions/187799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25807/" ]
Let me start by saying I'm a huge fan of the elegance of this pattern -- I have a group of basic entities that I have implemented builders for (specifically for testing). However I have found (and this may be the caveat) that as my program evolved I kept having to go back and re-work the builders. In the end, it really...
I like using fluent builders for the object under test to express the nature of the object I'm creating. ObjectMothers tend to get unwieldy and tend to (in the implementations I've come across) end up hiding details of the objects creation. Compare: ``` User fred = CreateUser("fred").WithReputation(900) ...
187,836
<p>Sometimes while debugging, I need to restart a service on a remote machine. Currently, I'm doing this via Remote Desktop. How can it be done from the command line on my local machine?</p>
[ { "answer_id": 187854, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 9, "selected": true, "text": "<p>You can use the services console, clicking on the left hand side and then selecting the \"Connect to another compu...
2008/10/09
[ "https://Stackoverflow.com/questions/187836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/549/" ]
Sometimes while debugging, I need to restart a service on a remote machine. Currently, I'm doing this via Remote Desktop. How can it be done from the command line on my local machine?
You can use the services console, clicking on the left hand side and then selecting the "Connect to another computer" option in the Action menu. If you wish to use the command line only, you can use ``` sc \\machine stop <service> ```
187,849
<p>I am experiencing some weird behavior with localized messages reported from my background worker process in my windows forms application.</p> <p>The application is a setup application with windows forms. The application launches a background worker to perform and IIS reset and then install MSIs.</p> <p>The first t...
[ { "answer_id": 190502, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 1, "selected": false, "text": "<p>The culture info is in thread-local storage, so if the background worker runs processes on different threads, this may be...
2008/10/09
[ "https://Stackoverflow.com/questions/187849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26540/" ]
I am experiencing some weird behavior with localized messages reported from my background worker process in my windows forms application. The application is a setup application with windows forms. The application launches a background worker to perform and IIS reset and then install MSIs. The first time I run the app...
If your UIThread runs an other UICulture than your BackgroundWorker you can explicit change the culture of the worker thread by using an callback like this: ``` private delegate CultureInfo GetUICultureCallback(); private CultureInfo GetUICulture() { if (this.InvokeRequired) ...
187,851
<p>How can I open a synchronous dialog in Flex? I need to call a function from an External Interface (JavaScript) that will open a simple dialog in the Flex application and returns an value according to the button the user has clicked (OK/Cancel).</p> <p>So it should by a synchronous call to a dialog, i.e. the call wa...
[ { "answer_id": 187955, "author": "David Arno", "author_id": 7122, "author_profile": "https://Stackoverflow.com/users/7122", "pm_score": 2, "selected": false, "text": "<p>Flex doesn't work in a synchronous fashion, as it is a single thread application and so needs your code to hand execut...
2008/10/09
[ "https://Stackoverflow.com/questions/187851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7524/" ]
How can I open a synchronous dialog in Flex? I need to call a function from an External Interface (JavaScript) that will open a simple dialog in the Flex application and returns an value according to the button the user has clicked (OK/Cancel). So it should by a synchronous call to a dialog, i.e. the call waits until ...
You can't do that in Flex. As David mentioned, Flex is single-threaded, so you can't have your function block while the dialog is being processed. Your best bet might be to use a Javascript popup. You'll have a lot less control over the window, but it should behave the way you want (blocking the function until it's be...
187,886
<p>I need to grant select permission for all tables owned by a specific user to another user. Can I do this with a single command along the lines of:</p> <pre><code>Grant Select on OwningUser.* to ReceivingUser </code></pre> <p>Or do I have to generate the sql for each table with something along the lines of:</p> <...
[ { "answer_id": 189496, "author": "DCookie", "author_id": 8670, "author_profile": "https://Stackoverflow.com/users/8670", "pm_score": 7, "selected": true, "text": "<p>Well, it's not a single statement, but it's about as close as you can get with oracle:</p>\n\n<pre><code>BEGIN\n FOR R I...
2008/10/09
[ "https://Stackoverflow.com/questions/187886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9940/" ]
I need to grant select permission for all tables owned by a specific user to another user. Can I do this with a single command along the lines of: ``` Grant Select on OwningUser.* to ReceivingUser ``` Or do I have to generate the sql for each table with something along the lines of: ``` Select 'GRANT SELECT ON Own...
Well, it's not a single statement, but it's about as close as you can get with oracle: ``` BEGIN FOR R IN (SELECT owner, table_name FROM all_tables WHERE owner='TheOwner') LOOP EXECUTE IMMEDIATE 'grant select on '||R.owner||'.'||R.table_name||' to TheUser'; END LOOP; END; ```
187,893
<p>This is what I'd like to do, but it doesn't seem possible: (edit: changed single to double quotes)</p> <pre><code>function get_archives($limit, $offset) { $query = $this-&gt;db-&gt;query(" SELECT archivalie.id, archivalie.signature, type_of_source.description AS type_...
[ { "answer_id": 187904, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": -1, "selected": false, "text": "<p>If you used double quotes instead of single quotes it would work, but you'd be open to an injection attack if the variabl...
2008/10/09
[ "https://Stackoverflow.com/questions/187893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4196/" ]
This is what I'd like to do, but it doesn't seem possible: (edit: changed single to double quotes) ``` function get_archives($limit, $offset) { $query = $this->db->query(" SELECT archivalie.id, archivalie.signature, type_of_source.description AS type_of_source_descriptio...
``` $query = $this->db->query(' SELECT archivalie.id, archivalie.signature, type_of_source.description AS type_of_source_description, media_type.description AS media_type_description, origin.description AS origin_description FROM archivalie, type_of_source, media...
187,894
<p>From C#, I want to do the equivalent of the following:</p> <pre><code>arp -a |findstr 192.168.1.254 </code></pre> <p>Alternatively, the answer could call the <a href="http://msdn.microsoft.com/en-us/library/aa366358.aspx" rel="noreferrer">SendARP</a> function and get the results.</p> <p>This will allow my applica...
[ { "answer_id": 187929, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 6, "selected": true, "text": "<p>SendARP P/Invoke goes like this:</p>\n\n<pre><code>[DllImport(\"iphlpapi.dll\", ExactSpelling=true)]\npublic static extern i...
2008/10/09
[ "https://Stackoverflow.com/questions/187894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5993/" ]
From C#, I want to do the equivalent of the following: ``` arp -a |findstr 192.168.1.254 ``` Alternatively, the answer could call the [SendARP](http://msdn.microsoft.com/en-us/library/aa366358.aspx) function and get the results. This will allow my application to do some other processing that requires the MAC addres...
SendARP P/Invoke goes like this: ``` [DllImport("iphlpapi.dll", ExactSpelling=true)] public static extern int SendARP( int destIp, int srcIP, byte[] macAddr, ref uint physicalAddrLen ); ``` [PInvoke.NET](http://www.pinvoke.net/default.aspx/iphlpapi/SendARP.html) has this example: ``` IPAddress dst = IPAddress.Parse...
187,913
<p>What I'd like to avoid: </p> <pre><code>ManagementClass m = new ManagementClass("Win32_LogicalDisk"); ManagementObjectCollection managementObjects = m.GetInstances(); List&lt;ManagementObject&gt; managementList = new List&lt;ManagementObject&gt;(); foreach(ManagementObject m in managementObjects){ managemen...
[ { "answer_id": 187922, "author": "steffenj", "author_id": 15328, "author_profile": "https://Stackoverflow.com/users/15328", "pm_score": 1, "selected": false, "text": "<p>You could try:</p>\n\n<pre><code>List&lt;ManagementObject&gt; managementList = new List&lt;ManagementObject&gt;(manage...
2008/10/09
[ "https://Stackoverflow.com/questions/187913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64/" ]
What I'd like to avoid: ``` ManagementClass m = new ManagementClass("Win32_LogicalDisk"); ManagementObjectCollection managementObjects = m.GetInstances(); List<ManagementObject> managementList = new List<ManagementObject>(); foreach(ManagementObject m in managementObjects){ managementList.Add(m); } ``` Isn...
What version of the framework? With 3.5 you could presumably use: ``` List<ManagementObject> managementList = managementObjects.Cast<ManagementObject>().ToList(); ``` (edited to remove simpler version; I checked and `ManagementObjectCollection` only implements the non-generic `IEnumerable` form)
187,920
<p>I'm logged into a SQL Server 2005 database as a non-sa user, 'bhk', that is a member of the 'public' server role only. The following code tries to execute within a stored procedure called by user 'bhk'. This line of code...</p> <pre><code>TRUNCATE TABLE #Table1 DBCC CHECKIDENT('#Table1', RESEED, @SequenceNumber) WI...
[ { "answer_id": 194185, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 2, "selected": false, "text": "<p>You wrote:</p>\n\n<blockquote>\n <p>\"Caller must own the table, or be a\n member of the sysadmin fixed server\n role...
2008/10/09
[ "https://Stackoverflow.com/questions/187920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14360/" ]
I'm logged into a SQL Server 2005 database as a non-sa user, 'bhk', that is a member of the 'public' server role only. The following code tries to execute within a stored procedure called by user 'bhk'. This line of code... ``` TRUNCATE TABLE #Table1 DBCC CHECKIDENT('#Table1', RESEED, @SequenceNumber) WITH NO_INFOMSGS...
Here is an alternate solution, that may work if you need to re-seed with a sequence number of more than 1. ``` TRUNCATE #Table1 SET IDENTITY_INSERT #Table1 ON INSERT INTO #Table1 (TableID) -- This is your primary key field VALUES (@SequenceNumber - 1) SET IDENTITY_INSERT #Table1 OFF DELETE FROM #Table1 ``` What ...
187,974
<p>I have a simple Word to Pdf converter as an MSBuild Task. The task takes Word files (ITaskItems) as input and Pdf files (ITaskItems) as output. The script uses a Target transform for conversion:</p> <pre><code>&lt;Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersio...
[ { "answer_id": 188060, "author": "lesscode", "author_id": 18482, "author_profile": "https://Stackoverflow.com/users/18482", "pm_score": 3, "selected": true, "text": "<p>I found the problem. It turns out that I had some logic in the Task that would turn any relative path specified for a P...
2008/10/09
[ "https://Stackoverflow.com/questions/187974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18482/" ]
I have a simple Word to Pdf converter as an MSBuild Task. The task takes Word files (ITaskItems) as input and Pdf files (ITaskItems) as output. The script uses a Target transform for conversion: ``` <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> <Using...
I found the problem. It turns out that I had some logic in the Task that would turn any relative path specified for a PDF file into an absolute path. Once I removed that and changed the script to this: ``` <Target Name="Convert" Inputs="@(WordDocuments)" Outputs="@(WordDocuments->'%(RelativeDir)%...
187,981
<p>I have the following regular expression : I figured out most of the part which is as follows :</p> <pre> ValidationExpression="^[\u0020\u0027\u002C\u002D\u0030-\u0039\u0041-\u005A\u005F\u0061-\u007A\u00C0-\u00FF°&#46;/]{1,256}$" u0020 : SPACE u0027 : APOSTROPHE u002C : COMMA u002D : HYPHEN / MINUS u0030-\u0039\ : ...
[ { "answer_id": 188003, "author": "Robert K", "author_id": 24950, "author_profile": "https://Stackoverflow.com/users/24950", "pm_score": 2, "selected": false, "text": "<p>\\u00C0 - \\u00FF are letters with accents on them, though that isn't all of them. And \"°\" is just the degree chara...
2008/10/09
[ "https://Stackoverflow.com/questions/187981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24958/" ]
I have the following regular expression : I figured out most of the part which is as follows : ``` ValidationExpression="^[\u0020\u0027\u002C\u002D\u0030-\u0039\u0041-\u005A\u005F\u0061-\u007A\u00C0-\u00FF°./]{1,256}$" u0020 : SPACE u0027 : APOSTROPHE u002C : COMMA u002D : HYPHEN / MINUS u0030-\u0039\ : 0-9 u0041-\u...
weird... according to the character map on Windows I'd say "À to ÿ" Those are some variations (accents, cedillas) on A, C, E, I, D, N, O, U, Y, the german Sharp s, ...
187,987
<p>I was wondering if this seemed to familiar to any experience NHibernate developers or if someone could give me an idea as to where to start to try and resolve this issue:</p> <p>I inherited an NHibernate site written in ASP.NET 1.1 using NHibernate 0.6 and .NET remoting to the DAL layer residing on the database ser...
[ { "answer_id": 188026, "author": "mspmsp", "author_id": 21724, "author_profile": "https://Stackoverflow.com/users/21724", "pm_score": 1, "selected": false, "text": "<ul>\n<li>verify your connection settings.</li>\n<li>if you can, cache objects as much as you can to avoid battering the se...
2008/10/09
[ "https://Stackoverflow.com/questions/187987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26550/" ]
I was wondering if this seemed to familiar to any experience NHibernate developers or if someone could give me an idea as to where to start to try and resolve this issue: I inherited an NHibernate site written in ASP.NET 1.1 using NHibernate 0.6 and .NET remoting to the DAL layer residing on the database server. I hav...
Problem was non thread-safe nhibernate session factory. Changed project to use an http module to use one nhibernate session per request (and made sure not to open a session for rquests on non .as\*x files) and all is well.
187,998
<p>Is there any way in SQL Server to get the results starting at a given offset? For example, in another type of SQL database, it's possible to do:</p> <pre><code>SELECT * FROM MyTable OFFSET 50 LIMIT 25 </code></pre> <p>to get results 51-75. This construct does not appear to exist in SQL Server. </p> <p>How can I ...
[ { "answer_id": 188031, "author": "Unsliced", "author_id": 2902, "author_profile": "https://Stackoverflow.com/users/2902", "pm_score": 2, "selected": false, "text": "<p>Depending on your version ou cannot do it directly, but you could do something hacky like</p>\n\n<pre><code>select top 2...
2008/10/09
[ "https://Stackoverflow.com/questions/187998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/420/" ]
Is there any way in SQL Server to get the results starting at a given offset? For example, in another type of SQL database, it's possible to do: ``` SELECT * FROM MyTable OFFSET 50 LIMIT 25 ``` to get results 51-75. This construct does not appear to exist in SQL Server. How can I accomplish this without loading al...
I would avoid using `SELECT *`. Specify columns you actually want even though it may be all of them. **SQL Server 2005+** ``` SELECT col1, col2 FROM ( SELECT col1, col2, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum FROM MyTable ) AS MyDerivedTable WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow ``` ...
187,999
<p>One small function of a large program examines assemblies in a folder and replaces out-of-date assemblies with the latest versions. To accomplish this, it needs to read the version numbers of the existing assembly files without actually loading those assemblies into the executing process.</p>
[ { "answer_id": 188036, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 3, "selected": false, "text": "<p>Use <code>AssemblyName.GetAssemblyName(\"assembly.dll\");</code>, then parse the name. According to <a href=\"http://msdn.m...
2008/10/09
[ "https://Stackoverflow.com/questions/187999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26553/" ]
One small function of a large program examines assemblies in a folder and replaces out-of-date assemblies with the latest versions. To accomplish this, it needs to read the version numbers of the existing assembly files without actually loading those assemblies into the executing process.
I found the following [in this article](http://blogs.msdn.com/alejacma/archive/2008/09/05/how-to-get-assembly-version-without-loading-it.aspx). ``` using System.Reflection; using System.IO; ... // Get current and updated assemblies AssemblyName currentAssemblyName = AssemblyName.GetAssemblyName(currentAssemblyPath);...
188,001
<p>I am attempting to rewrite my <a href="http://ForestPad.com" rel="nofollow noreferrer">ForestPad</a> application utilizing WPF for the presentation layer. In WinForms, I am populating each node programmatically but I would like to take advantage of the databinding capabilities of WPF, if possible.</p> <p>In genera...
[ { "answer_id": 188084, "author": "Joel B Fant", "author_id": 22211, "author_profile": "https://Stackoverflow.com/users/22211", "pm_score": 4, "selected": true, "text": "<p>Well, it would be easier if your element hierarchy was more like...</p>\n\n<pre><code>&lt;node type=\"forest\"&gt;\n...
2008/10/09
[ "https://Stackoverflow.com/questions/188001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12919/" ]
I am attempting to rewrite my [ForestPad](http://ForestPad.com) application utilizing WPF for the presentation layer. In WinForms, I am populating each node programmatically but I would like to take advantage of the databinding capabilities of WPF, if possible. In general, what is the best way to two-way databind the ...
Well, it would be easier if your element hierarchy was more like... ``` <node type="forest"> <node type="tree"> ... ``` ...rather than your current schema. As-is, you'll need 4 `HierarchicalDataTemplate`s, one for each hierarchical element including the root, and one `DataTemplate` for `leaf` elements: ...
188,007
<p>I'm using my code-behind page to create a save button programmatically:</p> <pre><code> Button btnSave = new Button(); btnSave.ID = "btnSave"; btnSave.Text = "Save"; </code></pre> <p>However I think this must create an html button or perhaps needs something else as I cannot seem to set the OnClick attri...
[ { "answer_id": 188021, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 3, "selected": false, "text": "<p>You would be adding a handler to the OnClick using the += syntax if you want to register a handler for the OnCl...
2008/10/09
[ "https://Stackoverflow.com/questions/188007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26126/" ]
I'm using my code-behind page to create a save button programmatically: ``` Button btnSave = new Button(); btnSave.ID = "btnSave"; btnSave.Text = "Save"; ``` However I think this must create an html button or perhaps needs something else as I cannot seem to set the OnClick attribute in the following line...
``` Button btnSave = new Button(); btnSave.ID = "btnSave"; btnSave.Text = "Save"; btnSave.Click += new System.EventHandler(btnSave_Click); protected void btnSave_Click(object sender, EventArgs e) { //do something when button clicked. } ```
188,043
<p>Ok guys just a small game:</p> <p>I have some specifications for a project. At some point they ask for the following to encrypt a password over the net, saying that it is a challenge response protocol:</p> <pre> CLIENT ----------------------------- SERVER (1)ask for challenge --------------&gt; (2) &lt;------...
[ { "answer_id": 188058, "author": "Greg Dean", "author_id": 1200558, "author_profile": "https://Stackoverflow.com/users/1200558", "pm_score": 2, "selected": false, "text": "<p>You would be able to reverse engineer the password. You want to send the SHA of the password, not the password i...
2008/10/09
[ "https://Stackoverflow.com/questions/188043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/366094/" ]
Ok guys just a small game: I have some specifications for a project. At some point they ask for the following to encrypt a password over the net, saying that it is a challenge response protocol: ``` CLIENT ----------------------------- SERVER (1)ask for challenge --------------> (2) <---------------------------...
How about the following: 1. Server sends a random challenge 2. Client sends SHA1 checksum of (challenge+password) 3. Servers compares against SHA1 checksum of (challenge+stored password)
188,057
<p>Quick question. What do you think, I have a few sites that use a 3 level drop-down menu that will be broken if IE8 released with its current CSS standards in IE8 beta2. So do I take the time to redo those drop downs now? I realize that the way they rendered CSS changed completely between beta 1 and 2, but 2 was/is ...
[ { "answer_id": 188066, "author": "Gabriel Isenberg", "author_id": 1473493, "author_profile": "https://Stackoverflow.com/users/1473493", "pm_score": 4, "selected": true, "text": "<p>You can add the meta tag to force IE7 compatible rendering. Your site continues to work, no changes are mad...
2008/10/09
[ "https://Stackoverflow.com/questions/188057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19226/" ]
Quick question. What do you think, I have a few sites that use a 3 level drop-down menu that will be broken if IE8 released with its current CSS standards in IE8 beta2. So do I take the time to redo those drop downs now? I realize that the way they rendered CSS changed completely between beta 1 and 2, but 2 was/is supp...
You can add the meta tag to force IE7 compatible rendering. Your site continues to work, no changes are made to the web site and life is happy for everyone. That said, i'm curious about the "forced to properly handle CSS" bit; IE8 has been pretty big win for CSS standards, but I could be missing the bandwagon. ;) HTM...
188,098
<p>I have a problem when an unhandeld exception occurs while debugging a WinForm VB.NET project.</p> <p>The problem is that my application terminates and I have to start the application again, instead of retrying the action as was the case in VS2003</p> <p>The unhandeld exception is implemented in the new My.MyApplic...
[ { "answer_id": 188817, "author": "Jeffrey", "author_id": 3259, "author_profile": "https://Stackoverflow.com/users/3259", "pm_score": 0, "selected": false, "text": "<p>I'm not sure about VS2008, but I had the same issue for awhile in VS2005. It turns out I just had to go to Debug->Except...
2008/10/09
[ "https://Stackoverflow.com/questions/188098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11123/" ]
I have a problem when an unhandeld exception occurs while debugging a WinForm VB.NET project. The problem is that my application terminates and I have to start the application again, instead of retrying the action as was the case in VS2003 The unhandeld exception is implemented in the new My.MyApplication class found...
Ok I found the answer to this issue in this blog post: [Handling "Unhandled Exceptions" in .NET 2.0](http://www.julmar.com/blog/mark/PermaLink,guid,f733e261-5d39-4ca1-be1a-c422f3cf1f1b.aspx) Thank you Mark! The short answer is: ``` Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); ``` ...
188,099
<p>Howdy. Consider the following:</p> <pre><code>SQL&gt; DECLARE 2 b1 BOOLEAN; 3 b2 BOOLEAN; 4 FUNCTION checkit RETURN BOOLEAN IS 5 BEGIN 6 dbms_output.put_line('inside checkit'); 7 RETURN TRUE; 8 END checkit; 9 10 PROCEDURE outp(n VARCHAR2, p BOOLEAN) IS 1...
[ { "answer_id": 188107, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 4, "selected": true, "text": "<p>Yes. PL/SQL performs <a href=\"http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/fundamentals.htm#sthr...
2008/10/09
[ "https://Stackoverflow.com/questions/188099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8670/" ]
Howdy. Consider the following: ``` SQL> DECLARE 2 b1 BOOLEAN; 3 b2 BOOLEAN; 4 FUNCTION checkit RETURN BOOLEAN IS 5 BEGIN 6 dbms_output.put_line('inside checkit'); 7 RETURN TRUE; 8 END checkit; 9 10 PROCEDURE outp(n VARCHAR2, p BOOLEAN) IS 11 BEGIN 12 ...
Yes. PL/SQL performs [short circuit evaluation](http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/fundamentals.htm#sthref481) of logical expressions from left to right.
188,114
<p>I'm trying to write a log file from an ASP.NET application under IIS7, but keep getting the following exception:</p> <blockquote> <p>UnauthorizedAccessException "Access to the path 'C:\Users\Brady\Exports' is denied."</p> </blockquote> <p>I have given write access to the iis_iusrs, iis_wpg, and aspnet users, b...
[ { "answer_id": 188125, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 3, "selected": true, "text": "<p>You need to grant permission to one of the following accounts</p>\n\n<pre><code>ASPNET - Win XP and Win 2000\nNE...
2008/10/09
[ "https://Stackoverflow.com/questions/188114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
I'm trying to write a log file from an ASP.NET application under IIS7, but keep getting the following exception: > > UnauthorizedAccessException > "Access to the path 'C:\Users\Brady\Exports' is denied." > > > I have given write access to the iis\_iusrs, iis\_wpg, and aspnet users, based on various advices found...
You need to grant permission to one of the following accounts ``` ASPNET - Win XP and Win 2000 NETWORK SERVICE - Win Vista and 2003 ``` These are the defaults, if the application pool has been configured for a different process account then you would need to work with that specific account.
188,118
<p>I've tried this, but it doesn't work:</p> <pre><code>col * format a20000 </code></pre> <p>Do I really have to list every column specifically? That is a huge pain in the arse.</p>
[ { "answer_id": 188135, "author": "someguy", "author_id": 8913, "author_profile": "https://Stackoverflow.com/users/8913", "pm_score": 5, "selected": false, "text": "<p>Never mind, figured it out:</p>\n\n<pre><code>set wrap off\nset linesize 3000 -- (or to a sufficiently large value to hol...
2008/10/09
[ "https://Stackoverflow.com/questions/188118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8913/" ]
I've tried this, but it doesn't work: ``` col * format a20000 ``` Do I really have to list every column specifically? That is a huge pain in the arse.
Never mind, figured it out: ``` set wrap off set linesize 3000 -- (or to a sufficiently large value to hold your results page) ``` Which I found by: ``` show all ``` And looking for some option that seemed relevant.
188,120
<p>So .NET 3.0/3.5 provides us with lots of new ways to query, sort, and manipulate data, thanks to all the neat functions supplied with LINQ. Sometimes, I need to compare user-defined types that don't have a built-in comparison operator. In many cases, the comparison is really simple -- something like foo1.key ?= fo...
[ { "answer_id": 188130, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>My <a href=\"http://pobox.com/~skeet/csharp/miscutil\" rel=\"noreferrer\">MiscUtil</a> library contains a ProjectionCo...
2008/10/09
[ "https://Stackoverflow.com/questions/188120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26286/" ]
So .NET 3.0/3.5 provides us with lots of new ways to query, sort, and manipulate data, thanks to all the neat functions supplied with LINQ. Sometimes, I need to compare user-defined types that don't have a built-in comparison operator. In many cases, the comparison is really simple -- something like foo1.key ?= foo2.ke...
My [MiscUtil](http://pobox.com/~skeet/csharp/miscutil) library contains a ProjectionComparer to build an IComparer<T> from a projection delegate. It would be the work of 10 minutes to make a ProjectionEqualityComparer to do the same thing. EDIT: Here's the code for ProjectionEqualityComparer: ``` using System; using ...
188,124
<p>I am writing a website with Visual Studio 2008 and ASP.NET 3.5. I have a masterpage set up to simplify the layout and to keep the content pages for content rather than content and layout.</p> <p>The navigation is list, css'd so it looks like a bar. In order to highlight the page on the bar, the list item needs to ...
[ { "answer_id": 188142, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>The use or non use of ContentPlaceHolder will not affect which element has the id=\"current\" set on it.</p>\n\...
2008/10/09
[ "https://Stackoverflow.com/questions/188124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
I am writing a website with Visual Studio 2008 and ASP.NET 3.5. I have a masterpage set up to simplify the layout and to keep the content pages for content rather than content and layout. The navigation is list, css'd so it looks like a bar. In order to highlight the page on the bar, the list item needs to look like t...
Add a property to your master page called Page Section ``` public string PageSection { get; set; } ``` Add a MasterType page directive to the top of your content pages ``` <%@ MasterType VirtualPath="~/foo.master" %> ``` In your content page code behind, set the PageSection property of the master page ``` Master...
188,138
<p>I've seen a number of references to gzipping a javascript to save download time. <em>But</em> I also see a number of warnings that certain browsers do not support this.</p> <p>I have two different methods at my disposal:</p> <ol> <li>use <code>mod_deflate</code> to make Apache compress JS/CSS files in a given dir...
[ { "answer_id": 188205, "author": "nsayer", "author_id": 13757, "author_profile": "https://Stackoverflow.com/users/13757", "pm_score": 2, "selected": false, "text": "<p>The best way to achieve this is for your server to support inline gzip. You would take the \".gz\" off both the script t...
2008/10/09
[ "https://Stackoverflow.com/questions/188138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24950/" ]
I've seen a number of references to gzipping a javascript to save download time. *But* I also see a number of warnings that certain browsers do not support this. I have two different methods at my disposal: 1. use `mod_deflate` to make Apache compress JS/CSS files in a given directory through htaccess 2. use `ob_star...
mod\_deflate and php's gzhandler both are based on zlib, so in that sense there is little difference to a browser how the content is being compressed. in response to your first concern, you can set module specific .htaccess info like this: ``` <IfModule mod_deflate.c> # stuff </IfModule> ``` in response to your s...
188,141
<p>I'm using C# on Framework 3.5. I'm looking to quickly sort a Generic <code>List&lt;T&gt;</code>. For the sake of this example, let's say I have a List of a <code>Person</code> type with a property of lastname. How would I sort this List using a lambda expression?</p> <pre><code>List&lt;Person&gt; people = Popula...
[ { "answer_id": 188149, "author": "Danimal", "author_id": 2757, "author_profile": "https://Stackoverflow.com/users/2757", "pm_score": 5, "selected": false, "text": "<pre><code>people.OrderBy(person =&gt; person.lastname).ToList();\n</code></pre>\n" }, { "answer_id": 188154, "a...
2008/10/09
[ "https://Stackoverflow.com/questions/188141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7215/" ]
I'm using C# on Framework 3.5. I'm looking to quickly sort a Generic `List<T>`. For the sake of this example, let's say I have a List of a `Person` type with a property of lastname. How would I sort this List using a lambda expression? ``` List<Person> people = PopulateList(); people.OrderBy(???? => ?????) ```
If you mean an in-place sort (i.e. the list is updated): ``` people.Sort((x, y) => string.Compare(x.LastName, y.LastName)); ``` If you mean a new list: ``` var newList = people.OrderBy(x=>x.LastName).ToList(); // ToList optional ```
188,147
<p>Trying to setup the exception_logger plugin on a production server. Everything worked fine on the dev machine. Trying to rake db:migrate on the prod server and i get this error:</p> <pre><code>rake aborted! no such file to load -- pagination </code></pre> <p>What am i missing?</p>
[ { "answer_id": 188228, "author": "Christoph Schiessl", "author_id": 20467, "author_profile": "https://Stackoverflow.com/users/20467", "pm_score": 1, "selected": false, "text": "<p>Obviously the error is related to the pagination plugin. That means the error may not be related to exceptio...
2008/10/09
[ "https://Stackoverflow.com/questions/188147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18811/" ]
Trying to setup the exception\_logger plugin on a production server. Everything worked fine on the dev machine. Trying to rake db:migrate on the prod server and i get this error: ``` rake aborted! no such file to load -- pagination ``` What am i missing?
Classic Pagination is not supported in 2.1 - or at least it is a dead library <http://workingwithrails.com/railsplugin/5289-classic-pagination> Have a look at will\_paginate - <http://github.com/mislav/will_paginate/wikis> that's what all the cool kids are using :-)
188,160
<p>How have you decided to handle data/control validation in your silverlight applications? </p>
[ { "answer_id": 188459, "author": "Bryant", "author_id": 10893, "author_profile": "https://Stackoverflow.com/users/10893", "pm_score": 1, "selected": false, "text": "<p>Haven't done much of this yet personally, but some good starting points <a href=\"http://weblogs.asp.net/manishdalal/arc...
2008/10/09
[ "https://Stackoverflow.com/questions/188160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5618/" ]
How have you decided to handle data/control validation in your silverlight applications?
You can throw and capture data validation exceptions. To manage both of these types of errors need to take 3 steps: 1. Identify the error handler either in the control or higher in the visiblity hierarchy (e.g., a container; in this case the grid that contains the text box) 2. Set NotifyOnValidationError and Validate...