instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>How could I create iPhone applications using the .NET development environment?</p>
| <p>The Mono team are working on 'static compilation' which allows mono apps to be run on a non-jailbroken iPhone. In short this works by running a cross-compiling JIT step as part of the build process to generate a native exe.</p>
<p>There was a demo of this at the PDC ... see <a href="http://tirania.org/blog/archive... | <p>There are ways to get other languages to work, they will - however - almost certainly not be accepted to the AppStore and will break with future updates. Generally it is better to use a screw driver to screw something into a hole than to thwap it repeated with a hammer attached to a 250hp motor...</p>
| 37,554 |
<p>I can't believe I am asking this...</p>
<p>It has been a while since I used VC6. I set up what I thought was the correct way to include additional directories for include files (I removed another developer's hard coded paths) and put in something like:</p>
<p>%MY_DIR%\include</p>
<p>but this does not work. Am I... | <p>Here's the answer...</p>
<p>it works fine. </p>
<p>$(ENV_VAR_NAME)
not
%ENV_VAR_NAME%</p>
<p>(I feel like an idiot. )</p>
| <p>I don't think that the IDE will take any environment settings unless you use that flag. </p>
<p>Oh, and you don't <em>have</em> build from the command line if you launch it from the command line. You can still use the build menu in the IDE. </p>
| 28,654 |
<p>I have a problem with IIS 6.0 ceasing to work for an ASP.NET application after installing Service Pack 1 for <code>.NET 3.5</code>.</p>
<p>I have 2 identical virtual dedicated servers. Installing SP1 on the first had no adverse effect. Installing it on the second caused ASP.NET pages to start returning 404 page not... | <p>This is broad problem, so let's start by asking some troubleshooting questions:</p>
<blockquote>
<ul>
<li>Based on your description, the ASP.NET runtime is not catching your request and processing the aspx files. You may need to register the asp.net pipeline with IIS again using ASPNET_REGIIS -i.</li>
<li>Ha... | <p>No-one did before, so I'll point to the trivial solution:<br>
Have you already de-installed the Service Pack and re-installed it again (or the whole framework)?</p>
<p>Edit: @Kev:<br>
Easy explanation: He said the update works on one machine, but not on the other. I had similar problems in the past and re-installin... | 3,574 |
<p>I have a few lines of PowerShell code that I would like to use as an automated script. The way I would like it to be able to work is to be able to call it using one of the following options:</p>
<ol>
<li>One command line that opens PowerShell, executes script and closes PowerShell (this would be used for a global b... | <p>Save your script as a .ps1 file and launch it using powershell.exe, like this:</p>
<pre><code>powershell.exe .\foo.ps1
</code></pre>
<p>Make sure you specify the full path to the script, and make sure you have set your execution policy level to at least "RemoteSigned" so that unsigned local scripts can be run.</p>... | <p>you can use this command :
powershell.exe -argument c:\scriptPath\Script.ps1</p>
| 4,931 |
<p>I have a button that adds an already defined usercontrol programtically. I am rebuilding each control on Postback and they show up fine. If I put text in the textbox it shows up fine, however my images are losing their url. Any idea why or how I can fix this?</p>
<p>I tried adding AJAX updatepanel to see if that ... | <p>You are correct <code><img></code> is an html control, while <code><asp:Image></code> is a server control. As long as server controls have viewstate enabled they will keep their values during postbacks.</p>
| <p>Image is not form field. That is why it's value is never posted back to server.</p>
<p>The reason your asp:Image controls retain value during postback is because they are stored in viewstate (which is stored in hidden field). When you click button this viewstate is posted back to server, and asp.net sets the ImageU... | 26,653 |
<p>For example, I'm writing tests against a CsvReader. It's a simple class that enumerates and splits rows of text. Its only <em>raison d'être</em> is ignoring commas within quotes. It's less than a page.</p>
<p>By "black box" testing the class, I've checked things like</p>
<ul>
<li>What if the file doesn't exist?... | <p>This really depends on the interface of your CsvReader, you need to consider what the user of the class is expecting. </p>
<p>For example, if one of the parameters is a file name and the file does not exist what should happen? This should not be dependent upon whether you use a stream reader or not. The unit tests ... | <p>You should always be managing errors that your framework throws; that way your application is robust & doesn't crash on catastrophic errors...</p>
| 24,840 |
<p>I'm curious about keeping source code around reliably and securely for several years. From my research/experience:</p>
<ol>
<li><p>Optical media, such as burned DVD-R's lose bits of data over time. After a couple years, I don't get all the files off that I put on them. Read errors, etc.</p></li>
<li><p>Hard drives ... | <p>The best answer is "in multiple places". If I were concerned about keeping my source code for as long as possible I would do: </p>
<p>1) Backup to some optical media on a regular basis, say burn it to DVD once a month and archive it offsite. </p>
<p>2) Back it up to multiple hard drives on my local machines </p>
... | <p>One way would be to periodically recycle your storage media, i.e. read data off the decaying medium and write it to a fresh one. There exist programs to assist you with this, e.g. <a href="http://www.dvdisaster.com/" rel="nofollow noreferrer">dvdisaster</a>. In the end, nothing lasts forever. Just pick the least ann... | 9,945 |
<p>I've read only good things about Merb, but the documentation on the <a href="http://merbivore.com/" rel="nofollow noreferrer">website</a> is basically the api reference, and right now there is no books already published. </p>
<p>Any resources about Merb?</p>
<p>I guess that I'll start to read the code, but it'd be... | <p>The wonderful <a href="http://peepcode.com/" rel="nofollow noreferrer">PeepCode</a> have got a <a href="http://peepcode.com/products/meet-merb-pdf-draft" rel="nofollow noreferrer">Merb PDF and screencast</a> available for $9.</p>
| <p>I think merb has been pretty bad about good example code, tutorials and updating dated information. I really like the project, but have been stung by this several times. Now that it has reached a semi stable 1.0 I really hope that some people step up and get a bunch of the docs up to date, add warnings to old docs a... | 43,018 |
<p>How would one go about displaying taskbar notifications?</p>
<p>I want to write an app that periodically displays a flash card esque notification, the intention is to see if a 5 second or so distraction every hour can help with language learning.</p>
| <p>In .NET you can use the <a href="http://msdn.microsoft.com/en-us/library/aa972170.aspx" rel="noreferrer">Notification Icon</a> to place a notification in the system tray.</p>
| <p>In .NET you can use the <a href="http://msdn.microsoft.com/en-us/library/aa972170.aspx" rel="noreferrer">Notification Icon</a> to place a notification in the system tray.</p>
| 26,783 |
<p>How does the processing overhead of the length() function in REXX change with the length of the string?</p>
<hr>
<p>Update: I'm using:</p>
<ul>
<li>uni-REXX (R) Version 297t</li>
<li>Open-REXX
(TM) Copyright (C) iX Corporation
1989-2002. All rights reserved.</li>
</ul>
| <p>The overhead is 0. The length is stored in a descriptor.</p>
<p>Neil Milsted
Author of uni-REXX (no kidding).</p>
| <p>It's language implementation specific. It was a long time since I wrote any REXX now, in fact I wrote AREXX (the Amiga implementation) and it was 15 years ago. :-)</p>
<p>You can write your own test routine. Generate strings of increasing length and measure the time it takes to get length() using a high performance... | 48,036 |
<p>I will be entering my third year of university in my next academic year, once I've finished my placement year as a web developer, and I would like to hear some opinions on the two modules in the Title.</p>
<p>I'm interested in both, however I want to pick one that will be relevant to my career and that I can apply t... | <p>The worthiness depends on three factors:</p>
<ul>
<li>How familiar are you with the topic already?</li>
<li>How good is the course/class you want to take?</li>
<li>What are your interested in more?</li>
</ul>
<p>Especially for HCI, there is a broad range of "common sense" information you would also easily obtain f... | <p>as a programmer to be you need the knowledge of neural network. if parallel processing is the way to go in hardware then future programmers must be knowledgable in neural network. don't forget that NN works better with noise or imprecise data but other systems may not. Note that most data we use for analysis are sam... | 26,678 |
<p>I have a very simple TCP server written in C. It runs indefinitely, waiting for connections. On Windows, I use <code>select</code> to check for activity on the socket, and if there isn't any, I have the following code to allow me to quit by hitting 'q' on the keyboard:</p>
<pre><code>if( kbhit() ) {
char c = get... | <p>Add stdin to your list of select handles, and if it has data, call read to read one character from it.</p>
| <p>Rather, add "f" from your </p>
<pre><code>read( f, &c, 1 )
</code></pre>
<p>to select call. When f is ready for read, a character has been pressed, and read() will not block.</p>
| 22,267 |
<p>I am trying to make a graph in java that would have different nodes. some nodes would be connected to others and some wont. If they are connected then some boolean value for that node will be true and another variable will hold the value of the node it is connected to. </p>
<p>...any suggestions on what you guys th... | <p>The two most common ways to represent a graph are adjacency matrix and adjacency lists. Let n be the number of nodes. </p>
<p>Adjacency matrix A is an n x n matrix of boolean values, such that A(i, j) = 1 if nodes i and j are connected, and 0 if they are not.</p>
<p>In adjacency lists representation for each nod... | <p>Possibly a duplicate of '<a href="https://stackoverflow.com/questions/51574/good-java-graph-algorithm-library#52062">Good Java graph algorithm library?</a>'. The short answer would be to look at <a href="http://jgrapht.sourceforge.net/" rel="nofollow noreferrer">JGraphT</a>.</p>
| 45,345 |
<p>I'm using SQL Server 2005, and creating ftp tasks within SSIS. </p>
<p>Sometimes there will be files to ftp over, sometimes not. If there are no files, I don't want the task nor the package to fail. I've changed the arrow going from the ftp task to the next to "completion", so the package runs through. I've cha... | <p>Check this <a href="http://sqlblog.com/blogs/rushabh_mehta/archive/2008/04/24/gracefully-handing-task-error-in-ssis-package.aspx" rel="noreferrer">link</a> that describes about gracefully handling task error in SSIS Package.</p>
<p>I had almost the same problem but, with retrieving files. I wanted the package NOT t... | <p>Put it in a ForEach container, which iterates over the files to upload. No files, no FTP, no failure.</p>
| 17,019 |
<p>I sometimes code when i'm away from the office. I would like to continue to use the benifits of source control when not connected to the company network.</p>
<p>My ideal system would allow me to checkin revisions to a repository on my laptop that would then sync with our main SVN repository when I connect to the co... | <p>This is the principle of <a href="http://git.or.cz/" rel="nofollow noreferrer">GIT</a> (a kind of new subversion). Git has local repository. For SVN, I have a VPN to the company, so I can still use the SVN Server from home, maybe this can be a solution to avoid changing of repository system (I know you aren't always... | <p>in my previous company the svn server was made available through a public domain, but access to the server was strict. You can set up authentication for checking out and commit on your svn server as for the off line commits I would recommend git.</p>
| 48,127 |
<p>I'm working on automating the configuration of several JBoss servers, which involves editing a substantial number of XML files.</p>
<p>I'd like to script all these changes as much as possible. But the "standard" tools (sed, grep et al) do not work well with XML. Without necessarily resorting to a higher-level langu... | <p>You'll find more answers in my <a href="https://stackoverflow.com/questions/91791/grep-and-sed-equivalent-for-xml-command-line-processing" title="Grep and Sed Equivalent for XML">previous question</a>. <a href="http://xmlstar.sourceforge.net/" rel="nofollow noreferrer" title="XMLStarlet tool collection">xmlstar</a> ... | <p>NAnt, the .NET cousin of Ant, has <a href="http://nant.sourceforge.net/release/latest/help/tasks/xmlpeek.html" rel="nofollow noreferrer">XmlPeek</a> and <a href="http://nant.sourceforge.net/release/latest/help/tasks/xmlpoke.html" rel="nofollow noreferrer">XmlPoke</a> tasks that I've used to very good effect in editi... | 40,882 |
<p>What I mean by autolinking is the process by which wiki links inlined in page content are generated into either a hyperlink to the page (if it does exist) or a create link (if the page doesn't exist).</p>
<p>With the parser I am using, this is a two step process - first, the page content is parsed and all of the li... | <p>In my own wiki I check all the links (without caching), but my wiki is only used by a few people internally. You should benchmark stuff like this.</p>
| <p>My idea would be to query the titles like <code>SELECT title FROM articles</code> and simply check if each wikilink is in that array of strings. If it is you link to the page, if not, you link to the create page.</p>
| 3,536 |
<p>I am a AS3 novice learning PureMVC and want to write code following best practices so that any other AS3 developer can pick up my code and easily understand what I did, I am tempted to do stuff as I would in JavaScript or Asp.Net/C#, but I have a feeling that might not be the best approach.</p>
<p>Thoughts? Links?<... | <p>I found that reading through the docs helped me get a clear definition of each of the parts to <a href="http://puremvc.org/" rel="nofollow noreferrer">PureMVC</a>. On top of that I downloaded the source for the demos and added them in Flex Builder so I could look through them easily and see how they were constructe... | <p>I found that reading through the docs helped me get a clear definition of each of the parts to <a href="http://puremvc.org/" rel="nofollow noreferrer">PureMVC</a>. On top of that I downloaded the source for the demos and added them in Flex Builder so I could look through them easily and see how they were constructe... | 17,390 |
<p>I'm looking to force my application to shut down, and return an Exit code. Had a look on MSDN and I can see that in WPF the Application has a Shutdown method which takes an error code as a parameter, but there doesn't appear to be one for System.Windows.Forms.Application.</p>
<p>I can see Application.Exit() but no... | <p>You can use System.Environment.Exit(yourExitCode).</p>
| <p>set the ExitCode property in the System.Environment class and when exitting. e.g.</p>
<pre><code>System.Environment.ExitCode = 1
Application.Exit()
</code></pre>
| 30,063 |
<p>I'm using Hibernate for a Java-based Web Application and want to add full-text search via Compass. Compass is supposed to support that, but fails to provide any useful Getting Started guide.</p>
<p>I could figure out that I have to annotate my Entities with @Searchable and the various @SearchableXXX variations and ... | <p>I'm wondering why you chose Compass to go Hibernate. We looked at Compass and Hibernate-Search and we chose the latter as it has excellent integration.</p>
<p>You can query the test index in exactly the same way you do an SQL database with HQL or Critera.</p>
<p>If you were using iBatis or JDBC then Compass would... | <p>The best resource to review would be to check the petclinic example provided with the compass distribution (with dependencies). If by default the listener is not configured then you will have to set the EventListener.</p>
| 32,761 |
<p>Throughout or C# sourcecode we have a lot of comments that miss the actual content such like this:</p>
<pre><code>/// <summary>
/// </summary>
</code></pre>
<p>or this:</p>
<pre><code>/// <summary>
///
/// </summary>
</code></pre>
<p>or this:</p>
<pre><code>/// <param Name="flag">&... | <p>ReSharper is the answer to this (as many other) shortcoming of Visual Studio. I have nothing but pity for anyone who does not use it. ;)</p>
| <p>You can use an XSLT file and debug the xml against the XSLT file and then it will throw error if the xml is not well formed showing you the exact line number against which the xml is not well formed.
This simple XSLT file works-</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version=... | 33,151 |
<p>I just can't remember the terminology used for this and other related properties.</p>
<p>EDIT - Maybe such a concept doesn't exist but I remember reading something in Effective C++ (or More Effective C++) where he advocated using swaps to commit changes last in the function because the vector swap functions were gu... | <p>I think you mean to say that the function is "exception-safe". See e.g. <a href="http://en.wikipedia.org/wiki/Exception_safety" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Exception_safety</a>.</p>
<p>The Wikipedia article further divides the safety into various levels. This is the one that is relevant h... | <p>Having read your edit, I suspect your title is slightly incorrect. Do you really mean it has no side effects <em>whether or not an exception is thrown</em> (as per the current wording) or that it has no side effects when an exception is thrown, but if the method completes without throwing an exception then it will/c... | 35,945 |
<p>This is a perennial question for me that I've never really resolved so I'd like your input. If I have actions that I know a user will not be able to perform due to insufficient privileges or object state, should the UI elements for those actions be hidden from the user, visible but disabled, or visible and result i... | <p>Hidden - This is the best approach for actions that are never available to the current user. There is no point in having the user waste mental effort figuring out why something is disabled if there is no action they can take to change this. </p>
<p>Disabled - This is the best approach for actions that are sometime... | <p>I have a particular hatred of applications that disable buttons. If you're an end user - you want to know why you can't use that button. Having it greyed out doesn't tell you anything. How do you get to the state to enable it? Tooltips are one solution, but they aren't the best, a lot of users will struggle with too... | 48,611 |
<p>I would like to add a backcolor for specific line depending of a Property of the object binded.</p>
<p>The solution I have (and it works) is to use the Event <code>DataBindingComplete</code> but I do not think it's the best solution.</p>
<p>Here is the event:</p>
<pre><code> private void myGrid_DataBindingComp... | <p>You can also attach an event handler to RowPostPaint:</p>
<pre><code>dataGridView1.RowPostPaint += OnRowPostPaint;
void OnRowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
MyObject value = (MyObject) dataGridView1.Rows[e.RowIndex].DataBoundItem;
DataGridViewCellStyle style = dataGridView1.... | <p>I don't really work with WinForms that much, but in ASP you would use the 'ItemDataBound' method. Is there something similar in windows forms for a DataGrid?</p>
<p>If so, in that method, the event arguments would contain the item that was databound, along with the DataGrid row. So the general code would look som... | 36,085 |
<p>When looking at the myriad types of software written at our company, I instantly jump to conclusions of the quality of the entire product based on the UI. If I find misspellings, weird tab orders, fields not lined up, odd colors, I assume that the entire application is of poor quality.</p>
<p>I'm assuming that if ... | <p>I think it's a good indicator of the care that a developer has for their work - basically a sense of professional pride. </p>
<p>It's a given that most devs don't make fantastic UI designers, but there are a basic set of rules that should be followed when developing professional software and these apply as much to ... | <p>In my opinion it is a valid decision. And you are right when you say that good looking software is not necessarily good software internally.</p>
<p>But definitely, if the programmers don't care about the usability of the program, most likely they won't care about it's functionality.</p>
| 38,569 |
<p>I would like to have a single DatagramSocket to listen for both unicast and broadcast messages. Is this possible?</p>
| <p>Broadcasting is, by definition, a <em>transmission</em> function.</p>
<p>If your UDP socket is listening on a particular port and bound to <code>INADDR_ANY</code> (aka 0.0.0.0) then it'll receive all packets sent to that port, regardless of whether they were sent to the local machine's specific IP addresses (i.e. u... | <p>I think if you set the address to 0.0.0.0, it'll do the work.</p>
| 44,896 |
<p>How do I check if a number is a palindrome?</p>
<p>Any language. Any algorithm. (except the algorithm of making the number a string and then reversing the string).</p>
| <p>This is <a href="http://projecteuler.net/index.php?section=problems&id=4" rel="noreferrer">one of the Project Euler problems</a>. When I solved it in Haskell I did exactly what you suggest, convert the number to a String. It's then trivial to check that the string is a pallindrome. If it performs well enough,... | <p>One line python code : </p>
<pre><code>def isPalindrome(number):
return True if str(number) == ''.join(reversed(str(number))) else False
</code></pre>
| 24,284 |
<p>Intel's <a href="http://www.threadingbuildingblocks.org/" rel="noreferrer">Threading Building Blocks (TBB)</a> open source library looks really interesting. Even though there's even an <a href="http://oreilly.com/catalog/9780596514808/" rel="noreferrer">O'Reilly Book</a> about the subject I don't hear about a lot o... | <p>I've introduced it into our code base because we needed a bettor malloc to use when we moved to a 16 core machine. With 8 and under it wasn't a significant issue. It has worked well for us. We plan on using the fine grained concurrent containers next. Ideally we can make use of the real meat of the product, but that... | <p>Have you looked at <a href="http://www.boost.org/" rel="nofollow noreferrer">boost</a> library with its <a href="http://www.boost.org/doc/libs/1_36_0/doc/html/thread.html" rel="nofollow noreferrer">thread API</a>? </p>
| 13,243 |
<p>I'm new to regular expressions and would appreciate your help. I'm trying to put together an expression that will split the example string using all spaces that are not surrounded by single or double quotes. My last attempt looks like this: <code>(?!")</code> and isn't quite working. It's splitting on the space bef... | <p>I don't understand why all the others are proposing such complex regular expressions or such long code. Essentially, you want to grab two kinds of things from your string: sequences of characters that aren't spaces or quotes, and sequences of characters that begin and end with a quote, with no quotes in between, fo... | <p>I'm reasonably certain this is not possible using regular expressions alone. Checking whether something is contained inside some other tag is a parsing operation. This seems like the same problem as trying to parse XML with a regex -- it can't be done correctly. You may be able to get your desired outcome by repe... | 47,802 |
<p>I have a winforms projects and we use the command pattern. We are trying to clean up our directory structure and make it consistent.</p>
<p>We are trying to decide if we should have a root commands folder or not. What do you think is better for a directory structure?</p>
<p>Project<br>
--Commands<br>
----AddComma... | <p>It seems like the general question is whether you want to categorize by actions/verbs (i.e. a Commands folder) or by targets/nouns (folders for Database, Calculation, etc). Whichever route you take, you might try to be consistent (take the same approach with Views and Widgets as you do with Commands, etc).</p>
<p>A... | <p>Personally I like the second option but I think that you could also do something like this:</p>
<pre><code>Project
-Commands
--Calculation
----AddCommand
----SubtractCommand
--Database
----InsertCommand
----DeleteCommand
</code></pre>
<p>Just my 2 cents</p>
| 37,599 |
<p><a href="http://img440.imageshack.us/img440/6950/problemyd1.png" rel="nofollow noreferrer">alt text http://img440.imageshack.us/img440/6950/problemyd1.png</a></p>
<p>(The curly lines with dots represent a network route.)</p>
<p>Having a process called "foo.exe", is there a way to forward everything it communicates... | <p>It's not too hard if you make your own computer a firewall, then your app connects to a port on your own computer, and that port is forwarded to both the original destination and logged or forwarded on to your spying computer.</p>
<p>Alternatively you can make your other computer the firwall and have it log/forward... | <p>You could hook into the TCP stack, for example, by using the Windows Filtering Platform or its predecessors, or you could substitute the network libraries/calls of that particular process.</p>
| 19,916 |
<p>I'm writing a J2ME application. One of the pieces is something that polls the contents of a directory periodically, and, if there are any new things, paints them on the screen. I've done this by having the UI form launch a polling thread with a pointer back to itself, and when the polling thread finds something it... | <p>Regarding Java, what you are describing looks like a <a href="http://java.sun.com/docs/books/tutorial/uiswing/concurrency/worker.html" rel="nofollow noreferrer">SwingWorker (worker thread)</a>.</p>
<p>When a Swing program needs to execute a long-running task, it usually uses one of the worker threads, also known as... | <p>For j2me apps you probably want to keep it simple. The main thing is to touch UI components only in the event thread. The direct way of doing this is to use <a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/SwingUtilities.html" rel="nofollow noreferrer">invokeLater or invokeAndWait</a>. Depending on your ... | 37,335 |
<p>We're running a java/hibernate app going against ORACLE 10g in TESTING. Once in a while, we're seeing this error:</p>
<blockquote>
<p>ORA-00942: table or view does not exist</p>
</blockquote>
<p>Is there a way to find out which table/view(s) ORACLE is talking about ?</p>
<p>I know that I can add extra levels of... | <p>Take a look into the DBA_AUDIT_EXISTS table, when auditing is turned on for Oracle. I believe that Oracle can provide very detailed auditing which you can simply toggle on and off when you like via DB commands, although I dont remember what they are off the top of my head.</p>
<p>See:
<a href="http://docs.oracle.co... | <p>I don't think there is a magic bullet here.
It may be a missing table, or a misspelled table name in the query.
It may be a privilege issue. You can't really tell without executing the query</p>
<p>I suggest you go ahead and instrument your code in such a way that you can turn it on and off. Run it, extract the ... | 22,996 |
<p>I have an Enum like this</p>
<pre><code>package com.example;
public enum CoverageEnum {
COUNTRY,
REGIONAL,
COUNTY
}
</code></pre>
<p>I would like to iterate over these constants in JSP without using scriptlet code. I know I can do it with scriptlet code like this:</p>
<pre><code><c:forEach var="t... | <p>If you are using Tag Libraries you could encapsulate the code within an EL function. So the opening tag would become:</p>
<pre><code><c:forEach var="type" items="${myprefix:getValues()}">
</code></pre>
<p>EDIT: In response to discussion about an implementation that would work for multiple Enum types just ske... | <p>If you are using Tag Libraries you could encapsulate the code within an EL function. So the opening tag would become:</p>
<pre><code><c:forEach var="type" items="${myprefix:getValues()}">
</code></pre>
<p>EDIT: In response to discussion about an implementation that would work for multiple Enum types just ske... | 17,114 |
<p>In almost all projects, the choice of the database system is 'almost' automatic .. if you're coding "in the Microsoft stack" you'll go with SQLServer, in the Linux world the default is MySQL, and for corporate in-house project most shops have decided on some default like Oracle or IBM DB2.</p>
<p>What are your thou... | <p>My customers often stipulate what database engine we will be using. We write .net apps against non-SQLServer dbs regularly. In the long run, it's better for the customer because they get to maintain what they know.</p>
| <p>I work on a gov contract, and while we code in the "Microsoft Stack", we can't use SQL Server because the government gets Oracle for free and wants us to use that instead.</p>
| 20,807 |
<p>How do you set your Cocoa application as the default web browser?</p>
<p>I want to create an application that is launched by default when the user clicks on an HTTP or HTTPS link in other applications (Mail, iChat etc.).</p>
| <p>There are four steps to making an app that can act as the default web browser. The first three steps allow your app to act as a role handler for the relevant URL schemes (HTTP and HTTPS) and the final step makes it the default role handler for those schemes.</p>
<p><strong>1) Add the URL schemes your app can handle... | <p>In order to appear as an option on <code>System Preferences > General > Default web browser</code> (at least for macOS 11) you need to add the document types for <strong>HTML</strong> and <strong>XHTML</strong> to the <em>Info.plist</em> (after the 4 steps already described on the <a href="https://stackoverflo... | 7,212 |
<p>For both .NET Winforms and Windows Presentation Foundation, if I have a text box that the user has just entered text into, and a button, if the user clicks the button the "LostFocus" event fires before the button click event fires. However if the user uses a keyboard shortcut for the button (e.g. Button's text is "... | <p>You could try tracking whether or not the lost focus logic has occured before firing the button logic. You shouldn't really have code directly in the handler anyway. You could do something like this:</p>
<pre><code>public partial class Form1 : Form
{
private Boolean _didLostFocusLogic;
public F... | <p>What would happen if you did this first of all in the button handler? (or perhaps subclass the button and override OnClick to apply this logic "worldwide").</p>
<pre><code>Button b = (Button) sender;
b.Focus();
</code></pre>
<p>Would that get round the issue?</p>
| 37,045 |
<p>I need to get a log of user access to our <code>SQL Server</code> so I can track <strong>average</strong> and <strong>peak concurrency usage</strong>. Is there a hidden table or something I'm missing that has this information for me? To my knowledge the application I'm looking at does not track this at the applicati... | <p>In SQL Server 2005, go to tree view on the left and select Server (name of the actual server) > Management > Activity Monitor. Hope this helps.</p>
| <ul>
<li>on <code>2000</code> you can use <code>sp_who2</code> or the <code>dbo.sysprocesses</code> system table</li>
<li>on <code>2005</code> take a look at the <code>sys.dm_exec_sessions</code> DMV</li>
</ul>
<p>Below is an example</p>
<pre><code>SELECT COUNT(*) AS StatusCount,CASE status
WHEN 'Running' THEN 'Runn... | 2,777 |
<p>It seems like Microsoft had a great idea with the ObservableCollection. They are great for binding, and are super fast on the UI.</p>
<p>However, requiring a context switch to the Dispatcher Thread every time you want to tweak it seems like a bit much. Does anyone know the best practices for using them? Is it si... | <p>Is updating the ObservableCollection on the UI thread really causing that much of a bottleneck for your application? If not, stick with updating it on the UI thread. Remember, it's not really a context switch that's happening when you run something with the Dispatcher - instead, you're simply submitting a job to the... | <p>You can use good old <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="nofollow noreferrer">BackgroundWorker</a> also in WPF (as in Windows Forms). It will adopt to the threading model of WPF and also provide a nice abstraction.</p>
| 24,254 |
<p><strong>I have class A:</strong></p>
<pre><code>public class ClassA<T>
</code></pre>
<p><strong>Class B derives from A:</strong></p>
<pre><code>public class ClassB : ClassA<ClassB>
</code></pre>
<p><strong>Class C derives from class B:</strong></p>
<pre><code>public class ClassC : ClassB
</code></pr... | <p>Well, you could change Method to:</p>
<pre><code>public static T Method<T,U>() where T : ClassA<U> where U : T
</code></pre>
<p>Does that help at all? It's not much use if you can't change Method of course...</p>
| <p>In most cases it is possible to solve this scenario by having a base non-generic abstract class:</p>
<pre><code>public abstract class BasicClassA
{
}
public class ClassA<T> : BasicClassA
{
}
public class ClassB : ClassA<ClassB>
{
}
public class ClassC : ClassB
{
}
public static T Method<T>() w... | 28,882 |
<p>I have PLA and PETG filament.</p>
<p>I hear that 3D filament absorbs water and causes problems when printing but after printing they can be used with water and they are water proof.</p>
<p>So my question is why is it different after printing/what has changed to make it now waterproof?</p>
<ul>
<li><p>Is PETG waterpr... | <p>Filament that absorbs water prior to printing is subject to boiling temperatures as it passes through the heater block. In extreme cases, steam will be visible and a spitting sound will be heard. The filament will expand as the water exits, causing multiple structural and printing problems.</p>
<p>Once printed, dry ... | <p>Filament that absorbs water prior to printing is subject to boiling temperatures as it passes through the heater block. In extreme cases, steam will be visible and a spitting sound will be heard. The filament will expand as the water exits, causing multiple structural and printing problems.</p>
<p>Once printed, dry ... | 1,861 |
<p>I have a website with members who message each other. There are getting to be a few members and they like to send messages - I'm sure you can see where this is going.</p>
<p>Currently I have said messages stored in a nicely relational table cunningly titled "messages" with different status ids to denote, er, status... | <p>I would definately split the 'messages' table into multiple. Eg:</p>
<p>MessageStatus
Message
MessageText</p>
<p>This way if your displaying a list of items in someone inbox, you only need to scan the 'Message' table which is smaller and fixed length columns for max seek speed. When someone wants to open and see... | <p>Have you thought of possibly having an archive process that would archive anything older then a certain period of time?</p>
<p>With proper indexing and fine tuning you would have to have quite a few messages to require moving them across multiple tables, unless its a issue with space.</p>
| 41,795 |
<p>It's getting close to the time when I need to submit training and travel requests. I'm looking for conferences and classes in the coming 12 months that are geared toward improving coding and software development, best practices, system architecture, etc. They need to be in the US or Canada since I'll never get appro... | <p>If you are using Microsoft technologies, the <a href="http://www.pnpsummit.com/" rel="nofollow noreferrer">patterns & practices Summit</a> is a good event -- if you are not working pretty much 100% in the Microsoft .NET space, though, it would be of less use.</p>
| <p><a href="http://infoq.com/" rel="nofollow noreferrer">InfoQ</a>'s conferences seem to be valuable. Some parts of their materials is available online.</p>
| 7,842 |
<p>What is the maximum length for the text string contained in a CEdit control in MFC? I get a beep when trying to add a character after the character 30001 is this documented anywhere? Can I display longer texts in a CEdit? Should I use another control?</p>
<p>As "Windows programmer" says down below, the text length ... | <p>I found the documentation is wrong when mentioning the default size for a single line CEdit control in vista.</p>
<p>I ran this code:</p>
<pre><code>CWnd* pWnd = dlg.GetDlgItem(nItemId);
CEdit *edit = static_cast<CEdit*>(pWnd); //dynamic_cast does not work
if(edit != 0)
{
UINT limit = edit->GetLimitTe... | <p>"(in characters it can display)" != "when trying to add a character".</p>
<p>"when trying to add a character" == "The maximum number of TCHARs the user can enter"
unless you mean programmatically trying to add a character.</p>
<p>"0x7FFFFFFE characters" != "0x7FFFFFFE bytes"
except sometimes, a fact which the quot... | 21,818 |
<p>I have an asp.net application that runs exclusively on IE7 (internal web site).</p>
<p>When a user needs to enter data, I pop up a child window with a form. When the form closes, it calls javascript:window.opener.location.reload(true) so that the new data will display on the main page.</p>
<p>The problem is that t... | <p>No, but there is a solution. Its generally considered good design to use a 302 redirect immediately after someone posts data to a page. This prevents that popup from ever occuring. Allow me to elaborate.</p>
<p>1) The user fills in a form and submits data via POST.</p>
<p>2) The backend receives the data and acts ... | <p>I do not believe that there is a way to do that. Instead, why not direct the parent window to a page without a reload.</p>
<p>javascript:window.opener.location='your url'</p>
| 11,930 |
<p>Assuming a map where you want to preserve existing entries. 20% of the time, the entry you are inserting is new data. Is there an advantage to doing std::map::find then std::map::insert using that returned iterator? Or is it quicker to attempt the insert and then act based on whether or not the iterator indicates ... | <p>The answer is you do neither. Instead you want to do something suggested by Item 24 of <a href="https://rads.stackoverflow.com/amzn/click/com/0201749629" rel="noreferrer" rel="nofollow noreferrer">Effective STL</a> by <a href="http://www.aristeia.com/" rel="noreferrer">Scott Meyers</a>:</p>
<pre><code>typedef map&... | <p>map[ key ] - let stl sort it out. That's communicating your intention most effectively.</p>
<p>Yeah, fair enough. </p>
<p>If you do a find and then an insert you're performing 2 x O(log N) when you get a miss as the find only lets you know if you need to insert not where the insert should go (lower_bound might h... | 12,252 |
<p>I am using Visual Studio 2008 SP1 (version 9.0.30729.1). My problem is that the only reporting-related toolbox items I see are 3 "Textbox" controls. Where are the other stuff? Do I need to add a reference to a different assembly?</p>
<p>Here are the steps I take:<br>
1) Open Visual Studio<br>
2) Add new proje... | <p>My good sense tells me that something got corrupted in your installation.</p>
<p>Here's what I would try before attempting a repair (this happened recently):</p>
<p>I fixed this by going into my profile as follows:</p>
<p>C:\Documents and Settings\MYUSERNAME\Local Settings\Application Data\Microsoft\VisualStudio\... | <p>Here is a book reference available through Google Books: <a href="http://books.google.com/books?id=b9j0MKXhnygC&pg=PA419&lpg=PA419&dq=vs+2008+Reports+Application+toolbox&source=web&ots=awTO1ibUZH&sig=7iHAUSCZ46_uAjC5lAfLeiXZt_Q&hl=en&sa=X&oi=book_result&resnum=7&ct=result#... | 27,484 |
<p>I have a set of tree objects with a depth somewhere in the 20s. Each of the nodes in this tree needs access to its tree's root.</p>
<p>A couple of solutions:</p>
<ol>
<li>Each node can store a reference to the root directly (wastes memory)
<ul>
<li>I can compute the root at runtime by "going up" (wastes cycles)<... | <p>Pass the root as a parameter to whichever functions in the node that need it.</p>
<p>Edit: The options are really the following:</p>
<ol>
<li>Store the root reference in the node</li>
<li>Don't store the root reference at all</li>
<li>Store the root reference in a global</li>
<li>Store the root reference on the st... | <p>You could derive a class from TreeView and then add a singleton static property. That way you are effectively adding a global field that references the single instance of the class but have the benefit of it being namespace scoped to that class.</p>
| 9,366 |
<p>Recently I worked on FindBugs warnings about exposing internal state, i.e. when a reference to an array was returned instead of returning a copy of the array. I created some templates to make converting that code easier.</p>
<p>Which one did you create to support defensive programming and want to share with the SO ... | <p>I like having as a template a "safer" equals() definition:</p>
<pre><code> /**
* Implement equals based on ${cursor}. <br />
* See {@link #compareTo(Object) compareTo}
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(final Object anObject)
{
boolean res = false;
i... | <p>Not a template, but I use <code>array.clone()</code> instead of <code>System.arraycopy()</code>. Is there anything wrong with that?</p>
<p>Edit:
A template I use when implementing a decorator, especially for an interface with many methods:</p>
<pre><code>wrapped.${enclosing_method}(${enclosing_method_arguments})
<... | 48,956 |
<p>A researcher has created a small simulation in MATLAB and we want to make it accessible to others. My plan is to take the simulation, clean up a few things and turn it into a set of functions. Then I plan to compile it into a C library and use <a href="https://en.wikipedia.org/wiki/SWIG" rel="nofollow noreferrer">SW... | <p>I remember that I was able to wrap a MATLAB simulation into a <a href="https://en.wikipedia.org/wiki/Dynamic-link_library" rel="nofollow noreferrer">DLL file</a> and then call it from a <a href="https://en.wikipedia.org/wiki/Embarcadero_Delphi" rel="nofollow noreferrer">Delphi</a> application. It worked really well.... | <p>Perhaps try <a href="http://python.net/crew/theller/ctypes/" rel="nofollow noreferrer">ctypes </a>instead of SWIG. If it has been included as a part of Python 2.5, then it must be good :-)</p>
| 2,712 |
<p>Should my program support IA64, or should it only support x64?</p>
<p>I haven't been able to easily find IA64 computers myself. Is IA64 dead?</p>
<p>MS seems to have a wide support for IA64, but it took me a long time to be able to find an IA64, and I had to end up getting it on eBay.</p>
| <p>What kind of software do you develop? If it's not a data center type of application or a high-end number crunching app, I'd be surprised if there were any demand for an ia64 version. And even then, I'd think it would be a situation where if you have to ask if you should support it, you probably don't need to.</p>
... | <p>If you're writing in C++, does it really matter? What I mean is, you don't say what makes your program "need to know" about the underlying architecture of the machine it is running on. From C++ itself, you should be fairly well protected against any differences between the two. Of course, testing on an esoteric plat... | 27,211 |
<p><em>An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)</e... | <blockquote>
<p>The only thing that I'm suspicious on is that the server has two Database engines: SERVER and server\sqlexpress</p>
</blockquote>
<p>I think this is the source of the problem. Which one do you intend to connect to? You need to specify the "instance" you are connecting to.</p>
<p>Assuming you inten... | <p>Can you connect to the SQL Server via Management Studio from a different machine? This might help you narrow down whether it is the SQL Server configuration or you connection string configuration.</p>
| 8,929 |
<p>After installing VS2005 VB6 lost F1 function to MSDN Oct/2001 lib. </p>
<p>Suggestions to re-install MSDN did not work. </p>
<p>The only thing F1 works on now are ADO statements in VB6. Example ado1.recordset.recordcount If I highlight recordcount and press F1 I do get the ADO help information. If I highlight "re... | <p>This happened to me once. The only thing I could do to fix it was a complete re-install of VB6 (wasn't caused by installing VS2005, but installing a component that added its own doc to Help). Probably not what you want to hear.</p>
| <p>Something similar happened to me, trying to compile a vb6 dll wasn't working.
Turns out that an update had been installed in the background and i needed to reboot before it would allow me to compile it again.</p>
| 12,277 |
<p>I am in the process of writing a Bluetooth scanner that locates and identifies mobile devices in the local vicinity. Is this something that I can accomplish using C#, or do I need to drop down into the C/C++ APIs? My application is targeting Windows XP and Vista. Pointers are appreciated.</p>
<p>Thanks!</p>
| <p>One problem with Bluetooth on the PC is that there are several BT stacks in use and you can never quite know which one is available on a given machine. The most common ones are Widcomm (now Broadcom) and Microsoft (appeared in XP, maybe one of the service packs). However, some BT hardware vendors package BlueSoleil ... | <p><a href="http://www.btframework.com/" rel="nofollow noreferrer">Mike Petrichenko</a> has a nice BT framework. It works with BlueSoleil, Widcomm, Toshiba and Microsoft.</p>
<p>It is now called the Wireless Communications Library and works with Bluetooth 802.11 and Infrared. Mike named the company Soft Service Company... | 17,469 |
<p>I have an object, that is facing a particular direction with (for instance) a 45 degree field of view, and a limit view range. I have done all the initial checks (Quadtree node, and distance), but now I need to check if a particular object is within that view cone, (In this case to decide only to follow that object ... | <p>Compute the angle between your view direction (understood as a vector) and the vector that starts at you and ends at the object. If it falls under FieldOfView/2, you can view the object.</p>
<p>That angle is: </p>
<pre><code>arccos(scalarProduct(viewDirection, (object - you)) / (norm(viewDirection)*norm(object - y... | <p>If you're doing 3D and can define the viewing range as a frustrum, then you can use something similar to this <a href="http://www.flipcode.com/archives/Frustum_Culling.shtml" rel="nofollow noreferrer">Frustrum Culling</a> technique.</p>
| 24,931 |
<p>Check out this test:</p>
<pre><code>[TestFixture]
public class Quick_test
{
[Test]
public void Test()
{
Assert.AreEqual(0, GetByYield().Count());
Assert.AreEqual(0, GetByEnumerable().Count());
}
private IEnumerable<string> GetByYield()
{
yield break;
}
private IEnum... | <p>I would prefer any method that delivers the clearest meaning to the developer. Personally, I don't even know what the <strong><em>yield break;</em></strong> line is does, so returning 'Enumerable.Empty();` would be preferred in any of my code bases.</p>
| <p>Even faster might be:</p>
<pre><code>T[] e = {};
return e;
</code></pre>
| 44,911 |
<p>We are about to start a new part of the project and there doesn't seem to be a lot of interest in unit testing (and it doesn't feel like they have experienced TDD). I believe it's nearly essential and it makes maintainance much easier.
So what are your views?</p>
<p>Thanks</p>
<p>BTW: this is a language agnostic q... | <p>Absolutely unit testing is used on our projects. Every class that isn't brainless getters and setters is unit-tested. Having functional tests for you code enables you to refactor at will without worrying that you'll break 50 different things at once.</p>
<p>Another underrated aspect of unit testing is that it bring... | <p>I'm interested in doing it, but not sure how to start doing it with the large projects I end up joining part way through... Haven't been involved in a real fresh start of a project since back in 1996!</p>
| 26,028 |
<p>Is there any class in the .NET framework that can read/write standard .ini files:</p>
<pre><code>[Section]
<keyname>=<value>
...
</code></pre>
<p>Delphi has the <code>TIniFile</code> component and I want to know if there is anything similar for C#? </p>
| <p>The creators of the .NET framework want you to use XML-based config files, rather than INI files. So no, there is no built-in mechanism for reading them.</p>
<p>There are third party solutions available, though.</p>
<ul>
<li>INI handlers can be obtained as <a href="https://www.nuget.org/packages?q=ini" rel="norefe... | <p>You should read and write data from xml files since you can save a whole object to xml and also you can populate a object from a saved xml. It is better an easy to manipulate objects.</p>
<p>Here is how to do it:
Write Object Data to an XML File: <a href="https://msdn.microsoft.com/en-us/library/ms172873.aspx" rel=... | 26,789 |
<p>I use <code>_vimrc</code> to configure my vim 7.2 (windows) default settings. One setting "set number" will display line numbers on the left side. My vim background color is white (I cannot find setting for this. Maybe the default is white. Anyway I accept this setting).</p>
<p>I would like the background color for... | <pre class="lang-vim prettyprint-override"><code>highlight LineNr ctermfg=grey ctermbg=white
</code></pre>
| <p>In my <code>_vimrc</code>, here is the setting:</p>
<pre><code>highlight LineNr guibg=grey
</code></pre>
<p>or</p>
<pre><code>hi LineNr guibg=grey
</code></pre>
<p>I don't need to set fore-color, the default is yellow and it is OK for me.</p>
| 31,193 |
<p>I’ve a Flashforge Adventurer 3 which I’ve found to be a fantastic out of the box ready to go printer. I’ve clocked up 500 hours on it.</p>
<p>I’ve had issues where the nozzle was too close to the print bed, making it impossible for the extruder wheel to force filament down the bowden tube. With harder filaments that... | <p>Nozzles do degrade with use. That is why they're made to be easily replaceable.</p>
<p>Your problem may be a worn nozzle or incomplete cleaning or something with the bowden tube etc,. but an easy troubleshooting step is just to replace the nozzle.</p>
| <p>I have had this happen at times. I finally got it to go away once I fixed my bed adhesion.</p>
<p>By chance is your print curling up near the edges? If it's popping up and exerting backpressure on the extruder, that can be enough to cause an internal jam and the extruder "clicking" (which is itself just a ... | 2,179 |
<p>I have been reading the post here:</p>
<p><a href="http://encosia.com/2008/10/04/using-jquery-to-enhance-aspnet-ajax-progress-indication/" rel="nofollow noreferrer">http://encosia.com/2008/10/04/using-jquery-to-enhance-aspnet-ajax-progress-indication/</a></p>
<p>But it wants to use the following object:</p>
<pre>... | <p>NO. numerical primary keys will not reused, except you specify them manually(you should really avoid this!)</p>
| <p>Yeah, it really depends on the way you generate the id.</p>
<p>For example if you are using a GUID as the primary key, most implementations of getting a random new Guid are not likely to pick another guid again, but it will given enough time and if the Guid is not in the table the insert statement will go fine, bu... | 31,605 |
<p>I've had significant success with NSURL, NSURL[Mutable]Request, NSURLConnection with my iPhone applications. When trying to compile a stand alone Cocoa application, 10 line program to make a simple HTTP request, there are zero compiler errors or warnings. The program compiles fine, yet the HTTP Request is never made... | <p>The other poster pretty much answered this for you, but I thought I would just add a few things.</p>
<p>First, you don't really need to link to Cocoa for this, just linking to the Foundation framework is okay. Also, since you don't need a connection to the Window Server, you can get rid of the [NSApplication shared... | <p><code>NSURLConnection</code> is an asynchronous API that relies upon <code>NSRunLoop</code>. Your posted code never creates a run loop for the connection to run in. Therefore, I presume Cocoa is unable to create the connection and so returns nil. Things to look into:</p>
<p>1) Anything in the console? Is <code>NSUR... | 33,504 |
<p>I have seen recent updates in term of record sets being updated so that we can scroll back and forth through the data it points to.</p>
<p>Why they were initially designed for a forward only traversal. Is there any impact using the new version?</p>
| <p>"new version" is about 5 years old.</p>
<p>forward only : it is the easiest way to implement. It is easiest to implement a Queue(FIFO) rather than a deque or linked list. Since the JDBC driver has to read the record from the DB, it can make them EASILY available to the ResultSet reader FIRST COME FIRST SERVE.</p>
... | <p>Packing too many features in to the first version of JDBC would have slowed down the adoption of JDBC, since the vendors would have taken longer to implement it. </p>
<p>Scrollable result sets is a relatively rarely used feature in JDBC, so it wasn't essential to have it there from day one. The same applies to the ... | 21,372 |
<p>I'm trying to display a series of titles varying from 60 characters to 160 or so and the capitalization varies, some of it all caps, some half caps. When it's mostly lowercase the whole 160 characters of text fits in the width I want, but when it starts getting more caps (they must be wider), it starts over flowing... | <p><strong>Control the Overflow</strong></p>
<p>The real trick is just setting a limit on size of the text box, and making sure that there aren't overflow problems. You can use overflow: hidden to take care of this, and display: block the element in order to give it the exact dimensions you need.</p>
<p><strong>Mono... | <p>You could try using javascript to programmatically test to see the width of the font, and if it's too large, take it down a step and try again. Instead of testing the width, see if the height of the element is more than one line (measured in ems, since you'll be changing the font size around).</p>
<pre><code>var fo... | 20,398 |
<p><em>Situation: Some Bank has an old legacy ABS (Automatic bank system).</em> </p>
<p>Bank wants to:</p>
<ol>
<li>notify old legacy CRM system about client's account changes (Publish operation).</li>
<li>check PIN codes of client cards (Request/Response operation) - in synchronious mode.</li>
</ol>
<p>ABS is imple... | <p>Lot of vendors hype about DataServices. I think the most value of these products is when integrating different datasources.</p>
<p>I would consider making a simple "application" that exposes this data as a service</p>
| <p>I can propose you to use Mule as ESB in your bank (see also <a href="http://www.mulesource.org/display/MULE/Home" rel="nofollow noreferrer">http://www.mulesource.org/display/MULE/Home</a>).</p>
<p>It allows you to communicate to database directly (jdbc level which has to be OK with stored procedures as well as tabl... | 21,986 |
<p>I would like to test a string containing a path to a file for existence of that file (something like the <code>-e</code> test in Perl or the <code>os.path.exists()</code> in Python) in C#.</p>
| <p>Use:</p>
<pre><code>File.Exists(path)
</code></pre>
<p>MSDN: <a href="http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx</a></p>
<p>Edit: In System.IO</p>
| <p>I use WinForms and my way to use File.Exists(string path) is the next one:</p>
<pre><code>public bool FileExists(string fileName)
{
var workingDirectory = Environment.CurrentDirectory;
var file = $"{workingDirectory}\{fileName}";
return File.Exists(file);
}
</code></pre>
<p>fileName <strong>mus... | 5,998 |
<p>I'm in the process of weeding out all hardcoded values in a Java library and was wondering what framework would be the best (in terms of zero- or close-to-zero configuration) to handle run-time configuration? I would prefer XML-based configuration files, but it's not essential. </p>
<p>Please do only reply if you h... | <p>If your hardcoded values are just simple key-value pairs, you should look at <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html" rel="noreferrer">java.util.Properties</a>. It's a lot simpler than xml, easier to use, and mind-numbingly trivial to implement.</p>
<p>If you are working with Jav... | <p>Properties files a very simple, if you need something more functional, you could format some of your configuration files as Java classes. These can be placed in a different package/module and can be pre-compiled or loaded at runtime with a library like BeanShell.</p>
<p>Note: In the simplest case (pre-compiled) yo... | 4,535 |
<p>I'm developing an application with Adobe Flex and AIR, and I've been banging my head against the wall trying to figure out how to solve a scrolling issue.</p>
<p>The basic structure of my main application window (simplified greatly) is this:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<mx:Window... | <p>An HBox or a VBox will try as hard as possible to display its content without scroll bars. This forces a parent container (often all the way up to the main Application) to be the one that must scroll if the content is too large to fit in the available bounds.</p>
<p>Behind the scenes, the HBox or VBox is setting th... | <p>Your problem seems like a lot like one that I struggled with some time ago. I found my answer from <a href="http://www.nabble.com/-flex_india%3A3318--Size-layout-issues-with-respect-to-parent-containers-tc12882767.html" rel="nofollow noreferrer">this discussion</a>: just disable the <code>measure()</code> implementa... | 46,234 |
<p>I am looking for a tool like <a href="http://linux.die.net/man/1/ltrace" rel="noreferrer">ltrace</a> or <a href="http://linux.die.net/man/1/strace" rel="noreferrer">strace</a> that can trace locally defined functions in an executable. ltrace only traces dynamic library calls and strace only traces system calls. Fo... | <p>Assuming you only want to be notified for specific functions, you can do it like this:</p>
<p>compile with debug informations (as you already have symbol informations, you probably also have enough debugs in)</p>
<p>given</p>
<pre><code>#include <iostream>
int fac(int n) {
if(n == 0)
return 1;
... | <p>Hopefully the <a href="http://valgrind.org/info/tools.html" rel="nofollow noreferrer">callgrind or cachegrind tools</a> for <a href="http://valgrind.org/" rel="nofollow noreferrer">Valgrind</a> will give you the information you seek.</p>
| 40,186 |
<p>I read the following in a review of Knuth's "The Art of Computer Programming":</p>
<p>"The very 'practicality' means that the would-be CS major has to learn Kernighan's mistakes in designing C, notably the infamous fact that a for loop evaluates the for condition repeatedly, which duplicates while and fails to matc... | <p>Consider this:</p>
<pre><code>for i:=0 to 100 do { ... }
</code></pre>
<p>In this case, we could replace the final value, 100, by a function call:</p>
<pre><code>for i:=0 to final_value() do { ... }
</code></pre>
<p>... and the <code>final_value</code>-function would be called only once.</p>
<p>In C, however:</... | <p>Maybe Knuth is referring to BASIC. </p>
<p>In BASIC (the older one, I dont know about VB), FOR loops were implemented differently. </p>
<p>E.g. to loop ten times</p>
<p>FOR N=1 TO 10</p>
<p>... </p>
<p>NEXT N</p>
<p>---- OR ----
to find sum of even numbers below 100</p>
<p>FOR N=0 TO 100 STEP 2</p>
<p>...</... | 28,433 |
<p>Eclipse 3.4[.x] - also known as <a href="http://www.eclipse.org/downloads/packages/" rel="noreferrer">Ganymede</a> - comes with this new mechanism of provisioning called <strong>p2</strong>.</p>
<p>"Provisioning" is the process allowing to discover and update on demand some parts of an application, as explained in ... | <p>Yes, you can specify the repository locations if you use the p2.director</p>
<p>this for example is a snippet of a script that I use to install eclipse (Ganymede) from a local copy of the Ganymede repository</p>
<pre><code>./eclipse\
-nosplash -consolelog -debug\
-vm "${VM}"\
-application org.ecl... | <p>It seems like you need to have one update work via the web which will mirror (download) what you need. But after that it should be able to get the files from the local peer. But I guess that is your question - does it need web access to determine that...</p>
| 15,978 |
<p>I'm toying with the idea of phasing in an ORM into an application I support. The app is not very structured with no unit tests. So any change will be risky. I'm obviously concerned that I've got a good enough reason to change. The idea is that there will be less boiler plate code for data access and there for greate... | <p>I would strongly recommend getting a copy of Michael Feather's book <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="nofollow noreferrer" rel="nofollow noreferrer">Working Effectively With Legacy Code</a> (by "Legacy Code" Feathers means any system that isn't adequately covered by unit tests).... | <p>The rule for refactoring is. Do unit tests.</p>
<p>So maybe first you should place some unittests at least for the core/major things.</p>
<p>The ORM should be designed for decreasing boilerplate code. The time/trouble vs. ROI to be enterprisy is up to you to estimate :)</p>
| 4,204 |
<p>I have the following code:</p>
<pre><code> String inputFile = "somefile.txt";
FileInputStream in = new FileInputStream(inputFile);
FileChannel ch = in.getChannel();
ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE); // BUFSIZE = 256
/* read the file into a buffer, 256 byte... | <p>You have to know what the encoding of the file is, and then decode the ByteBuffer into a CharBuffer using that encoding. Assuming the file is ASCII:</p>
<pre><code>import java.util.*;
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.charset.*;
public class Buffer
{
public stati... | <p>Yes, it is Unicode.</p>
<p>If you have 14 Chars in your File, you only get 7 '?'.</p>
<p>Solution pending. Still thinking.</p>
| 11,893 |
<p>Can you someone please point in me in a direction, sample code or an online resource to accomplish the following:</p>
<p><strong>Requirement:</strong>
I would like to write a simple IVR menu option that will run a script (Bash or Python). For example, phone the Asterisk machine and request to restart a service on ... | <p>The <a href="http://www.voip-info.org/wiki/view/Asterisk+AGI" rel="nofollow noreferrer">Asterisk AGI</a> page holds links to applications in many programming languages.
If you do mostly .NET, maybe <a href="http://www.codeplex.com/nasterisk" rel="nofollow noreferrer">nasterisk</a> or the older <a href="http://gundy.... | <p>Will you set up Asterisk just for this or is it/will it be doing other stuff such as PBX, IVR, etc?</p>
<p>If you are doing other stuff with Asterisk, then set up a hidden extension (one not advertised on the IVR menu) which you can dial once you're connected; in this extension, you can check the caller id and comp... | 48,005 |
<p>I have to create a site definition for a client that must contain pre-defined web part pages. I can create the web part pages but am at a loss when it comes to attaching them to the site on creation.</p>
<p>I know web part pages created through SharePoint are stored in a Document Library. Do I need to pre-populate ... | <p>You can follow this methodology which uses Feature Stapling. I used this to automatically add web parts to My Sites when they are created:</p>
<p><a href="http://blogs.msdn.com/sharepoint/archive/2007/03/22/customizing-moss-2007-my-sites-within-the-enterprise.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/sh... | <p>You can follow this methodology which uses Feature Stapling. I used this to automatically add web parts to My Sites when they are created:</p>
<p><a href="http://blogs.msdn.com/sharepoint/archive/2007/03/22/customizing-moss-2007-my-sites-within-the-enterprise.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/sh... | 29,006 |
<pre><code>Object o = new Long[0]
System.out.println( o.getClass().isArray() )
System.out.println( o.getClass().getName() )
Class ofArray = ???
</code></pre>
<p>Running the first 3 lines emits;</p>
<pre><code>true
[Ljava.lang.Long;
</code></pre>
<p>How do I get ??? to be type long? I could parse the string and do ... | <p>Just write </p>
<pre><code>Class ofArray = o.getClass().getComponentType();
</code></pre>
<p>From <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getComponentType--" rel="noreferrer">the JavaDoc</a>:</p>
<blockquote>
<p><code>public Class<?> getComponentType()</code></p>
<p>Ret... | <p>@ddimitrov is the correct answer. Put into code it looks like this:</p>
<pre><code>public <T> Class<T> testArray(T[] array) {
return array.getClass().getComponentType();
}
</code></pre>
<p>Even more generally, we can test first to see if the type represents an array, and <em>then</em> get its comp... | 26,154 |
<p>I need a tool to execute XSLTs against <strong>very large</strong> XML files. To be clear, I don't need anything to design, edit, or debug the XSLTs, just execute them. The transforms that I am using are already well optimized, but the large files are causing the tool I have tried (Saxon v9.1) to run out of memory.... | <p>I found a good solution: Apache's <a href="http://xml.apache.org/xalan-c/index.html" rel="noreferrer">Xalan C++</a>. It provides a <a href="http://xml.apache.org/xalan-c/programming.html#memory" rel="noreferrer">pluggable memory manager</a>, allowing me to tune allocation based on the input and transform. </p>
<p>... | <p>Take a look at <a href="http://www.marrowsoft.co.uk/Products.htm" rel="nofollow noreferrer">Xselerator</a></p>
| 28,557 |
<p>In our development environment each developer has their own dev server. Often times they do not actually develop on that server but develop from their local machine, deploy to their dev server, and then attach with the remote debugger to do debugging.</p>
<p>My question is; how can I use MSBuild to execute a diffe... | <p>You could use the project user file (*.suo / *.user) to do some 'poor mans dependency injection'.</p>
<p><a href="http://ahmed0192.blogspot.com/2006/11/customize-msbuild-without-modifying.html" rel="nofollow noreferrer">looks like this guy did something similar</a></p>
| <p>Yeah, I've done this before. Try trick is to key off <code>$(USERNAME)</code> in your msbuild script. If you haven't tried editing msbuild scripts before, you've got a lot of learning to do.</p>
| 10,345 |
<p>This is about when a .NET remoting exception is thrown. If you take a look at MSDN, it will mention that a remoting exception is thrown when something goes wrong with remoting. If my server is not running, I get a socket exception which is fine.</p>
<p>What I am trying to figure out is: does getting a remoting excep... | <p>Getting a remoting exception does not guarantee that your server is up and running. If something else happens to be running and listening on that port, the connection will succeed, and you will not get a socket exception. What happens in this case depends on how the application which actually got your connection b... | <p>Try assuring that you send the correct message and the messages received by the server are also correct, e.g. using assertions (it is called Design by Contract).
If you have such possibility, try debugging the server side and client side at the same time. (running two VS instances at the same time)</p>
| 9,951 |
<p>I'm struggling to get my printer up and running for a few days now. The problem is as follows. I got a test model of a cube (40x40 mm) and everytime I try to print it, the nozzle creates these 'lines' on the print which is caused by over extrusion I think? See image:</p>
<p><a href="https://i.stack.imgur.com/W... | <p>Your images look as if your initial nozzle to heat bed offset is too large. This causes the filament not to be squished. Try re-levelling and have a piece of plain printing paper have a little drag when pulled.</p>
| <p>I think You need to re-calibrate Z steps. Sometimes Marlin default z-steps/mm won't fit for 3D printer, because it depends on the hardware(z-axis threaded rod) that used to build the 3D printer. Check whether the Z-axis moves the distance that you command it to move. (ex: command to move x distance and check whether... | 1,326 |
<p>How do you specify that a foreign key constraint should be a 1:1 relationship in transact sql? Is declaring the column UNIQUE enough? Below is my existing code.!</p>
<pre><code>CREATE TABLE [dbo].MyTable(
[MyTablekey] INT IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[OtherTableKey] INT NOT NULL UNIQUE
... | <p>A foreign key column with the UNIQUE and NOT NULL constraints that references a UNIQUE, NOT NULL column in another table creates a 1:(0|1) relationship, which is probably what you want.</p>
<p>If there was a true 1:1 relationship, every record in the first table would have a corresponding record in the second table... | <p>Based on your code above, the unique constraint would be enough given that the for every primary key you have in the table, the unique constrained column is also unique. Also, this assumes that in [OtherTable], the [OtherTableKey] column is the primary key of that table.</p>
| 5,227 |
<p>I could really do with updating a user's session variables from within my HTTPModule, but from what I can see, it isn't possible.</p>
<p><em>UPDATE:</em> My code is currently running inside the <code>OnBeginRequest ()</code> event handler.</p>
<p><em>UPDATE:</em> Following advice received so far, I tried adding th... | <p>Found this over on the <a href="http://forums.asp.net/p/1098574/1665773.aspx" rel="nofollow noreferrer">ASP.NET forums</a>:</p>
<pre><code>using System;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Diagnostics;
// This code demonstrates how to make session state available... | <p>Try it: in class MyHttpModule declare:</p>
<pre><code>private HttpApplication contextapp;
</code></pre>
<p>Then:</p>
<pre><code>public void Init(HttpApplication application)
{
//Must be after AcquireRequestState - the session exist after RequestState
application.PostAcquireRequestState += new EventHandl... | 34,847 |
<p>So, I have Flex project that loads a Module using the ModuleManager - not the module loader. The problem that I'm having is that to load an external asset (like a video or image) the path to load that asset has to be relative to the Module swf...not relative to the swf that loaded the module.</p>
<p>The question i... | <p>You can import <code>mx.core.Application</code> and then use <a href="http://livedocs.adobe.com/flex/3/langref/mx/core/Application.html#url" rel="nofollow noreferrer">Application.application.url</a> to get the path of the host application in your module and use that as the basis for building the URLs.</p>
<p>For he... | <p>You can use this.url in the module and use this as a baseURL.</p>
<pre><code>var urlParts:Array = this.url.split("/");
urlParts.pop();
baseURL = urlParts.join("/");
Alert.show(baseURL);
</code></pre>
<p>and use <code>{baseURL + "/location/file.ext"}</code> instead of <code>/location/file.ext</code></p>
| 15,524 |
<p>I'm making a simple 2D game for the iPhone. It's based on CrashLanding. so it's basically a background texture and a few rectangular textures moving around. </p>
<p>I have this bizarre little graphics problem: some of the small 2d items (can assume just rectangles) moving around get this little flashing black bar... | <p>Do you have a thing like that little black bar in your textures?</p>
<p>I've encountered similar problems when I have done something wrong. Here's a small check-list:</p>
<ul>
<li>Have you have mipmapped your texture or not, and check what parameters does it have.</li>
<li>glTexParameters. (WRAP_S, WRAP_T, MAG_FIL... | <p>Since this is a 2D game, are these small rectangular sprites contained within the same texture sheet? Another possible culprit could be texture filtering.</p>
<p>If you are trying to manipulate texture coordinates to draw a subregion of your texture, you could check if you are drawing the sprite at a larger than 1... | 23,051 |
<p>I need to intercept the console output stream(s) in order to capture it for a log but still pass things through to the original stream so the application works properly. This obviously means storing the original <code>Console.Out</code> TextWriter before changing it with <code>Console.SetOut(new MyTextWriterClass(o... | <p>If you look at the implementation for SetOut it looks thread safe to me:</p>
<pre><code>[HostProtection(SecurityAction.LinkDemand, UI=true)]
public static void SetOut(TextWriter newOut)
{
if (newOut == null)
{
throw new ArgumentNullException("newOut");
}
new SecurityPermission(SecurityPermis... | <p>If you can do this early in <code>Main()</code> you'll have a much better chance of avoiding any race conditions, especially if you can do it before something creates a worker thread. Or in the static constructor of some class.</p>
<p>If <code>Main()</code> is marked with the <code>[STAThread]</code> attribute it w... | 47,926 |
<p>I am trying to keep track of something and using the SessionID as they key to that object</p>
<p>However the SessionID every 2-3 reqiests changes shouldn't it remain the same?</p>
<pre><code>HttpContext.Session.SessionID
</code></pre>
<p>Is the code I am using.</p>
| <p>I've seen that happen even without MVC. If I remember correctly, ASP.NET keeps assigning new session ids until you place something into the Session variable.</p>
| <p>Try with adding machine key into your web.config:<br>
Online key generator: <a href="http://aspnetresources.com/tools/keycreator.aspx" rel="nofollow noreferrer">http://aspnetresources.com/tools/keycreator.aspx</a>
It seems that server resets machine key for client and generates new one with new session id, every few... | 35,678 |
<p>Does anyone know how to get the HTML out of an IFRAME I have tried several different ways:</p>
<pre><code>document.getElementById('iframe01').contentDocument.body.innerHTML
document.frames['iframe01'].document.body.innerHTML
document.getElementById('iframe01').contentWindow.document.body.innerHTML
</code></pre>
<p... | <p>I think this is what you want:</p>
<pre><code>window.frames['iframe01'].document.body.innerHTML
</code></pre>
<p><strong>EDIT:</strong></p>
<p>I have it on good authority that this won't work in Chrome and Firefox although it works perfectly in IE, which is where I tested it. In retrospect, that was a big mista... | <p>You can get html out of an iframe using this code
iframe = document.getElementById('frame');
innerHtml = iframe.contentDocument.documentElement.innerHTML</p>
| 16,837 |
<p>I am using a Prusa i3 printer and just recently I have been having problems with the first layer. Here is a picture of what it looks like.</p>
<p><a href="https://i.stack.imgur.com/ShfZn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ShfZn.jpg" alt="First extruded layer on Prusa i3"></a> </p>
<... | <p>Oh wow. You are way over cooking your PLA. It is bubbling because it is BOILING. I can tell you have it too hot because the lines are all blurred as if they are liquid and pooled together. </p>
<p>That said I can't give you details because you didn't post settings. I would start by turning the temps to 170 &de... | <p>I had this problem and I had to adjust the nozzle temperature 10 °C below the minimum temperature of 190 °C!</p>
| 517 |
<p>I have a MFC dialog with 32 CComboBoxes on it that all have the same data in the listbox. Its taking a while to come up, and it looks like part of the delay is the time I need to spend using InsertString() to add all the data to the 32 controls. How can I subclass CComboBox so that the 32 instances share the same ... | <p>Turn off window redrawing when filling the combos. e.g.:</p>
<pre><code>m_wndCombo.SetRedraw(FALSE);
// Fill combo here
...
m_wndCombo.SetRedraw(TRUE);
m_wndCombo.Invalidate();
</code></pre>
<p>This might help.</p>
| <p>The first thing I would try is calling "InitStorage" to preallocate the internal memory for the strings.
From MSDN:</p>
<p><code>
// Initialize the storage of the combo box to be 256 strings with
// about 10 characters per string, performance improvement.</p>
<p>int n = pmyComboBox->InitStorage(256, 10);
</code></... | 44,482 |
<p>For some of the customers that we develop software for, we are required to "guarantee" a certain amount of spare resources (memory, disk space, CPU). Memory and disk space are simple, but CPU is a bit more difficult.</p>
<p>One technique that we have used is to create a process that consumes a guaranteed amount of... | <p>So this may not be exactly the answer you're looking for, but if all you want to do is make sure your application doesn't exceed certain limits on resource consumption and you're running on linux you can customize /etc/security/limits.con (may be different file on your distro of choice) to force the limits on a part... | <p>With a multi-core/processor system you could use Affinity to your advantage.</p>
| 15,941 |
<p>We're currently running an <code>svnserve</code> instance as NT service. While this works, it's needlessly cumbersome to administer, and I'd like to move on to the much simpler VisualSVN Server. (Bonus side benefits include Windows-integrated authentication and, thanks to HTTP/WebDAV, browsing of the latest revision... | <p>Read Committed Snapshot only deals with locks on selecting data from tables.</p>
<p>In t1 and t2 however, you're UPDATEing the data, which is a different scenario.</p>
<p>When you UPDATE the counter you escalate to a write lock (on the row), preventing the other update from occurring. t2 could read, but t2 will bl... | <p>There is at heart only one transaction, the outermost one. The inner transactions are more like checkpoints within a transaction. Isolation levels affect only sibling outermost transactions, not parent/child related transactions.</p>
<p>The counter will be incremented by two. The following yields one row with a val... | 23,492 |
<p>I need to add 30 minutes to values in a Oracle date column. I do this in my SELECT statement by specifying </p>
<p><code>to_char(date_and_time + (.000694 * 31)</code></p>
<p>which works fine most of the time. But not when the time is on the AM/PM border. For example, adding 30 minutes to <code>12:30</code> [whi... | <p>In addition to being able to add a number of days to a date, you can use interval data types assuming you are on <code>Oracle 9i</code> or later, which can be somewhat easier to read,</p>
<pre><code>SQL> ed
Wrote file afiedt.buf
SELECT sysdate, sysdate + interval '30' minute FROM dual
SQL> /
SYSDATE ... | <pre><code>SELECT to_char(sysdate + (1/24/60) * 30, 'dd/mm/yy HH24:MI am') from dual;
</code></pre>
<p>simply you can use this with various date format....</p>
| 32,106 |
<p>Parts of my application are in C++ under windows. I need the process id for the current process. Any thoughts? </p>
| <p>The <a href="http://msdn.microsoft.com/en-us/library/ms683180(VS.85).aspx" rel="noreferrer"><code>GetCurrentProcessId</code></a> function will do this.</p>
| <p>You can use <code>getpid()</code> or <code>_getpid()</code> , which are defined in <code><process.h></code> library.</p>
<p><a href="https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/getpid?view=vs-2019" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference... | 38,170 |
<p>I am writing a <a href="http://martinfowler.com/eaaCatalog/repository.html" rel="nofollow noreferrer">repository</a>. Fetching objects is done through a DAO. Creating and updating objects is done through a Request object, which is given to a RequestHandler object (a la <a href="http://en.wikipedia.org/wiki/Command_p... | <p>To test the repository I would suggest that you use test doubles for all of the lower layer objects.</p>
<p>To test the classes that depend on the repository I would suggest that you use test doubles for the repository. </p>
<p>In both cases I mean test doubles created by some mocking library (fakes where that wor... | <p>You may of may not be creating a web application, but you can have a look at the NerdDinner application which uses Repository. It is a free PDF that explains how to create an application using ASP.NET MVC and can be found here: <a href="http://www.wrox.com/WileyCDA/Section/id-321793.html" rel="nofollow noreferrer">... | 17,187 |
<p>Is there an easy way of using the <code>RegularExpressionValidator</code> control while ignoring white space?</p>
<p>I can use a custom validator control with <code>Regex</code> and <code>IgnorePatternWhitespace</code>, but it would be good to just have an option in the <code>RegularExpressionValidator</code> contr... | <p>Surround your regex with</p>
<blockquote>
<p>(?x: )</p>
</blockquote>
<p>so "a b c" becomes "(?x:a b c)</p>
| <p>Remember that the regular expression validator want to validate with javascript, too, so you want to make sure your expression will work with both the .Net and javascript regex engines. That means that using .IgnorePatterWhitespace isn't the best idea.</p>
| 8,152 |
<p>How do you actually perform datetime operations such as adding date, finding difference, find out how many days excluding weekends in an interval? I personally started to pass some of these operations to my postgresql dbms as typically I would only need to issue one sql statement to obtain an answer, however, to do ... | <p>While for most datetime operations I would normally convert to Unixtime and perform addition subtraction etc. on the Unixtime integer, you may want to look at the Zend framework Zend_Date class. </p>
<p>This has a lot of the functionality you describe. Although Zend is billed as a "framework" it works exceptionally... | <p>to get working days/holidays, postgresql CTE ftw -- see <a href="http://osssmb.wordpress.com/2009/12/02/business-days-working-days-sql-for-postgres-2/" rel="nofollow">http://osssmb.wordpress.com/2009/12/02/business-days-working-days-sql-for-postgres-2/</a></p>
| 8,053 |
<p>How can I figure out what is actually causing the following error? The page is the same as other pages but for some reason, only this page is having this error. It also only happens on the ISP (GoDaddy) who has a trust level of Medium and I can't set a breakpoint and try to catch it.</p>
<pre><code>Server Error in ... | <p>Have you tried using a local instance of IIS and setting the trust level to medium? That would help you debug and try stuff a little quicker. </p>
<p>(And is a good habit to get into anyway. You want to test in an environment as close to production as possible. And the VS web server definitely has a few important d... | <p>Setting breakpoints in obfuscated, non-debug assemblies are hard. It will likely lead you nowhere.</p>
<p>Find out why the obfuscated component is trying to access the temp path.</p>
| 34,497 |
<p>I'm writing an application that on some stage performs low-level disk operations in Linux environment. The app actually consists of 2 parts, one runs on Windows and interacts with a user and another is a linux part that runs from a LiveCD. User makes a choice of Windows drive letters and then a linux part performs a... | <p>Partitions have UUIDs associated with them. I don't know how to find these in Windows but in linux you can find the UUID for each partition with:</p>
<blockquote>
<p>sudo vol_id -u device (e.g. /dev/sda1)</p>
</blockquote>
<p>If there is an equivilent function in Windows you could simply store the UUIDs for what... | <p>You need to either mark the drive in some way (e.g. write a file etc.), or find some identifier that is only associated with that particular drive.</p>
<p>It is very hard, almost impossible to figure out what letter Windows would assign to a particular drive partition, without actually running Windows. This is beca... | 3,948 |
<p>In several modern programming languages (including C++, Java, and C#), the language allows <a href="http://en.wikipedia.org/wiki/Integer_overflow" rel="noreferrer">integer overflow</a> to occur at runtime without raising any kind of error condition.</p>
<p>For example, consider this (contrived) C# method, which doe... | <p>In C#, it was a question of performance. Specifically, out-of-box benchmarking.</p>
<p>When C# was new, Microsoft was hoping a lot of C++ developers would switch to it. They knew that many C++ folks thought of C++ as being fast, especially faster than languages that "wasted" time on automatic memory management an... | <p>My understanding of why errors would not be raised by default at runtime boils down to the legacy of desiring to create programming languages with ACID-like behavior. Specifically, the tenet that anything that you code it to do (or don't code), it will do (or not do). If you didn't code some error handler, then th... | 12,931 |
<p>I want to run two stepper motors using Arduino Mega 2560 and RAMPS 1.4. But, somehow I burned the Arduino while I was connecting the motor and plugging the board to the computer.</p>
<p>Can I plug external power supply and USB connection to the computer at the same time?</p>
<h3>Additional info from comments</h3>
<p... | <p>I had a similar issue building my Prusa i3 Mk2s clone. I was constantly hooking & unhooking my Arduino from my PC while the printer was plugged into the mains. At some point it had enough & it released some "magic smoke". Later on I found out this was the power regulator on the Arduino.</p>
<p>Y... | <p>The answer is, yes you can, but you need to follow guidelines.</p>
<p>Reversing +/- or otherwise incorrectly connecting power can destroy your electronics and cause fire hazard.</p>
<hr />
<p>From <a href="http://reprap.org/wiki/RAMPS_1.4" rel="nofollow noreferrer">RepRap wiki - RAMPS 1.4</a></p>
<blockquote>
<p>Max... | 871 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.