instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I have a certain page (we'll call it MyPage) that can be accessed from three different pages. In the Web.sitemap file, I tried to stuff the XML for this page under the three separate nodes like this:</p> <p>&lt; Page 1 ><br> &nbsp;&nbsp;&lt; MyPage / ><br> &nbsp;&nbsp;...<br> &lt; /Page 1 ><br><br> &lt; Page 2 ...
<p>That's not really the intended purpose of the Web.sitemap file.</p> <p>From <a href="http://msdn.microsoft.com/en-us/library/system.web.sitemap(VS.80).aspx" rel="nofollow noreferrer">MSDN Docs of the SiteMap class</a>, </p> <blockquote> <p>Fundamentally, the SiteMap is a container for a hierarchical collecti...
<p>I know you can have two different entries of ~/folder/index.aspx and ~/folder/ both point to the same place. A bit of a hack, yes, but maybe there's a way you can take this further?</p> <ul> <li>~/folder/index.aspx</li> <li>~/folder/</li> <li>~/folder</li> </ul>
12,322
<p>I have a Web Service (ASMX) with a few Web methods on our production Web server. On a separate internal Web server (which isn't publicly exposed) I have another Web site that will use the ASMX's public web methods. What are some of the best ways to secure the Web service such that only the internal Web server can ...
<p>One of the easiest ways is to pass credentials in the soap header of the message. So each call passes along the info needed to determine if the user is authorized. WSE makes some of that easier but one of the most succinct descriptions of this process can be found in Rocky Lhotka's book on Business Objects. I get a ...
<p>In this moment what comes to my mind is IP filtering on IIS. Fast to apply, should work in your scenario.</p>
14,733
<p>I tried:</p> <pre><code>DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(f); Node mapNode = getMapNode(doc); System.out.print("\r\n elementName "+ mapNode.getNodeName());//This works fine. Element e = (Element) mapNode; //Thi...
<p>I was using a different dtd file on the server. That was causing the issue.</p>
<p>Might the first child be a whitespace only text node or suchlike?</p> <p>Try:</p> <pre><code>System.out.println(doc.getFirstChild().getClass().getName()); </code></pre> <p>EDIT:</p> <p>Just looked it up in my own code, you need:</p> <pre><code>doc.getDocumentElement().getChildNodes(); </code></pre> <p>Or:</p> ...
18,637
<p>I have the odd problem that I am not able to open the properties of my .NET projects in Visual Studio. If I try to open it by clicking on the Properties tree node in the Solution Explorer I get the following message:</p> <blockquote> <p>There is no editor available for '....csproj'. Make sure the application for ...
<p>Repair installation doesn't worked as I mentioned in my question. The problem was solved by using the command line with</p> <pre><code>devenv /ResetSkipPkgs </code></pre> <p>BUT after that I had to reset some of my Resharper settings. </p>
<p>I had the same issue when i <strong>un-installed an extension</strong> from the extensions and updates. I tried all the options mentioned above but no luck. It showed me <strong>xamarin shell package did not load correctly</strong> every time i tried to load the app.</p> <p><strong>Then the issue was resolved by Re...
44,180
<p>Looking at MVC framework, it seems we require more of classic ASP knowledge then ASP.NET postbacks and Viewstates. Are we moving backwards to complex UI + code logic in the actual frontend HTML markup?</p>
<p>We're moving back to not trying to abstract away fundamental concepts like HTML and HTTP Requests. On the UI end, that translates into the Views being more tightly integrated with the output, which isn't a bad thing. the classic ASP model translated into having everything tightly integrated with the output, which <e...
<p>The entire point of MVC is for separation of code. Models should contain all of your business logic, the View should just handle the output to the user, and the Controller should glue those two pieces together.</p>
24,266
<p>From my code (Java) I want to ensure that a row exists in the database (DB2) after my code is executed.</p> <p>My code now does a <code>select</code> and if no result is returned it does an <code>insert</code>. I really don't like this code since it exposes me to concurrency issues when running in a multi-threaded...
<p>Yes, DB2 has the MERGE statement, which will do an UPSERT (update or insert).</p> <pre><code>MERGE INTO target_table USING source_table ON match-condition {WHEN [NOT] MATCHED THEN [UPDATE SET ...|DELETE|INSERT VALUES ....|SIGNAL ...]} [ELSE IGNORE] </code></pre> <p>See:</p> <p><s><a href="http://publib...
<p>I started with hibernate project where hibernate allows you to saveOrUpdate(). I converted that project into JDBC project the problem was with save and update. I wanted to save and update at the same time using JDBC. So, I did some research and I came accross ON DUPLICATE KEY UPDATE :</p> <pre><code>String sql=&quot...
42,784
<p>What are the differences between User Control and Custom Control in ASP.NET</p>
<p>AFAIK, user controls are controls that you can create out of existing controls and can be part of the project and have a designer surface for you to drag/drop.</p> <p>Custom controls are generally external to the project &amp; would require to be hand-coded (using various asp.net control events &amp; html building ...
<p><strong>Difference between CustomControl and UserControl</strong> <em>So, now you got the difference between Custom Control and User Control, I guess. Let's summarize the difference again. Read the comparison below to make it clear:</em></p> <p><a href="https://i.stack.imgur.com/AUrtx.png" rel="nofollow noreferrer...
47,983
<p>Windows NLB works great and removes computer from the cluster when the computer is dead.</p> <p>But what happens if the application dies but the server still works fine? How have you solved this issue?</p> <p>Thanks</p>
<p>By not using NLB.</p> <p>Hardware load balancers often have configurable "probe" functions to determine if a server is responding to requests. This can be by accessing the real application port/URL, or some specific "healthcheck" URL that returns only if the application is healthy.</p> <p>Other options on these lo...
<p>Presumably with Windows NLB there is some way to programmatically set the weight of nodes? The nodes should self-monitor and if there is some problem (e.g. a particular node is low on disc space), set its weight to zero so it receives no further traffic.</p> <p>However, this needs to be carefully engineered and hav...
37,044
<p>How can I know in a C#-Application, in which direction the screen of the mobile device is orientated? (i.e. horizontal or vertical).</p>
<p>In Microsoft.WindowsMobile.Status there is a class which keeps track of all kinds of properties of your device. Besides the one you need, DisplayRotation, it also contains properties about phone coverage, Nr of missed calls, next appointment and many more. See <a href="http://msdn.microsoft.com/en-us/library/micros...
<p>Just guessing but my first attempt would be:</p> <pre><code>var rect = System.Windows.Forms.Screen.PrimaryScreen.Bounds; // or var rect = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea; var ratio = rect.Width / rect.Height; if (ratio == 1.0) // square screen. if (ratio &gt; 1.0) // landscape. if (ratio &lt...
34,566
<p>I want to program graphical 2D games more complex than the basic 2D stuff I already know. I don't want to do 3D programming. Just more complex 2D stuff. I dropped high school before I could learn a lot of stuff so I walked away with enough algebra knowledge to balance my checkbook and do some light 2D Cartesian prog...
<p>You need to be competent in Trigonometry: <a href="http://en.wikipedia.org/wiki/Trigonometry" rel="noreferrer">Wikipedia</a> and <a href="http://mathworld.wolfram.com/topics/Trigonometry.html" rel="noreferrer">Mathworld</a></p> <p>Even though you don't wish to do 3D programming, 2D games also use vectors and matric...
<p>Strangely I've found a lot of useful stuff on linear algebra in Wikipedia: <a href="http://en.wikipedia.org/wiki/Portal:Mathematics" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Portal:Mathematics</a> </p> <p>Generally it's not the best source of knowledge, but math there is ok.</p>
22,788
<p>I have PHP configured so that magic quotes are on and register globals are off.</p> <p>I do my best to always call htmlentities() for anything I am outputing that is derived from user input.</p> <p>I also occasionally seach my database for common things used in xss attached such as...</p> <pre><code>&lt;script </...
<p>Escaping input is not the best you can do for successful XSS prevention. Also output must be escaped. If you use Smarty template engine, you may use <code>|escape:'htmlall'</code> modifier to convert all sensitive characters to HTML entities (I use own <code>|e</code> modifier which is alias to the above).</p> <p>M...
<p>It is difficult to implement a thorough sql injection/xss injection prevention on a site that doesn't cause false alarms. In a CMS the end user might want to use <code>&lt;script&gt;</code> or <code>&lt;object&gt;</code> that links to items from another site. </p> <p>I recommend having all users install FireFox wit...
9,682
<p>How effective is merging when folders and projects have been renamed in your solution?</p>
<p>We've had lots of success with TFS 2005 when it comes to file deletes/renames, with a few very specific exceptions, namely:</p> <ol> <li>Files which have been renamed in both source and target branches (this is usually trivially solved with a click on "Ignore server changes");</li> <li>Files which have been renamed...
<p>We've had lots of problems with TFS 2005 and deletes in general. I haven't determined the cause yet, but a number of my team members have run into problems merging in changes that involved a renamed or deleted folder. This seems particularly true if there was a lot of refactoring (and renaming, and re-renaming) in...
9,725
<p>I keep hearing this term tossed around in several different contexts. What is it?</p>
<p>Declarative programming is when you write your code in such a way that it describes what you want to do, and not how you want to do it. It is left up to the compiler to figure out the how. </p> <p>Examples of declarative programming languages are SQL and Prolog.</p>
<p>A couple other examples of declarative programming:</p> <ul> <li>ASP.Net markup for databinding. It just says "fill this grid with this source", for example, and leaves it to the system for how that happens.</li> <li>Linq expressions</li> </ul> <p>Declarative programming is nice because it can help <a href="http:...
15,755
<p>I am new to LINQ. I am trying to find the rows that does not exists in the second data table. </p> <p>report_list and benchmark both type are : DataTable. Both these datatables are being populated using OleDbCommand,OleDbDataAdapter. I am getting an error "Specified cast is not valid." in foreach ... loop. I woul...
<p>I don't know if I understood your question. Are you trying to get the items that exists in the first table but not in the second?</p> <pre><code> var first = new string[] { "b", "c" }; var second = new string[] { "a", "c" }; //find the itens that exist in "first" but not in "second" var q = from f in first ...
<pre><code>From a in report_list Group Join b in benchmark On a.bench_id Equals b.bench_id Into g = Group Where g.Count = 0 Select a </code></pre> <p>Note that this is VB syntax.</p>
41,671
<p>I was reading up about NTVDM.exe as I build a quick test console app and it crashed on a friends machine complaining about this EXE.</p> <p>As I understand it all DOS cmd windows (C# console apps included) run as 16bit not 32bit.</p> <p>Is this true? Does this mean all my works console app back office apps are ru...
<p>Any .NET app that is compiled for x86 will be 32-bit</p> <p>C# console apps aren't running in "real" dos - they run in a 32-bit or 64-bit environment - depending on your OS and .NET framework.</p>
<p>There is nothing special about a console exe; it is just a PE file. So regardless of console vs winform exe vs windows service, it is just going to run in whatever mode it was compiled.</p> <p>Visual Studio etc will never generate a 16-bit exe. x86 vs x64 is more interesting ;-p</p> <p>Probably, your friend doesn'...
44,165
<p>A while back I asked about instantiating a HttpContext object. Now that I have learnt what I didn't know, what confuses me is that you cannot say HttpContext ctx = new HttpContext(); because the object does not have a constructor.</p> <p>But doesn't every class need a constructor? In C#, if you don't provide one, t...
<p>Constructor can be private or protected.<br /> Also you can't create instance of abstract class, even if that class has public constructor.</p>
<p>Compiler does not create default constructor of a class until the class has constructor with arguments. In HttpContext class , it has 2 constructors with arguments . So, error is shown when you do HttpContext obj = new HttpContext().</p> <pre><code>public class Sample { int x; public Sample (int x) { ...
30,141
<p>I have a table in an access table which contains Product entries, one of the columns has a jpg image stored as an OLE Object. I am trying to import this table to MySQL but nothing seems to work. I have tried the MySQL migration tool but that has a known issue with Access and OLE Objects. (The issue being it does...
<p>Ok so in the interests of airing my dirty code in public here what i came up with.<br> Note : this is a hack designed to be used once and then thrown away.</p> <p>This Method takes in a datarowview containing 1 row of data from the access table. The Images are wrapped in OLE serialization, im not entirely famili...
<p>There's also <a href="https://github.com/shamrin/olefield" rel="nofollow">olefield</a> - Python module to extract data out of OLE object fields in Access. I successfully extracted BMP files with it. It could probably work with jpeg images, but I haven't tried it.</p>
6,293
<p>If I use the following code I lose the ability to right click on variables in the code behind and refactor (rename in this case) them</p> <pre><code>&lt;a href='&lt;%# "/Admin/Content/EditResource.aspx?ResourceId=" + Eval("Id").ToString() %&gt;'&gt;Edit&lt;/a&gt; </code></pre> <p>I see this practice everywhere but...
<p>I wouldnt call it bad practice (some would disagree, but why did they give us that option in the first place?), but I would say that you'll improve overall readability and maintainability if you do not submit to this practice. You already conveyed out a good point, and that is IDE feature limitation (i.e., design ti...
<p>It's up to you. Sometimes "spagehetti" code is easier to maintain than building/using a full on templating system for something simple, but once you get fairly complicated pages, or more specifically, once you start including a lot of logic into the page itself, it can get dirty really quickly. </p>
9,399
<p>What is the Emacs mode or package that highlights Lisp forms changing the color of the backgrounds so that the form you are in has one color, the outer form another, the outer outer form another and so on?</p>
<p>You may want to try <a href="http://www.foldr.org/~michaelw/emacs/" rel="nofollow noreferrer">mwe-color-box</a> (screenshot below) or read <a href="http://lemonodor.com/archives/001207.html" rel="nofollow noreferrer">Five approaches to s-expression highlighting</a> by <a href="http://lemonodor.com/" rel="nofollow no...
<p>I don't use it, but this might be what you're looking for: <a href="http://www.emacswiki.org/emacs/RainbowDelimiters" rel="nofollow">http://www.emacswiki.org/emacs/RainbowDelimiters</a></p>
41,209
<p>I changed the folder that my WordPress installation was in.</p> <p>However, this worked fine, except now all my images are not showing up.</p> <p>The problem is that each post has the full url of the image in it. (not my doing, this seems to be the default setting)</p> <p>Is there a tool or a quick fix available ...
<p>There is a <a href="http://www.velvetblues.com/web-development-blog/wordpress-plugin-update-urls/" rel="nofollow noreferrer">Update URLs</a> plugin for Wordpress to help you with that. Hope that helps!</p>
<p>You need to update your settings to reflect the directory change on the settings page in your admin section.</p> <p><strong>Edit:</strong></p> <p>Since it seems to be a problem in the posts themselves, you'll probably have to write a quick fixme script that runs through your post table searches for <code>'="/'</co...
25,816
<p>I'm trying to use XPath to parse an XML document. One of my NSXMLElement's looks like the following, hypothetically speaking:</p> <pre><code>&lt;foo bar="yummy"&gt; </code></pre> <p>I'm trying to get the value for the attribute bar, however any interpretation of code I use, gives me back bar="woo", which means I n...
<p>The TouchXML API is supposed to be an exact duplicate of Apple's NSXML implementation, so it should be the same except you'll replaces all NS-Method's with C-Methods.</p> <blockquote> <p>The TouxhXML classes map directly to the NSXML classes. <strong>NSXMLNode -&gt; CXMLNode</strong>, <strong>NSXMLDocument -&gt; CXM...
<p>The iPhone does have access to NSXMLParser which is a nice little sax parser. Aaron Hillegass has a good article on using NSXMLParser. It doesn't support XPath, but is pretty handy at ripping xml into your data objects.</p> <p><a href="http://weblog.bignerdranch.com/?p=48" rel="nofollow noreferrer">Parsing XML in C...
29,937
<p>I am working on a 2D iPhone game using OpenGL ES and I keep hitting the 24 MB memory limit – my application keeps crashing with the error code 101. I tried real hard to find where the memory goes, but the numbers in Instruments are still much bigger than what I would expect.</p> <p>I ran the application with the Me...
<p><em>I highly doubt this is a bug in Instruments.</em></p> <p>First, read this <a href="http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-part-6_25.html" rel="nofollow noreferrer">blog post by Jeff Lamarche about openGL textures</a>:</p> <ul> <li>has a simple example of how to load textures wit...
<p>This doesn't specifically help you, but if you find that the memory tools don't provide all the data you need, please file a bug at bugreport.apple.com. Attach a copy of your app and a description of how the tools are falling short of your analysis and Apple will see if they can improve the tools. Thanks!</p>
47,458
<p>I've got about 100 unit tests and with a coverage of %20, which I'm trying to increase the coverage and also this is a project in development so keep adding new tests. </p> <p>Currently running my tests after every build is not feasible they takes about 2 moments. </p> <p>Test Includes:</p> <ul> <li>File read fr...
<p>These don't sound like unit tests to me, but more like functional tests. That's fine, automating functional testing is good, but it's pretty common for functional tests to be slow. They're testing the whole system (or large pieces of it).</p> <p>Unit tests tend to be fast because they're testing one thing in isolat...
<p>It sounds like you may need to manage expectations amongst the development team as well. </p> <p>I assume that people are doing several builds per day and are epxected to run tests after each build. You might we be well served to switch your testing schedule to run a build with tests during lunch and then another ...
48,126
<p>I'm looking for a PHP library/function/class which can create <a href="http://en.wikipedia.org/wiki/Identicon" rel="nofollow noreferrer">Identicon</a>s.</p>
<p>i use this:</p> <pre><code>class Gravatar { static public function GetGravatarUrl( $email, $size = 128, $type = 'identicon', $rating = 'pg' ) { $gravatar = sprintf( 'http://www.gravatar.com/avatar/%s?d=%s&amp;s=%d&amp;r=%s', md5( $email ), $type, $size, $rating ); ...
<p>Mmm, I wondered why you asked, since you link to Wikipedia article which points to lot of implementations, including PHP ones. BTW, thanks for your question, I didn't know the name of these icons...</p> <p>But after exploring a bit, I found lot of links there were outdated... Following the <a href="http://digitalco...
29,311
<p>I'm looking to print this item:</p> <blockquote> <p><a href="https://www.thingiverse.com/thing:4274950" rel="nofollow noreferrer">https://www.thingiverse.com/thing:4274950</a></p> </blockquote> <p>I want to lay it flat on the bed, 90° to how it's shown on Thingiverse. The problem is there's the one little corner...
<p>I don't know a way to do that with Cura without breaking it up into multiple parts with different settings for each, but what about just enabling supports? You'd only get a very small amount of support material and it would act similarly to a brim to keep the small part from detaching.</p>
<p>I would enable supports using "Touching Build Plate", and then place a support blocker over the portion that you don't want supports added to.</p>
1,630
<p>I am doing 2nd year computer science and we have a software engineering group project. There are 5 people in the group and we would like to build a web application in php. Please suggest some ideas for me </p>
<p>Have a look a Paul Graham's list of "Startup Ideas We'd Like to Fund" - lots more ideas and the CMS has been done to death.</p> <p><a href="http://ycombinator.com/ideas.html" rel="noreferrer">http://ycombinator.com/ideas.html</a></p> <p>The list in short:</p> <ol> <li>A cure for the disease of which the RIAA is a...
<p><strong>What Classes Should I Schedule Next Semester?</strong></p> <p>Given a course schedule and a student profile, what classes should a student register for during the next semester? Take into account major, course prerequisites, and personal restrictions such as blocking out time spent at jobs or practice.</p> ...
24,398
<p>I have a DataGridView with one DataGridViewComboBoxColumn in my WinForms application. I need to drop down (open) this DataGridViewComboBoxColumn manually, let's say after a button is clicked.</p> <p>The reason I need this is I have set SelectionMode to FullRowSelect and I need to click 2-3 times to open the combo b...
<p>I know this can't be the ideal solution but it does create a single click combo box that works within the cell.</p> <pre><code> Private Sub cell_Click(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick DataGridView1.BeginEdit(True) If DataGridView1...
<p>FYI: Here is <a href="https://stackoverflow.com/users/1005063/nvivekgoyal">nvivekgoyal</a>'s code from the reference in his <a href="https://stackoverflow.com/a/32224097/3519108">answer</a>:</p> <pre><code>private void datagridview1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)...
29,836
<p>I know this is a really basic question, but I've just started with some basic C++ programming after coding a few projects with high-level languages. </p> <p>Basically I have three questions:</p> <ol> <li>Why use pointers over normal variables?</li> <li>When and where should I use pointers?</li> <li>How do you use ...
<ul> <li>Why use pointers over normal variables? </li> </ul> <p>Short answer is: Don't. ;-) Pointers are to be used where you can't use anything else. It is either because the lack of appropriate functionality, missing data types or for pure perfomance. More below...</p> <ul> <li>When and where should I use pointers?...
<p>In java and C# all the object references are pointers, the thing with c++ is that you have more control on where you pointer points. Remember With great power comes grand responsibility.</p>
19,705
<p>Is there a way to prevent someone from faking a mime type on a file upload and then running a php/exe/etc...</p> <p>I have to make the file upload directory writeable and executable so that the files can be stored, but this allows anyone to run a script after. One thing I can do is add random data to the file name...
<p>The file upload directory should not be accessible to the web browser. I.e. don't allow somebody to upload a file, say "<code>remove_all_my_files.php</code>", and then execute it on your system by giving the url to it, say "<code>http://xample.com/uploads/remove_all_my_files.php</code>".</p>
<p>On my Apache web server configurations I don't believe the actual file contents determine whether a file runs as a script or not. The determination as to whether to display a file as text or an image format, or run it as a script is made by matching the file ending. </p> <p>For example, a directive in the apache co...
15,533
<p>I need a map that has two keys, e.g.</p> <pre><code>Map2&lt;String /*ssn*/, String /*empId*/, Employee&gt; _employees; </code></pre> <p>So that I can</p> <pre><code>_employees.put(e.ssn(), e.empId(), e) </code></pre> <p>And later</p> <pre><code>_employees.get1(someSsn); _employees.get2(someImpId); </code></pre>...
<p>My first thought was: the easiest way to do this, I think, would be two maps.</p> <pre><code>Map&lt; String, Map&lt; String,Employee&gt; &gt; _employees; </code></pre> <p>But from what it looks like, you just want to be able to look up an employee by either SSN or ID. What's to stop you then from making two maps,...
<p>My first thought was: the easiest way to do this, I think, would be two maps.</p> <pre><code>Map&lt; String, Map&lt; String,Employee&gt; &gt; _employees; </code></pre> <p>But from what it looks like, you just want to be able to look up an employee by either SSN or ID. What's to stop you then from making two maps,...
40,091
<p>How do you estimate a <a href="http://en.wikipedia.org/wiki/Enterprise_application_integration" rel="nofollow noreferrer">EAI</a> project using Function point?</p>
<p>FP analysis is inappropriate for integration projects of any sort as it presupposes that you can specify the application up-front. Most of the work in any integration project of non-trivial complexity is reverse-engineering the nuances of the environment. Typically the environment will not be exhaustively document...
<p>Well given that FP counting is based on storage and end user interface, not sure if its even meaningful for EAI (from what little I remember). </p> <p>I would say you can't, at least not in a useful way. FP counting is generally viewed as a dubious practice of varying accuracy, doing it to an integration project wo...
27,744
<p>I've been building .NET web applications for many years now, and I never use the GAC? </p> <p>What am I missing? Or am I better off staying away from it?</p>
<p>The GAC is only useful if you register libraries which you're going to reuse. It is in no way obligatory to use to run a WebApp without shared libraries .</p>
<p>Like Vincent says, the GAC is important mostly for third-party library vendors who want to support servicing independent of client applications. In other words, if there's a bug in the library, you could upgrade the library and fix all applications that use the library, without having to know which applications they...
40,473
<p>What is Thermal Runaway Protection (TRP) and why should I enable it?</p> <p>How does one do so in Marlin?</p>
<h1>What is TRP and how does it work?</h1> <p>Thermal runaway protection is basically self-explaining; it is protection against the temperature getting out of control. Essentially, the firmware checks whether the measured output of the thermistor (<em>What is a thermistor? A thermistor is basically a temperature senso...
<h2>What is Thermal Runaway?</h2> <p>Let's look at a <a href="https://www.youtube.com/watch?v=qVjWg2vuWzk" rel="nofollow noreferrer">Thermal Runaway Test (#2)</a> performed by one Chris Bate.</p> <p>In this video the experimenter drove the heating element non-stop until disaster. The Nichrome wire in the heating elemen...
1,248
<p>Many beginning programmers write code like this:</p> <pre><code>sub copy_file ($$) { my $from = shift; my $to = shift; `cp $from $to`; } </code></pre> <p>Is this bad, and why? Should backticks ever be used? If so, how?</p>
<p>A few people have already mentioned that you should only use backticks when:</p> <ul> <li>You need to capture (or supress) the output.</li> <li>There exists no built-in function or Perl module to do the same task, or you have a good reason not to use the module or built-in.</li> <li>You sanitise your input.</li> <l...
<p>Perl has a split personality. On the one hand it is a great scripting language that can replace the use of a shell. In this kind of one-off I-watching-the-outcome use, backticks are convenient. <p> When used a programming language, backticks are to be avoided. This is a lack of error checking and, if the separate...
14,115
<p>Is anyone aware of a reasonably well documented example of simulated annealing in Visual Basic that I can examine and adapt?</p>
<p>This project looks pretty well documented: <a href="http://www.codeproject.com/KB/recipes/simulatedAnnealingTSP.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/recipes/simulatedAnnealingTSP.aspx</a>. It's C# but contains only one important source file (TravellingSalesmanProblem.cs) so it's pretty easy ...
<p>I generally refer to "Numerical recipes in C/C++" for all the pseudocode and adapt to my own later. That is the best documentation/implementation you could find. Sometimes you could even find better algorithms or an alternative way of solving. (In case Newton Raphshon is not the way to go)</p>
15,512
<p>I am trying to write a query for SQL Server 2005 but I can't figure out how to do it. I have a table with the following fields:</p> <p><strong>MessageID int<br/> CategoryID int<br/> Priority tinyint<br/> MessageText NVARCHAR(MAX)<br/></strong></p> <p>I need a query that will return * for each row that has the hig...
<p>Verified:</p> <pre><code>SELECT highest_priority_messages.* FROM ( SELECT m.MessageID , m.CategoryID , m.Priority , m.MessageText , Rank() OVER (PARTITION BY m.CategoryID ORDER BY m.Priority DESC) AS p_rank FROM [Message] m GROUP BY m.CategoryID , m.Pri...
<pre><code>SELECT Messages.MessageID , Messages.CategoryID , Messages.Priority , Messages. MessageText FROM Messages INNER JOIN ( SELECT CategoryID , MAX(Priority) AS Priority FROM Messages GROUP BY CategoryID ) AS...
28,005
<p>I've seen this format used for comma-delimited lists in some C++ code (although this could apply to any language):</p> <pre><code>void function( int a , int b , int c ) </code></pre> <p>I was wondering why would someone use that over a more common format such as:</p> <pre...
<p>That's a pretty common coding style when writing SQL statements:</p> <pre><code>SELECT field1 , field2 , field3 -- , field4 , field5 FROM tablename </code></pre> <p>Advantages:</p> <ul> <li>Lets you add, remove, or rearrange fields easily without having to worry about that final trailing comma.</...
<p>I know when I wrap and's in a sql or if statement I try to make sure the and is the start of the next line. </p> <p>If A and B <br> and C </p> <p>I think it makes it clear the the C is still part of the if. The first format you show may be that. But as with most style questions the simple matter is that if the...
28,577
<p>On Windows NTFS there is a nice but mostly unused feature called "Alternate Data Streams" (ADS) which I recently used in a hobby-dev project.</p> <p>On Mac HFS+ there is also a similarly nice but mostly unused feature called "named forks".</p> <p>I am thinking of porting this project to Linux, but I do not know i...
<p>There are file systems on both Windows and Linux (and other OSes) that support extended attributes (EAs). The Windows support was added for OS/2 compat and does not have any documented interface, except for a hacky method through the backup API (that's what Cygwin does). EAs are designed to store small values only. ...
<p>The commonly used Linux filesystems do not support this. Instead you could use multiple files and a suitable naming scheme (just append the stream index to each filename, perhaps), or an archive containing multiple files; you will find such an approach is better in other ways anyway - for instance, what happens on W...
21,681
<p>What would be the best way to have a list of items with a checkbox each in Java Swing?</p> <p>I.e. a JList with items that have some text and a checkbox each?</p>
<p>Create a custom <code>ListCellRenderer</code> and asign it to the <code>JList</code>.</p> <p>This custom <code>ListCellRenderer</code> must return a <code>JCheckbox</code> in the implementantion of <code>getListCellRendererComponent(...)</code> method.</p> <p>But this <code>JCheckbox</code> will not be editable, i...
<p>Here is just a little addition to the JCheckBoxList by Rawa. This will add the ability to select using space bar. If multiple items are selected, all will be set to inverted value of the first item.</p> <pre><code> addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e)...
4,014
<p>We have an application that is built upon ADO.NET. We follow some simple best practices that allow us to make use of the connection pool. For example, a block of code that is using a database might look something like this:</p> <blockquote> <pre><code>using( DbConnection dbConnection = GetDatabaseConnection() ) {...
<p>From the MSDN (<a href="http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx</a>):</p> <p><em>When a SqlConnection object is requested, it is obtained from the pool if a usable connection is available. To be usable, a connection must ...
<p>You can try setting "Max Pool Size" higher. Also you may want to try explicitly calling "Close" on the connection.</p>
44,582
<p>I have a ton of repeating code in my class that looks like the following:</p> <pre><code>NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; </code></pre> <p>The problem with asynchronous requests is when you h...
<p>I track responses in an CFMutableDictionaryRef keyed by the NSURLConnection associated with it. i.e.:</p> <pre><code>connectionToInfoMapping = CFDictionaryCreateMutable( kCFAllocatorDefault, 0, &amp;kCFTypeDictionaryKeyCallBacks, &amp;kCFTypeDictionaryValueCallBacks); </code></pr...
<p>I decided to subclass NSURLConnection and add a tag, delegate, and a NSMutabaleData. I have a DataController class that handles all of the data management, including the requests. I created a DataControllerDelegate protocol, so that individual views/objects can listen to the DataController to find out when their r...
43,042
<p><strong>Scenario</strong>: there is an <strong>Adobe Flex 3</strong> project which uses several third-party libraries and components in the form of <code>SWC</code> files.</p> <p>How can we know "what is inside" those <code>SWC</code> files? Specifically, how can I make sure that the project uses the latest version...
<p>I would consider it good practice to include the version name in the .swc file itself. For example, if you use the Mate framework, the swc filename is something like Mate_08_5.swc. At a quick glance, you can see that you're using version 0.8.5.</p> <p>As far as license goes, usually you distribute a LICENSE text ...
<p>You are making an interesting point.</p> <p>Adobe has provided a way to include basic metadatas in SWFs (and thus in SWCs) but this is stored in the binary and there's no way to extract it without decompilation.</p> <p>Interestingly, if one knows how to read a SWF, extracting metadatas is fairly easy. But most of ...
47,430
<p>As I understand it, <code>.bat</code> is the old 16-bit naming convention, and <code>.cmd</code> is for 32-bit Windows, i.e., starting with NT. But I continue to see .bat files everywhere, and they seem to work exactly the same using either suffix. Assuming that my code will never need to run on anything older than ...
<p>From <a href="https://groups.google.com/group/microsoft.public.win2000.cmdprompt.admin/msg/ad9066638815812c" rel="noreferrer">this news group posting</a> by <a href="http://en.wikipedia.org/wiki/Mark_Zbikowski" rel="noreferrer">Mark Zbikowski</a> himself:</p> <blockquote> <p>The differences between .CMD and .BAT ...
<p>The extension makes no difference.</p> <p>There are slight differences between <code>COMMAND.COM</code> handling the file vs <code>CMD.EXE</code>.</p>
17,950
<p>I have a problem where I want to read an object from the database using Hibernate, change a value, and save the object. If changing the value takes some time, what's the best way to ensure the underlying object in the database has not changed? I am doing this in one transaction (and one session). </p> <p>The code l...
<p>I'd recommend optimistic locking instead. you add a "version" property to your object and then hibernate does an update operation at the end and verifies that the version has not changed since you read the object. generally a much better design than pessimistic locking (nothing like finding those db deadlocks!).</...
<p>You can use pessimistic lock although I wouldn't do that, but it may be useful in your case.</p> <p>Since your object is retrieved from the DB you have to lock the DB so no one else modifies your object while you're working with it.</p> <p>To do that you should <strong><a href="http://www.hibernate.org/hib_docs/v...
44,075
<p>I can create a menu item in the Windows Explorer context menu by adding keys in the registry to <strong>HKEY_CLASSES_ROOT\Folder\shell</strong>.</p> <p>How can I create submenu items to the just created menu item?</p>
<p>First and foremost - backup everything! The databases, the machine itself... You can never be too careful.</p> <p>I was able to upgrade the TFS installation at my company by using these resources:</p> <p><a href="http://olausson.net/blog/CommentView,guid,6f97b619-a5ac-41af-a908-f099d49a3b16.aspx" rel="nofollow nor...
<p>Simply, follow the guidance in the Install document for TFS 2008 - It has an upgrade section. It talks about backing up databases and so on already. The instructions are clear and layed out well. </p>
6,085
<p>My printed parts consist rafts, supports and other extraneous filament when printing with ABS or PLA.</p> <p>What are efficient general techniques of removing them?</p>
<p>The best way to get rid of them is to change the design of the printed object to make them unnecessary.</p> <p>Instead of printing the one part with support material, the piece can be split into two or more parts which can be printed without support material and assembled after the printing.</p> <hr> <p>Given tha...
<p>I usually use a chisel or a flat-head screwdriver to easily remove the bottom plate that the printer auto-generates. I would also suggest using something like wire cutters or some mini pliers to pull them off.</p>
93
<p>I've started printing PETG recently and I'm happy with results so far, awesome strength and good looking (except for stringing). But I've noticed that PETG prints better with more distance nozzle-plate than usual, and under-extrusion make parts looking better than both normal/over-extrusion.</p> <ul> <li>What dista...
<p>Here is the mental framework that I use to reason about PETG: In a nutshell you want to <strong>avoid nozzle contact</strong>.</p> <p>Unlike most other plastics, PETG sticks to hot brass really well and every time the nozzle moves through material it will pick up some of it. Material around the the nozzle then stic...
<p>On my Ender 3 Pro's I have found the following works well (also remember settings can be effected by different brand/quality of filament):</p> <ul> <li>Bed to nozzle 0.2-0.3 mm,</li> <li>Multiplier 100 %,</li> <li>Nozzle ~230 °C/bed 70 °C,</li> <li>Speed 50 mm/s.</li> <li>Cooling off first few layers but from there ...
1,195
<p>On my <a href="http://rads.stackoverflow.com/amzn/click/B007KG0ZYI" rel="nofollow">Switching Power Supply</a> there is a little orange trimpot that's marked <code>VR1</code>; what does that do, and does it work similar to the ones on the stepper drivers?</p>
<p>No doubt it's just a final tuning potentiometer. Even on the pictures you linked it's described as V adj which stands for voltage adjustment. It's a way to tune your power supply's output as it can vary depending on temperature/humidity/wall-plug voltage/etc.</p> <p>It's usually set properly and doesn't need to be ...
<p>Vr usually stands for variable resistor, basically a pot. Usually by adjusting this you would adjust the voltage output on most power supplies, ensure you double check your voltage output with a meter after adjusting.</p>
261
<p>I know that the actual printing time is longer than the time estimated by Cura, due to acceleration and jerk factor.</p> <p>However, I have printed a small pyramid for which Cura estimates 4.0 minutes, while the measured printing time is 2 minutes and 40 seconds. What reasons could produce this difference?</p> <p...
<p>If you properly define your own machine with a <code>delta_wasp.def.json</code> file you can fill in the acceleration and jerk settings of your printer, so that Cura will use the correct values for print time estimation.</p> <p>For example, take a look at <a href="https://github.com/Ultimaker/Cura/blob/master/resou...
<p>Estimating time for any CNC based machines are measured in this formula:</p> <p><em>The length of pulses that machine travels x The feedrate of the pulse itself</em></p> <p>It gives you the time for whole movements. If you're familiar with NC codes, information of any movement is listed in a single line, having it...
599
<p>Are there real tangible differences or is it just a matter of taste?</p>
<p>Getting cruise control setup and maintained takes more time than TeamCity (where you can setup automated project (sln) build in matter of minutes). TeamCity also has a couple of very nice features, such as reporting build failure (via email, jabber, web site) immediately, so you don't have to wait for x minutes.</p...
<p>TeamCity can have PHP support, check the URL below:</p> <p><a href="http://www.waltercedric.com/joomla-mainmenu-247/370-continuous-build/1552-configuring-teamcity-maven-for-php-for-joomla-continuous-build.html" rel="nofollow noreferrer">http://www.waltercedric.com/joomla-mainmenu-247/370-continuous-build/1552-confi...
29,995
<p>I'd like to open the intelligence window without typing a character and then backspacing it. I can't seem to remember the shortcut for this. What is it? </p>
<p><kbd>Ctrl</kbd> + <kbd>Space</kbd>?</p> <p>Also, go to <a href="https://msdn.microsoft.com/en-us/library/5zwses53.aspx" rel="nofollow noreferrer">Tools -> Options -> Environment -> Keyboard</a> or <a href="https://msdn.microsoft.com/en-us/library/da5kh0wa.aspx" rel="nofollow noreferrer">Default Keyboard Shortcuts i...
<p><kbd>Ctrl</kbd> + <kbd>Space</kbd></p>
17,529
<p>I am actually working on SP in SQL 2005. Using SP i am creating a job and am scheduling it for a particular time. These jobs take atleast 5 to 10 min to complete as the database is very huge. But I am not aware of how to check the status of the Job. I want to know if it has got completed successfully or was there an...
<p>This is what I could find, maybe it solves your problem:</p> <ol> <li>SP to get the current job activiity.</li> </ol> <blockquote> <pre><code> exec msdb.dbo.sp_help_jobactivity @job_id = (your job_id here) </code></pre> </blockquote> <p>You can execute this SP and place the result in a temp table and get the req...
<p>--Copy in Query analizer and format it properly so you can understand it easyly --To execute your task(Job) using Query exec msdb.dbo.sp_start_job @job_name ='Job Name',@server_name = server name -- After executing query to check weateher it finished or not Declare @JobId as varchar(36) Select @JobId = job_id from s...
15,264
<p>Please check following image, Dog looks smooth from left side but its rough from right side , similar on back too.</p> <p>What could have caused this ?</p> <p></p> <p>Can it be due to moisture due to Air Conditioner in my room ? <a href="https://i.stack.imgur.com/u3VOP.jpg" rel="nofollow noreferrer"><img src="htt...
<p>I was making following mistakes </p> <p>a) X-axis belt needed a tightening ( I calibrated all X,Y,Z and they were perfect)</p> <p>b) There was under extrusion . ( I had to increase number of steps per mm for extruder motor and store the setting) </p> <p>XYZ calibration cube was really helpful in debugging the...
<p>It is most likely caused by inadequate part-cooling due to poor air-flow. Fit a [better] part cooling fan. There are plenty of designs on Thingiverse.</p> <p>You may also be able to resolve the issue by adjusting the printing temperature, but the easiest solution is to install a good part-cooling fan.</p>
1,323
<p>I'm just curious if any project exists that attempts to group all (or most) of PHP's built-in functions into a more object-oriented class hierarchy. For example, grouping all the string functions into a single String class, etc.</p> <p>I realize this won't actually solve any problems (unless the modifications took ...
<p>I think something like this is intergral for PHP to move forward. Being mainly a .Net programmer, I find PHP painful to work in with it's 1 million and 1 global functions. It's nice that PHP 5.3 has namespaces, but it doesn't help things much when their own libraries aren't even object oriented, let alone employ n...
<p>I don't agree. Object Oriented Programming is not inherently better than procedural programming. I believe that you should not use OO unless you need polymorphic behavior (inheritance, overriding methods, etc). Using objects as simple containers for code is not worth the overhead. This is <em>particularly</em> true ...
8,710
<p>Are there any good and easy to use options for sending secure email? Why is this not commonplace?</p>
<p>SMTP has extensions which support encryption which are supported by most vendors. The receiving server is required to have a certificate (not the sender). So configuring your outbound mail relay to insist upon encrypted connections and verify certificates will usually do it.</p> <p>If you want to encrypt it as far ...
<p><a href="http://www.gnupg.org/" rel="nofollow noreferrer">GnuPG</a> is probably your best bet. It's pretty widely supported and well-tested.</p>
40,242
<p>I've written code for communication between my phone and comp thru TCP sockets. When I type out the code line by line in the interactive console it works fine. However, when i try running the script directly through filebrowser.py it just wont work. I'm using Nokia N95. Is there anyway I can run this script directly...
<p>Have you read <a href="http://pramode.net/articles/lfy/mobile/pramode.html" rel="nofollow noreferrer">Hack a Mobile Phone with Linux and Python</a>? It is rather old, but maybe you find it helpful.</p>
<p>If the code is working in the interactive interpreter when typed, but not when run directly then I would suggest seeing if your code has reached a deadlock on the socket, for example both ends are waiting for data from the other. When typing into the interactive interpreter there is a longer delay between the execu...
17,122
<p>I'm looking for an open-source pastebin web-application written in either Python or Perl. I need it in order to implement a web-based specialized editor for my own needs, and I want to borrow code / ideas from the pastebin since I don't have much experience in web programming.</p> <p>Can you point to one (or a few...
<p><a href="http://dev.pocoo.org/projects/lodgeit/" rel="noreferrer">Lodgeit</a> is written in Python and is a nice pastebin</p>
<p>Hpaste is good. comes with pln txt and python highlighting (pygments) but u can add more easily. n if u need help u can contact the author (patx@patx.me). <a href="http://bitbucket.org/patx/hpaste" rel="nofollow noreferrer">hpaste wiki</a>. also runs in pure python is veyr light wieght and easy to setup (upload to u...
26,911
<p>How do I calculate the position of an accelerating body (e.g. a car) after a certain time (e.g. 1 second)?</p> <p>For a moving body that it not accelerating, it is a linear relationship, so I presume for an accelerating body it involves a square somewhere.</p> <p>Any ideas? </p>
<p>The equation is: s = ut + (1/2)a t^2</p> <p>where s is position, u is velocity at t=0, t is time and a is a constant acceleration.</p> <p>For example, if a car starts off stationary, and accelerates for two seconds with an acceleration of 3m/s^2, it moves (1/2) * 3 * 2^2 = 6m</p> <p>This equation comes from integ...
<p>Assuming you're dealing with constant acceleration, the formula is:</p> <p>distance = (initial_velocity * time) + (acceleration * time * time) / 2</p> <p>where</p> <p><i>distance</i> is the distance traveled</p> <p><i>initial_velocity</i> is the initial velocity (zero if the body is intially at rest, so you can ...
18,533
<p>Say I have the following route:</p> <pre><code>routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" }); </code></pre> <p>Lets also say that my controller has the following methods: <code>Index(Int32 id)</code> and <code>Edit(Int32 id)</code>.</p> <p>So...
<p>You can do the following for now.</p> <pre><code>protected override void HandleUnknownAction(string actionName) { //your code here. } </code></pre> <p>Another approach is that you put a constraint on the default route so it only matches methods you <em>know</em> exist on the controller. Then you could have anoth...
<p>Farooq Kaiser did an article on CodeProject on this topic which I found useful: <a href="http://www.codeproject.com/Articles/39005/Handling-Unknown-Actions-in-ASP-NET-MVC" rel="noreferrer" title="Handling Unknown Actions in ASP.NET MVC">Handling Unknown Actions in ASP.NET MVC</a></p> <p>I particularly like the tric...
38,508
<p>I want to run a weekly batch process in an asp.net page. How can that be done?</p> <p>Thanks</p>
<blockquote> <p>Is there any known drawbacks with the solution?</p> </blockquote> <p><a href="https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/">Here is the blog post</a> in which Jeff Atwood discusses this approach. As with most of Jeff's post, the meat is in the comments where the pros and cons ...
<p>Develop a Windows Service and schedule it to run weekly once.</p>
3,465
<p>Been trying to find a working implementation of a WPF listview (or listbox) where you can order items by dragging them up or down.</p> <p>I have found a few, but none really works, for example this one <a href="http://www.codeproject.com/KB/WPF/ListViewDragDropManager.aspx?msg=2765618#xx2765618xx" rel="nofollow nor...
<p>Drag&amp;Drop is not SO hard, really :) </p> <p>Try reading this <a href="http://www.beacosta.com/blog/?p=53" rel="nofollow noreferrer">post</a> about Drag&amp;Drop. </p>
<p>I've been struggling with WPF drag and drop for a while now and decided to just bite the bullet and create a framework for it.</p> <p>You can find the code here: <a href="http://code.google.com/p/gong-wpf-dragdrop/" rel="nofollow noreferrer">http://code.google.com/p/gong-wpf-dragdrop/</a></p> <p>I’d love to get so...
24,995
<p>I am trying to create a Key Listener in java however when I try </p> <pre><code>KeyListener listener = new KeyListener(); </code></pre> <p>Netbeans is telling me that KeyListener is abstract;cannot be instantiated. I know that I am missing some other piece of this key listener, but since this is my first time usin...
<p><code>KeyListener</code> is an interface - it has to be implemented by something. So you could do:</p> <pre><code>KeyListener listener = new SomeKeyListenerImplementation(); </code></pre> <p>but you can't instantiate it directly. You <em>could</em> use an anonymous inner class:</p> <pre><code>KeyListener listener...
<p>KeyListener is an interface, that means you can write a class based on it and implement its functions. Perhaps this <a href="http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html" rel="nofollow noreferrer">tutorial</a> helps.</p>
36,431
<p>How do I define nested class in Java Script. </p> <p>Here is the code snippet I have:</p> <pre><code>objA = new TestA(); function TestB () { this.testPrint = function () { print ( " Inside testPrint " ); } } function TestA () { var myObjB = new TestB(); } </code></pre> <p>Now I am trying to acces...
<p>If you want the prototype definition of the inner nested classes to be not accessible from outside the outer class, as well as a cleaner OO implementation, take a look at this.</p> <pre><code>var BobsGarage = BobsGarage || {}; // namespace /** * BobsGarage.Car * @constructor * @returns {BobsGarage.Car} */ Bobs...
<p>this is another way to do that.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>class A { constructor(classB) { this.ObjB = classB } } class B { Hello() { c...
22,463
<p>What is the best way to add <strong>non-ASCII</strong> file names to a <strong>zip file</strong> using <strong>Java</strong>, in such a way that the files can be properly read in both <strong>Windows</strong> and <strong>Linux?</strong></p> <p>Here is one attempt, adapted from <a href="https://truezip.dev.java.net/...
<p>The encoding for the File-Entries in ZIP is originally specified as IBM Code Page 437. Many characters used in other languages are impossible to use that way.</p> <p>The <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT" rel="noreferrer">PKWARE-specification</a> refers to the problem and adds a bit. ...
<p>Did it actually fail or was just a font issue? (e.g. font having different glyphs for those charcodes) I've seen similar issues in Windows where rendering "broke" because the font didn't support the charset but the data was actually intact and correct.</p>
13,184
<p>I have a annoying build process from using System.Addins API with ClickOnce. Using System.Addins requires a specific directory structure, and the main project does not reference the adapters, view, and contract directly, which doesn't work well with the ClickOnce architechture.</p> <p>The annoying part with the bui...
<p>I can't fully answer your question, but it appears you are creating ClickOnce deployments through Visual Studio. I would ditch that method and use <a href="http://msdn.microsoft.com/en-us/library/xc3tc5xx(VS.80).aspx" rel="nofollow noreferrer">MageUI</a> instead. It's a stand-alone executable that can be found in ...
<p>ClickOnce do not let you install the software where you want. It will install the binary and dlls in the documents and settings. You can in your project properties go in the Publish tab and select Application Files to select additional file to Include. If the System.Addings require dll in a specific folder relativel...
47,561
<p>Looking to get your take on an automated testing tool (voting should bring good ones to the top)</p> <p>Ideal tool would:</p> <ul> <li>Eliminate the need to present a set of values to a method. </li> <li>employ techniques such as Interactive Exploratory Testing where the code is examined to determine what values a...
<p>I've tried some of these tools in other languages and IMHO they are almost a complete waste of time. Reason? They can't guess at the semantics of a method call in any meaningful way. There's a very good article about this <a href="http://blog.objectmentor.com/articles/2008/01/10/generated-tests-and-tdd" rel="nofo...
<p>Another good tool that automatically generates unit tests is Randoop.</p> <p>Randoop is available for Java (<a href="http://mernst.github.io/randoop/" rel="nofollow">http://mernst.github.io/randoop/</a>) and for .NET (<a href="https://github.com/abb-iss/Randoop.NET" rel="nofollow">https://github.com/abb-iss/Randoop...
6,865
<p>I am implementing a BFS, and what it is going to do is go through an ordered tree to find the shortest solution to a puzzle.</p> <p>What i will be doing is creating a Snapshot object that holds the current position of each piece in a puzzle. I will add this Snapshot object into the queue and check if it is the solu...
<p>I think you're asking how do you create and keep lots of objects when you don't know how many there will be.</p> <p>You need to create an array of the objects. Then you can access them as snapshot[1], snapshot[2]... snapshot[i].</p>
<p>You could use a queue from the standard template library, then create a function that creates a Snapshot object and puts in into the queue. Give this function a static variable which gets incremented every time it is called and written into an id field of the snapshot.</p> <p><a href="http://www.csci.csusb.edu/dic...
26,546
<p>To date I have used <a href="http://replicat.org/" rel="nofollow noreferrer">RepG</a> and <a href="https://www.repetier.com/" rel="nofollow noreferrer">Repetier with CuraEngine</a> to do my slicing. In various instances when printing a layer of a cylinder it will start in the middle and head out toward either side....
<p>I have seen this behavior a lot in CuraEngine slices. Mostly older versions of the slicer. Not sure if they actually improved it. You could see this a lot in long and complicated forms. I also don't like this. Not only for unnecessary moves, but also for imperfections due the start in the middle. Sometimes you can t...
<p>It doesn’t really have much of effect in the actual print. I’m pretty sure the setting can be modified either in the GUI or through gcode. Usually it’s just the standard process when filling in a flat surface. There could be some minor benefits that are quality related. But my main assumption would be for ironing if...
1,521
<p>I know it's simple to implement, but I want to reuse something that already exist.</p> <p>Problem I want to solve is that I load configuration (from XML so I want to cache them) for different pages, roles, ... so the combination of inputs can grow quite much (but in 99% will not). To handle this 1%, I want to have ...
<p>You can use a <a href="http://docs.oracle.com/javase/6/docs/api/index.html?java/util/LinkedHashMap.html" rel="noreferrer">LinkedHashMap</a> (Java 1.4+) :</p> <pre><code>// Create cache final int MAX_ENTRIES = 100; Map cache = new LinkedHashMap(MAX_ENTRIES+1, .75F, true) { // This method is called just after a n...
<p>I also had same problem and I haven't found any good libraries... so I've created my own.</p> <p>simplelrucache provides threadsafe, very simple, non-distributed LRU caching with TTL support. It provides two implementations</p> <ul> <li>Concurrent based on ConcurrentLinkedHashMap</li> <li>Synchronized based on Lin...
27,797
<p>I'm trying to figure out why my app's TCP/IP connection keeps hiccuping every 10 minutes (exactly, within 1-2 seconds). I ran Wireshark and discovered that after 10 minutes of inactivity the other end is sending a packet with the reset (RST) flag set. A google search tells me "the RESET flag signifies that the rece...
<p>A 'router' could be doing anything - particularly NAT, which might involve any amount of bug-ridden messing with traffic...</p> <p>One reason a device will send a RST is in response to receiving a packet for a closed socket. </p> <p>It's hard to give a firm but general answer, because every possible perversion has...
<p>In most applications, the socket connection has a timeout. If there is no communication between the client and the server within the timeout, the connection is reset as you observe. A great example is a FTP server, if you connect to the server and just leave the connection without browsing or downloading files, the ...
31,277
<p>I learned C++ when it was C with classes. I find myself increasingly disliking new technologies like XML and Garbage collection. On the other hand, I have discovered scripting languages like Lua and Python. And I find myself rather liking a hybrid environment of C++, with deterministic memory control, with an embedd...
<p><a href="http://mitpress.mit.edu/sicp/full-text/book/book.html" rel="nofollow noreferrer">Structure and Interpretation of Computer Programs</a> a long with the <a href="http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/" rel="nofollow noreferrer">attendant lectures</a> provide a great introducti...
<p>I don't think you need to go through all that (rather theoretical) CS courses again. Just use wikipedia and look at the Python documentation. When it comes to modern C++ I suggest that you look at the C++ faq lite (just google it).</p>
27,513
<p>I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /dev/tty.usbserial . </p> <p>When i do this everything seems ...
<p><code>/dev/cu.xxxxx</code> is the "callout" device, it's what you use when you establish a connection to the serial device and start talking to it. <code>/dev/tty.xxxxx</code> is the "dialin" device, used for monitoring a port for incoming calls for e.g. a fax listener.</p>
<p>have you tried watching the traffic between the GUI and the serial port to see if there is some kind of special command being sent across? Also just curious, Python is sending ASCII and not UTF-8 or something else right? The reason I ask is because I noticed your quote changes for the strings and in some languages...
2,599
<p>I am having trouble finding good guides for WPF.<br> I have experience in C# and .NET but I don't know anything about WPF except for the regular marketing-ish description of the technology as a whole.<br> Can anyone point me to a good beginner's tutorial/guide on WPF.</p>
<p>Scott Hanselmann has blogged extensively about his experience in learning WPF by creating his 'BabySmash' windows application. All the source code is on codeplex and he has many blog articles describing his progress.</p> <p><a href="http://www.hanselman.com/blog/IntroducingBabySmashAWPFExperiment.aspx" rel="nofollo...
<p>Have a look at the <a href="http://joshsmithonwpf.wordpress.com/a-guided-tour-of-wpf/" rel="nofollow noreferrer">Guided tour of WPF</a> by Josh Smith. I also really like Adam's Nathan book WPF Presentation Unleashed.</p>
4,945
<p>I have a windows forms application with controls like textbox, combobox, datagridview etc. These controls allow a user to use the clipboad, i.e. cut/copy and paste text. It is also possible to delete text (which is not related to the clipboard).</p> <p>My application has a menubar with an Edit item containing Cut/C...
<p>There is no generic interface or set of methods for getting cut/copy/paste information from a windows forms control. </p> <p>I suggest your best approach would be to create a wrapper class for each type of control. Then when you want to update the menu state you get the current control with focus and create the app...
<p>Create an array for each enable/disable group. Add the controls to the array (of course it has to be of the correct type such as Object or Any, etc. depends on the programming language you are using). Then to enable, disable just loop through the array and invoke the enable/disable method or function for each contro...
11,771
<p>I have to solve the following problem in an optimal way.</p> <p>Input data is:</p> <ul> <li>N points in a plane given as a (x, y) pair of integer coordinates</li> <li>M points in the same plane given as a (x, y) pair of integer coordinates representing the center of a circle. All this circles have (0, 0) on their ...
<p>Here is the <a href="http://en.wikipedia.org/wiki/Envelope_(mathematics)" rel="nofollow noreferrer">Wikipedia entry on envelopes</a>. Here is a tutorial about <a href="http://www.economics.utoronto.ca/osborne/MathTutorial/MEEF.HTM" rel="nofollow noreferrer">the envelope theorem in optimization</a>.</p>
<p>Consider some other aspects of your computations.</p> <p>For instance, you apparently compare a lot of distances. Each takes a call to SQRT. Why not compare the "squares of the distances" instead. SQRT is a costly computation.</p>
45,284
<p>I want my background worker to add items to a list box, it appears to do so when debugging but the listbox doesn't show the values. I suspect this is something to do with adding items whilst inside the background worker thread, do I need to add these to an array and then populate the list box from the array during <...
<p>You can use Invoke like this:</p> <pre><code>private void AddToListBox(object oo) { Invoke(new MethodInvoker( delegate { listBox.Items.Add(oo); } )); } </code></pre>
<p><code>Application.Doevents()</code> function will solve the problem.</p>
48,040
<p>How do you programmatically set a DataContext that specifies the selected item of a list? </p> <p>More simply, how do you reproduce this type of binding in code?</p> <pre><code>&lt;StackPanel&gt; &lt;ListBox Name="listBox1" /&gt; &lt;TextBox Name="textBox1" DataContext="{Binding ElementName=listBox1, Path=...
<p>You need to set a Name for the textbox so you can refer to it in code. Then you should just be able to assign an object to the DataContext property. You can create a data binding programatically like so:</p> <pre><code>Binding binding = new Binding(); binding.ElementName = "listBox1"; binding.Path = new PropertyP...
<p>Wow, sometimes you just have to spell the question out to get that extra nudge in the right direction, huh?</p> <p>This code works for me:</p> <pre><code>Binding b = new Binding(); b.Path = new PropertyPath(ListBox.SelectedItemProperty); b.Source = listBox1; textBox1.SetBinding(TextBox.DataContextProperty, b); </c...
31,004
<p>I'm trying to write something that puts the contents of the message on a queue, to have work done on it later. I've been messing around with IMAP IDLE with varying degrees of success.</p> <p>I was wondering if anyone knows of a method to have a mail server receive an email, and then perform an action like posting t...
<p>Try <a href="http://www.catb.org/~esr/fetchmail/" rel="noreferrer">fetchmail</a> and <a href="http://www.procmail.org/" rel="noreferrer">procmail</a>. You periodically poll the mail server (every minute if necessary) and use fetchmail to download from the IMAP server. Set up a procmail rule to run your notifier ap...
<p>Configure the SMTP (mail transport) server to deliver the mail to an application that performs the desired action. Don't do it on the IMAP (mailbox client) level if you can avoid it.</p>
40,145
<p>The site I'm working on is using a Databound asp:Menu control. When sending 1 menu item it renders HTML that is absolutely correct in Firefox (and IE), but really messed up code in Safari and Chrome. Below is the code that was sent to each browser. I've tested it a few browsers, and they are all pretty similarly ...
<p>I found this solution from a comment on <a href="http://weblogs.asp.net/dannychen/archive/2005/11/21/using-device-filters-and-making-menu-work-with-safari.aspx" rel="noreferrer">weblogs.asp.net</a>. It might be a hack, but it does work.</p> <p>This cross browser compatibility struggle is getting upsetting. </p> <p...
<p>Adding <code>ClientTarget="uplevel"</code> to the page directive like so makes Safari work:</p> <pre><code>&lt;%@ Page ClientTarget="uplevel" ... %&gt; </code></pre>
34,976
<p>A client is asking to incorporate commenting on their news articles. They're using the Sharepoint news site template for their news publishing, etc. They want a simple commenting system, much like what is available on most blog engines, only they want it at the bottom of each news article.</p> <p>I just thought I w...
<p>I struggled with this a while back and the solution we found was to use a discussion borad list (out of the box) and we created a custom web part that we added to the page layout for news.</p> <p>We had to do som trickery to add support for anonymous comments, but on the whole it works good and wasen't to much code...
<p>I had the same request. I didn't find an existing solution, so I did it by copying from the standard Blog site template, plus custom coding.</p> <p>From the template: Copy the definition for the blog comments list. Remove the lookup fields, and use a feature to create the list on all publishing sites.</p> <p>Cus...
35,231
<p>I have the following webform:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestWebApp.Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="h...
<p>can't help with VB6 solution, can help with .net or java solution on the server.<br> Get iText or iTextSharp from <a href="http://www.lowagie.com/iText/" rel="nofollow noreferrer">http://www.lowagie.com/iText/</a>.<br> It has a PdfStamper class that can merge a PDF and FDF FDFReader/FDFWriter classes to generate F...
<p>Take my advice. Ditch PDF for XPS. I am working on two apps, both server based. One displays image-based documents as PDFs in a browser. The second uses FixedPage templates to construct XPS documents bound to data sources. </p> <p>My conclusion after working on both projects is that PDFs suck; XPS documents le...
7,845
<p>I need to programatically determine whether .NET 3.5 is installed. I thought it would be easy:</p> <pre><code>&lt;% Response.Write(Environment.Version.ToString()); %&gt; </code></pre> <p>Which returns "2.0.50727.1434" so no such luck...</p> <p>In my research I have that there are some rather obscure registry keys...
<p>You could try:</p> <pre><code>static bool HasNet35() { try { AppDomain.CurrentDomain.Load( "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); return true; } catch { return false; } } </code></pre> <p>@<a href="https://stack...
<p>Without any assembly loading and catching exceptions (which is slow), check for class API changes between 2.0 and 3.5. <a href="http://mono.ximian.com/class-status/2.0-vs-3.5/index.html" rel="nofollow noreferrer">Mono Class Status</a> is very helpful for this. For example you could check for <code>GC.Collect Method ...
3,693
<p>py2exe does not work with the standard email module</p> <p>Hello. I am trying to use py2exe for converting a script into an exe. The build process shows this:</p> <hr> <p>The following modules appear to be missing</p> <h2>['email.Encoders', 'email.Generator', 'email.Iterators', 'email.MIMEBase', 'email.MIMEMulti...
<p>Have a look at this question <a href="https://stackoverflow.com/questions/169897/how-to-package-twisted-program-with-py2exe">how-to-package-twisted-program-with-py2exe</a> it seems to be the same problem.</p> <p>The answer given there is to explicitly include the modules on the command line to py2exe.</p>
<p>while porting my app from py24 to 26 I had the same problem.</p> <p>After reading <a href="http://www.py2exe.org/index.cgi/ExeWithEggs" rel="nofollow noreferrer">http://www.py2exe.org/index.cgi/ExeWithEggs</a> if found finaly following solution:</p> <h2>in my application.py:</h2> <pre><code>import email import em...
20,984
<p>When creating a new file with vim, I would like to automatically add some skeleton code.</p> <p>For example, when creating a new xml file, I would like to add the first line:</p> <pre><code> &lt;?xml version="1.0"?&gt; </code></pre> <p>Or when creating an html file, I would like to add:</p> <pre><code>&lt;!DOCT...
<p>I got something like this in my .vimrc:</p> <pre><code>au BufNewFile *.xml 0r ~/.vim/xml.skel | let IndentStyle = "xml" au BufNewFile *.html 0r ~/.vim/html.skel | let IndentStyle = "html" </code></pre> <p>And so on, whatever you'll need.</p>
<p>It can work with snipmate too:</p> <pre class="lang-bash prettyprint-override"><code>augroup documentation au! au BufNewFile *.py :call ExecuteSnippet('docs') augroup END function! ExecuteSnippet(name) execute "normal! i" . a:name . "\&lt;c-r&gt;=TriggerSnippet()\&lt;cr&gt;" endfunction </code></pre> ...
19,663
<p>Is it worth changing my code to be "more portable" and able to deal with the horror of magic quotes, or should I just make sure that it's always off via a .htaccess file?</p> <pre><code>if (get_magic_quotes_gpc()) { $var = stripslashes($_POST['var']); } else { $var = $_POST['var']; } </code></pre> <p>Versu...
<p>Don't accommodate both situations. Two code paths = twice the headaches, plus there's a good chance you'll slip up and forget to handle both situations somewhere.</p> <p>I used to check if magic quotes were on or off, and if they were on, undo their magic (as others in the thread have suggested). The problem with...
<p>On more of a side note php 6 won't be supporting them anymore. So writting the code for them off may be beneficial in the future.</p>
48,373
<p>Couldn't think of an intuitive way to paraphrase the topic for this question, and I apologize for that. My question is the following:</p> <p>I have several UIViewController's which need to call in a UIDatePicker. I didn't want to subclass the Date Picker several times as it's the same interface. The problem I'm hav...
<p>It's not obvious from the question if you're creating a custom UIDatePicker subclass, or if you are just implementing UIDatePicker delegate methods in several different custom UIViewController subclasses.</p> <p>In either case, I think some combination of a delegate and a protocol is what you're looking for. </p> ...
<p>You can have a "base" view controller, BaseViewController for example. This controller would have any datepicker specific code in it. Then, all the related view controllers would then be subclasses of that base controller. Customize the behavior as needed for each controller, but you'll still have the basic picker-h...
45,645
<p>This code is executed by many way. When it's executed by the form button it works (the button start a thread and in the loop it call this method = it works). BUT it doesn't work when I have a call to that method from my BackgroundWorker in the form. </p> <p>With the following code:</p> <pre><code>private void resi...
<p>You need to return at the end of the if block - otherwise you'll resize it in the right thread, and then do it in the wrong thread as well.</p> <p>In other words (if you'd cut and paste the code instead of a picture, this would have been easier...)</p> <pre><code>private void resizeThreadSafe(int width, int height...
<p>You need write this:</p> <pre><code>if ( this.form.InvokeRequired ) { this.form.Invoke( ...... ); return; } this.form.Size = new Sizte( ... ); </code></pre> <p>OR</p> <pre><code>if ( this.form.InvokeRequired ) { this.form.Invoke( ...... ); } else { this.form.Size = new Sizte( ... ); } </code></pre...
43,746
<p>I am developing an online examination using servlets/jsp.I need to add a count down (hh/mm/ss) timer to the questions page that would end the exam and redirects to results page.</p> <p>I am done with all the other functionalities except the timer one.</p> <p>Can someone provide some help on this.</p> <p>Thanks</p...
<p>Have you tried a JavaScript solution. Its pretty easy to write your own. There is also a ton of examples on the net such as this <a href="http://javascript.internet.com/time-date/countdown-timer.html" rel="nofollow noreferrer">one</a>.</p>
<pre><code>&lt;html&gt; &lt;%@page session="false" %&gt; &lt;% HttpSession s=request.getSession(false); if(s==null) { %&gt; &lt;jsp:forward page="/Expired" /&gt; &lt;% } %&gt; &lt;% String duration=(String)s.getAttribute("duration"); %&gt; &lt;% int a=Integer.parseInt(duration); %&gt; &lt;head&gt;&lt;title&gt;&lt...
39,656
<p>I'm trying to trouble shoot a web service client in my current project. I'm not sure of the platform of the Service Server (Most likely LAMP). I believe there is a fault on their side of the fence as i have eliminated the potential issues with my client. The client is a standard ASMX type web reference proxy auto...
<p>I made following changes in <code>web.config</code> to get the SOAP (Request/Response) Envelope. This will output all of the raw SOAP information to the file <code>trace.log</code>.</p> <pre><code>&lt;system.diagnostics&gt; &lt;trace autoflush="true"/&gt; &lt;sources&gt; &lt;source name="System.Net" maxdata...
<p>I realize I'm quite late to the party, and since language wasn't actually specified, here's a VB.NET solution based on Bimmerbound's answer, in case anyone happens to stumble across this and needs a solution. Note: you need to have a reference to the stringbuilder class in your project, if you don't already.</p> <p...
38,556
<p>The application my team is currently developing has a DLL that is used to perform all database access. The application can not use a trusted connection because the database is behind a firewall and the domain server is not. So it appears that the connection string needs to have a DB username and password. The DLL...
<p>I'm not certain, but I believe you can put it in a config file and encrypt the config file.</p> <p>Update: See Jon Galloway's post <a href="http://weblogs.asp.net/jongalloway/archive/2008/04/13/encrypting-passwords-in-a-net-app-config-file.aspx" rel="nofollow noreferrer">here.</a></p>
<p>If the app is an ASP.NET app then just encrypt the connection strings section of your <code>web.config</code>.</p> <p>If the app is a client application running on multiple machines, instead of storing the connection string locally, consider using a web service or some other kind of secure mechanism to store it cent...
2,792
<p>I am curious to know How the Loader Maps DLL in to Process Address Space. How loader does that magic. Example is highly appreciated.</p> <p>Thanks in advance.</p>
<p>What level of detail are you looking for? On the basic level, all dynamic linkers work pretty much the same way:</p> <ol> <li>Dynamic libraries are compiled to relocatable code (using relative jumps instead of absolute, for example).</li> <li>The linker finds an appropriately-sized empty space in the memory map of ...
<p>Assuming this is in Windows (DLL hints at that), you might want to read Microsoft's <a href="http://msdn.microsoft.com/en-us/library/ms685090(VS.85).aspx" rel="nofollow noreferrer">Run-Time Dynamic Linking</a> documentation page. It doesn't specify in detail <em>how</em> the DLL is mapped into the address space; I g...
43,685
<p>Using Java mail, I would like to send an e-mail and check the status. Possible statuses include:</p> <ul> <li>Hard-bounce: No mail server found</li> <li>Soft-bounce: Mail server found, but account not found</li> <li>Success</li> </ul> <p>Is it even possible to send an e-mail and get some feedback about the delivery ...
<p>You can't do this reliably or consistently. What happens if your local mail server passes it onto a corporate out-going mail server, and then it bounces when that server tries to pass it on? What happens if the mail server can't talk to the other mail server and then the message times out after 4 days?</p>
<p>This <a href="http://edelstein.pebbles.cs.cmu.edu/jadeite/main.php?api=javamail&amp;state=package&amp;package=com.sun.mail.dsn" rel="nofollow">link</a> might helps you. This in an experimental jar file which uses RFC 3642 and RFC 3464. It has some basic classes which allows you to get the mail delivery status. And a...
18,099
<p>I have all the web pages of a website. My task is to change all HTML files to <code>.asp</code> files and change the links. I have about 280 HTML files.<br> Is there any software or web service which can read a website and show me the link structure of the site (to make my job easier) similar to a site map?</p>
<p>If the links use relative paths, all you have to do is to change the .html file extensions to .asp and place the files on a server that can run ASP.</p> <p>If they are absolute paths, you can get away with editing your hosts file to point the original domain to your own server and just place the untouched files on ...
<p>I don't understand what you are doing but when I want to know what links are on a webpage I grab Avant (ver 10) browser out of my archives and install. Go to the webpage you want to look at, right-click on the page and select "Open All Links in This Page."</p>
27,195
<p>Each month I get new CMYK and RGB images that shall be used on the web.</p> <p>I had a script using a patched up ImageMagick doing this, but it got deleted. So I need to do it again, but it was hard last time.</p> <p>How do you <em>easily</em> and quickly convert CMYK image files to RGB?</p>
<p>Like so:</p> <pre><code>convert CMYK.tiff -profile "RGB.icc" RGB.tiff </code></pre>
<p>The answer of g.b.1981 basically is correct (+1), but...</p> <p>To make it work reliable, I found I had to add <code>-type truecolor</code> to the commandline:</p> <pre><code>convert cmyk.jpg -colorspace rgb -type truecolor rgb.jpg </code></pre>
46,476
<p>If I have a string (010) and i want to add 1 to it (011) what value type should i use to convert this string into a number for adding and at the same time preserve the whole number and not 10 + 1 = 11. </p>
<p>You could use something like this:</p> <pre><code>string initialValue = "010"; int tempValue = Int.Parse(initialValue) + 1; string newValue = tempValue.ToString("000"); </code></pre> <p>You do your math as normal and then just return your string to its previous format using the number formatting feature of the <co...
<p>Would it be possible to just always ensure that there are three digits?</p> <p>So, you would do the math as usual, but create a function to attach extra zeros to the front, if needed?</p>
25,696
<p>Are there any good oracle podcasts around? The only ones I've found is produced by oracle corp, and as such are little more than advertising pieces pushing their technology of the moment.</p> <p>I'm specifically interested in Database technologies.</p>
<h2>Oracle Podcast Center</h2> <hr> <p><a href="http://www.oracle.com/applications/podcasts-sustainability.html" rel="nofollow noreferrer">Green Enterprise Podcasts</a></p> <p>Host: Paul Salinger, VP Marketing</p> <p>Listen to discussions with customers, partners, and Oracle green experts, exploring topics that can...
<p>Asking for an "Oracle podcast" that isn't going to be a product marketing focused is too broad. It's almost like asking for a "Microsoft Podcast." Anything you get is going to be broad and shallow. An introduction, nothing in depth.</p> <p>What are you looking for? DB, Middleware, Linux/OS, ERP, CRM, BI, Informatio...
6,950
<p>User A logs into a ticket management system to edit content on "SomePage.aspx"</p> <p>User B logs in 30 seconds later to edit the same ticket on "SomePage.aspx"</p> <p>What are some of the best known practices(in a 3-tier architecture) for notifying each of the users that someone else is modifying the same content...
<p>In a request/response system like HTTP, there isn't much of a concept of what a user is currently doing. You could notify them that someone else opened the ticket for edit "within the last two minutes" (or even prevent them from opening it in such a case) but user A could edit for half an hour - unless you prohibit ...
<p>i'm assuming that you're talking about a help-desk ticket or something analgous, where only one user should be working on it at a time. In this case the status of the ticket should change when the first user <em>checks it out</em></p>
28,806
<p>I don't really <em>get</em> lambda expressions. While they've been around since the days of ALGOL, I didn't start hearing about them until fairly recently, when Python and Ruby became very popular. Now that C# has the <code>=&gt;</code> syntax, people in my world (.NET) are talking about lamdba expressions more and...
<p>Basically as far as C# is concerned, lambda expressions are an easy way to create a delegate (or an expression tree, but let's leave those aside for now).</p> <p>In C# 1 we could only create delegate instances from normal methods. In C# 2 we gained anonymous methods. In C# 3 we gained lambda expressions, which are ...
<p>My main use of lambda expressions in .NET has been when working with lists. Using a lambda expression you can build up a query on a list in a similar way as you would build an SQL statement to search a database table.</p>
22,693
<p>I've implemented a stopwatch that works fine without considering that bank holidays and weekends shouldn't be counted in the total duration. I was looking for some open-source library where I could get the elapsed time, passing a start instant, end instant and a set of bank holidays (weekends aren't counted in). The...
<p>As I have mentioned <a href="https://stackoverflow.com/questions/80541/given-two-dates-what-is-the-best-way-of-finding-the-number-of-weekdays-in-php#80627">there</a>, probably the best and easiest approach is to create a table containing information about each day (work day count from beginning / bank holiday, etc; ...
<p>Do you only count Bank Hours too? 9AM - 3PM? Or is it 24 hours a day?</p>
11,791
<p>I've seen several examples of code like this:</p> <pre><code>if not someobj: #do something </code></pre> <p>But I'm wondering why not doing:</p> <pre><code>if someobj == None: #do something </code></pre> <p>Is there any difference? Does one have an advantage over the other?</p>
<p>In the first test, Python try to convert the object to a <code>bool</code> value if it is not already one. Roughly, <strong>we are asking the object : are you meaningful or not ?</strong> This is done using the following algorithm :</p> <ol> <li><p>If the object has a <code>__nonzero__</code> special method (as do ...
<p>For one the first example is shorter and looks nicer. As per the other posts what you choose also depends on what you really want to do with the comparison.</p>
12,602