instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>"Dirty reads", meaning reading an object's value even though it is write-locked by another thread, are <a href="http://www.terracotta.org/confluence/display/howto/Recipe?recipe=dirty-read" rel="nofollow noreferrer">described</a> on Terracotta's website, yet I've heard that they shouldn't be used, even if you don't c... | <p>A dirty read is a dirty read. Terracotta, being distributed/clustered, only adds the possibility to read even older values of the shared mutable state that you are accessing without proper synchronization.</p>
<p>You should note that, under the memory model in Java 5, you are not guaranteed to <em>ever</em> read an... | <p>I'm a Terracotta developer. The gist of the answer is just as Christian Vest Hansen already noted - just as the JVM makes no guarantees about the visibility of updates of a shared object that is accessed w/o proper synchronization, Terracotta likewise can make no guarantees about dirty reads of a clustered object.<... | 17,040 |
<p>What is the first thing you do when you install Visual Studio? I am talking about anything customization-wise (so we don't get answers based on 'I create a new project').</p>
<p>Do you have a favorite font? </p>
<p>Do you have a must have extension you couldn't possibly live without? </p>
<p>Do you have a keyboar... | <p>I install <a href="http://www.jetbrains.com/resharper/" rel="nofollow noreferrer">ReSharper</a> (sold by JetBrains) because it adds a lot of IDE behaviors/features that I became dependent on using Java IDEs.</p>
<p>The first thing I make others do is turn on line numbers for all file types, because it is impossible... | <p>Ensure that I have the "Visual C#" settings presets chosen, Turn on Line Numbering, Turn on Smart Tabs and set the tab size to 4.</p>
| 17,591 |
<p>I have a web page in which people go to register for my site. I use server side validation to authenticate them. I need to call some Javascript to tell GA that user was or was not registered. Later I need stats on success in registration.</p>
<p>How can I call the GA function on my server side C# code?</p>
| <p>A project i have released under open source allows for easy integration with Google Analytics from .net native code to fire page views, events etc through code.</p>
<p>It's called GaDotNet and can be found here:
<a href="http://www.diaryofaninja.com/projects/details/ga-dot-net" rel="nofollow noreferrer">http://www.... | <p>Paste the code Google gives you into your footer or template that is displayed on every page or each of the individual templates if you don't have a footer.</p>
<p>Then you can setup "conversion goals" on the pages where users end up when they are successful or not successful.</p>
<p>If you just want to track how ... | 19,405 |
<p>How can I delete the contents of a local folder in Python?</p>
<p>The current project is for Windows, but I would like to see *nix also.</p>
| <pre><code>import os, shutil
folder = '/path/to/folder'
for filename in os.listdir(folder):
file_path = os.path.join(folder, filename)
try:
if os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_pa... | <p>This should do the trick just using the OS module to list and then remove!</p>
<pre><code>import os
DIR = os.list('Folder')
for i in range(len(DIR)):
os.remove('Folder'+chr(92)+i)
</code></pre>
<p>Worked for me, any problems let me know! </p>
| 22,490 |
<p>I have a problem related to the <a href="http://en.wikipedia.org/wiki/Subset_sum_problem" rel="noreferrer">subset sum problem</a> and am wondering if the differences make it easier, i.e. solvable in a reasonable amount of time.</p>
<p>Given a value V, a set size L, and a sequence of numbers [1,N] S, how many size L... | <p>(The decision version of) your problem is still NP-complete. The idea is that if we could solve your problem, then (for each subset size, say) we could ask how many sets sum to less than V and how many sum to less than V-1, and the difference of those two numbers would tell us whether are subsets that sum to exactly... | <p>Well, for one thing since you're specifying size=L then even if you can't think of anything clever and just use brute force you'll have (N choose L) separate sums in the worst case, so it's a bit better than n^^L (well, L+1, as you'd then sum each subset). </p>
| 49,204 |
<p>When writing application code, it's generally accepted that premature <strong>micro</strong>-optimization is evil, and that profiling first is essential, and there is some debate about how much, if any, higher level optimization to do up front. However, I haven't seen any guidelines for when/how to optimize generic... | <p>"How should performance be balanced with other design goals...?"</p>
<ol>
<li><p>Get it to work.</p></li>
<li><p>Optimize it until it cannot be optimized further.</p></li>
</ol>
<p>Note the order. Avoid <em>premature</em> optimization means optimize it <em>after</em> it works. </p>
<p>Optimization is still ver... | <p>You're right it's not always clear where the best bang for the buck is for your time. Your best bet is to <strong>be a user of your framework</strong> as well as its designer. </p>
<p>Employ your own framework in a non-trivial application, try to exercise the whole range of functionality. The more you use it, it... | 44,082 |
<p>In Microsoft Access I have a table called Time Sheet and in this I have Time sheet no. , waiter no. , date and hours worked. I have 10 waiters. </p>
<p>I have another table called Service Charge Distribution. In this table I have Service Charge No. , waiter no. , week no. and distribution amount. </p>
<p>There is ... | <p>I think the formula would be :</p>
<p>Total Distribution Charge for the week /(number of waiters worked * hrs worked by one worker)</p>
| <p>I think you are looking for DSum:</p>
<pre><code>Answer=DSum("NameOfField","NameOfTable", _
"SomeDate Between #2008/1/20# And #2008/1/27#")
</code></pre>
<p>You can, of course, use a variable:</p>
<pre><code>Answer=DSum("NameOfField","NameOfTable","SomeDate Between #"
& date()-weekday(date())+1 & "# A... | 34,451 |
<p>If I have: </p>
<pre><code>signed char * p;
</code></pre>
<p>and I do a comparison:</p>
<pre><code>if ( *p == 0xFF )
break;
</code></pre>
<p>it will never catch 0XFF, but if I replace it with -1 it will:</p>
<pre><code>if ( *p == (signed char)0xFF )
break;
</code></pre>
<p>How can this happen? Is it some... | <p>The value <code>0xFF</code> is a signed int value. C will promote the <code>*p</code> to an <code>int</code> when doing the comparison, so the first if statement is equivalent to:</p>
<pre><code>if( -1 == 255 ) break;
</code></pre>
<p>which is of course false. By using <code>(signed char)0xFF</code> the statement ... | <p>0xff will be seen as an integer constant, with the value of 255. You should always pay attention to these kind of comparison between different types. If you want to be sure that the compiler will generate the right code, you should use the typecast:</p>
<pre>
if( *p == (signed char)0xFF ) break;
</pre>
<p>Anyway, ... | 8,637 |
<p>I have a search form in an app I'm currently developing, and I would like for it to be the equivalent of <code>method="GET"</code>.</p>
<p>Thus, when clicking the search button, the user goes to <code>search.aspx?q=the+query+he+entered</code></p>
<p>The reason I want this is simply bookmarkable URLs, plus it feels... | <p>Use a plain old html form, not a server side form (runat=server), and you should indeed be able to make it work. </p>
<p>This could however be a problem if you have an out of the box visual studio master page which wraps the entire page in a server side form, because you can't nest forms. </p>
<p>Web forms don'... | <p>I would do (b) since (a) would require two round trips for a single query. Alternatively, you could disable viewstate on the page, remove any other hidden fields via javascript, and also use javascript to modify the form method from post to get. I've never done this for real, but my toy page using the included sam... | 41,298 |
<p>Does anyone know of shared TODO list plugin for Eclipse that allows users in a a development team to all view and edit the same list of tasks?</p>
| <p><a href="http://www.eclipse.org/mylyn/" rel="nofollow noreferrer">Mylyn</a> can be used to integrate issue tracking systems into the IDE.</p>
<blockquote>
<p>It does this by making tasks a first class part of Eclipse, and integrating rich and offline editing for repositories such as Bugzilla, Trac, and JIRA. </p>... | <p>I don't know about such particular plug-in, but maybe that you could take a look to what the <a href="http://www.eclipse.org/ecf/" rel="nofollow noreferrer">Communication framework</a> or the <a href="http://www.eclipse.org/mylyn/" rel="nofollow noreferrer">Mylin feature</a> offer you in term of collaborative work.<... | 41,396 |
<p>I'm looking into building a content site with possibly thousands of different entries, accessible by index and by search.</p>
<p>What are the measures I can take to prevent <strong>malicious crawlers</strong> from ripping off all the data from my site? I'm less worried about SEO, although I wouldn't want to block l... | <p>Any site that it visible by human eyes is, in theory, potentially rippable. If you're going to even try to be accessible then this, by definition, <strong>must</strong> be the case (how else will speaking browsers be able to deliver your content if it isn't machine readable). </p>
<p>Your best bet is to look into w... | <p>Use where ever is possible human validators and try using some framework (MVC). The site ripping software is sometimes unable to rip this kind of page. Also detect the user agent, at least it will reduce the number of possible rippers</p>
| 21,380 |
<p>I am trying to update a custom firefox extension that I created for some tasks at work. Basically it is a sidebar that pulls up one of our webpages in an iframe for various purposes. When moving to Firefox 3 the iframe won't appear at all.</p>
<p>Below is an example of the XUL files that contains extension specific... | <ol>
<li>Set flex="1" on the iframe</li>
<li>The XUL code for sidebar is not an overlay, it's a document loaded inside an iframe (look at the Firefox main window in the DOM inspector). So the root element should be <page>, not <overlay>. This, combined with the flex="1", should make the page display.</li>
<li>You... | <p>I would try setting flex="1" on the iframe. If that's not working, perhaps try it with the <a href="http://developer.mozilla.org/en/XUL/browser" rel="nofollow noreferrer">browser</a> element instead of iframe.</p>
| 20,144 |
<p>I am trying to upload files using the FileReference class. Files >2MB all work correctly but files <2MB cause this error:</p>
<blockquote>
<p>"java.io.IOException: Corrupt form data: premature ending"</p>
</blockquote>
<p>On the server I am using the com.oreilly.servlet package to handle the request.</p>
<p>... | <p>In WPF you have <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dependencypropertydescriptor.addvaluechanged.aspx" rel="nofollow noreferrer">DependencyPropertyDescriptor.AddValueChanged</a>, but unfortunately in Silverlight there's no such thing. So the answer is no.</p>
<p>Maybe if you expla... | <p>Check out the following link. It showns how to get around the problem in silverlight where you don't have DependencyPropertyDescriptor.AddValueChanged</p>
<p><a href="http://themechanicalbride.blogspot.com/2008/10/building-observable-model-in.html" rel="nofollow noreferrer">http://themechanicalbride.blogspot.com/... | 29,726 |
<p>How do I iterate over a range of numbers in Bash when the range is given by a variable?</p>
<p>I know I can do this (called "sequence expression" in the Bash <a href="http://www.gnu.org/software/bash/manual/bashref.html#Brace-Expansion" rel="noreferrer">documentation</a>):</p>
<pre><code> for i in {1..5}; do echo ... | <pre><code>for i in $(seq 1 $END); do echo $i; done</code></pre>
<p>edit: I prefer <code>seq</code> over the other methods because I can actually remember it ;)</p>
| <p>This works in Bash and Korn, also can go from higher to lower numbers. Probably not fastest or prettiest but works well enough. Handles negatives too.</p>
<pre><code>function num_range {
# Return a range of whole numbers from beginning value to ending value.
# >>> num_range start end
# start: Whol... | 20,465 |
<p>I have 2 hosts and I would like to point a subdomain on host one to a subdomain on host two:</p>
<pre><code>subdomain.hostone.com --> subdomain.hosttwo.com
</code></pre>
<p>I added a CNAME record to host one that points to subdomain.hosttwo.com but all I get is a '<strong>400 Bad Request</strong>' Error.</p>
<... | <p>Try changing it to "subdomain -> subdomain.hosttwo.com"</p>
<p>The <code>CNAME</code> is an alias for a certain domain, so when you go to the control panel for hostone.com, you shouldn't have to enter the whole name into the <code>CNAME</code> alias.</p>
<p>As far as the error you are getting, can you log onto sub... | <p>It's probably best/easiest to set up a <a href="http://www.webconfs.com/how-to-redirect-a-webpage.php" rel="nofollow noreferrer">301 redirect</a>. No DNS hacking required.</p>
| 3,699 |
<p>Why do we have two standard filament sizes, 1.75 mm and 3 mm? Does it really make a difference when printing? Or is the 1.75 mm just for smaller printers?</p>
<p>In what situations should I be using 1.75 mm?</p>
<p>When should I be using 3 mm?</p>
| <p>There's no appreciable difference. Just use the filament that fits your particular printer.</p>
<p>If you don't yet have a printer, then I'd get one that uses 1.75 mm filament:</p>
<ul>
<li><p>1.75 mm is increasingly becoming the "standard", thus being easier to get. Some filaments are not available as 3... | <p>One thing I haven't seen anyone mention yet is the issue of the size vis-a-vis time of the final print. 3 mm filament allows the printer to spit out a <strong><em>lot</em></strong> of plastic at once, letting you build must taller prints much faster. Larger filament can also provide a much wider base for the ne... | 144 |
<p>I am seeing both of them used in this script I am trying to debug and the literature is just not clear. Can someone demystify this for me?</p>
| <p>Dynamic Scoping. It is a neat concept. Many people don't use it, or understand it.</p>
<p>Basically think of <code>my</code> as creating and anchoring a variable to one block of {}, A.K.A. scope.</p>
<pre><code>my $foo if (true); # $foo lives and dies within the if statement.
</code></pre>
<p>So a <code>my</code>... | <p>dinomite's example of using local to redefine the record delimiter is the only time I have ran across in a lot of perl programming. I live in a niche perl environment [security programming], but it really is a rarely used scope in my experience.</p>
| 15,753 |
<p>I have several branches in TFS (dev, test, stage) and when I merge changes into the test branch I want the automated build and deploy script to find all the updated SQL files and deploy them to the test database.</p>
<p>I thought I could do this by finding all the changesets associated with the build since the last... | <p>Thanks Scott,</p>
<p>After a while I found a nice way to manage this. </p>
<p>Basically I created a task which gets the current changesets associated with the build (point 1 of my question is not an issue) and then loop through them looking for .sql files. Once I have a list of those I can create a change script o... | <p>So I can understand the intuitive appeal of this approach, but I don't think it's the right way to go.</p>
<p>For one thing it's going to be difficult. But the second problem is that TFS doesn't have a good way to record deployment data.</p>
<p>For the first question, I'm not sure what that means. For the second q... | 27,196 |
<p>This has just come up as a question where I worked so I did a little digging and the answer is a ExpertsExchange one. So I hand you over to the original question asker, Manchung:</p>
<blockquote>
<p>I have a project written in pure C which is to be used in embedded system. So, I use pure C to minimize the code size.... | <p>On recent releases of gcc, <code>-ansi</code> is documented as being the same as <code>-std=c89</code>. The new comment syntax is only available with the C99 standard, so <code>-std=c99</code> would allow it.</p>
<p>There is also <code>-std=gnu89</code>, which is the same as <code>-std=c89</code> but allowing all g... | <p>C has had C++ style comments for nearly ten years now, maybe you should upgrade?</p>
| 35,014 |
<p>I'm packaging up a .NET 2.0 based web app for deployment through a Windows Installer based package. Our app uses Report Viewer 2008 and I'm including the Microsoft Report Viewer Redistributable 2008 installer. When I check the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=cc96c246-61e5-4d9e-bb5... | <p>Keep in mind that MSFT might be requiring the 3.5 Framework so they can write against it in future updates/releases, which might place your app in an unsupported (by MSFT) state.</p>
| <p>If it works without a hitch then you don't need .NET 3.5 Framework for now. Installing .NET 3.5 Framework is easy enough to do along with later versions of your software <em>if and only if your software stops working at that point</em>.</p>
| 4,056 |
<p>I know there are a few different <a href="http://en.wikipedia.org/wiki/Traveling_salesman_problem" rel="nofollow noreferrer">Traveling Salesman</a> projects out there and I've played with <a href="http://www.akira.ruc.dk/~keld/research/LKH/" rel="nofollow noreferrer">LKH</a> a bit, but I was wondering if anyone had ... | <p>In general, <a href="http://en.wikipedia.org/wiki/Special:Search?search=space+filling+fractal" rel="nofollow noreferrer">Space Filling Fractals</a> will give you some of the best results at the lowest costs.</p>
<p>In particular, I would recommend the <a href="http://en.wikipedia.org/wiki/Sierpi%C5%84ski_curve" rel... | <p>There's one <a href="http://www.cs.sunysb.edu/~algorith/implement/syslo/distrib/processed/babtsp.p" rel="nofollow noreferrer">here</a> that solves TSP exactly, but it's in PASCAL. In the current form the distances are integers, though. Shouldn't be hard too rewrite in C++. </p>
| 23,650 |
<p>Is it possible to generate PDF Documents in an Adobe AIR application without resorting to a round trip web service for generating the PDF? I've looked at the initial Flex Reports on GoogleCode but it requires a round trip for generating the actual PDF.</p>
<p>Given that AIR is supposed to be the Desktop end for RIA... | <p>There's <a href="http://code.google.com/p/alivepdf/" rel="nofollow noreferrer">AlivePDF</a>, which is a PDF generation library for ActionScript that should work, it was made just for the situation you describe.</p>
| <p>One of the other teams where I work is working on a Flex-based drawing application and they were totally surprised that AIR / Flex does not have PDF authoring built-in. They ended up rolling their own simple PDF creator based on the PDF specification.</p>
| 7,677 |
<p>Why does the linux kernel generate a segfault on stack overflow? This can make debugging very awkward when alloca in c or fortran creation of temporary arrays overflows. Surely it mjust be possible for the runtime to produce a more helpful error.</p>
| <p>You can actually catch the condition for a stack overflow using signal handlers.</p>
<p>To do this, you must do two things:</p>
<ul>
<li><p>Setup a signal handler for SIGSEGV (the segfault) using sigaction, to do this set the SO_ONSTACK flag. This instructs the kernel to use an alternative stack when delivering ... | <p>A stack overflow does not necessarily yield a crash. It may silently trash data of your program but continue to execute.</p>
<p>I wouldn't use SIGSEGV handler kludges but instead fix the original problem.</p>
<p>If you want automated help, you can use gcc's -Wstack-protector option, which will spot some overflows ... | 10,678 |
<p>I would normally use Google analytics because it is free and simple to implement but on this occasion we need an internally built reporting system. This system needs to be in .NET only because JavaScript is not an option.</p>
<p>My question is how do you track unique visitors when you can never be sure that they ha... | <p>Firstly, unique users is <em>always</em> an approximation. There is no guaranteed way to force cookies, their persistance is not completely in your control anyway, and IPs often represent blocks (sometimes vast) of users. Data quality is not good in this area, you just have to accept that.</p>
<p><a href="http://ww... | <p>I'll advice you to track users in your db thru server side code when they/users use your first page say when they login page:</p>
<p>with the help of this :HttpBrowserCapabilities browser = Request.Browser;
you will get the information like which browser is being used, cookies are set or not etc... then depending ... | 43,651 |
<p>Please point me to a toolkit i can use to build Near Field Communication apps.</p>
<p>thanks</p>
| <p>You can use the <a href="http://java.sun.com/developer/technicalArticles/javame/nfc/#3" rel="nofollow noreferrer">Contactless Communication API</a> for Java.</p>
| <p>Android supports NFC as of Android 2.3</p>
<p>There is a demo project in the SDK</p>
| 45,219 |
<p>I've heard alot about simplify 3D recently. It sounds like it's a great software, but 150 dollars!? The only thing that seems too different from other slicers is the placable supports, but Z suite has that now as well. Cura must be coming out with placable supports soon if they're going to stay in the game. It does ... | <p>The free slicers are catching up with Simplify3D, and are even overtaking it in some areas, so purchasing it may not make much sense to hobbyists. However, for professional print shops, where printers may cost twenty times as much (or even more), 150 dollars is nothing (especially since it is 150 dollars per PC, not... | <p>Well, simplify 3D has more than only placeable supports and I'm very happy with it. I Made my 3D printers and I had headaches with free slicers due I had to review the final result on pronterface, of course this programs was unable to run perfectly on P4 PC's with XP. </p>
<p>When I started to change for other prog... | 763 |
<p>Currently, WScript pops up message box when there is a script error. These scripts are called by other processes, and are ran on a server, so there is nobody to dismiss the error box. </p>
<p>What I'd like is for the error message to be dumped to STDOUT, and execution to return the calling process. Popping as a MSG... | <p>This is how you should be running Script batch jobs:</p>
<pre><code>cscript //b scriptname.vbs
</code></pre>
| <p>You haven't stated what language you're using. If you're using VBScript, you can write an error handler using the <a href="http://publib.boulder.ibm.com/infocenter/cqhelp/v7r0m0/index.jsp?topic=/com.ibm.rational.clearquest.apiref.doc/c_vbscript_err_hndlng.htm" rel="nofollow noreferrer">On Error...</a> statement. If ... | 11,497 |
<p>I am trying to declare and use a class B inside of a class A
and define B outside A.<br>
I know for a fact that this is possible because Bjarne Stroustrup<br>
uses this in his book "The C++ programming language"<br>
(page 293,for example the String and Srep classes).</p>
<p>So this is my minimal piece of code that ... | <p>Define the constructor for A AFTER the definition of struct B.</p>
| <p>Interestingly, I've bumped into the same problem with the page 293 ('11.12 A String Class') mentioned in the Stroustrup book.</p>
<p>The example provided in the printed book seems to be at fault, providing the following methods as inline, instead of defining them after the definition of struct Srep</p>
<pre><code>... | 40,012 |
<p>I'm implementing a tagging system for a website. There are multiple tags per object and multiple objects per tag. This is accomplished by maintaining a table with two values per record, one for the ids of the object and the tag.</p>
<p>I'm looking to write a query to find the objects that match a given set of tags.... | <p>Given:</p>
<ul>
<li>object table (primary key id)</li>
<li>objecttags table (foreign keys objectId, tagid)</li>
<li><p>tags table (primary key id)</p>
<pre><code>SELECT distinct o.*
from object o join objecttags ot on o.Id = ot.objectid
join tags t on ot.tagid = t.id
where t.Name = 'fruit' or t.... | <p>I'd suggest making your table have 1 tag per record, like this:</p>
<pre><code> apple -> fruit
apple -> red
apple -> food
banana -> fruit
banana -> yellow
banana -> food
</code></pre>
<p>Then you could just</p>
<pre><code> SELECT object WHERE tag = 'fruit' OR tag = 'food';
</code></pre>
<p... | 4,436 |
<p>I am trying to create a databound WPF GridView whose rows can either be read-only or editable (by double-clicking or through a context menu). I would like for the row to return to a read-only state if any of its editable controls loses focus. The functionality I am looking for is very similar to <a href="http://blog... | <p>With the ListView + GridView control il quite complex because this control "thinks in column" so you have to create a template for every column and switch the read-only template with edit template (for every cell).
I suggest you to take a look a the xceed DataGrid. It's free and it implements the edit functionality ... | <p>This is an old question with an old answer, that this answer no longer works!
In .Net 6, for editing Grid-View in WPF, you must use the "CurrentCellChanged" event.</p>
<p>UI:</p>
<pre><code><DataGrid x:Name="dataGrid" Margin="0,50,0,0" CurrentCellChanged="dataGrid_CurrentCellCha... | 29,076 |
<p>The most recent Crystal XI component for Delphi was released for Delphi 7. That VCL component compiles in D2007, but gives me errors at runtime. What is the best way to display a database-connected Crystal Report in a Delphi 2007 application?</p>
| <p>This is the solution I've found, using ActiveX:</p>
<p>First, register the Active X control like this:</p>
<p>In Delphi, choose Component -> Import Component</p>
<p>Click on "Type Library", click Next</p>
<p>Choose "Crystal ActiveX Report Viewer Library 11.5"</p>
<p>Pick whatever Palette Page you want (I went w... | <p>Here is a bit simpler and clean class which solves the problem very nicely:</p>
<p>Unit CrystalReports;
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.OleCtrls, ActiveX, ComObj, Data.DB, Data.... | 49,514 |
<p>There are lots of non-image-based CAPTCHA ideas floating around. But what about the old-fashioned way?</p>
<p>What are the elements of a good image CAPTCHA? What visual elements are hard for computers, but easier for humans? What about mistakes, elements that are easier for computers than they are for humans? W... | <p>Make each letter/number out of a pattern, I.E. unconnected dots. Meaning the computer has no way of knowing that a dot is part of a letter other than pattern recognition (which they don't have yet.) Then the usual distortions and random lines.</p>
<p>How you do this is the challenge.</p>
<p>EDIT: Also, bonus point... | <p>I really hate CAPTCHA on sites, they just annoy me, but if you want to try and make a robust one try the following:</p>
<ul>
<li>Ability to get a new image without submitting</li>
<li>Spoken version for the visually impaired</li>
<li>Non-uniform characters</li>
</ul>
<p>I've used Recaptcha on a few sites, it's a n... | 23,884 |
<p>From <a href="https://stackoverflow.com/questions/60419/do-i-really-need-to-use-transactions-in-stored-procedures-mssql-2005">this post</a>. One obvious problem is scalability/performance. What are the other problems that transactions use will provoke?</p>
<p>Could you say there are two sets of problems, one for lo... | <p>It depends a lot on the transactional implementation inside your database and may also depend on the transaction isolation level you use. I'm assuming "repeatable read" or higher here. Holding transactions open for a long time (even ones which haven't modified anything) forces the database to hold on to deleted or u... | <p>I think the major issue is at the design level. At what level or levels within my application do I utilise transactions.</p>
<p>For example I could:</p>
<ul>
<li>Create transactions within stored procedures, </li>
<li>Use the data access API (ADO.NET) to control transactions </li>
<li>Use some form of implicit ro... | 8,542 |
<p>What order of precedence are events handled in JavaScript?</p>
<p>Here are the events in alphabetical order...</p>
<ol>
<li>onabort - Loading of an image is
interrupted</li>
<li>onblur - An element loses focus</li>
<li>onchange - The user changes the
content of a field</li>
<li>onclick - Mouse clicks an object</li... | <p>This was not, so far as i know, explicitly defined in the past. Different browsers are free to implement event ordering however they see fit. While most are close enough for all practical purposes, there have been and continue to be some odd edge cases where browsers differ somewhat (and, of course, the many more ca... | <p>Here is demo for a number of events:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><input onclick="console.log('onclick - Mouse clicks an object')"
ondblcl... | 35,741 |
<p>The company I work for has several clients. I'm currently splitting my time between 2 .net projects. For Client A I need Visual Studio 2008, SQL Server 2008 and the 3.5 framework. For Client B 2005 versions/2.0 Framework.</p>
<p>Others in the company are using Microsoft Virtual PC to keep the development environme... | <p>I personally have both installed on the same system and use the proper tool for each project</p>
<p>VS 2005/SQL Server 2005</p>
<p>VS 2008/SQL Server 2008</p>
<p>I find that it works jsut fine, and I don't have the hassle of switching VM's.. I see the VM as just added overhead.</p>
| <p>actually i have VS 2003 to add to 2005 and 2008 on the same box. instead of multiple vms, worth having multiple monitors if you want to keep multiple versions open at the same time.</p>
| 27,437 |
<p>I have a Java program that loads thirdparty class files (classes I did not write) and executes them. These classes often use <code>java.util.Random</code>, which by default generates random starting seed values every time it gets instantiated. For reasons of reproducability, I want to give these classes the same sta... | <p>Consider modifying the third party libraries to have them use a seen for their Random instances. Though you do not have the source code, you can probably edit the bytecode to do it. One helpful toolkit for doing such is <a href="http://asm.objectweb.org/" rel="nofollow noreferrer">ASM</a>.</p>
| <p>"Use a custom classloader to load our own Random class instead of the JVM's version. This approach will not work because Java does not allow classloaders to override classes in the java package."</p>
<p>how about changing the bootclasspath to use your custom Random class ?</p>
<p>BR,
~A</p>
| 13,221 |
<p>I am writing a console application which makes use of the F1 key (for help). Unfortunately, while Konsole (of KDE) doesn't use this key, Gnome Terminal does, so the F1 key becomes inaccessible to my application. I don't think there's a way to detect whether the F1 key is already mapped in the GUI side of things (G... | <p>Googleage has revealed that I might be able to rely on Gnome Terminal setting the COLORTERM environment variable to 'gnome-terminal'.</p>
| <p>I simply check the $TERM for the terminal emulator of my choice and then add an alias for spawning a new terminal in the current directory.</p>
<pre><code>if [[ $TERM == 'xterm' ]] ; then
alias nw='gnome-terminal --working-directory=$PWD'
fi
</code></pre>
| 32,194 |
<p>any generic way to trace/log values of all local variables when an exception occurs in a method?
(in C# 3)</p>
| <p>Answer: Using PostSharp (Policy Injection), XTraceMethodBoundary attribute, override OnException .
this logs all the method input and return parameters types and values. I modified PostSharp to add a simple method to log parameters. not perfect but good enough</p>
<pre><code>private static void TraceMethodArgument... | <p>You could do a memory dump of the process since that captures both the heaps and the stacks, but since you tagged the question as logging, I assume that is not what you're looking for. </p>
<p>However, you can reduce the need for this information by making sure your methods are always small and to the point. That w... | 47,265 |
<p>How do I get the div from within this (the last) list item?</p>
<p>Currently I have this, which is just plain ugly...any suggestions on a cleaner selector/ solution?</p>
<pre><code>var div = ul.append("<li><div></div></li>").contents("li:last-child")[0].children[0];
</code></pre>
<p>Thanks... | <p>You could go about the adding a bit differently too:</p>
<pre><code>var div = $('<div/>');
// do whatever you need to do with the div
$('<li/>').appendTo(ul).append(div);
</code></pre>
| <p>Like this?</p>
<pre><code>var div = ul.append("<li><div></div></li>").contents("li:last-child > div")[0];
</code></pre>
| 48,172 |
<p>Given two vectors <strong>A</strong> and <strong>B</strong> which form the line segment <strong>L</strong> = A-B.
Furthermore given a view frustum <strong>F</strong> which is defined by its left, right, bottom, top, near and far planes.</p>
<p>How do I clip <strong>L</strong> against <strong>F</strong>? </p>
<p>Th... | <p>I don't want to get into writing code for this now but if I understand "frustum" correctly the following should work.</p>
<ol>
<li>Intersect the Line with all given planes</li>
<li>If you have two intersections you're done.</li>
<li>If you have only one intersection calculate the front plane and intersect.</li>
<li... | <p>Adding to what Corporal Touchy said above, you'll need to <a href="http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/" rel="nofollow noreferrer">know how to intersect a line segment with a plane</a>. In the description on that page, u represents the parameter in the parametric definition of your line. First... | 10,328 |
<p>I have a makerbot, and am using their slicer program. The part I am printing has an extremely coarse thread, 5 threads per inch with a 2 mm thread height. The thread face is at a 30 degree angle (15 degrees of overhang)</p>
<p>I have printed external threads like this without issue and without support material befo... | <p>There are some software tools that let you manually design support structures so you can target the areas that need them, and avoid others.</p>
<p>For example, Meshmixer can be used to add supports into your STL. I believe you still use a separate slicer.</p>
<p>Some slicers also have the ability to manually add s... | <p>Try using simplify 3d. It's a very powerful slicing software compatible with almost every 3d printer. It does cost 150 dollars, but that would be the only drawback to using that software. You can manually place supports around your model without having he software mess it up. I think this is exactly what you're look... | 556 |
<p>In C#, the questions of what types to create, what members they should have, and what namespaces should hold them, are questions of OO design. They are not the questions I'm interested in here.</p>
<p>Instead, I want to ask how you store these in disk artifacts. Here are some example rules:</p>
<ul>
<li><p>Put a... | <p>Whatever you do, just PLEASE do it consistently. I don't believe there is any one single answer (though there are a few wrong ones). But just make sure you stay true to your form as this will be the key for your successor(s) to find things easily.</p>
| <p>I prefer the conventional one-file-per-public-class, with folders inside the project (which map to sub-directories) used to group conceptually related classes as needed to keep the Solution Explorer view manageable. If your class names are well chosen the folders shouldn't be strictly necessary, but they are helpful... | 43,057 |
<p>I have 3 web projects in a Visual studio solution.I want to create a single web setup project which should install all 3 web projects in their virtual directories.So how to create a single web setup project which supports multiple web application installation?</p>
| <p>You can do this by creating a Web Setup Project. In the File System add as many Web Custom Folders as you need.</p>
<p>Only the main Web Application Folder will have the installation dialog so if you want to customize the virtual directory names then you will need to add a screen and set the Property of the web cu... | <p>As John Hunter said, it is possible to add multiple Web Custom Foldsers beside the default Web Appplication Folder. But you need to know some details about how things add up.</p>
<p>One thing to notice is that the <code>Property</code> name you set for the additional folder will be the physical path of the installa... | 45,838 |
<h3>Are there differences between the amount of syscalls in the major *NIX variants ?</h3>
<h3>Which syscalls would be supported universally ?</h3>
| <p>Anything that is not a posix standard may be an additional system call, or it maybe additional library functionality above the system call layer. If your goal is to write portable code stick to posix, and use the c library (as opposed to direct system calls) as much as possible.</p>
<p>If you are just curious, they ... | <p>The best I can find is a <a href="http://www.scribd.com/doc/2345014/Unix-Linux-BSD-Cheat-Sheets-I" rel="nofollow noreferrer">Unix-Linux-BSD Cheat-Sheets</a>, for various syscalls variations, to be compared with the <a href="http://docs.oracle.com/cd/E19683-01/816-0212/6m6nd4n86/index.html" rel="nofollow noreferrer" ... | 34,607 |
<p>I'm currently trying to implement a data collector on my Replicator+ by utilizing JSON-RPC. Is there an <strong>official</strong> reference for this? MakerBot used to host a <a href="http://wiki.makerbot.com/" rel="nofollow noreferrer">wiki site</a>, but that seems to be gone for their "troubleshooting" pages.</p>
| <p>It took some digging, but I was able to start scripting a wrapper in C# for the RPC commands.</p>
<ul>
<li><a href="https://github.com/TrueAnalyticsSolutions/MakerBotAgentAdapterCore#api" rel="nofollow noreferrer">C# Wrapper</a> (MTConnect Implementation)</li>
<li>Unofficial <a href="https://github.com/TrueAnalytic... | <h2>The Mystery of Makerbot-Wiki</h2>
<p>According to the Wayback machine, the wiki.makerbot.com went offline on <a href="https://web.archive.org/web/20121126084944/http://wiki.makerbot.com:80/" rel="nofollow noreferrer">31st December 2012</a>:</p>
<blockquote>
<p>Over the past three amazing years, MakerBot owners ... | 1,232 |
<p>Let's say I have a list of categories for navigation on a web app. Rather than selecting from the database for every user, should I add a function call in the application_onStart of the global.asax to fetch that data into an array or collection that is re-used over and over. If my data does not change at all - (Ed... | <p>You can store the list items in the Application object. You are right about the <code>application_onStart()</code>, simply call a method that will read your database and load the data to the Application object.</p>
<p>In Global.asax</p>
<pre><code>public class Global : System.Web.HttpApplication
{
// The key t... | <p>I use a static collection as a private with a public static property that either loads or gets it from the database.</p>
<p>Additionally you can add a static datetime that gets set when it gets loaded and if you call for it, past a certain amount of time, clear the static collection and requery it.</p>
| 8,980 |
<p>I have a SQL Server 2000 database instance that is rarely updated. I also have a database table which has no columns holding each row's created date or modified date. </p>
<p>Is there any way that I can determine the last time an update or insert was performed on the database as a whole, so that I can at least pu... | <p>The database's log file may have some information that is useful to your quest. AFAIK, the database itself doesn't store a "last updated" date.</p>
| <p>Depending on the size of the database and the number of tables you could put a trigger in place that would handle updates/or inserts and log that to another table, potentially logging the table name and a timestamp, it isn't elegant but could work. and Doesn't require any modification to the rest of the db.</p>
| 24,681 |
<p>I have a rather strange error with NHibernate. I am was having error with ISession been shared by across threads and got this resolved by supplying my own ADO.NET connection like:</p>
<pre><code> IDbConnection connection = new SqlConnection(ApplicationConfiguration.ConnectionString);
connecti... | <p>Check out the cascade attribute on your collection mapping - by default this is set to 'none', meaning child entities need to be explicitly saved. You probably want cascade="all" or cascade="all-delete-orphan".</p>
| <p>are you using NHibernate.ISession.save(object) before the flush and commit of the tyres list?</p>
| 49,785 |
<p>I've read a bunch of articles about getting better springs for my bed levelling screws so that I don't have to adjust it as often because standard springs vibrate loose as it prints.</p>
<p>However, would it be simpler and more effective to just use Nyloc nuts tightened against the adjustment wheels so that the whee... | <p>It's because the bed heats up. Since the bed can heat up to the point that locktite or nylon can soften, using those products to keep the screws from turning will have exactly the opposite effect.</p>
| <p>Does your bed already have washers on the screws? The neopreme (red) washer under the screw head (in picture). This is the German Reprap X400 design and is worth trying.</p>
<p><a href="https://i.stack.imgur.com/jucy3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jucy3.jpg" alt="enter image de... | 1,852 |
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p>
<pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) )
</code></pre>
<p>which is a hack, and which doesn't work outside Linux-like systems, and which needs help from the Pexpect module to avoid passw... | <p>Try the <a href="https://github.com/jbardin/scp.py" rel="noreferrer">Python scp module for Paramiko</a>. It's very easy to use. See the following example:</p>
<pre><code>import paramiko
from scp import SCPClient
def createSSHClient(server, port, user, password):
client = paramiko.SSHClient()
client.load_sy... | <p>Hmmm, perhaps another option would be to use something like <a href="http://fuse.sourceforge.net/sshfs.html" rel="nofollow noreferrer">sshfs</a> (there an <a href="http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SSHFS" rel="nofollow noreferrer">sshfs</a> for Mac too). Once your router is mounted you can just copy ... | 31,135 |
<p>We are trying to get our .NET devs to use the <a href="http://msdn.microsoft.com/en-us/library/58wxa9w5%28v=vs.90%29.aspx" rel="nofollow noreferrer">ASP.NET Development Server</a> (VS2008) for web development instead of a local instance of <a href="http://www.iis.net/" rel="nofollow noreferrer">IIS</a>.</p>
<p>I re... | <p>The web server built into VS doesn't not support SSL. It is meant to be a quick way to test an application. For SSL, you would need to use IIS and get a certificate.</p>
| <p>Actually there is a possible approach- if you just want to run ASP.NET programs with SSL, you can use Cassini + Apache Http Proxy/Nginx for Windows. But if you are on Windows XP beware there might have limitations on concurrent connections.</p>
| 22,727 |
<p>I have a large exiting C++ project involving:</p>
<ul>
<li>4 applications</li>
<li>50+ libraries</li>
<li>20+ third party libraries</li>
</ul>
<p>The project uses QMake (part of Trolltech's Qt) to build the production version on Linux, but I've been playing around at building it on MacOS.</p>
<p>I can build in on... | <p>I'm sure this could be of some great help for you :</p>
<p><a href="https://blog.qt.io/blog/2007/08/23/deploying-mac-applications-without-the-hassle/" rel="nofollow noreferrer">deployqt</a></p>
<p>Hope this helps !</p>
| <p>I side-stepped this problem completely by building my Qt app statically on OS X. That might not be practical for you though.</p>
| 4,658 |
<p>No C++ love when it comes to the "hidden features of" line of questions? Figured I would throw it out there. What are some of the hidden features of C++?</p>
| <p>You can put URIs into C++ source without error. For example:</p>
<pre><code>void foo() {
http://stackoverflow.com/
int bar = 4;
...
}
</code></pre>
| <p>Pointer arithmetics.</p>
<p>It's actually a C feature, but I noticed that few people that use C/C++ are really aware it even exists. I consider this feature of the C language truly shows the genius and vision of its inventor.</p>
<p>To make a long story short, pointer arithmetics allows the compiler to perform a[n... | 10,118 |
<p>What would you recommend for OS X development of a graphical application like those possible in WPF?</p>
<p>My specific background is in Smalltalk & Java, but I currently work mostly in DHTML/.NET (ASP.NET/C#).</p>
| <p>Cocoa. Considered by many to be the best application framework ever. The language is Objective-C, SmallTalk-like language that inspired the creators of Java.</p>
<p>Really, there is no reasonable alternative to Cocoa for OS X development, unless you have specific needs like wanting to be cross-platform.</p>
| <p>To put it a different way than previous posters: if you are not designing your interface in InterfaceBuilder and manipulating it with Objective-C, then you are going to end up with an application that does not look, feel, act, or work the way a Macintosh application should, and it will stick out like a sore thumb to... | 3,982 |
<p>I need to enable/disable completely network interfaces from a script in Windows XP. I'm looking for a python solution, but any general way (eg WMI, some command-line à la netsh, some windows call) is welcome and will be adjusted. Thanks.</p>
| <p>Using the netsh interface
Usage set interface [name = ] IfName
[ [admin = ] ENABLED|DISABLED
[connect = ] CONNECTED|DISCONNECTED
[newname = ] NewName ]</p>
<p>Try including everything inside the outer brackets:
netsh interface set interface name="thename" admin=disabled conn... | <p>The <a href="http://support.microsoft.com/kb/311272" rel="nofollow noreferrer">devcon</a> tool can control the NIC, but not the interface directly. It's a command-line version of the Device Manager applet.</p>
<pre><code>devcon disable (id or portion of name)
devcon enable (id or portion of name)
</code></pre>
| 10,933 |
<p>Not a competition, it is instead me trying to find why a certain regex works in one but not the other.</p>
<pre><code>(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
</code></pre>
<p>That's my Regex and I... | <p>It works for me. You must be doing something wrong.</p>
<pre><code>>>> re.match(r'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)', '127.255.0.0').groups()
('127', '255', '0', '0')
</code></pre>
... | <p>That regular expression matches here, no idea what you are doing wrong:</p>
<pre><code>>>> import re
>>> x = re.compile(r'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|'
... r'2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]'
... r'[0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)')... | 14,382 |
<p>In the small application that I'm currently developing for a customer I need to ask the user for his windows login username, password and domain and then use those with <strong>System.Diagnostics.Process.Start</strong> to start an application.</p>
<p>I have a textbox with UseSystemPasswordChar to mask the entered p... | <p>Try looking at the <a href="http://weblogs.asp.net/pglavich/archive/2006/02/26/439077.aspx" rel="noreferrer">SecurePasswordTextBox</a> custom control. Are you trying to do something similar to a "Run As" type command where you are trying to run the process as a different user than the one currently logged on? If not... | <p>The reason the SecureString wants to accept one character at a time is that otherwise you would have the entire string before that and cause the string to be in memory. Thus, using a SecureString in this scenario kind of defeats the purpose.</p>
| 41,038 |
<p>I am building up a view with various text and image elements.</p>
<p>I want to display some text in the view with a blurry copy of the text behind it, but not just a text shadow.</p>
<p>How do I apply Gaussian blurred text onto a UIImage or layer?</p>
| <p>Take a look at Apple's GLImageProcessing iPhone sample. It does some blurring, among other things.</p>
<p>The relevant code includes:</p>
<pre><code>static void blur(V2fT2f *quad, float t) // t = 1
{
GLint tex;
V2fT2f tmpquad[4];
float offw = t / Input.wide;
float offh = t / Input.high;
int i;... | <p>On the desktop, no question, you'd use CoreImage to do this.</p>
<p>On the phone though, I don't think there exists a way to do this using CoreGraphics. If it is absolutely critical OpenGLES may be able to help.</p>
<p>However, I would suggest rethinking your interface. I would think the blurred text would be dist... | 28,126 |
<p>I'm trying to find a way to determine how many parameters a constructor has.</p>
<p>Now I've built one constructor with no parameters and 1 constructor with 4 parameters.</p>
<p>Is there, in C#, a way to find out how many parameters a used or given constructor has?</p>
<p>Thing is, I'm using a third constructor t... | <p>You should look at the System.Reflection Namespace. More specifically, you can get a list of the constructors of a class with:</p>
<pre><code> System.Type.GetType("MYClassName").GetConstructors()
</code></pre>
| <p>i'm not sure exactly what context you need this information, but if you need it dynamically at run-time try the System.Reflection namespace</p>
<p>otherwise the Intellisense drop-list should show you all the constructors available...</p>
| 32,331 |
<p>I was just assigned to do a CMS using ASP.net 3.5 and MySQL. I am kind of new to ASP.NET development (quite sufficient with C#) and <strong>I am wondering what major ASP.NET and general .NET features I am losing when I don't have the option to use Microsoft SQL Server.</strong></p>
<p>I know already from quick Goog... | <p>You can leverage MySql in a number of ORMs, one of which is NHibernate. For the most part you can treat it as if you were running on SQL Server or Oracle. And with Linq2NHibernate, you can get nice LINQ syntax.</p>
<p>You'd lose the SqlDataSource control, but some would argue that it would actually be a blessing ... | <p>Some things that come to mind:</p>
<ul>
<li>asp.net has nice "automatic" user management (authentication) system. I think it only goes with SQL Server, but there might be a way to make it work on other DBs. The tutorials assume SQL Server usually (or the built in file based DB for development)</li>
<li>Not related ... | 7,403 |
<p>Of course most languages have library functions for this, but suppose I want to do it myself.</p>
<p>Suppose that the float is given like in a C or Java program (except for the 'f' or 'd' suffix), for example "<code>4.2e1</code>", "<code>.42e2</code>" or simply "<code>42</code>". In general, we have the "integer pa... | <p>All of the other answers have missed how <strong>hard</strong> it is to do this properly. You can do a first cut approach at this which is accurate to a certain extent, but until you take into account IEEE rounding modes (et al), you will never have the <em>right</em> answer. I've written naive implementations befor... | <p>Using a state machine. It's fairly easy to do, and even works if the data stream is interrupted (you just have to keep the state and the partial result). You can also use a parser generator (if you're doing something more complex).</p>
| 11,081 |
<p>I'm reading in a large text file with 1.4 million lines that is 24 MB in size (average 17 characters a line).</p>
<p>I'm using Delphi 2009 and the file is ANSI but gets converted to Unicode upon reading, so fairly you can say the text once converted is 48 MB in size.</p>
<p>( Edit: I found a much simpler example .... | <p>You asked me personally to answer your question here. I don't know the precise reason why you're seeing such high memory usage, but you need to remember that TStringList does a lot more than just loading your file. Each of these steps requires memory that may result in memory fragmentation. TStringList needs to l... | <p>Why are you loading that amount of data into a TStringList? The list itself will have some overhead. Maybe TTextReader could help you.</p>
| 40,225 |
<p>I have a generic class in C# with 2 constructors:</p>
<pre><code>public Houses(params T[] InitialiseElements)
{}
public Houses(int Num, T DefaultValue)
{}
</code></pre>
<p>Constructing an object using int as the generic type and passing in two ints as arguments causes the 'incorrect' constructor to be called (from... | <p>A clearer solution would be to have two static factory methods. If you put these into a nongeneric class, you can also benefit from type inference:</p>
<pre><code>public static class Houses
{
public static Houses<T> CreateFromElements<T>(params T[] initialElements)
{
return new Houses<... | <p>Perhaps instead of Params you could pass in IEnumerable</p>
<pre><code>public Houses(IEnumerable<T> InitialiseElements){}
</code></pre>
| 26,222 |
<p>You can easily use the <code>PropertyChanges</code> events to set the flag. But how do you easily reset it after a save to the <code>ObjectContext</code>?</p>
| <p>For your specific example, there is no need to worry about it. Web browsers perform typographical rendering and place the correct amount of space between periods and whatever character follows (and it's different depending on the next character, according to kerning rules.)</p>
<p>If you want line breaks, <br/&g... | <p>You'd better use white-space: pre-wrap than white-space: pre or &nbsp;
With your example, the latter solutions can start a new line on "rules.&nbsp;" just because your <strong>n</strong>on-<strong>b</strong>reakable <strong>sp</strong>ace hit the end of the line.</p>
| 3,711 |
<p>Jeff mentioned in one of the podcasts that one of the things he always does is put in instrumentation for database calls, so that he can tell what queries are causing slowness etc. This is something I've measured in the past using SQL Profiler, but I'm interested in what strategies other people have used to include... | <p>If a query is more then just a simple SELECT on a single table I always run it through EXPLAIN if I am on MySQL or PostgreSQL. If you are using SQL Server then Management Studio has a Display Estimated Execution Plan which is essentially the same. It is useful to see how the engine will access each table and what in... | <p>If you're writing queries in SQL Management Studio you can enter: <code>SET STATISTICS TIME ON</code> and SQl Server will tell you how long the individual parts of a query took to parse, compile and execute.
You might be able to log this information by handling the InfoMessage event of the SqlConnection class (but I... | 3,020 |
<p>I'm trying to setup CruiseControl.net webdashboard at the moment. So far it works nice, but I have a problem with the NAnt Build Timing Report.</p>
<p>Firstly, my current <code>ccnet.config</code> file looks something like this:</p>
<pre><code><project name="bla">
...
<prebuild>
<nant .../>
<... | <p>Apparently this can be solved by selecting only the first <code><buildresults></code> node in webdashboard's NAntTiming.xsl. Because each duplicate summary contains the same info this change in <code><div id="NAntTimingReport"></code> section seems to be sufficient:</p>
<pre><code><xsl:variable name=... | <p>Not a direct answer to your question, but you might want to check out Hudson. It has the benefit of being much easier to configure than CruiseControl. There's a bit about using it for NAnt <a href="http://hudson.gotdns.com/wiki/display/HUDSON/NAnt+Plugin" rel="nofollow noreferrer">here</a>.</p>
| 4,548 |
<p>As well-known, C++ has steeper learning curve than most of the mainstream languages, which results in better performance . But, does using C++ over other languages[like Java,Ruby,Python] for Qt development have still (major) advantages,let's say about Qtopia? If any, what are they?</p>
| <p>Qt is natively a C++ API, so any other languages have to have wrapper code around it which needs to be maintained, etc. The primary documentation will also be for the C++ API.</p>
<p>I'm not sure if there are any "official" bindings to other languages which are maintained and released together with Qt.</p>
| <p>it's easier to create a single executable.</p>
<p>don't know if that will be for long...</p>
| 29,256 |
<p>Apple strongly recommends using the binary plist format when reading large XML-based data sets into iPhone apps. Among their reasoning is the fact that XML parsing is very taxing on the iPhone. However, this requires that files residing on the remote web server be converted first.</p>
<p>For frequently-changing con... | <p>Yes. All the plist code is part of CoreFoundation, which is opensource. CoreFoundation can be directly built and run on Linux and Windows, so you can write a CF tool using the normal APIs you would use on Mac OS X, but build and run it on other platforms.</p>
<p>The particular API you want to be looking at is <a hr... | <p><a href="https://github.com/uddhav/java-plist-serializer" rel="nofollow">Java Spring framework solution</a></p>
| 33,124 |
<p>Is there anything similar on Windows what would achieve the same as the InputManager on OS X?</p>
| <ol>
<li>Require SSL on the application</li>
<li>In a custom error page for the 403 redirect the browser to the incoming URL, changing http to https along the way.</li>
</ol>
<p>Note: Keep port 80 open for this - or there won't be a server to listen for requests to redirect.</p>
| <p>Is just not accepting any connections on port 80 an option? I'm a complete web server noob so I don't know if the server can operate without an unsecured listen port but if the server can operate only listen on port 443 that would seem to be simplest option.</p>
<p>Another option would be a redirect from the unsec... | 5,083 |
<p>I would like to know if there is any easy way to print multiple emails(about 200) so that they continue on as opposed to printing one per page. I have tried with thunderbird and evolution and this does not seem possible. Would concatenating the individual mail files work or are there other unix utilities that could ... | <p>Why don't you put all the data from the mails in one text file and print that one.</p>
<p>This could be done by something like:</p>
<pre><code>cat *.eml > file.txt
</code></pre>
<p>Or print it directly with</p>
<pre><code>cat *.eml | lpr
</code></pre>
| <p>I can say for sure about *n*x, but if it is possible to define a printer which only outputs text, and that will output to a text file, then you could print your batch to that printer and remove the form-feeds from the resulting text file.</p>
<p>I've used a similar technique in Windows: create a new printer using t... | 38,735 |
<p>I have a couple of array's:</p>
<pre><code>const string a_strs[] = {"cr=1", "ag=2", "gnd=U", "prl=12", "av=123", "sz=345", "rc=6", "pc=12345"};
const string b_strs[] = {"cr=2", "sz=345", "ag=10", "gnd=M", "prl=11", "rc=6", "cp=34", "cv=54", "av=654", "ct=77", "pc=12345"};
</code></pre>
<p>which i then need to pars... | <p>Probably I didn't get it correctly, but obvious solutions is to split each array element into <code>key</code> and <code>value</code> and then write lo-o-ong <code>if-else-if-else ...</code> sequence like</p>
<pre><code>if (!strcmp(key, "cr"))
my_struct.cr = value;
else if (!strcmp(key, "ag"))
my_struct.ag = ... | <p>The problem is you dont have the metainformation to refer to the struct elements at run time (Something like structVar.$ElementName = ..., where $ElementName is not the element name but a (char?)variable containing the element name which should be used).
My solution would be to add this metainformation.
This should... | 36,395 |
<p>I would like to execute an OS command from my ruby script but I want to add an argument from a ruby variable.</p>
<p>I know that's possible by using keyword <em>system</em> like that :</p>
<pre><code>#!/usr/bin/env ruby
directory = '/home/paulgreg/'
system 'ls ' + directory
</code></pre>
<p>but is that possible b... | <p>No, that will just concatenate the output from <code>ls</code> and the contents of <code>directory</code>.</p>
<p>But you can do this:</p>
<pre><code>#!/usr/bin/env ruby
directory = '/home/paulgreg/'
`ls #{directory}`
</code></pre>
| <p>Nick is right, but there is no need to assemble the args piecewise:</p>
<pre><code>directory = '/Volumes/Omg a space/'
system('/bin/ls', directory)
</code></pre>
| 6,295 |
<p>Is it possible to open a project in Visual Studio 2008 without opening all the files that were previously opened last time I had the project open. I have a habit of keeping many files open as I am working on them, so next time I open the project, it (very slowly) loads up a bunch of files into the editor that I may... | <p>Simply delete the .suo file.
It contains the list of open files.</p>
| <p>The only way works for me is : change the project location and again reopen the solutions form there. :)</p>
| 3,679 |
<p>In Qt, when a widget receives focus, how can get a notification about it, so I can execute some custom code? Is there a signal or an event for that?</p>
| <p>You can add en <code>event filter</code>.<br/>
This is an example of an application written with <strong>QtCreator</strong>. This form has a <strong>QComboBox</strong> named <strong><em>combobox</em></strong>. </p>
<pre><code>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),ui(new Ui::MainWindow)
{
... | <p>QWidget::setFocus() is slot, not signal. You can check if QLineEdit is in focus with <a href="http://doc.trolltech.com/4.4/qwidget.html#focus-prop" rel="nofollow noreferrer">focus property</a>. QLineEdit emits signals when text is changed or edited, see documentation.</p>
| 41,638 |
<p>I have a bunch of images that need to rotate in and out one at a time every 2 seconds with fancy JQuery fadeIn and fadeOut. I have all the images in the HTML to pre-load them and a setInterval timer that fades the current image out, then fades the next image in. Problem is that sometimes when you are clicking or s... | <p>Have you thought about using the <a href="http://malsup.com/jquery/cycle/" rel="nofollow noreferrer">Cycle Plugin</a>? It sounds like this does exactly what you're trying to do, and it offers a lot of flexibility. I've used this plugin myself with great results. Highly recommended.</p>
| <p>I'm having a similar problem using a function I based off of <a href="http://snook.ca/archives/javascript/simplest-jquery-slideshow" rel="nofollow">snook.ca's simplest jquery slideshow</a>. (see my comment @tom) Although mine happens whether I'm clicking or scrolling or not!</p>
<p>It seems as though after the firs... | 33,951 |
<p>I maintain a Java Swing application.</p>
<p>For backwards compatibility with java 5 (for Apple machines), we maintain two codebases, 1 using features from Java 6, another without those features.</p>
<p>The code is largely the same, except for 3-4 classes that uses Java 6 features.</p>
<p>I wish to just maintain 1... | <p>Assuming that the classes have similar functionality with 1.5 vs. 6.0 differences in implementation you could merge them into one class. Then, without editing the source to comment/uncomment, you can rely on the optimization that the compiler always do. If an if expression is always false, the code in the if statem... | <p>There is no pre-compiler in Java. Thus, no way to do a #ifdef like in C.
Build scripts would be the best way.</p>
| 9,986 |
<p>Does anyone know any simple way to retrieve the country from a given IP Address, preferably in ISO_3166-1 format?</p>
| <p>A lot of people (including my company) seem to use MaxMind GeoIP.</p>
<p>They have a free version <a href="http://dev.maxmind.com/geoip/geoip2/geolite2/" rel="noreferrer">GeoLite</a> which is not as accurate as the paid version, but if you're just after something simple, it may be good enough.</p>
| <p>You can give a try to <a href="https://astroip.co" rel="nofollow noreferrer">https://astroip.co</a>, it is a new Geolocation API I built which exposes geo data together with other useful datapoints like currency, timezone, ASN data and security.</p>
<p>Here it is an example of the json response:</p>
<pre><code>curl ... | 2,343 |
<p>we had a heated discussion about a method name. </p>
<p>We have a class <code>User</code>. There is property called "Groups" on the user. It contains all groups that contain the user directly. That's ok. What we have problem with, is the name of the method that would recursively list all user's groups and their "pa... | <p>In the interests of <a href="http://en.wikipedia.org/wiki/Cohesion_(computer_science)" rel="nofollow noreferrer">high cohesion and low coupling</a>, I would suggest keeping that functionality out of your User class entirely. It should also be easier to implement caching for multiple calls if that functionality was i... | <p>I'm from Stej's team:-) There is already property called "Groups" on the user. It contains all groups that contain the user directly. That's ok. </p>
<p>What we have problem with, is the name of the method that would recursively list all user's groups and their "parent" groups and return list of all groups, of whic... | 24,425 |
<p>We've used the no-longer-supported RichTextBox control as part of our (ASP.NET-based) CMS for a long time, and we'd like to replace it with something lighter-weight and with better cross-browser support. We were originally looking at various ASP.NET components, but I'm wondering if we'd be better off just using an o... | <p>I've used <a href="http://tinymce.moxiecode.com/" rel="noreferrer">TinyMCE</a>. Great across browsers; easy to configure to be extremely light weight and allows you to control what your user can do. Some of the plug-ins (such as the image manager) are great and easy to implement. Nice that it also support the Google... | <p>WebKit.org has a <a href="http://webkit.org/demos/editingToolbar/" rel="nofollow noreferrer">demo</a> of a very nice/subtle text editor, but i don't know if it works in IE at all (It does work in WebKit based browsers (obviously) and Firefox) </p>
| 21,814 |
<p>I created a separate assembly to contain common extension methods, the extension methods uses classes from <code>System.Web.dll</code> (and others).</p>
<p>When I then create a new project (Console Application) that references the <code>Utilities.dll</code> assembly that contains the extension methods, I do not nee... | <p>well, yes! In order to compile, it needs to be able to resolve everything in the public/protected API. Otherwise it can't enforce the constraint. I imagine it needs to recognise the types to see if the extension method is a candidate for a method.</p>
<p>You could try placing the extension methods in a child namesp... | <p>@Marc gives you the why. I would suggest that as a good practice you break out anything that refers to web classes into yet another assembly, say Com.Company.Extensions.Web in addition to Com.Company.Extensions. Then you can include both in web projects and only the non-web extensions in other projects.</p>
| 49,475 |
<p>we are using git-svn to manage branches of an SVN repo. We are facing the following problem: after a number of commits by user X in the branch, user Y would like to use git-svn to merge the changes in branch to trunk. The problem we're seeing is that the commit messages for all the individual merge operations look a... | <p>The git-svn man page recommends that you <em>don't use merge</em>. ""It is recommended that you run git-svn fetch and rebase (not pull or merge)"". Having said that, you can do what you like :-)</p>
<p>There are 2 issues here. First is that svn only stores the <em>commiter</em>, not the author of a patch as git doe... | <p>Try using the --add-author-from and --use-log-author options to git-svn.</p>
| 15,440 |
<p>When reading some answers to aquestion on <a href="https://stackoverflow.com/questions/118884/what-is-an-elegant-way-to-force-browsers-to-reload-cached-cssjs-files">clearing cache for JS files</a>, somebody pointed to this part of the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.9" rel="nofo... | <p>AFAIK there is no difference on the part of browsers as both Firefox and IE will (incorrectly) cache the response from a url with a querystring, in the same way they cache the response from a url without a querystring. In the case of Safari it respects the spec and doesn't cache urls with querystrings. HTTP proxie... | <p>I believe you manage caching in ASP.NET MVC using the OutputCache attribute (on your controller methods).</p>
| 15,918 |
<p>I need to write a little tool for a customer to be run on Windows 98. Since this is a very small project I'd hope that I could avoid having to go native C++ and use C#.</p>
<p>The <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5" rel="noreferrer">.net Framework ... | <p>There are a few features that Win98 won't support such as form opacity and balloon tooltips. If you use any P/Invoke, you'll have to make sure to support ANSI versions of functions (use <code>CharSet.Auto</code>) and you'll have to check MSDN to make sure that the API functions you're using are supported on Win98. ... | <p>I've written several "small tools" that I have personally run on Win98. What I would suggest is that you create a VM and test out your app after every significant build.</p>
<p>The issues I saw was almost completely UI related (things <em>really</em> didn't size correctly).</p>
| 38,228 |
<p>Passing an undimensioned array to the VB6's Ubound function will cause an error, so I want to check if it has been dimensioned yet before attempting to check its upper bound. How do I do this?</p>
| <blockquote>
<p><strong>Note:</strong> the code has been updated, the original version can be found in the <a href="https://stackoverflow.com/posts/183668/revisions">revision history</a> (not that it is useful to find it). The updated code does not depend on the undocumented <code>GetMem4</code> function and <a href=... | <pre><code>Dim someArray() as Integer
If someArray Is Nothing Then
Debug.print "this array is not initialised"
End If
</code></pre>
| 22,163 |
<p>The thing is I've been using the <a href="http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx" rel="noreferrer">lock statement</a> to protect a critical part of my code, but now, I realize I could allow concurrent execution of that critical code is some conditions are met.<br>
Is there a way to condition the lock?... | <pre><code>Action doThatThing = someMethod;
if (condition)
{
lock(thatThing)
{
doThatThing();
}
}
else
{
doThatThing();
}
</code></pre>
| <p>Use <a href="http://en.wikipedia.org/wiki/Double_checked_locking_pattern" rel="nofollow noreferrer" title="Wikipedia link: Double-Checked Locking pattern">Double-checked locking pattern</a>, as suggested above. that's the trick IMO :)</p>
<p>make sure you have your lock object as a <em>static</em>, as listed in not... | 30,117 |
<p>How do I get Perl to read the contents of a given directory into an array?</p>
<p><a href="https://en.wikipedia.org/wiki/Grave_accent#Use_in_programming" rel="noreferrer">Backticks</a> can do it, but is there some method using 'scandir' or a similar term?</p>
| <pre><code>opendir(D, "/path/to/directory") || die "Can't open directory: $!\n";
while (my $f = readdir(D)) {
print "\$f = $f\n";
}
closedir(D);
</code></pre>
<p>EDIT: Oh, sorry, missed the "into an array" part:</p>
<pre><code>my $d = shift;
opendir(D, "$d") || die "Can't open directory $d: $!\n";
my @list = rea... | <p>from: <a href="http://perlmeme.org/faqs/file_io/directory_listing.html" rel="nofollow noreferrer">http://perlmeme.org/faqs/file_io/directory_listing.html</a></p>
<pre><code>#!/usr/bin/perl
use strict;
use warnings;
my $directory = '/tmp';
opendir (DIR, $directory) or die $!;
while (my $file = readdir(DIR)) {
... | 4,260 |
<p>Does anyone know of a hot end that is sealed? What I meaning is that the hot end has a rubber seal where the filament enters to keep the top airtight (in order to eliminate oozing).</p>
<p>I am looking to build a dual extruder printer but, I do not want any oozing from the hot end which is not in use. I could build ... | <p>There's a lot that can be done to improve the removability of supports, and much of this is not widely known/published.</p>
<p>One big wrong default in Cura that contributes to problems with support is <em>Limit Support Retractions</em>, which defaults to on. This causes heavy stringing between components of the sup... | <p>You could reduce the <code>Support Density</code>:</p>
<blockquote>
<p>A higher value results in better overhangs, but the supports are harder to remove.</p>
</blockquote>
<p>Furthermore read <a href="https://3dprinting.stackexchange.com/a/7991/">this answer</a> on question: "<a href="https://3dprinting.stackex... | 1,723 |
<p>I doubt I am the only one who has come up with this solution, but if you have a better one please post it here. I simply want to leave this question here so I and others can search it later. </p>
<p>I needed to tell whether a valid date had been entered into a text box and this is the code that I came up with. I fi... | <pre><code>DateTime.TryParse
</code></pre>
<p>This I believe is faster and it means you dont have to use ugly try/catches :)</p>
<p>e.g</p>
<pre><code>DateTime temp;
if(DateTime.TryParse(startDateTextBox.Text, out temp))
{
// Yay :)
}
else
{
// Aww.. :(
}
</code></pre>
| <pre><code>DateTime temp;
try
{
temp = Convert.ToDateTime(grd.Rows[e.RowIndex].Cells["dateg"].Value);
grd.Rows[e.RowIndex].Cells["dateg"].Value = temp.ToString("yyyy/MM/dd");
}
catch
{
MessageBox.Show("Sorry The date not valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop,MessageBoxDefaultButton.... | 48,619 |
<p>As far as variable naming conventions go, should iterators be named <code>i</code> or something more semantic like <code>count</code>? If you don't use <code>i</code>, why not? If you feel that <code>i</code> is acceptable, are there cases of iteration where it shouldn't be used?</p>
| <p>Depends on the context I suppose. If you where looping through a set of Objects in some
collection then it should be fairly obvious from the context what you are doing.</p>
<pre><code>for(int i = 0; i < 10; i++)
{
// i is well known here to be the index
objectCollection[i].SomeProperty = someValue;
}
</... | <p>I am going to go against the grain and say no. </p>
<p>For the crowd that says "i is understood as an iterator", that may be true, but to me that is the equivalent of comments like 'Assign the value 5 to variable Y. Variable names like comment should explain the why/what not the how.</p>
<p>To use an example from ... | 15,883 |
<p>I have an alert script that I am trying to keep from spamming me so I'd like to place a condition that if an alert has been sent within, say the last hour, to not send another alert. Now I have a cron job that checks the condition every minute because I need to be alerted quickly when the condition is met but I don... | <p>By far the easiest is to store time stamps as modification times of dummy files. GNU <code>touch</code> and <code>date</code> commands can set/get these times and perform date calculations. Bash has tests to check whether a file is newer than (<code>-nt</code>) or older than (<code>-ot</code>) another.</p>
<p>For e... | <p>Use "test":</p>
<pre><code>if test file1 -nt file2; then
# file1 is newer than file2
fi
</code></pre>
<p>EDIT: If you want to know when an event occurred, you can use "touch" to create a file which you can later compare using "test".</p>
| 25,196 |
<p>Is there a way to compile an Eclipse-based Java project from the command line? </p>
<p>I'm trying to automate my build (using FinalBuilder not ant), and I'm neither a Java nor Eclipse expert. I can probably figure out how to do this with straight java command line options, but then the Eclipse project feels like a ... | <p>You can build an eclipse project via a workspace from the command line:</p>
<pre><code>eclipsec.exe -noSplash -data "D:\Source\MyProject\workspace" -application org.eclipse.jdt.apt.core.aptBuild
</code></pre>
<p>It uses the <code>jdt apt</code> plugin to build your workspace automatically. This is also known as a... | <p>Short answer. No.
Eclipse does not have a command line switch like Visual Studio to build a project.</p>
| 25,295 |
<p>How do I check if the timestamp date of a record is before midnight today?</p>
<p>datediff is driving me nuts...</p>
| <p>Try:</p>
<pre><code>WHERE dtColumn < DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
</code></pre>
| <p>Try this:</p>
<pre><code>where myColumn < cast( (cast(getdate() - 0.5 as int)) as datetime)
</code></pre>
| 39,465 |
<p>How can I build a native Mac OS X installer for my application, on a non-Mac platform?</p>
<p>For example, I have a windows pc and a Java application. I want the windows pc to build an installer (possibly inside a .dmg archive) that works with Apple installer.</p>
| <p>It is now possible to create a native Mac OS X installer on a non-Mac platform. As Louis Gerbarg, the tricky bit is the BOM (bill-of-materials) file. However an open source version of mkbom (based on the osxbom code by Joseph Coffland) is now available at:</p>
<p><a href="http://hogliux.github.io/bomutils" rel="nof... | <p>Put everything into one JAR file, add it to a ZIP. Done.</p>
<p>But seriously, you're wanting to distribute your application to Macintosh users without testing it first? What planet are you on!?</p>
| 35,942 |
<p>In the below program:</p>
<pre><code>class Main
{
static string staticVariable = "Static Variable";
string instanceVariable = "Instance Variable";
public Main(){}
}
</code></pre>
<p>The <code>instanceVariable</code> will be stored inside the memory allocated for object instance. Where will the <... | <p>Memory for static variables are normally held in some rooted (and hidden) <code>object[]</code>. This can be seen doing a !gcroot on the object in WinDbg (with SOS).</p>
<p>Just to add, these references can never be GC'ed (unless you null the field), as I discovered recently.</p>
| <p>For instance in C++ staic variables are allocated in global memory space with global variables. Compiler uses special naming convention to know that this variable belongs to the class.</p>
| 43,724 |
<p>I need to speed up a program for the Nintendo DS which doesn't have an FPU, so I need to change floating-point math (which is emulated and slow) to fixed-point.</p>
<p>How I started was I changed floats to ints and whenever I needed to convert them, I used <strong>x>>8</strong> to convert the fixed-point variable x... | <p>You can try my fixed point class (Latest available @ <a href="https://github.com/eteran/cpp-utilities" rel="noreferrer">https://github.com/eteran/cpp-utilities</a>)</p>
<pre><code>// From: https://github.com/eteran/cpp-utilities/edit/master/Fixed.h
// See also: http://stackoverflow.com/questions/79677/whats-the-bes... | <p>Whichever way you decide to go (I'd lean toward a typedef and some CPP macros for converting), you will need to be careful to convert back and forth with some discipline.</p>
<p>You might find that you never need to convert back and forth. Just imagine everything in the whole system is x256.</p>
| 10,508 |
<p>Scenario:</p>
<ol>
<li>The user has two monitors.</li>
<li>Their browser is open on the secondary monitor.</li>
<li>They click a link in the browser which calls window.open() with a specific top and left window offset.</li>
<li>The popup window always opens on their primary monitor.</li>
</ol>
<p>Is there any way ... | <p>You can't specify the monitor, but you can specify the position of the popup window as being relative to the where the click caused the window to popup. </p>
<p>Use the getMouseXY() function to get values to pass as the left and top args to the window.open() method. (the left and top args only work with V3 and up b... | <p>as long as you know the x and y position that falls on the particular monitor you can do:</p>
<pre><code>var x = 0;
var y = 0;
var myWin = window.open(''+self.location,'mywin','left='+x+',top='+y+',width=500,height=500,toolbar=1,resizable=0');
</code></pre>
| 8,199 |
<p>In an Oracle cluster (more than one machine co-operating to serve one database) will the "sysdate" function always return a consistent answer? Even if the servers' Operating System clock reports inconsistent values?</p>
| <p>I would strongly suspect that SYSDATE is OS-linked too. Be very watchful of the reason why you need to use it. If have any logic which implements incremental tracking of events (e.g. you're doing incremental exports) and you must ensure no items left out as well as no duplication, base the tracking on sequential IDs... | <p>I spent a (little bit) of time looking for an answer to this, but couldn't find one, but, given that sysdate is just returning the date/time from the operating system, I suspect dmitriy is correct.</p>
| 22,104 |
<p>I made a class from Linq to SQL Clasees with VS 2008 SP1 Framework 3.5 SP1, in this case I extended the partial</p>
<pre><code>partial void UpdateMyTable(MyTable instance){
// Business logic
// Validation rules, etc.
}
</code></pre>
<p>My problem is when I execute db.SubmitChanges(), it executes UpdateMyTabl... | <ul>
<li>if you provide this method, you must perform the update in the method.</li>
</ul>
<hr>
<p><a href="http://msdn.microsoft.com/en-us/library/bb882671.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb882671.aspx</a></p>
<ul>
<li>If you implement the Insert, Update and Delete methods in... | <p>If you want to implement this method but not do the update yourself you make the method call ExecuteDynamicUpdate(item);</p>
<p>Likewise ExecuteDynamicDelete and ExecuteDynamicInsert for DeleteMyTable and InsertMyTable respectively.</p>
| 16,875 |
<p>What features do you wish were in common languages? More precisely, I mean features which generally don't exist at all but would be nice to see, rather than, "I wish dynamic typing was popular."</p>
| <p>I've often thought that "observable" would make a great field modifier (like public, private, static, etc.)</p>
<pre><code>GameState {
observable int CurrentScore;
}
</code></pre>
<p>Then, other classes could declare an observer of that property:</p>
<pre><code>ScoreDisplay {
observe GameState.CurrentScore(... | <p>I'd like a language that was much more restrictive and was designed around producing good, maintainable code without any trickiness. Also, it should be designed to give the compiler the ability to check as much as possible at compile time. </p>
<p>Start with a newish VM based heavily OO language.</p>
<ul>
<li>Re... | 39,854 |
<p>I need a method for adding "business days" in PHP. For example, Friday 12/5 + 3 business days = Wednesday 12/10.</p>
<p>At a minimum I need the code to understand weekends, but ideally it should account for US federal holidays as well. I'm sure I could come up with a solution by brute force if necessary, but I'm ho... | <p>Here's a function from the <a href="http://www.php.net/manual/en/function.date.php#79911" rel="noreferrer">user comments</a> on the date() function page in the PHP manual. It's an improvement of an earlier function in the comments that adds support for leap years.</p>
<p>Enter the starting and ending dates, along w... | <p>I just get my function working based on Bobbin and mcgrailm code, adding some things that worked perfect to me.</p>
<pre><code>function add_business_days($startdate,$buisnessdays,$holidays,$dateformat){
$enddate = strtotime($startdate);
$day = date('N',$enddate);
while($buisnessdays > 0){ // compatib... | 43,607 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.