instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I have a database driven website serving about 50,000 pages.</p> <p>I want to track each webpage/record hit. I will do this by creating logs, and then batch processing the logs once a day. I am not concerned with how I will do the batch process, only with the quickest way to log.</p> <p>How would you log, which do...
<ol> <li><p>Write to file. Rotate logs.</p></li> <li><p>Batch load the file to the database on a scheduled basis.</p></li> </ol> <p>There are many, many reasons to choose this architecture -- ease of scaling (write to many logs, load them to db), lack of reliance on a SPOF in the database (if something goes wrong, yo...
<p>Into file will be quicker, but into DB will be better.</p>
22,222
<p>Although I've been getting more and more familiar with Xcode while developing for the iPhone, there are times I just wished I had a better IDE, something like Eclipse.</p> <p>So I was wondering does anyone know how to migrate iPhone projects to Eclipse, and if it's worth it?</p>
<p>XCode largely uses standard Unix tools for a lot of its work. iPhone applications are compiled using GCC 4.0, it uses gdb for debugging, so it should be possible to set up Eclipse to at least compile applications. </p> <p>If you look in the Build section of the Project Info pane (select the project, hit the Info ...
<p>There are no plugins that support Apple IOS application development in Eclipse but on windows, you can develop using Adobe CS5. This is one of the powerful tool from Adobe in which you can develop .ipa applications on windows but you need some stuff to be ready before you start developing IOS applications using Adob...
25,463
<p>I am trying to read an Http response stream twice via the following:</p> <pre><code>HttpWebResponse response = (HttpWebResponse)request.GetResponse(); stream = response.GetResponseStream(); RssReader reader = new RssReader(stream); do { element = reader.Read(); if (element is RssChannel) { feed.Channels.A...
<p>Copy it into a new MemoryStream first. Then you can re-read the MemoryStream as many times as you like:</p> <pre><code>Stream responseStream = CopyAndClose(resp.GetResponseStream()); // Do something with the stream responseStream.Position = 0; // Do something with the stream again private static Stream CopyAndClo...
<p>have you tried resetting the stream position? if this does not work you can copy the stream to a MemoryStream and there you can reset the position (i.e. to 0) as often as you want.</p>
17,819
<p>For a System.Windows.Forms.TextBox with Multiline=True, I'd like to only show the scrollbars when the text doesn't fit.</p> <p>This is a readonly textbox used only for display. It's a TextBox so that users can copy the text out. Is there anything built-in to support auto show of scrollbars? If not, should I be usi...
<p>Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form. It's not quite perfect but ought to work for you.</p> <pre><code>using System; using System.Drawing; using System.Windows.Forms; public class MyTextBox : TextBox { private ...
<p>What Aidan describes is almost exactly the UI scenario I am facing. As the text box is read only, I don't need it to respond to TextChanged. And I'd prefer the auto-scroll recalculation to be delayed so it's not firing dozens of times per second while a window is being resized.</p> <p>For most UIs, text boxes with ...
9,879
<p>I want to simplify my execution of a Groovy script that makes calls to an Oracle database. How do I add the ojdbc jar to the default classpath so that I can run:</p> <pre><code>groovy RunScript.groovy </code></pre> <p>instead of:</p> <pre><code>groovy -cp ojdbc5.jar RunScript.groovy </code></pre>
<p>Summarized from <em>Groovy Recipes</em>, by Scott Davis, <strong>Automatically Including JARs in the ./groovy/lib Directory</strong>:</p> <ol> <li>Create <code>.groovy/lib</code> in your login directory</li> <li><p>Uncomment the following line in ${GROOVY_HOME}/conf/groovy-starter.conf</p> <p><code>load !{user.hom...
<p><code>groovy</code> is just a wrapper script for the Groovy JAR that sets up the Java classpath. You could modify that script to add the path to your own JAR, as well, I suppose.</p>
31,733
<p>Has anybody experience in building a custom style in Qt? What I have in my mind is a complete new style that affects all kind of widgets. I have seen some examples in the web for a custom combo box. But I have no idea how much time and code it takes to build a "complete" new custom style ... maybe someone can give m...
<p>Check out the <a href="http://doc.qt.io/qt-4.8/stylesheet.html" rel="nofollow noreferrer">Stylesheets</a> facility in Qt 4. While it's still a hassle, it's way easier than doing a full-on custom style. You can just adjust one visual facet at a time and try it out.</p> <p>It pays attention to inheritance. So if y...
<p>If you don't need to radically change the widget style, you might want to try using widget style sheets:</p> <pre><code> http://doc.qt.digia.com/4.4/stylesheet.html </code></pre>
9,236
<p>You can see small gaps in the print which looks like under extrusion (see image below). What is the reason for that?</p> <p>I've tried smaller retracting distances. Temperature looks stable.</p> <p>Print settings:</p> <ul> <li>PETG from Extruder</li> <li>245&nbsp;°C Printing temperature</li> <li>50&nbsp;mm/s prin...
<p>Here's your problem:</p> <blockquote> <ul> <li>1&nbsp;mm retraction distance -> stringing...</li> </ul> </blockquote> <p>If you have stringing, that means that material that was supposed to end up as part of printed lines instead ended up somewhere else, leaving less material (underextrusion) where it was ac...
<p>I increased the retracting distance to 1.5mm. Speed was set to 30mm/s Printing temperature is still 245°C</p> <p>The screw which is pressing the filament to the drive gear was too tight. So the stepper lost steps.</p> <p>-> No stringing and no under extrusion anymore. prints are looking good now.</p>
1,456
<p>The extruder on my Prusa i3 MK3S keeps clogging while printing. Loading is fine, and each time it clogs, unloading and loading the filament seems to work. The filament extruded just after resolving a clog looks like it has small bubbled on it.</p> <p>The problem only seems to happen when printing certain models. Pr...
<p>My problem was 2 things. The <strong>heatbreak</strong>, which was switched out for the MK2 version(Explantation below). And the <strong>Teflon Tube</strong> that runs down the heatsink.</p> <h2>Heatbreak</h2> <p>Change the heat-break to a generic E3D one. You can order the heatbreak for the <strong>MK2</strong> f...
<p>The problem with low layer heights is that the filament flow is low, this means that the filament is at prolonged times at temperature, filament cooking can cause clogging. Try increasing the layer height to 0.2&nbsp;mm to observe if the same clogging problems still occur, furthermore, try lowering the extrusion tem...
1,511
<p>I have a GPS from u-blox.com with a USB-connection and driver. The driver installs a virual COM port that pops up when you plug the USB in. Using a hyperterminal I can then watch the flow of data from the GPS.</p> <p>Then I want the data in my program, not so easy...</p> <p>I have implemented some methods using th...
<p>If you can communicate with the GPS using HyperTerminal then in principle there's no reason why you shouldn't be able to in C#. Are you sure you've configured the serial port correctly, particularly the baud rate, data bits, stop bits, parity, and flow control settings?</p> <p>You could use SysInternals <a href="ht...
<p>I ran into a similar problem in an application I was writing and the problem turned out to be that I was trying to us <code>SerialPort.WriteLine</code> which sends a <code>\r\n</code> to end the line when I really needed to just send <code>\n</code>. When I switched to <code>SerialPort.Write</code> with a <code>\n<...
36,065
<p>I am in the middle of implementing an application using ASP.NET MVC and would love to cache the data passed to user controls or the output rendering on some user controls that I render using the Html.RenderPartial, that way I don't have to query the DB with every request I do to the controller for a new view.</p>
<p>That appears to be one of those 1 million dollar questions!</p> <p>It seems that a lot of people are having that problem, but the solution is not trivial.</p> <p>Check out an <a href="http://www.codeplex.com/aspnet/WorkItem/View.aspx?WorkItemId=2062" rel="nofollow noreferrer">issue reported recently</a> on the ASP...
<p>I would maybe suggest using the sub controllers from the MVC Contrib and then caching the controller's method using the OutputCache stuff.</p>
22,611
<p>When working in a big project that requires debugging (like every project) you realize how much people love "printf" before the IDE's built-in debugger. By this I mean</p> <ul> <li>Sometimes you need to render variable values to screen (specially for interactive debugging).</li> <li>Sometimes to log them in a file<...
<p>Don't commit debugging code, just debuggin tools.</p> <p>Loggin OTOH has a natural place in execption handling routines and such. Also a few well placed logging statments in a few commonly used APIs can be good for debugging.</p> <p>Like one log statment to log all SQL executed from the system.</p>
<p>My vote would be with what you described as a friendly tracker class. This class would keep all of that centralized, and potentially even allow you to change debug/logging strategies dynamically.</p> <p>I would avoid things like Macros simply because that's a compiler trick, and not true OO. By abstracting the co...
40,344
<p>In C++, there isn't a de-facto standard logging tool. In my experience, shops roll their own. This creates a bit of a problem, however, when trying to create reusable software components. If everything in your system depends on the logging component, this makes the software less reusable, basically forcing any do...
<p>Yes. But dependency injection will help in this case.</p> <p>You can create an abstract logging base-class and create implementations for the logging-frameworks you want to use. Your components are just dependent on the abstract base-class. And you inject the implementations along with al their dependencies as need...
<p>If you are looking to build libraries which wont be recompiled, but want to provide a logging interface then perhaps a good way is to allow the user (of the library) to provide a callback.</p> <p>On initialising logging with your library, they would need to specify the callback, and then the glue-code is up to them...
6,035
<p>When considering using performance counters as my companies' .NET based site, I was wondering how big the overhead is of using them. </p> <p>Do I want to have my site continuously update it's counters or am I better off to only do when I measure?</p>
<p>The performance impact is negligible in updating. Microsoft's intent is that you always write to the performance counters. It's the monitoring of (or capturing of) those performance counters that will cause a degradation of performance. So, only when you use something like perfmon to capture the data.</p> <p>In ...
<p>The thing that I have found is that it is not that slow for the majority of applications. I wouldn't put one in a tight loop, or something that is called thousands of times a second.</p> <p>Secondly, I found that programmatically creating the performance counters is very slow, so make sure that you create them bef...
37,056
<p>I'm looking for a good plugin for doing web front end work in Eclipse. I don't want something that completely takes over eclipse, or something that has masses of dependencies that need to be updated all the time, or something that is geared towards a particular server-side platform, or something that costs a heap.</...
<p>Sounds like you need the <a href="http://www.eclipse.org/webtools/" rel="nofollow noreferrer">Web Tools Project</a></p> <p>Update: In latest 2016 Eclipse Neon, go to HELP -> Install Software and search for Eclipse Web Developer tools. For some reason it's hard to find them from the Marketplace.</p> <p><a href="h...
<p>As of now, Eclipse Juno has great HTML/CSS/XML/JS editors, with the PDT a good plugin for PHP</p>
41,739
<p>I am using Fluent NHibernate and having some issues getting a many to many relationship setup with one of my classes. It's probably a stupid mistake but I've been stuck for a little bit trying to get it working. Anyways, I have a couple classes that have Many-Many relationships. </p> <pre><code>public class Person ...
<p>The fact that it is adding two records to the table looks like you are missing an <a href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#example-many-to-many-mapping-file" rel="noreferrer">inverse attribute</a>. Since both the person and the group are being changed, NHibernate is persisting the r...
<p>Are you making sure to add the Person to the Groups.Admin? You have to make both links.</p>
13,375
<p>I have a container div that holds two internal divs; both should take 100% width and 100% height within the container.</p> <p>I set both internal divs to 100% height. That works fine in Firefox, however in IE the divs do not stretch to 100% height but only the height of the text inside them.</p> <p>The following i...
<p>I think "works fine in Firefox" is in the <strong>Quirks mode</strong> rendering only. In the <strong>Standard mode</strong> rendering, that might not work fine in Firefox too.</p> <p>percentage depends on "containing block", instead of viewport.</p> <p><a href="http://www.w3.org/TR/CSS21/visudet.html#the-height-p...
<p>I don't think IE supports the use of auto for setting height / width, so you could try giving this a numeric value (like Jarett suggests).</p> <p>Also, it doesn't look like you are clearing your floats properly. Try adding this to your CSS for #container:</p> <pre><code>#container { height:100%; width:100%...
20,834
<p>How do I create a button control (with <code>CreateWindow</code> of a <code>BUTTON</code> window class) that has a standard system-wide size (especially height) that's consistent with the rest of Windows applications? I should of course take DPI into account and probably other settings.</p> <blockquote> <p><stron...
<h2>In the perfect, hassle-free world...</h2> <p>To create a standard size button we would have to do this:</p> <pre><code>LONG units = GetDialogBaseUnits(); m_hButton = CreateWindow(TEXT("BUTTON"), TEXT("Close"), WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 0, 0, MulDiv(LOWORD(units)...
<p>@macbirdie: you should NOT use GetDialogBaseUnits(), it is based on the default system font (Ugly bitmap font). You should use MapDialogRect()</p>
8,301
<p>I am used to TYPO3 where I just can upload an image within the content element an then just determine the size an so on.</p> <p>Is there a way to handle images in drupal somehow like this?</p>
<p>Image upload support for Drupal is a bit of a jungle. </p> <p>The most basic way to do this is with image.module and img_assist. This will add a link below each textarea allowing an upload, and when you upload one it inserts a custom tag into the content body that specifies the image, its title, its size and alignm...
<p>I'm just starting to learn about drupal, but here are some of my finds in the Drupal-image-gallery department - perhaps one of these will do what you want:</p> <p><a href="http://www.developmentseed.org/blog/2007/oct/24/unlimited-images-your-content-drupal-and-flickr" rel="nofollow noreferrer">Flickrup</a></p> <p>...
14,852
<p>My product has several components: ASP.NET, Windows Forms App and Windows Service. 95% or so of the code is written in VB.NET.</p> <p>For Intellectual Property reasons, I need to obfuscate the code, and until now I have been using a version of dotfuscator which is now over 5 years old. I'm thinking it is time to mo...
<p>Back with .Net 1.1 obfuscation was essential: decompiling code was easy, and you could go from assembly, to IL, to C# code and have it compiled again with very little effort.</p> <p>Now with .Net 3.5 I'm not at all sure. Try decompiling a 3.5 assembly; what you get is a long long way from compiling.</p> <p>Add th...
<p>I tried Eziriz demo version....I liked it. But never brought the software.</p>
2,464
<p>Usercontrol with button - When uc is added dynamically to another page I loose the button handler.</p> <p>ie: I have 1 usercontrol with 1 button - the button has an event handler in the code behind. When i add the UserControl to a page programatically the button handler does not fire. Any idea of an easy way to f...
<p>You'll be using Page.LoadControl to add the ascx control in the page's OnInit event handler (although I've done so in Load event handler and it works, but the documentation specifies OnInit)</p> <p>Your user control (and page) should wire up their events for every load and postback e.g. this.buttonID.Click += new S...
<p>Sometimes when you dynamically add controls to a page the button event handlers get messed up because the IDs of the controls get out of sync. But again I would need to see how you are dynamically loading the controls. </p>
26,698
<p>So when my Prusa I3 is heating up, a small bit of filament is coming out of the nozzle, forming a small string at.</p> <p>When the printing starts, this results in a small plastic ball on the bed, impacting the overall printing process.</p> <p>How can I avoid this?</p>
<p>On my Kossel Mini I programmed it to go to the edge of the bed and purge a small amount of filament which creates a dot. I purge enough to get the dot to stick to the bed and then go on with printing, when the head moves the dot stays attached and usually pulls excess material off the nozzle. This can be added to ...
<p>I just go and pull it off the print head with pliers when it's about to start and sometimes shortly after it starts printing, but its probably not the safest way to deal with the problem. Printing a skirt, brim, or raft should help to fix the problem.</p>
574
<p>I'm trying to consume a webmethod but it seems that my application can't resolve DNS. The problem surfaces when I configure my application with an url (e.g.: <a href="http://mywebservice.com/webservice/methods.asmx" rel="nofollow noreferrer">http://mywebservice.com/webservice/methods.asmx</a>), but it does not when ...
<p>Have you tried confirming the same DNS query works via nslookup <em>from the same system on which your application runs</em>?</p> <p>I.e.,</p> <pre>C:\>nslookup Default Server: whatever.dns.example.org Address: 111.222.333.111 > set q=a > mywebservice.com Server: whatever.dns.example.org Address: 111.222.333....
<p>Digging a little bit more I found that there is a proxy in between my PC and the server. Therefore, I'm oblied to log with a valid user in order to access the internet. The problem <b>was</b> that my application's server (where the IIS is running) was configured to run using anonymous access. All I had to do was to ...
27,866
<p>My understanding is that C# and java differ with respect to generics in some ways, one of which is that generic type parameters are available at runtime in C#/.NET but not in Java. Why did the Java language designers do it this way? </p>
<p>To allow binary compatibility with pre-generics bytecode, therefore allowing new code to interface with old code.</p> <p>From the <a href="http://java.sun.com/docs/books/tutorial/java/generics/erasure.html" rel="nofollow noreferrer">Type Erasure</a> page of The Java Tutorials:</p> <blockquote> <p>Type erasure en...
<p>I remember reading something about this in the book Hardcore Java:</p> <blockquote> <p>The problem with checking elements in a collection at runtime is that it is extremely expensive; the order of efficiency is only O(n). If you have only 10 addresses in your collection, checking elements is easy. Howev...
48,830
<p>With a huge influx of newbies to Xcode, I'm sure there are lots of Xcode tips and tricks to be shared.</p> <p>What are yours? </p>
<h2>Switch to Header/Source File</h2> <blockquote> <ul> <li><p><kbd>Option ⌥</kbd> <kbd>Command ⌘</kbd> <kbd>Up Arrow ↑</kbd></p> </li> <li><p><strong>View</strong> &gt; <strong>Switch to Header/Source File</strong></p> </li> </ul> </blockquote> <p>Switches between the <code>.m</code> and <code>.h</code> files.</p> <bl...
<p>I came into Xcode right from Windows world (as MANY others), and one of the first quirks which I was faced to, was trying to "indent a selected block of text" with the TAB key.</p> <p>Typically, when using a Windows editor, you select a block of text, and whenever you press TAB (or shift TAB) keys, the selected tex...
17,618
<p>I'm a Scrum newbie and looking to implement Scrum in my company. Obtaining buy-in is not a problem, it is my company and the developers are more than happy to work like this.</p> <p>The problem is that 75% of our revenue is derived from fixed length/fixed price projects. </p> <p>Ken Schwaber in his book, Agile Pro...
<p>Yes. I think you can. See <a href="http://homepage.mac.com/s_lott/iblog/architecture/C551260341/E20080211062302/index.html" rel="noreferrer">The Waterfall's Not Working</a>. </p> <p>The "getting outside the fixed-price box" isn't that hard a conversation to have. Customers have seen failures also. They've seen...
<p>I'm not sure about the bidding and profits but the scrum methodology can certainly be applied to a fixed-length/price project. If the requirements are known and solid they can be put in the product backlog and the sprints can be planned according to the requirements and the time limit. You can still leverage the ben...
33,249
<p>Personally I like this one:</p> <p><img src="https://i.stack.imgur.com/ZNtvc.jpg" alt=""></p> <p>P.S. Do not hotlink the cartoon without the site's permission please. </p>
<p>Another one from <a href="http://xkcd.com/327/" rel="nofollow noreferrer">xkcd</a> <img src="https://imgs.xkcd.com/comics/exploits_of_a_mom.png" alt="Exploits of a Mom" title="Her daughter is named Help I&#39;m trapped in a driver&#39;s license factory."></p>
<p><img src="https://i.somethingawful.com/jeffk/computarfunnys/4-17-00-02.gif" alt="alt text"></p>
11,010
<p>Has anyone considered using something along the lines of the Amazon SimpleDB data store as their backend database?</p> <p>SQL Server hosting (at least in the UK) is expensive so could something like this along with cloud file storage (S3) be used for building apps that could grow with your application.</p> <p>Grea...
<p>This is a good analysis of Amazon services from <a href="http://www.25hoursaday.com/weblog/2008/08/21/SomeThoughtsOnAmazonsElasticBlockStore.aspx" rel="nofollow noreferrer">Dare</a>.</p> <p><em>S3 handled what I've typically heard described as "blob storage". A typical Web application typically has media files and ...
<p>But do you really need SQL Server? Can't you live with PostgreSQL or MySQL? Both have proven to be ok for most tasks. </p> <p>Now if you need SQL Server features then you're out of luck. </p> <p>Another option is to rent a server. How expensive is expensive?</p> <p>(I've used Amazon S3 to store images for an appl...
7,723
<p>varchar(255), varchar(256), nvarchar(255), nvarchar(256), nvarchar(max), etc?</p> <p>256 seems like a nice, round, space-efficient number. But I've seen 255 used a lot. Why?</p> <p>What's the difference between varchar and nvarchar?</p>
<p>VARCHAR(255). It won't use all 255 characters of storage, just the storage you need. It's 255 and not 256 because then you have space for 255 plus the null-terminator (or size byte).</p> <p>The "N" is for Unicode. Use if you expect non-ASCII characters.</p>
<p>If you will be supporting languages other than English, you will want to use nvarchar.</p> <p>HTML should be okay as long as it contains standard ASCII characters. I've used nvarchar mainly in databases that were multi-lingual support. </p>
7,812
<p>We're developing a windows mobile 6.1 application and would like to make the user interface look better than the standard battleship grey. Has anyone had any experience with 3rd party controls that can make a windows mobile app look like a WPF/Silverlight/Iphone - like interface?</p>
<p>There might be some useful-ish replies in <a href="https://stackoverflow.com/questions/35907/3rd-party-ui-components-for-net-compact-framework">this</a> question.</p>
<p>There might be some useful-ish replies in <a href="https://stackoverflow.com/questions/35907/3rd-party-ui-components-for-net-compact-framework">this</a> question.</p>
21,030
<p>Say you have 2 database servers, one database is the 'master' database where all write operations are performed, it is treated as the 'real/original' database. The other server's database is to be a mirror copy of the master database (slave?), which will be used for read only operations for a certain part of the ap...
<p>What you want is called Transactional Replication in SQL Server 2005. It will replicate changes in near real time as the publisher (i.e. "master") database is updated.</p> <p><a href="http://blogs.techrepublic.com/howdoi/?p=123" rel="nofollow noreferrer">Here is a pretty good walk through of how to set it up.</a><...
<p>The answer to this will vary depending on the database server you are using to do this.</p> <p>Edit: Sorry, maybe i need to learn to look at the tags and not just the question - i can see you tagged this as sqlserver.</p>
3,403
<p>when a System.Web.HttpResponse.End() is called a System.Thread.Abort is being fired, which i'm guessing is (or fires) an exception? I've got some logging and this is being listed in the log file...</p> <p>A first chance </p> <pre><code>exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib....
<p>There is no such thing as a "graceful" abort. You could simply Flush() the response, though, instead of ending it and let the framework take care of closing the connection for you. I'm assuming in this case that you want the response sent to the client, i.e., the typical case.</p> <p>According to <a href="http://...
<p>Don't use Response.End() method because it uses Application.End() and stop the application. Further use HTTP request or response violating Page Life Cycle. Use HttpContext.Current.Response.Close() or HttpContext.Current.ApplicationInstance.CompleteRequest(); </p>
47,682
<p>I am not able to access localhost https pages in firefox3. It gave the error </p> <blockquote> <p>'Can't connect securely because the SSL protocol has been disabled. (Error code: ssl_error_ssl_disabled)'</p> </blockquote> <p>I enabled all the SSL2 related preferences through about:config and the error changed ...
<p>I think that it's better to use simply <a href="http://www.php.net/str_replace" rel="noreferrer">str_replace</a>, like the manual says:</p> <blockquote> <p>If you don't need fancy replacing rules (like regular expressions), you should always use this function instead of ereg_replace() or preg_replace().<...
<p>While a regexp would suit here just fine, I'll present you with an alternative method. It <em>might</em> be a tad faster than the equivalent regexp, but life's all about choices (...or something).</p> <pre><code>$length = strlen($urlString); for ($i=0; $i&lt;$length; i++) { if ($urlString[$i] === '?') { $urlS...
33,130
<p>To sketch the background of this question : at work we use Dell Precision workstations. My current one has got an NVidia Quadro FX1700. My team is developing the graphics components for a real time data acquisition system. So we are always looking out to see if the graphics operations don't use up too much CPU time....
<p>GDI works by calling various functions in the graphics device driver. There are a core set of functions that every driver <em>must</em> implement. Other functions may be implemented by the driver. If they are not, GDI will perform those functions itself.</p> <p>If a particular function is not implemented in hardwar...
<p>Vista has a new <a href="http://msdn.microsoft.com/en-us/library/aa480220.aspx" rel="nofollow noreferrer">display driver architecture</a> which would provide an opportunity for a dramatic increase in performance. Are you comparing like hardware/OS combinations?</p>
17,135
<p>During development (and for debugging) it is very useful to run a Java class' <em>public static void main(String[] argv)</em> method directly from inside Eclipse (using the Run As context menu).</p> <p>Is there a similarily quick way to specify command line parameters for the run? What I do now is go to the "Run D...
<p>This answer is based on Eclipse 3.4, but should work in older versions of Eclipse.</p> <p>When selecting Run As..., go into the run configurations.</p> <p>On the Arguments tab of your Java run configuration, configure the variable ${string_prompt} to appear (you can click variables to get it, or copy that to set i...
<p>Another idea:</p> <p>Place all your parameters in a properties file (one parameter = one property in this file), then in your main method, load this file (using <code>Properties.load(*fileInputStream*)</code>). So if you want to modify one argument, you will just need to edit your args.properties file, and launch y...
48,823
<p>I am using CCNET on a sample project with SVN as my source control. CCNET is configured to create a build on every check in. CCNET uses MSBuild to build the source code.</p> <p>I would like to use the latest revision number to generate <code>AssemblyInfo.cs</code> while compiling. How can I retrieve the latest revi...
<p>CruiseControl.Net 1.4.4 has now an <a href="http://confluence.public.thoughtworks.org/display/CCNET/Assembly+Version+Labeller" rel="noreferrer">Assembly Version Labeller</a>, which generates version numbers compatible with .Net assembly properties.</p> <p>In my project I have it configured as:</p> <pre><code>&lt;l...
<p>Be careful. The structure used for build numbers is only a short so you have a ceiling on how high your revision can go.</p> <p>In our case, we've already exceeded the limit.</p> <p>If you attempt to put in the build number 99.99.99.599999, the file version property will actually come out as 99.99.99.10175.</p>
2,358
<p>I'm quite familiar with the reasons for wanting to copy a property vs. retain. (Essentially the value vs. relationship argument. You almost always want to copy strings, for example.)</p> <p>What about NSColor and NSGradient? </p> <p>They both conform to NSCopying, but as currently implemented, are immutable.</p> ...
<p>Subclasses of NSColor and NSGradient that are assigned to your properties may not be immutable or referentially transparent, so you should still use the same logic for determining retain vs copy that you would for any object that has commonly used mutable subclasses, even though in practice it is unlikely to matter ...
<p>Subclasses of NSColor and NSGradient that are assigned to your properties may not be immutable or referentially transparent, so you should still use the same logic for determining retain vs copy that you would for any object that has commonly used mutable subclasses, even though in practice it is unlikely to matter ...
33,061
<p>I'm using:</p> <pre><code>FileInfo( System.Environment.GetFolderPath( System.Environment.SpecialFolder.ProgramFiles) + @"\MyInstalledApp" </code></pre> <p>In order to determine if a program is detected on a users machine (it's not ideal, but the program I'm looking for is a right old kludge of a M...
<p>The function below will return the x86 <code>Program Files</code> directory in all of these three Windows configurations:</p> <ul> <li>32 bit Windows</li> <li>32 bit program running on 64 bit Windows</li> <li>64 bit program running on 64 bit windows</li> </ul> <p>&nbsp;</p> <pre><code>static string ProgramFilesx8...
<p>One-liner using the new method in .NET. Will always return x86 Program Files folder.</p> <p><code>Environment.Is64BitOperatingSystem ? Environment.GetEnvironmentVariable("ProgramFiles(x86)") : Environment.GetEnvironmentVariable("ProgramFiles"))</code></p>
23,591
<p>I am writing a client-side <strong>Swing</strong> application (graphical font designer) on <strong>Java 5</strong>. Recently, I am running into <code>java.lang.OutOfMemoryError: Java heap space</code> error because I am not being conservative on memory usage. The user can open unlimited number of files, and the prog...
<p>Ultimately you always have a finite max of heap to use no matter what platform you are running on. In Windows 32 bit this is around <code>2GB</code> (not specifically heap but total amount of memory per process). It just happens that Java chooses to make the default smaller (presumably so that the programmer can't c...
<p>If everything else fails, in addition to increasing the max heap size try also increasing the swap size. For Linux, as of now, relevant instructions can be found in <a href="https://linuxize.com/post/create-a-linux-swap-file/" rel="nofollow noreferrer">https://linuxize.com/post/create-a-linux-swap-file/</a>.</p> <p...
5,799
<p>How do I make icons for my exe file when compiling my Python program?</p>
<p>I was searching for this a while ago, and found this: <a href="http://www.mail-archive.com/pygame-users@seul.org/msg05619.html" rel="nofollow noreferrer">http://www.mail-archive.com/pygame-users@seul.org/msg05619.html</a></p> <p>Quote from above link:</p> <blockquote> <p>The setup.py File: PY_PROG =</p> <p>'trek10.p...
<p>I have no experience with py2exe but a quick <a href="http://www.google.com/search?q=py2exe+embed+icon" rel="nofollow noreferrer">google search</a> found <a href="http://www.py2exe.org/index.cgi/CustomIcons" rel="nofollow noreferrer">this</a>, if <em>embedding</em> icons in exe files was what you asked for. </p> <...
36,874
<p>How do you draw a custom button next to the minimize, maximize and close buttons within the Titlebar of the Form?</p> <p>I know you need to use Win32 API calls and override the WndProc procedure, but I haven't been able to figure out a solution that works right.</p> <p>Does anyone know how to do this? More specifi...
<p>The following will work in XP, I have no Vista machine handy to test it, but I think your issues are steming from an incorrect hWnd somehow. Anyway, on with the poorly commented code.</p> <pre><code>// The state of our little button ButtonState _buttState = ButtonState.Normal; Rectangle _buttPosition = new Rectangl...
<p>Drawing seems to be the easy part, the following will do that:</p> <p>[Edit: Code removed, see my other answer]</p> <p>The real problem is changing the state and detecting clicks on the button... for that you'll need to hook into the global message handler for the program, .NET seems to hide the mouse events for a...
13,249
<p>We are using Linq To SQL with our own data context logic that executes the one linq query across multiple databases. When we get the results back, we need the database for each of the rows. So...</p> <p>I want to have a property on my class that will return the database name (SQL Server, so DB_NAME()). How can I...
<p>I tried to do that recently and couldn't get it to work. What I ended up doing is sending a variable at startup. So say you have an environment variable called $LOG_LEVEL:</p> <pre><code>&lt;level value="${log_level}" /&gt; </code></pre> <p>and at startup...</p> <pre><code>java -Dlog_level=$LOG_LEVEL your_app </c...
<p>Create a system variable. I prefer to use setenv.bat for such variables.</p> <pre><code>@echo off rem app specific log dir set "APP_LOG_ROOTDIR=../app/app-log" exit /b 0 </code></pre> <p>Add reference in log4j.xml file</p> <pre><code>&lt;appender name="fileAppender" class="org.apache.log4j.RollingFileAppender"&gt...
24,564
<p>I have implemented a python webserver. Each http request spawns a new thread. I have a requirement of caching objects in memory and since its a webserver, I want the cache to be thread safe. Is there a standard implementatin of a thread safe object cache in python? I found the following </p> <p><a href="http://fres...
<p>Well a lot of operations in Python are thread-safe by default, so a standard dictionary should be ok (at least in certain respects). This is mostly due to the GIL, which will help avoid some of the more serious threading issues.</p> <p>There's a list here: <a href="http://coreygoldberg.blogspot.com/2008/09/python...
<p>For a thread safe object you want threading.local:</p> <pre><code>from threading import local safe = local() safe.cache = {} </code></pre> <p>You can then put and retrieve objects in <code>safe.cache</code> with thread safety.</p>
26,239
<p>Is it possible to change the font size used in a ContextMenu using the .NET Framework 3.5 and C# for a desktop application? It seems it's a system-wide setting, but I would like to change it only within my application.</p>
<p>If you are defining your own context menu via a <code>ContextMenuStrip</code> in Windows Forms, use the <em>Font</em> property.</p> <p>If you are defining your own context menu via a <code>ContextMenu</code> in WPF, use the various <em>Fontxxx</em> properties such as <em>FontFamily</em> and <em>FontSize</em>.</p> ...
<p>You mention .NET 3.5 - are you writing in WPF? If so, you can specify font size for the TextBlock.FontSize attached property</p> <pre><code>&lt;Whatever.ContextMenu TextBlock.FontSize="12"&gt; &lt;MenuItem ... /&gt; &lt;!-- Will get the font size from parent --&gt; &lt;/Whatever.ContextMenu&gt; </code></pre> <p>...
12,211
<p>I have a couple of tables in a SQL 2008 server that I need to generate unique ID's for. I have looked at the "identity" column but the ID's really need to be unique and shared between all the tables. </p> <p>So if I have say (5) five tables of the flavour "asset infrastructure" and I want to run with a unique ID ...
<p>Why not use a GUID?</p>
<p>I found this when searching on google. I am facing a simillar problem for the first time. I had the idea to have a dedicated ID table specifically to generate the IDs but I was unsure if it was something that was considered OK design. So I just wanted to say THANKS for confirmation.. it looks like it is an adequate...
37,660
<p>This is something I've always wondered, and I can't find any mention of it anywhere online. When a shop from, say Japan, writes code, would I be able to read it in English? Or do languages, like C, PHP, anything, have Japanese translations that they write?</p> <p>I guess what I'm asking is does every single coder i...
<p>If I understood well the question actually is: &quot;does every single coder in the world know enough English to use the exact same reserved words as I do?&quot;</p> <p>Well.. English is not the subject here but programming language reserved words. I mean, when I started about 10 yrs ago, I didn't have any clue of ...
<p>I think WordBasic was localized. WordBasic was used to write macro's for in Word before VBA was used.</p> <p>If I remember it correctly, only WordBasic written in the English version would execute on all localized version. If you would write a Dutch version, you could only execute it on a Dutch Word.</p>
24,797
<p>Calling all PHP gurus!</p> <p>I understand that you can use getimagesize() to get the actual pixel height and width of an image in PHP. However, if you open an image in photoshop and look at the image size dialog, you notice that there is a resolution value that determines the print size of the image.</p> <p>Given...
<p>You could just read the JPEG file directly, bytes 14-18 specify:</p> <ul> <li>byte 14: 01, X and Y density unit specifier (00: none, pixel ratios, 01: DPI,02: DPC)</li> <li>bytes 15-16: horizontal pixel density,</li> <li>byte 16-18: vertical pixel densit</li> </ul> <p>Also see: <a href="http://www.obrador.com/esse...
<p>Depending on how the image is saved, EXIF contains a metric crapload of information - Read more about it in the <a href="http://php.net/exif" rel="nofollow noreferrer">PHP manual</a>. You may need to parse/process the results a bit, however (e.g. the flash info is, or at least has been, just a byte, expressing vario...
32,785
<p>That's basically the question, is there a "right" way to implement <code>operator&lt;&lt;</code> ? Reading <a href="http://bytes.com/forum/thread170304.html" rel="noreferrer">this</a> I can see that something like:</p> <pre><code>friend bool operator&lt;&lt;(obj const&amp; lhs, obj const&amp; rhs); </code></pre> <...
<p>The problem here is in your interpretation of the article you <a href="http://bytes.com/forum/thread170304.html" rel="noreferrer">link</a>.</p> <h3>Equality</h3> <p>This article is about somebody that is having problems correctly defining the bool relationship operators.</p> <p>The operator:</p> <ul> <li>Equalit...
<p><code>operator&lt;&lt;</code> implemented as a friend function:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; class Samp { public: int ID; string strName; friend std::ostream&amp; operator&lt;&lt;(std::ostream &amp;os, const Samp&amp; obj); }; std::ostream&amp;...
29,302
<p>I was trying to solve my <a href="https://stackoverflow.com/questions/254718/how-do-you-use-fonts-after-installing-xna">XNA Font problem</a>, when I found this <a href="http://www.xnaresources.com/pages.asp?pageid=33" rel="nofollow noreferrer">here</a>:</p> <blockquote> <p>Visual Studio doesn’t recognize any fo...
<p>I have successfully installed a <a href="http://www.proggyfonts.com/index.php?menu=download" rel="noreferrer">PROGGY</a> font. It was usable after I restarted VC6.</p> <p>I suspect they are talking about restarting your visual studio, instead of reinstalling your visual studio.</p>
<p>I'd imagine this is only true until you restart the IDE. Easy enough to test, isn't it?</p>
31,925
<p>I am working on an application which draws a simple dot grid. I would like the mouse to snap between the points on the grid, eventually to draw lines on the grid.</p> <p>I have a method which takes in the current mouse location (X,Y) and calculates the nearest grid coordinate.</p> <p>When I create an event and att...
<p>Don't modify the cursor position. You don't need to.</p> <p>Instead, <em>draw</em> as if it was snapped to the grid. When the user clicks somewhere, just draw the line from the nearest grid points.</p> <p>For instance, if the user clicks on (197,198), but you know that the nearest point actually is (200,200), just...
<p>I agree with ruijoel, do not mess with the cursor position. It is better to have a cross or a ring that is drawn at the snap point to show the user which point is the one that will be snapped to at a click event.</p> <p>For this to work well you may want to look at xor-drawing so that item is erased once you move t...
46,849
<p>A few years ago we started playing around with <a href="http://www.w3.org/MarkUp/Forms/" rel="noreferrer">XForms</a> from the W3C for a web app which required hundreds of custom forms.</p> <p>As they aren't currently supported natively by the major browsers, what parsers/tools are you using on your projects today?<...
<p>We use XForms for creating user interfaces for SOAP-based web services. Currently we settled with <strong>Chiba</strong> XForms engine (<a href="http://chiba.sourceforge.net/" rel="nofollow noreferrer">http://chiba.sourceforge.net/</a>), but <strong>Orbeon</strong> (<a href="http://www.orbeon.com" rel="nofollow nore...
<p>I do not use them and as they are not supported by any major browsers I doubt that anybody else will use them very often either.</p>
10,652
<p>Currently we have mutiple projects sharing a JIRA instances. We want to make it such that the users only view the projects that they are doing testing.</p> <p>But however we are currently groupging these users to the standard grouping jira-users.</p> <p>What is the best way to filter out JIRA project that only cer...
<p>Personally I'm all for project roles. I have a general permission scheme that allows all users/groups defined in project roles to browse the project, which leaves the project administrator/manager to define which groups can view their project. So by removing or adding jira-users (default group that a user would ha...
<p>The best and dynamic way of solving this problem is with the help of security levels and setting the security levels based on the issue at run time using a post function.</p>
30,619
<p>I'm working on a localized application which I develop in SharpDevelop. Based on a <a href="http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=211" rel="nofollow noreferrer">tutorial</a> I ran into an error:</p> <blockquote> <p>Could not find any resources appropriate for the specified culture (or...
<p>CreateFileBasedResourceManager will only deal with binary .resources files (not .resx files).</p> <p>If you insist on loading resources from external file rather than embed the resources into the assembly, you will need to run the resgen command line utility to generate a .resources file. So if you haven't done tha...
<p>I'm not sure what version of .NET you are using but this MSDN article on <a href="http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx" rel="nofollow noreferrer">how the runtime locates assemblies</a> may be of service to you.</p>
39,362
<p>What is the easiest way, preferably using recursion, to find the shortest root-to-leaf path in a BST (Binary Search Tree). Java prefered, pseudocode okay.</p> <p>Thanks!</p>
<p><strong>General description:</strong></p> <p>Use a <a href="http://en.wikipedia.org/wiki/Breadth-first_search" rel="noreferrer">Breadth-first search (BFS)</a> as opposed to a <a href="http://en.wikipedia.org/wiki/Depth-first_search" rel="noreferrer">Depth-first search (DFS)</a>. Find the first node with no childre...
<p>Breadth first search is exactly optimal in terms of the number of vertices visited. You have to visit every one of the vertices you'd visit in a breadth first search just in order to prove you have the closest leaf!</p> <p>However, if you have a mandate to use recursion, Mike Thompson's approach is <em>almost</em> ...
13,780
<p>I want to close a System.Windows.Forms.Form if the user clicks anywhere outside it. I've tried using IMessageFilter, but even then none of the messages are passed to PreFilterMessage. How do I receive clicks outside a form's window?</p>
<p>With thanks to <a href="https://stackoverflow.com/users/36388/p-daddy">p-daddy</a> in <a href="https://stackoverflow.com/questions/298626/what-do-these-wndproc-codes-mean">this question</a>, I've found this solution which allows me to use ShowDialog:</p> <pre><code>protected override void OnShown(EventArgs e) { ...
<p>If it is a child form in an MDI application, you could trap the click in the parent form, otherwise the solution will be messy.</p> <p>I am not convinced what you suggest represents intuitive UI behaviour anyway. Are you sure that is the best design?</p>
38,210
<p>I've got a new varchar(10) field in a database with 1000+ records. I'd like to update the table so I can have random data in the field. I'm looking for a SQL solution.</p> <p>I know I can use a cursor, but that seems inelegant.</p> <p>MS-SQL 2000,BTW</p>
<pre><code>update MyTable Set RandomFld = CONVERT(varchar(10), NEWID()) </code></pre>
<p>If this is a one time thing just to get data into the system I really see no issue with using a cursor as much as I hate cursors they do have their place. </p>
10,945
<p>I'm wondering if the need to alter the indentation of code to adjust the nesting has any adverse effects on merging changes in a system like SVN.</p>
<p>I've used python with SVN and Mercurial, and have no hassles merging.</p> <p>It all depends on how the diffing is done - and I suspect that it is character-by-character, which would notice the difference between one level of indent and another.</p>
<p>Generally source control systems merge on a line-by-line basis by default. I have found that merging Python code is no different from merging any other source code that is reasonably indented. If one programmer wraps a block of code in an <code>if</code> statement (indenting the whole block), and another programmer ...
14,522
<p>What I want to do is something like this: I have enums with combined flagged values.</p> <pre><code>public static class EnumExtension { public static bool IsSet&lt;T&gt;( this T input, T matchTo ) where T:enum //the constraint I want that doesn't exist in C#3 { return (input &amp; match...
<p><strong>EDIT: This is now live in version 0.0.0.2 of UnconstrainedMelody.</strong></p> <p>(As requested on my <a href="http://codeblog.jonskeet.uk/2009/09/10/generic-constraints-for-enums-and-delegates/" rel="noreferrer">blog post about enum constraints</a>. I've included the basic facts below for the sake of a sta...
<p>I just wanted to add Enum as a generic constraint.</p> <p>While this is just for a tiny helper method using <a href="https://www.github.com/Fody/ExtraConstraints" rel="nofollow noreferrer"><code>ExtraConstraints</code></a> is a bit too much overhead for me.</p> <p>I decided to just just create a <code>struct</code...
2,886
<p>I recently got an Ender 3 Pro and had a blast with it for the first few days, but then I got greedy for a better print and threw off my calibration with some &quot;upgrades&quot; and ended up with some really nasty elephant's foot. The first 3 mm are all bubbly and uneven as if someone heated it up and squished it s...
<p>The following is from the article &quot;<a href="https://all3dp.com/2/elephant-s-foot-3d-printing-problem-easy-fixes/" rel="nofollow noreferrer">Elephant's Foot - Easy Fixes</a>&quot; on All3DP.com</p> <blockquote> <p>As we’ve explained, elephant’s foot most often occurs as the result of an uncooled first layer. If ...
<p>I have 2 Ender 3 Max printers. Both suffered elephant's foot after the initial setup. After trying virtually every suggestion available on the internet I eventually was able to fix them. Assuming the bed is properly leveled, I feel the most common causes are:</p> <ol> <li>Too much tension on the X-axis guide whee...
2,036
<p>I'm running into a perplexing problem with an ActiveX control I'm writing - sometimes, Internet Explorer appears to fail to properly unload the control on process shutdown. This results in the control instance's destructor not being called.</p> <p>The control is written in C++, uses ATL and it's compiled using Visu...
<p>To debug a problem in COM with C++ where an object's (C++) destructor is not being called, the best approach is to focus on how the COM object's refcounts are being incremented or decremented. What is probably happening is that somebody is incrementing the refcount one too many times, and then not decrementing it t...
<p>Another approach - add cleanup code to your <a href="http://msdn.microsoft.com/en-us/library/ms682583.aspx" rel="nofollow noreferrer">DllMain</a> function (adding that function if it doesn't already exist). Then regardless of reference counts (and reference count errors), when your DLL is unloaded you can clean you...
9,090
<p>I am trying to iterate over all the elements of a static array of strings in the best possible way. I want to be able to declare it on one line and easily add/remove elements from it without having to keep track of the number. Sounds really simple, doesn't it?</p> <p>Possible non-solutions:</p> <pre><code>vector&l...
<p>C++ 11 added initialization lists to allow the following syntax:</p> <pre><code>std::vector&lt;std::string&gt; v = {"Hello", "World"}; </code></pre> <p>Support for this C++ 11 feature was added in at least <a href="http://gcc.gnu.org/projects/cxx0x.html" rel="noreferrer">GCC 4.4</a> and only in <a href="https://ms...
<pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;vector&gt; #include &lt;boost/assign/list_of.hpp&gt; int main() { const std::vector&lt; std::string &gt; v = boost::assign::list_of( "abc" )( "xyz" ); std::copy( v.begin(), v.end(), std::ostream_iterator&lt; std::...
5,540
<p>I'm printing with opaque grey PETG on glass. The intention is to produce a house number plate, so a shiny, production quality finish on the bottom. For this reason, extruding at 245&nbsp;°C with a bed at 95&nbsp;°C, to give a perfect glass finish with no filament lines showing. Smaller test versions have been very p...
<p>Are you using Z-hop? Is there any play in the Z-axis direction? It appears that parts of the first layer are printed much thinner than other parts.</p> <p>What can happen if there is a little play in the Z-axis direction that the nozzle doesn't return to the same level after a Z-hop movement (e.g. backlash in the l...
<p>PETG becomes transparent when the layers completely fuse. Translucency is from incomplete adhesion or voids left. Try small increases to flow or print width to get slightly better fill - or slow the speed (but speed might not affect how much material is output).</p> <p>Also, I see the top surface has a pattern on i...
1,581
<p>My question is how do I configure an EJB 3.0 style message driven bean to use a configured JMS datasource in jboss. </p> <p>For example, my MDB looks something like:</p> <pre><code>@MessageDriven(mappedName = "ExampleMDB", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", pr...
<p>bdfoy has the best large scale solution, but if you just want to install a few modules you can ask the CPAN shell to install a specific distribution by referencing a path to a tarball (relative to the top of the CPAN tree).</p> <pre><code>cpan&gt; install MSCHWERN/Test-Simple-0.62.tar.gz </code></pre> <p>Throw a U...
<p><a href="https://stratopan.com" rel="nofollow noreferrer">Stratopan.com</a> is another alternative. Stratopan provides private CPANs in the cloud. You can fill your Stratopan repository with specific versions of modules (and their dependencies) and then install them using the standard Perl tool chain. The reposit...
32,580
<p>I need to create and copy to the clipboard some RichText with standard "formatting" like bold/italics, indents and the like. The way I'm doing it now seems kind of inelegant... I'm creating a RichTextBox item and applying my formatting through that like so:</p> <pre><code>RichTextBox rtb = new RichTextBox(); Font ...
<p>You may want to suspend the layout of the richtextbox before you do all of that, to avoid unecessary flicker. That's one of the common mistakes I used to make which made it seem "inelegant"</p>
<p>I know it's been a while, but check out this stackoverflow post on converting rtf to html. It would probably be way easier to get your stuff into html, manipulate it, then either display it using html or convert it back to rtf.</p> <p><a href="https://stackoverflow.com/questions/439301/convert-rtf-to-html">Convert ...
16,478
<p>I'm trying to determine the best way to truncate or drop extra decimal places in SQL without rounding. For example:</p> <pre><code>declare @value decimal(18,2) set @value = 123.456 </code></pre> <p>This will automatically round <code>@value</code> to be <code>123.46</code>, which is good in most cases. However,...
<pre><code>select round(123.456, 2, 1) </code></pre>
<pre><code>select convert(int,@value) </code></pre>
6,567
<p>How can I make a Property "ReadOnly" outside the Assembly (DLL) for people using the DLL but still be able to populate that property from within the assembly for them to read?</p> <p>For example, if I have a <strong>Transaction</strong> object that needs to populate a property in a <strong>Document</strong> object ...
<p>C#</p> <pre><code>public object MyProp { get { return val; } internal set { val = value; } } </code></pre> <p>VB</p> <pre><code>Public Property MyProp As Object Get Return StoredVal End Get Friend Set(ByVal value As Object) StoredVal = value End Set End Property </code></pre>
<p>What language? In VB you mark the setter as Friend, in C# you use internal.</p>
49,580
<p>Currently I use the <a href="http://www.onepageprojectmanager.com/oppm/resource.html" rel="nofollow noreferrer">"One Page Project Manager" Excel Template</a> for project status reports. It contains a summary of last week's work and a forecast for the next week. For all important tasks we track, if they are comleted ...
<p>Status reporting should be brief (nobody likes to sit there for ages while every member of the team goes on and on about their status) so I'm a big fan of SOFT reports:</p> <ul> <li><strong>Successes</strong> - what have you achieved since the last status meeting: tasks directly off the project schedule. If possibl...
<p>Even if you're not using Agile you would still win from tracking your progress in functionality rather than in tasks.</p> <p>Your stakeholders most likely have no idea what '<em>refactor the t_sec_name table to add auto-increment to the identity column</em>' means and most likely would not care if it is completed o...
30,080
<p>I want to add my own member to the StringBuilder class, but when I go to create it IntelliSense doesn't bring it up.</p> <pre><code>public class myStringBuilder() Inherits System.Text.[StringBuilder should be here] .... end class </code></pre> <p>Is it even possible? thanks</p>
<p><code>StringBuilder</code> is <code>NotInheritable</code> (aka <code>sealed</code> in C#) so you cannot derive from it. You could try wrapping <code>StringBuilder</code> in your own class or consider using <a href="http://msdn.microsoft.com/en-us/library/bb384936.aspx" rel="nofollow noreferrer">extension methods</a>...
<p>StringBuilder is a sealed class... so inheritance is not allowed.</p>
21,610
<p>Sorry the title isn't more help. I have a database of media-file URLs that came from two sources: </p> <p>(1) RSS feeds and (2) manual entries. </p> <p>I want to find the ten most-recently added URLs, but a maximum of one from any feed. To simplify, table '<code>urls</code>' has columns <code>'url, feed_id, timest...
<p>Assuming feed_id = 0 is the manually entered stuff this does the trick: </p> <pre><code>select p.* from programs p left join ( select max(id) id1 from programs where feed_id &lt;&gt; 0 group by feed_id order by max(id) desc limit 10 ) t on id1 = id where id1 is not null or feed_id = 0 order by...
<p>You probably want a <a href="http://dev.mysql.com/doc/refman/5.0/en/union.html" rel="nofollow noreferrer">union</a>. Something like this should work:</p> <pre><code> (SELECT url, feed_id, timestamp FROM rss_items GROUP BY feed_id ORDER BY timestamp DESC LIMIT 10) UNION (SELECT ...
14,421
<p>Developing websites are time-consuming. To improve productivity, I would code a prototype to show to our clients. I don't worry about making the prototype comform to the standard. Most of the time, our clients would approve the prototype and give an unreasonable deadline. I usually end up using the prototype in prod...
<p>It is only worth the effort if it gives you a practical benefit. Sticking to standards might make it easier to build a website that works across most browsers. Then again, if you're happy with how a website displays on the browsers you care about (maybe one, maybe all), then going through hoops to make it pass valid...
<p>There are two rules for writing websites:</p> <ol> <li>The site must work for your users.</li> <li>The site must work for your users.</li> </ol> <p>To meet the first rule, you have to code such that your site renders correctly when using Internet Explorer. Unless you have the freedom to alter your site design to ...
14,556
<p>Are there common machines or OSs that will have problems connecting on a network where unicast ARP requests or broadcast ARP responses are not supported? I am providing a public Wi-Fi service, and considering blocking these types of ARP packet. Will this cause connectivity issues for contemporary clients?</p>
<p>The ARP specification has recently been updated with <a href="http://tools.ietf.org/rfcmarkup/5227" rel="nofollow noreferrer">RFC 5227</a> which talks about the use of gratuitous ARP packets for "address conflict detection".</p> <p>If you block ARP response broadcasts this ACD is not possible.</p>
<p>Broadcast ARP is used by some High-Availability IP-Takeover schemes to announce the new MAC-address on switch-over.</p>
49,705
<p>We are currently using BizTalk 2006 R2 to build Enterprise Integration solutions. We use BizTalk maps extensively, but when you build a solution in Visual Studio 2005, it produces the following warning against maps:</p> <blockquote> <p>Warning Double-click here to show/hide compiler links.</p> </blockquote> <p>I...
<p>I don't believe there's a way to suppress these for BizTalk projects. BizTalk gurus just learn to ignore them.</p>
<p>You can use the /nowarn option to suppress warnings.</p> <p>See <a href="http://msdn.microsoft.com/en-us/library/7f28x9z3(VS.80).aspx" rel="nofollow noreferrer">MSDN: /nowarn (Suppress Specified Warnings) (C# Compiler Options)</a>.</p>
22,152
<p>I learned something simple about SQL the other day:</p> <pre><code>SELECT c FROM myTbl GROUP BY C </code></pre> <p>Has the same result as:</p> <pre><code>SELECT DISTINCT C FROM myTbl </code></pre> <p>What I am curious of, is there anything different in the way an SQL engine processes the command, or are they tru...
<p><a href="https://stackoverflow.com/questions/164319/is-there-any-difference-between-group-by-and-distinct#164485">MusiGenesis</a>' response is functionally the correct one with regard to your question as stated; the SQL Server is smart enough to realize that if you are using "Group By" and not using any aggregate fu...
<p>There is no significantly difference between group by and distinct clause except the usage of aggregate functions. Both can be used to distinguish the values but if in performance point of view group by is better. When distinct keyword is used , internally it used sort operation which can be view in execution plan.<...
19,861
<p>This question comes up occasionally, but I haven't seen a satisfactory answer.</p> <p>A typical pattern is (row is a <strong>DataRow</strong>):</p> <pre><code> if (row["value"] != DBNull.Value) { someObject.Member = row["value"]; } </code></pre> <p>My first question is which is more efficient (I've flippe...
<p>I must be missing something. Isn't checking for <code>DBNull</code> exactly what the <a href="http://msdn.microsoft.com/en-us/library/3fwatee0.aspx" rel="noreferrer"><code>DataRow.IsNull</code></a> method does?</p> <p>I've been using the following two extension methods:</p> <pre class="lang-cs prettyprint-override...
<p>I always use :</p> <pre><code>if (row["value"] != DBNull.Value) someObject.Member = row["value"]; </code></pre> <p>Found it short and comprehensive.</p>
27,318
<p>I have a HTML with the following content:</p> <pre><code>... some text ... &lt;a href="file.aspx?userId=123&amp;section=2"&gt;link&lt;/a&gt; ... some text ... ... some text ... &lt;a href="file.aspx?section=5&amp;user=678"&gt;link&lt;/a&gt; ... some text ... ... some text ... </code></pre> <p>I would like to parse...
<p>Why use regex to split it out?</p> <p>You could first extrct the query string. Split the result on &amp; and then create a map by splitting the result from that on =</p>
<p>Using regex to first find the key value pairs and then doing splits... doesn't seem right.</p> <p>I'm interested in a complete regex solution.</p> <p>Anyone?</p>
40,341
<p>In asp.net is there any benefit to including or not including an id property? Assume for this question that there is no programtic reason why we need an ID. (We are not manipulating the control in code behind, nor on the client).</p> <p>My personal preference is only to include an Id property when I have a reason t...
<p>Having ID properties are useful for testing your page with a tool like Quick Test Pro, etc. They're also useful for blind users who browse with a screen reading tool.</p> <p>There's a good Hanselminutes podcast where this is discussed: <a href="http://www.hanselminutes.com/default.aspx?showID=143" rel="nofollow no...
<p>True, the only reason the ID exists is to get a handle on an individual object, but there is definitely no benefit to deleting the auto-assigned ID that VisualStudio creates for you. </p> <p>You never know when you may an ID, so I would at least recommend leaving the default if nothing else.</p>
46,136
<p>I've got a data object with a component in it that is an System.Collections.Generic.IList, and I'd like to reflect changes to that list into a Gtk# NodeView, so that when an item is added to the list, the NodeView will get a new item added to it. </p> <p>How would I listen for changes to an IList? I have consider...
<p>1) Concentrate on a properly normalized database design. I would say that when you are forced to make design tradeoffs in your code vs. database design, if performance is your goal, make tradeoffs in your object design instead of your database design. Understand that you aren't going to be able to do a proper supe...
<p>Linq to SQL is very slow unless you compile queries. Otherwise your application will be CPU bound as most of the time will be spend converting Expression trees into SQL. </p> <p>We are talking about 10x performance gain if you use compiled queries. Try it :)</p>
20,691
<p>How do I print debug messages in the Google Chrome JavaScript Console?</p> <p>Please note that the JavaScript Console is not the same as the JavaScript Debugger; they have different syntaxes AFAIK, so the <strong>print</strong> command in JavaScript Debugger will not work here. In the JavaScript Console, <code>prin...
<p>Executing following code from the browser address bar:</p> <pre> javascript: console.log(2); </pre> <p>successfully prints message to the "JavaScript Console" in Google Chrome.</p>
<p>Even though this question is old, and has good answers, I want to provide an update on other logging capabilities.</p> <p>You can also print with groups:</p> <pre><code>console.group(&quot;Main&quot;); console.group(&quot;Feature 1&quot;); console.log(&quot;Enabled:&quot;, true); console.log(&quot;Public:&quot;, tru...
26,801
<p>Despite the rather clear <a href="http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary620.html" rel="noreferrer">documentation</a> which says that <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/package.html#parseFloat()" rel="noreferrer">parseFloat()</...
<p>Because comparing anything to NaN is always false. Use isNaN() instead.</p>
<p>Documentation can be found in the Adobe Flex Language Reference <a href="http://livedocs.adobe.com/flex/2/langref/package.html#isNaN()" rel="nofollow noreferrer">Here</a> as well as other globally available functions.</p>
18,149
<p>I'm making a game and one of the methods calculates a character's base hit numbers based on skill values. The method currently calculates each value individually, since each skill can be used at short, medium, and long range.</p> <p>I originally thought I could combine the skills into a tuple and iterate over it, d...
<p>It feels like what you really want is a class representing the weapon, with attributes to handle the base values and calculate hit values with various modifiers. Here's a simple example:</p> <pre><code>SHORT_RANGE = 'S' MEDIUM_RANGE = 'M' LONG_RANGE = 'L' SHORT_RANGE_MODIFIER = 0.6 MEDIUM_RANGE_MODIFIER = 0.3 LONG_...
<p>@Vinko: perhaps make calcBaseHitNumbers, do the "if not self.calculatedBase:" check internally, and just no-op if it's been done before. That said, I can't see the pressing need for precalculating this information. But I'm no Python performance expert.</p>
29,428
<p>Is there any way of doing parallel assignment in C++? Currently, the below compiles (with warnings)</p> <pre><code>#include &lt;iostream&gt; int main() { int a = 4; int b = 5; a, b = b, a; std::cout &lt;&lt; "a: " &lt;&lt; a &lt;&lt; endl &lt;&lt; "b: " &lt;&lt; b &lt;&lt; endl; return 0; ...
<p>That's not possible. Your code example</p> <pre><code>a, b = b, a; </code></pre> <p>is interpreted in the following way:</p> <pre><code>a, (b = b), a </code></pre> <p>It does nothing. The comma operator makes it return the value of a (the right most operand). Because assignment binds tighter, b = b is in parens....
<p>Or Lua...<br> There are tricks with C/C++, like using xor or operations, but with risk of overflow and such. Just do it the painful way, with three assignments. Not a big deal.</p>
34,671
<p>Given a small set of entities (say, 10 or fewer) to insert, delete, or update in an application, what is the best way to perform the necessary database operations? Should multiple queries be issued, one for each entity to be affected? Or should some sort of XML construct that can be parsed by the database engine be ...
<p>It depends on how many you need to do, and how fast the operations need to run. If it's only a few, then doing them one at a time with whatever mechanism you have for doing single operations will work fine.</p> <p>If you need to do thousands or more, and it needs to run quickly, you should re-use the connection an...
<p>Most databases support BULK UPDATE or BULK DELETE operations. </p>
6,622
<p>can anybody please explain the following c# behaviour? I have written a small console application just to learn about CAS, but I can not seem to understand why the following lines of code work like they do:</p> <pre><code>string[] myRoles = new string[] { "role1", "role2", "role3" }; GenericIdentity myIdentity = ne...
<p>In .NET 4.0 SecurityManager.IsGranted has been made obsolete. </p> <p>This is what it was and if you compile in .NET 4.0 compatibility it will complain.</p> <pre><code>bool isGranted = SecurityManager.IsGranted(new SecurityPermission(SecurityPermissionFlag.Infrastructure)) </code></pre> <p>To fix it:</p> <pre><...
<p>I believe <code>SecurityManager.IsGranted</code> is mainly looking at code demands (the assembly etc) - not specific demands such as principal permissions.</p> <p>To do what you want:</p> <pre><code> static bool HasAccess(string role) { IPrincipal principal = System.Threading.Thread.CurrentPrincipal...
40,166
<p>I have the following query:</p> <pre><code>select column_name, count(column_name) from table group by column_name having count(column_name) &gt; 1; </code></pre> <p>What would be the difference if I replaced all calls to <code>count(column_name)</code> to <code>count(*)</code>?</p> <p>This question was inspired b...
<p><code>count(*)</code> counts NULLs and <code>count(column)</code> does not</p> <p>[edit] added this code so that people can run it</p> <pre><code>create table #bla(id int,id2 int) insert #bla values(null,null) insert #bla values(1,null) insert #bla values(null,1) insert #bla values(1,null) insert #bla values(null,...
<p>It is best to use</p> <pre><code>Count(1) in place of column name or * </code></pre> <p>to count the number of rows in a table, it is faster than any format because it never go to check the column name into table exists or not</p>
8,383
<p>I wanted to edit a log comment in the repository browser and received an error message that no pre-revprop-change hook exists for the repository. Besides having a scary name, what is a pre-revprop-change hook, and how do I create it?</p>
<p>For Windows, here's a link to an example batch file that only allows changes to the log message (not other properties):</p> <p><a href="http://ayria.livejournal.com/33438.html" rel="noreferrer">http://ayria.livejournal.com/33438.html</a></p> <p>Basically copy the code below into a text file and name it <code>pre-r...
<ol> <li>Go to SVN repo directory into the subfolder "hooks", e.g. "D:\SVN\hooks\" </li> <li>create the empty file "pre-revprop-change.bat" there</li> <li>in the file write "exit 0" (without "") and save it</li> <li>enjoy :)</li> </ol> <p>(This solution surely has drawbacks, as nothing is checked/prohibited. But for m...
23,989
<p>I have created a common library at work, and it is installed in the GAC on our test server. I've recently updated it and I want all of our applications to be using the update. I created a publisher policy assembly and installed it in the GAC along with the update, but when a web app loads Leggett.Common, 1.0.0.0, it...
<p>You're talking about code that would be shared library stuff. Static methods do have a place in shared libs. Check out System.Linq.Enumerable</p> <p>I'd follow these guidelines:</p> <ul> <li>These aren't static methods by default. They should only be static methods because they are naturally stateless (behavior ...
<p>Absolutely not. Utility modules over time turn into large collections of cruddy code.</p>
22,393
<p>I'd like to show/hide a column at runtime based on a particular condition. I'm using "Print when expression" to conditionally show/hide this column (and it's header) in my report. When the column is hidden, the space it would have occupied is left blank, which is not particularly attractive.</p> <p>I would prefer i...
<p>In later version (v5 or above) of jasper reports you can use the <code>jr:table</code> component and <strong>truly</strong> achieve this (without the use of java code as using dynamic-jasper or dynamic-reports).</p> <p>The method is using a <code>&lt;printWhenExpression/&gt;</code> under the <code>&lt;jr:column/&gt...
<p>If it is just one column, is it possible to place this column to the far right, and then use the print when expression. That way there is not a hole in the middle. I know this is not ideal, as I had tried to do what you are currently trying to accomplish in the past, and could not find what I call a good solution.</...
14,146
<p>I have an exe with an <code>App.Config</code> file. Now I want to create a wrapper dll around the exe in order to consume some of the functionalities.</p> <p>The question is how can I access the app.config property in the exe from the wrapper dll?</p> <p>Maybe I should be a little bit more in my questions, I have ...
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.openmappedexeconfiguration(VS.80).aspx" rel="noreferrer">ConfigurationManager.OpenMappedExeConfiguration Method</a> will allow you to do this.</p> <p>Sample from the MSDN page:</p> <pre><code>static void GetMappedExeConf...
<p>It's an xml file, you can use Linq-XML or DOM based approaches to parse out the relevant information.<br> (that said I'd question if there isn't a better design for whatever it is.. you're trying to achieve.)</p>
7,706
<p>I just wanted to compare different solutions used when implementing ACLs in Rails.</p>
<p>I use the authorization plugin (Created by <a href="http://www.billkatz.com/" rel="nofollow noreferrer">Bill Katz</a>):</p> <blockquote> <p>Roles can be authorized for the entire application, a model class, or a specific object. The plugin provides a way of checking authorization at the class or instance method l...
<p>There's a plugin called acl_system2 which operates by having a users table and a roles table. There's a lot more useful information in the <a href="http://github.com/ezmobius/acl_system2/tree/master/README" rel="nofollow noreferrer">README</a> and the project is on github too.</p>
14,393
<p>Is there any easy way to create an acronym from a string?</p> <pre><code>First_name Middle_name Last_name =&gt; FML first_name middle_name last_name =&gt; FML First_name-Middle_name Last_name =&gt; F-ML first_name-middle_name last_name =&gt; F-ML </code></pre>
<pre><code>Tokenize the string on whitespace. For each token1, Tokenize on dash. For each token2 Take token2[0] and capitalize if not first token2, prepend with dash Concatenate to result2 Concatenate to result </code></pre>
<p>I don't know about language agnostic, but I would make a function that accepts an args[] parameter to bring in all of your strings then loop through those and concatenate the first char of each onto another string which is returned.</p> <p>Edit: Strike that. Didn't realize it was a single string. You would have t...
28,653
<p>Greetings,</p> <p>I need a way (either via C# or in a .bat file) to get a list of all the computers on a given network. Normally, I use "net view", but this tends to work (from my understanding) only within your domain. I need the names (or at least the IP Addresses) of all computers available on my network. </...
<p><a href="http://nmap.org/" rel="noreferrer">Nmap</a> is good for this - use the -O option for OS fingerprinting and -oX "filename.xml" for <a href="http://nmap.org/book/man-output.html" rel="noreferrer">output</a> as xml that you can then parse from c#.</p> <p>A suitable commandline would be (where 192.168.0.0/24 i...
<p>Ping everything in the rage, then you can get netbios info from the systems that respond to identify it's name.</p>
13,118
<p>Ok so I am trying to print a new fusion 360 file that I converted into an STL and then into gcode using cura and I got the gcode loaded onto the SD card and mounted into my Monoprice 3D printer, Maker Select 3D Printer v2, and tried to do a print. Now here is the strange part. When I choose "print file" and then sel...
<p>Wash-away filament used for support in PLA printing is typically PVA, which is completely water soluble and may serve your purpose. It is easily 3D printed as the primary filament and attaches well to the build plate.</p> <p>Many 3D printer filament suppliers will carry this type of support material. It is importan...
<p>ABS dissolves in acetone. Indeed actone can be used to clean up 3D prints, see <a href="https://3dprinting.stackexchange.com/questions/4235/whats-smoother-acetone-treated-pla-or-abs/">What&#39;s smoother? Acetone treated PLA or ABS</a>. PLA maybe not somuch as ABS, see the same post.</p> <p>PLA dissolves in any chl...
911
<p>I have a windows application that I want to run as a windows service - how can I do this ?</p>
<p>Quick-n-dirty way, use the INSTSRV and SRVANY tools in the Windows Resource Kit: <a href="http://support.microsoft.com/kb/137890" rel="nofollow noreferrer">How To Create a User-Defined Service</a></p>
<p>In addition to XYNTService and SRVANY already recommended, you should consider <a href="http://www.CoreTechnologies.com/products/AlwaysUp" rel="nofollow noreferrer">AlwaysUp, a commercial product designed to run any application as a Windows Service</a>. You can try it free for 30 days to ensure that it will do the j...
46,932
<p>In Microsoft Oslo SDK CTP 2008 (using Intellipad) the following code compiles fine:</p> <pre><code>module M { type T { Text : Text; } } </code></pre> <p>while compiling the below code leads to the error "M0197: 'Text' cannot be used in a Type context"</p> <pre><code>module M { type T { ...
<p>The primary benefits of a CHUI (that is something with forms and fields, not necessarily command line interfaces) is the keyboard for navigation and consistent layout. That is key.</p> <p>If your GUI can be completely, and efficiently, keyboard navigated, then your CHUI user base should be happy. This is because in...
<p>As soon as you present some data, someone's going to want to query against it. You can integrate that with a gui, no problem. If you think some of your customers are going to want to script certain tasks. set it up. Anything to do with automation is better done from the command line(y harlo thar cron job!)</p> <p>I...
31,619
<p>Java requires that you catch all possible exceptions or declare them as thrown in the method signature. This isn't the case with C# but I still feel that it is a good practice to catch all exceptions. Does anybody know of a tool which can process a C# project and point out places where an exception is thrown but n...
<p>Check out the ExceptionFinder plug-in by Jason Bock for the .NET Reflector. It does just what you are looking for. Here's a screeny:</p> <p>Check it out on <a href="http://www.codeplex.com/ExFinderReflector" rel="nofollow noreferrer">CodePlex</a></p>
<p>If you are using C# for a web application then you can use ELMAH which shows a list of all the handled and unhandled exceptions. </p> <p>Just download ELMAH and plug it in. It is FREE!</p>
28,752
<p>I am using the <a href="http://ui.jquery.com/repository/latest/demos/functional/#ui.datepicker" rel="nofollow noreferrer">date picker provided by jQuery UI</a> to select a date range that ends up in a single text input with something like 11/11/2008 - 12/05/2008. What would you recommend as far a validation (jQuery...
<p>There has maybe been a lot of hype in the early 2000's, and what happened is the following: there has been a lot of attempts to create aspect-oriented frameworks, and these attempts have merged into two significant projects in the Java sphere: AspectJ and Spring AOP. AspectJ is complete, complex, academic, somewhat ...
<p>I'm going to suggest that it wasn't big enough. It sounds very appealing, but does it really make coding any easier? I've been wanting to try it out and find what benefits it really holds, but I don't think I do enough coding where I need the relationships that it provides. I don't think it is as beneficial as it so...
40,816
<p>I asked before about pixel-pushing, and have now managed to get far enough to get noise to show up on the screen. Here's how I init:</p> <pre><code>CGDataProviderRef provider; bitmap = malloc(320*480*4); provider = CGDataProviderCreateWithData(NULL, bitmap, 320*480*4, NULL); CGColorSpaceRef colorSpaceRef; colorSpac...
<p>The slowness is almost certainly in the noise generation. If you run this in Instruments you'll probably see that a ton of time is spent sitting in your loop.</p> <p>Another smaller issue is your colorspace. If you use the screen's colorspace, you'll avoid a colorspace conversion which is potentially expensive. </p...
<p>I suspect doing 614400 (<code>320*480*4</code>) memory writes, random number generation and making a new object each frame is slowing you down. </p> <p>Have you tried just writing a static bitmap to screen and seeing how fast that is? Have you perhaps tried profiling the code? Do you also need to make a new CGRect ...
23,593
<p>what is the best way to put a container class or a some other class inside a class as private or a public member?</p> <p>Requirements:</p> <p>1.Vector&lt; someclass> inside my class</p> <p>2.Add and count of vector is needed interface</p>
<p>If the container's state is part of the class's invariant, then it should, if possible, be private.</p> <p>For example, if the container represents a three dimensional vector then part of the invariant might be that it always contains exactly 3 numbers. Exposing it as a public member would allow code external to t...
<p>Make all members private and use accessor methods, this allows you to change the implementation later. Only in very unusual circumstances would I make any data member public.</p> <p>Remember that chaning the implementation happens more often than you may imagine, its not just a case of changing the type of the...
23,985
<p>I've been seeing that expression for over 10 years now. I've been trying to think what it's good for. Since I see it mostly in #defines, I assume it's good for inner scope variable declaration and for using breaks (instead of gotos.)</p> <p>Is it good for anything else? Do you use it?</p>
<p>It's the only construct in C that you can use to <code>#define</code> a multistatement operation, put a semicolon after, and still use within an <code>if</code> statement. An example might help:</p> <pre><code>#define FOO(x) foo(x); bar(x) if (condition) FOO(x); else // syntax error here ...; </code></pre>...
<p>Generically, <code>do</code>/<code>while</code> is good for any sort of loop construct where one must execute the loop <em>at least</em> once. It is possible to emulate this sort of looping through either a straight <code>while</code> or even a <code>for</code> loop, but often the result is a little less elegant. ...
32,122
<p>I'm trying to get an expect script to work, and when I use the -re flag (to invoke regular expression parsing), the 'timeout' keyword seems to no longer work. When the following script is run, I get the message 'timed out at step 1', then 'starting step 2' and then it times out but does NOT print the 'timed out at s...
<p>The important thing is that a declaration in C++ is not an expression.</p> <pre><code>bool a = (CThing* pThing = GetThing()); // not legit!! </code></pre> <p>You can't do both a declaration and boolean logic in an if statement, C++ language spec specifically allows either an expression or a declaration.</p> <pre>...
<p>You can also enclose the assignment in an extra set of ( ) to prevent the warning message.</p>
16,526
<p><strong>Sorry answer found while typing</strong> </p> <p>I am trying to connect to an external webservice that requires username/password authentication through a proxy. I am using Visual Studio Express 2008 to generate a service reference</p> <ul> <li>I have connected to the same webservice using a web referen...
<p>Change the binding to :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;customBinding&gt; &lt;binding name="AreaWebServiceSoap12" closeTimeout="00:01:00" openTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:05:00"&gt; &lt;textMessageEncodi...
<p>And here is how you can connect without proxy:</p> <p><a href="http://blog.bodurov.com/Create-a-WCF-client-for-asmx-web-service-without-using-web-proxy" rel="nofollow noreferrer">http://blog.bodurov.com/Create-a-WCF-client-for-asmx-web-service-without-using-web-proxy</a></p>
36,886