instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>There's a word that's used in API design that relates to the coupling between two entities. If one entity can vary without impacting the entity they are said to be _ _ _ _ _. For example given the declaration</p>
<p>class Point
{
public int X;
public in Y;
}</p>
<p>members X and Y could be said to exhi... | <p>Orthogonal? Independent?</p>
| <p>They are said to be <strong>Loosely-Coupled</strong>.</p>
| 49,403 |
<p>I would like to assign a global hotkey to my Python application, running in Gnome. How do I do that? All I can find are two year old posts saying, well, pretty much nothing :-)</p>
| <p>Check out the Deskbar source code - they do this; afaik, they call out a C library that interacts with X11 to do the job</p>
| <p>Check out the Deskbar source code - they do this; afaik, they call out a C library that interacts with X11 to do the job</p>
| 38,792 |
<p>Using instance methods as callbacks for event handlers changes the scope of <code>this</code> from <em>"My instance"</em> to <em>"Whatever just called the callback"</em>. So my code looks like this</p>
<pre><code>function MyObject() {
this.doSomething = function() {
...
}
var self = this
$('#foobar').b... | <p>This question is not specific to jQuery, but specific to JavaScript in general. The core problem is how to "channel" a variable in embedded functions. This is the example:</p>
<pre><code>var abc = 1; // we want to use this variable in embedded functions
function xyz(){
console.log(abc); // it is available here!
... | <p>I think it actually depends on what are you going to do inside your <code>doSomething</code> function. If you are going to access <code>MyObject</code> properties using this keyword then you have to use that. But I think that the following code fragment will also work if you are not doing any special things using <c... | 43,853 |
<p>HxD (hex editor) allows to search/view/edit RAM.</p>
<p>How can I protect a EXE against such editor? Data is encrypted inside INI/registry/DB,
but is decoded at RAM. </p>
<p>What is the solution? At runtime decode, use and recode data inside RAM ASAP?</p>
| <p>Maybe <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>H</kbd> in Eclipse / IntelliJ IDEA ? (albo present in NB somewhere)
Or "data flow from/to" in IntelliJ IDEA?</p>
| <p>In UML 2 there are two basic categories of diagrams: structure diagrams and behavior diagrams. Every UML diagram belongs to one these two diagram categories. The purpose of structure diagrams is to show the static structure of the system being modeled. They include the class, component, and or object diagrams. Behav... | 18,518 |
<p>I have a program that spits out an Excel workbook in Excel 2003 XML format. It works fine with one problem, I cannot get the column widths to set automatically.</p>
<p>A snippet of what I produce:</p>
<pre><code> <Table >
<Column ss:AutoFitWidth="1" ss:Width="2"/>
<Row ss:AutoFitHeight="0" s... | <p>Only date and number values are autofitted :-(
quote: "... We do not autofit textual values"</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa140066.aspx#odc_xmlss_ss:column" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa140066.aspx#odc_xmlss_ss:column</a></p>
| <p>Autofit does not work on cells with strings.
Try to replace the Column-line in your example by the following code:</p>
<pre><code> <xsl:for-each select="/*/*[1]/*">
<Column>
<xsl:variable name="columnNum" select="position()"/>
<xsl:for-each select="/*/*/*[position()=$co... | 20,718 |
<p>I have a relatively powerful dev workstation - 8 cores and 3 Gig of Ram. However, Visual Studio 2008 does not seem to take full advantage, especially during large builds.
Are there any tweaks to be performed on XP VM settings etc to increase performance? I remember back in the bad old days that out of the box windo... | <p>The biggest issue I usually have when working in large projects aren't cpu or memory, but the hard drive. Get several HD's on different channels (or use SCSI for best performance) and put the output files, intermediate files, temp folder on 3 different HD's. That should make a big difference.</p>
<p>I know you said... | <p>From what I remember, XP Pro only supported up to 2 processors, with cores falling under their definition of processor? XP Home officially only supported 1, but I know that people were able to get 2 working on it.</p>
| 38,674 |
<p>I want to place all my programs content in a compressed archive file as its starting to get quite large. I know theres a few libraries around like zlib but i dont know how to make them do what I want to do:</p>
<ul>
<li><p>Be able to load textures/models etc from the file, curretly im using d3dx methods such as D3D... | <p>I'd recommend looking at open source games (quake3 for example). Some of them are packing resources and have working implementations of "virtual file system", as Vilx noted. You might get some ideas.</p>
| <p>There are ready made libraries for this sort of thing. I'm afraid I don't know any names, but I suggest to google on the keywords "virtual file system".</p>
| 48,156 |
<p>I'm trying to write a log file from an ASP.NET application under IIS7, but keep getting the following exception:</p>
<pre><code>UnauthorizedAccessException "Access to the path 'C:\Users\Brady\Exports' is denied."
</code></pre>
<p>I've been advised to use <a href="http://technet.microsoft.com/en-us/sysinternals/bb8... | <p>When PM starts it displays a filter dialog. Just click 'Reset' to use the standard filtering. This will generate lots of messages, and you are only interested in very few of them. Under <em>Process Name</em>, select a line with the process you want to monitor. Richtclick it and choose <em>include </em>. That limits ... | <p>Not sure why you would want to use Process Monitor for access problem in file system.</p>
<p>Check that the directory has access permitted for the user which the application is running as at the point of the file IO call. If you are impersonating this would be the Network Service account. If you are impersonating, ... | 23,145 |
<p>How can I send a monitor into/out-of a different power state (like sleep)?</p>
| <p>The latest version is maintained on IDesign's site here:</p>
<p><a href="http://idesign.net/Downloads/GetDownload/1887" rel="nofollow noreferrer">http://idesign.net/Downloads/GetDownload/1887</a></p>
<p>Older version are available on the O'Reilly site.</p>
<p>Programming WCF Services 3rd Edition (PWSTE) Samples:
... | <p>I went through the same process. But, luckily, I needed to download InProc Factory project from Idesign's site and there it was, the ServiceModelEx is bundled with InProc Factory example.</p>
<p>It is stored under <a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&tabid=11#WCFEssentials" rel... | 42,564 |
<p>Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). </p>
<p>Except for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you... | <p>We've used IronPython to build our flagship spreadsheet application (40kloc production code - and it's Python, which IMO means loc per feature is low) at <a href="http://www.resolversystems.com/" rel="noreferrer">Resolver Systems</a>, so I'd definitely say it's ready for production use of complex apps.</p>
<p>There... | <p>I know I'm probably stating the obvious, but don't forget that the quality of the development team and their familiarity with the technology will have a major impact on your ability to deliver. </p>
<p>If you have a strong team, then it's probably not an issue if they're familiar. But if you have people who are mor... | 5,632 |
<p>In the past I've never been a fan of using triggers on database tables. To me they always represented some "magic" that was going to happen on the database side, far far away from the control of my application code. I also wanted to limit the amount of work the DB had to do, as it's generally a shared resource and I... | <p>Triggers are generally used incorrectly, introduce bugs and therefore should be avoided. Never design a trigger to do integrity constraint checking that crosses rows in a table (e.g "the average salary by dept cannot exceed X).</p>
<p><a href="http://asktom.oracle.com" rel="noreferrer">Tom Kyte</a>, VP of Oracle h... | <p>I'm not a fan, personally. I'll use them, but only when I uncover a bottleneck in the code that can be cleared by moving actions into a trigger. Generally, I prefer simplicity and one way to keep things simple is to keep logic in one place - the application. I've also worked on jobs where access is very compartme... | 3,490 |
<p>It seems pretty common to want to let your javascript know a particular dom node corresponds to a record in the database. So, how do you do it?</p>
<p>One way I've seen that's pretty common is to use a class for the type and an id for the id:</p>
<pre><code><div class="thing" id="5">
<script> myThing ... | <p>Note that an ID cannot start with a digit, so:</p>
<pre><code><div class="thing" id="5">
</code></pre>
<p>is invalid HTML. See <a href="https://stackoverflow.com/questions/70579/what-is-a-valid-value-for-id-attributes-in-html#70586">What are valid values for the id attribute in HTML?</a></p>
<p>In your case... | <p>Non-standard attributes are fine, if you're using XHTML and take the time to extend the DTD you're using to cover the new attributes. Personally, I'd just use a more unique id, like some of the other people have suggested.</p>
| 20,022 |
<p>An old Direct3D book says </p>
<blockquote>
<p>"...you can achieve an acceptable frame
rate with hardware acceleration while
displaying between 2000 and 4000
polygons per frame..."</p>
</blockquote>
<p>What is one polygon in Direct3D? Do they mean one primitive (indexed or otherwise) or one triangle?</p>
| <p>That book means triangles. Otherwise, what if I wanted 1000-sided polygons? Could I still achieve 2000-4000 such shapes per frame?</p>
| <p>As others already said, polygons here means triangles.
Main advantage of triangles is that, since 3 points define a plane, triangles are coplanar by definition. This means that every point within the triangle is exactly defined as a linear combination of polygon points. More vertices aren't necessarily coplanar, an... | 29,596 |
<p>I am working on an ASP.NET MVC application where I need to export data to an excel spreadsheet. Previously, in webforms apps, I used some code I found to render a GridView as an excel-compatible file. This was quite handy. I was wondering what the quickest/most effective method would be to do this in MVC. Thanks.<... | <p>One simple option would be to create a view to render an XML-version of an Excel File. You could either use the new Office 2007 version, or the older 2003 version. We chose the 2003 version so that more people could use it, but that's up to you, of course.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa1... | <p>Here is a blog post from Stephen Walther entitled <a href="http://stephenwalther.com/blog/archive/2008/06/16/asp-net-mvc-tip-2-create-a-custom-action-result-that-returns-microsoft-excel-documents.aspx" rel="noreferrer">ASP.NET MVC Tip #2 - Create a custom Action Result that returns Microsoft Excel Documents</a></p>
| 38,761 |
<p>Right, I know I am totally going to look an idiot with this one, but my brain is just <em>not</em> kicking in to gear this morning.</p>
<p>I want to have a method where I can say "if it goes bad, come back with this type of Exception", right?</p>
<p>For example, something like (<strong>and this doesn't wor... | <p>You can almost do it like this:</p>
<pre><code>static void TestException<E>(string message) where E : Exception, new()
{
var e = new E();
e.Message = message;
throw e;
}
</code></pre>
<p>However, that doesn't compile because Exception.Message is read only. It can only be assigned by passing it to... | <p>I think seeing as all exceptions should have a parameterless constructor, and have the <code>Message</code> property, so the following should work:</p>
<pre><code>static ExType TestException<ExType>(string message) where ExType:Exception
{
ExType ex = new ExType();
ex.Message = message;
return ex;... | 6,266 |
<p>Give me some of your thoughts on which is a better coding practice/makes more efficient code/looks prettier/whatever: Increasing and improving your ability to use if statements to anticipate and catch potential problems? Or simply making good use of try/catch in general?</p>
<p>Let's say this is for Java (if it m... | <p>this debate (2003) was good:</p>
<p><a href="http://www.joelonsoftware.com/items/2003/10/13.html" rel="nofollow noreferrer">http://www.joelonsoftware.com/items/2003/10/13.html</a></p>
<p><a href="http://nedbatchelder.com/blog/200310/joel_on_exceptions.html" rel="nofollow noreferrer">http://nedbatchelder.com/blog/2... | <p>There's one thing that hasn't been mentioned here. </p>
<p>With an if-else statement, every time the code runs, at least 1 of the condition is guaranteed to be evaluated executed. I'm sure we all know how an if-else-elseif works, but to be clear... the <strong>if</strong> portion of the statement will always be eva... | 42,629 |
<p>The default GWT StackPanel is not enough good, i want to have functionality similar to outlook stack panel. May be there is already something exists?</p>
| <p>If you don't mind using EXT-GWT, a much prettier fully compliant GWT UI toolkit then this might be more what your looking for. </p>
<p><a href="http://extjs.com/examples/layouts/accordionlayout.html" rel="nofollow noreferrer">The Example</a>. </p>
<p>GXT as it is also called can do lots of good things for a GUI.</... | <p>I took the TabPanel source code and modified it so it drew the tabs to look like Outlook.</p>
| 34,145 |
<p>I have a <code>PHP</code> script that listens on a queue. Theoretically, it's never supposed to die. Is there something to check if it's still running? Something like <code>Ruby's God ( http://god.rubyforge.org/ )</code> for <code>PHP</code>?</p>
<p>God is language agnostic but it would be nice to have a solution t... | <p>I had the same issue - wanting to check if a script is running. So I came up with this and I run it as a cron job. It grabs the running processes as an array and cycles though each line and checks for the file name. Seems to work fine. Replace #user# with your script user.</p>
<pre><code>exec("ps -U #user# -u #u... | <p>One possible solution is to have it listen on a port using the socket functions. You can check that the socket is still listening with a simple script. Even a monitoring service like pingdom could monitor its status. If it dies, the socket is no longer listening.</p>
<p>Plenty of solutions.. Good luck.</p>
| 14,276 |
<p>Anybody have a script or alias to find untracked (really: unadded) files in a Perforce tree?</p>
<p>EDIT: I updated the accepted answer on this one since it looks like P4V added support for this in the January 2009 release.</p>
| <p><strong>EDIT:</strong> Please use <code>p4 status</code> now. There is no need for jumping through hoops anymore. See @ColonelPanic's <a href="https://stackoverflow.com/a/13864328/39648">answer</a>.</p>
<p>In the Jan 2009 version of P4V, you can right-click on any folder in your workspace tree and click "reconcile ... | <p>In P4V, under the "View" menu item choose "Files in Folder" which brings up a new tab in the right pane.
To the far right of the tabs there is a little icon that brings up a window called "Files in Folder" with 2 icons.
Select the left icon that looks like a funnel and you will see several options. Choose "Show ite... | 3,067 |
<p>I used jQuery exclusively on my last project to do all my AJAX calls. I used both $.ajax and $.getJSON calls to return data to the page. However, I see a ton of examples online using jQuery to handle UI and data formatting, but using ASP.NET AJAX to actually perform web service calls and retrieve data. Is it more ef... | <p>I don't think it will make too much difference whether you use ASP.NET Ajax or jQuery. What might make difference is what data is returned and what format it is in i.e. XML, HTML or JSON.</p>
<p>For example, it might be more efficient to return a lightweight JSON object from an Ajax call rather than a big XML docum... | <p>I thought that ASP.Net's libraries were adapted to use jquery...
<a href="http://www.aspcode.net/ASPNET-and-JQuery-first-example.aspx" rel="nofollow noreferrer">http://www.aspcode.net/ASPNET-and-JQuery-first-example.aspx</a></p>
<p>If true, it would mean the two are linked in speed. Although jQueries libraries are ... | 34,225 |
<p>I have a JSP page that contains a scriplet where I instantiate an object. I would like to pass that object to the JSP tag without using any cache. </p>
<p>For example I would like to accomplish this: </p>
<pre><code><%@ taglib prefix="wf" uri="JspCustomTag" %>
<%
Object myObject = new Object();
%>... | <p>A slightly different question that I looked for here: "How do you pass an object to a tag file?"</p>
<p>Answer: Use the "type" attribute of the attribute directive:</p>
<pre><code><%@ attribute name="field"
required="true"
type="com.mycompany.MyClass" %>
</code></pre>
<p>The typ... | <p>Use expression language:</p>
<pre>
<wf:my-tag obj="${myObject}" />
</pre>
| 10,123 |
<p>I have a SQL script that inserts data (via INSERT statements currently numbering in the thousands) One of the columns contains a unique identifier (though not an IDENTITY type, just a plain ol' int) that's actually unique across a few different tables. </p>
<p>I'd like to add a scalar function to my script that get... | <blockquote>
<p>I'm starting to think it can't be done that way since there doesn't seem to be a way to maintain the offset counter between calls. Is that right, or is there something I'm missing.</p>
</blockquote>
<p>You aren't missing anything; SQL Server does not support global variables, and it doesn't support d... | <p>It would probably be more work than it's worth, but you can use static C#/VB variables in a SQL CLR UDF, so I think you'd be able to do what you want to do by simply incrementing this variable every time the UDF is called. The static variable would be lost whenever the appdomain unloaded, of course. So if you need... | 4,795 |
<p>As I hate reinventing the wheel, I wonder if there are any commonly used packaged out there for doing hte simple job of communicating (key,value) pairs of data betweeen two network endpoints (probably TCP/IP is the most likely carrier). I would like something that works in any environment, which for me means Unix/L... | <p>Consider using <a href="http://en.wikipedia.org/wiki/JSON" rel="nofollow noreferrer">JSON</a>? There are libraries available for most programming languages.</p>
| <p>There's also <a href="http://en.wikipedia.org/wiki/Bencode" rel="nofollow noreferrer">bencoding</a>. There's probably libraries (torrent libraries) that will parse it easily enough.</p>
| 30,004 |
<p>I have been writting a keyword search script based on this tutorial:
<a href="http://www.hackosis.com/2007/11/06/howto-simple-search-engine-with-php-and-mysql/" rel="nofollow noreferrer">http://www.hackosis.com/2007/11/06/howto-simple-search-engine-with-php-and-mysql/</a></p>
<p>Like some of the commenters mentione... | <p>If you want to return results that contain <strong>any of the keywords</strong>, then replace all the <strong>AND</strong> with <strong>OR</strong>.</p>
<p>If you do this, then your db will check if any of the keywords exist in any of the columns of the table.</p>
<p>Hence your final query would be read by the DB ... | <p>The AND operator has a higher precedence than OR, so if you want to return results that contain <strong>all of the keywords</strong> you need to add parentheses as follows:</p>
<pre><code> SELECT * FROM blog
WHERE (blog_title LIKE '%barry%' OR blog_content LIKE '%barry%')
AND (blog_title LIKE '%child%' OR bl... | 37,491 |
<p>I am writing a .NET library that for various reasons cannot be registered in the GAC.
This dll (let's call it SDK.dll) depends on other DLLs in order to be loaded.</p>
<p>When writing a program that uses this SDK.dll, I noticed that my program failed loading the dll with a FileNotFoundException thrown. This happens... | <p>You can handle this at runtime by subscribing to this event:</p>
<pre><code>AppDomain.CurrentDomain.AssemblyResolve
</code></pre>
<p>It's fired when the runtime fails to resolve an assembly. In your event handler method, write your logic to find the assembly and load it using Assembly.LoadFrom(). It would look som... | <p>to register your assembly in GAC it must have be signed with a <a href="http://msdn.microsoft.com/en-us/library/szdke3d6.aspx" rel="nofollow noreferrer">strong name</a>.</p>
<p>If it depends on other assemblies, those should be in GAC to.</p>
<p>BeowulfOF</p>
| 46,430 |
<p>I have a page with a "Print" link that takes the user to a printer-friendly page. The client wants a print dialog box to appear automatically when the user arrives at the print-friendly page. How can I do this with javascript?</p>
| <pre><code>window.print();
</code></pre>
<p>unless you mean a custom looking popup.</p>
| <p>if problem:</p>
<pre><code> mywindow.print();
</code></pre>
<p>altenative using: </p>
<pre><code>'<scr'+'ipt>print()</scr'+'ipt>'
</code></pre>
<p>Full:</p>
<pre><code> $('.print-ticket').click(function(){
var body = $('body').html();
var ticket_area = '<aside class="widget ticke... | 29,979 |
<p>Anyone have any experience creating a modal dialog box using AJAX and ASP.NET MVC? I am looking to create a Yes/Cancel confirmation dialog when a user deletes an item. In standard ASP.NET I could just use the ModalPopup extender, but I am not sure how to do this in MVC.</p>
<p>Thanks</p>
| <p>How about <a href="http://www.ericmmartin.com/projects/simplemodal/" rel="nofollow noreferrer">SimpleModal</a> for jQuery?</p>
| <p>I've found <a href="http://dev.iceburg.net/jquery/jqModal/" rel="nofollow noreferrer">jqModal</a> [for jQuery] to be very easy to work with.</p>
| 34,709 |
<p>I've built the x86 Boost libraries many times, but I can't seem to build x64 libraries. I start the "Visual Studio 2005 x64 Cross Tools Command Prompt" and run my usual build:</p>
<pre><code>bjam --toolset=msvc --build-type=complete --build-dir=c:\build install
</code></pre>
<p>But it still produces x86 .lib files... | <p>You need to add the <code>address-model=64</code> parameter.</p>
<p>Look e.g. <a href="http://devsql.blogspot.com/2007/05/building-boost-134-for-x86-x64-and-ia64.html" rel="noreferrer">here</a>.</p>
| <p>You may find following <a href="https://boostorg.github.io/build/manual/develop/index.html#bbv2.overview.invocation.properties" rel="nofollow noreferrer">Boost.Build property</a>:</p>
<pre><code>address-model=64
</code></pre>
| 38,799 |
<p>We need to be able to change the default selected print tray of a given printer. Does anyone have VC++/win32 code for doing this?</p>
<p>In case it matters, I believe we have to change the default setting for the printer. Our print jobs are executed by an application other than ours, so we can't make these kinds ... | <p>FYI - the solution we wound up using was to capture the DEVMODE structure. We have a small win32 app that presents the printer settings dialog (via <a href="http://msdn.microsoft.com/en-us/library/dd183576.aspx" rel="nofollow">DocumentProperties</a> with fMode set to DM_IN_PROMPT). The resultant DEVMODE is then sa... | <p>I had to do something very similar recently on a <a href="http://www.zan1011.com/" rel="nofollow noreferrer">specific printer driver</a> and it required a vendor specific SDK. The tray doesn't seem to appear in DEVMODE or any of the other PRINTINFO_* structures so I guess I'd drop an email to the printer vendor.</p... | 19,999 |
<p>I've been working on a project called <a href="http://www.codeplex.com/axial" rel="nofollow noreferrer">Axial</a> that converts MSIL (compiled C# or VB.NET) to JavaScript. There are a few samples of working code, but some common situations don't work properly. (The current release doesn't work in production mode and... | <p>You ought to be using <a href="http://www.php.net/fgetcsv" rel="nofollow noreferrer">fgetcsv()</a> if possible.</p>
<p>Otherwise, there is always fgets().</p>
| <p>You should have a look at <code>fgetcsv()</code>, it automatically parses the coma seperated line into an array. </p>
<p>As for the runtime efficiency, I have no idea. You will have to run a quick test, preferably with a file of the size you are expecting to handle later on. But I would be surprised if the fget??? ... | 33,218 |
<p>I need to print parts that fit together very well on the Longer LK5 Pro. However, after printing a Benchy, I noticed that whatever I print has a lot of imperfections. Is there any way I can fix this? All I know about the printing conditions was that I was printing at 230 °C nozzle temperature with 60 °C bed temperat... | <p><a href="https://www.longer3d.com/products/lk5-pro-fdm-3d-printer" rel="nofollow noreferrer">Looking up your printer</a>, one thing I noticed is that it has power loss recovery. This feature writes to the SD card at the start of each new layer, stalling the print for at least a significant fraction of a second with ... | <p>Just got an LK5 and printed the included Benchy gcode. It looks pretty similar to the benchy in the pics with some of the blobs in the same location. Then I downloaded the benchy from Thingiverse and sliced it with the Longer 1.3 Slicer. Pretty good results from doing that but it took longer to print.</p>
| 2,133 |
<pre><code><% using (Html.BeginForm() { %>
<%=Html.DropDownList("TopItemsList", ViewData["ListData"], new { onchange="[???]" })%>
<% } %>
</code></pre>
<p>In the above example, what value should you set onchange to? Or, how do you get the correct form?</p>
<p>Is there any difference with Ajax.Be... | <p>try this:</p>
<pre><code><%=Html.DropDownList("TopItemsList", ViewData["ListData"], new { onchange="this.form.submit();" })%>
</code></pre>
<p>Every form element in the has a "form" property that is pointed to the form that contains this element.</p>
<p>Yes, using "Html." and "Ajax." has a difference. Ajax.... | <p>Why are you mixing your html with javascript??</p>
<p>Delete the onchange attribute and add some JQuery:</p>
<pre><code>$("#TopItemsList").change(function () {
$("input[type=submit]").click();
});
</code></pre>
| 47,589 |
<p>OK first some background. I am busy automating our build process. We run a mixture of Vs 2005 and VS 2008 both targeting platform 2.0. We use Nant to do our builds using the MSBUILD task to do the compile and Cruise Control .net to do our CI. Currently we treat all warnings as errors, fail the build if any FxCop ... | <p>What we do is actually have a powershell script run right after that parses through the output file, and throws a series of errors with an appropriate message depending on which condition it found. As soon as powershell throws an error the build fails.</p>
| <p>See documentation about NDepend Critical Rules and Build Failure:
<a href="http://www.ndepend.com/Doc_CI_CriticalRule.aspx" rel="nofollow">http://www.ndepend.com/Doc_CI_CriticalRule.aspx</a></p>
| 35,506 |
<p>I've been asked to implement some code that will update a row in a MS SQL Server database and then use a stored proc to insert the update in a history table. We can't add a stored proc to do this since we don't control the database. I know in stored procs you can do the update and then call execute on another stor... | <p>Either run them both in the same statement (separate the separate commands by a semi-colon) or a use a transaction so you can rollback the first statement if the 2nd fails.</p>
| <p>You can also create sql triggers.</p>
| 10,098 |
<p>I am seeing some rather weird behavior with PowerShell, it looks like custom functions might need a "parenthesis wrapper" to evaluate as you might expect them. Given a simple PowerShell function:</p>
<pre><code>function Return-True { return $true }
</code></pre>
<p>and then some sample code to invoke it:</p>
<pre... | <p>When PowerShell sees the token <code>Return-True</code> it identifies it as a command and until evaluation or end of the statement, everything else is an argument which is passed to the function <code>Return-True</code>.</p>
<p>You can see this in action if you do:</p>
<pre><code>PS > function Return-True { "Th... | <p>The second line is not doing a boolean evaluation. Look at what happens if you do the same thing with strings.</p>
<pre><code>PS C:\> function Return-True { return "True string" }
PS C:\> Return-True
True string
PS C:\> Return-True -eq "False string"
True string
PS C:\> (Return-True) -eq "False string"
... | 17,980 |
<p>What I'm trying to do with <code>FileStream</code> in C#/.NET is to open two streams: one appending to a file and the other reading those writes asynchronously (for unit testing some network connection handling code). I can't figure out how to get the <em>writer</em> stream to open the file in non-exlusive locking ... | <p>See this question: <a href="https://stackoverflow.com/questions/124946/c-file-readwrite-fileshare-doesnt-appear-to-work">C# file read/write fileshare doesn’t appear to work</a></p>
<p>In short, your freader has to specify FileShare.Write to allow for the fact that there is already a writer on the file.</p>
| <p>I am not sure if it helps, but if you are only unit testing, wouldn't it be easier to use a memory stream instead of files?</p>
| 22,948 |
<p>I need to see the contents of the viewstate of an asp.net page. I looked for a viewstate decoder, found <a href="http://www.testingreflections.com/node/view/3424" rel="noreferrer">Fridz Onion's ViewState Decoder</a> but it asks for the url of a page to get its viewstate. Since my viewstate is formed after a postback... | <p>Use <a href="http://www.fiddlertool.com" rel="noreferrer">Fiddler</a> and grab the view state in the response and paste it into the bottom left text box then decode.</p>
| <p>Normally, ViewState should be decryptable if you have the machine-key, right? After all, ASP.net needs to decrypt it, and that is certainly not a black box.</p>
| 4,284 |
<p>I have a function in a native DLL defined as follows:</p>
<pre><code>#include <string>
void SetPath(string path);
</code></pre>
<p>I tried to put this in Microsoft's P/Invoke Interop Assistant, but it chokes on the "string" class (which I think is from MFC?).</p>
<p>I have tried marshaling it as a variety o... | <p>Looks like you're trying to use the C++ standard library string class. I doubt that will be easy to Marshal. Better to stick with a char * and Marshal as StringBuilder. That's what I usually do. You'll have to add a wrapper that generates the C++ string for you.</p>
| <p>Yes. You can. Actually, not just <code>std::string</code>, <code>std::wstring</code>, any standard C++ class or your own classes can be marshaled or instantiated and called from C#/.NET.</p>
<p>The basic idea of instantiating a C++ object from .NET world is to allocate exact size of the C++ object from .NET, then c... | 19,187 |
<p>Suppose the following data schema:</p>
<pre><code>Usage
======
client_id
resource
type
amount
Billing
======
client_id
usage_resource
usage_type
rate
</code></pre>
<p>In this example, suppose I have multiple resources, each of which can be used in many ways. For example, one resource is a <code>widget</code>. <... | <p>There is apparently an project at sourceforge to extend Rails' ActiveRecord with support for <a href="http://compositekeys.rubyforge.org/" rel="nofollow noreferrer">Composite Primary Keys</a>. I haven't used this extension, but it might help you. It's also a gem at rubyforge.</p>
<p>Plain Ruby on Rails, as of ver... | <p>You can create any constraint you want with the 'execute' command in a migration.</p>
<p>You would probably want to add some error handling to .save to deal with cases when the constraint throws an error.</p>
<p>You can't use AR's built-in method generators to generate the usages off the billing, but you can still... | 35,370 |
<p>I am currently developing a (somewhat large) site for a magazine, the site mainly consists of sections like : news (for various categories), members, and some 'other stuff' (like shoutbox, polls, previous covers, photo galleries that can be tagged, and ad banners system).</p>
<p>Now, since most part of the site is ... | <p>Honestly I think it's a pretty bad idea, at least on the background of my own experience.</p>
<p>The main disadvantages:</p>
<ul>
<li>doubles the amount of knowledge an admin/editor has to have/develop</li>
<li>doubles the amount of security risks</li>
<li>doubles the amount of updating/patching the CMS installati... | <p>It could be a good idea to use WordPress, depending on the features you want in your blogs. Drupal has a 'blog' feature, but it's a bit limited. (For example, people can't leave comments using OpenID like they can in Word Press - although I haven't used Drupal in 6 months or so, it might have changed. For an example... | 46,821 |
<p>I was looking for a tree or graph data structure in C#, but I guess there isn't one provided. <a href="http://msdn.microsoft.com/en-us/library/ms379574.aspx" rel="noreferrer">An Extensive Examination of Data Structures Using C# 2.0</a> a bit about why. Is there a convenient library which is commonly used to provide... | <p>My best advice would be that there is no standard tree data structure because there are so many ways you could implement it that it would be impossible to cover all bases with one solution. The more specific a solution, the less likely it is applicable to any given problem. I even get annoyed with LinkedList - wha... | <p>In case you need a rooted tree data structure implementation that uses less memory, you can write your Node class as follows (C++ implementation):</p>
<pre><code>class Node {
Node* parent;
int item; // depending on your needs
Node* firstChild; //pointer to left most child of node
Node* ... | 9,245 |
<p>My C application uses 3rd libraries, which do their own memory management.
In order to be robust, my application has code to deal with failures of library functions due to lack of free memory.</p>
<p>I would like to test this code, and for this, I need to simulate failures due to lack of memory.</p>
<p>What tool/s... | <p>You can use <code>ulimit</code> to limit the amount of resources a user can use, including memory. So you create a test user, limit their memory use to something just enough to launch your program, and watch it die :)</p>
<p>Example:</p>
<pre><code>ulimit -m 64
</code></pre>
<p>Sets a memory limit of 64kb.</p>
| <p>You want the ulimit command in bash. Try
<pre>help ulimit</pre> at a bash shell prompt.</p>
| 13,427 |
<p>I am writing an RSS feed (for fun) and was looking at the spec <a href="http://cyber.law.harvard.edu/rss/rss.html" rel="noreferrer">here</a>.</p>
<blockquote>
<p>RSS is a dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.</p>
</blo... | <p>No, RSS is an XML-based format, and JSON is an different language rather than some kind of dialect. RSS readers won't understand JSON.</p>
<p>Your question is akin to asking 'Can I speak French in Chinese?'</p>
| <blockquote>
<p>Are there programs that can aggregate/understand this format.</p>
</blockquote>
<p>You can use <a href="https://www.w3.org/TR/xslt-30/" rel="nofollow noreferrer">XSLT 3.0</a> to transform XML to JSON and back to XML again. More info on how to accomplish the transforms to JSON here: </p>
<p><a href="... | 30,609 |
<p>Does anyone have a method to overcome the 260 character limit of the MSBuild tool for building Visual Studio projects and solutions from the command line? I'm trying to get the build automated using CruiseControl (CruiseControl.NET isn't an option, so I'm trying to tie it into normal ant scripts) and I keep on runni... | <p>It seems that it is limitation of the MSBuild. We had the same problem, and in the end, we had to get paths shortened, because did not find any other solution that worked properly.</p>
| <p>Have you tried DOS paths? Or the \\?\ prefix? The <a href="http://blogs.msdn.com/bclteam/" rel="nofollow noreferrer">.NET BCL team blog</a> has more info.</p>
| 16,930 |
<p>I have had my Ender 3 Pro for about 2 years now and it has been working amazingly!</p>
<p>Since November it's struggling very much while printing. I am quite sure the problem lives on the extruder motor.</p>
<p>About 1 of 5 prints come out ok. The main problem is that the first 2-3 first layers are all good. But as ... | <p>There are a few probable causes I can think of based on your description. That it only starts happening after the printer has been running for a bit makes me think it's a heat issue.</p>
<p>The first problem I'd check out is that extruder motor getting that hot. It should be warm, but not so hot it's uncomfortable t... | <blockquote>
<p>I noticed that the motor is getting pretty hot.</p>
</blockquote>
<p>That's not normal. Replacement motors are cheap and easy to find, so I'd swap out the motor before doing anything else. If the new one also heats up the same way, there might be a problem with the main board, but I'll bet a new motor w... | 2,086 |
<p>I am creating a jQuery plugin.</p>
<p>How do I get the real image width and height with Javascript in Safari?</p>
<p>The following works with Firefox 3, IE7 and Opera 9:</p>
<pre><code>var pic = $("img")
// need to remove these in of case img-element has set width and height
pic.removeAttr("width");
pic.removeA... | <p>Webkit browsers set the height and width property after the image is loaded. Instead of using timeouts, I'd recommend using an image's onload event. Here's a quick example:</p>
<pre><code>var img = $("img")[0]; // Get my img elem
var pic_real_width, pic_real_height;
$("<img/>") // Make in memory copy of ima... | <p>For functions where you do not want to alter the original placement or image.</p>
<pre><code>$(this).clone().removeAttr("width").attr("width");
$(this).clone().removeAttr("height").attr("height);
</code></pre>
| 41,183 |
<p>In textmate, when there's a current selection, I hit the " key and the selection gets surrounded by quotes. The same thing happens with other balanced characters like (, {, [ and '.</p>
<p>Am I missing something obvious in Emacs configuration that would enable similar behaviour when using transient mark mode, or do... | <p>wrap-region.el from <a href="http://sami.samhuri.net/2007/6/23/emacs-for-textmate-junkies" rel="nofollow noreferrer">this guy's blog post</a> will do what you're looking for.</p>
<p><a href="http://mumble.net/~campbell/emacs/paredit.el" rel="nofollow noreferrer">Paredit</a> will complete the TextMate-style quoting.... | <p>You should check out these older, very similar, questions:</p>
<p><a href="https://stackoverflow.com/questions/1023770/automatically-closing-braces-in-emacs/1024531#1024531">Automatically closing braces in Emacs?</a></p>
<p><a href="https://stackoverflow.com/questions/848647/emacs-typeover-skeleton-pair-insert-may... | 9,835 |
<p>Tracking a single remote branch as a local branch is straightforward enough. </p>
<pre><code>$ git checkout --track -b ${branch_name} origin/${branch_name}
</code></pre>
<p>Pushing all local branches up to the remote, creating new remote branches as needed is also easy.</p>
<pre><code>$ git push --all origin
</co... | <p>Using bash:</p>
<strong>after git 1.9.1</strong>
<pre><code>for i in `git branch -a | grep remote | grep -v HEAD | grep -v master`; do git branch --track ${i#remotes/origin/} $i; done
</code></pre>
<blockquote>
<p><strong>credits:</strong> Val Blant, elias, and Hugo</p>
</blockquote>
<strong>before git 1.9.1</strong... | <p>In case you already have some branches checked out and want to</p>
<ul>
<li>check out all remaining branches from the remote</li>
<li>make sure all local branches track the remote branches</li>
</ul>
<p>you can use the following bash- and zsh-compatible script:</p>
<pre><code>git branch -r | while read b; do if g... | 49,659 |
<p>A prospective client wants to have a calendar feature on their website. They want the option to go edit this calendar to update the events. Does Word Press offer something like this?</p>
| <p>I've seen people use Google Calendar for this. Then you can easily embed google cal in your web pages. Also, if others use Google Cal they can add evens to their calendars.</p>
<p><a href="http://www.google.com/support/calendar/bin/answer.py?hl=en&answer=41207" rel="nofollow noreferrer">http://www.google.com/... | <p>I'm not sure if Wordpress has that feature but I do know of a Calendar class for PHP that's fairly simple, easy to implement and very easy to style. Check out the tutorial, <a href="http://oscarm.org/page/calendarClass/" rel="nofollow noreferrer">here</a>. </p>
| 27,536 |
<p>I'm trying to do a file system backup of a RedHat Enterprise Linux v4 server using Symantec Backup Exec 11d (Rev 7170). The backup server is Windows Server 2003.</p>
<p>I can browse the target server to create a selection list, and when I do a test run it completes successfully.</p>
<p>However, when I run a real ... | <p>Sure sounds like firewall issues. Try stopping iptables, and running again. Also, RALUS can dump a log file - which may give some more to go on. </p>
<p>I use the older UNIX agent myself, which uses port 6101 IIRC - but I believe that the newer client uses tcp/10000 for control and 1024-65535 for transfer.</p>
<p>... | <p>To clarify the answer, the solution was to open up the tcp ports from 1024-65535.</p>
<p>The iptables looked liked this:</p>
<pre><code>[root@MYSERVER ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- 0.0... | 4,128 |
<p>I'm curious if anyone have any really good tutorials/articles/books for learning about stack machines in general, and the JVM in particular. I know these ones:</p>
<p><a href="http://www.artima.com/insidejvm/applets/EternalMath.html" rel="nofollow noreferrer">http://www.artima.com/insidejvm/applets/EternalMath.html... | <p>I learned what the JVM did by reading The "Java Virtual Machine Specification" by Tim Lindholm back in 1999.</p>
<p>I don't really know where to find as good a resource about more modern technologies like the JIT compilation that the Hotspot VM can do.</p>
| <p>I've found a lot of what I was looking for now, in the final chapter of "Structure and Interpretation of Computer Programs". You are going to have to read through all the book though since they constantly build on examples and concepts from earlier on.</p>
| 21,645 |
<p>I have an old Delphi codebase I have to maintain, lots of DLLs, some older than others. In some of these DLLs there is no version information in the Project Options dialog. The controls for adding a version are greyed out and I can't even add a version number by manually editing the .DOF file. How can I include a ve... | <p>Check if the default .RES file exists in the project source location. Delphi includes the version number of the project in a .res file with the same name as the .dpr file. If the .RES file does not exist, the simplest way to recreate it is to add the {$R *.RES} compiler directive to the .DPR file, immediately after ... | <p>I use a build control system (FinalBuilder) and that is able to add version resources to all my DLLs and EXEs that are all coherent. Therefore I can be confident that the file set is all labelled with the same build. There are some Delphi projects that don't have versions by default, and FB will add them for you any... | 15,985 |
<p>I'm designing this collection of classes and abstract (MustInherit) classes…</p>
<p><img src="https://web.archive.org/web/20120911004421/http://img396.imageshack.us/img396/1711/nodeclassinheritanceej0.gif" alt="class diagram"></p>
<p>This is the database table where I'm going to store all this…</p>
<p><img src="h... | <p>Use CHECK constraints on the table. These allow you to use any kind of boolean logic (including on other values in the table) to allow/reject the data.</p>
<p>From the <a href="http://msdn.microsoft.com/en-us/library/ms188258.aspx" rel="nofollow noreferrer">Books Online</a> site:</p>
<blockquote>
<p>You can crea... | <p>SQL Server doesn't know anything about your classes. I think that you'll have to enforce this by using a Factory class that constructs/deconstructs all these for you and makes sure that you're passing the right values depending upon the type. </p>
<p>Technically this is not "enforcing the rules in the database" but... | 11,170 |
<p>I want to use PKCS#7 as a container format for some encrypted, signed content and we need to use AES in CBC mode with ISO 10126 based padding. I can't seem to find a concrete reference to an algorithm identifier to use for this combination. I can invent my own but would then lose interoperability with other tools.</... | <p>The padding mode does not need to be specified. This is true because PKCS#7 (like many other cryptographic containers) uses ASN.1/BER encoding. As the BER encoding contains the exact length of the message inside the padded plain text, the actual value of the padding doesn't matter.</p>
| <p>It turns out that the padding mode does not need to be specified, only the crypto algorithm matters.</p>
| 39,158 |
<p>I am working on a project where I produce an aluminium extrusion cutting list.</p>
<p>The aluminium extrusions come in lengths of 5m.</p>
<p>I have a list of smaller lengths that need to be cut from the 5m lengths of aluminium extrusions.</p>
<p>The smaller lengths need to be cut in the order that produces the le... | <p>This is a classic, difficult problem to solve efficiently. The algorithm you describe sounds like a <a href="http://en.wikipedia.org/wiki/Greedy_algorithm" rel="noreferrer">Greedy Algorithm</a>. Take a look at this Wikipedia article for more information: <a href="http://en.wikipedia.org/wiki/Cutting_stock_problem" r... | <p>The <a href="https://en.wikipedia.org/wiki/Column_generation" rel="nofollow noreferrer">Column generation algorithm</a> will quickly find a solution with the minimum possible waste.</p>
<p>To summarize, it works well because it doesn't generate all possible combinations of cuts that can fit on a raw material length.... | 4,214 |
<p>I like to use IPython's zope profile to inspect my Plone instance, but a few annoying permissions differences come up compared to inserting a breakpoint and hitting it with the admin user.</p>
<p>For example, I would like to iterate over the content objects in an unpublished testing folder. This query will return n... | <p>Just use catalog.search({'path':'Plone/testing'}). It performs the same query as catalog() but does not filter the results based on the current user's permissions.</p>
<p>IPython's zope profile does provide a method utils.su('username') to change the current user, but it does not recognize the admin user (defined i... | <p>Just use catalog.search({'path':'Plone/testing'}). It performs the same query as catalog() but does not filter the results based on the current user's permissions.</p>
<p>IPython's zope profile does provide a method utils.su('username') to change the current user, but it does not recognize the admin user (defined i... | 35,252 |
<p>I am new to culling. On a first glance, it seems that most occlusion culling algorithms are object-level, not examining single meshes, which would be practical for game rendering.</p>
<p>What I am looking for is an algorithm that culls all meshes within a single object that are occluded for a given viewpoint, with ... | <p>Blender performs both view frustum culling and occlusion culling, based on the dynamic AABB tree acceleration structures from the Bullet physics library. Occluders and objects are represented by their bounding volume (axis aligned bounding box).</p>
<p>View frustum culling just traverses the AABB tree, given a came... | <p>Usually the first thing you do is see if the meshes have any chance of occluding each other. Often times with a simple bounding primitive (bounding boxes or bounding spheres). If I recall correctly, <a href="http://en.wikipedia.org/wiki/Octree" rel="nofollow noreferrer">Octrees</a> will help with this.</p>
| 41,031 |
<p>With the <em>Visual Studio 2005 C++ compiler</em>, I get the following warning when my code uses the <code>fopen()</code> and such calls:</p>
<pre class="lang-none prettyprint-override"><code>1>foo.cpp(5) : warning C4996: 'fopen' was declared deprecated
1> c:\program files\microsoft visual studio 8\vc\i... | <p>It looks like Microsoft has deprecated lots of calls which use buffers to improve code security. However, the solutions they're providing aren't portable. Anyway, if you aren't interested in using the secure version of their calls (like <strong>fopen_s</strong>), you need to place a definition of <strong>_CRT_SECURE... | <p>I also got the same problem. When I try to add the opencv library</p>
<pre><code>#include <opencv\cv.h>
</code></pre>
<p>I got not a warning but an error.</p>
<pre><code>error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_... | 3,516 |
<p>Which scenarios, areas of an application/system, etc. are best suited for 'classic' state based testing versus using mock objects?</p>
| <p>You should be using mocks for dependencies. I don't think that its an either-or; Usually you will create mocks for dependencies, set expectations (whether it is calls or state) on them, then run the unit under test. Then you would check its state, and verify the expectations on the mocks, afterwards.</p>
| <p>Its a matter of style.. Mockist vs Classic TDDers.<br>
Personally.. I'd go testing real classes as far as possible. Tone down on Mocks as much as possible; only to decouple things like IO (filesystems, DB Connections, network), Third party components, etc. things that are slow/difficult to get under test. </p>
| 7,860 |
<p>That was an interview question that I was unable to answer:</p>
<p>How to check that a string is a palindrome using regular expressions?</p>
<p>p.s. There is already a question "<a href="https://stackoverflow.com/questions/52002/how-to-check-if-the-given-string-is-palindrome">How to check if the given string is pa... | <p>The answer to this question is that "it is impossible". More specifically, the interviewer is wondering if you paid attention in your computational theory class.</p>
<p>In your computational theory class you learned about finite state machines. A finite state machine is composed of nodes and edges. Each edge is ann... | <p>A slight refinement of Airsource Ltd's method, in pseudocode:</p>
<pre><code>WHILE string.length > 1
IF /(.)(.*)\1/ matches string
string = \2
ELSE
REJECT
ACCEPT
</code></pre>
| 28,873 |
<p>Trivial data binding examples are just that, trivial. I want to do something a little more complicated and am wondering if there's an easy, built in way to handle it.</p>
<pre><code>public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
List<DataStruct> list = new List<Dat... | <p>In Matlab a semicolon ";" at the end of a line suppresses output. So,</p>
<pre><code>>> d=1+2;
>> d=1+2
d =
3
</code></pre>
<p>Or you can use <em>disp</em> as in the <a href="https://stackoverflow.com/questions/192796/creating-output-m-file-in-matlab#192841">first answer</a>.</p>
<pre><code>>... | <pre><code>disp(num2str(d));
</code></pre>
| 23,429 |
<p>I have rough ideas - like dealing with singular/plural, two or more words/phrases that mean the same thing, misspellings, etc. But I'm not sure of any patterns or rules of thumb for dealing with these, either programatically and automatically or by presenting them to administrators or even users to clean up.</p>
<p... | <p>You should have a <strong>policy for the format</strong> of the tags (e.g. tags should be singular). Depending on how diverse the tags are, it might be useful not only to auto-complete while you are typing in a tag, but also to <strong>suggest similar tags</strong>, so that it is easy for people to use the tag syste... | <p>Use an <strong>ajax-driven</strong> suggestion form, like StackOverflow :)</p>
| 32,470 |
<p>I have an application that is database intensive. Most of the applications methods are updating data in a database. Some calls are wrappers to stored procedures while others perform database updates in-code using 3rd party APIs. </p>
<p>What should I be testing in my unit tests? Should I...</p>
<ol>
<li>Test t... | <p>I do number 2, i.e., test the update by updating a record, and then reading it back out and verifying that the values are the same as the ones you put in. Do both the update and the read in a transaction, and then roll it back, to avoid permanent effect on the database. I don't think of this as testing Framework ... | <p>If the update logic is complex then you should do #2.</p>
<p>In practice the only way to really unit test a complex calculation and update
like say, calculating the banking charges on a set of customer transactions,
is to intialise a set of tables to known values at the start of your
unit test and test for the expe... | 43,298 |
<p>When developing with .NET 3.5 I naturally use LINQ for data access.</p>
<p>But for .NET 2.0 projects, what data access model is the best one to use? I tend to use TableAdapters mainly, but sometimes also write my own SQL depending on the situation.</p>
| <p>Have you tried <a href="http://nhibernate.org" rel="nofollow noreferrer">NHibernate</a>? I haven't used it much myself, but my experience with its Java cousin was very positive.</p>
<p>There are other alternatives such as <a href="http://www.llblgen.com/defaultgeneric.aspx" rel="nofollow noreferrer">LLBLGen</a> as ... | <p>For an MVC style ASP .Net 2.0 application you can use Castle project and ActiveRecord for data access. ActiveRecord can be used separately.</p>
<p><strong>Active Record</strong><br />
"The enterprise data mapping pattern implemented using NHibernate"<br />
<a href="http://www.castleproject.org/" rel="nofollow noref... | 48,471 |
<p>What .NET namespace or class includes both Context.Handler and Server.Transfer?</p>
<p>I think one may include both and my hunt on MSDN returned null. </p>
| <p>System.Web.</p>
<pre><code>HttpContext.Current.Handler
HttpContext.Current.Request.Server.Transfer
</code></pre>
| <blockquote>
<p>Hmmmm, I talking about them as they are implemented here:</p>
<p><a href="http://blog.benday.com/archive/2008/03/31/23176.aspx" rel="nofollow noreferrer">http://blog.benday.com/archive/2008/03/31/23176.aspx</a></p>
<p>(at least Context.Handler there)</p>
<p>I am still having trouble in ... | 6,083 |
<p>I installed TortoiseHg (Mercurial) in my Vista 64-bit and the context menu is not showing up when I right click a file or folder.
Is there any workaround for this problem?</p>
| <p>Update: TortoiseHg 0.8 (released 2009-07-01) now includes both 32 and 64 bit shell extensions in the installer, and also works with Windows 7. The workaround described below is no longer necessary.</p>
<hr>
<p>A workaround to getting the context menus in Windows Explorer is buried in the TortoiseHg development mai... | <p>According to the <a href="http://bitbucket.org/tortoisehg/stable/wiki/FAQ" rel="nofollow noreferrer">TortoiseHg FAQ</a> the context menus will work in 64-bit Vista <a href="http://bitbucket.org/tortoisehg/stable/wiki/FAQ#does-tortoisehg-work-on-vista" rel="nofollow noreferrer">if you start a 32-bit instance of explo... | 6,089 |
<p>My hosting provider (pairNetworks) has certain rules for scripts run on the server. I'm trying to compress a file for backup purposes, and would ideally like to use bzip2 to take advantage of its AWESOME compression rate. However, when trying to compress this 90 MB file, the process sometimes runs upwards of 1.5 min... | <p>nice will change the process' priority, and thus will get its CPU seconds sooner (or later), so if the rule is really about CPU seconds as you state in your question, nice will not serve you at all, it'll just be killed at a different time.</p>
<p>As for a solution, you may try splitting the file in three 30 MB pie... | <p>No, <code>nice</code> will only affect how your process is scheduled. Put simply, a process that takes 30 CPU seconds will always take 30 CPU seconds even if it's preempted for hours.</p>
<p>I always get a thrill when I load up all the cores of my machine with some hefty processing but have them all niced. I love... | 44,413 |
<p>If I'm using <code>Long uuid = UUID.randomUUID().getMostSignificantBits()</code> how likely is it to get a collision. It cuts off the least significant bits, so there is a possibility that you run into a collision, right?</p>
| <p>According to <a href="http://docs.oracle.com/javase/7/docs/api/java/util/UUID.html" rel="noreferrer">the documentation</a>, the static method <code>UUID.randomUUID()</code> generates a type 4 UUID.</p>
<p>This means that six bits are used for some type information and the remaining 122 bits are assigned randomly.</... | <p>You are better off just generating a random long value, then all the bits are random. In Java 6, new Random() uses the System.nanoTime() plus a counter as a seed.</p>
<p>There are different levels of uniqueness. </p>
<p>If you need uniqueness across many machines, you could have a central database table for alloc... | 42,142 |
<p>Can someone please provide an implementation of a C function that gets invoked to dump the current stack? It's for a x86 linux system. It can be invoked in 2 ways: explicitly by another function, or after a crash (probably as a trap/int handler). The output can be either to the screen or to a file, as indicated by... | <p>following on Adam's answer, the source code that shows how to perform the actual stack backtracing is in gnu libc's backtrace(), under /libc/debug/backtrace.c - not sure if the full link below will be accepted by stackoverflow's html filters...</p>
<p><a href="http://cvs.savannah.gnu.org/viewvc/*checkout*/libc/deb... | <p>When function calls are nested, the stack grows downwards and builds a chain of stack frames. At any given point in a program it is theoretically possible to backtrace the sequence of stack frames to the original calling point. The <code>backtrace()</code> function navigates the stack frames from the calling point ... | 20,285 |
<p>I have a very interesting problem on my LinqToSql model. On some of my tables i have a references to other tables and in LinqToSql this is represented by a EnitiyRef class, when you are trying to access the references table LinqToSql will load the reference from the database.</p>
<p>On my development machine everyt... | <p>Have you turned the context logging on and compared the results on your dev box to those on your production box?</p>
| <p>Examine DataContext lifetime. There may be stale cache at work here</p>
<p>For example: </p>
<ol>
<li>Context1 : Load Sale with ID == 1. Examine its User property and observe null User.</li>
<li>Context2: Load Sale with ID == 1. Modify User property by adding a new User. Commit.</li>
<li>Context1: Load Sale w... | 22,080 |
<p>GWT seems like a really nice technology for Java developers who don't like (or don't know) HTML/JS/CSS to build rich web interfaces. On the server-side Grails also looks really nice, it's often described as "Rails for Java developers". I've read that Grails' "convention over configuration" approach, together with th... | <p>Grails already has a gwt plugin: <a href="http://grails.org/GWT+Plugin" rel="noreferrer">check it out</a>.</p>
| <blockquote>
<p>with the benefits of dynamic languages
(Groovy) can really reduce the amount
of (boilerplate) code that needs to be
written</p>
</blockquote>
<p>That's what folks from RoR camp was preaching all the time. After some initial boom RoR projects got into inevitable trouble with bigger projects. The... | 39,879 |
<p>I've implemented a basic search for a research project. I'm trying to make the search more efficient by building a <a href="http://en.wikipedia.org/wiki/Suffix_tree" rel="noreferrer">suffix tree</a>. I'm interested in a C# implementation of the <a href="http://en.wikipedia.org/wiki/Ukkonen%27s_algorithm" rel="norefe... | <p>Hard question. Here's the closest to match I could find: <a href="http://www.codeproject.com/KB/recipes/ahocorasick.aspx" rel="noreferrer">http://www.codeproject.com/KB/recipes/ahocorasick.aspx</a>, which is an implementation of the Aho-Corasick string matching algorithm. Now, the algorithm uses a suffix-tree-like... | <p>Here is an implementation of a suffix tree that is reasonably efficient. I haven't studied Ukkonen's implementation, but the running time of this algorithm I believe is quite reasonable, approximately <code>O(N Log N)</code>. Note the number of internal nodes in the tree created is equal to the number of letters in ... | 20,642 |
<p>I am developing an application to install a large number of data files from multiple DVDs. The application will prompt the user to insert the next disk, however Windows will automatically try to open that disk either in an explorer window or ask the user what to do with the new disk.<br>
How can I intercept and can... | <p>There are two approaches that I know of. The first and simplest is to register the special Windows message "QueryCancelAutoPlay" and simply return 1 when the message is handled. This only works for the current window, and not a background application.</p>
<p>The second approach requires inserting an object that i... | <p>Alternatively, you could just programmatically save the current state of autoplay and turn it off when your program starts, then restore the original state when your program closes. This would be a lot simpler. Check out <a href="http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/93502.mspx... | 3,282 |
<p>Given a System.Timers.Timer, is there a way from the main thread to tell if the worker thread running the elapsed event code is still running?</p>
<p>In other words, how can one make sure the code running in the worker thread is not currently running before stopping the timer or the main app/service thread the time... | <p>Look up ManualResetEvent, as it is made to do specifically what you're asking for.</p>
<p>Your threads create a new reset event, and add it to an accessible queue that your main thread can use to see if any threads are still running.</p>
<pre><code>// main thread owns this
private List<ManualResetEvent> _res... | <p>For the out of the box solution, there is no way. The main reason is the thread running the TimerCallback function is in all likelihood still alive even if the code running the callback has completed. The TimerCallback is executed by a Thread out of the ThreadPool. When the task is completed the thread does not d... | 30,505 |
<p>I am trying to interpret HttpReferer strings in our server logs. It seems like there is quite a high number of empty values.</p>
<p>I am wondering how many of these empty values are due to direct hits from people entering our URL directly into a browser and how many might be due to some kind of blocking utility tha... | <p>I think a large proportion may actually be caused by ISPs' restrictions. I know my ISP (BT, in the UK) filters it out (probably at the router) which is bloody annoying at times.</p>
<p>As it turns out, the block is actually put in place by Zone Alarm, a software firewall, which is often supplied by ISPs.</p>
| <p>Some antivirus software is retarded and also started doing this for "security" reasons. </p>
<p>We had an email form that used referrer tracking to eliminate the gist of the random bot-spam an some people moaned that it didn't work. </p>
<p>Not entirely wonderful, but there are far more <em>good</em> uses of the r... | 32,147 |
<p>Currently i'm using pretty much Unix + Mysql + Perl + Apache with some javascript to make it more ajax like. and i've been looking at sites which are web 2.0 and stackoverflow and really like the simple design and the smooth flow from pages and action, etc.</p>
<p>i'm trying to decide if learning catalyst, mason an... | <p>Answers to your questions....</p>
<ol>
<li><p><em>"career development"</em> - MVC is a good programming practice so gaining knowledge and experience of it would definitely enhance your career potential.</p></li>
<li><p><em>"ease of building powerful web 2.0 website"</em> - Catalyst certainly make this a lot easier ... | <p>I agree with Dave Rolsky: calling TT "more capable" than Mason is a poor choice of words. People who like TT appear to like it because it's supposed to be "cleaner". Coming to TT from Mason, TT feels like a fairly tight straight-jacket. Hypothetically you may very well "have the full power of perl" inside of TT as... | 49,418 |
<p>I've done a good bit of research to find an upload component for .NET that I can use to upload large files, has a progress bar, and can resume the upload of large files. I've come across some components like <a href="http://ajaxuploader.com" rel="noreferrer">AjaxUploader</a>, <a href="http://krystalware.com/product... | <blockquote>
<p>1) Is it possible to resume a file upload on the client without using flash/java/Silverlight?</p>
</blockquote>
<p>No. The actual HTTP protocol itself does not support resume of partial uploads, so even if you did use flash or silverlight, you'd still need to use something else like FTP on the server... | <p>Nothing more to add about the resume problem.
I used (and keep on using) telerik radUpload and I am quite satisfied with it
(it can even be used in medium trust mode which was quite important for me). The only problem I had (and was not able to fix) is to upload files bigger than 2GB...</p>
| 36,188 |
<p>I'm using this code, to make a request to a given URL:</p>
<pre><code>private static string GetWebRequestContent(string url)
{
string sid = String.Empty;
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
req.KeepAlive = false;
using (HttpWebResponse res = (HttpWebResponse)req.GetResponse())... | <p>It works perfectly in my browser.</p>
<p>I found the solution 1 minute after i posted the question:</p>
<pre><code>ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
</code></pre>
<p>And that means the HttpWebRequest was using TLS 1.0 - I don't know, but I assume that is 40 bit DES or 56 bit DES, w... | <p>There is smothing you might want to consider with the load balancer. The ones we use forward the HTTPS secure traffic to the servers behind it on an insecure HTTP connection. The connection between the load balancer and the browser is still secure but there is no need for the over head of the secure protocol between... | 28,333 |
<p>I found a good description on <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" rel="nofollow noreferrer">wikipedia</a> with a few reference links, but there may be better ones, please help me to find these!</p>
<p>To be clear, I am not looking for implementation for any language specific imple... | <p><a href="http://www.25hoursaday.com/weblog/2007/11/19/GuidelinesForBuildingRESTfulWebServices.aspx" rel="nofollow noreferrer">Guidelines for Building RESTful Web Services</a> has all the info on the resources you need.</p>
<p>This is another useful <a href="http://www.25hoursaday.com/weblog/2008/08/17/ExplainingRES... | <p>I read <a href="http://oreilly.com/catalog/9780596529260/" rel="nofollow noreferrer">RESTful web services by O'Reilly</a> and really enjoyed it.</p>
| 31,942 |
<p>The following code is causing an intermittent crash on a Vista machine.</p>
<pre><code>using (SoundPlayer myPlayer = new SoundPlayer(Properties.Resources.BEEPPURE))
myPlayer.Play();
</code></pre>
<p>I highly suspect it is this code because the program crashes mid-beep or just before the beep is played every t... | <p>Actually, the above code (that is, new SoundPlayer(BEEPPURE)).Play(); was crashing for me.</p>
<p>This article explains why, and provides an alternative to SoundPlayer that works flawlessly:</p>
<p><a href="http://www.codeproject.com/KB/audio-video/soundplayerbug.aspx?msg=2862832#xx2862832xx" rel="nofollow norefer... | <p>The solution is to use Microsoft.VisualBasic.Devices, which does not suffer from this bug. Since it's Vista only, and the Event Viewer even managed to fail midway through logging the crash (process id 0x**%9** should have a hex value there instead), I point the blame at the new sound code in Vista.</p>
<p>BTW, con... | 10,843 |
<p>Can you recommend an open source library (C or C++) to convert MS Office files into a set of images?</p>
<p>I am evaluating ImageMagick and while it does support PDF files, it does not work with MS Office files.</p>
| <p>This library is quite popular and used by abiword (gnome) and kword (kde): <a href="http://wvware.sourceforge.net/" rel="nofollow noreferrer">wvWare</a></p>
| <p>Hm I've seen that OpenOffice does a good job on "translating" Word to whatever, so how about installing OpenOffice and maybe using it's UNO model from C++ to solve that problem?</p>
| 37,898 |
<p>Every Christmas we draw names for gift exchanges in my family. This usually involves mulitple redraws until no one has pulled their spouse. So this year I coded up my own name drawing app that takes in a bunch of names, a bunch of disallowed pairings, and sends off an email to everyone with their chosen giftee.</p... | <p>Just make a graph with edges connecting two people if they are allowed to share gifts and then use a perfect matching algorithm. (Look for "Paths, Trees, and Flowers" for the (clever) algorithm)</p>
| <p>Python solution here.</p>
<p>Given a sequence of <code>(person, tags)</code>, where tags is itself a (possibly empty) sequence of strings, my algorithm suggests a chain of persons where each person gives a present to the next in the chain (the last person obviously is paired with the first one).</p>
<p>The tags ex... | 34,468 |
<p>Does anyone know how to disable authenticode signature verification in a .NET executable (to avoid slow startup) without using an application config file? In other words, do this:</p>
<pre><code><configuration>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>... | <p>If you are allowed to modify the Main() method, then what you could do is the following in your Main:</p>
<ol>
<li>Create an application config file in memory with generatePublisherEvidence</li>
<li>Create a new application domain using the newly created application config file</li>
<li>Run the original Main in the... | <p>Well, according to MSDN the element generatePublishersEvidence can only be used in a configuration file:</p>
<blockquote>
<p><strong>Configuration File</strong></p>
<p>This element can be used only in the
application configuration file.</p>
</blockquote>
<p>See <a href="http://msdn.microsoft.com/en-us/lib... | 38,061 |
<p>I'm a 3D printing newbie, and I bought some Hatchbox PLA to start with since it is recommended by the community it seems. </p>
<p>Is there really a steep quality drop off if you go for brands that are 50% less than Hatchbox? What does that quality drop off look like?</p>
| <p>In addition to @TecTec3's answer:</p>
<h3>Parameters that define filament quality:</h3>
<ul>
<li>Diameter variance: If there is too much fluctuation in diameter, the filament might get stuck.</li>
<li>Material Quality: I had really expensive filament that was brittle and did tend to snap when it was extruded. Other ... | <p>There is no massive difference in print quality of PLA filaments unless you start going under 10 dollars US for a 1 kilo spool. The filament that I use is yoyi PLA that can be found on Amazon for about 20 bucks, this filament works really nice with my printer and it is fairly cheap. Just make sure you never use the... | 695 |
<p>We currently have a company email server with Exchange, and a bulk email processing server that is using IIS SMTP. We are upgrading to a 3rd party MTA (zrinity xms) for bulk sending. I need to be able to keep sending the messages already queued for IIS when we switch to the 3rd party sofware. Can I simply move the I... | <p>You should be able to move the *.eml files to the Exchange server's <strong>pickup directory</strong>. Or set the IIS SMTP service to <strong>smart host</strong> to the new MTA, assuming they (the 3rd party) allow SMTP relay from your IP address.</p>
| <p>Moving the files will work. However, any email with a BCC line in the header will get sent out with the BCC intact. Some clients, such as gmail, will display the information to the recipient, thus breaking the whole point of BCC.</p>
<p>This happens when copying EML files to MS-SMTP (which Exchange also uses) becau... | 12,828 |
<p>The main focus of the package is developer tools but there is also one component (a DLL) that some small number of developers would like to redistribute with their own application. This is managed code running under .NET 3.5.</p>
| <p>The easiest way to discourage others from reusing your library is to mark all classes "internal" and mark the library assembly with the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx" rel="nofollow noreferrer">InternalsVisibleTo custom attribute</a>.... | <p>Having a serial number keyed to the registrant's details (eg email) is fairly simple. That way he knows there is a chance you could trace any copy made from his back to him.</p>
| 24,379 |
<p>This is really the first thing that I have written in python. I come from Java background. I don't want to just learn how to program java code with Python syntax. I want to learn how to program in a pythonic paradigm.</p>
<p>Could you guys please comment on how I can make the following code more pythonic?</p>
<... | <p>There is an excellent primer by David Goodger called "Code Like a Pythonista" <a href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html" rel="nofollow noreferrer">here</a>. A couple of things from that text re naming (quoting):</p>
<ul>
<li><p><code>joined_lower</code> for functions, methods,
... | <p>Using recursion (where not necessary) is not pythonic. Python doesn't have tail recursion elimination and <em>flat is better than nested</em>.</p>
<p>When in doubt, try <code>import this</code></p>
<p><strong>update</strong>: by popular request, here goes the iterative factorization (sigh):</p>
<pre><code>"""retu... | 16,328 |
<p>i have a control that is organized like this</p>
<p><img src="https://dl-web.getdropbox.com/get/jsstructure.GIF?w=faef1ed3" alt="alt text"></p>
<p>and i want to have the javascript registered on the calling master pages, etc, so that anywhere this control folder is dropped and then registered, it will know how to ... | <p>You can use a helper class with static method:</p>
<pre><code>public static class PageHelper {
public static void RegisterClientScriptIfNeeded( Page page, string key, string url ) {
if( false == page.IsClientScriptBlockRegistered( key )) {
page.ClientScript.RegisterClientScriptInclude( key ,... | <p>I can't see the image you posted.</p>
<p>You could also use Context.Items to ensure that the item is only added once per request and render the javascript through the control itself, although I think the registerclient script is great too.</p>
<pre><code> protected override void Render(HtmlTextWriter writer)
... | 15,567 |
<p>I've been printing successfully on my CR-10 for the past year now. I've had issues now and then but have been able to look around the internet and solve them. I've been using some Flashforge white PLA with great results.</p>
<p>Example:
<a href="https://i.stack.imgur.com/JlMqb.jpg" rel="noreferrer"><img src="https:... | <p>Not all filaments are created equal. Even with the very same manufacturer, the addition of colorful pigments can change the needed printing temperature a lot! I have had a white china PLA that was giving ok quality at 200°C, but the same brand's clear PLA only took 195°C to print. My white Kaisertech prints better a... | <p>Not all filaments are created equal. Even with the very same manufacturer, the addition of colorful pigments can change the needed printing temperature a lot! I have had a white china PLA that was giving ok quality at 200°C, but the same brand's clear PLA only took 195°C to print. My white Kaisertech prints better a... | 1,006 |
<p>In SQL Server, why is this:</p>
<pre><code>[dbo].[table_name]
</code></pre>
<p>preferable to this:</p>
<pre><code>dbo.table_name
</code></pre>
<p>And along those lines, why even list the dbo at all if there's only one schema?</p>
| <p>It's just in case you have a keyword as a tablename like [user]</p>
| <p>Doesn't this allow you to have whatever 'bad' items you desire in there?<br>
Keywords, spaces, etc...</p>
| 29,713 |
<p>I have written a java annotation that looks like this:</p>
<pre><code>@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD) // can I further limit this to only fields of type DomainObject?
public @interface Owns {
}
</code></pre>
<p>After briefly looking around I couldn't see if there was a way to furthe... | <p>You could emit an error in an <a href="http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Processor.html" rel="noreferrer">annotation processor</a> (you'll have to use a <a href="http://java.sun.com/j2se/1.5.0/docs/guide/apt/GettingStarted.html" rel="noreferrer">private API</a> if you want Java 5 supp... | <p>I believe that this is not enforcable at compile-time - If you want to ensure that it is not on any inappropriate fields, you would have to check at run/load-time. </p>
| 49,593 |
<p>I'm at my wit's end here. I'm trying to use an auto-complete extender from the asp.net ajax extensions toolkit, which is filled from a bog-standard webservice. The application is a .net 3.5 web site, hosting the webservice in a subdirectory (real, not virtual).</p>
<p>Whenever I try to post to the webservice I get ... | <p>Ok, found the issue with the help of a colleague. Seems the Ektron CMS added a mapping in IIS -- it mapped * to aspnet_isapi.dll. That overrode all the other mappings. I deleted that, and now things work.</p>
| <p>Are you rewriting URLs? You need to exclude your web services from rewrites.</p>
| 15,644 |
<p>If I escape some code because I want it to display as the actual code in html (eg for an example code snippet), save it to the database and then pull it back to the editor (an html page), it is displayed as html, as opposed to the escaped text.</p>
<p>My problem arises when I include a textarea tag in the text beca... | <p>@Bob: <a href="http://php.net/htmlentities" rel="nofollow noreferrer">htmlentities()</a> is not the same as <a href="http://php.net/htmlspecialchars" rel="nofollow noreferrer">htmlspecialchars()</a></p>
<p>htmlentities() will convert every character that has an ASCII code to that code.
htmlspecialchars() will only ... | <p>Most web based languages will have some library function for escaping HTML-interpreted characters, so check the documentation for the language you're using.</p>
<p>Like Darryl said, html_entities() (which is an alias for htmlspecialchars()) will do the trick in PHP.</p>
| 28,798 |
<p>I have the following code:</p>
<p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22615" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22615</a></p>
<p>Which is called by the javascript mentioned in <a href="https://stackoverflow.com/questions/355865/javascript-function-not... | <p>I think you want to replace this (line 36):</p>
<pre><code>$rows = getRowsByArticleSearch($searchString, $table);
</code></pre>
<p>with this:</p>
<pre><code>$rows = getRowsByArticleSearch($query, $table);
</code></pre>
<p>And for security concerns, the least you should do is the mysql_real_escape_string stuff fr... | <p>In the code you linked to, I do not see where $searchString is declared? In the aforementioned PHP, I see these two separate sections:</p>
<pre><code>$query ='';
if (isset($_GET["query"]))
$query = $_GET["query"];
</code></pre>
<p>and the code you are executing later on down the page is</p>
<pre><code>$table = 'A... | 46,392 |
<p>What are the possibilities of a programmer to handle data that are rarely used but cannot be simply deleted because at least reporting still requires it?</p>
<p>Some examples I am thinking of:</p>
<ul>
<li>Discountinued funding types of older years of a university</li>
<li>Unused currencies (e.g. Italian lira)</li... | <p>With old data not used in most queries the best solution is to partition tables by the the key which differentiates stale from current data (such as date, currency_id or things like that). You can then put the stale data in separate tables, databases or even servers (depending on the configuration you have running).... | <p>One solution could be (assuming records referencing obsolete data are the oldest): <strong>archive</strong> those records and remove old reference data.</p>
| 23,727 |
<p>I know we are <em>really</em> behind the times here, but we are just about to upgrade from .NET 1.1 to .NET 2.0. </p>
<p>Thank you for your sympathy. </p>
<p>Anyhow, are there any gotchas we should look out for?<br>
Do you have any general advice before we jump in? </p>
<p>Please do not post telling me to go ... | <p>Here is my recommendation before upgrading:</p>
<ul>
<li>If you are used to use Visual Studio 2003, you will need to go for VS2005. You will have to convert the old solutions and projects so that it will be compatible with VS2005. Make sure to have a backup of the project you're going to convert so that you can rol... | <p>One gotcha is home-grown 1.1 implementations of .NET 2.0 stuff (that was missing in 1.1) like RegistryHandler and so forth. Sometimes your newly-ported 2.0 code will look like it's properly using a 2.0 class when it's really using the home-grown version.</p>
| 34,650 |
<p>I have a function that takes a struct, and I'm trying to store its variables in array:</p>
<pre><code>int detect_prm(Param prm) {
int prm_arr[] = {prm.field1, prm.field2, prm.field3};
return 0;
}
</code></pre>
<p>But with <code>gcc -Wall -ansi -pedantic-errors -Werror</code> I get the following error:</p>
<b... | <p>This is illegal in C. Initializer lists must be constant compile time expressions. Do the following instead:</p>
<pre><code>int prm_arr[3];
prm_arr[0] = prm.field1;
prm_arr[1] = prm.field2;
prm_arr[2] = prm.field3;
</code></pre>
| <p>Mike's answer is absolutely right.</p>
<p>However, if you're able to use the GNU C extensions, or to use the newer and better C99 standard instead (use the <code>--std=c99</code> option), then initializers such as this are perfectly legal. The C99 standard has been out for, well, 9 years, and most C compilers supp... | 19,452 |
<p>VB6 IDE can get into a state when the Make XXXX menu option under the File Menu is disabled.</p>
| <p>Found my own solution that did not require re-installing VB6.
In VB6, Right click on the toolbar, goto Customize and reset toolbars.
Aftewards, the Make XXXX menu under the File menu is re-enabled!</p>
| <p>In VB6 IDE, go to menu View->Toolbars->Customize->Reset.</p>
| 48,136 |
<p>Something to take an XML schema and let you add/edit data but not change the XML structure, preferably installed on a server. basically a UI to edit xml documents as a web app. Someone has got to have done this already right?</p>
| <p><a href="http://xopus.com" rel="nofollow noreferrer">Xopus</a> is a commercial XML editor designed specifically to be used by non-technical people. Xopus is browser based and can be installed on any webserver. Xopus keeps the XML document 100% valid at all times using XML Schema and has a WYSIWYG view using XSLT. </... | <p>Check out microsoft for an <a href="http://www.microsoft.com/downloads/details.aspx?familyid=72d6aa49-787d-4118-ba5f-4f30fe913628&displaylang=en" rel="nofollow noreferrer">XML Notepad 2007</a>. I'm not to fond of it, since it really treats xml as a tree as opposed to plain text, but that is what you want, right?... | 9,179 |
<p>In GWT, what is the best way to convert a JavaScriptObject overlay type into a JSON string?</p>
<p>I currently have</p>
<pre><code>public final String toJSON() {
return new JSONObject(this).toString();
}
</code></pre>
<p>Which seems to work fine. I would like to know if there are any better approaches.<... | <p>I've never actually tried that (only consumed JSON so far, never needed to produce it). This seems to be native browser/javascript functionality.</p>
<p>You <em>could</em> write it as:</p>
<pre><code>public native String toJSON() /*-{
return this.toString();
}-*/;
</code></pre>
<p>They essentially just do the e... | <p>we have a JSNI method like that, but use douglas crockfords JSON library (in case the browser doesn't supply one natively):</p>
<p><a href="https://github.com/douglascrockford/JSON-js" rel="nofollow">https://github.com/douglascrockford/JSON-js</a></p>
<pre><code>public native String stringify() /*-{
return JSON.... | 32,290 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.