instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Is there a way to detect, from within the finally clause, that an exception is in the process of being thrown?</p> <p>See the example below:</p> <pre><code> try { // code that may or may not throw an exception } finally { SomeCleanupFunctionThatThrows(); // if currently executing an exception, exit the...
<p>Set a flag variable, then check for it in the finally clause, like so:</p> <pre><code>boolean exceptionThrown = true; try { mightThrowAnException(); exceptionThrown = false; } finally { if (exceptionThrown) { // Whatever you want to do } } </code></pre>
<p>No I do not believe so. The catch block will run to completion before the finally block.</p> <pre><code>try { // code that may or may not throw an exception } catch { // catch block must exist. finally { SomeCleanupFunctionThatThrows(); // this portion is ran after catch block finishes } </code></pre> <p>...
9,215
<p>I have written a simple PowerShell filter that pushes the current object down the pipeline if its date is between the specified begin and end date. The objects coming down the pipeline are always in ascending date order so as soon as the date exceeds the specified end date I know my work is done and I would like to...
<p>It is possible to break a pipeline with anything that would otherwise break an outside loop or halt script execution altogether (like throwing an exception). The solution then is to wrap the pipeline in a loop that you can break if you need to stop the pipeline. For example, the below code will return the first it...
<p>Another option would be to use the <code>-file</code> parameter on a <code>switch</code> statement. Using <code>-file</code> will read the file one line at a time, and you can use <code>break</code> to exit immediately without reading the rest of the file.</p> <pre class="lang-powershell prettyprint-override"><code...
35,174
<p>How can I use .NET DataSet.Select method to search records that match a DateTime? What format should I use to enter my dates in?</p>
<p>The best method is dd MMM yyyy (ie 15 Sep 2008). This means there is no possiblity of getting it wrong for different Locals.</p> <pre><code>ds.select(DBDate = '15 Sep 2008') </code></pre> <p>You can use the DateFormat function to convert to long date format as well and this will work fine too.</p>
<p>I use the following for the SQL Select:</p> <pre><code> public string BuildSQL() { // Format: CAST('2000-05-08 12:35:29' AS datetime) StringBuilder sb = new StringBuilder("CAST('"); sb.Append(_dateTime.ToString("yyyy-MM-dd HH:mm:ss")); sb.Append("' AS datetime)"); re...
9,322
<p>I have a lot of buttons and by clicking on different button, different image and text would appear. I can achieve what I want, but the code is just so long and it seems very repetitive. For example:</p> <pre><code> var aaClick = false; $("aa").observe('click', function() { unclick(); $('charac...
<p>Build it all into a function where you can simply pass it the names of the DIVs you want to register. As long are you are consistent with your .jpg names, it should work.</p> <pre><code>var clicks = [] function regEvents(divName) { $(divName).observe('click', function() { unclick(divName); $('ch...
<p>Do the buttons share a common container? Then the following code works:</p> <pre><code>$(container).childElements().each(function(element) { $(element).observe('click', function () { … }); … }); </code></pre> <p>Alternatively, you can also do this:</p> <pre><code>["aa", "bb", "cc"].each(function(element) ...
33,411
<p>I thought I could easily answer this question by searching the web, but my Google-fu has failed me. So I turn to you, oh mighty stackoverflowers, and beseech you for enlightenment:</p> <p><strong>What is the quickest and best way to generate a visual site map (e.g. flowchart, mind map, IA diagram) of an existing we...
<p>It's not free, but Visio has a web site map diagram type that will go spider a site and generate a nice pretty diagram of the results.</p>
<p>In order to visualize site map as a flowchart, you can use Site Visualizer software. It has 30-days full-featured trial period, so you can create visual map of any existing website absolutely for free.</p> <p>After installation, create new project, type website URL you need to crawl, then lick Start tool button. Af...
41,175
<p>I've recently gotten my hobby java project embedded into a page <a href="https://stackoverflow.com/questions/138157/java-console-like-web-applet">thanks to this very site</a>, but now I'm having some security issues.</p> <p>I have the include:</p> <pre><code>import java.sql.*; </code></pre> <p>and the line:</p> ...
<p>I think the security exception is actually from a System.exit() call in your applet, after the Class.forName(). Generally you are not allowed to call System.exit() in unsigned applets as it shuts the whole JVM down. Have you checked if line 80 is actually the Class.forName() line, or does line 80 have some kind of e...
<p>Try getting rid of the <code>newInstance()</code> part. I think just having the <code>Class.forName()</code> does it for loading the driver.</p>
25,927
<p>I haven't really done any Windows scripting at all, so I am at a loss on how to pull this one off. Anyway, basically what we want to do is have a script that will take an argument on which IIS AppPool to recycle. I have done some research on Google and haven't had much success on getting things to work.</p> <p>He...
<p><strong>Where-Object</strong> is a filter that expects something as in input. There seems to be a missing <strong>pipe</strong>, before the <em>where filter</em>. </p> <p>Try:</p> <pre><code>$appPoolName = $args[0] $appPool = get-wmiobject -namespace "root\MicrosoftIISv2" -class "IIsApplicationPool" | Where-Object...
<p>With IIS 8.0 I've found I had to use <code>-namespace root\webadministration -class ApplicationPool</code></p> <p>For example, to recycle an Application Pool in IIS 8 remotely using PowerShell:</p> <p>As always, please test this first by listing the application pools. Just remove the <code>| where</code> and the ...
24,202
<p>I'm building a PHP page with data sent from MySQL.</p> <p>Is it better to have</p> <ul> <li>1 <code>SELECT</code> query with 4 table joins, or</li> <li>4 small <code>SELECT</code> queries with no table join; I do select from an ID</li> </ul> <p>Which is faster and what is the pro/con of each method? I only need o...
<p>You should run a profiling tool if you're truly worried cause it depends on many things and it can vary but as a rule its better to have fewer queries being compiled and fewer round trips to the database.</p> <p>Make sure you filter things as well as you can using your where and join on clauses.</p> <p>But honestl...
<p>Be careful when dealing with a merge table however. It has been my experience that although a single join can be good in most situations, when merge tables are involved you can run into strange situations.</p>
7,926
<p>Im having problems displaying records to my view when passing viewdata to a user control. This is only apparent for linq to sql objects where I am using table joins.</p> <p>The exception I receive is "Unable to cast object of type '&lt;>f__AnonymousType4<code>10[System.String,System.Int32,System.Nullable</code>1[S...
<pre><code>foreach (table1 m in (IEnumerable)ViewData.Model) </code></pre> <p><code>m</code> is not of type <code>table1</code>. It is an anonymous type (<code>select new { ... }</code> in CViewDataUC.cs).</p> <p>You should create a class that represents the type of the model objects you are passing from controller t...
<p>Thanks, this has helped me a lot!</p> <p>One small comment, you have to use angle brackets:</p> <pre><code>IQueryable&lt;CInformation&gt; info = from table1 in dataContext.table1 </code></pre>
35,228
<p>Can the glTF format be used for 3D printing?</p> <p>If not, is there any tool can convert it to another format such as STL, OBJ, STEP, and IGES? </p>
<p>As far as can be found it should be possible to convert glTF into STL (or OBJ).</p> <p>You could try to use an online converter to do this, e.g. <a href="http://www.greentoken.de/onlineconv/" rel="nofollow noreferrer">this one (greentoken)</a>; and <a href="http://assimp.sourceforge.net/main_features_formats.html" ...
<p>No, <code>gltf</code> is not a format that slicers accept commonly, and indeed, it is not even intended to be reverseable in the 1.0 format version. This has changed a little for the 2.0 standard. Some programs that allow exporting into the sliceable <code>stl</code> and <code>obj</code> formats can also import <co...
1,037
<p>I'm currently adding some new extended classes to this code:</p> <pre><code>foreach (BaseType b in CollectionOfExtendedTypes) { if (b is ExtendedType1) { ((ExtendedType1) b).foo = this; } else if (b is ExtendedType2) { ((ExtenedType2) b).foo = this; } else { b.foo = this; } } </code></pr...
<p>This really looks like a situation for a good polymorphic implementation. If you override the appropriate methods in the derived classes, you may not need the checks in the loop at all.</p>
<p>In C#, I believe the switch statement only works with integers and strings.</p>
27,619
<p>When I set trust connection = yes in my web.config, what user account does it use?</p> <p>Is it the 'NT AUTHORITY\NETWORK SERVICE'?</p> <p>Because I under security in Sql management, I see: NtAuthority/System only??</p>
<p>It uses the user that your Application Pool is running as, the default being 'NT AUTHORITY\NETWORK SERVICE'</p> <p>The title of the question should be "What user account will ASP.NET use when I connect to SQL Server using trusted___connection". Trusted_connection uses the current process' (or impersonated) credenti...
<p>It will use the credential of the currently logged in user. The reason you see NETWORK Service is because IIS app pools (by default) runs as that account.</p>
36,246
<p>input: phrase 1, phrase 2</p> <p>output: semantic similarity value (between 0 and 1), or the probability these two phrases are talking about the same thing</p>
<hr> <p>You might want to check out this paper:</p> <p><a href="http://ants.iis.sinica.edu.tw/3BkMJ9lTeWXTSrrvNoKNFDxRm3zFwRR/55/Sentence%20Similarity%20Based%20on%20Semantic%20Nets%20and%20corpus%20statistics.pdf" rel="noreferrer">Sentence similarity based on semantic nets and corpus statistics (PDF)</a></p> <p>I'v...
<p>Take a look at <a href="http://mkusner.github.io/publications/WMD.pdf" rel="nofollow noreferrer">http://mkusner.github.io/publications/WMD.pdf</a> This paper describes an algorithm called Word Mover distance that tries to uncover semantic similarity. It relies on the similarity scores as dictated by word2vec. Integr...
8,771
<p>I would like to make custom cake molds. </p> <p>I've asked about this in a few stores that specialize in cooking equipment, they said this wasn't possible. </p> <p>I wonder if 3D printing makes it possible. It would require a material that is food-safe, as per <a href="https://3dprinting.stackexchange.com/question...
<p>For <a href="http://3dprintingfromscratch.com/common/types-of-3d-printers-or-3d-printing-technologies-overview/#fdm" rel="nofollow noreferrer">FDM</a> printing: </p> <p>Both Cura and Makerbot Desktop (and perhaps others I'm not as familiar with) will give you a preview of both the length and weight of your print, i...
<p>I recently faced the problem of calculating the cost of my printed 3D models. I wanted to know what their real value had to be counted in Excel. It was really inconvenient. Then I found a program for counting, it turned out really great, even takes into account the electricity. This is not an advertisement just thr...
130
<p><em>By Logic Programming I mean the a sub-paradigm of declarative programming languages. Don't confuse this question with "What problems can you solve with if-then-else?"</em></p> <p>A language like Prolog is very fascinating, and it's worth learning for the sake of learning, but I have to wonder what class of rea...
<p><em>Prototyping</em>. </p> <p>Prolog is dynamic and has been for 50 years. The compiler is liberal, the syntax minimalist, and "doing stuff" is easy, fun and efficient. SWI-Prolog has a built-in <a href="https://www.swi-prolog.org/pldoc/man?section=debugoverview" rel="nofollow noreferrer">tracer (debugger!)</a>, an...
<p>Yes, <a href="https://en.wikipedia.org/wiki/Prolog" rel="nofollow noreferrer">Prolog has been around since 1972</a>. It was invented by Alain Colmerauer with Philippe Roussel, based on Robert Kowalski's procedural interpretation of Horn clauses. Alain was a French computer scientist and professor at Aix-Marseille Un...
26,519
<p>If I add 3-400 databases to a single SQL Server instance will I encounter scaling issues introduced by the large number of databases?</p>
<p>This is one of those questions best answered by: Why are you trying to do this in the first place? What is the concurrency against those databases? Are you generating databases when you could have normalized tables to do the same functionality?</p> <p>That said, yes MSSQL 2005 will handle that level of database per...
<p>I have never tried this in 2005. But a company I used to work for tried this on 7.0 and it failed miserably. With 2000 things got a lot better but querying across databases was still painfully slow and took too many system resources. I can only imagine things improved again in 2005.</p> <p>Are you querying acros...
9,334
<p>I want to create parts for a 3D printer using OpenSCAD. Having some STL files from the vendor, but nothing else (no technical drawing, no CAD files).</p> <p>Does anybody knows a free tool, that allows me to</p> <ul> <li>measure distances between 2 selected vertices,</li> <li>measure distances between a selected ve...
<p>I suggest Blender. It's not the simplest of tools but it is free and learning it will improve your 3D printing skills. :-) (I write this answer also for future viewers of this question so I start basic).</p> <p>Another answer can be found here, <a href="https://blender.stackexchange.com/q/19772/14005">How do I measu...
<p>Use Meshy &quot;...a WebGL-based tool that does measurements and simple transformations on STL and OBJ files.&quot;: <a href="https://0x00019913.github.io/meshy/" rel="nofollow noreferrer">https://0x00019913.github.io/meshy/</a></p>
472
<p>I'm working on a very simple game (essentially an ice sliding puzzle), for now the whole things in one file and the only level is completely blank of any form of obstacle. It throws up a few errors. My current annoyance is an expected primary expression error, can anyone tell me how to fix it (it throws up at line 9...
<p>This might help:</p> <pre><code>void movePlayer(){ tempX = x; tempY = y; if (key[KEY_UP] &amp;&amp; map[y - 1][x] == 3) for ( ; map[y - 1][x] == 3; --y){ } else if(key[KEY_DOWN] &amp;&amp; map[y + 1][x] == 3) for ( ; map[y + 1][x] == 3; ++y){ } e...
<p>Your "for" loops are missing a section. Usually there are three parts: an initialization, a condition, and post-iteration operation. From what I can tell, you have the last two, but no initialization. The compiler is currently interpreting your first "for" loop, for example, as:</p> <ol> <li>Check 3 against [y-...
48,686
<p>I've got some code that will generically get all Controls in a form and put them in a list. Here's some of the code:</p> <pre><code> private List&lt;Control&gt; GetControlList(Form parentForm) { List&lt;Control&gt; controlList = new List&lt;Control&gt;(); AddControlsToList(par...
<p>I believe the VS designer does it by getting an instance of the control's designer (see the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.designerattribute.aspx" rel="nofollow noreferrer"><code>Designer</code> attribute</a>), and, if the designer is a <a href="http://msdn.microsoft.com/en-us...
<p>The items such as ToolStripItem etc aren't actually controls, they are simply components that make up a ToolStrip or MenuStrip.</p> <p>Which means, that if you want to include those components in your flattened list of controls then you will need to do the specific checks.</p>
38,040
<p>I've been working with Vector2's and XNA, and I've come to find that calling the Normalize() member function on a Zero Vector normalizes it to a vector of {NaN, NaN}. This is all well and good, but in my case I'd prefer it instead just leave them as Zero Vectors.</p> <p>Adding this code to my project enabled a cut...
<p>This doesn't work because Vector 2 <a href="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.vector2.aspx" rel="nofollow noreferrer">is actually a struct</a>. This means it gets passed by value and you can't modify the caller's copy. I think the best you can do is the workaround specified by lomaxxx...
<p>I'm not sure why your second code sample doesn't work but if the first lot of code does what you want you could simply work around it by going:</p> <pre><code>Vector2 v2 = new Vector2() v2 = v2.NormalizeOrZero(); </code></pre>
39,064
<p>Probably a really simple one this - I'm starting out with C# and need to add values to an array, for example:</p> <pre><code>int[] terms; for(int runs = 0; runs &lt; 400; runs++) { terms[] = runs; } </code></pre> <p>For those who have used PHP, here's what I'm trying to do in C#:</p> <pre><code>$arr = array(...
<p>You can do this way -</p> <pre><code>int[] terms = new int[400]; for (int runs = 0; runs &lt; 400; runs++) { terms[runs] = value; } </code></pre> <p>Alternatively, you can use Lists - the advantage with lists being, you don't need to know the array size when instantiating the list.</p> <pre><code>List&lt;int&...
<p>Here is one way how to deal with adding new numbers and strings to Array:</p> <pre><code>int[] ids = new int[10]; ids[0] = 1; string[] names = new string[10]; do { for (int i = 0; i &lt; names.Length; i++) { Console.WriteLine(&quot;Enter Name&quot;); names[i] = Convert.ToString(Console.ReadL...
24,807
<p>Through profiling I've discovered that the sprintf here takes a long time. Is there a better performing alternative that still handles the leading zeros in the y/m/d h/m/s fields?</p> <pre><code>SYSTEMTIME sysTime; GetLocalTime( &amp;sysTime ); char buf[80]; for (int i = 0; i &lt; 100000; i++) { sprintf(buf, ...
<p>If you were writing your own function to do the job, a lookup table of the string values of 0 .. 61 would avoid having to do any arithmetic for everything apart from the year.</p> <p>edit: Note that to cope with leap seconds (and to match <a href="http://en.cppreference.com/w/c/chrono/strftime" rel="nofollow norefe...
<p>StringStream is the suggestion that I got from Google.</p> <p><a href="http://bytes.com/forum/thread132583.html" rel="nofollow noreferrer">http://bytes.com/forum/thread132583.html</a></p>
34,224
<p>I am using Python and the <a href="http://twistedmatrix.com/trac/" rel="nofollow noreferrer">Twisted</a> framework to connect to an FTP site to perform various automated tasks. Our FTP server happens to be Pure-FTPd, if that's relevant.</p> <p>When connecting and calling the <strong>list</strong> method on an <str...
<p>Firstly, if you're performing automated tasks on a retrieived FTP listing then you should probably be looking at <code>NLST</code> rather than <code>LIST</code> as noted in <a href="https://www.rfc-editor.org/rfc/rfc959#page-33" rel="nofollow noreferrer">RFC 959 section 4.1.3</a>:</p> <pre> NAME LIST (NLST) ... ...
<p>This is somehow expected. FTPFileListProtocol isn't able to understand every FTP output, because, well, some are wacky. As explained in the docstring:</p> <p>If you need different evil for a wacky FTP server, you can override either C{fileLinePattern} or C{parseDirectoryLine()}.</p> <p>In this case, it may be a bu...
39,080
<p>when I apply the tag above my methods I get the error </p> <blockquote> <p>Type System.Runtime.CompilerServices.Extension is not defined.</p> </blockquote> <p>Here is my sample</p> <pre><code>&lt;System.Runtime.CompilerServices.Extension()&gt; _ Public Sub test() End Sub </code></pre> <p>Where am I goin...
<p>What version of .net framework the IDE is pointing towards?</p> <p>Also, at first glance the syntax of extension method looks incorrect.</p> <p>The code is incomplete. Please put the using statements in the example for anyone to use the code and compile it - to reproduce the error.</p>
<p>Use this...</p> <p>System.Runtime.CompilerServices.ExtensionAttribute</p> <p>Couldn't find anything called Extension in the namespace you mentioned.</p>
43,133
<p>Recently I started looking on pressure advance and how it works and I'm a bit confused about where it is usually implemented.</p> <p>My Idea of 3D printer was that its firmware is fairly dumb and only replays GCode, not knowing anything about the object being printed, material used, or even the printer itself.</p> <...
<blockquote> <p>In addition the E axis is no longer controlled directly by the GCode, but it's motion is almost independently determined by the firmware.</p> </blockquote> <p>This is the case even without linear advance. G-code does not directly control the movement of any of the axes. G-code only specifies the path th...
<p>This is a really good question that sheds a lot of light on 3D printer software/firmware architecture, and Tom already said a lot of the things I wanted to say before getting a chance to write an answer. The basic problem is that, to do pressure advance accurately (and in a way that doesn't get it horribly wrong whe...
1,796
<p>I'm having a problem with a Klondike Solitaire I'm programming. It's almost finished but now when I try to compile (I'm using Dr. Java, yeah I know), it keeps popping up with 2 errors.</p> <ol> <li>Cannot find symbol: Variable event</li> <li>Cannot find symbol: Method "findbunki" (java.awt.Point)</li> </ol> <p>I'v...
<p>Without code this would be my guess:</p> <p>1) you use a variable named 'event' but it is not one of the arguments in you method. (Alternatively: you forgot to declare it, but from the name I'd guess it's belongs in a method call)</p> <p>2) You call the method 'findbunki' on an object of type java.awt.Point - Poin...
<p>You should be import java.awt.event.*;</p>
47,831
<p>Ok, bear with me guys and girls as I'm learning. Here's my question.</p> <p>I can't figure out why I can't override a method from a parent class. Here's the code from the base class (yes, I pilfered the java code from an OOP book and am trying to rewrite it in C#).</p> <pre><code>using System; public class Mood...
<p>In C# methods are not virtual by default, so if you design some method as overridable, you should specify it as virtual:</p> <pre><code>class Base { protected virtual string GetMood() {...} } </code></pre> <p>Second, you have to specify that you are going to override method from base class in derived class. </p...
<p>You need to mark the overrides of getMood with the "override" keyword. You'll also need to mark the base getMood method with the "virtual" keyword.</p>
43,805
<p>What are some of the new features that can be used in .NET 2.0 that are specific to C# 3.0/3.5 after upgrading to Visual Studio 2008? Also, what are some of the features that aren't available?</p> <p><strong>Available</strong></p> <ul> <li>Lambdas</li> <li>Extension methods (by declaring an empty System.Runtime.Co...
<p>You can use any new C# 3.0 feature that is handled by the compiler by emitting 2.0-compatible IL and doesn't reference any of the new 3.5 assemblies:</p> <ul> <li>Lambdas (used as <code>Func&lt;..&gt;</code>, not <code>Expression&lt;Func&lt;..&gt;&gt;</code> )</li> <li>Extension methods (by declaring an empty <code>...
<p>Lambdas &amp; Extension methods are handled purely by the compiler and can be used with the .Net 2.0 framework.</p>
20,854
<p>I distribute software online, and always wonder if there is a proper way to better define version numbers.</p> <p>Let's assume A.B.C.D in the answers. When do you increase each of the components?</p> <p>Do you use any other version number tricks such as D mod 2 == 1 means it is an in house release only?</p> <p>D...
<p>I'm starting to like the Year.Release[.Build] convention that some apps (e.g. Perforce) use. Basically it just says the year in which you release, and the sequence within that year. So 2008.1 would be the first version, and if you released another a months or three later, it would go to 2008.2.</p> <p>The advantage...
<p>For in-house development, we use the following format.</p> <pre><code>[Program #] . [Year] . [Month] . [Release # of this app within the month] </code></pre> <p>For example, if I'm releasing application # 15 today, and it's the third update this month, then my version # will be</p> <pre><code>15.2008.9.3 </code><...
16,283
<p>I'm now trying to create a xml-rpc server with the CodeIgniter Framework. </p> <pre><code>&lt;?php $this-&gt;load-&gt;library('xmlrpc'); $this-&gt;load-&gt;library('xmlrpcs'); $config['functions']['weblogUpdates.ping'] = array('function' =&gt; 'weblogUpdates.ping'); $config['functions']['ping'] = array('function' ...
<p>Have you looked at <a href="http://codeigniter.com/user_guide/libraries/xmlrpc.html" rel="nofollow noreferrer">the codeigniter user guide</a>?</p>
<p>Thanks, found the problem, I'm so dumb. Had a beta-server up running which I had set Wordpress to ping, and forgot to change the address when I got the new server :$</p>
37,808
<p>I am working with ASP.net.<br><br> I am trying to call a method that exists on the base class for the page I am using. I want to call this method via Javascript and do not require any rendering to be handled by ASP.net.<br><br> What would be the easiest way to accomplish this. <br><br> I have looked at PageMethods w...
<p>It depends on what the method relies on, but assuming it is a static method or that it does not rely on the Page Lifecycle to work, you could expose a webservice endpoint and hit that with whichever Javascript calling mechanism you would like to use.</p>
<p>As Thunder3 suggests, expose a Web Service. Once you have done this, you can register the webservice with the ScriptManager (or ScriptManagerProxy), which will cause a JavaScript wrapper to be generated. This wrapper gives you a good interface to the call.</p>
9,315
<p>Every time I see Ruby or Python discussed in the context of web development, it's always with a framework (Rails for Ruby, Django for Python). Are these frameworks necessary? If not, is there a reason why these languages are often used within a framework, while Perl and PHP are not?</p>
<p><strong>The short answer is no, they are not necessary</strong>. In ruby you have .erb templates that can be used in a similar way as you use PHP pages. You can write a site in ruby or Python using several technologies (Rails-like frameworks, Templates or even talking directly with the HTTP library and building th...
<p>By no means are those development frameworks required. But as with most development environments, your productivity will increase exponentially if you have a supported framework to reference and build your applications on. It also decreases the training needed to bring others up to speed on your applications if th...
21,097
<p>I'm <em>extremely new</em> to Java, and have mostly just been teaching myself as I go, so I've started building an applet. I'd like to make one that can select a file from the local disk and upload it as a multipart/form-data POST request but <strong>with a progress bar</strong>. Obviously the user has to grant perm...
<p>To check progress using HttpClient, wrap the MultipartRequestEntity around one that counts the bytes being sent. Wrapper is below:</p> <pre><code>import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; import org.apache.commons.httpclient.methods.RequestEntity; public class Coun...
<p>Look into <a href="http://hc.apache.org/httpclient-3.x/" rel="nofollow noreferrer">HTTP Client</a> for uploadign the file to the web. It should be able to to do that. I am unsure how to get the progress bar, but it would involve querying that API somehow.</p>
31,776
<p>With WSSv2 (SharePoint 2003) you could get the version of SharePoint you were working with</p> <p>e.g. <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spglobaladmin.version.aspx" rel="nofollow noreferrer">SPGloablAdmin.Version</a> gives you "12.0.0.6219" for <a href="http://www....
<p>SPFarm.Local.BuildVersion would probably give you the same result without having to refer to a SPWebService.</p> <p>Cheers :)</p>
<p>As maxim said, but i included it in a Powershell script <a href="http://snipt.org/nLS/" rel="nofollow">http://snipt.org/nLS/</a></p>
35,656
<p>I'm interested in seeing what <strong>custom extensions other developers have created for the ASP.NET MVC HtmlHelper class</strong>. </p> <p>I think Microsoft got off to a <strong>great a start</strong>, but as usual, left a lot of <strong>open</strong> holes to fill! </p> <p>Looks like I am going to have to cre...
<p>You should check the <a href="http://www.codeplex.com/MVCContrib" rel="nofollow noreferrer">MVC-Contrib</a> project on Codeplex...</p> <p>Also, I just found <a href="http://blogs.taiga.nl/martijn/archive/2008/08/27/paging-with-asp.net-mvc.aspx" rel="nofollow noreferrer">this</a> paging extension to the HtmlHelper w...
<p>I made quite a few for a project I did at work. The ones that I can think off the top of my head were:</p> <p>ActionImage, which was the unholy love child of ActionLink and Image. ScriptBlock, which could write out a JavaScript script block based on some parameters from the ASP.NET. Textile, which would take a stri...
36,900
<p>Our current application is a single OpenGL EXE containing multiple pages. The EXE is responsible for accessing data sent across the network via UDP. It accumulates the data and stores it in a host of singleton structures. The individual pages within the EXE access the singleton structures to process the data as t...
<p>Give all the DLLs a function SetGlobalDataPointer(Singleton*). Your EXE calls this function before it calls any other DLL function. In the DLL code, replace all occurances of theSingleton. by theSingletonPtr-></p>
<p>You could either:</p> <ul> <li>put everything bar the very outermost shell into a 'common' DLL;</li> <li>use a DEF file to generate export functions from your EXE.</li> </ul> <p>The second is very uncommon but it is possible to generate an import library just from the DEF file. Use LIB /DEF to generate the import ...
11,014
<p>I appreciate that there are now many mechanisms in dotnet to deal with XML in a myriad of ways... </p> <p>Suppose I have a string containing the XML....</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;root&gt; &lt;Element1&gt; &lt;Element1_1&gt; SomeData &lt;/Elemen...
<p>Which APIs are you able to use? Can you use .NET 3.5 and LINQ to XML, for instance? If so, <a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xnode.remove.aspx" rel="noreferrer">XNode.Remove</a> is your friend - just select Element1_1 (in any of the many ways which are easy with LINQ to XML) and call R...
<p>I'd use either this:</p> <pre><code>XmlDocument x = new XmlDocument(); x.LoadXml(SomeXmlString); foreach (XmlNode xn in x.SelectNodes("//Element1_1")) xn.ParentNode.RemoveChild(xn); </code></pre> <p>or the same with an explicit XPath:</p> <pre><code>foreach (XmlNode xn in x.SelectNodes("/root/Element1/Element1...
27,281
<p>When we talk about the .NET world the CLR is what everything we do depends on. What is the minimum knowledge of CLR a .NET programmer must have to be a good programmer? Can you give me one/many you think is/are the most important subjects: GC?, AppDomain?, Threads?, Processes?, Assemblies/Fusion? </p> <p>I will ver...
<p>Most of those are way deeper than the kind of thing many developers fall down on in my experience. Most misunderstood (and important) aspects in my experience:</p> <ul> <li>Value types vs reference types</li> <li>Variables vs objects</li> <li>Pass by ref vs pass by value</li> <li>Delegates and events</li> <li>Disti...
<p>Jon's answer is good. Those are all fairly basic but important areas that a lot of developers do not have a good understanding of. I think knowing the difference between value and reference types ties in to a basic understanding of how the GC in .NET behaves, but, more importantly, a good understanding of the Dispos...
38,522
<p>During the course of our application login there are several queries ran, all around validating the login. In evaluating them I noticed that one of the queries is run without the NOLOCK hint.</p> <p>There does not seem to be any particular danger of dirty read because the data would hardly ever change.</p> <p>Thi...
<p>Having NOLOCKs or not is the least of your worries with a DoS attempt against your server.</p> <p>I wouldn't sweat it.</p> <p>If, as you say, the data rarely changes, having the NOLOCKs there probably don't hurt.</p>
<p>Also a very rare case, but still: Just at the moment somebody deactivates the user to prevent them from logging in, NOLOCK lets them in. Could be a rogue user/hacker/employee who needs to be locked out immediately?</p> <p>You would have to be concerned about this particular scenario to forgo the performance advanta...
36,048
<p>When I use (in MS Access 2003 SP3): </p> <pre><code>SELECT * INTO NewTable FROM SomeQuery; </code></pre> <p>MEMO fields are converted to TEXT fields (which are limited to 255 characters), so longer texts are cut.</p> <p>The output of the query itself is fine and not truncated; the text is cut only in the new tabl...
<p>You have here the <a href="http://allenbrowne.com/ser-63.html" rel="nofollow noreferrer">current workarounds</a> for avoiding any Truncation of Memo fields.</p> <p>In your case, that may be the result of the query's Properties Sheet including a "<code>set Unique</code>" Values to Yes (which forces comparison of Mem...
<p>SP3 of 2003 is notorious, it may be related to that. There is a hotfix:</p> <p><a href="http://support.microsoft.com/default.aspx/kb/945674" rel="nofollow noreferrer">http://support.microsoft.com/default.aspx/kb/945674</a></p>
48,893
<ol> <li><p>In a simple winform application, I call a function that endlessy create files on a button click event. I add Application.DoEvents() to the loop.</p></li> <li><p>I press the red X to close the form.</p></li> <li><p>the form closes, but files continue to be created ... </p></li> </ol> <p>I think its on the b...
<p>The fact that you're using <code>Application.DoEvents</code> is the first sign of a problem: it shows that you're doing too much in the UI thread. It's almost never appropriate in a well-structured program. The UI thread is not meant to have any long-running tasks. (Admittedly if it takes a long time to draw your UI...
<p>Did you specifially create a new thread for that ButtonClick code? If not, then it's on the same thread as the Form, so the "X" button <em>should</em> stop it.</p> <p>In either case, you could set a flag (isClosing), and check for that flag in your "while true" loop.</p>
32,449
<p>This is probably too much to ask, but is there any language that does a really terrific job of representing time and date operations? I'll grant straight away that it's <b>really hard</b> to write a truly great time library. That said, are there any widespread languages that have one? Basically, I want something ...
<p>How about <a href="http://msdn.microsoft.com/en-us/library/system.datetime_methods.aspx" rel="nofollow noreferrer">.NET's DateTime</a>? (You can pick your language within the framework)</p>
<p>Ruby has excellent support, actually. Check out <a href="http://www.developer.com/open/article.php/3729206" rel="nofollow noreferrer">this page</a>. Really great support for turning strings into dates, dates into strings, doing math on dates, parsing "natural language" strings like "3 months ago this friday at 3:4...
11,568
<p>I want to allow an Excel report to be viewed embedded in a WebPage... is there a way?</p> <ul> <li><p>I don't want to use an ActiveX, or OWC (Office Web Components), I just want to open an existing file from the internet explorer application.</p></li> <li><p>I don't want users to download and then open it.</p></li>...
<p>This has to do with the local person's browser set up and not really anything you can do on your end. If they click a link with the .xls(x) extension, the browser determines if it wants to open it itself or in a new window.</p> <p>Here 2 microsoft pages on how to change these settings:</p> <p><a href="https://suppor...
<pre><code>&lt;iframe src="file:\\yourpath\yourfile.xls" width="100%" height="500"&gt;&lt;/iframe&gt; </code></pre>
20,320
<p>When executing the following (complete) SQL query on Microsoft SQL Server 2000:</p> <pre><code>SELECT B.ARTIFACTTNS, B.ARTIFACTNAME, B.ARTIFACTTYPE, B.INITIALBYTES, B.TIMESTAMP1, B.FILENAME, B.BACKINGCLASS, B.CHARENCODING, B.APPNAME, B.COMPONENTTNS, B.COMPONENTNAME, B.SCAMODULENAME, B.SCACOMPONENTNAME FROM...
<p>Because <code>ARTIFACTTYPE</code> can refer to either <code>A.ARTIFACTTYPE</code> or <code>B.ARTIFACTTYPE</code> and the server needs to know which one you want, just change it to <code>A.ARTIFACTTYPE</code> and you should be okay in this case.</p> <p>To clarify, you need to specify the alias prefix any time the co...
<p>To be clear, it is lines 13, 14 and 15 that have the ambiguous columns.</p>
41,091
<p>I'm trying to implement a unit test for a function in a project that doesn't have unit tests and this function requires a System.Web.Caching.Cache object as a parameter. I've been trying to create this object by using code such as...</p> <pre><code>System.Web.Caching.Cache cache = new System.Web.Caching.Cache(); ca...
<p>When I've been faced with this sort of problem (where the class in question doesn't implement an interface), I often end up writing a wrapper with associated interface around the class in question. Then I use my wrapper in my code. For unit tests, I hand mock the wrapper and insert my own mock object into it.</p> ...
<pre><code>var httpResponse = MockRepository.GenerateMock&lt;HttpResponseBase&gt;(); var cache = MockRepository.GenerateMock&lt;HttpCachePolicyBase&gt;(); cache.Stub(x =&gt; x.SetOmitVaryStar(true)); httpResponse.Stub(x =&gt; x.Cache).Return(cache); httpContext.Stub(x =&gt; x.Response).Return(httpResponse); ...
30,289
<p>The link over here lists ([http://www.yoda.arachsys.com/csharp/singleton.html][1]) some singleton patterns in C#. The article also describes the obvious that a singleton is not meant to accept parameters which “as otherwise a second request for an instance but with a different parameter could be problematic”. This m...
<p>Based on your question, it seems you may be looking at an Abstract Factory pattern (creates an instance of several families of classes) that keeps an internal list/dictionary of classes that have already been instantiated, thus mimicking the singleton pattern functionality.</p> <p>You would then use this factory cl...
<blockquote> <p>his means that any parameters you need to get the class working should be induced as a property.</p> </blockquote> <p>Ideally singleton class should not depend on external code. </p> <p>In case when you need to provide additional information to singleton constructor, you can just create a pool o...
18,285
<p>Is there any technology out there that will allow you to do side-by-side updates of production schemas?</p> <p>The goal is to have zero down time when applying updates to a schema in production. Weblogic 10 has a similar feature for their Java EE apps where by you deploy the new version of the app and new connectio...
<p>Yes. There is online redefinition package.</p> <p><a href="http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_redefi.htm#CBBJJAIF" rel="nofollow noreferrer">DBMS_Redefinition</a></p> <p>But I doubt this will give you zero downtime, this doesn't account for every possible change to a schema. This lets...
<p>Depends what you mean, or include, in "schema". If you want to add or drop an index, that can be done "in-flight", although it will require a lock which may halt activity for a time. In the latest Oracle versions, it doesn't need to hold the lock for the entire time it takes to build the index, just for a moment to...
33,798
<p>What is the best way to do cross-platform handling of hidden files? (preferably in Python, but other solutions still appreciated)</p> <p>Simply checking for a leading '.' works for *nix/Mac, and file attributes work on Windows. However, this seems a little simplistic, and also doesn't account for alternative method...
<p>Here's a script that runs on Python 2.5+ and should do what you're looking for:</p> <pre><code>import ctypes import os def is_hidden(filepath): name = os.path.basename(os.path.abspath(filepath)) return name.startswith('.') or has_hidden_attribute(filepath) def has_hidden_attribute(filepath): try: ...
<p>"Is there a standard way to deal with this?" Yes. Use a standard (i.e., POSIX-compliant) OS.</p> <p>Since Windows is non-standard -- well -- there's no applicable standard. Wouldn't it be great if there was? I feel your pain.</p> <p>Anything you try to do that's cross-platform like that will have Win32 odditie...
36,046
<p>I have a COM <code>.dll</code> registered successfully with <code>regsvr32</code> but somehow <code>CoCreateInstance()</code> fails to create one of its interfaces. Is there a freeware tool which can determine the reason for the failure?</p>
<p>First of all, check the return value of the CoCreateInstance() call. Second, you can use a tool like Regmon or Process Monitor to see what registry lookup fails. This way, you can quickly determine what exactly wasn't registered the way you'd expect it to be. </p>
<p>If your com dll is implemented in C++ &amp; has debug info, you could also try debugging with MSVC to step into CoCreateInstance.</p> <p>My guess is that you missed associating your class with one of the interfaces properly. I've done that a number of times by mistake. If you're using ATL you need to make sure your...
42,848
<p>I'm stuck in .NET 2.0 Windows Forms.</p> <p>It doesn't look like the ability to select multiple nodes exists in the standard <code>TreeView</code> control.</p> <p>I'm trying to do this for a context menu selection. So check boxes aren't an acceptable UI paradigm here.</p> <p>What's the best way to provide that v...
<p>We did this in a WTL project once, but the basic work needed is the same for .NET. To achieve a multiple selection tree control, you will need to draw the tree items yourself and override the keyboard and mouse handling. You will also need to maintain your own list of items that are selected.</p> <p>Don't forget to...
<p>You might look at a 3rd party solution. The <a href="http://www.infragistics.com" rel="nofollow noreferrer">Infragistics</a> tree does this. Not free, but the time spent trying to find a solution isn't really free, either.</p>
25,248
<p>I want to be able to run unstrusted ruby code. I want to be able to pass variables to said untrusted code that it may use. I also want said code to return a result to me. Here is a conceptual example of what I am thinking</p> <pre><code>input = "sweet" output = nil Thread.start { $SAFE = 4 #... untrusted code...
<p>$SAFE is not enough; you need to be at least at the level of Why's freaky sandbox. However, I don't know if that sandbox code is actively maintained or if he/they ever solved the holes such as infinite loops, etc.</p> <p>Unsafe generally means hostile. If you can relax from hostile to, say, 'naive', and depending...
<p>I'd strongly recommend just using JRuby.</p> <p>The JVM has had a very strong security model built in from the beginning, and JRuby piggy-backs off that. You can restrict access to files, restrict loading of code, and much more. It's <em>far</em> better than anything that exists in native Ruby impls, and there are ...
20,438
<p>I have a CC.NET project configured to call a common NAnt build file, which does some stuff, and then calls a child NAnt build file. The child build file name is specified by CC.NET to the command build file using a property.</p> <p>The hurdle that I am trying to get over is that the common build file log gets overw...
<p>Use the <a href="http://nant.sourceforge.net/release/0.85-rc1/help/tasks/nant.html" rel="nofollow noreferrer">nant task</a>, so you get one single build file.</p>
<p>Is there any way that you could <em>include</em> the child nant file as opposed to executing it as a full-fledged child nant project? This would prevent the overwrite, but not sure if it's possible in your situation.</p>
4,345
<p>I made an array in PHP which holds a bucnh of unix timestamps.</p> <p>I'm trying to make a function that will return an array containing the indexes of the 3 largest numbers in that array.</p> <p>For instance, if the largest numbers are located at indexes 3,5 and 8</p> <p>And if the largest is 5, second largest i...
<p>You could use <a href="http://uk3.php.net/manual/en/function.asort.php" rel="nofollow noreferrer">asort</a> to sort the array and maintain index and then use <a href="http://uk3.php.net/manual/en/function.array-slice.php" rel="nofollow noreferrer">slice</a> along with the 4th parameter, again to maintain the index, ...
<p>In PHP code:</p> <pre><code>function threeLargest($array){ krsort($array, "SORT_NUMERIC"); $return[0] = $array[0]; $return[1] = $array[1]; $return[2] = $array[2]; return $return; } </code></pre>
45,252
<p>I just installed Ganymede and am exploring an old project in it. All of my JSPs are giving me weird validation errors. I'm seeing stuff like - </p> <pre><code>Syntax error on token "}", delete this token Syntax error on token "catch", Identifier expected Syntax error, insert "Finally" to complete TryStatement </cod...
<p>I actually found out what my problem was through the <a href="http://www.eclipse.org/newsportal/article.php?id=17447&amp;group=eclipse.webtools#17447" rel="noreferrer">eclipse webtools usergroup</a>. The issue for me was the use of the Spring form custom tag library. If you self-close the tag... </p> <pre><code>&...
<p>I have the same issue. Whatever JSP editor is in Ganymede does not like my if/else scriptlets:</p> <pre><code>&lt;% if(message != null) { %&gt; &lt;p id="message"&gt;&lt;%=message %&gt;&lt;/p&gt; &lt;% } else { %&gt; &lt;p&gt;Please login to view your account information.&lt;/p&gt; &lt;% } %&gt; </code>...
17,375
<p>How would one go about capturing users keystrokes in the SMS composer on the Symbian OS, specifically for a Nokia N73 (or any of the symbian supported devices <a href="http://en.wikipedia.org/wiki/Symbian_OS#Devices_that_have_used_the_Symbian_OS" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Symbian_OS#Devi...
<p>Actually, you can capture keystrokes destined for any application in Symbian OS. <code>RWindowGroup::CaptureKey()</code> and <code>RWindowGroup::CaptureLongKey()</code> allow your executable to capture keys from any applicaton, whether yours is in the foreground or not. However, in this case this may prove to be te...
<p>Well, there are several levels to answering to your question.</p> <ul> <li><p>The keystrokes are actually captured by the message editor application. So, either it provides an API to feed you all its keystrokes (you can look for one on <a href="http://forum.nokia.com" rel="nofollow noreferrer">http://forum.nokia.co...
30,167
<p>Is there a simple way in .NET to quickly get the current protocol, host, and port? For example, if I'm on the following URL:</p> <p><code>http://www.mywebsite.com:80/pages/page1.aspx</code></p> <p>I need to return:</p> <p><code>http://www.mywebsite.com:80</code></p> <p>I know I can use <code>Request.Url.Absolute...
<p>The following (C#) code should do the trick</p> <pre><code>Uri uri = new Uri("http://www.mywebsite.com:80/pages/page1.aspx"); string requested = uri.Scheme + Uri.SchemeDelimiter + uri.Host + ":" + uri.Port; </code></pre>
<p>In my case</p> <pre><code>Uri uri = new Uri(&quot;http://www.mywebsite.com:80/pages/page1.aspx&quot;); string requested = uri.Scheme + Uri.SchemeDelimiter + uri.Authority; </code></pre> <p>works to get</p> <p><a href="https://www.mywebsite.com:80" rel="nofollow noreferrer">https://www.mywebsite.com:80</a></p>
4,176
<p>I have a file with data listed as follows:</p> <pre><code>0, 2, 10 10, 8, 10 10, 10, 10 10, 16, 10 15, 10, 16 17, 10, 16 </code></pre> <p>I want to be able to input the file and split it into three arrays, in the process trimming all excess spaces and converting ea...
<p>There is really nothing wrong with fscanf, which is probably the fastest solution in this case. And it's as short and readable as the python code:</p> <pre><code>FILE *fp = fopen("file.dat", "r"); int x, y, z; std::vector&lt;int&gt; vx, vy, vz; while (fscanf(fp, "%d, %d, %d", &amp;x, &amp;y, &amp;z) == 3) { vx.p...
<p>If you want to be able to scale to harder input formats, you should consider spirit, boost parser combinator library.</p> <p><a href="http://www.boost.org/doc/libs/1_37_0/libs/spirit/classic/doc/quick_start.html" rel="nofollow noreferrer">This page</a> has an example which almost do what you need (with reals and on...
33,542
<p>I've got a list of links which have a click event attached to them, I need to get the ID from the child A link. So in the example below if I clicked the first list element I'd need google retuned. </p> <p>I've tried <code>'$this a'</code> but can't quite work out the syntax.</p> <pre><code>$("ul li").click(functio...
<p>I don't see the sample HTML but </p> <pre><code>$(this).find('a:first').attr('id') </code></pre> <p>would do it (fix <em>a:first</em> selector if it's not what you meant)</p> <p><strong>this</strong> refer to the element that fired your event</p>
<p>You could use the <a href="http://docs.jquery.com/Traversing/children" rel="nofollow noreferrer"><code>children</code></a> method:</p> <pre><code>$(this).children('a').eq(0).attr('id'); </code></pre> <p>I'm not sure about the syntax, but something like this should work.</p>
46,879
<p>Is there anyway how to check which website is being used with that pool without browsing each website and checks its assigned pool?</p> <p>I have approximately 35 websites and I can't afford browsing the websites one by one....</p> <p>Thanks</p>
<p>I won't create one class to handle in- and output - one class, one responsibility. I would like two filter streams, one for input/decryption and one for output/encryption:</p> <pre><code>InputStream decrypted = new DecryptingStream(inputStream, decryptionParameters); ... OutputStream encrypted = new EncryptingStrea...
<p>Can you split the body at arbitrary locations? </p> <p>If so, I would have two threads, input thread and output thread and have a concurrent queue of strings that the output thread monitors. Something like:</p> <pre><code>ConcurrentLinkedQueue&lt;String&gt; outputQueue = new ConcurrentLinkedQueue&lt;String&gt;(); ...
47,344
<p>I have been programming in Perl, off and on, for years now, although only sporadically is it my primary language. Because I often go months without writing any perl, I rely heavily on my dog-eared Camel Book to remind me how to do things. However, when I copy recipes verbatim with no understanding, this bothers me. ...
<p>Hmmm... <code>($lotr=$hobbit) =~ s/Bilbo/Frodo/g</code> is one of the many magicks of Perl. Now for some answers.</p> <p>Q1) <code>$lotr</code> is being assigned the value contained in <code>$hobbit</code>. After the assignment, we can forget about the source variable. Treat <code>($lotr = $hobbit)</code> as it's o...
<p>If in Q2 you mean to take a sub-string from $a, you might find this idiom useful:</p> <pre><code>($b) = $a =~ /(substring-to-match)/; $b =~ s/regex-on-susbtring/result-string/; </code></pre> <p>Also do note that $a and $b are not normal variables in Perl since they have special scope rules related to the sort func...
45,162
<p>According to the help file that comes with the Spring.NET framework, you can inject a dependancy defined in the local file by using an 'idref' tag along with a 'local' attribute. </p> <p>I have been trying to do this with no success and was hoping someone had the experience to help me out. </p> <p>Below I have a...
<p>I guess gef was on the right way but accidentially mixed it up when pasting the snippet.You are looking for the <a href="http://www.springframework.net/docs/1.2.0/reference/html/objects.html#objects-ref-element" rel="nofollow noreferrer">&lt;ref&gt; element</a>:</p> <pre><code>&lt;object id="theTargetObject" type="...
<p>Please view the post <a href="http://forum.springsource.org/showthread.php?t=14211" rel="nofollow noreferrer">http://forum.springsource.org/showthread.php?t=14211</a></p>
33,910
<p>How do I use PowerShell to stop and start a "Generic Service" as seen in the Microsoft "Cluster Administrator" software?</p>
<p>You can also use WMI. You can get all the Generic Services with:</p> <pre><code>$services = Get-WmiObject -Computer "Computer" -namespace 'root\mscluster' ` MSCluster_Resource | Where {$_.Type -eq "Generic Service"} </code></pre> <p>To stop and start a service:</p> <pre><code>$timeout = 15 $services[0].TakeOfflin...
<p>It turns out the answer is to simply use the command line tool CLUSTER.EXE to do this:</p> <p>cluster RES MyGenericServiceName /OFF</p> <p>cluster RES MyGenericServiceName /ON</p>
13,887
<p>I have been using Solidworks and AutoCAD to create STL file of a 3D model I want to print. I slice the STL file using Freesteel Z level slicer (<a href="http://www.freesteel.co.uk/wpblog/slicer/" rel="nofollow">http://www.freesteel.co.uk/wpblog/slicer/</a>) and save the slices in a bmp format. </p> <p>My 3d print h...
<p>Your objective has a serious constraint regarding the pixel resolution. Within that limitation, the software (slicer) you are using will generate "best guess" images, particularly dependent on floating point math. There may be a single combination of circular shapes (radius) and spacing for these shapes that provide...
<p>Your objective has a serious constraint regarding the pixel resolution. Within that limitation, the software (slicer) you are using will generate "best guess" images, particularly dependent on floating point math. There may be a single combination of circular shapes (radius) and spacing for these shapes that provide...
258
<p>In the build log I'd like to the start and end time of each project's compilation. Is there any way to get VS to do this?</p>
<p>For VC++ builds you can enable build timing. Go to Tools->Options->Projects and Solutions->VC++ Project settings and choose the option for 'Build Timing'</p>
<p>Not without modifying the actual project file (using a text editor) to add calls in to the MSBuild script targets.</p>
6,866
<p>Is it possible, in Windows XP, to copy files to a Network Place from the command line, a batch file or, even better, a PowerShell script?</p> <p>What sent me down this road of research was trying to publish files to a WSS 3.0 document library from a user's machine. I can't map a drive to the library in question bec...
<p>Using a batch file, you can both log on to the resource and copy the file: </p> <p>The Batch File would contain the following: </p> <pre><code>net use \\{dest-machine}\{destfolder} {password} /user:{username} copy {file} \\{dest-machine}\{destfolder} </code></pre> <p>e.g.</p> <pre><code>net use \\Development\myf...
<p>Yes you can. I suggest using a tool like robocopy.</p>
3,154
<p>I am running <code>MOSS 2007</code> on a <code>Windows 2003</code> box. I need to know what configuration must be done to get Alerts to work. <code>SMTP settings</code>, etc.... When I create my alert, it is created but it does not send the email to show me that something changed in my document library or on any par...
<p>Did you setup the Web Application Outgoing E-mail Settings in your Central Administration? Y</p>
<p>I don't think this question is really appropriate for StackOverflow - its not a programming question, see the FAQ.</p> <p>But anyway - could be anti-virus or smtp relay rules stopping sharepoint sending smtp to your mail server. Try this tool to diagnose.</p> <p><a href="http://www.simplecomtools.com/smtptesttool....
39,224
<p>I really like the mp3 player on 8tracks.com and was wondering how they manage to keep the mp3 playing even when I change pages?</p> <p>For example, listen to the track here <a href="http://8tracks.com/mixes?q=Aztec+Camera" rel="nofollow noreferrer">http://8tracks.com/mixes?q=Aztec+Camera</a> and click on one of the...
<p>Keep it simple: have the player store the current track/time in a cookie when onunload fires, then start from there when the next page loads. You'll need to write a couple support functions in JavaScript, as AFAIK Flash doesn't have access to browser cookies or JS events.</p>
<p>Yup, but you would get all the problemas that are involved with frames, you would end adding script code on all pages to take care when the user entered the site directly without the frame defining site</p>
17,372
<p>In Ultimaker Cura, is there a setting to slow down just the first layer (or two layers) covering over the infill? </p> <p>I'm not talking about the top layers, since you may have infill covered over during a lower section of the print. And I'm not talking about bridging, since this isn't a true bridge, and quick te...
<p>Cura can do this. It's a bit convoluted though. Here's what you need to do:</p> <ul> <li>Load your model / scene in the build plate.</li> <li>Load an additional cube and make it as big as the entire build plate so that it overlaps with everything (in the preferences you may need to disable "Ensure that models are k...
<p>As far as I know, Cura has no option to do this. Conceptually Cura treats the model as a solid, so that the material over infill is not "overhang". However, you may be able to hack it by using the "magic mesh surface mode" feature under "special modes", to treat the model as a surface rather than a solid, then enabl...
1,355
<p>I use MyGeneration along with nHibernate to create the basic POCO objects and XML mapping files. I have heard some people say they think code generators are not a good idea. What is the current best thinking? Is it just that code generation is bad when it generates thousands of lines of not understandable code?</p>
<p>Code generated by a code-generator should not (as a generalisation) be used in a situation where it is subsequently edited by human intervention. Some systems such the wizards on various incarnations of Visual C++ generated code that the programmer was then expected to edit by hand. This was not popular as it requ...
<p>In certain (not many) cases they are useful. Such as if you want to generate classes based on lookup-type data in the database tables.</p>
24,814
<p>Is there a way to copy an entire directory to the output directory in a console application in C#.NET?</p> <p>I know for files you can right click them, properties and mark copy to output directory. But I'm not going to do that for 20.000 files...</p> <p>Thx, Lieven Cardoen aka Johlero</p>
<p>Are you sure you want all 20000 files in the output?</p> <p>Besides manual copy-paste operation I see two options: one is you can have a post-build task to copy all the files and another is to have 20000 files zipped, zip file added as a content item to your project with "copy always" set and either console applica...
<p>You could hit ctrl+A to highlight all of them, then hit ctrl+C to copy them, then go to the new directory and hit ctrl+V to paste them all to the new location...</p> <p>Or you could open up the command window and use copy... but the first way is probably easier.</p>
34,634
<p>I know that IntelliJ has an option to select all the code in a JSP file, right click, and select "format". This nicely formats all HTML, CSS, scriptlets and JSTL tags in a JSP file. </p> <p>Can Eclipse do this? </p> <p>If not, what is the best free Eclipse plugin that does the same? </p>
<p>With the Web Tool Plateform plateform (on eclipse.org website), this is very simple : in the JSP editor tab, right click->source->format (or Shift+Ctrl+F)</p>
<p>I found this one on eclipse plugin central.</p> <p>Looks like an all in one kind of formatter. I haven't tried it myself but it might be what you are looking for</p> <p><a href="http://www.eclipseplugincentral.com/Web_Links-index-req-viewlink-cid-926.html" rel="nofollow noreferrer">NXFormat</a></p>
29,670
<p>I am in the process of moving from VSS to SVN and I'm not sure how to share files in SVN.</p> <p>Basically we have the following structure in VSS</p> <pre><code>$MOSS - Components - ComponentA - bin - ComponentB - bin - GAC Mirror </code></pre> <p>GAC Mirror holds a shared copy of all the ...
<p>Is svn:externals what you're after? <a href="http://svnbook.red-bean.com/en/1.0/ch07s03.html" rel="nofollow noreferrer">http://svnbook.red-bean.com/en/1.0/ch07s03.html</a></p>
<p>Use SVN 1.6+, it supports files also, see: <a href="http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.advanced.externals" rel="nofollow">http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.advanced.externals</a></p>
31,066
<p>I'm experiencing a strange issue where my Visual Studio 2005 C++ program crashes the first time it runs after a new build. I'm having a difficult time debugging this intermittent issue and I suspect it's somehow related to a file somewhere on my hard drive that is being changed. If I can find the file(s), that mig...
<p>You can use <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="nofollow noreferrer">Process Monitor</a> tool. Set "Show File System Activity" to ON and set a filter on the process name to get only the traces you need.</p>
<p>SysInternals (now Microsoft) FileMon</p> <p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx" rel="nofollow noreferrer"><a href="http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx</a></a></p>
31,695
<p>I have a PHP script that runs as a CGI program and the HTTP <code>Authenticate</code> header gets eaten and spit out. So I would like to implement some kind of FORM based authentication. As an added constraint, there is no database so no session data can be stored.</p> <p>I am very open to having a master username ...
<p>A few ways you could do this.</p> <ol> <li><a href="http://fragments.turtlemeat.com/htaccess.php" rel="nofollow noreferrer">htaccess</a> -- have your webserver handle securing the pages in question (not exactly cgi form based though).</li> <li>Use cookies and some sort of hashing algorithm (md5 is good enough) to s...
<p>... About salt, add the username in your hash salt will prevent someone who knows your salt and have access to your password file to write a rainbow table and crack number of your users's password.</p>
3,805
<p>As a team we are using Visual Studio 2005 with framework 3.0. I am thinking if it will be nice for us to switch to Visual Studio 2008 with framework 3.5 ? Is it worth it ?</p> <p>Thanks.</p>
<p>Yes, it is 100% worth it. Visual Studio 2008 supports 2005 code (.net 2.0) completely. There are also a lot of improvements that you'll enjoy as you use 2008.</p>
<p>yes it is. works faster and more reliable</p>
33,194
<p>I am deciding on a framework to try out for PHP. I have narrowed it down to CakePHP and CodeIgniter. I have a couple of questions for any of you who have used or are familiar with both:</p> <ol> <li><p>I like the fact that CakePHP keeps most of the code outside of the webroot by default. Especially since I may end...
<p>You should <strong>try</strong> both frameworks for a week or so, building something trivial (like a blog or wiki) in both, and see which you prefer using. Whatever makes the most sense <em>to you</em> will probably sustain you the longest through upgrades an deprecations.</p> <p>CakePHP is in a bit of a volatile ...
<ol> <li><p>This is a non issue. The app has a couple of lines which says where the core and your application code lies. You just need to change those lines.</p></li> <li><p>You can never anticipate this one. </p></li> </ol> <p>The state of PHP is a wildcard here. One app (CI) is built to be compatible with PHP4 t...
31,828
<p>When I run my Visual Studio Windows Forms application by clicking F5 (debug mode), after I click on the close button (which calls <code>Application.Exit()</code>), after a few seconds I get an error that says:</p> <blockquote> <p>cannot acess a disposed object: Object name 'SampleForm'.</p> </blockquote> <p>A bi...
<p>Mark your thread as BackgroundThread, and it will stop running as soon as you close the window.</p>
<p>Yes, you need to kill the thread first.</p> <p>This really has nothing to do with debug mode though. This has to do with basic threading.</p> <p>EDIT: Per your update, you should not be aborting the thread. The thread should be getting signaled and exiting on it's own. I am not sure what your thread or code looks ...
19,707
<p>I'm using IPAddress.TryParse() to parse IP addresses. However, it's a little too permissive (parsing "1" returns 0.0.0.1). I'd like to limit the input to dotted octet notation. What's the best way to do this?</p> <p>(Note: I'm using .NET 2.0)</p> <hr> <p><strong>Edit</strong></p> <p>Let me clarify:</p> <p>I'm w...
<p>If you are interested in parsing the format, then I'd use a regular expression. Here's a good one (<a href="http://www.regular-expressions.info/regexbuddy/ipquick.html" rel="noreferrer">source</a>):</p> <pre><code>bool IsDottedDecimalIP(string possibleIP) { Regex R = New Regex(@"\b(?:\d{1,3}\.){3}\d{1,3}\b"); ...
<p>An IP address is actually a 32 bit number - it is not xxx.xxx.xxx.xxx - that's just a human readable format for the same. So IP address 1 is actually 0.0.0.1.</p> <p>EDIT: Given the clarification, you could either go with a regex as has been suggested, or you could format the short cuts to your liking, so if you wa...
49,649
<p>I've seen some methods of <a href="http://www.anastasiosyal.com/archive/2007/04/17/3.aspx" rel="noreferrer">checking if a PEFile is a .NET assembly by examining the binary structure</a>.</p> <p>Is that the fastest method to test multiple files? I assume that trying to load each file (e.g. via <a href="http://msdn.m...
<p>Maybe this helps</p> <p>from <a href="https://web.archive.org/web/20110930194955/http://www.grimes.demon.co.uk/dotnet/vistaAndDotnet.htm" rel="nofollow noreferrer">https://web.archive.org/web/20110930194955/http://www.grimes.demon.co.uk/dotnet/vistaAndDotnet.htm</a></p> <blockquote> <p>Next, I check to see if it is ...
<p>The first link there is going to be the fastest and simplest method of checking (the PE file header one). You're correct in assuming that calling Assembly.ReflectionOnlyLoad is going to be pretty slow. </p>
42,755
<p>I know <a href="http://www.libtiff.org/libtiff.html" rel="noreferrer">libtiff</a> for C, but haven't found a port for .NET. Does such a port exist?</p>
<p>My company recently released a free and open-source(New BSD license) version of LibTiff written using only managed C# (license permits commercial use and distribution).</p> <p><a href="https://bitmiracle.com/libtiff/" rel="nofollow noreferrer">https://bitmiracle.com/libtiff/</a></p>
<p>What about using the built in .NET class? See <a href="http://msdn.microsoft.com/en-us/library/aa969817.aspx" rel="noreferrer">"How to: Encode and Decode a TIFF Image"</a> on MSDN.</p>
37,580
<p>i need write the code that runs when DllRegisterServer is called. i.e. when someone calls:</p> <pre><code>regsvr32 myActiveX.ocx </code></pre> <p>i'm trying to find the definitive list of required registry entries (rather than just what i can cobble together by spellunking through the registry).</p> <p>So far my ...
<p>What i know so far. COM creates an object based on it's <em>clsid</em>. This is a guid that uniquely identifies that class. </p> <pre><code>HKEY_CLASSES_ROOT \Clsid \{AE8530CF-D204-4877-9CAB-F052BF1F661F} </code></pre> <p>That class is then used to create objects. COM now needs to know where the DLL is th...
<p>Are you working on a 64 bit OS?</p> <p>If so, instead of writing to<br> HKEY_CLASSES_ROOT\CLSID\<br> you should write to<br> HKEY_CLASSES_ROOT\Wow6432Node\CLSID\</p>
36,114
<p>I am trying to build a server control that, depending on a "QuestionTypeId" display either a text box, date picker or Yes-No radio buttons. </p> <p>I have my control displaying how I want it to, but when the submit button is pressed on the form, the text box, date picker or radio buttons that were generated in the ...
<p>I think you need to create (and add) the controls in <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.control.createchildcontrols.aspx" rel="nofollow noreferrer" title="MSDN">CreateChildControls</a>. This will mean you'll need to store the value of the QuestionTypeId in either Viewstate or ControlState...
<p>When you add controls dynamically, you need to make sure they are recreated before the viewstate is restored.</p> <p>I haven't done this in a while, but from memory I think you should recreate your controls in the OnInit method. This happens before postback data has been loaded and before the controls have their va...
40,979
<p>Is it possible to setup a JDBC connection to Oracle without providing username/password information in a configuration file (or in any other standard readable location)?</p> <p>Typically applications have a configuration file that contains setup parameters to connect to a database. Some DBAs have problems with the ...
<p>You definitely don't want to be able to connect to the database without credentials because that makes the database vulnerable. </p> <p>This is a general problem, how do I store credentials needed to access external systems? WebLogic has a credential mapper to solve this problem, in which credentials (encrypted) a...
<p>You can store the credentials anywhere, including as hardwired strings in the program or as entries in the Windows registry. It's up to you to retrieve them if you use something nonstandard, though; I'm not aware of any pre-rolled solutions that aren't plaintext.</p>
15,415
<p>Say I want to get the HTML of</p> <pre>http://www.google.com</pre> <p>as a String using some built-in classes of the Cocoa Touch framework.</p> <p>What is the least amount of code I need to write?</p> <p>I've gotten this far, but can't figure out how to progress. There must be an easier way.</p> <pre><code>CFHT...
<p>The <i>quickest</i> way is to use NSString's <code>+stringWithContentsOfURL:</code> method. However, this is a modal call, and your application will be non-responsive while it runs. You can either move it to a background thread, or use the NSURLConnection class to make a proper, asynchronous request.</p>
<p>One way to do this is as follows, however as <strong>Ben Gottlieb</strong> points out, this is a synchronouseRequest and will cause your program's execution to wait on the return of this function call, possibly making your application non-responsive. </p> <pre><code>NSURL *url = [ NSURL URLWithString: @"http://www....
29,938
<p>I was really looking at the differences between pass by value and how Java allocates objects and what java does to put objects on the stack.</p> <p>Is there anyway to access objects allocated on the heap? What mechanisms does java enforce to guarantee that the right method can access the right data off the heap?</...
<p>There is no instruction in the JVM instruction set that gives arbitrary access to the heap. Hence, bytecode manipulation will not help you here.</p> <p>The JVM also has a verifier. It checks the code of every method (as a class is being loaded) to verify that the method does not try to pop more values off the execu...
<p>Regarding objects on the stack, it is only the new Java 6 VM from SUN (and perhaps some others) that will try to optimize byte code by putting objects on the stack. Typically, all objects will go into the heap. For reference, check out: <a href="http://www.ibm.com/developerworks/java/library/j-jtp09275.html" rel="no...
36,814
<p>I'm relatively new to Mercurial and my team is trying it out right now as a replacement for Subversion. </p> <p>How can I commit and push a single file out to another repository while leaving other modifications in my working directory uncommitted (or at least not pushed to the other repository)?</p> <p>This happ...
<p>There's a Mercurial feature that implements shelve and unshelve commands, which give you an interactive way to specify changes to store away until a later time: <a href="http://www.selenic.com/mercurial/wiki/index.cgi/ShelveExtension" rel="nofollow noreferrer">Shelve</a>.</p> <p>Then you can <code>hg shelve</code> ...
<p>Since you said easiest, I often use <code>hg commit -i</code> (--interactive) even when committing whole files. With <code>--interactive</code> you can just select the file(s) you want rather than typing their entire path(s) on the command line. As an added bonus you can even selectively include/exclude chunks withi...
15,227
<p>I want to create variables as <code>a1</code>,<code>a2</code>,<code>a3</code>...<code>a10</code>. For that I used a for loop. As the variable in loop increments I need to create a variable as above.</p> <p>Can anyone give me an idea?</p> <p>At the time of creation I also need to be able to assign values to them.</...
<p>Usually, we use a list, not a bunch of individual variables.</p> <pre><code>a = 10*[0] a[0], a[1], a[2], a[9] </code></pre>
<p>You can use the exec function:</p> <pre><code>for i in range(0,10): exec("a%d=%d" % (i,i)) </code></pre> <p>Not very pythonic way of doing things.</p>
48,992
<p>I have TurtoiseSVN and ankhSVN installed. I created a repository on my computer.. "C:\Documents and Settings\user1\My Documents\Subversion\Repository\"</p> <p>I am trying to connect to this repository from my co-workers computer. What should this URL be?</p> <p>Any help would be great. Thanks.</p>
<p>You will need to run the svnserve daemon on your computer, or run an apache server with the necessary modules, to allow your colleague to access this locally stored repository. For a simple case like this I would recommend svnserve, it should be simpler to configure and run.</p> <p>The url would then be:</p> <pre>...
<p>Try svn://xxx.xxx.xxx.xxx/Repository/</p> <p>The default port is 3690 if you have a firewall to configure.</p>
21,068
<p>I'm thinking about making a simple map control in WPF, and am thinking about the design of the basic map interface and am wondering if anyone has some good advice for this. </p> <p>What I'm thinking of is using a ScrollViewer (sans scroll bars) as my "view port" and then stacking everything up on top of a canvas. ...
<p>If you're looking for a good start, you can use the foundation of code supplied by the <a href="https://github.com/SharpMap/SharpMap" rel="nofollow noreferrer">SharpMap</a> project and build out from there. If I recall there were a few people already working on a WPF renderer for SharpMap, so you may also have some ...
<p>The main question is how you store and access the items you are going to put in the map (assuming this isn't just a picture display). Lookup scenegraph for some ideas.</p> <p>Also if you want it to be more than a toy image viewer the lat long to XY scaling can get 'interesting'</p>
11,213
<p>I keep hearing that Flex is open source and I figured that a great way to learn about the inner workings would be to look at it. I can easily find the Flex SDK (<a href="http://opensource.adobe.com/wiki/display/flexsdk/Get+Source+Code" rel="noreferrer">http://opensource.adobe.com/wiki/display/flexsdk/Get+Source+Code...
<p>If you have installed the sdk or Flex builder all of the source files are installed locally on your computer, I believe.</p> <p>I have flex builder 3 installed source is located here(depending on where you installed):</p> <p><em>Source for flex 3 sdk</em></p> <p>C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\fr...
<p>The open source stuff appears to be at:</p> <pre><code>http://opensource.adobe.com/wiki/display/flexsdk/Downloads </code></pre> <p>I don't know if everything is available there yet, there may be issues with third-party stuff.</p>
20,484
<p>I'm working on a C++ application that needs detailed timing information, down to the millisecond level. </p> <p>We intend to gather the time to second accuracy using the standard <code>time()</code> function in <code>&lt;ctime&gt;</code>. We would like to additionally gather the milliseconds elapsed since the las...
<p>Boost.DateTime has millisecond and nanosecond representations <strong>IF</strong> the underlying platform supports them. While it is using platform specific code, it is keeping those details out of your code. </p> <p>If that is a big deal, they do have another way of doing platform independent subsecond resolutio...
<p>Look into the QueryPerformanceCounter methods if this is for Windows.</p>
14,288
<p>Lets just say you have a table in Oracle:</p> <pre><code>CREATE TABLE person ( id NUMBER PRIMARY KEY, given_names VARCHAR2(50), surname VARCHAR2(50) ); </code></pre> <p>with these function-based indices:</p> <pre><code>CREATE INDEX idx_person_upper_given_names ON person (UPPER(given_names)); CREATE INDEX id...
<p>The index can be used, though the optimiser may have chosen not to use it for your particular example:</p> <pre><code>SQL&gt; create table my_objects 2 as select object_id, object_name 3 from all_objects; Table created. SQL&gt; select count(*) from my_objects; 2 / COUNT(*) ---------- 83783 SQL&...
<p>Are you sure you want the index to be used? Full table scans are not bad. Depending on the size of the table, it might be more efficient to do a table scan than use an index. It also depends on the density and distribution of the data, which is why statistics are gathered. The cost based optimizer can usually be...
21,348
<p>(This is a followup to my <a href="https://stackoverflow.com/questions/42468/how-do-i-measure-bytes-inout-of-an-ip-port-used-for-net-remoting">previous question</a> about measuring .NET remoting traffic.)</p> <p>When I am testing our Windows service / service controller GUI combination, it is often most convenient ...
<p>What you should do is to run RawCap, which is a sniffer that can capture traffic to/from the loopback interface in Windows. Just start it with "RawCap.exe 127.0.0.1 loopback.pcap".</p> <p>You can then open up loopback.pcap in Wireshark or <a href="http://www.netresec.com/?page=NetworkMiner" rel="noreferrer">Network...
<p>You should definitely try Npcap, it works perfectly with Wireshark to capture loopback traffic in Windows, see here: <a href="https://wiki.wireshark.org/CaptureSetup/Loopback" rel="nofollow">https://wiki.wireshark.org/CaptureSetup/Loopback</a></p>
6,848
<p>Is there a way to merge two primary keys into one and then cascade update all affected relationships? Here's the scenario:</p> <p>Customers (idCustomer int PK, Company varchar(50), etc)</p> <p>CustomerContacts (idCustomerContact int PK, idCustomer int FK, Name varchar(50), etc)</p> <p>CustomerNotes (idCustomerNo...
<p>There's no automatic way to do it, but you have a couple options, you can manually write the procedures, or you can either code generate the merge on a regular basis or dynamically generate it at run-time. To do this, you can use the <code>INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS</code> and <code>INFORMATION_SCHE...
<p>Consider using Triggers instead. On update of the Customers (idCustomer column), you do whatever needed modifications (Delete, Update ...) on the related tables.</p>
27,638
<p>I have a BLTouch clone (3DTouch) on my printer (Artillery Sidewinder X1). I installed it on the printer ages ago and has been working fine since. Recently, I did a BTT smart filament sensor upgrade.</p> <p>I updated and edited both the Marlin firmware and the MKS TFT28 screen firmware to get it to work with the smar...
<p>So I discovered that the fade height must have been set to something really off.</p> <p>I didn't know this at the time so I thought I should set the fade height to the default 10 mm just to make sure nothing was wrong and tested it. The printer now levels and compensates perfectly!</p>
<p>Make sure <code>RESTORE_LEVELING_AFTER_G28</code> is uncommented in <code>configuration.h</code>.</p>
1,941
<p>It's a tricky question I was asked the other day... We're working on a pretty complex telephony (SIP) application with mixed C++ and PHP code with MySQL databases and several open source components.</p> <p>A telecom engineer asked us to estimate the performance of the application (which is not ready yet). He went l...
<p>You certainly can bound the problem with upper (max throughput) limits. There is nothing nonsense about that. In fact, not knowing that stuff indicates a pretty haphazard approach to a problem - especially in the telephony world. </p> <p>You can work through the problem yourself - what is the minimum "work" you ...
<p>This is true in some domains, but unless you are an expert in that domain then you don't have any idea. For example I write code to controlling industrial robots. The speed is limited by the robot motion, not by the execution speed of the code. Knowing how fast the robot is and how far it has to go, we can make fair...
37,032
<p>I am maintaining an app for a client that is used in two locations. One in England and one in Poland.</p> <p>The database is stored in England and uses the format £1000.00 for currency, but the information is being gathered locally in Poland where 1000,00 is the format.</p> <p>My question is, in VB6 is there a fun...
<p>The data is not actually stored as the string <code>&quot;£1000.00&quot;</code>; it's stored in some numeric format.</p> <blockquote> <p><strong>Sidebar:</strong> Usually databases are set up to store money amounts using either the <strong>decimal</strong> data type (also called <strong>money</strong> in some DBs), ...
<p>What database are you using? And what data type is the amount stored in?</p> <p>As long as you are always converting from one format to another, you do not need to do any parsing, just replace "." with "," or the other way around. You may need to remove the "£"-sign as well if that is stored in your string.</p>
4,017
<p>I have several .NET <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel="nofollow noreferrer">Windows Forms</a> applications that I'm preparing to convert into a <a href="http://en.wikipedia.org/wiki/ClickOnce" rel="nofollow noreferrer">ClickOnce</a>/smart-client deployment scenario. I've read the isn't-this-gr...
<p>Here are a few that I am aware of.</p> <ol> <li><p><strike>Can't put an icon on the desktop.</strike> You can now.</p></li> <li><p>I can't install for all users.</p></li> <li><p>I need to jump through hoops to move the deployment to a different server. It is not a problem if you are developing internally, and the ...
<p>You can't install if the client is behind a proxy that requires authentication.</p>
18,040
<p>I have a program that will calculate the minimal area taken by fitting rectangles together.</p> <p>Input: Rectangles of different height and width.<br> Output: One rectangle that contains all these rectangles.<br> Rules: One cannot turn or roll the rectangles around and they cannot overlap.</p> <p>I understand tha...
<p><a href="http://www-rcf.usc.edu/~skoenig/icaps/icaps04/icapspapers/ICAPS04KorfR.pdf" rel="noreferrer">http://www-rcf.usc.edu/~skoenig/icaps/icaps04/icapspapers/ICAPS04KorfR.pdf</a></p> <p>Apparently this problem is harder than it looks at first. It's an interesting algorithm, since first it guesses a solution and t...
<p>I'd start by skimming through <a href="http://mathworld.wolfram.com" rel="nofollow noreferrer">http://mathworld.wolfram.com</a> - they're awesome for stuff like this.</p> <p>Second, I could envision a dopey algorithm that would put the longest (in the X dimension) box on the bottom, then the tallest (in the Y dimen...
31,326
<p>When my app is run in the iPhone simulator, the delegate method</p> <pre><code>- (void)applicationWillTerminate:(UIApplication *)application </code></pre> <p>is only called the first time I hit the iPhone simulator's home button.</p> <p>After the home button is pressed and the app is launched again, hitting the h...
<p>I suspect that it is being called, but that you are getting confused because after you hit the Home button in the Simulator, you've ended the current session in Xcode. You probably have an <code>NSLog</code> in your <code>applicationWillTerminate:</code> method, yes? Once you hit the Home button, <code>NSLog</code>s...
<pre><code>- (void)applicationWillTerminate:(UIApplication *)application </code></pre> <p>is called when the application "terminates". If you are using iOS then the app will NOT terminate when the home button is pressed, unless you have disabled multi-tasking for your app or the user does not have a "multi-tasking sup...
48,043