instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I have been working as a native C++ programmer for last few years. Now we are starting a new project from the scratch. So what is your thoughts on shifting to C++\CLI at the cost of losing platform independent code. Are there are any special advantages that one can gain by shifting to C++\CLI?</p>
<p>I would recommend the following, based on my experience with C++, C# and .NET:</p> <ul> <li>If you want to go the .NET way, use C#.</li> <li>If you do not want .NET, use traditional C++.</li> <li>If you have to bridge traditional C++ with .NET code, use C++/CLI. Works both with .NET calling C++ classes and C++ call...
<p>One main disadvantage of using C++/CLR is the possibility of losing your IP (intellectual Property) if the code is not obscured suficently. In general I agree with the statements made by other members here. If you want portable code independant of the MS .net vm then native C/C++ is the way to go. </p>
18,392
<p>i am trying to fix a site I am helping a friend with, and in IE it is displaying the navigation bar like it is stacking on top of each other.</p> <p>Is that a part of the double float bug, I tried adding display:inline, but I still have that problem.</p> <p>URL: <a href="http://www.flanels.com/RadiantecHOME.html" ...
<p>Well, protobuf-net will simply handle this for you; it runs off the properties of types, and has full support for <code>decimal</code>. Since there is no direct way of expressing <code>decimal</code> in proto, it won't (currently) generate a <code>decimal</code> property from a ".proto" file, but it would be a nice ...
<p>I put together a patch for protobuf-csharp-port with hooks which generates protobuf classes with native Decimal and DateTime structs. Wire format wise, they are represented by two "built-in" proto messages.</p> <p>Here is the link: <a href="https://code.google.com/p/protobuf-csharp-port/issues/detail?can=2&amp;star...
48,567
<p>In Perl</p> <pre><code>print "a" x 3; # aaa </code></pre> <p>In C# </p> <pre><code>Console.WriteLine( ??? ) </code></pre>
<p>It depends what you need... there is <code>new string('a',3)</code> for example.</p> <p>For working with strings; you could just loop... not very interesting, but it'll work.</p> <p>With 3.5, you could use <code>Enumerable.Repeat("a",3)</code>, but this gives you a sequence of strings, not a compound string.</p> ...
<p>If you need to do this with strings like Tom pointed out, then an extension method will do the job nicely.</p> <pre><code>static class StringHelpers { public static string Repeat(this string Template, int Count) { string Combined = Template; while (Count &gt; 1) { Combined += Tem...
37,829
<p>I've got a (poorly written) base class that I want to wrap in a proxy object. The base class resembles the following:</p> <pre><code>public class BaseClass : SomeOtherBase { public BaseClass() {} public BaseClass(int someValue) {} //...more code, not important here } </code></pre> <p>and, my proxy rese...
<p>If you do not explicitly call any constructor in the base class, the parameterless constructor will be called implicitly. There's no way around it, you cannot instantiate a class without a constructor being called.</p>
<p>I ended up doing something like this:</p> <pre><code>public class BaseClassProxy : BaseClass { public BaseClass BaseClass { get; private set; } public virtual int MethodINeedToOverride(){} public virtual string PropertyINeedToOverride() { get; protected set; } } </code></pre> <p>This got me around some ...
19,271
<p>In a SQL Server database, I record people's date of birth. Is there an straight-forward method of working out the person's age on a given date using SQL only? </p> <p>Using <strong>DATEDIFF(YEAR, DateOfBirth, GETDATE())</strong> does not work as this only looks at the year part of the date. For example <strong>DATE...
<p>Check out this article: <a href="http://www.kodyaz.com/articles/calculate-age-sql-code.aspx" rel="noreferrer">How to calculate age of a person using SQL codes</a></p> <p>Here is the code from the article:</p> <pre><code>DECLARE @BirthDate DATETIME DECLARE @CurrentDate DATETIME SELECT @CurrentDate = '20070210', @B...
<p>I hope this one is perfect provided you accept the algorithm that a leap-baby turns a year older on successive February 29th's, or March 1's on non-leap years. @DOB must contain a date within a few centuries of now, @AsOf must contain a similar date >= @DOB:</p> <pre><code>SET @Age = YEAR(@AsOf) - YEAR(@DOB) - 1 IF...
35,989
<p>In my free time I started writing a small multiplayer game with a database backend. I was looking to separate player login information from other in game information (inventory, stats, and status) and a friend brought up this might not be the best idea.</p> <p>Would it be better to lump everything together in one t...
<p>Start by ignoring performance, and just create the most logical and easy-to-understand database design that you can. If players and game objects (swords? chess pieces?) are separate things conceptually, then put them in separate tables. If a player can carry things, you put a foreign key in the "things" table that r...
<p>Probably as well to put it in one table in this situation as your query performance will be better.</p> <p>You really only want to use the next table when there will be an element of duplicate data by which you should look to normalization to reduce your data storage overheads.</p>
20,621
<p>I am trying to find out if it's possible to build a complete IVR application by cobbling together parts from open source projects. Is anyone using a non-commercial VoiceXML implementation to build speech-enabled systems?</p>
<p>I've tried JVoiceXML in the past and had some luck with it.</p> <p><a href="http://jvoicexml.sourceforge.net/" rel="noreferrer">http://jvoicexml.sourceforge.net/</a></p> <p>It's java of course, but that wasn't a problem for my situation.</p>
<p>If you want to build an IVR and you're not married to VoiceXML, you might try <a href="http://www.twilio.com/" rel="nofollow noreferrer">Twilio</a>. They have a simple XML syntax, an awesome REST API, and small-project-friendly pay per minute pricing which lets you concentrate on building your app and not building/h...
5,668
<p>Is there any resource that provides a chart of CSS properties and their support through most browser/OS combinations? For example, if I want to know what browser supports <code>overflow</code> or <code>min-height</code> and any quirks to be aware of in the implementation of these properties and their values, what is...
<p><a href="http://www.quirksmode.org/css/contents.html" rel="noreferrer">http://www.quirksmode.org/css/contents.html</a></p> <p>Quriks mode is also a really good resource for this sort of information.</p>
<p>Most of the CSS reference sites I used to use are out of date, but SitePoint recently (I'd say the past year) released a <a href="http://reference.sitepoint.com/css" rel="nofollow noreferrer" title="CSS Reference">CSS Reference</a> that is kept up to date and is easy to navigate. </p>
24,863
<p>On OS from win 2000 or later (any language) can I assume that this path will always exists? For example I know that on win xp in some languages the "Program Files" directory have a different name. So is it true for the System32 folder?</p> <p>Thanks. Ohad.</p>
<p>You definitely cannot assume that: Windows could be installed on a different drive letter, or in a different directory. On a previous work PC Windows was installed in D:\WINNT, for example.</p> <p>The short answer is to use the API call GetSystemDirectory(), which will return the path you are after.</p> <p>The lon...
<p>Just an FYI, but in a Terminal Server environment (ie, Citrix), GetWindowsDirectory() may return a unique path for a remote user. </p> <p><a href="http://msdn.microsoft.com/en-us/library/ms724454(VS.85).aspx" rel="nofollow noreferrer">link text</a></p> <p>As more and more companies use virtualized desktops, devel...
29,595
<p>I have a small server program that accepts connections on a TCP or local UNIX socket, reads a simple command and (depending on the command) sends a reply.</p> <p>The problem is that the client may have no interest in the answer and sometimes exits early. So writing to that socket will cause a <code>SIGPIPE</code> a...
<p>You generally want to ignore the <code>SIGPIPE</code> and handle the error directly in your code. This is because signal handlers in C have many restrictions on what they can do.</p> <p>The most portable way to do this is to set the <code>SIGPIPE</code> handler to <code>SIG_IGN</code>. This will prevent any socke...
<p>Linux manual said:</p> <blockquote> <p>EPIPE The local end has been shut down on a connection oriented socket. In this case the process will also receive a SIGPIPE unless MSG_NOSIGNAL is set.</p> </blockquote> <p>But for Ubuntu 12.04 it isn't right. I wrote a test for that case ...
13,356
<p>If you have several <code>div</code>s on a page, you can use CSS to size, float them and move them round a little... but I can't see a way to get past the fact that the first <code>div</code> will show near the top of the page and the last <code>div</code> will be near the bottom! I cannot completely override the or...
<p>CSS can take elements <em>out of the normal flow</em> and position them anywhere, in any manner you want. But it cannot <em>create a new flow</em>. </p> <p>By this I mean that you can position the last item from the html document at the beginning/top of the page/window, and you can position the first item from th...
<p>Good point about the header always being first and the footer last! But I might want to move my advertising DIV from along the top, to down the right.</p> <p>The other thing I've heard about is putting the content DIV first, so Google pays you more attention (relevant keywords near the top of the page score higher)...
11,769
<p>Aside from using the region to infer which carrier the user is under.</p>
<p>1st Import <code>#import &lt;CoreTelephony/CTTelephonyNetworkInfo.h&gt;</code> make sure you have the Framework installed too.</p> <pre><code>CTTelephonyNetworkInfo *phoneInfo = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier *phoneCarrier = [phoneInfo subscriberCellularProvider]; NSLog(@"Carrier = %@", [phoneCarr...
<p>No, there is no API in the SDK to do this.</p>
38,622
<p>Is there anything that has features of TFS(Like Source Control, Debug, Testing,...) that we can use in a workgroup with a small team(say 1-6 persons)?</p> <p>BTW: we are using VS 2008 Team Suit</p>
<p>Do you particularly need it all in one package? Various open source projects only do one thing, but integrate nicely with others. For instance:</p> <ul> <li><a href="http://subversion.tigris.org" rel="noreferrer">Subversion</a> for source control</li> <li><a href="http://trac.edgewall.org/" rel="noreferrer">Trac</a...
<p>I was in the same boat as you. I even asked a <a href="https://stackoverflow.com/questions/291145/is-the-subversion-stack-a-realistic-alternative-to-team-foundation-server">question about it here at SO</a>. We had the budget for TFS, and even the hardware to put it on, but with our team only being 5 people, going th...
33,625
<p>How do I invoke a console application from my .NET application and capture all the output generated in the console? </p> <p>(Remember, I don't want to save the information first in a file and then relist as I would love to receive it as live.)</p>
<p>This can be quite easily achieved using the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx" rel="noreferrer">ProcessStartInfo.RedirectStandardOutput</a> property. A full sample is contained in the linked MSDN documentation; the only caveat is that you...
<p>From <em><a href="http://pythontr.org/index.php?option=com_content&amp;view=article&amp;id=50:python-script-lerinin-c-ile-caltrlmas-execute-python-script-in-c&amp;catid=31:makale&amp;Itemid=66" rel="nofollow noreferrer">PythonTR - Python Programcıları Derneği, e-kitap, örnek</a></em>:</p> <pre><code>Process p = new...
22,612
<p>This is a sample (edited slightly, but you get the idea) of my XML file:</p> <pre><code>&lt;HostCollection&gt; &lt;ApplicationInfo /&gt; &lt;Hosts&gt; &lt;Host&gt; &lt;Name&gt;Test&lt;/Name&gt; &lt;IP&gt;192.168.1.1&lt;/IP&gt; &lt;/Host&gt; &lt;Host&gt; &lt;Name&gt;Test&lt;/Name&gt...
<p>You could load them into an XmlDocument and use an XPath statement to fill a NodeList...</p> <pre><code>Dim doc As XmlDocument = New XmlDocument() doc.Load("hosts.xml") Dim nodeList as XmlNodeList nodeList = doc.SelectNodes("/HostCollectionInfo/Hosts/Host") </code></pre> <p>Then loop through the nodes</p>
<pre><code> XPathDocument xpathDoc; using (StreamReader input = ...) { xpathDoc = new XPathDocument(input); } XPathNavigator nav = xpathDoc.CreateNavigator(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nav.NameTable); XPathNod...
14,998
<p>My code takes an interface as input but only excercises a couple of the interface's methods (often, just getters).</p> <p>When testing the code, I'd love to define an anonymous inner class that returns the test data. But what do I do about all the other methods that the interface requires?</p> <p>I could use my I...
<p>If you are using JUnit to test, use Mocks instead of stubs.</p> <p>Read Martin Fowler's seminal article "<a href="http://martinfowler.com/articles/mocksArentStubs.html" rel="nofollow noreferrer">Mocks Aren't Stubs</a>"</p> <p>I recommend the <a href="http://www.easymock.org/" rel="nofollow noreferrer">EasyMock</a>...
<p>Write an "Adapter Class" and overwrite only the methods you care.</p> <pre><code>class MyAdapter extends MyClass { public void A() { } ... } </code></pre>
11,976
<p>I would like to implement something similar to a c# delegate method in PHP. A quick word to explain what I'm trying to do overall: I am trying to implement some asynchronous functionality. Basically, some resource-intensive calls that get queued, cached and dispatched when the underlying system gets around to it. ...
<p>(Apart from the observer pattern) you can also use <a href="http://php.net/manual/function.call-user-func.php" rel="nofollow noreferrer"><code>call_user_func()</code></a> or <a href="http://php.net/manual/function.call-user-func-array.php" rel="nofollow noreferrer"><code>call_user_func_array()</code></a>.</p> <p>If...
<p>How do you feel about using the <a href="http://en.wikipedia.org/wiki/Observer_Pattern" rel="nofollow noreferrer">Observer</a> pattern? If not, you can implement a true callback this way:</p> <pre><code>// This function uses a callback function. function doIt($callback) { $data = "this is my data"; $call...
7,105
<p>I've used the CF <a href="http://blogs.msdn.com/stevenpr/archive/2006/04/17/577636.aspx" rel="nofollow noreferrer">Remote Performance Monitor</a>, however this seems to only track memory initialised in the managed world as opposed to the unmanaged world. Well, I can only presume this as the numbers listed in the pro...
<p>Try enabling <a href="http://blogs.msdn.com/stevenpr/archive/2005/06/22/431612.aspx" rel="nofollow noreferrer">Interop logging</a>.</p> <p>Also, if you have access to the code of the native dll you are using, check this out: <a href="http://msdn.microsoft.com/en-us/netframework/bb630228.aspx" rel="nofollow noreferr...
<p>I've definitely been fighting with unmanaged issues in a C# managed app for a while -- it's not easy. </p> <p>What I've found to be most helpful is to have a regular output to a text log file. For example you can print the output of <a href="http://msdn.microsoft.com/en-us/library/aa908760.aspx" rel="nofollow nore...
3,153
<p>I find that getting Unicode support in my cross-platform apps a real pain in the butt.</p> <p>I need strings that can go from C code, to a database, to a Java application and into a Perl module. Each of these use a different Unicode encodings (UTF8, UTF16) or some other code page. The biggest thing that I need is...
<p>Have a look at this: <a href="http://www.icu-project.org/" rel="nofollow noreferrer" title="International Components for Unicode">http://www.icu-project.org/</a></p>
<p>How are you doing the cross-platform calls? Is it all called from Java? </p> <p><a href="http://java.sun.com/docs/books/tutorial/i18n/text/string.html" rel="nofollow noreferrer">http://java.sun.com/docs/books/tutorial/i18n/text/string.html</a> might be useful.</p> <p>I'm a bit confused about exactly what you are t...
5,996
<p>The ActiveScaffold list view has a search form that is loaded via ajax when a user click the search link. I'd prefer to have the form show by default when a user opens a list page.</p> <p>I've figured out a way to trigger the ajax call when the page loads, but I'm wondering if there's a way to get ActiveScaffold to...
<p>There is a way to get it rendered automatically:</p> <p>active_scaffold :model do |config| config.list.always_show_search = true end</p>
<p>I don't currently have an active scaffold project handy but here is how I would figure it out.</p> <p>I'd use firefox with firebug installed and take a look at what is called when the link is clicked. Then I would go look at that javascript and what it is generating. Then I would search the source for any part of...
46,257
<p>I understand that boxing and unboxing is about casting (real type to object... object to real type). But I do not understand what the MSDN say about it with the Nullable. Here is the text I do not understand:</p> <blockquote> <p>When a nullable type is boxed, the common language runtime automatically boxes the un...
<p>What it's saying is that if you do:</p> <pre><code>int? x = 5; object y = x; // Boxing </code></pre> <p>You end up with a boxed <code>int</code>, not a boxed <code>Nullable&lt;int&gt;</code>. Similarly if you do:</p> <pre><code>int? x = null; // Same as new Nullable&lt;int&gt;() - HasValue = false; object y = x; ...
<p>If a <code>Nullable&lt;T&gt;</code> is <code>null</code>, it'll be boxed as a null reference and will not behave as a boxed value type with <code>HasValue = true</code>.</p> <p>In fact, to implement this feature, it was required that CLR intrinsically support <code>Nullable&lt;T&gt;</code> type and treat it differe...
49,029
<p>I am working on an application that uses several large canvas controls (several thousand pixels across), layered on top of each other. The canvas controls themselves are completely invisible, but each contains a number of controls, mainly images.</p> <p>My question is, is there a recommended maximum size for a can...
<p>From my understanding of the innards of <code>Canvas</code>, it should need no additional memory for being bigger.</p> <p>The first thing that comes to my mind on having a non-zero sized <code>Canvas</code> is that it allows one to put items on it relatively to any of the four corners, which helps when e.g. resizin...
<p>From my understanding of the innards of <code>Canvas</code>, it should need no additional memory for being bigger.</p> <p>The first thing that comes to my mind on having a non-zero sized <code>Canvas</code> is that it allows one to put items on it relatively to any of the four corners, which helps when e.g. resizin...
29,356
<p>I have an MSBuild task to build a specific project in a solution file. It looks something like this:</p> <pre><code>&lt;Target Name="Baz"&gt; &lt;MSBuild Projects="Foo.sln" Targets="bar:$(BuildCmd)" /&gt; &lt;/Target&gt; </code></pre> <p>From the command line, I can set my <code>BuildCmd</code> to either <code>R...
<p>I understood that you want to build a target with a specific command: Build, Clean, etc.</p> <p>This is how I would do it.</p> <p>Create a property to receive your build command, when not specified defaults to Build</p> <pre><code>&lt;PropertyGroup&gt; &lt;BuildCmd Condition=" '$(BuildCmd)' == ''"&gt;Build&lt;/...
<p>Just edit the sln file yourself and find out - MSBuild is a real easy syntax, just look for targets.</p>
28,722
<p>I have 2 files:</p> <pre><code>/****demo.cpp****/ #include &lt;iostream.h&gt; #include "gc.h" class foo{}; int main(){ gc&lt;foo&gt; x1; cout&lt;&lt;x1; } /*****gc.h*****/ template &lt;class T&gt; class gc { T* ptr; public: operator T*(){} }; </code></pre> <p>If I don't write <code>operator T*(...
<p>operator <code>T*(){}</code> is a <a href="http://msdn.microsoft.com/en-us/library/ts48df3y.aspx" rel="nofollow noreferrer">cast operator</a>. You are providing a function that can be used to convert from a <code>gc&lt;T&gt;</code> to a <code>T*</code> ... though it should require that you actually return somethin...
<p>operator <code>T*(){}</code> is a <a href="http://msdn.microsoft.com/en-us/library/ts48df3y.aspx" rel="nofollow noreferrer">cast operator</a>. You are providing a function that can be used to convert from a <code>gc&lt;T&gt;</code> to a <code>T*</code> ... though it should require that you actually return somethin...
34,679
<p>I'm looking it over and it seems to be that it is fundamentally broken.</p> <ul> <li>Only 5 instance methods aren't marked obsolete. </li> <li>There doesn't appear to be any built-in way to parse query-string variables.</li> <li>There are no methods to mutate the Uri, for example appending a new query variable.</li...
<p>I wouldn't say the Uri class is fundamentally broken at all. The purpose of the Uri class is to provide a compact and standard representation of a URI. The Uri class encapsulates all of the logic needed to return the URI in a canonical form and to provide support for IPV4 and IPV6 notations, and IRI support.</p> <p...
<p>Why do all of the file classes and web classes take unvalidated strings? The .NET Framework designers really dropped the ball on string encapsulation classes like this. </p> <p>If you are concerned about the verification of your string data, almost all of your strings should go into some kind of container. Without...
26,528
<p>example:</p> <pre><code>public static void DoSomething&lt;K,V&gt;(IDictionary&lt;K,V&gt; items) { items.Keys.Each(key =&gt; { if (items[key] **is IEnumerable&lt;?&gt;**) { /* do something */ } else { /* do something else */ } } </code></pre> <p>Can this be done without using reflection? How do I say...
<p>Thanks very much for this post. I wanted to provide a version of Konrad Rudolph's solution that has worked better for me. I had minor issues with that version, notably when testing if a Type is a nullable value type:</p> <pre><code>public static bool IsAssignableToGenericType(Type givenType, Type genericType) { ...
<p>You want to check out the <a href="http://msdn.microsoft.com/en-us/library/system.type.isinstanceoftype.aspx" rel="nofollow noreferrer">Type.IsInstanceOfType</a> method</p>
10,026
<p>How do you rename a file to include the datetime using the windows command line?</p>
<p>Here is a similar question:</p> <p><a href="https://stackoverflow.com/questions/203090/how-to-get-current-datetime-on-windows-command-line-in-a-suitable-format-for-us">How to get current datetime on Windows command line, in a suitable format for using in a filename?</a></p> <p>Hope this helps.</p>
<p>Check out <a href="http://www.ss64.com/nt/stampme.txt" rel="nofollow noreferrer">StampMe.cmd</a> at <a href="http://www.ss64.com/nt/syntax.html" rel="nofollow noreferrer">http://www.ss64.com/nt/syntax.html</a>.</p>
31,337
<p>I'm looking for secure ways to pass data between a client running Flash and a server. The data in question will be generated BY the Flash app, which in this case is your score after finishing a game. I want to verify the data is untampered on the server. What are some good methods of getting this done?</p> <p>On...
<p>Encrypt the data with a public key stored in the binary. This will raise the barrier of entry for an attack. In addition to that, sanity check the data as it arrives on the server. This could be as simple as calculating the maximum number of points that could realistically be earned per time unit of play, or tran...
<p>As long as people can get at the executable - which, unless you want to run the game on a locked kiosk, is always the case - there's no perfectly secure way of doing this.</p> <p>The music and movie industries spent tens of millions on DRM that got cracked by home hobbyists in days/weeks. If they can't protect <em...
6,855
<p>Component Services -> Computers -> My Computer -> COM+ Applications</p> <p>Open a COM+ Application object.</p> <p>Open Components.</p> <p>Right-click on a class and select Properties.</p> <p>Under "Advanced" there is a check box for "Allow IIS intrinsic properties".</p> <p>How do I check this check box programm...
<p>I found out how to do it.</p> <p>Apparently I have to get a collection of COM+ applications, find the one I want (by name), then get a collection of components in the application, then go through the collection and set the attribute:</p> <pre><code> //get collection of applications COMAdminCatal...
<p>I have no experience with this particular property, but it seems to be documented in <a href="http://msdn.microsoft.com/en-us/library/ms688285(VS.85).aspx#_cos_components_iisintrinsics" rel="nofollow noreferrer">MSDN</a>.</p>
43,347
<p>As part of a project with my university, I have developed a new extruder to attach to a Prusa i3 MK2. My problem is that both the nozzle and PINDA probe have moved 17mm forward and 0.5mm to the right. As a result when I try and calibrate the printer it moves to the home position and the PINDA probe is too far out ov...
<p>Consider the original installation with the orientation of the Pinda probe to the nozzle. Let's say for argument's sake that the Pinda probe is 3 mm to the right and directly in line with the nozzle on the y axis.</p> <p>If you examine your new nozzle, I would expect that the relationship of the nozzle to the Pinda ...
<blockquote> <p>What is the simplest method of moving the home position...</p> </blockquote> <p>I think the solution outline by @fred_dot_u is very elegant, so I would go with it.</p> <blockquote> <p>...so that the printer can be properly calibrated?</p> </blockquote> <p>I'm not sure that will be possible.</p> ...
827
<p>I have a django application that I'd like to add some rest interfaces to. I've seen <a href="http://code.google.com/p/django-rest-interface/" rel="noreferrer">http://code.google.com/p/django-rest-interface/</a> but it seems to be pretty simplistic. For instance it doesn't seem to have a way of enforcing security. ...
<p>I would look into using django-piston <a href="http://bitbucket.org/jespern/django-piston/wiki/Home" rel="noreferrer">http://bitbucket.org/jespern/django-piston/wiki/Home</a> application if security is your main concern. </p> <p>I have used django-rest-interface in the past, its reliable and though simple can be qu...
<p>Well, from the look of things, there's an <code>authentication</code> parameter to <code>Collection</code>. (see this example: <a href="http://django-rest-interface.googlecode.com/svn/trunk/django_restapi_tests/examples/authentication.py" rel="nofollow noreferrer">authentication.py</a>)</p> <p>Second, (even if Djan...
26,171
<p>What RTOS is best for working on the same PC with Windows?</p> <p>I know about RTX and INtime, but have not used them. Are there any others? Which one is your favorite and why?</p>
<p>I would try eCos. It is runs on the i386, is free, has great tool support, and includes board support packages ready made. </p>
<p>If you are looking to have a lot of fun with real-time systems, why not play around with Ubuntu's real-time patch and turn an old computer you have into a real-time desktop or use virtualbox or something of course. Here is a link you will find useful in getting it setup:</p> <p><a href="http://viswanathj.wordpress....
13,104
<p>I've added a weakly named assembly to my <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio#Visual_Studio_2005" rel="noreferrer">Visual Studio 2005</a> project (which is strongly named). I'm now getting the error:</p> <blockquote> <p>&quot;Referenced assembly 'xxxxxxxx' does not have a strong name&quot;</...
<p>To avoid this error you could either:</p> <ul> <li>Load the assembly dynamically, or</li> <li>Sign the third-party assembly. </li> </ul> <p>You will find instructions on signing third-party assemblies in <em><a href="https://dzone.com/articles/net-fu-zero-delay-signing-of-a" rel="noreferrer">.NET-fu: Signing an Un...
<p>First make sure all NuGet packages are at the same version across all projects in your solution. E.g., you don’t want one project to reference NLog 4.0.0.0 and another project to reference NLog 4.1.0.0. Then try reinstalling NuGet packages with</p> <pre><code>Update-Package -reinstall </code></pre> <p>I had three th...
42,953
<p>I am currently working on converting an existing web application to support an additional language (namely Welsh). My proposed approach is to extract all displayed text into property files and then access the text using JSTL fmt tags.</p> <p>My question is: how should these property files be structured? I know they...
<blockquote> <p>Is this approach in line with industry standards? This is the first multilingual application for my current company, so it is likely to be used as a blueprint for all others. </p> </blockquote> <p>Yes, I think it is.</p> <p>I believe Maven creates the following directory structure:</p> <pre> src ...
<p>I'm not sure it's a good idea to establish too strong a connection between the resource files and the code files that use them, since it could lead to unnecessary duplication of texts that could be reused. </p> <p>This is especially problematic when the texts are translated by a third party, since the same expressi...
45,455
<p>I'm using Microsoft WebTest and want to be able to do something similar to NUnit's <code>Assert.Fail()</code>. The best i have come up with is to <code>throw new webTestException()</code> but this shows in the test results as an <code>Error</code> rather than a <code>Failure</code>. </p> <p>Other than reflecting on...
<p>Set the <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.webtesting.webtest.outcome.aspx" rel="nofollow noreferrer">Outcome property</a> to <em>Fail</em>:</p> <pre><code>Outcome = Outcome.Fail; </code></pre> <p>There's also an <a href="http://msdn.microsoft.com/en-us/library/micros...
<p>Set the value of Outcome in the PostWebTest event handler.</p>
27,730
<p>I'd like to gather metrics on specific routines of my code to see where I can best optimize. Let's take a simple example and say that I have a "Class" database with multiple "Students." Let's say the current code calls the database for every student instead of grabbing them all at once in a batch. I'd like to see ho...
<p>I use this method on occasion and find it to be fairly accurate. The problem is that in large applications with a fairly hefty amount of debugging logs, it can be a pain to search through the logs for this information. So I use external tools (I program in Java primarily, and use JProbe) which allow me to see averag...
<p>I use this method and I think it's very accurate.</p>
36,540
<p>I have developed an installer class which removes certain folders from the base dir.However,I also want to remove the entry of another application from add/remove programs through the inst class.Could anyone suggest the solution.</p> <p>Regards, Harsh Suman</p>
<p>Remove the entry from the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall </p>
<p>It may worth to read this forum thread: <a href="http://www.eggheadcafe.com/community/aspnet/2/10069013/uninstall-a-proram-by-using-c.aspx" rel="nofollow">http://www.eggheadcafe.com/community/aspnet/2/10069013/uninstall-a-proram-by-using-c.aspx</a></p>
24,392
<p>I have a shell script with this code:</p> <pre><code>var=`hg st -R "$path"` if [ -n "$var" ]; then echo $var fi </code></pre> <p>But the conditional code always executes, because <code>hg st</code> always prints at least one newline character.</p> <ul> <li>Is there a simple way to strip whitespace from <code>...
<p>Let's define a variable containing leading, trailing, and intermediate whitespace:</p> <pre><code>FOO=' test test test ' echo -e "FOO='${FOO}'" # &gt; FOO=' test test test ' echo -e "length(FOO)==${#FOO}" # &gt; length(FOO)==16 </code></pre> <hr> <p>How to remove all whitespace (denoted by <code>[:space:]</code> ...
<p>While it's not strictly Bash this will do what you want and more:</p> <pre><code>php -r '$x = trim(" hi there "); echo $x;' </code></pre> <p>If you want to make it lowercase too, do:</p> <pre><code>php -r '$x = trim(" Hi There "); $x = strtolower($x) ; echo $x;' </code></pre>
48,293
<p>There is a well-known debate in Java (and other communities, I'm sure) whether or not trivial getter/setter methods should be tested. Usually, this is with respect to code coverage. Let's agree that this is an open debate, and not try to answer it here.</p> <p>There have been several blog posts on using Java refle...
<p>I'm not aware of any readily available library or class that does this. This may mainly be because I don't care as I am on the side of strongly opposing such tests. So even though you asked there <em>must</em> be a bit of justification for this view:</p> <p>I doubt that autotesting getters and setters benefit your ...
<p>Answering the previous comment at <a href="https://stackoverflow.com/questions/108692/is-there-a-java-unit-test-framework-that-auto-tests-getters-and-setters#108930">@me</a> here because of my reputation:</p> <blockquote> <p>Vlookward, not writing getters/setters makes no sense at all. The only options for settin...
13,404
<p>I have a set of calculation methods sitting in a .Net DLL. I would like to make those methods available to Excel (2003+) users so they can use them in their spreadsheets.</p> <p>For example, my .net method:</p> <pre><code>public double CalculateSomethingReallyComplex(double a, double b) {...} </code></pre> <p>I ...
<p>There are two methods - you can used Visual Studio Tools for Office (VSTO):</p> <p><a href="http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx</a></p> <p>or you can use COM:</p> <p><a href="http://blogs.msdn.com/eric...
<p>There are two methods - you can used Visual Studio Tools for Office (VSTO):</p> <p><a href="http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx</a></p> <p>or you can use COM:</p> <p><a href="http://blogs.msdn.com/eric...
7,800
<p>I have a dtsx package with a precedence constraint that evaluates an expression and a constraint. The constraint is "success" and the expression is "@myVariable" == 3. myVariable is an int32, and when set in Visual Studio's design GUI the package executes fine. There are two other paths that check for the value t...
<p>Sorry took me so long to get back to this thread! But <code>(DT_I4)@[User::myVariable] == 3</code> did the trick. Thanks!</p>
<p>This seems to be a bug in the initial release of dtexec.exe. I have version 9.00.3042.00 wich is like, SQL Server 2005 SP2, installed in my dev enviro. We have a second test machine that is on version 9.00.1399.06 . The only place I see this failure is on the test box. My dev. box runs to completion. I added an expl...
22,192
<p>If you create an Oracle dblink you cannot directly access LOB columns in the target tables.</p> <p>For instance, you create a dblink with:</p> <pre><code>create database link TEST_LINK connect to TARGETUSER IDENTIFIED BY password using 'DATABASESID'; </code></pre> <p>After this you can do stuff like:</p> <pre...
<p>Yeah, it is messy, I can't think of a way to avoid it though.<br> You could hide some of the messiness from the client by putting the temporary table creation in a stored procedure (and using "execute immediate" to create they table)<br> One thing you will need to watch out for is left over temporary tables (should ...
<p>Do you have a specific scenario in mind? For example, if the LOB holds files, and you are on a company intranet, perhaps you can write a stored procedure to extract the files to a known directory on the network and access them from there.</p>
5,901
<p>Edit: this puzzle is also known as "Einstein's Riddle"</p> <p>The <a href="https://en.wikipedia.org/wiki/Zebra_Puzzle" rel="noreferrer">Who owns the Zebra</a> (you can <a href="https://www.brainzilla.com/logic/zebra/einsteins-riddle/" rel="noreferrer" title="Einstein&#39;s Riddle">try the online version here</a>) i...
<p>Here's a solution in Python based on constraint-programming:</p> <pre class="lang-py prettyprint-override"><code>from constraint import AllDifferentConstraint, InSetConstraint, Problem # variables colors = "blue red green white yellow".split() nationalities = "Norwegian German Dane Swede English".split() ...
<p>One example of a programmatic solution (originally written for a similar question), can be found here: <a href="https://puzzle-solvers.readthedocs.io/en/latest/" rel="nofollow noreferrer">https://puzzle-solvers.readthedocs.io/en/latest/</a></p> <p>I implemented a matrix of relationships between the classes, which ge...
41,226
<p>Programmatic solution of course...</p>
<p><a href="http://www.daveamenta.com/2008-05/c-delete-a-file-to-the-recycle-bin/" rel="noreferrer">http://www.daveamenta.com/2008-05/c-delete-a-file-to-the-recycle-bin/</a></p> <p>From above:</p> <pre><code>using Microsoft.VisualBasic; string path = @"c:\myfile.txt"; FileIO.FileSystem.DeleteDirectory(path, Fil...
<p>You need to delve into unmanaged code. Here's a static class that I've been using:</p> <pre><code>public static class Recycle { private const int FO_DELETE = 3; private const int FOF_ALLOWUNDO = 0x40; private const int FOF_NOCONFIRMATION = 0x0010; [StructLayout(LayoutKind.Sequential, CharSet = Char...
3,821
<p>I'd trying to style my ComboBoxes to match the rest of the UI but I'm having problems with the IsMouseOver highlighting. It highlights with the color I specify for a second and then fades back to the default color, kind of a cool effect but not what I'm going for. Here is my style:</p> <pre><code>&lt;Style TargetTy...
<p>The problem is indeed due to the default template for the ComboBox. If you use <a href="http://www.red-gate.com/products/reflector/" rel="nofollow noreferrer">Reflector</a> to open the PresentationFramework.Aero assembly you can take a look at the ButtonChrome class. There is a method called OnRenderMouseOverChanged...
<p>You can override this behavior by getting a copy of the default template from the WPF Visual Studio Designer and then in the ComboBoxReadonlyToggleButton style comment out the ButtonChrome section and replace it with a Border. Here is a link to the site where I found the solution - <a href="http://www.scriptscoop.n...
31,191
<p>GCC 3.4.5 (MinGW version) produces a warning: parameter has incomplete type for line 2 of the following C code:</p> <pre><code>struct s; typedef void (* func_t)(struct s _this); struct s { func_t method; int dummy_member; }; </code></pre> <p>Is there a way to fix this (or at least hide the warning) without changin...
<p>You can't quite do this easily - according to the <a href="http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf" rel="nofollow noreferrer">C99 standard</a>, Section 6.7.5.3, paragraph 4:</p> <blockquote> <p>After adjustment, the parameters in a parameter type list in a function declarator that is part of a...
<p>You want to call it with a function pointer. Why not use a void pointer instead?</p> <pre><code>typedef void (*func_t)(void*); </code></pre> <p>You MIGHT be able to pass a loosely-typed function pointer as well; I don't have a compiler on hand.</p> <pre><code>typedef void (*func_t)(void (*)()); </code></pre>
48,569
<p>What is a good, simple encryption scheme for protecting passwords in a database? I don't necessarily need anything that's hyper-secure nor do I need anything that's lightning fast, but those things would be nice. Primarily, I just want something that's easy to implement without being terribly slow or insecure.</p>...
<p>As mk says, <s>SHA1 or MD5 are the standard ones, along with SHA2</s>.</p> <hr /> <p>Update: As processors have gotten faster over the years, hashes have gotten more brute-forceable. It's now recommended you use <a href="https://en.wikipedia.org/wiki/Bcrypt" rel="nofollow noreferrer"><code>bcrypt</code></a>.</p> <p>...
<p>If you're using SQL Server, there's the HashBytes function: </p> <p><a href="http://msdn.microsoft.com/en-us/library/ms174415.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms174415.aspx</a></p>
5,079
<p>Is it possible to scale a UIView down to 0 (width and height is 0) using CGAffineTransformMakeScale?</p> <p>view.transform = CGAffineTransformMakeScale(0.0f, 0.0f);</p> <p>Why would this throw an error of &quot;<code>&lt;Error&gt;: CGAffineTransformInvert: singular matrix.</code>&quot; ?</p> <br /> <br /> <p><em>Upd...
<p>There are lots of times when the underlying frameworks need to invert your transform matrix. The inverse of a matrix is some matrix M' such that the product of your matrix M and the inverse matrix M' is the identify matrix 1.</p> <p>1 = M * M'</p> <p>The zero matrix does not have an inverse, hence the error messa...
<p>you could try:</p> <pre><code>CGAffineTransform transform = myView.transform; myView.transform = CGAffineTransformScale(transform. 0.0f, 0.0f); </code></pre> <p>or inline the whole thing.</p>
26,563
<p>I need to develop an application which stores data in a SQL Server 2005 database (the app itself will be either a WCF Service or an Asp.Net Web Service).</p> <p>Now, this data is supremely confidential, and I need to have it stored in an encrypted form in the database.</p> <p>So, I am wondering what the best pract...
<p>Look at <a href="http://blogs.technet.com/keithcombs/archive/2005/11/24/sql-server-2005-data-encryption.aspx" rel="nofollow noreferrer">this link</a> for a good introduction with samples.</p> <p>I think doing the data encryption in the application is better, because in that case the transferred data is already encr...
<p>Before you decide on an encryption method, you need to access what parts of the system are vulnerable. If the potential for unauthorized access to the database exists, does the same threat exist for your application? Someone could run your code through Reflector and determine what methods were being used to encryp...
25,471
<p>Files:</p> <p>Website\Controls\map.ascx</p> <p>Website\App_Code\map.cs</p> <p>I'd like to create a strongly typed instance of map.ascx in map.cs</p> <p>Normally, in an aspx, you would add a &lt;%Register... tag to be able to instantiate in codebehind. Is this possible in an app_code class? I'm using .NET 3.5/Vis...
<p>Normally, I'd do something like this (assuming your type is "Map" and that you have the appropriate "Inherits" declaration in your .ascx file):</p> <pre><code>Map map = (Map)LoadControl("~/Controls/map.ascx"); </code></pre>
<p>Is there a map.ascx.cs file in Website\Controls? If so, move it to App_Code. Note you may have to update the CodeFile attribute in the .ascx file to ~\App_Code\map.ascx.cs. Alternatively, since the control is a partial class, you could just create the code in ~\App_Code\map.cs as:</p> <pre><code>public partial cl...
22,109
<p>There are a few questions about configuring Apache for local development, such as <a href="https://stackoverflow.com/questions/118423/set-up-apache-for-local-developmenttesting">this one</a>, but I didn't see anything about IIS. Suggestions for locking down IIS without crippling it's functionality?</p> <p>In respon...
<p>If you are using Visual Studio for ASP.NET development you don't need to use IIS. The default configuration for Web Projects is to use the built in Web server, webDev.WebServer.EXE</p> <p>The version of IIS in XP isn't well suited for development as it is connection throttled and allows only one site.</p>
<p>If you're using Visual Studio .NET 2008 (or 2005) they have a built-in Web Server that will only respond to localhost requests... No need to install IIS. How about that for lock-down? ;-)</p>
37,247
<p>I was fortunate enough to be able to start fresh with Grails. However, many people have asked me how to add Groovy and/or Grails to a legacy Java/JSP web app. Do people have experience or recommendations on how to best include Groovy and Grails into a large legacy application?</p>
<p>This IBM Developerworks article goes into detail about <a href="http://www.ibm.com/developerworks/java/library/j-grails07158/index.html?S_TACT=105AGX02&amp;S_CMP=EDU" rel="nofollow noreferrer">how to use Grails with your legacy database</a>.</p> <p>A tool that may help map legacy databases to grails domain objects ...
<p>I'd start off by sharing the data model between the jsps and grails app (grails can run with plain Java classes and hibernate config, so if you are using hibernate already it shouldn't be hard to reuse the hibernate classes). Then I'd migrate each jsp/servlet <em>as is</em> to grails. If you are using spring already...
27,186
<p>Is it possible to make hibernate do "the right thing" for some value of "right" in this situation?</p> <pre><code>from ClassA a, ClassB b where a.prop = b.prop </code></pre> <p>The thing is that prop is a UserType with different representation in the joined tables. In table A it is represented as an integer and in...
<p>I think you can do this using a <code>&lt;formula&gt;</code> tag on the relationship in your mapping file.</p> <p>For example:</p> <pre><code>&lt;many-to-one name="myClassB" class="ClassB"&gt; &lt;formula&gt;--Some SQL Expression that converts between ClassA.prop and ClassB.prop&lt;/formula&gt; &lt;/many-to-one&...
<p>(1) Change data-type of columns which map to "prop" to be the same. This will require "Making DBA your friend" but will result in consitent "prop" UserType usage.</p> <p>(2) Handle the type differences in equals() method</p> <pre><code>public boolean equals(Object x, Object y) throws HibernateException { boole...
22,146
<p>I'm interfacing with a payment gateway and not having any luck with Net::SSLeay and its post_https subroutine. The payment gateway has issued me a client certificate that must be used for authentication. The Net::SSLeay perldoc has the following example:</p> <pre><code>($page, $response, %reply_headers) ...
<p>New versions of Net::SSLeay don't have the prototype that old versions have. Reading the source of old and new version I'd say the prototype was a bug (the code it calls can handle more variables than advertised).</p> <p>The solution I recommend is upgrading to a newer version of Net::SSLeay. If that is not possibl...
<p>You have an extra comma after '/path/to/key'</p>
29,927
<p>This is happening on Vista. I created a new dialog based MFC project to test this. I added a CEdit control to my dialog. I called SetLimitText to let my CEdit receive 100000 characters. I tried both:</p> <pre><code>this-&gt;m_cedit1.SetLimitText(100000); UpdateData(FALSE); </code></pre> <p>and </p> <pre><code>sta...
<p>I contacted microsof support. </p> <p>The goal was to have approximately 240000 characters in one single editable line of text.</p> <p>I am able to reproduce the issue on Windows Vista (x64 and x32 both) but <em>not</em> on Windows XP. </p> <p>this code works fine in XP:</p> <pre><code> BOOL ClongeditXPDlg::...
<p>FYI -- if the text is read-only/dsiplay only, you can add some CR-LFs to the string to fix the display of the text. It appears that the ExtTextOut function works slightly different when the newlines. Since it is a single-line edit box the newlines are stripped so the text looks the same -- unless you copy and paste...
25,311
<p>I have an application that launches a webpage in the "current" browser when the user selects it. This part of my app works fine in the Windows version but I can't figure out how to do this in Linux build.</p> <p>Right now the Linux version is hardcoded for Firefox in a specific directory and runs a new instance of ...
<p>If you're writing this for modern distros, you can use <code>xdg-open</code>:</p> <pre><code>$ xdg-open http://google.com/ </code></pre> <p>If you're on an older version you'll have to use a desktop-specific command like <code>gnome-open</code> or <code>exo-open</code>.</p>
<p>If you don't want to involve additional applications, just use the built-in remote control commands of firefox. E.g:</p> <pre><code>firefox -remote 'openurl(http://stackoverflow.com)' </code></pre> <p>Se detailed usage at <a href="http://www.mozilla.org/unix/remote.html" rel="nofollow noreferrer">http://www.mozill...
18,864
<p>What are some guidelines for when it is <strong>not</strong> necessary to check for a null?</p> <p>A lot of the inherited code I've been working on as of late has null-checks ad nauseam. Null checks on trivial functions, null checks on API calls that state non-null returns, etc. In some cases, the null-checks are r...
<p>One thing to remember that your code that you write today while it may be a small team and you can have good documentation, will turn into legacy code that someone else will have to maintain. I use the following rules:</p> <ol> <li><p>If I'm writing a public API that will be exposed to others, then I will do null c...
<p>At first, this seemed like a strange question: <code>null</code> checks are great and a valuable tool. Checking that <code>new</code> returns <code>null</code> is definitely silly. I'm just going to ignore the fact that there are languages that allow that. I'm sure there are valid reasons, but I really don't thin...
38,887
<p>In my webapplication (C#, .Net 3.5), made up of a <em>core</em> class library (containing the business logic, data layer and a couple of utility classes), a windows service project, a webservice project and the website project, I have a couple of static classes in the <em>core</em> library used by all other projects...
<p>I would try to avoid static classes for things which will require initialization. Make your Log class a normal class, and perhaps have a separate factory class to create instances or a single instance. You might want to use dependency injection to avoid having any statics, although this could get painful for somethi...
<p>I think you have to ask the hard questions here. Does that stuff <strong>need</strong> to be static? Static objects, whether in Singleton form or not, are pretty tough to work with. If you really need the static-ness, perhaps something like the <a href="http://jeremyjarrell.com/archive/2008/04/21/88.aspx" rel="nofol...
22,513
<p>I work with a lot of web applications that are driven by databases of varying complexity on the backend. Typically, there's an <a href="http://en.wikipedia.org/wiki/Object-relational_mapping" rel="noreferrer">ORM</a> layer separate from the business and presentation logic. This makes unit-testing the business logic ...
<p>I've actually used your first approach with quite some success, but in a slightly different ways that I think would solve some of your problems:</p> <ol> <li><p>Keep the entire schema and scripts for creating it in source control so that anyone can create the current database schema after a check out. In addition, ...
<p>For JDBC based project (directly or indirectly, e.g. JPA, EJB, ...) you can mockup not the entire database (in such case it would be better to use a test db on a real RDBMS), but only mockup at JDBC level.</p> <p>Advantage is abstraction which comes with that way, as JDBC data (result set, update count, warning, .....
17,498
<p>I have a table of tags and want to get the highest count tags from the list.</p> <p>Sample data looks like this</p> <pre><code>id (1) tag ('night') id (2) tag ('awesome') id (3) tag ('night') </code></pre> <p>using</p> <pre><code>SELECT COUNT(*), `Tag` from `images-tags` GROUP BY `Tag` </code></pre> <p>gets me ...
<p>In all versions of MySQL, simply alias the aggregate in the SELECT list, and order by the alias:</p> <pre><code>SELECT COUNT(id) AS theCount, `Tag` from `images-tags` GROUP BY `Tag` ORDER BY theCount DESC LIMIT 20 </code></pre>
<p>Try this query</p> <pre><code> SELECT data_collector_id , count (data_collector_id ) as frequency from rent_flats where is_contact_person_landlord = 'True' GROUP BY data_collector_id ORDER BY count(data_collector_id) DESC </code></pre>
4,765
<p>I am attempting to set an asp.net textbox to a SQL 2005 money data type field, the initial result displayed to the user is 40.0000 instead of 40.00. In my asp.net textbox control I would like to only display the first 2 numbers after the decimal point e.g. 40.00</p> <p>What would be the best way to do this? My code...
<pre><code>this.txtPayment.Text = string.Format("{0:c}", dr[Payment"].ToString()); </code></pre>
<p>Use the <em>ToString</em> method with "c" to format it as currency.</p> <pre><code>this.txtPayment.Text = dr["Payment"].ToString("c"); </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx" rel="nofollow noreferrer">Standard Numeric Format Strings</a></p>
5,951
<p>I'm looking for a KDTree implementation in Java.<br> I've done a google search and the results seem pretty haphazard. There are actually lots of results, but they're mostly just little one-off implementations, and I'd rather find something with a little more "production value". Something like apache collections or t...
<p>In the book <a href="http://oreilly.com/catalog/9780596516246/" rel="noreferrer">Algorithms in a Nutshell</a> there is a kd tree implementation in java along with a few variations. All of the code is on <a href="http://examples.oreilly.com/9780596516246/" rel="noreferrer">oreilly.com</a> and the book itself also wa...
<pre><code>package kdtree; class KDNode{ KDNode left; KDNode right; int []data; public KDNode(){ left=null; right=null; } public KDNode(int []x){ left=null; right=null; data = new int[2]; for (int k = 0; k &lt; 2; k++) data[k]=x[k]; ...
31,638
<p>When I started writing database queries I didn't know the JOIN keyword yet and naturally I just extended what I already knew and wrote queries like this:</p> <pre><code>SELECT a.someRow, b.someRow FROM tableA AS a, tableB AS b WHERE a.ID=b.ID AND b.ID= $someVar </code></pre> <p>Now that I know that this is the sam...
<p>Filtering joins solely using <code>WHERE</code> can be extremely inefficient in some common scenarios. For example:</p> <pre><code>SELECT * FROM people p, companies c WHERE p.companyID = c.id AND p.firstName = 'Daniel' </code></pre> <p>Most databases will execute this query quite literally, first taking the ...
<p><strong>And what about performances ???</strong></p> <p>As a matter of fact, performances is a very important problem in RDBMS.</p> <p>So the question is <em>what is the most performant... Using JOIN or having joined table in the WHERE clause ?</em></p> <p>Because optimizer (or planer as they said in PG...) ordinary...
15,681
<p>Imagine I have a document (word document).</p> <p>I have an enumeration which will indicate how to extract data from the document. So if I want just text, the images, or both (3 members of the enumeration).</p> <p>I have a case statement based on this enumeration, but without falling into a code smell, how can I w...
<p>I would use a Strategy pattern coupled with a factory to create the appropriate strategy based on the value of the enumeration. <strong>EDIT</strong> As others have pointed out you could also determine the correct strategy via a Map as well. Factory is my choice because it only encapsulates the logic and doesn't r...
<p>A solution could be having one class for every way you want to extract the data. Each class would do all the extraction work and they could have a common IExtract interface. You would only have to return the interface based on the enumeration and then just call the methods on the interface.</p>
42,252
<p>I've been wondering, as a lone game developer, or to say a part of team which has only got programmers and people who like to play games... How do I manage the void created by lack of artists (sprites/tiles/animations) in such a situation???</p> <p>What do you do in that case? and suppose I am a student, with no m...
<p>The first thing you'll gain by switching will be a substantially more powerful platform that's running directly on the bare-metal of your server.</p> <p>From my experience, moving <em>up</em> the VMware application stack has never been problematic (Server to Workstation to ESX). However, I would verify this by expo...
<p>One thing to note is the considerable expense of the ESX line compared to Workstation. If you're working for a successful company, though, the cost can easily be justified as ESX is (imho) da bomb. Also, FYI, the old free VMware Server options definitely had a whole different interface.</p>
13,550
<p>I need to execute a large set of SQL statements (creating a bunch of tables, views and stored procedures) from within a C# program.</p> <p>These statements need to be separated by <code>GO</code> statements, but <code>SqlCommand.ExecuteNonQuery()</code> does not like <code>GO</code> statements. My solution, which I...
<p>Use SQL Server Management Objects (SMO) which understands GO separators. See my blog post here: <a href="http://weblogs.asp.net/jgalloway/archive/2006/11/07/Handling-_2200_GO_2200_-Separators-in-SQL-Scripts-_2D00_-the-easy-way.aspx" rel="noreferrer">http://weblogs.asp.net/jongalloway/Handling-_2200_GO_2200_-Separato...
<p>Too difficult :)</p> <p>Create array of strings str[] replacing GO with ",@" :</p> <pre><code> string[] str ={ @" USE master; ",@" CREATE DATABASE " +con_str_initdir+ @"; ",@" -- Verify the database files and sizes --SELECT name, size, size*1.0/128 AS [Size in MBs] --SELECT name --F...
6,208
<p>I need to create some reports from a sql server database for end users to view.</p> <p>Is it possible to hook into sql server from excel?</p> <p><b>Update</b> The end user will only click on the file to view the reports, asking them to do more is too much to ask!</p>
<p>Yes, it absolutely is, depends on what version of excel you have. In 2007 if you go under the Data tab and then "Get External Data" you will see many options to connect to various data sources including SQL</p>
<p>Simplest and oldest way is to use ODBC, but with VBScript, anything is possible.</p>
15,036
<p>Due to a weird request, I can't put <code>null</code> in a database if there is no value. I'm wondering what can I put in the store procedure for nothing instead of <code>null</code>.</p> <p>For example: </p> <pre><code>insert into blah (blah1) values (null) </code></pre> <p>Is there something like nothing or em...
<p>I would push back on this bizarre request. That's exactly what <code>NULL</code> is for in SQL, to denote a missing or inapplicable value in a column.</p> <p>Is the requester experiencing grief over SQL logic with <code>NULL</code>?</p> <p><strong>edit:</strong> Okay, I've read your reply with the extra detail a...
<p>Is null is a valid value for whatever you're storing?</p> <ul> <li>Use a sentry value like INT32.MaxValue, empty string, or "XXXXXXXXXX" and assume it will never be a legitimate value</li> <li>Add a bit column 'Exists' that you populate with true at the same time you insert.</li> </ul> <p><b>Edit:</b> But yeah, I'...
43,972
<p>I'm trying to fetch some HTML from various blogs and have noticed that different providers use the same tag in different ways.</p> <p>For example, here are two major providers that use the meta name generator tag differently:</p> <ul> <li>Blogger: <code>&lt;meta content='blogger' name='generator'/&gt;</code> (cont...
<p>The answer is: <strong>don't use regular expressions</strong>.</p> <p>Seriously. Use a SGML parser, or an XML parser if you happen to know it's valid XML (probably almost never true). You will absolutely screw up and waste tons of time trying to get it right. Just use what's already available.</p>
<p>Ok, since you are looking for language-agnostic then you can try a REGEX like <code>/&lt;meta\s.*content=.*&gt;/</code> and take the result from that and parse out the specific values that you are looking for. I'm by no means a REGEX expert so there is probably a better way but in using the tool at <a href="http://w...
5,148
<p>NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need. Feel free to suggest any other program.</p> <p>I have a form with nearly 100 fields that I would like to auto-fill with PHP. I know how to do the autofill, but I would like to avoid manually adding the...
<p>Taking some ideas from Zsolt Botykai and Mark Biek:</p> <pre><code>:%s:&lt;input\(.* id="\([^"]*\)".*\) /&gt;:&lt;input \1 value="&lt;?php echo $data['\2']; ?&gt; /&gt;:g </code></pre>
<p>step 1 : search the chaine type="text" :</p> <pre><code>/type="text" </code></pre> <p>Verify that all the strings you want are caught. step 2 : Subsitute with the wanted string :</p> <pre><code>:%s//type="text" value="&lt;?php echo $data riskrating]; ?&gt;"/g </code></pre> <p>step 3 : Be happy !</p>
15,007
<p>I'm using KVM to run a Windows virtual machine on my Linux box. Networking is accomplished through a tap device, hooked into a bridged Ethernet device, which allows the Windows VM to basically appear like a separate physical computer on my network. This is pretty nice.</p> <p>However, my understanding is that most,...
<p>I assume that you could configure your Windows guest to use the host as its default gateway, and set up NAT via the wireless interface on the host. So the signal flow would look like this:</p> <ol> <li>Windows software opens connections to a host on the internets.</li> <li>Windows routes the packet via the default ...
<p>Why it should be a problem to setup host linux system to use WLAN and then us this connection as default gateway for local/internal bridge and all VMs are pluged into it? Ok, simple NAT has to be configured but what ist actually the point?</p>
10,411
<p>I have code to create another "row" (div with inputs) on a button click. I am creating new input elements and everything works fine, however, I can't find a way to access these new elements.</p> <p>Example: I have input element (name_1 below). Then I create another input element (name_2 below), by using the javas...
<p>You have to create the element AND add it to the DOM using functions such as appendChild. See <a href="http://www.w3schools.com/htmldom/dom_methods.asp" rel="nofollow noreferrer">here</a> for details.</p> <p>My guess is that you called createElement() but never added it to your DOM hierarchy.</p>
<p>If it's properly added to the dom tree you will be able to query it with document.getElementById. However browser bugs may cause troubles, so use a JavaScript toolkit like jQuery that works around browser bugs.</p>
15,680
<p>How can I access a public static member of a Java class from ColdFusion?</p>
<p>You run the createObject but don't call the "init" before running the static method. For example:</p> <pre><code>&lt;cfset systemObject = createObject("java", "java.lang.System") /&gt; &lt;cfoutput&gt;#systemObject.currentTimeMillis()#&lt;/cfoutput&gt; </code></pre> <p>In this case "currentTimeMillis()" is a stat...
<p>I would also mention that the class has to be in CF's classpath.</p>
23,822
<p>Is there any good tool or tool-chain that allows UML images in the .svg format to be created from a textual source file? The reason for this question is that I want to automate the generation of these images to avoid having to manually create and update this set of images.</p>
<p><a href="http://www.umlgraph.org/" rel="noreferrer">UMLGraph</a> is a program for generating UML diagrams (primarily Class Diagrams and Sequence Diagrams) from text based descriptions. It is intended to be used with java source code, but with some alterations, C++ style source code can also be used as described by <...
<p>the free UML tool <a href="http://jude.change-vision.com/jude-web/product/index.html" rel="nofollow noreferrer">JUDE</a> allows UML diagrams to be created from Java source code. I don't know if it does for other languages.</p>
23,664
<p>I am writing event data to a log file in an asp.net httphandler by using the File.AppendAllText method. I am concerned with what will happen when multiple requests are received simultaneously. Does AppendAllText lock the file it's writing to?</p>
<p>no, you should have a static lock object guarding the log-file write, e.g.</p> <pre><code>public static object LockingTarget = new object(); public void LogToFile(string msg) { lock(LockingTarget) { //append to file here as fast as possible } } </code></pre>
<p>You can use My.Log to write to log files. </p> <p>Edit: If you use the FileLogTraceListener, that listener is thread-safe.</p> <p>Doing this also allows you to control and configure the logging through the web.config file.</p>
36,155
<p>So I need to update a text field. Neither the UPDATE statement or the WRITETEXT statement work when used below</p> <pre><code>CREATE TABLE MyTable (IDField int, MyField text) INSERT INTO MyTable (IDField) SELECT 1 DECLARE @Data1 varchar(8000), @Data2 varchar(8000), @ptrval binary(16) SELECT @Data1 = REPLICATE('1...
<p>Try using UPDATETEXT instead</p> <pre><code>WRITETEXT MyTable.MyField @ptrval @Data1 UPDATETEXT MyTable.MyField @ptrval 8000 NULL @Data2 </code></pre> <p>The insert offset is zero based so 8000 should write into the 8001st character. The delete offset is null as a value of NULL deletes all data from the insert_of...
<p>I had a hard time with this one.</p> <p>I was trying to save long strings (actually rich text box contents) to a ntext feild.</p> <p>The solution turned out to be fairly simple.</p> <pre><code> SQLst = "UPDATE Test SET Text = cast (@value as ntext)" &amp; _ " WHERE Num = 3 " Debug.Pr...
24,978
<p>How can I mock the database calls to make my application logic been tested without database?</p>
<p>Use the <a href="http://martinfowler.com/eaaCatalog/repository.html" rel="nofollow noreferrer">repository pattern</a> and mock it in your tests using a mocking framework such as <a href="http://code.google.com/p/moq/" rel="nofollow noreferrer">MoQ</a>.</p> <p><strong>Edit:</strong> check out <a href="http://stephen...
<pre><code>procedure GetData (output arrayOfData) arrayOfData.record1.field1 = "dataA" arrayOfData.record1.field2 = "dataAB" arrayOfData.record2.field1 = "dataB" arrayOfData.record2.field2 = "dataBB" return arrayOfData) end procedure </code></pre> <p>Then call GetData and use that chunck of data that you nee...
46,712
<p>I have an issue - </p> <p>The javascript <code>Date("mm-dd-yyyy")</code> constructor doesn't work for FF. It works fine for IE.</p> <ul> <li>IE : <code>new Date("04-02-2008")</code> => <code>"Wed Apr 2 00:00:00 EDT 2008"</code></li> <li>FF2 : <code>new Date("04-02-2008")</code> => <code>Invalid Date</code> </l...
<p>It is the <a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date" rel="noreferrer">definition of the Date object</a> to use values 0-11 for the <code>month</code> field.</p> <p>I believe that the constructor using a String is system-dependent (not to mention locale/timezone depen...
<p>Bold statement.</p> <p>This might have your interest: <a href="http://ejohn.org/blog/javascript-pretty-date/" rel="nofollow noreferrer">JavaScript Pretty Date</a>.</p>
19,775
<p>I am using Oracle 10g R2. Recently, after rebooting the server, I started having a problem where I couldn't connect to the instance. I am only connecting locally on the server itself. </p> <p>Oddly enough, the issue corrects itself if I start the Database Administration Assistant, and select my instance to suppose...
<p>EDIT: I don't think I read your question properly: The listener should not affect connections on the local machine, so you can probably ignore the rest of the answer, unless it gives you a hint! How were you testing your connection? Was ORA-12514 the only error?</p> <hr> <p>(I'm assuming you're on Windows here) ...
<p>You haven't specified if this is windows or unix?</p> <p>I've seen similar issues on unix when ORACLE_HOME was defined slightly differently on the account which starts up oracle, and on connecting accounts, one account had ORACLE_HOME=/usr/oracle , the other had ORACLE_HOME=/usr/oracle/ , the trailing slash messed ...
29,697
<p>I'm sure it's just simple html/css but I don't know what to call the bar (googling horizontal bar html always results in a horizontal rule).</p> <p><a href="http://jquery.com/" rel="nofollow noreferrer">http://jquery.com/</a> has one - the grayish bar the runs across the top separating the menu from the content of ...
<p>There is a number of ways to do this. </p> <p>On jquery.com it is part of background image applied the body tag. </p> <p>You can have a header section which has background aligned to the bottom as an image and bottom padding that prevents text/content from overlaying that part. Finally you could use thick border i...
<p>Its a <a href="http://static.jquery.com/files/rocker/images/bg_home_tile_sml.jpg" rel="nofollow noreferrer">BG image</a> that's applied to the body tag.</p> <pre><code>body { background: #2a3139 url(../images/bg_home_tile_sml.jpg) repeat-x 50% 0; } </code></pre> <p>IMO it's the best way to achieve this effect....
37,012
<p>I have a vector-like class that contains an array of objects of type <code>"T"</code>, and I want to implement 4 arithmetic operators, which will apply the operation on each item:</p> <pre><code>// Constructors and other functions are omitted for brevity. template&lt;class T, unsigned int D&gt; class Vector { publ...
<p>First, you should really return a reference from your operator+=, since you can later use them to implement operator+, operator- and so on. I will change that accordingly.</p> <p>Also, your do_for_each has to be a template, since it has to know the precise type of the function object, as binary function objects are...
<p>I think litb is on the correct track and answered the exact question.<br> But I think this is the wrong solution.</p> <p>I would rather not use the do_for_each() but rather use the std::transform() directly:</p> <pre><code>template&lt;class T, unsigned int D&gt; class Vector { public: Vector&amp; operator ...
37,451
<p>I can't find a reference to it but I remember reading that it wasn't a good idea to call virtual (polymorphic) methods within a destructor or the Dispose() method of IDisposable.</p> <p>Is this true and if so can someone explain why?</p>
<p>Calling virtual methods from a finalizer/<code>Dispose</code> is unsafe, for the same reasons <a href="https://stackoverflow.com/questions/119506/virtual-member-call-in-a-constructor">it is unsafe to do in a constructor</a>. It is impossible to be sure that the derived class has not already cleaned-up some state th...
<p>To expand on Jon's answer, instead of calling virtual methods you should be overriding the dispose or the destructor on sub classes if you need to handle resources at that level.</p> <p>Although, I don't believe there is a "rule" in regards to behavior here. But the general thought is that you want to isolate resou...
16,642
<p>Essentially what I want is a BlockingQueue of size=1. I have a "listener" thread that simply waits, blocking until an object is put into the queue, and then retrieves it--and a "producer" thread that actually puts the object into the queue.</p> <p>I can implement this with some synchronized blocks and a BlockingQue...
<p>Have you looked into using XmlAttributeOverrides? </p> <p><a href="http://msdn.microsoft.com/en-us/system.xml.serialization.xmlattributeoverrides.aspx" rel="nofollow noreferrer">.NET Framework Class Library: XmlAttributeOverrides Class</a></p> <blockquote> <p>first, you can control and augment the serialization ...
<p>Use reflection to get the values of all the properties from the class then write them as attributes on to an XmlNode</p> <pre><code>PropertyInfo[] properties = control.GetType().GetProperties(); foreach (PropertyInfo property in properties) { object o = property.GetValue(control, null); // write value of o.ToSt...
26,385
<p>anyone able to tell me how often a materialized view is set to refresh with the following setting plz?</p> <p>REFRESH FORCE ON DEMAND START WITH sysdate+0 NEXT (round(sysdate) + 1/24) + 1</p> <p>i think i read it as every hour but i'm not sure</p>
<pre><code>SQL&gt; alter session set nls_date_format = 'yyyy-mm-dd :hh24:mi:ss'; Session changed. SQL&gt; select sysdate from dual; SYSDATE -------------------- 2008-12-19 :12:18:28 SQL&gt; select (round(sysdate) + 1/24) + 1 from dual; (ROUND(SYSDATE)+1/24 -------------------- 2008-12-21 :01:00:00 </code></pre>
<p>i think using </p> <pre><code>NEXT (trunc(sysdate) + 1/24) + 1 </code></pre> <p>is more accurate</p>
49,888
<p>My requirement is I have server J2EE web application and client J2EE web application. Sometimes client can go offline. When client comes online he should be able to synchronize changes to and fro. Also I should be able to control which rows/tables need to be synchronized based on some filters/rules. Is there any exi...
<p>There are a number of Java libraries for data synchronizing/replication. Two that I'm aware of are <a href="http://opensource.replicator.daffodilsw.com/" rel="nofollow noreferrer">daffodil</a> and <a href="http://www.symmetricds.org/" rel="nofollow noreferrer">SymmetricDS</a>. In a previous life I foolishly implemen...
<p>What is best suited as the client-side data store in your application? You can choose from an embedded database like SQLite or a message queue or some object store or (if none of these can be used since it is a web application) files/ documents saved on the client using Web DB or <a HREF="http://www.w3.org/TR/Indexe...
34,163
<p>I was recently put in charge of the wiki for the development team. The wiki is still in its infancy, so I have a lot of room to work with. It goal is to house internal to the development team. Currently, the main piece of information that the wiki holds is Coding Standards. </p> <ul> <li>What are some best practice...
<ul> <li>Introduction to the source base for new programmers</li> <li>General documentation (not the API documentation per-se, but more tutorial like things)</li> <li>Lists of staff / who's doing what and how to reach them</li> <li>Notes / resources / articles that explain concepts used in the software</li> <li>Documen...
<ul> <li>Burndown charts</li> <li>common setup information for development environments (nice for when new people start)</li> <li>Specs</li> <li>Known issues and workarounds with development tools</li> </ul>
30,810
<pre><code>function AddTheatres() { Services.AdminWebServices.AddTheatresSVC(oTheatres, OnSuccessTheatres, OnError, OnTimeOut); } function OnSuccessTheatres(result1) { Services.AdminWebServices.AddTicketPricesSVC(oTicketPrices, OnSuccessTicketPrices, OnError, OnTimeOut); //working } function OnSuccessTicketPrices...
<p>Did you implement the OnError and OnTimeout handlers? Maybe there is a server error?</p>
<pre><code>function OnError(error) { alert(error.get_message()); } function OnTimeOut() { alert('System Time Out'); } </code></pre> <p>This is the way to implement it right?</p>
32,034
<p>I am wondering if there is a method or format string I'm missing in .NET to convert the following:</p> <pre><code> 1 to 1st 2 to 2nd 3 to 3rd 4 to 4th 11 to 11th 101 to 101st 111 to 111th </code></pre> <p><a href="http://www.dotnet-friends.com/fastcode/csharp/fastcodeincsc3bd4149-03d0-40fe-90fd-63bc...
<p>No, there is no inbuilt capability in the .NET Base Class Library.</p>
<p>I think the ordinal suffix is hard to get... you basically have to write a function that uses a switch to test the numbers and add the suffix.</p> <p>There's no reason for a language to provide this internally, especially when it's locale specific.</p> <p>You can do a bit better than that link when it comes to the...
9,466
<p>Essentially, I have to get a flat file into a database. The flat files come in with the first two characters on each line indicating which type of record it is.</p> <p>Do I create a class for each record type with properties matching the fields in the record? Should I just use arrays?</p> <p>I want to load the d...
<p>I'd recommend creating classes (or structs, or what-ever value type your language supports), as </p> <pre><code>record.ClientReference </code></pre> <p>is so much more descriptive than</p> <pre><code>record[0] </code></pre> <p>and, if you're using the (wonderful!) <a href="http://www.filehelpers.com/" rel="nofol...
<p>When I have had to load this kind of data in the past, I have put it all into a work table with the first two characters in one field and the rest in another. Then I have parsed it out to the appropriate other work tables based on the first two characters. Then I have done any cleanup and validation before inserting...
39,324
<p>I've built a wrapper over NumbericUpDown control. The wrapper is generic and can support int? and double?</p> <p>I would like to write a method that will do the following.</p> <pre><code>public partial class NullableNumericUpDown&lt;T&gt; : UserControl where T : struct { private NumbericUpDown numericUpDown; ...
<p>It's not clear how you gonna use it. If you want double create GetDouble() method, for integers - GetInteger()</p> <p>EDIT:</p> <p>Ok, now I think I understand your use case</p> <p>Try this:</p> <pre><code>using System; using System.ComponentModel; static Nullable&lt;T&gt; ConvertFromString&lt;T&gt;(string valu...
<p>Since this method will always return the result of</p> <pre><code>numericUpDown.Value </code></pre> <p>you have no cause for the value to be converted to anything other than Decimal. Are you trying to solve a problem you don't have?</p>
13,594
<p>Consider the "double-check idiom for lazy initialization of instance fields":</p> <blockquote><pre>// Item 71 in Effective Java copied from <a href="http://java.sun.com/developer/technicalArticles/Interviews/bloch_effective_08_qa.html" rel="nofollow noreferrer">this interview with Bloch</a>. private volatile FieldT...
<p>Yes, this is thread safe.</p> <p>The synchronized block is to prevent multiple threads from unnecessarily calling <code>computeFieldValue()</code>. Since <code>field</code> is volatile, the accesses in <code>reset</code> and <code>getField</code> are all well-ordered.</p> <p>If the first check is non-null, <code>g...
<p>It seems like this will work as long as the reset method is the <code>reset()</code> method listed above. However, if the <code>reset()</code> method instantiates a new Object (like below), couldn't you end up potentially returning something different than you intended?</p> <pre><code>void reset() { field = new...
39,514
<p>I have an OWL ontology and I am using Pellet to do reasoning over it. Like most ontologies it starts by including various standard ontologies:</p> <pre><code>&lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rdfs="http://www.w3.org/20...
<p>Pellet recognizes all of these namespaces when loading and should not attempt to dereference the URIs. If it does, it suggests the application using Pellet is doing something incorrectly.</p> <p>You may find more help on <a href="http://lists.owldl.com/mailman/listinfo/pellet-users/" rel="nofollow noreferrer">the ...
<p>Make local copies of the four files and replace the remote URLs with local URIs (i.e. file://... or serve them from your own box: <a href="http://localhost.." rel="nofollow noreferrer">http://localhost..</a>.).</p>
12,541
<p>Does the placement of a function have an effect on the performance of closures within scope? If so, where is the optimal place to put these functions? If not, is the implied association by closure enough reason to place a function in another place logically?</p> <p>For instance, if <strong>foo</strong> does not r...
<p>Both those snippets are equivalent, because they're both defined in the (same) environment of the anonymous function you're creating. I think you'd be able to access <code>localState</code> from <code>foo</code> either way.</p> <p>That being said... if you have absurd amounts of variables in the environment you're ...
<p>In your examples the difference won't really matter. Even if foo is in the global scope you won't have a problem.</p> <p>However, it's useful to keep in mind that if you use the style of assigning functions to variables to declare your functions the order in which they are declare can become quite a problem.</p> <...
30,223
<p>I was wondering is there is a fool-proof way to run a program on windows such that I'm <b>guaranteed</b> that <b>no interactive dialogs of any kind</b> are displayed.</p> <p>I've tried the registry ErrorMode hack, calling _CrtSetReportMode(), etc., but they all have holes in them or require you to modify the progra...
<p>If an exception occurs, you never get to the return statement in getStoredMails. You need to either throw the exception you catch (possibly wrapping it in another more descriptive exception) or just return null at the end of the method. It really depends on what you want to do if there's an error.</p> <p>Oh, and yo...
<p>I modified the source. I added "return null" in exception and the for loop the output in the function. And the function gives me the right output but then throws it the exception.</p>
21,208
<p>A website I'm working on (using AS2 because it's oldschool) has a larger index .swf file that loads sub-swfs using <code>loadMovie("foo1.swf", placeToShowSwf)</code>. There's <code>foo1.swf</code> through 4, which is silly because the only thing that's different between them is a single number in the address of an x...
<p>Perhaps you should double-check that you have proper authorization in <code>crossdomain.xml</code>. If your crossdomain file is jacked, none of your requests will go through.</p> <p><a href="http://crossdomainxml.org/" rel="nofollow noreferrer">http://crossdomainxml.org/</a></p>
<p>Your function is creating a new XML instance each time, and as a result you will need to define the onLoad function each time as well, if you reuse the same XML instance then you won't need to re-define the function, e.g.</p> <pre> var iFooNum:Number; var oXML:XML = new XML(); oXML.onLoad = function (success:Boole...
30,288
<p>We use Spring + Hibernate for a Webapp.</p> <p>This Webapp will be deployed on two unrelated production sites. These two production sites will use the Webapp to generate and use Person data in parallel.</p> <p>What I need to do, is to make sure that the Persons generated on these two unrelated production sites all...
<p>You could use sequences on both production systems, but define them differently:</p> <p>Production System 1: CREATE SEQUENCE sequence_name START WITH 1 INCREMENT BY 2;</p> <p>Production System 2: CREATE SEQUENCE sequence_name START WITH 2 INCREMENT BY 2;</p> <p>The first sequence will generate only odd numbers, t...
<p>You basically need to make sure the values for the keys fall into different sets. So prepending a varchar with a system identifier.</p> <p>Note: I havent tested this but you should be able to define a normal sequence per database</p> <p>and do something like </p> <pre><code>insert VALUES('Sys1' || to_char(sequenc...
22,086
<p>I am looking for a lean and well constructed open source implementation of a B-tree library written in C. It needs to be under a non-GPL license so that it can be used in a commercial application. Ideally, this library supports the B-tree index to be stored/manipulated as a disk file so that large trees can be built...
<p>Check out QDBM: <a href="http://fallabs.com/qdbm/" rel="noreferrer">http://fallabs.com/qdbm/</a>. It's LGPL (can be used in commercial app), implements a disk backed hash and/or B+ tree with arbitrary key/value pairs, and builds on a variety of platforms. </p>
<p>Maybe you can considere the berkeley db. It is using a b-tree internally.</p>
5,230
<p>Is there a way to recover the contents of a browser textarea? Say, you've typed a long post and then accidentally clicked on a link. Then when you come back, the textfields tantalizingly retain the text you typed in, but the textarea is blank. Where does IE and Firefox store the stuff that prepopulates? Can textarea...
<p>One thing you could try (although I haven't tried it, so I can't say how effective this method would be) to <em>immediately</em> try to search the memory space of the browser for the text - maybe it was not deallocated, or even if it was deallocated, maybe it wasn't overwritten by other data.</p> <p>You can do this...
<p>Whenever I type something really long, I always copy it to my clipboard before submitting the form in case something happens. Or, sometimes I type it in Notepad and copy it over when I'm done. That may not be the answer you're looking for, but it might help.</p>
15,634
<p>Given the following Delphil DLL declaration</p> <pre><code>function csd_HandleData(aBuf: PChar; aLen: integer): integer; stdcall; </code></pre> <p>what would be the VB6 declaration to use it?</p> <p>I've tried a variety of declarations, e.g.</p> <pre><code>Declare Function csd_HandleData Lib "chsdet.dll" (ByVal ...
<p>try</p> <pre><code>Declare Function csd_HandleData Lib "chsdet.dll" (ByVal aBuf As String, ByVal aLen As Integer) As Integer </code></pre> <p>Seems you forgot the return value.</p>
<p>I don´t know exactly how Vb works but PChar is a pointer, so try to get the reference instead of the value.</p> <pre><code>Declare Function csd_HandleData Lib "chsdet.dll" (**ByReference &lt;--guessing here :D** aBuf As String, ByVal aLen As Integer) </code></pre>
37,785
<p>In Perl, an object is just a reference to any of the basic Perl data types that has been blessed into a particular class. When you use the ref() function on an unblessed reference, you are told what data type the reference points to. However, when you call ref() on a blessed reference, you are returned the name of...
<p><code>Scalar::Util::reftype()</code> is the cleanest solution. The <a href="http://search.cpan.org/dist/Scalar-List-Utils/lib/Scalar/Util.pm" rel="noreferrer"><code>Scalar::Util</code></a> module was added to the Perl core in version 5.7 but is available for older versions (5.004 or later) from CPAN.</p> <p>You can...
<p>And my first thought on this was: "Objects in Perl are always hash refs, so what the hack?"</p> <p>But, Scalar::Util::reftype is the answer. Thanks for putting the question here.</p> <p>Here is a code snippet to prove this.. (in case it is of any use to anyone).</p> <pre> $> perl -e 'use strict; use warnings "all...
3,226