instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I came across a code snippet like this:</p> <p><code>Timestamp expiryDate = Timestamp.valueOf(dateStr + " " + "23:59:59.000"); </code></p> <p>Here dateStr is a string entered by the user in a form, in the format yyyy-mm-dd. Now the behavior of Timestamp.valueOf is such that it converts non-existent dates into appr...
<p>Try <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html" rel="noreferrer">SimpleDateFormat</a>. You simply set a format such as the one in your example and then call parse on your dateStr.</p>
<h1><em>java.time</em></h1> <p>The <code>java.util</code> Date-Time API and their formatting API, <code>SimpleDateFormat</code> are outdated and error-prone. Since <code>java.sql.Timestamp</code> extends <code>java.util.Date</code>, it has got the same problems. It is recommended to stop using them completely and switc...
28,068
<p>Although I know how to build a DOM the long, arduous way using the DOM API, I'd like to do something a bit better than that. Is there a nice, tidy way to build hierarchical documents with, say, an API that works something like Hibernate's Criteria API? So that I can chain calls together like this, for example:</p>...
<p>You definitely want to use <code>JDom</code>: <a href="http://www.jdom.org/docs/apidocs/" rel="nofollow noreferrer">http://www.jdom.org/docs/apidocs/</a> . It can be used as you described as many methods return a reference to <code>this</code>. Here is some code our teacher showed us for this XML document. Haven't t...
<p>Try looking at the <a href="http://www.dom4j.org/dom4j-1.6.1/guide.html" rel="nofollow noreferrer">Quick Start</a> guide for DOM4J. It makes getting the XML out pretty easy too. I've included a relevant snippet:</p> <pre><code>import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; pu...
44,387
<p>I had this questions since the time I learnt about object-oriented programming. Now, I have got a wonderful forum I thought of asking this.</p> <p>Lets say we are implementing an employee management application using EJB.</p> <p>Now, there are 2 ways of doing this.</p> <ol> <li><p>Normally, we create entities (PO...
<p>The first one is certainly clearer, and clarity should certainly be an aim of your code. However, in terms of the first one, I'll direct you <a href="http://www.codinghorror.com/blog/archives/000553.html" rel="nofollow noreferrer">here</a>: Jeff Atwood's take on calling things "SomethingManager" - not recommended.</...
<p>Having separare class for persisting Employee looks more OO. And more flexible, because you potentially may want to have DBEmployeeMrg, FileSystemEmployeeMrg, InMemoryEmployeeMgr and MockEmployeeMgr for testing - all those classes may implement inteface EmployeeMrg in different way.</p> <p>For your code to be short...
14,364
<p>Suppose that a group wants to encrypt some information, then share the encryption key among the group members in a way that requires the consensus of the group to decrypt the information. I'm interested in a variety of scenarios where the breadth of consensus ranges from unanimity to an absolute majority. A useful t...
<p>I have always been fascinated by this secret sharing technique. I've seen code implementing it on the internet, but have never seen actual applications. <a href="http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing" rel="noreferrer">Shamir's secret sharing</a> The wikipedia article links to some actual code, as...
<p>Lotus Notes provides a practcal implementation of 'Silo passwords' whereby access to some resource (data/info/document) is locked to a 'shared-id' - The ID (part of a certfied PKI system I think based on RSA) is setup with 2 or more (I think up to 16) individual user passwords. The certifier/administrator sets up a ...
13,698
<p>I currently learning about scrum and want to learn from experienced professionals in the subject. </p> <p>Is velocity relevant for project that take 3 month (and usually have 2-3 intermediate deliveries to customer) ?<br> I think it's not enough time to make a statistic relevant. Is it worth to record velocity per ...
<p>So, to split your question into two parts:</p> <p>1) Is Velocity worthwhile in a 3-month project? Yes, I think it is. I've worked on teams where most projects were 2-6 months in length. We had one-week iterations, but I know teams that are as short as 3-days. However, there is a movement in the agile community towa...
<p>Smaller iterations will allow you to get a better measure of velocity as they provide more data points. The tracking does not have to be elaborate a simple burn down chart will give a quick graphical look at velocity. </p>
33,329
<p>I like the idea of having Interfaces and Implementation separate. But how separate? Are the Interface definitions in a separate .Net assembly? Do you have a single project that defines all Interfaces for a solution? Otherwise are there issues with circular dependencies of Interfaces?</p>
<p>Put your domain objects and interfaces in a seperate "domain" assembly.<br> This assembly should never reference anything but the core .net assemblies.</p> <p>This way you get a clean seperation from your domain/service model and your implementation.</p> <p><em>Edit:</em><br> <a href="http://jeffreypalermo.com/blo...
<p>In the project I'm working on right now, the interfaces and related base classes go into assemblies that are logically divided among functions. The implementations of these providers and classes go inside a core assembly. The idea being that people who use our API can reference more or one of the API dlls in a cle...
8,161
<p>Following on from <a href="https://stackoverflow.com/questions/347698/how-do-i-automatically-export-a-war-after-java-build-in-eclipse">this question</a>, I now want to know how to stop an ANT script from executing if the preceding build failed. I can't see a way in the Build setup in Eclipse of chaining builds toge...
<p>No native way, AFAIK. What you can do is modify your ant script to check if .class files produced by Eclipse are newer than WAR. If not, stop.</p>
<p>You should be able to store the success into a file. If you make sure the content of the file is a property file content the next ant task can use that file to fill in a property (like build.success) and can act on that.</p>
45,297
<p>I would like to see if there is such a tool that allows reusable web template with components like menu and form easily applied. Basically I want to mock a very simple interface using html, to see if the navigation is working, then generate a pure XHTML/CSS for me to use on my web projects.</p> <p>For your inform...
<p>Aptana and Scripts/Samples?</p>
<p>Try this <a href="http://www.blumentals.net/webuilder/" rel="nofollow noreferrer">http://www.blumentals.net/webuilder/</a> this is the best editor(for me) supports javascript, css, php, etc.</p>
29,644
<p>On an ASP.NET website, are static classes unique to each web request, or are they instantiated whenever needed and GCed whenever the GC decides to disposed of them?</p> <p>The reason I ask is because I've written some static classes before in C# and the behavior is different than I would have expected. I would have...
<p>Your static classes and static instance fields are shared between all requests to the application, and has the same lifetime as the application domain. Therefore, you should be careful when using static instances, since you might have synchronization issues and the like. Also bear in mind, that static instances wil...
<blockquote> <p>If they are not unique to each request, is there a way to allow them to be?</p> </blockquote> <p>Nope. Static members are owned by the ASP.NET process and shared by <em>all</em> users of the Web app. You'll need to turn to other session management techniques such as session variables. </p>
23,689
<p>I am just now learning about function pointers and, as I was reading the K&amp;R chapter on the subject, the first thing that hit me was, &quot;Hey, this is kinda like a closure.&quot; I knew this assumption is fundamentally wrong somehow and after a search online I didn't find really any analysis of this comparison...
<p>A lambda (or <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)" rel="noreferrer">closure</a>) encapsulates both the function pointer and variables. This is why, in C#, you can do:</p> <pre><code>int lessThan = 100; Func&lt;int, bool&gt; lessThanTest = delegate(int i) { return i &lt; lessThan; }; <...
<p>The big question is: what is a closure and/or lambda behind the scenes? what does it become a closure and/or a lambda or even more, a delegate? the very possible answer is that these become in a sort of function pointer as assembly code, thus, closures, delegates, lambdas, anonymous functions are in essence a kind o...
25,620
<p>Please advise if you can.</p> <p>I am building an SMS web service API that will allow people to send SMS to their desired cellphone numbers. A request will be sent to the interface, we then process that request based on the account details provided and credits available on their account.</p> <p>We have two propose...
<p>Interface A.</p> <p>Interface B is essentially just a list of key/values, where as Interface A takes advantage of the structured nature of XML and provides meaning through the structure. </p> <p>For example: ClientId is an attribute of the Message, not the Request itself. This is clear from looking at A, but not f...
<p>Interface A. It's shorter.</p>
43,079
<p>Seems likes it might be useful to have the assert display a message when an assertion fails.</p> <p>Currently an <code>AssertionError</code> gets thrown, can you specify a custom message for it?</p> <p>Can you show an example mechanism for doing this (other than creating your own exception type and throwing it)?</...
<p>You certainly can:</p> <pre><code>assert x &gt; 0 : &quot;x must be greater than zero, but x = &quot; + x; </code></pre> <p>See <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html" rel="noreferrer">Programming with Assertions</a> for more information.</p>
<p>If you use</p> <pre><code>assert Expression1 : Expression2 ; </code></pre> <p>Expression2 is used as a detail message for the AssertionError.</p>
34,454
<p>What would be the best way to display &amp; program simple game board (say chess, checkers and such) in C#? In terms of controls and underlying game logic. </p> <p>An idea that came to my mind was to use <strong>Picture Box</strong> (or class inheriting from it) with Board &amp; Field classes. </p> <ul> <li>Is tha...
<p>In an object-oriented approach, think about the objects involved in your game (e.g. the board, the pieces) … let them each provide a drawing method that takes a <code>Graphics</code> object and draws itself on it.</p> <p>The drawing itself could be done on a <code>PictureBox</code> – this is the ideal control for s...
<p>Generally, first design the logical constructs for the board, pieces and such, then the operations on these, and only finally design a graphical interface, more or less as a frontend.</p>
42,116
<p>I'm looking for non-web-based tools to view IIS logs. I've been using <a href="http://www.microsoft.com/technet/scriptcenter/tools/logparser/default.mspx" rel="nofollow noreferrer">LogParser</a> but I was hoping for something with an interface. It doesn't need to do any fancy reports or charts -- just a list with ...
<p><a href="http://www.codeplex.com/visuallogparser" rel="nofollow noreferrer">VisualLogParser</a> wraps Log Parser in a GUI. I'm sure there are others as well, but it's fit the bill for me. All the yumminess of Log Parser, with a half-decent interface.</p>
<p>I'm intrigued why you need more of an "interface" than the command line interface already provided by LogParser? Are you struggling with the SQL-like syntax maybe or is there something else?</p> <p>LogParser ticks ALL your other requirements. It totally rocks <em>my</em> socks.</p>
14,640
<p>I am using the functions strpos(string, string) in javascript. In Firefox, Opera and IE the page loads fine, but in Chrome I get the error: Uncaught ReferenceError: strpos is not defined. The page I am working on is <a href="http://seniorproject.korykirk.com/0xpi2.php" rel="nofollow noreferrer">http://seniorproject....
<p>Use <a href="http://www.w3schools.com/jsref/jsref_IndexOf.asp" rel="nofollow noreferrer"><code>haystack.indexOf(needle)</code></a>.</p>
<p>If you want to use PHP functions in javascript, use php.js</p> <p>Here's <code>strpos()</code> <a href="http://phpjs.org/functions/strpos:545" rel="nofollow">http://phpjs.org/functions/strpos:545</a></p>
40,030
<p>At what point would you create your own exception class vs. using java.lang.Exception? (All the time? Only if it will be used outside the package? Only if it must contain advanced logic? etc...)</p>
<p>I think you need to ask yourself a slighly different question "What advantage does creating a new exception give me or developers who use my code?" Really the only advantage it gives you or other people is the ability to handle the exception. That seems like an obvious answer but really it's not. You should only ...
<p>In most cases it doesn't make sense to create your own exception class. </p> <p>There is a tendency in novice programmers to create their own exception class just so they can use a name that is more indicative of the type of error. So you'll find classes like FTPInitializationException, DAOFactoryException etc. eve...
29,400
<p>Estimating how long any given task will take seems to be one of the hardest parts about software development. At my current shop we estimate tasks in hours at the start of an iteration, but once the task is complete we do not use it to aide us in future estimations.</p> <p>How do you use the information you gather ...
<p>By far one of the most interesting approaches I've ever seen for scheduling realistically is <a href="http://www.joelonsoftware.com/items/2007/10/26.html" rel="nofollow noreferrer">Evidence Based Scheduling</a> which is part of the FogCreek FogBugz 6.0 release. See Joel's blog post linked above for a synopsis and so...
<p>If an estimate blew out, attempt to identify if it was just random (environment broke, some once off tricky bug etc) or if there was something that you didn't identify.</p> <p>If an esimate was way too large, identify what it was that you thought was going to take so long and work out why it didn't.</p> <p>Doing t...
22,979
<p>Since I've joined twitter I have found it very helpful to keep my finger on the pulse of technology and where it is going.</p> <p>I follow many of the top Microsoft developers and find it interesting to see their struggles, opinions, and influences...</p> <ul> <li>codinghorror / Jeff Atwood </li> <li>shanselman ...
<p>It's definitely a distraction, but I find that an amusing distraction here and there is good for me. I get more done in shorter amounts of time when my morale is high, and connecting to the outside world helps with that. I follow my wife, our cat (yep, has a twitter), several friends, a few ColdFusion &amp; Flex eva...
<p>It's a distraction ... especially because most of the <strong>tweets</strong> are non-programming related ... i.e. Hanselman ... <strong>but</strong> that is the purpose of Twitter! So shame on me for being a follower!</p>
22,085
<p>Is it safe to use MS SQL's WITH (NOLOCK) option for select statements and insert statements if you never modify a row, but only insert or delete rows?</p> <p>I..e you never do an UPDATE to any of the rows.</p>
<p>If you're asking whether or not you'll get data that may no longer be accurate, then it depends on your queries. For example, if you do something like:</p> <pre><code>SELECT my_id, my_date FROM My_Table WHERE my_date &gt;= '2008-01-01' </code></pre> <p>at the same time that a row is being inser...
<p>Not sure how SELECT statements could conflict if you're limiting yourself to INSERTs and DELETEs. INSERT is problematic because there may have been conflicting primary keys inserted during your query, for instance. Both INSERTs and DELETEs both expose you to the conditions expressed in your WHERE clause, or JOINs, e...
36,594
<p>I am assigning ViewState["something"] in Page Load of content page and when I try to access the ViewState variable in Master Page Load event handler, the viewstate variable is lost.Can anyone guide me why this is happening and the solution.</p>
<p>Master pages and content pages do not share the same ViewState. If you are trying to pass something from the content page to the master page there are a couple of alternatives:<br> - use this.Context.Items that is common to the entire site during an HTTP request<br> - make a public property on the master page, cast ...
<p>Maybe (just found it on the web) this is a hint to the solution:</p> <blockquote> <p>Unless the MasterPage has its ViewState turned on, all controls below it would lose their state.</p> </blockquote> <p>Found this in a blog post titled <a href="https://web.archive.org/web/20161212011915/http://geekswithblogs.net:80/...
49,559
<p>I would like to upgrade my team from VS2005 to VS2008 without touching the version of Team Server which is 2005. </p> <p>Is that possible? </p> <p>And if so, how do I tell VS to recognize TFS?<br> Currently in my VS2008 options menu, I don't have any source control to choose from.</p>
<p>Yes, you can... (We're doing that here too)</p> <ul> <li>Tools -> Connect To Team Foundation Server</li> <li>"Add..."</li> <li>Enter IP / hostname</li> </ul>
<p>Yes, that works fine. If you install the Team Foundation Client from the TFS 2008 DVD on your VS machine, you can connect to both TFS 2005 and TFS 2008 servers. If you don't have access to a TFS 2008 DVD (note that the trial should be fine), installing the 2005 client on VS 2008 should also work, but I've never pers...
11,674
<p>In visual studio 2008, when I drag a database table into my dbml screen, any tables that end with the letter s automatcially get the s removed from the dbml object. Is there any way to disable this?</p> <p>Also, the collection of rows also gets an s appended to the collection property name. Is there a way to chan...
<p>You need to disable the Pluralize Table Names for the LINQ to SQL designer.</p> <p>To do this navigate to Tools -> Options -> Database Tools -> O/R Designer and change the <strong>Pluralization of names</strong> to <strong>false</strong>.</p> <p>Then you will need to recompile your project and it should address th...
<p>In a code first scenario, you can handle some problems that pop up like this on a more granular level by simply specifying the name of the table on the entity with the Table attribute:</p> <pre><code> [Table("QTPhotos")] public class QTPhoto </code></pre> <p>What I found was, originally, we had a simple en...
43,558
<p>How do I set, clear, and toggle a bit?</p>
<h1>Setting a bit</h1> <p>Use the bitwise OR operator (<code>|</code>) to set a bit.</p> <pre><code>number |= 1UL &lt;&lt; n; </code></pre> <p>That will set the <code>n</code>th bit of <code>number</code>. <code>n</code> should be zero, if you want to set the <code>1</code>st bit and so on upto <code>n-1</code>, if you...
<p>Try one of these functions in the C language to change n bit:</p> <pre><code>char bitfield; // Start at 0th position void chang_n_bit(int n, int value) { bitfield = (bitfield | (1 &lt;&lt; n)) &amp; (~( (1 &lt;&lt; n) ^ (value &lt;&lt; n) )); } </code></pre> <p>Or</p> <pre><code>void chang_n_bit(int n, int ...
7,034
<p>I'm trying to put together a list of JavaScript UI widget frameworks for consideration in a project. Ideally it would be a library that has a range of ready made ui widgets, no dependencies on dom/js extention/manipulation frameworks like JQuery or Prototype, minimal additional cruft, such as Ajax API's and DOM sele...
<p>Answered here: <a href="https://stackoverflow.com/questions/218699/your-choice-of-cross-browser-javascript-gui">Your choice of cross-browser javascript GUI</a> and here: <a href="https://stackoverflow.com/questions/200284/what-are-alternatives-to-extjs">What are alternatives to ExtJS?</a></p>
<p><a href="http://rialto.improve-technologies.com" rel="nofollow noreferrer">Rialto</a> (Rich Internet Application Toolkit) is ajax-based cross browser javascript widgets library. Because it is technology agnostic it can be encapsulated in JSP, JSF, .Net, Python or PHP graphic components. The purpose of Rialto is to e...
44,630
<p>I've just solved another *I-though-I-was-using-this-version-of-a-library-but-apparently-my-app-server-has-already-loaded-an-older-version-of-this-library-*issue (sigh).</p> <p>Does anybody know a good way to verify (or monitor) whether your application has access to all the appropriate jar-files, or loaded class-ve...
<p>If you happen to be using JBoss, there is an MBean (the class loader repository iirc) where you can ask for all classloaders that have loaded a certain class.</p> <p>If all else fails, there's always <code>java -verbose:class</code> which will print the location of the jar for every class file that is being loaded.<...
<p>There must be a better way than the way I do it, but I tend to do this in a very manual way.</p> <ol> <li>Every Jar must have it's version number in the file name (if it doesn't change it's name).</li> <li>each application has it's own classpath.</li> <li>There must be a reason to start using an updated Jar (new ve...
16,878
<p><a href="http://developer.yahoo.com/javascript/howto-proxy.html" rel="nofollow noreferrer">http://developer.yahoo.com/javascript/howto-proxy.html</a></p> <p>Are there disadvantages to this technique? The advantage is obvious, that you can use a proxy to get XML or JavaScript on another domain with XMLHttpRequest wi...
<p>Overhead - things are going to be a bit slower because you're going through an intermediary.</p> <p>There are security issues if you allow access to any external site via the proxy - be sure to lock it down to the specific site (and probably specific URL) of the resource you're proxying.</p>
<p>I suppose there could be security considerations, though others are likely to be more qualified than me to address that. I've been running such a proxy on my personal site for a while now and haven't run into problems.</p>
22,254
<p>If you had to fix and stabilize a MVC application, where would you start: the Model, Controller or View? The problems are spread equally throughout the application, with bad programming practices that make it hard to add functionality. The application is written in PHP if it makes a difference.</p>
<p>Start with the model because it is the foundation of your application. It is also easier to write tests for. It is tricky to write unit tests for controllers, though it can be done, and even harder for views. However, once you have a really solid and encapsulated API for your model, it is relatively easy to layer a ...
<p>Id' say model, controller, view, in that order. Because the most fundamental logic in in the model, followed by the controller (at quite a distance, usually)</p>
21,256
<p>How do you deal with source control management and automated deployment (configuration management) of database tables. I work in a SQL Server environment and it's pretty easy to script out drop and create files for stored procedures/triggers/functions even jobs. It's also easy to handle scripting out the creation ...
<p>You can automatically create the initial creation script, but ALTER scripts really need to be hand-coded on a case-by-case basis, because in practice you need to do custom stuff in them.</p> <p>In any case, you'll need some way of creating apply and rollback scripts for each change, and have an installer script whi...
<p>It varies, depending on how you want to treat existing data and how extensive the schema changes are, but even in Management Studio, before you commit changes, you can generate a script of all the changes.</p> <p>For a lot of data or where there are constraints or foreign keys, even simple ALTER operations can take...
13,075
<p>Does anyone here use VB.NET and have a strong preference for or against using <code>IsNothing</code> as opposed to <code>Is Nothing</code> (for example, <code>If IsNothing(anObject)</code> or <code>If anObject Is Nothing...</code>)? If so, why?</p> <p>EDIT: If you think they're both equally acceptable, do you thin...
<p>If you take a look at the MSIL as it's being executed you'll see that it doesn't compile down to the exact same code. When you use IsNothing() it actually makes a call to that method as opposed to just evaluating the expression. </p> <p>The reason I would tend to lean towards using "Is Nothing" is when I'm negating...
<p>Is Nothing requires an object that has been assigned to the value Nothing. IsNothing() can take any variable that has not been initialized, including of numeric type. This is useful for example when testing if an optional parameter has been passed.</p>
2,763
<p>We've got an application we'd like our users to download. Currently they click a link and download the EXE. What we'd like to do is have a launchpad/downloader application that would be small and fast to download, which would then download and install the main application.</p> <p>In a perfect world the downloader...
<p>You'll need to write a bootstrap EXE, there's a little bit of documentation in <a href="http://msdn.microsoft.com/en-us/library/aa372866.aspx" rel="nofollow noreferrer">Windows Installer SDK</a> or if you're wanting to take the lazy route, it looks like <a href="http://www.indigorose.com/msi-factory/features.php" re...
<p>I don't recommend writing your own exe, I would recommended using somethig you already have, the <a href="http://msdn.microsoft.com/en-us/magazine/cc163899.aspx" rel="nofollow noreferrer">Generic Boostrapper</a> that comes with Visual Studio. </p> <p>This separates the task of creating your msi. Creating the boos...
33,080
<p>I have a Windows Mobile application using the compact framework (NETCF) that I would like to respond to someone pressing the send key and have the phone dial the number selected in my application. Is there a way using the compact framework to trap the send key? I have looked at several articles on capturing keys,...
<p>I can confirm that using SHCMBM_OVERRIDEKEY works on both PPC and SP devices. I have tested it on WM5 PPC, WM5 SP, WM6 PPC, WM6 SP. I have not tried WM6.1 or WM6.5 yet but I kind-of assume that they work since WM6 works.</p> <p>Also you may need to support DTMF during the call as well?</p> <p>Since I was writing...
<p>Is there some particular reasoning behind not using the designated <a href="http://msdn.microsoft.com/en-us/library/aa446543.aspx" rel="nofollow noreferrer">PhoneMakeCall</a>? It's available for Smartphone and up to Windows Mobile 6 Professional.</p> <p>Edit: I misread the question a bit. I see now that you wanted ...
46,166
<p>I have an ASP.NET Site that has a single Master Page. On one of my pages in this site I display a PDF file as the content of the page.</p> <p>I need a way to know the size that I can make the PDF control so that I do not create a scroll bar for the webpage (the PDF control has it's own scroll bar).</p> <p>I was a...
<p>There's no way to determine this server-side, so you'll need to use JavaScript. I'd recommend the <a href="http://plugins.jquery.com/project/dimensions" rel="nofollow noreferrer">jQuery Dimensions plug in</a>.</p>
<p>If you do use JavaScript, however, there is a workaround where you can put that value into a HiddenField (Which of course JavaScript would see as an Input), and click a Submit button, all behind the scenes. If you use an UpdatePanel, you may be able to get away with a partial postback without user intervention.</p>...
27,533
<p>Is there a connection limit on Sql Server 2005 Developers Edition. We have many threads grabbing connections, and I know ADO.NET does connection pooling, but I get OutOfMemory exceptions. We take out the db connections and it works fine. </p>
<p>This is the response to that question on Euan Garden's (a Program Manager for Visual Studio Team Edition) blog:</p> <p><em>There are no limits in terms of memory, db size or procs for DE, it is essentially Enterprise Edition. There is however a licensing restriction that prevents it from being used in production.</...
<p>Are the out of memory exceptions from the .NET? If the error was on the server you would probably see a connection refused message instead.</p>
19,825
<p>I am using the <a href="https://jqueryui.com/dialog/" rel="noreferrer"><code>jquery-ui-dialog</code></a> plugin</p> <p>I am looking for way to refresh the page when in some circumstances when the dialog is closed.</p> <p>Is there a way to capture a close event from the dialog?</p> <p>I know I can run code when th...
<p>I have found it!</p> <p>You can catch the close event using the following code:</p> <pre><code> $('div#popup_content').on('dialogclose', function(event) { alert('closed'); }); </code></pre> <p>Obviously I can replace the alert with whatever I need to do.<br> <strong>Edit:</strong> As of Jquery 1.7, the bind...
<p>If I'm understanding the type of window you're talking about, wouldn't <b>$(window).unload()</b> (for the dialog window) give you the hook you need? <p> (And if I misunderstood, and you're talking about a dialog box made via CSS rather than a pop-up browser window, then <b>all</b> the ways of closing that window are...
20,729
<p>I'd like my application to have a full-screen mode. What is the easiest way to do this, do I need a third party library for this or is there something in the JDK that already offers this?</p>
<p>Try the <a href="http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html" rel="noreferrer">Full-Screen Exclusive Mode API</a>. It was introduced in the JDK in release 1.4. Some of the features include:</p> <blockquote> <ul> <li><strong>Full-Screen Exclusive Mode</strong> - allows you to suspend th...
<p>It really depends on what you're using to display your interface, i.e. AWT/Spring or OpenGL etc.</p> <p>Java has a full screen exclusive mode API - <a href="http://java.sun.com/docs/books/tutorial/extra/fullscreen/exclusivemode.html" rel="nofollow noreferrer">see this tutorial from Sun</a>.</p>
16,828
<p>I use the <kbd>Shift</kbd> + <kbd>F7</kbd> often to switch between source and design view.</p> <p>Does anyone know of a hotkey to switch between the <strong>source file</strong> and its <strong>code behind file</strong>, e.g. between (Default.aspx and Default.aspx.cs)?</p>
<p><kbd>F7</kbd></p>
<p>Try <kbd>Ctrl</kbd> + <kbd>PageUp</kbd> to toggle between design view and code behind.</p>
41,401
<p>What is the difference between <code>private</code> and <code>protected</code> members in C++ classes?</p> <p>I understand from best practice conventions that variables and functions which are not called outside the class should be made <code>private</code>—but looking at my MFC project, MFC seems to favor <code>pro...
<p>Private members are only accessible within the class defining them.</p> <p>Protected members are accessible in the class that defines them and in classes that inherit from that class.</p> <p>Edit: Both are also accessible by friends of their class, and in the case of protected members, by friends of their derived ...
<p>private and protected access modifiers are one and same only that protected members of the base class can be accessed outside the scope of the base class in the child(derived)class. It also applies the same to inheritance . But with the private modifier the members of the base class can only be accessed in the scope...
27,806
<p>What are the best open source image gallery engines? Both stand-alone, and for existing frameworks such as Wordpress or Drupal.</p> <p>Hopefully we can build a good list here over time.</p>
<p><a href="http://gallery.menalto.com" rel="nofollow noreferrer">Gallery</a> is the classic choice. It has skins, security layers, heaps of plugins, etc, but can be run with the default settings easily if you want to. I've used it for years.</p>
<p>GOOD QUESTION, lots of people ask this in many web forums so hopefully we will get some good responses to this, and have a good list of solutions.</p> <p>Personally I always used to say something like Gallery or some other OS script, but recently I have found myself using more and more something like a simple php s...
24,856
<p>I have a series of Extension methods to help with null-checking on IDataRecord objects, which I'm currently implementing like this:</p> <pre><code>public static int? GetNullableInt32(this IDataRecord dr, int ordinal) { int? nullInt = null; return dr.IsDBNull(ordinal) ? nullInt : dr.GetInt32(ordinal); } pub...
<p>You can just declare your method like this:</p> <pre><code>public static T GetNullable&lt;T&gt;(this IDataRecord dr, int ordinal) { return dr.IsDBNull(ordinal) ? default(T) : (T) dr.GetValue(ordinal); } </code></pre> <p>This way, if T is a nullable int or any other nullable value type, it will in fact return n...
<p>I do it this way:</p> <pre><code>DataRow record = GetSomeRecord(); int? someNumber = record[15] as int? Guid? someUID = record["MyPrimaryKey"] as Guid?; string someText = GetSomeText(); record["Description"] = someText.ToDbString(); // ........ public static class StringExtensionHelper { public static object ...
38,967
<p>I launch the following command line (process) from a Windows VC++ 6 program using CreateProcess (or _spawnv()):</p> <ul> <li>java -cp c:\dir\updates.jar;c:\dir\main.jar Main</li> </ul> <p>and class updates in updates.jar (overiding some in main.jar) are not read or found. It is as if the updates.jar library canno...
<p>Try using Microsoft's FileMon utility to figure out what's happening. Set the include filter to "updates" to focus in on the problem.</p> <p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx</a></p>
<p>Have you tried this on another machine? Another OS? Which JVM are you using? Have you tried different JVMs?</p> <p>Can you provide us with a minimal example which demonstrates the problem?</p>
35,210
<p>I have an app that I'm writing a little wizard for. It automated a small part of the app by moving the mouse to appropriate buttons, menus and clicking them so the user can watch.</p> <p>So far it moves the mouse to a tree item and sends a right-click. That pops up a menu via TrackPopupMenu. Next I move the mous...
<p>I didn't find a prefect way to do it, but the following works pretty well:</p> <pre><code>//in my case, the menu is a popup from a tree control created with: CMenu menu; menu.CreatePopupMenu(); //add stuff to the menu... pTreeCtrl-&gt;SetMenu(&amp;menu); m_hMenu = menu.GetSafeHmenu(); CPoint pt; GetCursorPos(&amp;...
<p>I expect you could generate the necessary click messages by calling <a href="http://msdn.microsoft.com/en-us/library/ms646310.aspx" rel="nofollow noreferrer"><code>SendInput</code></a>. Move the mouse over where the menu is, and then click.</p> <p>You might want to take a look at the <a href="http://msdn.microsoft....
41,322
<p>I have a query which is starting to cause some concern in my application. I'm trying to understand this EXPLAIN statement better to understand where indexes are potentially missing:</p> <pre> +----+-------------+-------+--------+---------------+------------+---------+-------------------------------+----...
<p>Well looking at the query would be useful, but there's at least one thing that's obviously worth looking into - the final line shows the ALL type for that part of the query, which is generally not great to see. If the suggested possible key (userfield) makes sense as an added index to table c, it might be worth addi...
<h3>Query Plan</h3> <p>The query plan we might hope the optimiser would choose would be something like: </p> <ul> <li>start with <code>sessions</code> where <code>partner_id=1</code> , possibly using an index on <code>partner_id,</code> </li> <li>join <code>sessions</code> to <code>users</code>, using an index on <c...
27,424
<p>I have been using CPPUnit as a unit testing framework and am now trying to use it in an automated build and package system. However a problem holding me back is that if a crash occurs during the running of the unit tests, e.g. a null pointer dereferencing, it halts the remainder of the automation.</p> <p>Is there ...
<p>You're automating the execution of your cppunit-based unit-tests during your build process, right ? </p> <p>If you were trying to use CppUnit to execute the build process, I would be tempted to say don't do that !</p> <p>Could you tell us what is stopping the build process when the unit tests crash ? And what are ...
<p>I didn't try it, but if in Windows, I guess use SEH would help:</p> <pre><code>__try { // running your case } __except { } </code></pre> <p>Integrate it into the CppUnit framework, and everytime receive an unknown exception, mark the case as fail.</p>
24,928
<p>I'm going to start maintaining an Eclipse RCP application for my current employer soon.<br/> What are your experiences with this platform? What are the pros, what are the cons, what are the caveats that I should be aware of?<br/> Also, what reading materials (books, tutorials) can you recommend? Most of the tutorial...
<ul> <li><a href="http://www.vogella.de/articles/RichClientPlatform/article.html" rel="nofollow noreferrer">Eclipse Rich Client Platform (RCP) with Eclipse Ganymede (3.4) - Tutorial</a></li> <li><a href="http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/CatalogSWT-JFace-Eclipse.htm" rel="nofollow noreferrer">JFace exam...
<p>The Programmer's Guide in the Eclipse Platform Plug-In Developer Guide (in Eclipse's F1 help and at <a href="http://help.eclipse.org/helios/index.jsp?nav=/2_0" rel="nofollow">http://help.eclipse.org/helios/index.jsp?nav=/2_0</a> for 3.6, the release current at this writing) has a lot of useful overview information a...
40,273
<p>I have a CSS rule like this:</p> <pre><code>a:hover { background-color: #fff; } </code></pre> <p>But this results in a bad-looking gap at the bottom on image links, and what's even worse, if I have transparent images, the link's background color can be seen through the image.</p> <p>I have stumbled upon this prob...
<p>I tried to find some selector that would get only <code>&lt;a&gt;</code> elements that don't have <code>&lt;img&gt;</code> descendants, but couldn't find any... About images with that bottom gap, you could do the following: </p> <pre><code>a img{vertical-align:text-bottom;} </code></pre> <p>This should get rid of...
<p>The following should work (untested):</p> <p>First you</p> <pre><code> a:hover { background-color: #fff; } </code></pre> <p>Then you</p> <pre><code>a:imagelink:hover { background-color: inherit; } </code></pre> <p>The second rule will override the first for &lt;a class="imagelink" etc.> and preserve the backgro...
34,518
<p>How should I describe this part which looks like a small gear so that I can research replacements?</p> <p><a href="https://i.stack.imgur.com/51BdD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/51BdD.jpg" alt="image of a pulley"></a></p> <p>This came with my FLSUN 3D printer, which may be based...
<p>This is a timing belt pulley.</p> <p>Specifically, is a GT2 timing pulley, 2&nbsp;mm pitch (between teeth), 6&nbsp;mm wide. The drive diameter is measured by the number of teeth (16 in this case) , the shaft diameter (bore) is measured in mm.</p> <p>The 'GT2' part refers to the tooth profile, some other examples a...
<p>It is an "aluminum timing pulley"</p> <p><a href="https://www.google.com/search?psb=1&amp;tbm=shop&amp;q=aluminum%20timing%20pulley&amp;ved=0CAMQr4sDKAFqFwoTCMis1KHmiuMCFRoMswAdMqUElxAB" rel="nofollow noreferrer">https://www.google.com/search?psb=1&amp;tbm=shop&amp;q=aluminum%20timing%20pulley&amp;ved=0CAMQr4sDKAF...
1,382
<p>Does anyone know of any existing packages or libraries that can be used to build a calendar in a django app? </p>
<p>A quick google search reveals <a href="https://github.com/justinlilly/django-gencal" rel="noreferrer">django-gencal</a>, which looks like exactly what you need. It would also be worth looking at the snippets under the calendar tag on Django Snippets at <a href="http://www.djangosnippets.org/tags/calendar/" rel="nor...
<p>Today I ran into <a href="http://code.google.com/p/django-swingtime/" rel="nofollow noreferrer">django-swingtime</a>. Worth checking out.</p>
6,710
<pre><code>@Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Problem { @ManyToOne private Person person; } @Entity @DiscriminatorValue("UP") public class UglyProblem extends Problem {} @Entity public class Person { @OneToMany(mappedBy="person") private List&lt; UglyProblem &gt...
<p>I think it's a wise decision made by the Hibernate team. They could be less arrogante and make it clear why it was implemented this way, but that's just how Emmanuel, Chris and Gavin works. :)</p> <p>Let's try to understand the problem. I think your concepts are "lying". First you say that many <strong>Problem</str...
<p>In my opinion @JoinColumn should at least provide an option to apply the @DiscriminatorColumn = @DiscriminatorValue to the SQL "where" clause, although I would prefer this behaviour to be a default one.</p> <p>I am very surprised that in the year 2020 this is still an issue. Since this object design pattern is not ...
5,899
<p>I need to write a java script. This is supposed to validate if the checkbox is selected in the page or not. The problem here is that the check box is inside a grid and is generated dynamically. The reason being the number of check box that need to be rendered is not know at design time. So the id is know only at the...
<p>Here is a thought:</p> <p>As indicated by Anonymous you can generate javascript, if you are in ASP.NET you have some help with the RegisterClientScriptBlock() method. <a href="http://msdn.microsoft.com/en-us/library/aa478975.aspx" rel="nofollow noreferrer">MSDN on Injecting Client Side Script</a></p> <p>Also you c...
<p>If it's your only checkbox you can do a getElementsByTagName() call to get all inputs and then iterate through the returned array looking for the appropriate type value (i.e. checkbox).</p>
14,570
<p>Are there C++ compilers already supporting <a href="http://en.wikipedia.org/wiki/C%2B%2B0x" rel="noreferrer">C++0x</a> <a href="http://en.wikipedia.org/wiki/Lambda_calculus" rel="noreferrer">lambda</a> expressions?</p>
<p><a href="https://connect.microsoft.com/VisualStudio/content/content.aspx?ContentID=9790" rel="noreferrer">Visual Studio 2010 CTP</a> supports it already.</p> <p><strong>Update:</strong> It is now <a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" rel="noreferrer">Visual Studio 2010 Beta 2</a></p>
<p>Intel C++ Compiler does, e.g. according to <a href="http://www.threadingbuildingblocks.org/documentation.php" rel="nofollow noreferrer">TBB</a> Tutorial.</p>
45,533
<p>I'm considering using PostgreSQL with a .Net web app. Basically 3 reasons:</p> <ol> <li>Mature Geo Queries</li> <li>Small footprint + Linux</li> <li>Price</li> </ol> <p>I'm wondering a bit about tools though, SQL Server Profiler and query plans and performance monitors have been helpful. How is this world with Pos...
<p>Postgres comes with pgAdmin, which does graphical explains to help you optimise queries. Entering your query in an SQL entry pane and pressing F7 gives you a really clear indication of how the query is planned and executed. More on this, here:</p> <p><a href="http://www.postgresonline.com/journal/index.php?/archi...
<p>I would consider MS SQL because of LINQ to SQL.</p> <p>There is dbLinq which is still in early alpha, but it works for very simple queries.</p>
39,120
<p>I want to assert that a method is called exactly one time. I'm using RhinoMocks 3.5.</p> <p>Here's what I thought would work:</p> <pre class="lang-cs prettyprint-override"><code>[Test] public void just_once() { var key = "id_of_something"; var source = MockRepository.GenerateStub&lt;ISomeDataSource&gt;(...
<p>Here's how I'd verify a method is called once.</p> <pre class="lang-cs prettyprint-override"><code>[Test] public void just_once() { // Arrange (Important to GenerateMock not GenerateStub) var a = MockRepository.GenerateMock&lt;ISomeDataSource&gt;(); a.Expect(x =&gt; x.GetSomethingThatTakesALotOfResour...
<p>Having a feature called "Exactly" would be handy to write tests on code that might otherwise get into an infinite loop. I would love to write a test such that the second call to a method would raise an exception.</p> <p>Some libraries for python allow you to sequence expectations, so the first returns false and th...
36,346
<p>I am currently developing a Rails application using a database that was designed before I was aware of Rails existence.<br> I have currently created some migrations to add some new tables and new columns to existing tables.</p> <p>I would like to have the migrations to recreate the full database.</p> <p>Which step...
<p>I think this will require some manual work.</p> <p>You can start out by running <code>rake db:schema:dump</code> if you do not have the file <code>db/schema.rb</code> in your project. You probably already have a <code>db/schema.rb</code> file if you have been using migrations. That file will contain the ruby repr...
<p>Short answer: Yes</p> <p>Long answer: It depends on how the database was setup and how far it differs from your current one. Also, because I am assuming that the ID's are generated dynamically - if you move from one table to another make sure that all of your foreign keys are updated correctly.</p> <p>Write a scri...
23,070
<p>table data of 2 columns "category" and "subcategory"</p> <p>i want to get a collection of "category", [subcategories] using code below i get duplicates. Puting .Distinct() after outer "from" does not help much. What do i miss?</p> <pre><code> var rootcategories = (from p in sr.products ...
<p>solved with this code</p> <pre><code> var rootcategories2 = (from p in sr.products group p.subcategory by p.category into subcats select subcats); </code></pre> <p>thanks everyone</p>
<p>Your main query is on Products, so you're going to get records for each product. Switch it around so you're querying on Category, but filtering on Product.Category</p>
34,818
<p>PHP treats all arrays as associative, so there aren't any built in functions. Can anyone recommend a fairly efficient way to check if an array <em>&quot;is a list&quot;</em> (contains only numeric keys starting from 0)?</p> <p>Basically, I want to be able to differentiate between this:</p> <pre><code>$sequentialArra...
<p>You have asked two questions that are not quite equivalent:</p> <ul> <li>Firstly, how to determine whether an array has only numeric keys</li> <li>Secondly, how to determine whether an array has <em>sequential</em> numeric keys, starting from 0</li> </ul> <p>Consider which of these behaviours you actually need. (I...
<p>One cheap and dirty way would be to check like this:</p> <pre><code>isset($myArray[count($myArray) - 1]) </code></pre> <p>...you might get a false positive if your array is like this:</p> <pre><code>$myArray = array("1" =&gt; "apple", "b" =&gt; "banana"); </code></pre> <p>A more thorough way might be to check th...
20,895
<p>I have always wondered how people update a previous line in a command line. a great example of this is when using the wget command in linux. It creates an ASCII loading bar of sorts that looks like this:</p> <blockquote> <p>[======>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs...
<p>There are two ways I know of to do this:</p> <ul> <li>Use the backspace escape character ('\b') to erase your line</li> <li>Use the <code>curses</code> package, if your programming language of choice has bindings for it.</li> </ul> <p>And a Google revealed <a href="http://en.wikipedia.org/wiki/ANSI_escape_code" re...
<p>If your using a scripting language you could use the "tput cup" command to get this done... P.S. This is a Linux/Unix thing only as far as I know...</p>
8,506
<p>I am doing a project at the moment, and in the interest of code reuse, I went looking for a library that can perform some probabilistic accept/reject of an item: </p> <p>i.e., there are three people (a, b c), and each of them have a probability P{i} of getting an item, where p{a} denotes the probability of a. These...
<p>Would something like this do? Put all p{i}'s in the array, function will return an index to the person who gets the item. Executes in O(n).</p> <pre><code>public int selectPerson(float[] probabilies, Random r) { float t = r.nextFloat(); float p = 0.0f; for (int i = 0; i &lt; probabilies.length; i++) { ...
<p>i just tested out the method above - its not perfect, but i guess for my purposes, it ought to be enough. (code in groovy, pasted into a unit test...)</p> <pre><code> void test() { for (int i = 0; i &lt; 10; i++) { once() } } private def once() { def double[] probs = [...
15,406
<p>I am using cocos2d-iphone to place Sprites onto a Layer to setup a game playfield. At certain points in the game, certain Sprites need to be removed based upon game conditions. What I would like to do is setup an array of Sprite pointers, but I have two questions:</p> <p>What's the best way to place Sprite pointe...
<p>The <code>Sprite</code> class inherits from <code>CocosNode</code>, so you should be able to call <code>spritePointer.parent.remove(spritePointer)</code></p>
<p>I figured it out. If anyone else is interested, the way to do it is to declare an array of Sprite pointers, such as: </p> <pre><code>Sprite * mySprites[10][10]; // assuming a 10x10 playfield where obstacles get placed </code></pre> <p>Then, when setting up your Sprites: </p> <pre><code>mySprites[0][0] = [Sprit...
41,596
<p>I need a reasonably smart algorithm to come up with "nice" grid lines for a graph (chart).</p> <p>For example, assume a bar chart with values of 10, 30, 72 and 60. You know:</p> <p>Min value: 10 Max value: 72 Range: 62</p> <p>The first question is: what do you start from? In this case, 0 would be the intuitive ...
<p>I've done this with kind of a brute force method. First, figure out the maximum number of tick marks you can fit into the space. Divide the total range of values by the number of ticks; this is the <i>minimum</i> spacing of the tick. Now calculate the floor of the logarithm base 10 to get the magnitude of the tick,...
<p>In R, use</p> <pre><code>tickSize &lt;- function(range,minCount){ logMaxTick &lt;- log10(range/minCount) exponent &lt;- floor(logMaxTick) mantissa &lt;- 10^(logMaxTick-exponent) af &lt;- c(1,2,5) # allowed factors mantissa &lt;- af[findInterval(mantissa,af)] return(mantissa*10^exponent) } </...
47,205
<p>I'm needing to check the differences between two XMLs but not "blindly", Given that both use the same DTD, I'm actually interested in verifying wether they have the same amount of elements or if there's differences.</p>
<ul> <li><a href="http://www.logilab.org/859" rel="nofollow noreferrer">xmldiff</a> from Logilab</li> <li><a href="http://diffxml.sourceforge.net/" rel="nofollow noreferrer">diffxml</a> </li> <li>A commercial one include in <a href="http://www.altova.com/products/xmlspy/xml_differencing.html" rel="nofollow noreferrer">...
<p><a href="http://www.oxygenxml.com/xml_diff_and_merge.html" rel="nofollow noreferrer">oXygen</a> has good XML diff (and merge) support.</p>
8,918
<p>I am building a product that we are eventually going to white-label. Right now I am trying to figure out the best way to facilitate these requirements programmatically so the user can update the basic design of the site (ie header color, etc) via their profile/settings form. </p> <p>Requirements: </p> <ol> <li>Use...
<p>I've been there some months ago. While using dynamic CSS generated by a dedicated handler / servlet has been the first solution, to improve performances a customized CSS is now produced on file overrinding the basic elements of the standard CSS:</p> <pre><code>&lt;link rel="stylesheet" href="standard.css" /&gt; &lt...
<p>I would avoid using the !important clause and instead just ensure their values appear in a <code>&lt;style&gt;</code> tag following the import of the regular style sheets.</p> <p>Otherwise, I would do it the same way.</p>
21,563
<p>I'm looking for a Windows network emulator that can emulate the packet-loss &amp; latency characteristics of a 3G wireless network. </p> <p>I used to use a tool from GIPs that has been end-of-life'd. I've also tried Shunra Virtual Enterprise but found it a bit too basic</p>
<p>There's a FreeBSD tool called dummynet that can do this. Since you have a Windows setup, you could put it on a separate box and route through it for testing, or perhaps even run it on a VM on your Windows machine. I know of no Windows solution to this problem, but perhaps others will.</p>
<p>Have you tried LANforge ICE for Windows? <a href="http://www.candelatech.com/lanforge_v3/datasheet.html#ice" rel="nofollow noreferrer">http://www.candelatech.com/lanforge_v3/datasheet.html#ice</a></p>
14,335
<p>The company I work for is starting to have issues with their current branching model and I was wondering what different kinds of branching strategies the community has been exposed to?</p> <p>Are there any good ones for different situations? What does your company use? What are the advantages and disadvantages of...
<p>Here is the method I've used in the past with good success:</p> <p>/trunk - bleeding edge. Next major release of the code. May or may not work at any given time.</p> <p>/branches/1.0, 1.1, etc. Stable maintenance branches of the code. Used to fix bugs, stabilize new releases. If a maintenance branch, it shoul...
<p>For Subversion, I agree with Ryan Duffield's comment. The chapter he refers to provides a good analyses on which system to use.</p> <p>The reason I asked is that Perforce provides a completely different way to create branches from SVN or CVS. Plus, there are all the DVCSs that give it's own philosophy on branchin...
5,537
<p>I need to create a database to store simulation results. What resources are out there to help me design this?</p> <p>EDIT: For those who want more details...</p> <p>We work with a discrete event simulation used by the military. Important simulation events are thus when weapons are fired, when kills occur, and al...
<p>Provide the following and you'll get a helpful answer</p> <ol> <li>Database type (MsSQL, MySQL etc)</li> <li>Any other languages you are using with this (C#, PHP)</li> <li>The data you want to store</li> <li>What you plan to do with the data (it may affect how best to store and query it), this step is very optional...
<p>Often, we write down the use cases -- who's going to use it and what they're going to do.</p> <p>Sometimes, we write down the things that will be in the database. The entities, their attributes, and the different things the entities do.</p> <p>Once we have some basic background, we often draw diagrams of the enti...
17,377
<p>The situation is this: I have a USB device (a custom device I'm trying to talk to) with two endpoints, one writing to the device, one reading from the device. Both are bulk transfers. Every communication transaction takes the form of (1) Write a command to the device (2) Read the response. I'm using libusb (version ...
<p>Turns out it was a misconfiguration in the descriptors on the device itself. lsusb -v showed an extra interface which was never used, which had a single isochronous endpoint 0x81. Since this was never used (and had never been tested as far as I could see, so quite possibly not even defined correctly) I removed it fr...
<p>You can try <a href="http://www.jungo.com/st/windriver_usb_pci_driver_development_software.html" rel="nofollow noreferrer">WinDriver</a> it's a commercial tool but have free full function evaluation (somehow time limited). You can check with WinDriver and if problem is reproducible it's might be device or your proto...
21,965
<p>On my OS X box, the kernel is a 32-bit binary and yet it can run a 64-bit binary. How does this work?</p> <pre><code>cristi:~ diciu$ file ./a.out ./a.out: Mach-O 64-bit executable x86_64 cristi:~ diciu$ file /mach_kernel /mach_kernel: Mach-O universal binary with 2 architectures /mach_kernel (for architecture i386):...
<p>The CPU can be switched from 64 bit execution mode to 32 bit when it traps into kernel context, and a 32 bit kernel can still be constructed to understand the structures passed in from 64 bit user-space apps.</p> <p>The MacOS X kernel does not directly dereference pointers from the user app anyway, as it resides it...
<p>For the kernel to be 64-bit would only bring the effective advantage that kernel extensions (i.e., typically drivers) could be 64-bit. In fact, you'd need to have either all 64-bit kernel extensions, or (as is the case now) all 32-bit ones; they need to be native to the architecture of the running kernel.</p>
7,255
<p>I have something like this:</p> <pre> barProgress.BeginAnimation(RangeBase.ValueProperty, new DoubleAnimation( barProgress.Value, dNextProgressValue, new Duration(TimeSpan.FromSeconds(dDuration))); </pre> <p>Now, how would you stop that animation (the <code>DoubleAnimation</code>)? The reason I want to do ...
<p>To stop it, call <code>BeginAnimation</code> again with the second argument set to <code>null</code>.</p>
<p>You can use this code:</p> <pre><code>[StoryBoardName].Remove([StoryBoardOwnerControl]); </code></pre>
4,066
<p>I have the following Clojure code and I'm not sure why it's not working:</p> <pre><code>(defn match (x y &amp;optional binds) (cond ((eql x y) (values binds t)) ((assoc x binds) (match (binding x binds) y binds)) ((assoc y binds) (match x (binding y binds) binds)) ((var? x) (values (cons (cons x y) bi...
<p>The problem is that I'm using parentheses ('(' and ')'), rather than square brackets ('[' and ']'), for the arguments list.</p> <p>It should start out like this:</p> <pre><code>(defn match [x y &amp;optional binds] </code></pre> <p>(I found the answer in <em>Programming Clojure</em> by Stuart Halloway.)</p>
<p>This seems to be a symptom for various syntax errors.</p> <p>I've had it when accidentally writing a <code>.</code> after the docstring, i.e. <code>"bla bla".</code> instead of <code>"bla bla."</code>. It was rather hard to find, because the line number in the error message was incorrect.</p>
48,205
<p>I was given a MySQL database file that I need to restore as a database on my Windows Server 2008 machine.</p> <p>I tried using MySQL Administrator, but I got the following error:</p> <blockquote> <p>The selected file was generated by mysqldump and cannot be restored by this application.</p> </blockquote> <p...
<p>It should be as simple as running this: </p> <pre><code>mysql -u &lt;user&gt; -p &lt; db_backup.dump </code></pre> <p>If the dump is of a single database you may have to add a line at the top of the file:</p> <pre><code>USE &lt;database-name-here&gt;; </code></pre> <p>If it was a dump of many databases, the use ...
<h1>How to Restore MySQL Database with MySQLWorkbench</h1> <p>You can run the drop and create commands in a query tab.</p> <h2>Drop the Schema if it Currently Exists</h2> <pre class="lang-sql prettyprint-override"><code>DROP DATABASE `your_db_name`; </code></pre> <h2>Create a New Schema</h2> <pre class="lang-sql p...
13,130
<p>What system do you recommend for implementing "automatic updates" for some java (desktop) application? I'd also want to have module/plugin installation and update. Think Eclipse and Firefox.</p> <p>I'm aware of Eclipse RCP's OSGi stuff, and also NetBeans RCP has something here. Do one have to buy wholly into their ...
<p>Have you looked at the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/javaws/developersguide/faq.html" rel="noreferrer">Java Web Start</a>? It checks for updated module on the server and downloads it only if required otherwise things are cached locally on the client PC and starts from there.</p>
<p>It is not like plugin system. But it has updating and installing function for desktop app. You can look by link <a href="https://github.com/gdevby/desktop-starter-launch-update-bootstrap" rel="nofollow noreferrer">this</a></p>
39,287
<p>I've got an issue when accessing a web site, I can access it by using the NetBIOS name, but when accessing with the FQDN i get an error. </p> <p>Any ideas on how to troubleshoot this?</p> <p>(There is no DNS configured yet, we have modified the Hosts file to enter the related names and IP.)</p>
<p>First, check the obvious: are there any typos in the file?</p> <p>Next, test out the name resolution. Something simple like pinging the web server by it's FQDN will do. See if the right IP is mentioned.</p> <ul> <li>If you get "unknown host", your client's hosts file does not have an entry for the FQDN you entered...
<p>Just to make sure, you have something like this</p> <pre><code>192.168.100.5 othermachine othermachine.mydomain.local </code></pre> <p>with both the netbios and the FQDN in it and not just the IP and netbios name?</p>
19,921
<p>I was looking at WF and was wondering if it would be best to use the StateMachine workflow to follow a users state. i.e. user is anonymous, user is known but not authenticated, user is known and authenticated.</p> <p>would this be a good way to go about solving this regular issue?</p>
<p>No, I think that it is completely inappropriate. Please see these questions for more info:</p> <ul> <li><a href="https://stackoverflow.com/questions/115124/what-are-your-experiences-with-windows-workflow-foundation">What are your experiences with Windows Workflow Foundation?</a></li> <li><a href="https://stackoverf...
<p>In my experience, WF is far too heavyweight for any such use - it is too difficult to do simple things with it. It is useless for this scenario.</p> <p>I'd certainly be interested in opposite experiences, though - has anyone successfully used WF on a small scale in a simple project? Workflows and state machines are...
16,866
<p>I need to create a unique ID for a given location, and the location's ID must be sequential. So its basically like a primary key, except that it is also tied to the locationID. So 3 different locations will all have ID's like 1,2,3,4,5,...,n</p> <p>What is the best way to do this? I also need a safe way of getti...
<p>One of the ways I've seen this done is by creating a table mapping the location to the next ID.</p> <pre><code>CREATE TABLE LocationID { Location varchar(32) PRIMARY KEY, NextID int DEFAULT(1) } </code></pre> <p>Inside your stored procedure you can do an update and grab the current value while also increme...
<p>If this doesn't need to be persisted, you could always do this in your query versus storing it in the table itself.</p> <pre><code>select locationID ,row_number() over (partition by locationID order by (select null)) as LocationPK From YourTable </code></pre>
18,814
<p>I have a .net transaction with a SQL insert to a SQL Server 2005 database. The table has an identity primary key. </p> <p>When an error occurs within the transaction, <code>Rollback()</code> is called. The row inserts are rolled back correctly, however the next time I insert data to the table, the identity is incre...
<p>If you think about it, the auto-increment number <strong>should not</strong> be transactional. If other transactions had to wait to see if the auto-number was going to be used or "rolled back", they would be blocked by the existing transaction using the auto-number. For example, consider my psuedo code below with ...
<p>Muhan try to think of it in the context of many simultaneous connections executing this transaction and not one at a time. Some will fail and some will succeed. You want SQL Server to concentrate on running the new requests as they come in and not on maintaining a gap-less identity column. IMO it (gaps in the val...
35,768
<p>So, I have the following rows in the DB:</p> <p>1 | /users/</p> <p>2 | /users/admin/</p> <p>3 | /users/admin/*</p> <p>4 | /users/admin/mike/</p> <p>5 | /users/admin/steve/docs/</p> <p>The input URL is <strong>/users/admin/steve/</strong>, and the goal is to find the URL match from the DB.</p> <p>I want to ret...
<p>Here's how I'd do it:</p> <pre><code>SELECT * FROM mytable AS m WHERE &lt;input-url&gt; = m.urlpattern OR &lt;input-url&gt; REGEXP REPLACE(m.urlpattern, '*', '.*'); </code></pre> <p>The REPLACE() is to change the globbing-style wildcard into an equivalent regular-expression wildcard.</p>
<p>If I understand this correctly, something like this should work: </p> <p>SELECT COALESCE( </p> <blockquote> <p>(SELECT whatever FROM your query to see if there is an exact url),<br> (SELECT next approximation),<br> 'SOL'</p> </blockquote> <p>)</p>
47,624
<p>I export my settings in Visual Studio and if I ever move to a new machine or have problems, I use those backed up settings to restore Visual Studio to the way I like it. It also allows me to maintain a consistent development environment between the various machines that I use.</p> <p>This works great for keybinding...
<p>I have finally found the solution to this. There is a <a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=105493" rel="noreferrer">known bug in Visual Studio</a> and there are <a href="http://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?FeedbackID=105493" rel="nore...
<p>I have not tried it, but "Tools\Import and Export Settings..." maybe will let you export a .vssettings file you can then take to another box.</p> <p>See also</p> <p><a href="http://blogs.msdn.com/saraford/archive/2005/04/19/409887.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/saraford/archive/2005/04/19/40...
37,150
<p>I want to know how to set the height property for the HTML <code>&lt;select&gt;</code> in code.</p> <p>I tried setting <code>.Attribute.Add("Style","Height:120px")</code> just to see if I could get it to change but to no avail.</p>
<p>Better yet, give it a CssClass. :)</p>
<p>Style is already a Property...</p> <pre><code>DropDownList myDropDown; myDropDown.Style["height"] = "120px"; </code></pre>
22,981
<p>I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large...
<p><a href="http://cherrypy.org/" rel="noreferrer">CherryPy</a>. Features, as listed from the website:</p> <ul> <li>A fast, HTTP/1.1-compliant, WSGI thread-pooled webserver. Typically, CherryPy itself takes only 1-2ms per page!</li> <li>Support for any other WSGI-enabled webserver or adapter, including Apache, IIS, li...
<p>Just to point out something different from the usual suspects...</p> <p>Some years ago while I was using <a href="http://zope.org/" rel="nofollow noreferrer">Zope</a> 2.x I read about <a href="http://www.nightmare.com/medusa/medusa.html" rel="nofollow noreferrer">Medusa</a> as it was the web server used for the pla...
26,245
<p>In my website (under development), the members can send messages to each other which are sent directly to their email, now I'm worried that some members can send spam to other members (I have a spam filter but it doesn't give 100% protection as you know), I'm worried that my domain might get blacklisted on Yahoo, Gm...
<p>Your email might not be considered "bulk" because it sounds like it's one->one as opposed to one->many, but these bulk mail help resources might still be helpful:</p> <ul> <li><a href="http://help.yahoo.com/l/us/yahoo/mail/postmaster/forms_index.html" rel="nofollow noreferrer">Yahoo! Mail Postmaster Help</a></li> <...
<p>While there may be whitelists used by those sites, I suspect that they only contribute to whatever scoring system is in use - being on the list won't be sufficient in itself.</p> <p>The overall controlling factor will be the "reputation" of your site - you need to work to ensure that reputation stays sound.</p> <p...
37,650
<p>What is the best way to display a checkbox in a Crystal Report?</p> <p>Example: My report has a box for "Male" and "Female", and one should be checked.</p> <p>My current workaround is to draw a small graphical square, and line it up with a formula which goes like this:</p> <pre><code>if {table.gender} = "M" then ...
<p>Try a pair of images with a conditional formula for visibility</p>
<p>2 pictures<br> 1 - Empty box<br> 2 - Checked box</p> <p>Display the right picture with a formula</p>
35,379
<p>I currently have an application which needs to have an awareness of which monitor the cursor is located when running in a multi-monitor configuration. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms648390.aspx" rel="noreferrer">GetCursorPos</a> and <a href="http://msdn.microsoft.com/en-us/library/ms534603.aspx" rel="noreferrer">MonitorFromPoint</a>.</p>
<p>Don't forget Screen.MonitorFromPoint and Mouse.CursorPos - these WinAPI functions are encapsulated in the VCL.</p>
28,411
<p>In a flow definition, I am trying to access a bean that has a dot in its ID</p> <p>(example: <code>&lt;evaluate expression="bus.MyServiceFacade.someAction()" /&gt;</code></p> <p>However, it does not work. SWF tries to find a bean "bus" instead.</p> <p>Initially, I got over it by using a helper bean to load the re...
<p>I was able to do this by using both the bean accessor (<code>@</code>) symbol and single-quotes around the name of the bean.</p> <p>Using your example: <code>#{@'bus.MyServiceFacade'.someAction()}</code></p>
<p>In my experience, anything with a getter method can be accessed via dot notation. In your example, whatever object is being represented by the <code>bus</code> bean needs to have a <code>getServiceFacade</code> method and that the object returned by <code>getServiceFacade</code> would need to have a <code>getSomeAc...
8,821
<p>Does the opening Window enhance an application's attractiveness? Should it be a picture or bland Blue and White?</p>
<p>Use the default OS theme colors. Anything else will be attractive to certain groups of people, and ugly to others (who will complain <em>very loudly</em> about how ugly they find it). If you stick with the OS theme colors, then at least your application's appearance will not be something you'll be criticized over....
<p>Some people like it clean and nice, while others consider stylish themes to be positive and nice to have. You gotta consider who your application is pointed towards and do what that group is interested in. </p>
40,957
<p>We have a browser based application which integrates a webdav server. We generate URLs to specific documents on our (webdav) servlet. (<code>https://server.com/webdav/path/to/file.doc</code>)</p> <p>What we are looking for is a good way for our clients to open these links directly in the appropriate program. I.E. f...
<p>I don't believe there is a way... You would have to either be able to walk the Heap, and examine every object there, or walk the stack of every active thread in the application process space, examining every stack reference variable on every thread... </p> <p>The other way, (I am guessing you can't do) is intercept...
<pre><code>IEnumerable&lt;Type&gt; GetAllTypesThatImplementInterface&lt;T&gt;() { var @interface = typeof (T); return @interface.IsInterface ? AppDomain.CurrentDomain.GetAssemblies() .SelectMany(assembly =&gt; assembly.GetTypes()) .Where(type =&gt; !type....
38,854
<p>This discussion started <a href="https://stackoverflow.com/questions/155084/flash-rendering-optimisation-tips-and-tricks">over here</a> but I thought it would be nice to have a definitive answer...</p> <p>So let's say you have MovieClip on the Stage (or a UIComponent for the Flex audience) - what do you have to do ...
<p>The hack is for Flash 8 (Actionscript 2) or below. With the upgrades to Actionscript 3 and Flex 2/3 setting the visible property is enough.</p>
<p>If you're using Flex and its container layout system, the <a href="http://livedocs.adobe.com/flex/3/langref/mx/core/IUIComponent.html#includeInLayout" rel="nofollow noreferrer">includeInLayout</a> property in the <code>UIComponent</code> class is also useful when you don't want to display something: it specifies whe...
20,541
<p>I wish to create an online system to track some things (e.g., a database with children, where each child has 1 or more visits from doctors). I want the users to be able to enter data as well as search for it, especially from mobile devices. So, this is a custom mobile online DB app of modest but non-zero size.</p> ...
<p>from the superficial description this sounds like a trivial web application, the "easiest" path will be to use the tools that you already know well</p> <p>[people are most likely just going to recommend the tools they like/use, which while 'easiest' for them may have no bearing on your results]</p>
<p>I'd for <a href="http://code.google.com/appengine/" rel="nofollow noreferrer">Google App Engine</a> (server side code is written in Python, db is on the Google's infrastructure); I think it respects your requirements:</p> <ul> <li>ease of initial development: Python is the simplest language ever</li> <li>ease and l...
42,284
<p>I'm optimizing a directx graphics application to take advantage of nVidia's SLI technology. I'm currently investigating some of the techniques mentioned in their 'Best Practices' web page, but wanted to know what advice/experience any of you have had with this? </p> <p>Thanks!</p>
<p>This is not really an answer to you question, more of a comment on SLI. </p> <p>My understanding is that SLI is only really a cost-effective means of gaining performance when you buy two cards right away, which few people actually do. Many people buy an SLI motherboard and card thinking it will give them a better u...
<p>The one thing SLI can do that having two non-SLIed graphics can't do is Nvidia Surround. </p> <p>In some games this will allow you to play the game at 1080x(3x1920). So you can play the game on three monitors as if it was one.</p> <p>The disadvantage that I have found to SLI is</p> <p>A) It limits the number of m...
39,825
<p>pdb and winpdb both seem to be missing this essential (to me) feature. I saw something suggesting WingIDE has it but I'd prefer a solution that is free, and if I do have to pay, I'd prefer to pay for something that is better than Wing.</p>
<p>Please look what pydev in eclipse offers...</p>
<p>Take a look at <a href="http://mmm-experts.com/Products.aspx?ProductID=4" rel="nofollow noreferrer">PyScripter</a>. It has an integrated debugger, watch windows and much more. It's open source and is developed <a href="http://pyscripter.googlepages.com/" rel="nofollow noreferrer">here</a>.</p> <p>HTH</p>
25,492
<p>This is a subjective question, but I need opinions.</p> <p>I have a WinForms C# application whose window hides itself after a specific keystroke (Enter or Escape), with possible modifiers (e.g. Ctrl-Enter). When hiding on KeyDown or KeyPress, the other application that becomes active after my window hides itself re...
<p>This is a hack, but you can set the state of your program to "pending hide" when receive the key down. And then when you get the key up for that sequence, reset the "pending state" and then hide. </p> <p>Alternatively, can you just "eat" the key up off the message queue after you receive the key down?</p> <p>I w...
<p>Well, I'd say "Don't worry about it, until it becomes a problem", but I guess it is a problem now....</p> <p>In that case, I would hide on KeyPress (the expected user experience), but grab the focus until you get a KeyUp (or until a short timeout).</p>
37,907
<p>Do you know of any tool that would do like Ruby on Rails' Scaffolding (create simple CRUD pages for any particular class to allow quickly populating a database with dummy data), only which used Java classes with Hibernate for database access, and JSP/JSF for the pages?</p> <p>It is a drag when you are programming o...
<p><a href="http://grails.org/" rel="nofollow noreferrer">Grails</a> is a very nice Rails-like framework built on top of Spring MVC. For persistence, they use <a href="http://grails.org/GORM" rel="nofollow noreferrer">GORM</a>, which is basically an ActiveRecord-like framework built on top of Hibernate. Pretty slick....
<p>Grails is somewhat different from Rails, even though it was based on Rails and has a similar feel. Grails uses spring to help wire your services together. The environment is not only dynamic (with Groovy) but also allows you to use Java (static environment) as well. It is really cool, especially if you're coming fro...
31,848
<p>Is there a standard library method that converts a string that has duration in the standard ISO 8601 Duration (also used in XSD for its <code>duration</code> type) format into the .NET TimeSpan object?</p> <p>For example, P0DT1H0M0S which represents a duration of one hour, is converted into New TimeSpan(0,1,0,0,0)....
<p>This will convert from xs:duration to TimeSpan:</p> <pre><code>System.Xml.XmlConvert.ToTimeSpan("P0DT1H0M0S") </code></pre> <p>See <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlconvert.totimespan.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.xml.xmlconvert.totimespan.aspx</...
<p>As @ima dirty troll said TimeSpan translates always years as 365 days and months as 30 days.</p> <pre><code>TimeSpan ts = System.Xml.XmlConvert.ToTimeSpan("P5Y"); DateTime now = new DateTime(2008,2,29); Console.WriteLine(now + ts); // 27/02/2013 0:00:00 </code></pre> <p>To address it you should add each field indi...
8,829
<p>Are there any libraries, pieces of code or suchlike that'll let me play <a href="http://en.wikipedia.org/wiki/ZX_Spectrum" rel="nofollow noreferrer">ZX Spectrum</a> .ay files in my XNA Game Studio games?</p>
<p>You should convert .ay files to wav first. There is a program <a href="http://ldesoras.free.fr/prod.html#src_ay3hacking" rel="noreferrer">here</a> to do that. It also comes with source code so someone who have some free time might help by creating a content importer &amp; processor from it? :-)</p>
<p>If you need sound in XNA, and want XBOX 360 support you need to use the supported file formats. You are properbly better of by trying to convert the .ay files to a format that XNA natively support.</p> <p>If you only want to support Windows, then search for a .NET Library that can play them, it will work in XNA on ...
13,616
<p>I have a SQL Insert query inside a stored proc, for inserting rows into a <strong>linked server</strong> table.</p> <p>Since the stored proc is getting called within a parent transaction, this Insert statement tries to use a DTC for inserting rows into the linked server.</p> <p>I would like to <strong>avoid</stron...
<p>My suggestion is that you store whatever you want to insert into a staging table, and once the procedure is over run the cross server insert. To my knowledge there is no way of ignoring the transaction you are in once you are within the SProc execution. </p> <p>In contrast, if you use .NET 2.0's System.Transactio...
<p>Try using openquery to call the linked server query/sp instead of direct calling That worked for me</p> <p>so instead of insert into ... select * from mylinkedserver.pubs.dbo.authors</p> <p>e.g. DECLARE @TSQL varchar(8000), @VAR char(2) SELECT @VAR = 'CA' SELECT @TSQL = 'SELECT * FROM OPENQUERY(MyLinkedServer,''...
10,202
<p>As a <a href="http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29" rel="noreferrer">C#</a> developer I'm used to running through constructors:</p> <pre class="lang-cs prettyprint-override"><code>class Test { public Test() { DoSomething(); } public Test(int count) : this() { ...
<p><strong>C++11: Yes!</strong></p> <p>C++11 and onwards has this same feature (called <a href="https://secure.wikimedia.org/wikipedia/en/wiki/C++11#Object_construction_improvement" rel="noreferrer">delegating constructors</a>). </p> <p>The syntax is slightly different from C#:</p> <pre><code>class Foo { public: ...
<p>Would be more easy to test, than decide :) Try this:</p> <pre><code>#include &lt;iostream&gt; class A { public: A( int a) : m_a(a) { std::cout &lt;&lt; "A::Ctor" &lt;&lt; std::endl; } ~A() { std::cout &lt;&lt; "A::dtor" &lt;&lt; std::endl; } public: int m_a; }; class B ...
39,702
<p>I tried this XAML:</p> <pre><code>&lt;Slider Width="250" Height="25" Minimum="0" Maximum="1" MouseLeftButtonDown="slider_MouseLeftButtonDown" MouseLeftButtonUp="slider_MouseLeftButtonUp" /&gt; </code></pre> <p>And this C#:</p> <pre><code>private void slider_MouseLeftButtonDown(object sender, MouseButtonEventArgs ...
<p>Sliders swallow the MouseDown Events (similar to the button).</p> <p>You can register for the PreviewMouseDown and PreviewMouseUp events which get fired before the slider has a chance to handle them.</p>
<p>I'd like to mention that the Slider doesn't quite swallow the entire MouseDown event. By clicking on a tick mark, you <em>can</em> get notified for the event. The Slider won't handle MouseDown events unless they come from the slider's... slider.</p> <p>Basically if you decide to use the</p> <pre><code>AddHandler(S...
19,458
<p>What are Null Pointer Exceptions (<code>java.lang.NullPointerException</code>) and what causes them?</p> <p>What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?</p>
<p>There are two overarching types of variables in Java:</p> <ol> <li><p><em>Primitives</em>: variables that contain data. If you want to manipulate the data in a primitive variable you can manipulate that variable directly. By convention primitive types start with a lowercase letter. For example variables of type <cod...
<p>A <code>null</code> pointer is one that points to nowhere. When you dereference a pointer <code>p</code>, you say "give me the data at the location stored in "p". When <code>p</code> is a <code>null</code> pointer, the location stored in <code>p</code> is <code>nowhere</code>, you're saying "give me the data at th...
26,866
<p>I'm currently refactoring code to replace Convert.To's to TryParse.</p> <p>I've come across the following bit of code which is creating and assigning a property to an object.</p> <pre><code>List&lt;Person&gt; list = new List&lt;Person&gt;(); foreach (DataRow row in dt.Rows) { var p = new Person{ RecordID = C...
<p>Write an extension method.</p> <pre><code>public static Int32? ParseInt32(this string str) { Int32 k; if(Int32.TryParse(str, out k)) return k; return null; } </code></pre>
<p>I suggest separate the TryParse part from initializer. It will be more readable.</p> <pre><code>int recordId; Int32.TryParse(row["ContactID"].ToString(), out recordID) foreach (DataRow row in dt.Rows) { var p = new Person{ RecordID = recordId }; list.Add(p); } </code></pre>
36,036
<p>I using SharePoint Designer to create a workflow. I'm trying to get at a sub-folder in a document library in the "Define Workflow Lookup" dialog. There are two issues with this:</p> <ol> <li>I can't look up items by URL Path. If I look up by Title, I can output the URL Path, but selecting by path doesn't work. Wh...
<p>I really don't have much experience with Sharepoint, but I thought I could at least provide <em>some</em> answer - even if it's the wrong one.</p> <p>From another dev I've spoken to it sounds like it's tough to get into any subfolders, so you might need to look at making your own custom workflow.</p> <p>Maybe some...
<p>The issue is that "folders" are not really folders as they are accessed by querystring, not a "/" as with real folders.</p>
5,340
<p>Here's the problem, you include multiple assemblies and add 'using namespaceX' at the top of your code file.<br> Now you want to create a class or use a symbol which is defined in multiple namespaces, e.g. <code>System.Windows.Controls.Image</code> &amp; <code>System.Drawing.Image</code></p> <p>Now unless you use ...
<p>Use alias</p> <pre><code>using System.Windows.Controls; using Drawing = System.Drawing; ... Image img = ... //System.Windows.Controls.Image Drawing.Image img2 = ... //System.Drawing.Image </code></pre> <p><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive" rel="nof...
<p>This page has a very good writeup on namespaces and the using-statement:</p> <p><a href="http://www.blackwasp.co.uk/Namespaces.aspx" rel="noreferrer">http://www.blackwasp.co.uk/Namespaces.aspx</a></p> <p>You want to read the part about "Creating Aliases" that will allow you to make an alias for one or both of the ...
8,643
<p>Using VC2005, I have 3 projects to build:</p> <ul> <li>libA (contains a typelib, results in libA.dll): IDL has a line <code>library libA { ...</code> </li> <li>libB (contains a typelib importing libA, results in libB.dll): IDL has a line <code>importlib( "libA " );</code></li> <li>libC (imports libB): one of the s...
<p>Looks like it doesn't:</p> <p><a href="http://msdn.microsoft.com/en-us/library/cc511823.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc511823.aspx</a></p> <p>It's now in the 'Archived Application Blocks' section of the MSDN docs.</p> <p><a href="http://msdn.microsoft.com/en-us/library/c...
<p>No. Microsoft considers the Updater Application Block to be replaced by ClickOnce in .NET 2.0. The Enterprise Library for .NET 1.1 is no longer updated.</p>
16,899