instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I looked at the different options for plotting functions (or other types of graphs) in an interactive window. I mostly use wxWidgets but I'd be open to any other "interfaces". </p> <h2><strong>Looking at what is available, here is what I've found</strong>:</h2> <p><strong>wxPlot</strong>: Not updated since 2006. B...
<p>Even though this thread is old but gold. <a href="http://www.qcustomplot.com/">QCustomPlot</a> is very recommendable as well to complement this list.</p>
<p>OpenGL. It WILL be hard and possibly rewriting the wheel, though. Keep in mind that OpenGL is a general 3D library, and not a specific plot library, but you can implement plotting based on it.</p>
37,878
<p>In a database, I have a string that contains "default" written in it. I just want to replace that default with 0. I have something like: </p> <pre><code>select * from tblname where test = 'default' </code></pre> <p>I do not want quotes in the replacement for "default".</p> <p>I want </p> <pre><code>select * from...
<p>I'm assuming the field <code>test</code> is of a text type (varchar, char, or the like).</p> <p>First: Update the table to contain '0' where it contains 'default'.</p> <pre><code>UPDATE tblname SET test = '0' WHERE test = 'default' </code></pre> <p>Then: Select all rows with '0' in them. You can't leave off the q...
<p>I think you would be better using format strings</p> <pre><code>string myVar = "0"; string sql = String.Format(@"select * from tblname where test = \"{0}\"", myVar); </code></pre> <p>You should also ask yourself why you are generating inline SQL on the fly and not using stored procedures as this is how SQL injecti...
35,016
<p>My program generates relatively simple PDF documents on request, but I'm having trouble with unicode characters, like kanji or odd math symbols. To write a normal string in PDF, you place it in brackets:</p> <pre><code>(something) </code></pre> <p>There is also the option to escape a character with octal codes:</p...
<p>The simple answer is that there's no simple answer. If you take a look at the PDF specification, you'll see an entire chapter — and a long one at that — devoted to the mechanisms of text display. I implemented all of the PDF support for my company, and handling text was by far the most complex part of exercise. The...
<p>I'm not a PDF expert, and (as Ferruccio said) the PDF specs at Adobe should tell you everything, but a thought popped up in my mind: </p> <p>Are you sure you are using a font that supports all the characters you need? </p> <p>In our application, we create PDF from HTML pages (with a third party library), and we ha...
15,595
<p>I recently posted a question about Azure... <a href="https://stackoverflow.com/questions/315879/is-azure-an-operating-system-or-a-framework">is it really an OS?</a> I understand the technical details, and I got a lot of fuzzy answers... I really want to know... what do you think is the difference between an OS and ...
<p><a href="http://en.wikipedia.org/wiki/Operating_system" rel="noreferrer">Operating System</a>: The infrastructure software component of a computer system</p> <p><a href="http://en.wikipedia.org/wiki/Framework#Software_framework" rel="noreferrer">Framework</a>: A re-usable design for a software system (or subsystem)...
<p>frameworks provide api contracts that oses usually don't - meaning they sit <em>atop</em> the os, hide and manage the differences, and consequently give you that platform independence goodness that can broaden our target audience</p>
40,791
<p>I'm trying to install faac and am running into errors. Here are the errors I get when trying to build it:</p> <hr> <pre><code>[root@test faac]# ./bootstrap configure.in:11: warning: underquoted definition of MY_DEFINE run info '(automake)Extending aclocal' or see http://sources.redhat.com/automake/automake.ht...
<p>I think the first thing to check is that you have libtool installed.</p> <p>Edit:</p> <p>This is what I get on Ubuntu 8.04:</p> <pre><code>$ ./bootstrap configure.in:11: warning: underquoted definition of MY_DEFINE configure.in:11: run info '(automake)Extending aclocal' configure.in:11: or see http://sources...
<p>Maybe your automake doesn't know about your libtool for some reason. It looks like you've got two copies of libtool installed, which might be confusing it.</p> <p>Maybe you should remove both copies, plus all automake, autoconf installs, and reinstall them (possibly from source?).</p> <p>I guess the first step is ...
13,299
<p>How inefficient is it to get the stack trace for an exception? I know it's costly, but how costly? Should they definitely <em>not</em> be used in production environment?</p>
<p>In a production environment, it's helpful to <em>log</em> the stack trace so the user can find it when they contact tech support. Printing stack trace in place of an understandable (by the typical user) message should be avoided.</p> <p>You shouldn't be concerned with the efficiency of exceptional blocks of code. ...
<p>I usually only print or save the stack trace if I know that it can occur in a part of the system that is heavily dependent on other parts or other systems. This is especially true for pieces responsible for integration as the error might be intermittent and be heavily dependent on the state of the environment.</p>
27,574
<p>We are putting up a company blog at companyname.com/blog but for now the blog is a Wordpress installation that lives on a different server (blog.companyname.com). </p> <p>The intention is to have the blog and web site both on the same server in a month or two, but that leaves a problem in the interim.</p> <p>At th...
<p>Rather than using mod_rewrite, you could use <a href="http://httpd.apache.org/docs/1.3/mod/mod_proxy.html#forwardreverse" rel="nofollow noreferrer">mod_proxy</a> to set up a reverse proxy on companyname.com, so that requests to <a href="http://companyname.com/blog/article-name" rel="nofollow noreferrer">http://compa...
<p>There is functionality with <a href="http://www.zoneedit.com" rel="nofollow noreferrer">ZoneEdit</a> called webforwards which could probably do this and hide what you are actually doing (unless someone looked into it).</p>
18,905
<p>I currently do my textfile manipulation through a bunch of badly remembered AWK, sed, Bash and a tiny bit of Perl.</p> <p>I've seen mentioned a few places that python is good for this kind of thing. How can I use Python to replace shell scripting, AWK, sed and friends?</p>
<p>Any shell has several sets of features.</p> <ul> <li><p>The Essential Linux/Unix commands. All of these are available through the <a href="https://docs.python.org/3/library/subprocess.html" rel="noreferrer">subprocess</a> library. This isn't always the best first choice for doing <em>all</em> external commands. L...
<p>If your textfile manipulation usually is one-time, possibly done on the shell-prompt, you will not get anything better from python.</p> <p>On the other hand, if you usually have to do the same (or similar) task over and over, and you have to write your scripts for doing that, then python is great - and you can easi...
25,707
<p>So, I now know <a href="https://stackoverflow.com/questions/230595/what-artifacts-to-save-for-a-nightly-build">what to save from nightly builds</a>. What about when I give something to customers? </p> <p>For example, I probably want to save debugging information (e.g. PDB).</p> <p>What else?</p>
<p>We use:</p> <ul> <li>installers</li> <li>binaries</li> <li>pdbs</li> <li>tag of source files</li> <li>any other source files that might not be in svn - for example config.status</li> <li>build log</li> </ul> <p>You made me wonder if I'm missing anything important</p>
<p>Trace messages don't necessarily need to be generated by default but the possibility to enable them can be very helpful.</p>
29,447
<p>My .NET application fails when run from a network drive even when the very same executable runs perfectly fine from a local hard drive?</p> <p>I tried checking for "Full trust" like so:</p> <pre><code>try { // Demand full trust permissions PermissionSet fullTrust = new PermissionSet( PermissionState.Unrest...
<p>It indeed has to do with the fact the apps on a network location are less trusted then on your local hdd (due to the default policy of the .NET framework). </p> <p>If I'm not mistaken Microsoft finally corrected this annoyance in .NET 3.5 SP1 (after a lot of developers complaining).</p> <p>I google'd it: <a href="...
<p>This is security built in by microsoft into the .net framework. It's a way of stopping malware to be run locally with full priviliges, so you cannot change this programmatically in the code.</p> <p>What you need to do is increase the trust of specific assemblies. You do this in the .NET Framework Configuration (Con...
17,939
<p>What is the best way to add "Expires" in http header for static content? eg. images, css, js</p> <p>The web server is IIS 6.0; the language is classical ASP</p>
<p>You could try something like this:</p> <pre><code>@ECHO OFF REM --------------------------------------------------------------------------- REM Caching - sets the caching on static files in a web site REM syntax REM Caching.CMD 1 d:\sites\MySite\WWWRoot\*.CSS REM REM %1 is the WebSite ID REM %2 is the pa...
<p>I don't know if this is what you are looking for, but it does keep my pages from being cached.</p> <pre><code>&lt;META HTTP-EQUIV="Pragma" CONTENT="no-cache"&gt; &lt;META HTTP-EQUIV="Cache-Control" CONTENT="no-store"&gt; &lt;META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"&gt; &lt;META HTTP-EQUIV="Expires" CONTEN...
12,776
<p>I work for a software vendor whose market is developer tools and we have been looking for a QA person for our products. </p> <p>Since we are a small shop the position will be a combination of Support and QA however since we make developer tools, our support consists in large part of actual development (in that the ...
<p>Money and responsibility.</p> <p>The reason I shy away from these types of jobs is they dont tend to hold my interest long enough. Having real development tasks should keep you out of that category. The other problem is the salary is usually significantly lower with that in the title.</p>
<p>I think you have a toughie here:</p> <ul> <li>The cost of a full time developer for doing the job you require would be too high.</li> <li>Most dev's (including myself) would get incredibly fed up, very quickly. Most dev's passion is coding, they want to do it as much as possible. Where TBH, from what you have said,...
8,192
<p>I'm wanting to play around with creating an LR parser generators. Does anyone know of a good (free) resource describing how to create a state machine table from a grammar? </p>
<p>For a free resource, consider the Python source code for <a href="http://www.dabeaz.com/ply/" rel="nofollow noreferrer">PLY</a> - a full implementation of Lex and Yacc in Python.</p> <p>I would recommend a book, however, and you can hardly do better than get <a href="https://rads.stackoverflow.com/amzn/click/com/02...
<p>Maybe you find Grammatica useful. It's a free Parser generator for .NET. I have some experience with it and it was good. You can try it and study its code. <a href="http://grammatica.percederberg.net/" rel="nofollow noreferrer">http://grammatica.percederberg.net/</a></p>
39,668
<p>For instance, I have a SqlDataSource that loads a list of items. On my form, I've got 3 dropdown boxes that both should contain that same list of values, and then the user can select a different value for each and save.</p> <p>By hooking up each dropdown list to the same SqlDataSource, the database gets hit three ...
<p>Why don't you enable caching for your datasources?</p>
<p>You should let go of your reliance on direct databindings for form elements and just build a list or array that is replicated or cloned. Then bind to your separate lists to the form elements and "write code" to handle what you want it to do against your datasource.</p>
32,359
<p>I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. </p> <p>What conditions would you use each for?</p>
<p>Both are valuable. I use both doctest and <a href="https://pypi.python.org/pypi/nose/" rel="noreferrer">nose</a> taking the place of unittest. I use doctest for cases where the test is giving an example of usage that is actually useful as documentation. Generally I don't make these tests comprehensive, aiming sole...
<p>I almost never use doctests. I want my code to be self documenting, and the docstrings provide the documentation to the user. IMO adding hundreds of lines of tests to a module makes the docstrings far less readable. I also find unit tests easier to modify when needed. </p>
47,204
<p><a href="http://stephenwalther.com/blog/archive/2008/07/01/asp-net-mvc-tip-12-faking-the-controller-context.aspx" rel="nofollow noreferrer">http://stephenwalther.com/blog/archive/2008/07/01/asp-net-mvc-tip-12-faking-the-controller-context.aspx</a></p> <p>This post shows how to test setting a cookie and then seeing ...
<p>Are you looking for something more like this? (untested, just typed it up in the reply box)</p> <pre><code>var cookies = new HttpCookieCollection(); controller.ControllerContext = new FakeControllerContext(controller, cookies); var result = controller.TestCookie() as ViewResult; Assert.AreEqual("somevaluethatshoul...
<pre><code>function ReadCookie(cookieName) { var theCookie=""+document.cookie; var ind=theCookie.indexOf(cookieName); if (ind==-1 || cookieName=="") return ""; var ind1=theCookie.indexOf(';',ind); if (ind1==-1) ind1=theCookie.length; return unescape(theCookie.substring(ind+cookieName.length+1,ind1)); } </code><...
9,462
<p>I sometimes need to use Visual Studio when I have limited screen real estate (remote desktopping from a laptop for example). <strong>It would be really useful to be able to make the currently selected code tab maximise to take the whole screen for a limited time.</strong> </p> <p>Is that possible? Is there a key...
<p>View->Full Screen (Shift + Alt + Enter)</p> <p>Does that work?</p>
<p>I use Shift-Alt-Enter to activate full screen mode.</p>
20,609
<p>In a VB6 application, I have a <code>Dictionary</code> whose keys are <code>String</code>s and values are instances of a custom class. If I call <code>RemoveAll()</code> on the <code>Dictionary</code>, will it first free the custom objects? Or do I explicitly need to do this myself?</p> <pre><code>Dim d as Script...
<p>Yes, all objects in the <code>Dictionary</code> will be released after a call to <code>RemoveAll()</code>. From a performance (as in speed) standpoint I would say those lines setting the variables to <code>Nothing</code> are unnecessary, because the code has to first look them up based on the key names whereas <cod...
<p>If there are no other variables that reference the items in the collection then those objects should be handed to the Garbage Collector to be cleaned up the next time the GC is run.</p> <p>If you, for example do this where sObj is a static variable somewhere then the when the GC is invoked next by the system, the f...
10,063
<p>I'm writing C# code that needs to connect to COM events. I implemented the use of IConnectionPointContainer and IConnectionPoint thus:</p> <pre><code> IConnectionPointContainer connectionPointContainer = internalGenerator as IConnectionPointContainer; if (connectionPointContainer == null) { ...
<p>IConnectionPointContainer is implemented on the CCW (COM callable wrapper) that .NET automatically generates when exposing your .NET object as a COM object externally.</p> <p>Try calling <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.getcominterfaceforobject.aspx" rel="nofol...
<p>The problem is that doing a GetIUnknownForObject call returns a pointer which you can then successfully call to attain IConnectionPointContainer for the object using its GUID. But, that call to QueryInterface then simply returns the original .NET object, not an IConnectionPointContainer interface.</p> <p>I'm also s...
35,817
<p>I've encrypted the connectionstring in my web.config file using the steps in the link below: <a href="http://www.codeproject.com/KB/database/WebFarmConnStringsNet20.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/database/WebFarmConnStringsNet20.aspx</a></p> <p>However, whenever I call my application,...
<p>Well, I found the source of the problem, and boy was it embarrassing. In the attribute keyContainerName, I spelled the name incorrectly. </p> <p>That it. That's what caused the problem.</p> <p>Apparently, the encryption will work even if you provide an incorrect keyContainerName, which I incorrectly assumed will...
<p>Did you remember to add the </p> <pre><code>&lt;configProtectedData&gt; </code></pre> <p>to your web.config?</p>
13,323
<h2>How are you tracking changes, testing effort for bugs that impact multiple artifacts released separately?</h2> <p>Code sharing is good because it reduces the total number of paths through the code which means more impact for fewer changes and less bugs (or more bugs addressed with fewer changes). For example, we ...
<p>In Jira you can allow sub-tasks so you could assign sub-tasks to the main task. You can also allow time tracking on the issues so you know how much time each task is taking and what the difference between estimated and actual is. </p> <p>You can also enable versioning so you have a road map of what is being done in...
<p>For jira, make use of the affects versions and fixed in versions (plus you can add multiple custom fields, like verified by QA in versions)</p>
36,670
<p>Suppose I have:</p> <ol> <li>Toby</li> <li>Tiny</li> <li>Tory</li> <li>Tily</li> </ol> <p>Is there an algorithm that can easily create a list of common characters in the same positions in all these strings? (in this case the common characters are 'T' at position 0 and 'y' at position 3)</p> <p>I tried looking at...
<p>Finding a list of characters that are common in ALL strings at a certain position is trivially simple. Just iterate on each string for each character position 1 character position at a time. If any string's character is not the match of it's closest neighbor string's character, then the position does not contain a...
<p>In lisp:</p> <pre><code>CL-USER&gt; (defun common-chars (&amp;rest strings) (apply #'map 'list #'char= strings)) COMMON-CHARS </code></pre> <p>Just pass in the strings:</p> <pre><code>CL-USER&gt; (common-chars "Toby" "Tiny" "Tory" "Tily") (T NIL NIL T) </code></pre> <p>If you want the characters thems...
9,422
<p>Is there a function in python to split a word into a list of single letters? e.g:</p> <pre><code>s = &quot;Word to Split&quot; </code></pre> <p>to get</p> <pre><code>wordlist = ['W', 'o', 'r', 'd', ' ', 't', 'o', ' ', 'S', 'p', 'l', 'i', 't'] </code></pre>
<pre><code>&gt;&gt;&gt; list("Word to Split") ['W', 'o', 'r', 'd', ' ', 't', 'o', ' ', 'S', 'p', 'l', 'i', 't'] </code></pre>
<p>def count(): list = 'oixfjhibokxnjfklmhjpxesriktglanwekgfvnk'</p> <pre><code>word_list = [] # dict = {} for i in range(len(list)): word_list.append(list[i]) # word_list1 = sorted(word_list) for i in range(len(word_list) - 1, 0, -1): for j in range(i): if word_list[j] &gt; word_list[j + 1]: ...
13,877
<p>I've done this a <strong>million</strong> times ... setting up a developer work station. </p> <p>Is there a best practices, or installation checklist for installing Microsoft development software on a work station? What about applying updates and/or service packs? Is there a specific order for doing this, in hope...
<p>I would use the following and this order IS KEY if you want to do ASP.NET Development without issue.</p> <ul> <li>Operating System</li> <li>IIS for the OS &lt;- If not done before VS, issues can be had</li> <li>OS Updates</li> <li>Office </li> <li>Office Updates</li> <li>SQL Server and tools</li> <li>SQL Server Upd...
<p>You should be able to install each piece of software regardless of the order you install it in. That being said, if you want to be 'safe', start with the lowest version of each and work you way up, installing the updates/SP's as you go along.</p>
24,610
<p>I saved my VB-Express code as .dll and registered it with regasm and made a .tlb file.</p> <p>But when I try to run a function from it in an Excel-modul I get: <strong>Run-time error ‘453’: Can’t find DLL entry point RegisterServiceProcess in kernel32</strong></p> <p>What step did I miss?</p>
<p>See <a href="http://richnewman.wordpress.com/2007/04/15/a-beginner" rel="nofollow noreferrer">http://richnewman.wordpress.com/2007/04/15/a-beginner</a>’s-guide-to-calling-a-net-library-from-excel/ or better still try out ExcelDNA ( <a href="http://groups.google.com/group/ExcelDna" rel="nofollow noreferrer">http://g...
<p>Try this Microsoft Knowledge Base article: <a href="http://support.microsoft.com/kb/131525" rel="nofollow noreferrer">Can't Run Macro That Calls 16-bit DLL in 32-bit MS Excel</a>.</p> <p>Do you have the proper rights to access the DLL?</p>
11,152
<p>What's the best library to use to generate RSS for a webserver written in Common Lisp?</p>
<p>Most anything will probably do. Personally, I've been using xml-emitter for my blog's Atom feed, which has worked out well so far.</p> <p>Just choose whichever XML generation library you like and hack away, I'd say. As others have remarked, RSS is simple; it's little work to generate it manually.</p> <p>That sai...
<p>I am not aware of any specific RSS library. But the format is fairly simple so any library that can write xml will do at that level.</p> <p>You could have e.g. a look at the nuclblog (<a href="http://cyrusharmon.org/projects?project=nuclblog" rel="nofollow noreferrer">http://cyrusharmon.org/projects?project=nuclbl...
10,256
<p>I'm reading <em>The C++ Programming Language</em> and in it Stroustrup states that the int value of a char can range from 0 to 255 or -127 to 127, depending on implementation. Is this correct? It seems like it should be from -128 to 127. If not, why are their only 255 possible values in the second implementation po...
<p>You're stuck in <a href="http://en.wikipedia.org/wiki/Two%27s_complement" rel="nofollow noreferrer">two's complement</a> thinking - The C++ standard does not define the representation used for negative numbers!</p> <p>If your computer (god forbid) uses <a href="http://en.wikipedia.org/wiki/Ones_complement#Ones.27_c...
<p>My current understanding is that there are three possibilities:</p> <ul> <li><p>If the values are represented as unsigned, a char will range from 0 to 255.</p> </li> <li><p>If the values are represented as signed in two's complement, a char will range from -128 to 127.</p> </li> <li><p>Finally, if the values are rep...
32,972
<p>There are plenty of different Add-Ins for Visual Studio see <a href="http://visualstudiogallery.com" rel="noreferrer">Visual Studio Gallery </a>. Please share your experiences and favorites.</p> <p>As motivation, here are some of my favorites:</p> <ul> <li><a href="http://www.codeproject.com/KB/macros/versioningco...
<p>I'm amazed that <a href="http://www.wholetomato.com/" rel="noreferrer">Visual Assist</a> has not been mentioned yet!</p>
<p>My two pennies worth: <a href="http://www.tabsstudio.com/" rel="nofollow noreferrer">TabStudio</a> and <a href="http://www.hanselman.com/blog/IntroducingRockScroll.aspx" rel="nofollow noreferrer">RockScroll</a>.</p> <p>Tab Studio is uber-awesome when working on WPF / Silverlight apps, trying to keep track of any nu...
49,714
<p>For the Anycubic Kossel Linear Plus I have to upload data to the 3D printer from a software called Arduino and then close it. Then I open Pronterface and put in the right port and baud rate that is in the Arduino files and then click "connect". Afterwards it says </p> <pre><code>connecting... </code></pre> <p>and ...
<p>I know this is coming very late, but I'll post anyway in hopes that it may help somebody else experiencing the same frustration.</p> <p>I received all of the same suggestions again and again on the forums -- about baud rate, COM ports, and a lot else which failed to get Pronterface to connect.</p> <p>At last I pos...
<p>I know this may be a little late, but I bought the same printer and found that I had problems also. To fix this connection issue I first made sure I had no arduino programs open that were trying the connect to the printer. These would not allow Pronterface to connect to my printer. Then if I still had issues I opene...
586
<p>When I add a breakpoint and hit F5 to run in the debugger (I am using my debug build), a dialog pops up telling my my web.config file does not have debug=true in it (which is does) and I get 2 choices a) run without the debugger or b) let visual studio update my web.config file. If I choose b) the web.config is upda...
<p>Open web.config manually and make sure the following line is in there</p> <pre><code>&lt;compilation defaultLanguage="c#" debug="true" /&gt; </code></pre> <p>Now you should be able to debug from VS. If this does not work I suggest that you recreate the project.</p> <p>EDIT: perhaps from what you say it could be t...
<p>If the debug=true is enabled then there is some problem in the Internet Application Server application. Try re-creating the web application and let Visual Studio create the web site.</p> <p>Check also that the cassini web server is set up to be used as the debugging web server in the project properties.</p>
21,939
<p>We have a web service that uses up more and more private bytes until that application stops responding. The managed heap (mostly Gen2) will show some 200-250 MB, while private bytes shows over 1GB. What are possible causes of a memory leak outside of the managed heap?</p> <p>I've already checked for the following...
<p>Make sure your app is complied in release mode. If you compile under debug mode, and deploy that, simply instantiating a class that has an event defined (event doesn't even need to be raised), will cause a small piece of memory to leak. Instantiating enough of these objects over a long enough period of time will c...
<p>Also look for:</p> <ul> <li>COM Assemblies being loaded</li> <li>DB Connections not being closed</li> <li>Cache &amp; State (Session, Application)</li> </ul> <p>Try forcing the Garbage Collector (GC) to run (write a page that does it when it loads) or try the instrumentation, but that's a bit hit and miss in my ex...
36,225
<p>I have to concatenate a bunch of Strings in Javascript and am searching for the fastest way to do so. Let's assume that the Javascript has to create a large XML-"file" that, naturally, consists of many small Strings. So I came up with:</p> <pre><code> var sbuffer = []; for (var idx=0; idx&lt;10000; idx=idx+1...
<p>Changing the line:</p> <p><code>sbuffer.push(‘Data comes here... bla... ’); </code></p> <p>to </p> <p><code>sbuffer[sbuffer.length] = ‘Data comes here... bla... ’; </code></p> <p>will give you 5-50% speed gain (depending on browser, in IE - gain will be highest)</p> <p>Regards.</p>
<p>Beware of IE bad garbage collector! What do you suppose to do with your array after using? Probably it will get GC'd?</p> <p>You can gain perfornace on concatenating with joins, and then lose on post-GC'ing. On the other hand if you leave an array in scope all the time, and NOT reuse it, that can be a good solution...
18,510
<p>I absolutely need to use an IoC container for decoupling dependencies in an ever increasingly complex system of enterprise services. The issue I am facing is one related to configuration (a.k.a. registration). We currently have 4 different environments -- development to production and in between. These environmen...
<p>I use <a href="http://www.ninject.org/" rel="nofollow noreferrer">Ninject</a>. I like the fact that I don't have to use Xml to configure the dependencies. I can just use straight up C# code. There are <a href="http://kohari.org/2008/06/08/attributes-we-dont-need-no-stinkin-attributes/" rel="nofollow noreferrer">m...
<p>I'm not sure whether it will suit your particular case, you didn't mention what platform you're working in, but I've had great success with <a href="http://www.castleproject.org/container/index.html" rel="nofollow noreferrer">Castle Windsor's IOC framework</a>. The dependencies are setup in the config file (it's a ....
6,701
<p>I know a few advanced ways, to change directories. <code>pushd</code> and <code>popd</code> (directory stack) or <code>cd -</code> (change to last directory).</p> <p>But I am looking for quick way to achieve the following:</p> <p>Say, I am in a rather deep dir:</p> <pre><code>/this/is/a/very/deep/directory/struct...
<p>Do you mean that the path names are the same, and only one directory name changes ("a" becomes "another")? In that case:</p> <pre><code>cd ${PWD/a/another} </code></pre> <p>will switch to the other directory. <code>$PWD</code> holds your current directory, and <code>${var/foo/bar}</code> gives you <code>$var</code...
<pre><code>cd ^/a/^/another/ </code></pre>
8,592
<p>I am working on a ASP.NET app and i have a need to post back to the server after a file is chosen in a FileUpload control without having to have the user explicitly click a 'submit' button. Is this possible? and if so, how?</p>
<p>I'm assuming you want to make the upload start right away. If so, you should react to the <code>change</code> event in JavaScript, and simply make it submit the form.</p> <pre><code>&lt;!-- HTML code ---&gt; &lt;input type="file" onchange="if (confirm('Upload ' + this.value + '?')) this.form.submit();" &gt; <...
<p>The first answer had the right javascript, but ASP.NET does not necessarily expose the input control directly, so it is better to put the onchange event on the FileUpload control.</p> <pre><code>&lt;asp:FileUpload ID="myFileUpload" onchange="if (confirm('Upload ' + this.value + '?')) this.form.submit();" runat="ser...
47,850
<p>I need to print out data into a pre-printed A6 form (1/4 the size of a landsacpe A4). I do not need to print paragraphs of text, just short lines scattered about on the page.</p> <p>All the stuff on MSDN is about priting paragraphs of text. </p> <p>Thanks for any help you can give, Roberto</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,813
<p>I have an access database with 3 tables.</p> <ul> <li>People </li> <li>Gifts</li> <li>PeopleGifts</li> </ul> <p>Using VS 2008, what is the quickest way to get a page up and running which allows me to run queries against these tables and do basic inserts.</p> <p>I want to have comboboxs bound to fields in the tab...
<p>The quickest way? <a href="http://www.ironspeed.com/" rel="nofollow noreferrer">Iron Speed</a></p>
<p>try using an oleDBDataAdapter and a formview</p>
29,442
<p>What are release notes for and who reads them? Should/could they be automated by just spitting out bug fixes for the current release, or do they warrant careful human editing? So, anybody with a link to best practices(reasoning behind) in regards to software release notes?</p>
<p>Bugfixes and added features. Users will read them to determine if they should go to the trouble of installing an incremental upgrade, or wait until the next release because this one doesn't add any features they need or fix any bugs in features that they were using.</p> <p>I'd say they at least require a human to r...
<p>This is of course highly dependent on the type of application/service/whatnot,<br> but I've found that reading the release notes of my favorite developing tools etc..<br> often make me stumble upon nice, interesting or even killer features that I'd probably miss if I did'nt at least skim the notes.....well, perha...
40,748
<p>In jQuery, if I assign <code>class=auto_submit_form</code> to a form, it will be submitted whenever any element is changed, with the following code:</p> <pre><code>/* automatically submit if any element in the form changes */ $(function() { $(".auto_submit_form").change(function() { this.submit(); }); }); <...
<pre><code> /* submit if elements of class=auto_submit_item in the form changes */ $(function() { $(".auto_submit_item").change(function() { $("form").submit(); }); }); </code></pre> <p>Assumes you only have one form on the page. If not, you'll need to do select the form that is an ancestor of the current...
<p>I came up with a generic approach to this:</p> <pre><code>$('.autoSubmit, .autoSubmit select, .autoSubmit input, .autoSubmit textarea').change(function () { const el = $(this); let form; if (el.is('form')) { form = el; } else { form = el.closest('form'); } form.submit(); }); </code></pre> <p>...
42,724
<p><strong>Bounty:</strong> I will send $5 via paypal for an answer that fixes this problem for me.</p> <p>I'm not sure what VS setting I've changed or if it's a web.config setting or what, but I keep getting this error in the error list and yet all solutions build fine. Here are some examples:</p> <pre> Error 5 ...
<p>I had the same error recently. Here's how I fixed it (I hope it works for you too):</p> <p>-Open your project properties, go to the references section.</p> <p>-Remove the reference to System in the upper section.</p> <p>I think it's referencing System twice but it's only showing once. Hence the ambigous referenc...
<p>When asking for help diagnosing compilation problems, it often helps to post the offending source code :)</p> <p>These errors really mean that the specified name conflicts with another and the compiler cannot resolve this. It does look a little odd tho..</p>
3,563
<p>How can I insert compilation timestamp information into an executable I build with Visual C++ 2005? I want to be able to output something like this when I execute the program:</p> <blockquote> <p>This build XXXX was compiled at dd-mm-yy, hh:mm.</p> </blockquote> <p>where date and time reflect the time when the p...
<p>Though not your exact format, <strong>DATE</strong> will be of the format Mmm dd yyyy, while <strong>TIME</strong> will be of the format hh:mm:ss. You can create a string like this and use it in whatever print routine makes sense for you:</p> <pre><code>const char *buildString = "This build XXXX was compiled at " _...
<p>Visual C++ also supports <code>__TIMESTAMP__</code> which is almost exactly what you need. That being said, the tough part about build timestamps is keeping them up to date, that means compiling the file in which <code>__TIMESTAMP__</code> is used on every rebuild. Not sure if there's a way to set this up in Visua...
4,537
<p>Sometimes whenever I write a program in Linux and it crashes due to a bug of some sort, it will become an uninterruptible process and continue running forever until I restart my computer (even if I log out). My questions are:</p> <ul> <li>What causes a process to become uninterruptible?</li> <li>How do I stop that...
<p>An uninterruptible process is a process which happens to be in a system call (kernel function) that cannot be interrupted by a signal.</p> <p>To understand what that means, you need to understand the concept of an interruptible system call. The classic example is <code>read()</code>. This is a system call that can t...
<p>If you are talking about a "zombie" process (which is designated as "zombie" in ps output), then this is a harmless record in the process list waiting for someone to collect its return code and it could be safely ignored.</p> <p>Could you please describe what and "uninterruptable process" is for you? Does it surviv...
27,620
<p>I noticed that the most popular tag (82 questions tagged) is <a href="https://3dprinting.stackexchange.com/questions/tagged/3d-printer">3d-printer</a>, and that we also have a <a href="https://3dprinting.stackexchange.com/questions/tagged/3d-printing">3d-printing</a> tag (23 questions). These seem extremely redundan...
<p>This tag has been removed from the system and made intrinsic. </p> <p><a href="https://3dprinting.stackexchange.com/questions/tagged/untagged">Please cleanup the questions that now have no tags...</a></p>
<p>The fact that there is a synonym appears to be the reason that both tags are still hanging around, in the <a href="https://3dprinting.stackexchange.com/tags/synonyms">list of synonyms</a>:</p> <blockquote> <p><a href="https://i.stack.imgur.com/RpBnK.png" rel="nofollow noreferrer" title="Synonyms"><img src="https:...
35
<p>I am working on a client proposal and they will need to upgrade their network infrastructure to support hosting an ASP.NET application. Essentially, I need to estimate peak usage for a system with a known quantity of users (currently 250). A simple answer like "you'll need a dedicated T1 line" would probably suffice...
<p>Try the <a href="http://www.spasche.net/openinbrowser/" rel="noreferrer">Open in browser extension</a>.</p> <p>[edit 30.05.2010 - updated the link]</p>
<p>Having JSON sent with an application/json mimetype is correct and changing that would be wrong.</p> <p>text/javascript is considered obsolete.</p>
12,038
<p>In C++ the storage class specifier static allocates memory from the data area. What does "data area" mean?</p>
<p>In addition to what Konrad said, declaring a variable as static basically means that the memory for it gets allocated with the program as it is loaded, as opposed to on the heap or the stack. Historically, using only static variables in a critical applications meant that the memory footprint of the application woul...
<p>I think 'data area' is referring to the heap, whereas local variables would usually be located on the stack.</p> <p>Or it means that the memory allocated for this variable is located in the .data section of the executable, but that would be specific to Windows and the PE format.</p>
18,975
<p>I'm working with a number of 'helper' classes, which affectively have a bunch of static functions which allow the controllers and actions have access to chunks of shared functionality.</p> <p>Problem is that these files have been used as a dumping ground for any functionality which is required across the modules/ap...
<p>Take a look at the <a href="http://www.php.net/autoload" rel="nofollow noreferrer">autoloading feature</a>. this will reduce all your includes down to only what is required, when it is required.</p>
<p>Your best bet when constructing such dependencies to stay "acyclic". You can have higher-level functionality "require" the low level functionality it needs to operate, but design it in a way so that things do not point to each other.</p> <p>This way, by breaking it into small enough units you will be able to ensure...
21,475
<p>I still havent' figured out active directory, so I was hoping you guys could recommend some 3rd party components that would have all the built in methods done for me :)</p> <p>I usually build my own users table with permissions/role tables, but want to add active directory as an option so you can tap into users alr...
<p>You didn't specify a language. Here's one for .NET:</p> <p><a href="http://www.dotnetactivedirectory.com/" rel="nofollow noreferrer">http://www.dotnetactivedirectory.com/</a></p>
<p>If you're using .NET 3.5, you can use the <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.aspx" rel="nofollow noreferrer">System.DirectoryServices.AccountManagement</a> namespace to make AD operations a whole lot easier.</p>
46,132
<p>I've got a form that's a few pages long. To traverse the form all I'm doing is showing and hiding container divs. The last page is a confirmation page before submitting. It takes the contents of the form and lays it out so the user can see what he/she just filled out. If they click on one of these it'll take them ba...
<p>Without getting too complicated, you can make a function that handles the repetitive stuff. I haven't tested this, but you'll get the idea:</p> <pre><code>function valField(fieldName,navName) { var output = '&lt;a href="javascript://" onclick="$(\''+navName+'\').click();$(\'input#'+fieldName+'\').focus();" titl...
<p>I'd start with an introduction to arrays: <a href="http://www.hunlock.com/blogs/Mastering_Javascript_Arrays" rel="nofollow noreferrer">this one</a> looks pretty decent, for starters.</p> <p>Wrap your head around arrays and loops to get started, and you'll be well served.</p>
31,792
<p>I need to write a program that can sift through specially-formatted text files (essentially CSV files with a fixed set of column types that have different delimiters for some columns ... comma in most places, colons in others) to search for formatting errors. I figure regular expressions will be the way to go.</p> ...
<p>Use the Regex COM component built into Windows. You can find a step by step on referencing and using it in your project at: <a href="http://www.regular-expressions.info/vb.html" rel="nofollow noreferrer">http://www.regular-expressions.info/vb.html</a></p>
<p>Use the Regex COM component built into Windows. You can find a step by step on referencing and using it in your project at: <a href="http://www.regular-expressions.info/vb.html" rel="nofollow noreferrer">http://www.regular-expressions.info/vb.html</a></p>
6,643
<p>I am using ReSharper and love it!</p> <p>However I have one problem, when i hit Shift-Alt-L ReSharper only locates the file in solution explorer if the folder it is located in is open. If the folder is not open, ReSharper doesn't locate the file.</p>
<p>Actually, for ReSharper 4.5 we found a way to workaround this problem of VS, so in ReSharper 4.5 this is no longer an issue. </p>
<p><kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>N</kbd> combined with Visual Studio's "Track Item In Solution Explorer" works for me. The drawback is that the file is actually opened.</p>
46,774
<p>Does anyone know if there is an API to get the current monitor state (on or off) in Windows (XP/Vista/2000/2003)?</p> <p>All of my searches seem to indicate there is no real way of doing this. </p> <p><a href="http://www.promixis.com/forums/archive/index.php/t-1282.html" rel="noreferrer">This thread</a> tries to u...
<p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa372690%28v=vs.85%29.aspx" rel="nofollow noreferrer">GetDevicePowerState</a> <em>sometimes</em> works for monitors. If it's present, you can open the <code>\\.\LCD</code> device. Close it immediately after you've finished with it.</p> <p>Essentially...
<p>If your monitor has some sort of built-in USB hub, you could try and use that to detect if the monitor is off/on.<br> This will of course only work if the USB hub doesn't stay connected when the monitor is consider "off".</p>
24,879
<p>We're reviewing one of the company's system's exception handling and found a couple of interesting things.</p> <p>Most of the code blocks (if not all of them) are inside a try/catch block, and inside the catch block a new BaseApplicationException is being thrown - which seems to be coming from the Enterprise Librar...
<p><strong>Never</strong><sup>1</sup> <code>catch (Exception ex)</code>. Period<sup>2</sup>. There is no way you can handle all the different kinds of errors that you may catch.</p> <p>Never<sup>3</sup> catch an Exception-derived type if you can't handle it or provide additional information (to be used by subsequent e...
<p>Sounds like the exception that is thrown should not have been implemented as an exception. </p> <p>Anyway, I would say that since this BaseApplicationException is a general all-purpose exception, it would be good to throw exceptions that are more context-specific. So when you are trying to retrieve an entity from a...
16,078
<p>After switching back and forth between several scripting languages this week, I found myself thinking how similar they all are. Yet I'm always reaching for Google (or nowadays SO) to remember details like what the local equivalents of "instanceof" and "endswith" are, or the right syntax to declare an interface, or ...
<p>I would suggest that the main problem is recognising what the syntax of each statement is supposed to be. </p> <p>In any case, what is the point? Almost all scripting languages have facilities to do much the same things, which is why people tend to master one that they use consistently, and stick with it.</p>
<p>I have begun to see that syntax is but one property of a language. And most of them look like C to me. The purpose of a language (object oriented, strong typing, etc) is something else again. It starts to look like syntax is not the most important aspect.</p> <p>I went and read the wikipedia entry...</p> <block...
23,782
<p>How can I maintain the scroll position of a treeview control in .NET application? For example, I have a treeview control and go through a process of adding various nodes to it tacking them on to the bottom. During this process, I can scroll through the treeview and view different nodes. The problem is when the proce...
<p>I think I figured it out:</p> <ol> <li>Get the node at the top of the treeview.</li> <li>Expand the parent node.</li> <li>Make the node that was previously at the top visible.</li> </ol> <blockquote> <pre><code>If treeNodeParent.IsExpanded = False Then Dim currentNode As TreeNode = TreeViewHosts.GetNodeAt(0, 0...
<p>The best thing is to use UpdatePanel and nest your treeview tags inside it. For example,</p> <pre><code>&lt;asp:UpdatePanel id="UpdatePanel"&gt; &lt;ContentTemplate&gt; &lt;asp:TreeView id="TreeView"&gt; &lt;/asp:TreeView&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pr...
43,125
<p>I'm using the Infragistics grid and I'm having a difficult time using a drop-down list as the value selector for one of my columns.</p> <p>I tried reading the documentation but Infragistics' documentation is not so good. I've also taken a look at this <a href="http://news.infragistics.com/forums/p/9063/45792.aspx" ...
<p>Here's an example from one of my pages:</p> <pre><code>UltraWebGrid uwgMyGrid = new UltraWebGrid(); uwgMyGrid.Columns.Add("colTest", "Test Dropdown"); uwgMyGrid.Columns.FromKey("colTest").Type = ColumnType.DropDownList; uwgMyGrid.Columns.FromKey("colTest").ValueList.ValueListItems.Insert(0, "ONE", "Choice 1"); uwgM...
<pre><code> public void MakeCellValueListDropDownList(UltraWebGrid grid, string columnName, string valueListName, string[] listArray) { //Set the column to be a dropdownlist UltraGridColumn Col = grid.Columns.FromKey(columnName); Col.Type = ColumnType.DropDownList; Col...
3,602
<p>I have a std::vector containing a handful of numbers, which are not in any particular order, and may or may not have gaps between the numbers - for example, I may have { 1,2,3, 6 } or { 2,8,4,6 } or { 1, 9, 5, 2 }, etc.</p> <p>I'd like a simple way to look at this vector and say 'give me the lowest number >= 1 whic...
<p>The checked answer uses &lt; for comparison. != is much simpler:</p> <pre><code>int find_gap(std::vector&lt;int&gt; vec) { std::sort(vec.begin(), vec.end()); int next = 1; for (std::vector&lt;int&gt;::iterator it = vec.begin(); it != vec.end(); ++it) { if (*it != next) return next; ++next...
<p><strong>A possible implementation of Thomas Kammeyer's answer</strong></p> <p>I found Thomas' approach really smart and useful - since some of us dream in code and I find the actual implementation a bit tricky I wanted to provide some ready-to-use code.</p> <p>The solution presented here is as generic as possible:...
49,708
<p>I have a 2D area with "dots" distributed on this area. I now am trying to detect "clusters" of dots, that is, areas with a certain high density of dots.</p> <p>Any thoughts on (or links to articles with thoughts on) how to elegantly detect these areas?</p>
<p>How about defining an arbitrary resolution for your space, and calculate for each point in that matrix, a measure of the distance from that point to all dots, then you could make a "heat graph" and use a threshold to define the clusters.</p> <p>It's a nice exercise for processing, maybe later I will post a solution...
<p>I would calculate the distances from each point to all other points. Then sort the distances. Points that have a distance from each other that is below a threshold are considered <em>Near</em>. A group of points that is <em>near</em> to each other is a cluster.</p> <p>The problem is that <em>cluster</em> may be cle...
46,422
<p>I need to find whether the user clicking the browser back button or Refresh button.</p> <p>I need to redirect the page to Error page when he clicks the back or refresh button. How to do this.</p> <p>I need to do this in javascript for my ASP.net page</p>
<p>First of all, giving error messages if users use Back or have to refresh a page for whatever reason, is a really bad idea. Instead, you should transparently deal with that. Think about a page not coming up fully because of problems on the transportation level - the only option the user has is to reload or go back.</...
<p>.NET 3.5 can very well handle the browser back (and forward) buttons. Search with Google: "Scriptmanager EnableHistory". You can control which user actions will add an entry to the browser's history (ScriptManager -> AddHistoryPoint) and your ASP.NET application receives an event whenever the user clicks the browse...
37,285
<p>I'm printing PLA with the Creality Ender 2 and my print comes out totally fine with the exception of the first layer.</p> <p>Here's the weird part though, if I place a raft or a brim below/around the print - the raft or brim will print perfectly cleanly. Even on a raft though, the very first layer of the actual pri...
<p>Turns out it had to do with the nature of the small holes that I was printing. I had to slow the speed of the initial layer down from 25mm/s to 15mm/s and also set Cura to 'optimize wall printing order' so that it didn't jump back and forth between holes constantly. </p> <p>I also sped up the travel speed to 50mm/s...
<p>Sounds like you need to get the printing nozzle closer to the bed. In the case of the raft you can adjust the 'air gap' which is how much it raises off the top of the raft before starting the print.</p>
985
<p>Is there an easy way to verify that a given private key matches a given public key? I have a few <code>*.pub</code>and a few <code>*.key</code> files, and I need to check which go with which.</p> <p>Again, these are pub/key files, DSA.</p> <p>I would really prefer a one-liner of some sort...</p>
<p>I found a way that seems to work better for me:</p> <pre><code>ssh-keygen -y -f &lt;private key file&gt; </code></pre> <p>That command will output the public key for the given private key, so then just compare the output to each *.pub file.</p>
<p>Just use <a href="http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html" rel="nofollow noreferrer">puttygen</a> and load your private key into it. It offers different options, e.g. exporting the corresponding public key.</p>
34,588
<p>Helo!</p> <p>Is this possible to use string value of one node which tells what type of field is presented in another node using LINQ to XML?</p> <p>For example:</p> <pre><code>&lt;node&gt; &lt;name&gt;nodeName&lt;/name&gt; &lt;type&gt;string&lt;/type&gt; &lt;/node&gt; &lt;node&gt; &lt;name&gt;0&lt;/name&gt;...
<p>Well, you won't get a nice statically typed API given that the type information is only known at execution time - but you could easily write an extension method on XElement which looks for the appropriate subelements and returns <code>System.Object</code>. For instance (untested):</p> <pre><code>public static objec...
<pre><code>public static void Main() { var xmlNodes = new XElement( "Nodes", new XElement( "Node", new XElement( "Name", "nodeName" ), new XElement( "Type", "string" ) ), new XElement( "Node", new XElement( "Name", "True" ), new XElement( "Type...
37,506
<p>I have a bunch of XML that has lines that look like this</p> <pre><code>&lt;_char font_name="/ITC Stone Serif Std Bold" italic="true" /&gt; </code></pre> <p>but sometimes look like this</p> <pre><code>&lt;_char font_size="88175" italic="true" font_name="/ITC Stone Serif Std Bold" /&gt; </code></pre> <p>Here's wh...
<p>Does the simple use of '|' operator satisfy you ?</p> <pre><code>name="/ITC Stone Sans Std Bold"[^&gt;]italic="(true)"|italic="(true)"[^&gt;]font_name="/ITC Stone Serif Std Bold" </code></pre> <p>That should detect any line with the attribute name before of after attribute italic with value true.</p>
<p>In Perl - untested:</p> <pre><code>while (&lt;&gt;) { s/italic="true"/italic="false"/ if m%font_name="/ITC Stone Sans Std Bold" italic="true"|italic="true" font_name="/ITC Stone Serif Std Bold"%; print; } </code></pre> <p>Very simple minded - might need a global qualifier, might need a more complex substit...
24,067
<p>I have a fairly simple addition to the HTTP standard. An ambitious goal I know, but I'd at least like to submit a proposal and get feedback on the idea. What is the proper forum/method of doing so?</p>
<p>The current HTTP standard falls under the Internet Engineering Task Force (IETF) working group Hypertext Transfer Protocol Bis (<a href="http://www.ietf.org/html.charters/httpbis-charter.html" rel="noreferrer">httpbis</a>). The page there shows the contact information for the group and the current modifications/clar...
<p>According to W3C's <a href="http://www.w3.org/Protocols/" rel="nofollow noreferrer">HTTP page</a>:</p> <blockquote> <p>Now that both HTTP extensions and HTTP/1.1 are stable specifications, W3C has closed the HTTP Activity. The Activity has achieved its goals of creating a successful standard that addres...
26,477
<p>Probably a very stupid question but I can't figure how to rename an object in PowerPoint.. For example, all my Graphs are called by default "Graph 1" etc. Could someone help me on that? Thanks!</p>
<p>In PowerPoint 2007 you can do this from the Selection pane.</p> <p>To show the Selection pane, click on the Home tab in the ribbon, then click on Arrange and then 'Selection Pane...' at the bottom. The Selection pane will open on the right. (Or press CTRL+F10)</p> <p>To rename an object, first select the object a...
<p>Thanks for your help but actually I am just doing it using VBA...</p> <pre><code>ActiveWindow.Selection.ShapeRange(1).Name = "newname" </code></pre> <p>Cheers</p>
15,849
<p>I've been a web developer for some time now, and have recently started learning some functional programming. Like others, I've had some significant trouble apply many of these concepts to my professional work. For me, the primary reason for this is I see a conflict between between FP's goal of remaining stateless ...
<p>First of all, I would not say that CLOS (Common Lisp Object System) is "pseudo-OO". It is first class OO.</p> <p>Second, I believe that you should use the paradigm that fits your needs.</p> <p>You cannot statelessly store data, while a function is flow of data and does not really need state.</p> <p>If you have s...
<p>Databases and Functional Programming can be fused.</p> <p>for example:</p> <p>Clojure is a functional programming language based on relational database theory.</p> <pre><code> Clojure -&gt; DBMS, Super Foxpro STM -&gt; Transaction,MVCC Persistent Collections -&gt; db, table, col ...
42,795
<p>Is it possible to have a HasMany relationship of a basic type such as String, on an ActiveRecord class, without the need for creating another entity such as (TodoListItem) to hold the value.</p> <pre><code>[ActiveRecord] public class TodoList { [PrimaryKey] public int Id { get { return _id; } set { _...
<p>Yes, you can do this. You can map a one-to-many relation to a built-in or simple type (value type or string) rather than a persisted type. </p> <p>You'll need to specify the <code>ColumnKey</code>, <code>Table</code> and <code>Element</code> params in the <code>HasMany</code> attribute declaration to get it to wire...
<p>In ActiveRecord, your types map to a record in a table (by default). It seems like you are confusing how this type should map to your table.</p> <p>The MyClass type should have a definition something like this (excluding the PK settings):</p> <pre><code>[ActiveRecord(Table = "MyTable")] public class MyClass : Act...
20,228
<p>Well, the question is pretty much in the title. I've just installed Visual Studio SP1, and now when I want to import a Entity Model from a database, it doesn't display the SQL Anywhere provider anymore.</p> <p>Does anyone know if there is a patch or some way to make it work with SP1?</p> <p>Thanks.</p>
<p>There is a post on the <a href="http://blogs.msdn.com/adonet/archive/2008/08/11/third-party-provider-support-for-the-entity-framework-rtm.aspx" rel="nofollow noreferrer">ASP.NET Team blog</a> that it will be available in Q3-Q4 of 2008. So I guess SP1 does need a new version of SQL Anywhere component.</p> <p>Did you...
<p>I had the same issue and did the following:</p> <ol> <li>Control Panel -> Uninstall a program</li> <li>Selected SQL Anywhere 12 - Client an clicked Repair. This made me unable to connect to any database from Sybase Central with an error message about JDBC.</li> <li>Selected SQL Anywhere 12 and clicked Repair.</li> ...
15,641
<p>C# .NET 3.5. I'm trying to understand the intrinsic limitation of the C# Action object. Within the lamda (are those, in fact, lamdas?), we can perform assignments, call functions, even execute a ternary operation, but we can't execute a multi-statement operation.</p> <p>Is this because the single-statement execut...
<p>You are missing a semi-colon, it compiles:</p> <pre><code> Action action = () =&gt; { if (m_Count &lt; 10) m_Count++; value = m_Count; }; </code></pre> <p>When you say <code>type name = statement;</code> you need a semicolon even if you use braces for a code block.</p>
<p>cfeduke has posted the solution to getting your code to compile.</p> <p>Note that you can't convert statement-block lambda expressions into expression trees, even though you can convert them into delegates. There are <a href="http://csharpindepth.com/ViewNote.aspx?NoteID=68" rel="noreferrer">other limitations</a> o...
28,993
<p>I'm looking for a macro which can be run to select a consistent range of cells so that I can easily copy them to another spreadsheet. The range would be F3:BJ3.</p>
<p>This should do the trick:</p> <pre><code>Public Sub selectCells() Range("F3:BJ3").Select End Sub</code></pre> <p><b>edit:</b> for that matter, you can use the following to actually perform the 'copy' command for you as well:</p> <pre><code>Public Sub selectCellsAndCopy() Range("F3:BJ3").Select Selecti...
<p>Use this one it is working fine.</p> <pre><code>Sub On_Click() ActiveSheet.Range("A1:E1").Select End Sub </code></pre>
46,594
<p>I would like to search the bodies of all outlook items. I know how to do this for the four PIM items (Notes/Tasks/Appointments/Contacts). But the code is identical for all of them with the exception of casting the COM object to the specific item type (i.e., ContactItem, AppointmentItem, etc). Is there a parent cla...
<p>Looking at the documentation, I don't see a class like you want.</p> <p>For Outlook 2007, the list of objects that can be in an Items collection is <a href="http://msdn.microsoft.com/en-us/library/bb147566.aspx" rel="nofollow noreferrer">here</a>. It includes things like distribution lists that don't have a body, ...
<p>While the PIM items might be derived from a common class, it is not creatable through the com object, but, all <a href="http://msdn.microsoft.com/en-us/library/bb207137.aspx" rel="nofollow noreferrer"><strong>items</strong></a> also return a <a href="http://msdn.microsoft.com/en-us/library/bb208118.aspx" rel="nofoll...
37,003
<p>Believe it or not I need a way of displaying animated gifs in Flex 3. This guy has a component for sale but it's Flex 2 only: <a href="http://dougmccune.com/blog/2007/01/19/how-to-load-animated-gifs-using-adobe-flex-20/" rel="nofollow noreferrer">http://dougmccune.com/blog/2007/01/19/how-to-load-animated-gifs-using-...
<p>i bought and used the mccune product but have now changed to flex 3. i found your question by searching for the same answer as you and have just come across this</p> <p><a href="http://flexology.wordpress.com/2008/09/30/loadinganimated_gif_in_flex/" rel="nofollow noreferrer">http://flexology.wordpress.com/2008/09/3...
<p>Does <a href="http://code.google.com/p/as3gif/" rel="nofollow noreferrer">this</a> help?</p> <p>Edit: I've no idea how well that suggestion works on a larger GIF, but if you're still having issues, it might be worth importing the GIF into Flash and turning it into its own SWF.</p> <p>Flex should be more than able ...
18,350
<p>How do I get it to work with my project?</p> <p><a href="http://ajax.asp.net/" rel="noreferrer">http://ajax.asp.net/</a></p> <p><a href="http://www.codeplex.com/AjaxControlToolkit/" rel="noreferrer">http://www.codeplex.com/AjaxControlToolkit/</a></p>
<p><strong>Install the ASP.NET AJAX Control Toolkit</strong></p> <ol> <li><p>Download the ZIP file AjaxControlToolkit-Framework3.5SP1-DllOnly.zip from the <a href="http://www.codeplex.com/AjaxControlToolkit/Release/ProjectReleases.aspx?ReleaseId=16488" rel="noreferrer">ASP.NET AJAX Control Toolkit Releases</a> page of...
<p>you will also need to have a asp:ScriptManager control on every page that you want to use ajax controls on. you should be able to just drag the scriptmanager over from your toolbox one the toolkit is installed following Zack's instructions.</p>
6,131
<p>Can anyone explain the differences between <strong>Protocols</strong> and <strong>Categories</strong> in Objective-C? When do you use one over the other?</p>
<p>A protocol is the same thing as an interface in Java: it's essentially a contract that says, <strong>"Any class that implements this protocol will also implement these methods."</strong></p> <p>A category, on the other hand, just binds methods to a class. For example, in <strong>Cocoa</strong>, I can create a categ...
<p>Protocols are contracts to implement the specified methods. Any object that conforms to a protocol agrees to provide implementations for those methods. A good use of a protocol would be to define a set of callback methods for a delegate (where the delegate must respond to all methods).</p> <p>Categories provide the...
47,112
<p>Our shop designs and create custom software applications for a vareity of vertical industies. We currently use a modified version of the <a href="http://www.lhotka.net/" rel="nofollow noreferrer">Csla</a> framework for most of our development. </p> <p>It's a <strong>great framework</strong>, supports a vareity of...
<blockquote> <p>The cons of the framework are the fact that you are at the mercy of how the creator implements changes and technology and all the many features that you do not use.</p> </blockquote> <p>It would seem that you will be exposed to these same cons with LINQ so keep that in mind when making a chan...
<p>I read a good blog by Rick Strahl called <a href="http://www.west-wind.com/WebLog/posts/160237.aspx" rel="nofollow noreferrer">A Simple Business Object Wrapper for LINQ to SQL</a> that answers some of my questions. He takes some time an explains his viewpoints on frameworks.</p>
37,498
<p>In effect, if I have a <code>class c</code> and instances of <code>$c1</code> and <code>$c2</code> which might have different private variable amounts but all their public methods return the same values I would like to be able to check that <code>$c1 == $c2?</code></p> <p>Does anyone know an easy way to do this?</...
<p>You can also implement a equal($other) function like</p> <pre> &lt;?php class Foo { public function equals($o) { return ($o instanceof 'Foo') && $o.firstName()==$this.firstName(); } } </pre> <p>or use foreach to iterate over the public properties (this behaviour might be overwritten) of one object ...
<p>You can try writing a class of your own to plugin and write methods that do comparison based on what you define. For example:</p> <pre><code>class Validate { public function validateName($c1, $c2) { if($c1-&gt;FirstName == "foo" &amp;&amp; $c2-&gt;LastName == "foo") { return true; } ...
7,954
<p>How can I use CRTP in C++ to avoid the overhead of virtual member functions?</p>
<p>There are two ways.</p> <p>The first one is by specifying the interface statically for the structure of types:</p> <pre><code>template &lt;class Derived&gt; struct base { void foo() { static_cast&lt;Derived *&gt;(this)-&gt;foo(); }; }; struct my_type : base&lt;my_type&gt; { void foo(); // required to co...
<p><a href="http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern" rel="nofollow noreferrer">This</a> Wikipedia answer has all you need. Namely:</p> <pre><code>template &lt;class Derived&gt; struct Base { void interface() { // ... static_cast&lt;Derived*&gt;(this)-&gt;implementation...
32,815
<p>Is there a Firefox plugin for manipulating and deleting saved form data? In the browser there is only the option to delete all data.</p>
<p>You can use the <a href="http://code.google.com/p/sqlite-manager/" rel="nofollow noreferrer">SQLite Manager</a> to access the form history database directly. Just select the profile <code>formhistory.sqlite</code>.</p>
<p>I am using FFv 3.0.4.</p> <p>Using Tools -> Clear Private Data, invoke a pop-up.</p> <p>From the pop-up dialog, you can decide what to clear</p> <p>[] Browsing History [] Download History [] Saved Form and Search History &lt;------ you are interested in this [] Cache [] Cookies [] Offline Saved data [] saved pass...
44,167
<p>My site has a drop-down menu built in CSS and JavaScript that drops down over a Flash animation. In IE (6&amp;7) the drop-down menus drop over the Flash animation, however, in Firefox (2&amp;3) the menus appear underneath the Flash animation. Is there any way to get this dynamic menu to flow OVER the Flash in Fire...
<p>Try setting wmode to transparent - see <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15523" rel="noreferrer">here</a></p>
<p>Have you tried the iframe trick (i.e. floating an iframe behind the menu, thus putting hte flash layers behind.)</p>
8,269
<p>I was wondering if anyone has a good solution to a problem I've encountered numerous times during the last years.</p> <p>I have a shopping cart and my customer explicitly requests that it's order is significant. So I need to persist the order to the DB.</p> <p>The obvious way would be to simply insert some OrderFi...
<p>FWIW, I think the way you suggest (i.e. committing the order to the database) is not a bad solution to your problem. I also think it's probably the safest/most reliable way.</p>
<p>When I use <code>Hibernate</code>, and need to save the order of a <code>@OneToMany</code>, I use a <code>Map</code> and not a <code>List</code>.</p> <pre><code>@OneToMany(fetch = FetchType.EAGER, mappedBy = "rule", cascade = CascadeType.ALL) @MapKey(name = "position") @OrderBy("position") private Map&lt;Integer, R...
42,811
<p>How do I capture the event of the clicking the Selected Node of a TreeView? It doesn't fire the <strong>SelectedNodeChanged</strong> since the selection has obviously not changed but then what event can I catch so I know that the Selected Node was clicked?</p> <p><strong>UPDATE</strong>: When I have some time, I'm ...
<p>Easiest way - if it doesn't interfere with the rest of your code - is to simply set the node as not selected in the SelectedNodeChanged method.</p> <pre><code>protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e){ // Do whatever you're doing TreeView1.SelectedNode.Selected = false; } </code><...
<p>i have a problem look like but i solved it !</p> <p>in server side code :</p> <pre><code> protected void MainTreeView_SelectedNodeChanged(object sender, EventArgs e) { ClearTreeView(); MainTreeView.SelectedNode.Text = "&lt;span class='SelectedTreeNodeStyle'&gt;" + MainTreeView.SelectedNode.T...
13,269
<p>I want the log to roll over as long as the application is running, but I want the log to start fresh when the application is restarted.</p> <p><em>Updated:</em> Based on <a href="https://stackoverflow.com/questions/269999/how-do-i-make-log4j-clear-a-log-at-startup#270026">erickson's</a> feedback, my appender looks ...
<p>If you set the <code>append</code> parameter to <code>false</code>, the base log file will be "started fresh" when the application restarts. Do you mean that you want any "rolled" log files to be deleted too?</p>
<p>I've written some custom code to find my <code>RollingFileAppender</code> (which is unnecessarily difficult to get access to in log4j!) which I then cause to roll over. I've adapted my code below for a single use. I use code similar to this at application startup to force my logs to roll (if non-empty) so I always...
33,931
<p>I've been using tags in my projects. I was browsing the custom tags on grails.org to find some new tags for my library.</p> <p><a href="http://www.grails.org/Contribute+a+Tag" rel="nofollow noreferrer">http://www.grails.org/Contribute+a+Tag</a></p> <p>I was wondering if people in the StackOverflow community have ...
<p>The <a href="http://www.graphviz.org/Resources.php" rel="nofollow noreferrer">Graphviz resources page</a> lists a project, <a href="http://www.codeplex.com/quickgraph" rel="nofollow noreferrer">QuickGraph</a>, which may solve your problem.</p>
<p>Netron, a graphing library, that unfortunately died because the source got bought. Still, the last releases on SF are there: <a href="http://sourceforge.net/project/showfiles.php?group_id=69788&amp;package_id=123851" rel="nofollow noreferrer">http://sourceforge.net/project/showfiles.php?group_id=69788&amp;package_id...
26,723
<p>We are looking for a open source J2EE Application server for log budget deployments. We are considering JBoss and Glassfish. Which is the best open source application server? Any comparative study available?</p>
<p>JBoss has been used in production environment for over 6 years now. Glassfish's codebase is over 10 years BUT most of the code is recent. Glassfish v3 (still in beta) has a microkernel (so is Jboss 5) architecture.</p> <p>Glassfish has command line tools and a nice console. Since Glassfish is from sun, usually it w...
<p>I would consider any bells and whistles you might be interested in. JBoss has a lot of nice integration points with frameworks, such as Hibernate, but has a history of not playing well with Spring. Both very useful frameworks, both code change your decision on how you might proceed.</p>
26,773
<p>I'm writing a Java Tree in which tree nodes could have children that take a long time to compute (in this case, it's a file system, where there may be network timeouts that prevent getting a list of files from an attached drive).</p> <p>The problem I'm finding is this:</p> <ol> <li><p><code>getChildCount()</code> ...
<p><a href="http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#data" rel="nofollow noreferrer">http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#data</a></p> <p>scroll a little down, there is the exact tutorial on how to create lazy loading nodes for the jtree, complete with exampl...
<p>I'm not sure if it's entirely applicable, but I recently worked around problems with a slow tree by pre-computing the answers to methods that would normally require going through the list of children. I only recompute them when children are added or removed or updated. In my case, some of the methods would have ha...
18,721
<p>Does anybody use the Class Designer much in Visual Studio?</p> <p>I have downloaded the Modeling Power Toys for 2005 and have been impressed with what I've seen so far. The MSDN Class Designer Blog doesn't seem to have been updated for a while but it still looks quite useful.</p> <p>Is the Class Designer a quick w...
<p>As a visualization tool, or for exploratory purposes (drawing up multiple options to see what they look like) it's not bad, but generally I find the object browser does fine for most stuff I care about.</p> <p>As a code generation tool, it's a terrible idea.</p> <p>The whole idea that we will design all our code s...
<p>I have tried it out couple of times, mainly for viewing existing classes. If it would show all the relationships, it would be more usefull. Now it only shows inheritation.</p>
3,520
<p>Actually, I'm using this way. Do you have a better way?</p> <pre><code>private bool AcceptJson(HttpRequest request) { const string JsonType = "application/json"; if (request.ContentType.ToLower(CultureInfo.InvariantCulture).StartsWith(JsonType)) { return true; } if (request.AcceptTypes...
<p>That approach can lead to false positives (it doesn't account for q values or content types of which application/json is a substring).</p> <p>You can find a decent Accept header parser in <a href="http://www.dev-archive.net/articles/xhtml.html#content-negotiation" rel="nofollow noreferrer">this article about XHTML<...
<p>It's tough to know what you mean by "better". Strictly speaking, you don't need to worry about the content type, so that can be removed. I guess technically a better way would be to remove the Select call and put the condition into the Count method.</p>
21,127
<p>I have an enum that looks as follows:</p> <pre><code>public enum TransactionStatus { Open = 'O', Closed = 'C'}; </code></pre> <p>and I'm pulling data from the database with a single character indicating - you guessed it - whether 'O' the transaction is open or 'C' the transaction is closed.</p> <p>now because the...
<pre><code>static void Main(string[] args) { object val = 'O'; Console.WriteLine(EnumEqual(TransactionStatus.Open, val)); val = 'R'; Console.WriteLine(EnumEqual(DirectionStatus.Left, val)); Console.ReadLine(); } public static bool EnumEqual(Enum e, object boxedValue) { ...
<p>I would take a look at Enum.Parse. It will let you parse your char back into the proper enum. I believe it works all the way back to C# 1.0. Your code would look a bit like this:</p> <pre><code>TransactionStatus status = (TransactionStatus)Enum.Parse(typeof(TransactionStatus), obj.ToString()); </code></pre>
13,109
<p>I would like to show a set of consecutive numbers in a UIPickerView component but have it wrap around like the seconds component of the Clock->Timer application. The only behavior I can enable looks like the hours component of the Timer application, where you can scroll in only one direction.</p>
<p>It's just as easy to set the number of rows to a large number, and make it start at a high value, there's little chance that the user will ever scroll the wheel for a very long time -- And even then, the worse that will happen is that they'll hit the bottom.</p> <pre><code>- (NSInteger)pickerView:(UIPickerView *)pi...
<p>Just create an array multiple times, so that you have your numbers multiple times. Lets say when want to have the numbers from 0 to 23 and put that in an array. that we will do 10 times like this...</p> <pre><code>NSString *stdStepper; for (int j = 0; j&lt;10; j++) { for(int i=0; i&lt;24; i++) ...
26,361
<p>Are you choosing not to use managed code for any new applications for Win32? Why? Are there resources you need that aren't available from the CLR?</p> <p>(Note "New" - not enhancements to existing codebases.)</p>
<p>One significant reason is ease of deployment. I can build a Win32 application (using MFC or WTL libraries), and with static linking there are <strong>no dependencies</strong> on external libraries (yes, I know that static linking is not the <a href="http://msdn.microsoft.com/en-us/library/ms235316.aspx" rel="nofollo...
<p>Yes and no. I use C++/CLI if I need to do any Win32/COM stuff. C++/CLI is wonderful. Our UIs are entirely .NET, but occasionally we do have need to use straight C++.</p>
45,020
<p>I am using an M3D printer and loaded an STL design with holes in the middle:</p> <p><a href="https://i.stack.imgur.com/UMD0V.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UMD0V.jpg" alt="Screenshot of STL design with holes in the middle"></a></p> <p>However, the output is an object without hol...
<p>Have you tried letting it print a few more layers? It is very common that printers use the first few layers to create a <strong>raft</strong>, which will make the model adhere better to the bed.</p> <p>I believe this illustration from Simplify3D <a href="https://www.simplify3d.com/support/articles/rafts-skirts-and-...
<p><strong>Case 1:</strong></p> <p>There may be an issue with the precision of the print nozzle, not being able to fully articulate the hole. That is to say, the printer is trying to print it with holes, but the material is filling in that area.</p> <p>Try increasing the size of the hole. Granted, it is not an exact ...
443
<p>I have SQL query, which is working nice on Oracle and MSSQL. Now I'm trying this on PostgreSQL and it gives a strange exception: <code>org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table "main"</code></p> <p>Here is the query: </p> <pre><code>SELECT * FROM "main" main INNER JOIN "som...
<p>According to <a href="http://sql-info.de/en/postgresql/postgres-gotchas.html#1_5" rel="nofollow noreferrer">this</a>, seems like you either mistyped an alias or used a table name in place of it.</p>
<p>somehting=>something</p> <pre> postgres=# create database test postgres-# ; CREATE DATABASE postgres=# \c test You are now connected to database "test". test=# select version(); version ---------------------------------------...
27,991
<p>I have quite a few developers asking me if certain SQL jobs ran, and I would like to give them access to check it on their own without giving them <code>sysadmin</code> rights. I know that in <code>SQL 2005</code>, you can grant them the <code>SQLAgentReaderRole</code>, but I am looking for a solution in <code>SQL ...
<p>Pretty sure there isn't one out of the box. This thread seems to be pretty decent...halfway down they discuss creating a role and then locking that down further. Also you could just create a mini-program (sp even?) to email the results of the job as a summary, or add to each job an on completion event to email an ...
<p>Looks like there's some hope for those of us still working with 2000 -</p> <p>"In order to accomplish this in SQL Server 2000 the DBA must add the user to TargetServersRole role in MSDB database. Prior to Service Pack 3 on SQL Server 2000 the user must be added to the sysadmin group in order to get a chance to view...
9,289
<p>I know how to include files that are in folders further down the heirachy but I have trouble finding my way back up. I decided to go with the set_include_path to default all further includes relative to a path 2 levels up but don't have the slightest clue how to write it out.</p> <p>Is there a guide somewhere that ...
<p>I tend to use <strong><a href="http://uk3.php.net/dirname" rel="nofollow noreferrer">dirname</a></strong> to get the current path and then use this as a base to calculate all future path names.</p> <p>For example,</p> <pre><code>$base = dirname( __FILE__ ); # Path to directory containing this file include( "{$base...
<p>it's probably easier to just use an absolute path to reference:</p> <pre><code>set_include_path('/path/to/files'); </code></pre> <p>this way you have a reference point for all your future includes. includes are handled relative to the point they were called, which can cause a bit of confusion in certain scenarios....
34,735
<p>I'm using the following code to retrieve a message from the database and then write it out to a html page: </p> <pre><code>Dim strDSN, cnn, cmd strDSN = "Driver={SQL Server};" &amp; "Server=(local)\sql2k5;" &amp; ... set cnn = Server.CreateObject("ADODB.Connection") cnn.ConnectionString = strDSN cnn.CursorLocation ...
<p>Your db is probably storing data in something other than utf-8, (maybe utf-16 or ucs 2 ?), while your asp page (by default) expects utf-8. That's why your data appears correct from SQL management studio, but not from an ASP page. utf-8 data in the DB looks like funky characters when viewed from SQL Management Studi...
<p>You might try using the <a href="http://msdn2.microsoft.com/en-us/library/ms130978.aspx" rel="nofollow noreferrer">SQL Native Client</a> to see if that fixes it for you, it is a bit of a wild guess, but I know that it has resolved other issues with data types and Classic ASP.</p>
42,354
<p>Continuing the "Hidden features of ..." meme, let's share the lesser-known but useful features of Ruby programming language.</p> <p>Try to limit this discussion with core Ruby, without any Ruby on Rails stuff.</p> <p>See also:</p> <ul> <li><a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">Hi...
<p>Peter Cooper has a <a href="http://www.rubyinside.com/21-ruby-tricks-902.html" rel="nofollow noreferrer">good list</a> of Ruby tricks. Perhaps my favorite of his is allowing both single items and collections to be enumerated. (That is, treat a non-collection object as a collection containing just that object.) It...
<pre><code>@user #=&gt; nil (but I did't know) @user.name rescue "Unknown" </code></pre>
8,945
<p>Is it still worth to add the log4j library to a Java 5 project just to log let's say some exceptions to a file with some nice rollover settings. Or will the standard util.logging facility do the job as well?</p> <p>What do you think?</p>
<p>I'd say you're probably fine with util.logging for the needs you describe.</p> <p>For a good decision tree, have a look at <a href="http://web.archive.org/web/20190320144728/http://java.sys-con.com/node/48541" rel="noreferrer">Log4j vs java.util.logging</a></p> <blockquote> <p>Question One : Do you anticipate a need...
<p>I would go with log4j. The possibilites with log4j is not obsolete at all!</p>
5,174
<p>I recently wrote mailing list software in Ruby On Rails. I would like to get some expert advice on the best way to test it. For example, it would be cool if I could write a script generate 10,000 email addresses, use the software to send an email to those 10,000 addresses, and then write a script to make sure the ...
<p>If you happen to have an email address on a system run with the Postfix MTA, you have an arbitrarily large supply of email addresses at your disposal. For example, my regular email address is nr@cs.tufts.edu, but mail sent to nr+xxx@cs.tufts.edu will get forwarded according to the contents of ~nr/.forward+xxx. I u...
<p>I suppose your ML manager has a command interface, being either a web one or a mail one (or hopefully both)? You need to test these as well. Web UI is a bit more difficult to test but the mail one should be pretty simple. If I were to write such a ML manager, I'd probably add a XML-RPC/SOAP webservice to access a...
47,932
<p>The question gives all necessary data: what is an efficient algorithm to generate a sequence of <em>K</em> non-repeating integers within a given interval <em>[0,N-1]</em>. The trivial algorithm (generating random numbers and, before adding them to the sequence, looking them up to see if they were already there) is v...
<p>The <a href="https://docs.python.org/2/library/random.html#random.sample" rel="nofollow noreferrer">random module</a> from Python library makes it extremely easy and effective:</p> <pre><code>from random import sample print sample(xrange(N), K) </code></pre> <p><code>sample</code> function returns a list of K uniq...
<p>This is Perl Code. Grep is a filter, and as always I didn't test this code.</p> <pre><code>@list = grep ($_ % I) == 0, (0..N); </code></pre> <ul> <li>I = interval</li> <li>N = Upper Bound</li> </ul> <p>Only get numbers that match your interval via the modulus operator.</p> <pre><code>@list = grep ($_ % 3) == 0, ...
19,199
<p>I want to test the behavior of a certain piece of .NET code in partial trust environments. What's the fastest way to set this up? Feel free to assume that I (and other readers) are total CAS noobs.</p> <p>@Nick: Thanks for the reply. Alas, the tool in question is explicitly for unmanaged code. I didn't say "man...
<p>This is an excellent question, especially from a TDD point of view and validating code under different trust scenarios. </p> <p>I think the way I'd approach this would be something along the lines of - </p> <ul> <li><p>Create an AppDomain in my TDD code using the AppDomain.CreateDomain() overload that allows you t...
<p>Use the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=bd02c19c-1250-433c-8c1b-2619bd93b3a2&amp;displaylang=en" rel="nofollow noreferrer">Microsoft Application Verifier</a>.</p> <p>AppVerifier helps to determine:</p> <ul> <li>When the application is using APIs correctly: (Unsafe TerminateT...
4,103
<p>I know there are HTML entities for 1/2, 1/4, and 3/4, but are there others? Like 1/3 or 1/8? Is there a good way to encode arbitrary fractions?</p>
<p>how about <sup>15</sup>&frasl;<sub>16</sub>? (&lt;sup&gt;15&lt;/sup&gt;&amp;frasl;&lt;sub&gt;16&lt;/sub&gt;)</p>
<p>This would depend on your exact needs and audience. For most purposes many methods would be appropriate. 15/16, 15 parts of 16, 93.75%, <sup>15</sup>/<sub>16</sub> all mean the same, you might even use symbols like ++++++++++++++-</p> <p>For some more complex scenarios you will need more complex solutions more l...
20,886