instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>How do I go about using HTTPS for some of the pages in my ASP.NET MVC based site?</p>
<p>Steve Sanderson has a pretty good tutorial on how to do this in a DRY way on Preview 4 at:</p>
<p><a href="http://blog.codeville.net/2008/08/05/adding-httpsssl-support-to-aspnet-mvc-routing/" rel="noreferrer">http://blog.codev... | <p>If you are using <a href="http://blogs.teamb.com/craigstuntz/2009/10/05/38476/" rel="noreferrer">ASP.NET MVC 2 Preview 2 or higher</a>, you can now simply use:</p>
<pre><code>[RequireHttps]
public ActionResult Login()
{
return View();
}
</code></pre>
<p>Though, the order parameter is worth noting, as <a href="h... | <p><strong>MVC 6</strong> (ASP.NET Core 1.0) is working slightly different with Startup.cs.</p>
<p>To use RequireHttpsAttribute (as mentioned in <a href="https://stackoverflow.com/a/2359061/1095493">answer</a> by Amadiere) on all pages, you could add this in Startup.cs instead of using attribute style on each controll... | 18,966 |
<p>I'm trying to determine a fast way of storing a set of objects, each of which have an x and y coordinate value, such that I can quickly retrieve all objects within a certain rectangle or circle.
For small sets of objects (~100) the naive approach of simply storing them in a list, and iterating through it, is relativ... | <p><a href="http://en.wikipedia.org/wiki/Quadtree" rel="noreferrer">Quadtrees</a> seem to solve the specific problem I asked. <a href="http://en.wikipedia.org/wiki/Kd-tree" rel="noreferrer">Kd-Trees</a> are a more general form, for any number of dimensions, rather than just two. </p>
<p><a href="http://en.wikipedia.... | <p>You could put all the x cords in a map, and the y cords in another map, and have the map values point to the object.</p>
<pre><code> TreeMap<Integer, TreeMap<Integer, Point>> xMap = new TreeMap<Integer, TreeMap<Integer, Point>>();
for (int x = 1; x < 100; x += 2)
... | 16,043 |
<p><strong>What is the best way to share Delphi source files among projects?</strong></p>
<p><em>Clarification: We want to use a single source file in multiple Delphi projects. We've been using our SCM tool to put the same file into multiple folders, but this is not a super-elegant experience and we are also consider... | <p><strong>Use Source Control System's File Sharing Feature</strong></p>
<ul>
<li>Pro: Fast and easy to set up, if the SCM system supports it.</li>
<li>Pro/Con: Each consumer project can independently affect compile-time.</li>
<li>Con: There is no official location, in the local working copy of sources.
<ul>
<li>This... | <p><strong>Copy-on-compile</strong></p>
<ul>
<li>Pro: File sharing can be managed file-by-file.</li>
<li>Pro/Con: Each consumer project can independently affect compile-time.</li>
<li>Con: Debugger will link to the temporary copy, not the official version.
<ul>
<li>TODO: See whether there is some way to change this.<... | 32,448 |
<p>I have a GridView with a TemplateField with a checkbox. My goal is to capture the onclick event using autopostback and setting a database flag. My only problem is that the event fire's twice. The first time The Checkbox (In the sender parameter) holds the clicked value so I set it based on the click. The second time... | <p>Do you set the checked status of the checkbox to false at all in your page load event?</p>
| <p>You want to capture the even of the GridView; identify the command (sender) that is causing the postback, and then you can execute your DB update.</p>
| 49,731 |
<p>I would like to be able to trap <kbd>Ctrl</kbd>+<kbd>C</kbd> in a C# console application so that I can carry out some cleanups before exiting. What is the best way of doing this?</p>
| <p>See MSDN:</p>
<p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.console.cancelkeypress?view=net-6.0" rel="nofollow noreferrer">Console.CancelKeyPress Event</a></p>
<p>Article with code samples:</p>
<p><a href="https://web.archive.org/web/20200810221940/http://geekswithblogs.net/mrnat/archive/2004/09/23... | <p><code>Console.TreatControlCAsInput = true;</code> has worked for me.</p>
| 21,432 |
<p>I need a list of integers from 1 to x where x is set by the user. I could build it with a for loop eg assuming x is an integer set previously:</p>
<pre><code>List<int> iList = new List<int>();
for (int i = 1; i <= x; i++)
{
iList.Add(i);
}
</code></pre>
<p>This seems dumb, surely there's a more... | <p>If you're using .Net 3.5, <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.range.aspx" rel="noreferrer">Enumerable.Range</a> is what you need.</p>
<blockquote>
<p>Generates a sequence of integral
numbers within a specified range.</p>
</blockquote>
| <p>Here is a short method that returns a List of integers.</p>
<pre><code> public static List<int> MakeSequence(int startingValue, int sequenceLength)
{
return Enumerable.Range(startingValue, sequenceLength).ToList<int>();
}
</code></pre>
| 7,170 |
<p>I'm planning to propose to my (very small) company that we buy a computer to run continous integration on. If they say yes, the task of actually buying the machine will probably fall on me, so my question is:</p>
<p>What do I look for in a computer that will be used for continuous integration for a very small (3 pe... | <p>You're not really going to need that powerful of a machine. If you are running tests or other metrics, processing ability is probably your primary concern but really you could run that on an old pentium 1 and it would probably work. </p>
<p>Your constraints are going to be your operating environment. If you are run... | <p>Unless the app is huge I'd just get a dual core box with about 4 gigs of ram and probably 2 reasonably fast SATA disks set in RAID 0. 500 Gigs maybe?</p>
<p>If you want to be really safe with it, get two 70ish gig drives for RAID 0 for the OS partition and then 3 140+ gig drives in RAID 5 for the data.</p>
| 16,992 |
<p>How do I get the path of the directory in which a <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29" rel="noreferrer">Bash</a> script is located, <em>inside</em> that script?</p>
<p>I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where th... | <pre><code>#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
</code></pre>
<p>is a useful one-liner which will give you the full directory name of the script no matter where it is being called from.</p>
<p>It will work as long as the ... | <p>I want to make sure that the script is running in its directory. So</p>
<pre><code>cd $(dirname $(which $0) )
</code></pre>
<p>After this, if you really want to know where the you are running then run the command below.</p>
<pre><code>DIR=$(/usr/bin/pwd)
</code></pre>
| 8,466 |
<h2>Background</h2>
<p>There are several different <a href="http://msdn.microsoft.com/en-us/library/958x11bc.aspx" rel="noreferrer">debug flags</a> you can use with the Visual Studio C++ compiler. They are:</p>
<ul>
<li><strong>(none)</strong>
<ul>
<li>Create no debugging information</li>
<li>Faster compilation time... | <p>Codeview is a much older debugging format that was introduced with Microsoft's old standalone debugger back in the "Microsoft C Compiler" days of the mid-1980s. It takes up more space on disk and it takes longer for the debugger to parse, and it's a major pain to process during linking. We generated it from our co... | <p>There is one more disadvantage for /Z7:
It's not compatible with incremental linking, which may alone be a reason to avoid it.
Link: <a href="http://msdn.microsoft.com/en-us/library/4khtbfyf%28v=vs.100%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/4khtbfyf%28v=vs.100%29.aspx</a></p>
<p>By the way:... | 36,139 |
<p>I have two DataTables, <code>A</code> and <code>B</code>, produced from CSV files. I need to be able to check which rows exist in <code>B</code> that do not exist in <code>A</code>.</p>
<p>Is there a way to do some sort of query to show the different rows or would I have to iterate through each row on each DataTab... | <blockquote>
<p>would I have to iterate through each row on each DataTable to check if they are the same.</p>
</blockquote>
<p>Seeing as you've loaded the data from a CSV file, you're not going to have any indexes or anything, so at some point, something is going to have to iterate through every row, whether it be y... | <pre><code> try
{
if (ds.Tables[0].Columns.Count == ds1.Tables[0].Columns.Count)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
{
if (ds.Ta... | 19,841 |
<p>I'm building a web 2.0 site with tagging functionality and wanted to get a sense from anyone with experience how long (in sec) the system can take to a) show a new tag on a given record and b) index the tag for search. For example, does a newly added tag have to be available for search in 1 second but show on the u... | <p>I think this is really dependent on the type of site, size of site, overall complexity and user expectations.</p>
<p>You will have to balance everything to meet your needs, I don't believe there there is any de-facto standard that says it must be X seconds.</p>
<p>Responsiveness is important, but certain audiences... | <p>It depends on how you handle changes. This should be consistent.</p>
<p>But anything that suffers this kind of delay should be detectable in the UI: a tag added but not yet available should display in a way that identifies it as added but not yet available, so the user doesn't believe they've encountered an error w... | 22,792 |
<p>In C++/CLI , you can use native types in a managed class by it is not allowed to hold a member of a native class in a managed class : you need to use pointers in that case.</p>
<p>Here is an example :</p>
<pre><code>class NativeClass
{
....
};
public ref class ManagedClass
{
private:
NativeClass mNativeClass; ... | <p>I found the answer on <a href="http://www.codeproject.com" rel="nofollow noreferrer">codeproject</a> :</p>
<p>Nishant Sivakumar posted an article about this at <a href="http://www.codeproject.com/KB/mcpp/CAutoNativePtr.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/mcpp/CAutoNativePtr.aspx</a></p>
<... | <p><a href="http://msdn.microsoft.com/en-us/library/ms379600.aspx" rel="nofollow noreferrer">STL.Net is documented here</a>. I don't know what state it is in or what use it might be for you.</p>
| 21,250 |
<p>We are developing a WPF application that uses the System.AddIn framework to host add-ins that display additional WPF content. Everything seems to be working fine, but overnight, the application threw the following NullReferenceException:</p>
<pre>
Message: Error : Object reference not set to an instance of an obje... | <p>It's going to sound dumb, but ...uh... "layout your cell before you exit heightForRowAtIndexPath" ;)</p>
<p>Seriously, though -- the OS only ever calls this if it's going to be needed (as in: it's about to create the cell & display it on screen), so laying it out & getting ready to display is not wasted ef... | <p>If you look at SMS.app as example, Apple saves the row height of the cell in the SMS.app sqlite database.</p>
| 34,316 |
<p>I recently upgraded VS 2005 to VS 2008. Unfortunately I have a very basic problem: In the codeview window my vertical scrollbar does not look like a normal, traditional scrollbar, but like some kind of code-preview window. It is roundabout four times wider than a normal scrollbar.
The problem is that my ReSharper (4... | <p>Are you using the <a href="http://www.hanselman.com/blog/IntroducingRockScroll.aspx" rel="nofollow noreferrer">RockScroll</a> add-in? If so, disable it.
<img src="https://www.hanselman.com/blog/content/binary/WindowsLiveWriter/IntroducingRockScroll_C29C/RockScroll_5.png" alt="alt text"></p>
| <p>You have RockScroll installed. - try updating RockScroll</p>
<p><a href="http://www.hanselman.com/blog/IntroducingRockScroll.aspx" rel="nofollow noreferrer">http://www.hanselman.com/blog/IntroducingRockScroll.aspx</a></p>
<p>if not just remove it</p>
<p>Scott does note that RockScroll is a Works on my Machine rel... | 44,254 |
<p>Have you ever seen any of there error messages?</p>
<blockquote>
<p>-- SQL Server 2000</p>
<p>Could not allocate ancillary table for view or function resolution.<br />
The maximum number of tables in a query (256) was exceeded.</p>
<p>-- SQL Server 2005</p>
<p>Too many table names in the query. The maximum allowable... | <p>For SQL Server 2005, I'd recommend using table variables and partially building the data as you go. </p>
<p>To do this, create a table variable that represents your final result set you want to send to the user.</p>
<p>Then find your primary table (say the orders table in your example above) and pull that data, pl... | <p>I'd like to see that query, but I imagine it's some problem with some sort of iterator, and while I can't think of any situations where its possible, I bet it's from a bad while/case/cursor or a ton of poorly implemented views.</p>
| 2,453 |
<p>I am looking to set the result action from a failed IAuthorizationFilter. However I am unsure how to create an ActionResult from inside the Filter. The controller doesn't seem to be accible from inside the filter so my usual View("SomeView") isn't working. Is there a way to get the controler or else another way o... | <p>You can instantiate the appropriate ActionResult directly, then set it on the context. For example:</p>
<pre><code>public void OnAuthorization(AuthorizationContext context)
{
if (!context.HttpContext.User.Identity.IsAuthenticated)
{
context.Result = new ViewResult { ViewName = "Whatever" };
}
}
... | <p>You can instantiate the appropriate ActionResult directly, then set it on the context. For example:</p>
<pre><code>public void OnAuthorization(AuthorizationContext context)
{
if (!context.HttpContext.User.Identity.IsAuthenticated)
{
context.Result = new ViewResult { ViewName = "Whatever" };
}
}
... | 13,564 |
<p>Is there any library function for this purpose, so I don't do it by hand and risk ending in TDWTF?</p>
<pre><code>echo ceil(31497230840470473074370324734723042.6);
// Expected result
31497230840470473074370324734723043
// Prints
<garbage>
</code></pre>
| <p>This will work for you:</p>
<pre><code>$x = '31497230840470473074370324734723042.9';
bcscale(100);
var_dump(bcFloor($x));
var_dump(bcCeil($x));
var_dump(bcRound($x));
function bcFloor($x)
{
$result = bcmul($x, '1', 0);
if ((bccomp($result, '0', 0) == -1) && bccomp($x, $result, 1))
$result ... | <p>OK, for my <a href="https://github.com/phpexpertsinc/MoneyType" rel="nofollow noreferrer"><strong>high-precision Money library</strong></a>, which is currently on hundreds of production sites, I had to completely rewrite this bcround functionality. Nothing I found on the entire Internet was up to code.</p>
<p>Here'... | 28,599 |
<p>Using Prototype 1.6's "new Element(...)" I am trying to create a <table> element with both a <thead> and <tbody> but nothing happens in IE6.</p>
<pre><code>var tableProto = new Element('table').update('<thead><tr><th>Situation Task</th><th>Action</th><th>R... | <p>As it turns out, there's nothing wrong with the example code I provided in the question--it works in IE6 just fine. The issue I was facing is that I was also specifying a class for the <table> element in the constructor incorrectly, but omitted that from my example.</p>
<p>The "real" code was as follows, and ... | <p>If prototypes' .update() method internally tries to set the .innerHTML it will fail in IE. In IE, <strong>the .innerHTML of a table element is readonly</strong>.</p>
<p>Source:</p>
<p><a href="http://webbugtrack.blogspot.com/2007/12/bug-210-no-innerhtml-support-on-tables.html" rel="nofollow noreferrer">http://web... | 15,894 |
<p>I want to use the Web Browser control within an mono application, but when I do get the error "libgluezilla not found. To have webbrowser support, you need libgluezilla installed." Installing the Intrepid Deb causes any application that references the web browser control to crash on startup with : 'Thread (nil) may... | <pre><code>apt-cache search libgluezilla
libmono-mozilla0.1-cil - Mono Mozilla library
</code></pre>
<p>From the package description: </p>
<pre><code>Description: Mono Mozilla library
Mono is a platform for running and developing applications based on the
ECMA/ISO Standards. Mono is an open source effort led by Nov... | <p>here's a link to it on the ubuntu site:</p>
<p><a href="http://packages.ubuntu.com/intrepid/libgluezilla" rel="nofollow noreferrer">http://packages.ubuntu.com/intrepid/libgluezilla</a></p>
<p>there is a download section at the bottom for a deb package</p>
| 6,387 |
<p>This is the error, it's basically a security warning</p>
<p><a href="http://img357.imageshack.us/img357/7992/visualstudiowarninggr4.jpg" rel="nofollow noreferrer">Warning message http://img357.imageshack.us/img357/7992/visualstudiowarninggr4.jpg</a></p>
<p>(And here's the text grabbed off the dialog box)
Security ... | <p>After playing around a bit (I'm using Windows XP), I found that VS resets the All Users Startup directory to C:\Documents and Settings\All Users\Start Menu\Programs\Startup. If this directory doesn't exist, it is reset to '' in the registry, and the error is displayed. Adding this directory corrected the issue. I've... | <p>The following does the trick on XP. On this dialog:
Select "Load project normally" radio button.
Uncheck "Ask me for every project in this solution" checkbox.
Click OK.</p>
| 30,157 |
<p>I need to build a prototype for an intranet website, and I want to focus on usability (layout, navigability, etc) and leave the theme for later (I have very bad taste, so this will probably be done by someone else)</p>
<p>I know about ASP.NET's capability of switching themes instantly, but how do I have to design t... | <p>If you're planning on using <a href="http://msdn.microsoft.com/en-us/library/ykzx33wh.aspx" rel="nofollow noreferrer">ASP.NET Themes</a>, then you can design all of the controls generically and add Skins later on. Depending on the complexity of the design (meaning how many different styles you have for textboxes or... | <p>just wrap your controls in divs. will make layout/style much easier in the end</p>
| 16,400 |
<p>I am investigating GDI leaks issue in one of our smart-client application.
I am looking for a tool (like <strong>tasklist</strong>) to get the GDI objects associated to a process. I can see the GDI objects in taskmanager, But my requirement to capture it periodically somewhere. For example in a text file.</p>
| <p>It should be quite straightforward to write a program to periodically log the number of GDI handles in use by a process, using the <a href="http://msdn.microsoft.com/en-us/library/ms683192.aspx" rel="noreferrer">GetGuiResources</a> API function.</p>
| <p>Use <a href="http://www.nirsoft.net/utils/gdi_handles.html" rel="nofollow noreferrer">GDIView</a>, a free tool from NirSoft.</p>
<p>Their description:</p>
<blockquote>
<p>GDIView is a unique tool that displays the list of GDI handles (brushes, pens, fonts, bitmaps, and others) opened by every process. It display... | 31,295 |
<p>Marked a javascript file as "Embedded resource"<br />
Added WebResource attribute to my AssemblyInfo class<br /><br />
Now i'm trying to output the embedded javascript to my master page. All I'm getting is a "Web Resource not found" from the web resource url.</p>
<p><br />Project Assembly Name:<br /></p>
<pre><cod... | <p>Instead of <code>this.GetType()</code>, get a type from the assembly that contains the resource.. ie:</p>
<pre><code>typeof(Company.Product.Web.Library.Class1)
</code></pre>
<p>Does that work? </p>
| <p>The answer to your question completely depends on where you have this file in your actual project, and what the default namespace is. As Chris mentioned, the path you provide to the methods that register the script need the right path to locate the embedded resource. You don't just match the string you specify in yo... | 41,459 |
<p>Is it possible with Axis2 and Eclipse to generate a Web Service client and have it use java types that you already have in packages instead of creating it's own types. Reason being of course if I have type A already created and it creates it's own Type A I can't just assign variable of type A to variable of type B.... | <p>If you really want to reuse existing classes, you can call the Axis2 API directly without generating a client using wsdl2java. Below is some relatively simple code to call a web service. You just need to fill in the web service endpoint, method QName, expected return Class(es), and arguments to the service. You c... | <p>pretty much most java webservices projects go through this. I don't know if the .NET/C# world have a more elegant solution. </p>
<p>It makes sense, as Mike mentioned, to use BeanUtils.copyProperties.</p>
<p>BR,<BR>
~A</p>
| 25,145 |
<p>I have a very simple html page here:</p>
<p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22407" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22407</a></p>
<p>And I have 4 layers on the page. The reason for this is it is the framework oif a much more complicated site, I ... | <p>Tables are for tabular data (think Excel). If you have a grid of data to display use a table. When it comes to page lyouts, use CSS positioning.</p>
<p>Also, obsessive DIV use isn't the best way to use CSS. Getting into the habit of wrapping everything up in a DIV is a practice known as "div mania" and you can G... | <p>Well, first off, when setting a background image, it won't hide the text within the DIV, no matter how high you set the Z-Index. It just doesn't work. One solution could be to wrap the inner text in a span, and hide the span when you want the background image of the div to show. But, from your question, you didn't ... | 43,306 |
<p>While right clicking on the reference in the solution explorer "add webreference is missing" Why it was missing in my machine?</p>
| <p>Try "Add Service Reference" -> Advanced -> Add Web Reference</p>
| <p>Another way to add the web reference is to click on the Project in the Solution Explorer then go to the "Project" menu and then select "Add Web Reference".</p>
| 39,707 |
<p>I have the following route defined</p>
<pre><code> routes.MapRoute(
"ItemName",
"{controller}/{action}/{projectName}/{name}",
new { controller = "Home", action = "Index", name = "", projectName = "" }
);
</code></pre>
<p>This route actually works, so if I ... | <p>When constructing and matching routes in ASP.NET routing (which is what ASP.NET MVC uses), the first appropriate match is used, not the greediest, and order is important.</p>
<p>So if you have two routes:</p>
<pre><code>"{controller}/{action}/{id}"
"{controller}/{action}/{projectName}/{name}"
</code></pre>
<p>in ... | <p>You can try </p>
<pre><code>Html.RouteLink("Edit","ItemName", new {name=m.name, projectName=m.Project.title});
</code></pre>
| 41,889 |
<p>I have a bit of code that looks like this:</p>
<pre><code>text = reg.Replace(text, new MatchEvaluator(MatchEvalStuff));
</code></pre>
<p>I need to pass in a 2nd parameter like this:</p>
<pre><code>text = reg.Replace(text, new MatchEvaluator(MatchEvalStuff, otherData));
</code></pre>
<p>Is this possible, and what... | <p>MatchEvaluator is a delegate so you can't change its signature. You can create a delegate that calls a method with an additional parameter. This is pretty easy to do with lambda expressions:</p>
<pre><code>text = reg.Replace(text, match => MatchEvalStuff(match, otherData));
</code></pre>
| <p>MatchEvaluator is a delegate so you can't change its signature. You can create a delegate that calls a method with an additional parameter. This is pretty easy to do with lambda expressions:</p>
<pre><code>text = reg.Replace(text, match => MatchEvalStuff(match, otherData));
</code></pre>
| 39,428 |
<p>I have a Prusa i3 made by Geeetech. My 3D prints keep suffering from warping when printing with PLA.</p>
<p>Whenever I print something with a base at about 10 cm x 10 cm, at least one corner of the print would warp up. I've read numerous articles about warping and tried all sorts of methods. My printer's bed is lev... | <p>For ABS it will warp unless you build a heat chamber. </p>
<p>That said the tricks to reduce warping come down to: </p>
<ol>
<li>Material, i.e. PLA is less likely to warp; </li>
<li>Use a fan, it helps so much; </li>
<li>Make sure you have temps calibrated well - Too hot is more warp; </li>
<li>Use a raft. The Mak... | <p>Source (at least in part): </p>
<ul>
<li><a href="http://books.google.co.uk/books?id=MJqoBQAAQBAJ&pg=RA10-PA6" rel="nofollow noreferrer">SolidWorks 2015 Tutorial with Video Instruction, page 11-6</a>, and;</li>
<li><a href="https://www.makerbot.com/media-center/2011/06/23/12-ways-to-fight-warping-and-curling" r... | 510 |
<h3>Duplicate:</h3>
<blockquote>
<p><a href="https://stackoverflow.com/questions/263945/what-happens-if-you-call-erase-on-a-map-element-while-iterating-from-begin-to-e">What happens if you call erase on a map element while iterating from begin to end</a></p>
<p><a href="https://stackoverflow.com/questions/180516/how-to... | <p>You can post-increment the iterator while passing it as argument to erase:</p>
<pre><code>myMap.erase(itr++)
</code></pre>
<p>This way, the element that was pointed by <code>itr</code> before the erase is deleted, and the iterator is incremented to point to the next element in the map. If you're doing this in a lo... | <pre><code>#include <boost/next_prior.hpp>
map<string,vector<string> >::iterator next = boost::next(itr);
map1.erase(iter);
iter = next;
</code></pre>
| 33,756 |
<p>I need my program to work only with certain USB Flash drives (from a single manufacturer) and ignore all other USB Flash drives (from any other manufacturers).</p>
<p>is it possible to check that specific USB card is inserted on windows using .NET 2.0? how?</p>
<p>if I find it through WMI, can I somehow determine ... | <p><strong>EDIT:</strong> Added code to print drive letter.</p>
<hr>
<p>Check if this example works for you. It uses WMI.</p>
<pre><code>Console.WriteLine("Manufacturer: {0}", queryObj["Manufacturer"]);
...
Console.WriteLine(" Name: {0}", c["Name"]); // here it will print drive letter
</code></pre>
<p>The full c... | <p>Perhaps #usblib:</p>
<p><a href="http://www.icsharpcode.net/OpenSource/SharpUSBLib/" rel="nofollow noreferrer">http://www.icsharpcode.net/OpenSource/SharpUSBLib/</a></p>
| 15,080 |
<p>Sometimes I need to quickly extract some arbitrary data from XML files to put into a CSV format. What's your best practices for doing this in the Unix terminal? I would love some code examples, so for instance how can I get the following problem solved?</p>
<p>Example XML input:</p>
<pre class="lang-html prettyprint... | <p>If you just want the name attributes of any element, here is a quick but incomplete solution.</p>
<p>(Your example text is in the file <em>example</em>)</p>
<blockquote>
<p>grep "name" example | cut -d"\"" -f2,2
| xargs -I{} echo "{},"</p>
</blockquote>
| <p><a href="https://mikefarah.gitbook.io/yq/" rel="nofollow noreferrer">yq</a> can be used for XML parsing.</p>
<p>It is a lightweight and portable command-line YAML processor and can also deal with XML.
The syntax is similar to <a href="https://stedolan.github.io/jq/" rel="nofollow noreferrer">jq</a></p>
<p><strong>In... | 4,867 |
<p>I am working on developing a pair of libraries to work with a REST API. Because I need to be able to use the API in very different settings I'm currently planning to have a version in PHP (for web applications) and a second version in Python (for desktop applications, and long running processes). Are there any bes... | <p>So, the problem with developing parallel libraries in different languages is that often times different languages will have different idioms for the same task. I know this from personal experience, having ported a library from Python to PHP. Idioms aren't just naming: for example, Python has a good deal of magic you... | <p>Well, the obvious one would be to keep your naming consistent. Functions and classes should be named similarly (if not identically) in both implementations. This usually happens naturally whenever you implement an API separately in two different languages. The big ticket item though (at least in my book) is to fo... | 23,539 |
<p>This has been bugging me, I can't get my head around it. I will use the foodstuffs analogy to try and simplify my probelm.</p>
<p>1000 members of the public where asked to pick a variety from each of 13 categories of footstuff. These selections were then stored in a mysql database against their name.</p>
<pre><cod... | <p>Assuming you have a simple layout, then you would have something like this (I'll restrict myself to three of the categories):</p>
<pre><code>PersonId What_Milk What_Bread What_Cheese
1 Semi Wheat Swiss
2 Skimmed Rolls French
3 Soy Brown Smelly
4 L... | <pre><code>SELECT
PersonId,
milk,
bread,
cheese
FROM FoodPreference
WHERE PersonId != :chosen_person_id
AND $milk= CASE WHEN :isset($_POST["milk"]))> '' THEN :isset($_POST["milk"])) ELSE milk END
AND $bread= CASE WHEN :isset($_POST["bread"]))> '' THEN :isset($_POST["bread"]... | 28,169 |
<p>I have a sequence of SQL calls, which I want to use to detect loops (and hence unnecessary duplicate sql calls), but it got me thinking of this more general problem.</p>
<p>Given a list, say
<code>[a,b,c,b,c,a,b,c,b,c,a,b,b]</code></p>
<p>Is there some way I can turn that into
<code>a,[[b,c]*2,a]*2,b*2</code></p>
... | <p>Look into the <a href="http://en.wikipedia.org/wiki/LZW" rel="noreferrer">Lempel-Ziv-Welsh compression algorithm</a>. It is built on detecting repetitions in strings and utilizing them for compression. I believe you can use a <a href="http://en.wikipedia.org/wiki/Trie" rel="noreferrer">Trie</a>
for it.</p>
| <p>If you can sort it first, then it's easy to go through one more time to find duplicate runs. Of course, sorting something as free-form as SQL queries sounds a bit scary.</p>
| 45,516 |
<p>It would be really handy to be able to somehow say that certain properties in the generated entity classes should, for example, be decorated by (say) validation attributes (as well as Linq To SQL column attributes).</p>
<p>Is it a T4 template someplace? Or are there other ways to skin the cat?</p>
| <p>Damien Guard has written T4 templates that can be customized. See:</p>
<p><a href="http://damieng.com/blog/2008/09/14/linq-to-sql-template-for-visual-studio-2008" rel="nofollow noreferrer">http://damieng.com/blog/2008/09/14/linq-to-sql-template-for-visual-studio-2008</a></p>
<p>...and:</p>
<p><a href="http://visu... | <p>No, the SqlMetal tool is what handles the generation of the C# and it is defined within itself how the C# is generated (or VB for that matter).</p>
<p>I'm not familiar with the template style you want but you could try exteding the generated classes (if they aren't that big a change) since they are just partial cla... | 41,295 |
<p>It is not possible to fire an event in C# that has no handlers attached to it. So before each call it is necessary to check if the event is null.</p>
<pre><code>if ( MyEvent != null ) {
MyEvent( param1, param2 );
}
</code></pre>
<p>I would like to keep my code as clean as possible and get rid of those null check... | <p>I saw this on another post and have shamelessly stolen it and used it in much of my code ever since:</p>
<pre><code>public delegate void MyClickHandler(object sender, string myValue);
public event MyClickHandler Click = delegate {}; // add empty delegate!
//Let you do this:
public void DoSomething() {
Click(th... | <p>You can use PostSharp to on build time add this magic. It is the best way.</p>
| 44,258 |
<p>A couple of days ago, I read a blog entry (<a href="http://ayende.com/Blog/archive/2008/09/08/Implementing-generic-natural-language-DSL.aspx" rel="noreferrer">http://ayende.com/Blog/archive/2008/09/08/Implementing-generic-natural-language-DSL.aspx</a>) where the author discuss the idea of a generic natural language ... | <p>Considering the complexity of lexing and parsing, I don't know if I'd want to code all that by hand. <strong><a href="http://www.antlr.org/" rel="noreferrer">ANTLR</a> isn't that hard to pickup and I think it is worthing looking into based on your problem.</strong> If you use a parse grammar to build and abstract ... | <p>"One quite clear application of that, at least for me, would be to allow application testers create "testing scripts" in natural language and then parse the sentences into classes that uses JUnit to check for app behaviors"</p>
<p>What you are talking about here sounds exactly like the tool, FitNesse.
Exactly as yo... | 17,410 |
<p>Let's say I have the following HTML:</p>
<pre><code><table id="foo">
<th class="sortasc">Header</th>
</table>
<table id="bar">
<th class="sortasc">Header</th>
</table>
</code></pre>
<p>I know that I can do the following to get all of the <strong>th</strong> elem... | <p>table#foo th.sortasc</p>
| <p>The CSS selector would be something like '#foo th.sortasc'. In jQuery that would be $('#foo th.sortasc').</p>
| 12,710 |
<p>I'm writing code on the master page, and I need to know which child (content) page is being displayed. How can I do this programmatically? </p>
| <p>It's better to let the <code>ContentPage</code> notify the <code>MasterPage</code>. That's why the <code>ContentPage</code> has a <code>Master</code> Property and <code>MasterPage</code> does not have <code>Child</code> property.
Best pratice in this is to define a property or method on the <code>MasterPage</code> a... | <p>Page.Request.Url.PathAndQuery or one of the other properties of the Url Uri object should be available to you from the master page code.</p>
| 33,780 |
<p>I'm working on a project in C and it requires memalign(). Really, posix_memalign() would do as well, but darwin/OSX lacks both of them.</p>
<p>What is a good solution to shoehorn-in memalign? I don't understand the licensing for posix-C code if I were to rip off memalign.c and put it in my project- I don't want an... | <p>Mac OS X appears to be <a href="http://www.taybin.com/2007/04/03/macos-x-memory-alignment/" rel="noreferrer">16-byte mem aligned.</a> </p>
<p>Quote from the website: </p>
<blockquote>
<p>I had a hard time finding a definitive
statement on MacOS X memory alignment
so I did my own tests. On 10.4/intel,
both ... | <p>Thanks for the help, guys... helped in my case (OpenCascade src/Image/Image_PixMap.cxx, OSX10.5.8 PPC)</p>
<p>Combined with the answers above, this might save someone some digging around or instill hope if not particularly familiar with malloc, etc.:</p>
<p>The rather large project I'm building only had one refere... | 23,852 |
<p>For some odd reason the Elapsed event is firing twice, where it should definitely be firing once.
And immediately after, the timer ceases to work...
The code structure is somewhat like this:
A certain object is defined to fire a certain event when a value it contains, which is constantly updated in 500-1500ms interv... | <p>From <a href="http://msdn.microsoft.com/en-us/library/system.timers.timer(VS.80).aspx" rel="nofollow noreferrer">MSDN</a>:</p>
<blockquote>
<p>The Elapsed event is raised on a
ThreadPool thread. If processing of
the Elapsed event lasts longer than
Interval, the event might be raised
again on another Threa... | <p>Well my most basic instinct would be that somehow you actually have two event wireups to the Elapsed event - resulting in two events firing. I've been caught out through this, sometimes because I've added the event wireup manually when it has already been added in the designer, or there is some inheritance aspect he... | 29,615 |
<p>I have started using Jython as it seems to be a excellent language, and has proved to be so far.</p>
<p>I am using dom4j to manipulate and retrieve data from the DOM of a bunch of HTML files I have on disk. I have wrote the below script to check threw the DOM using Xpath for <strong>H1</strong> tags and grab text,... | <p>How about this (I don't claim to know much about Python, by the way, but this looks like an obvious first step):</p>
<pre><code>for path in ('//xhtml:h1', '//xhtml:title'):
elemHolder = dom.createXPath(path)
elemHolder.namespaceURIs = map
elem = elemHolder.selectSingleNode(dom)
if elem is not None:
... | <p>That looks like it would work perfectly, only other thing is. I will be passing the value to a database and depending what was found its put in the appropriate column.</p>
<p>If its a H1 tag it will put it in the H1 column and if its a title tag it will get put in the title column.</p>
<p>Is there a way to detemin... | 28,630 |
<p>I am looking for a way to interact with a standalone full version of Windows Media Player.<br>
Mostly I need to know the Path of the currently played track.</p>
<p>The iTunes SDK makes this really easy but unfortunately there really isn't any way to do it with Windows Media Player, at least not in .Net(C#) without ... | <p>I had this <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/dbd43d7e-f3a6-4087-be06-df17e76b635d/windows-media-player-remoting-in-c?forum=clr" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/vstudio/en-US/dbd43d7e-f3a6-4087-be06-df17e76b635d/windows-media-player-remoting-in-c?forum=... | <p>The best info I have seen on interacting with Windows Media Player is this <a href="http://blogs.msdn.com/toub/archive/2007/09/22/fun-with-dvr-ms.aspx" rel="nofollow noreferrer">article</a> written by Stephen Toub.</p>
<p>He lists a whole load of different ways to play dvr-ms files (doesn't really matter what forma... | 8,042 |
<p>If I have a property that I want to let inheritors write to, but keep readonly externally, what is the preferred way to implement this? I usually go with something like this:</p>
<pre><code>private object m_myProp;
public object MyProp
{
get { return m_myProp; }
}
protected void SetMyProp(object value)
{
m_... | <pre><code>private object m_myProp;
public object MyProp
{
get { return m_myProp; }
protected set { m_myProp = value; }
}
</code></pre>
<p>Or in C# 3.0</p>
<pre><code>public object MyProp {get; protected set;}
</code></pre>
| <p>Having a setter and getter isn't really any better than having a variable at that level of visibility.</p>
<p>Therefore you could just make the variable itself protected and the reader public.</p>
<p>That said, setters and getters are an indicator of bad OO--are you sure you need them? You should be asking the ob... | 27,071 |
<p>I'm writing a bash script that needs to delete old files.</p>
<p>It's currently implemented using :</p>
<pre><code>find $LOCATION -name $REQUIRED_FILES -type f -mtime +1 -delete
</code></pre>
<p>This will delete of the files older than 1 day.</p>
<p>However, what if I need a finer resolution that 1 day, say like... | <p>Does your <a href="http://man7.org/linux/man-pages/man1/find.1.html" rel="noreferrer"><code>find</code></a> have the <code>-mmin</code> option? That can let you test the number of mins since last modification:</p>
<pre><code>find $LOCATION -name $REQUIRED_FILES -type f -mmin +360 -delete
</code></pre>
<p>Or maybe ... | <p><code>find $PATH -name $log_prefix"*"$log_ext -mmin +$num_mins -exec rm -f {} \;</code></p>
| 31,032 |
<p>I am using macros in excel 2007 for my work. I am working with many data and I need to sum data from 2 or more rows in the same coloumn according to the same month. However the month column is expressed as date.</p>
<p>for example, i have series of data</p>
<pre><code>A B
2/10/2008 2
2/10/2008 3
4... | <pre><code> A B C D E F
1 10/ 1/2008 24106 1 Oct-08 24106 8
2 10/31/2008 24106 7 Nov-08 24107 11
3 11/ 1/2008 24107 8 Dec-08 24108 6
4 11/30/2008 24107 3
5 12/ 1/2008 24108 2
6 12/ 2/2008 24108 4
... | <p>If you are unfamiliar with VBA, I would start off by recording a macro while doing what you want to do by using the Subtotals feature under the Data menu (i.e. through Excel's interface).</p>
<p>Once the macro is recorded, you can look at the VBA code produced, and alter it to suit your needs.</p>
| 41,006 |
<p>I've been asked to write a Windows service in C# to periodically monitor an email inbox and insert the details of any messages received into a database table.</p>
<p>My instinct is to do this via POP3 and sure enough, Googling for ".NET POP3 component" produces countless (ok, 146,000) results.</p>
<p>Has anybody d... | <p>I recomment <a href="http://www.chilkatsoft.com" rel="nofollow noreferrer">chilkat</a>. They have pretty stable components, and you can get their email component for as cheap as $99 for a single developer. Personally, I think going with the whole package of components is a better deal, as it's only $289, and comes... | <p>How about WCF? It's free.</p>
<p>If you have an Exchange server:
<a href="http://msdn.microsoft.com/en-us/library/bb397812.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb397812.aspx</a></p>
<p>an example for pop3:
<a href="http://bartdesmet.net/blogs/bart/archive/2006/09/13/4417.aspx" re... | 3,863 |
<p><strong>Is there a tool that will take you java beans (pojos) and automatically make them a form for a webpage?</strong></p>
<p>To be more clear I have a bunch of Jaxb objects that I want to be able to display in a form without having to code a bunch of html. Is there a tool that will read the jaxb objects and gen... | <p>If I interpret your question quite literally, then you should take a look at the ROMA framework: <a href="http://www.romaframework.org/" rel="nofollow noreferrer">http://www.romaframework.org/</a>. It tries to take POJOs (beans) which are annotated and automatically generate user interfaces.</p>
| <p>I presume that the question was intended to be </p>
<p>'How do I render a HTML form that represents all of the fields for a given bean - this will save me from having to manually typing the HTML'</p>
<p>Theoretically, this is possible through reflection, but it's always tricky to know which fields should be includ... | 36,522 |
<p>What is a doubly linked list's remove method?</p>
| <p>The same algorithm that <a href="https://stackoverflow.com/questions/270950/linkedlist-remove-method#270962">Bill the Lizard</a> said, but in a graphical way :-)</p>
<p><a href="https://i.stack.imgur.com/dbGK6.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dbGK6.gif" alt="Remove From Linked List... | <p>Are you asking for the name of a method in the api? That answer would simply be remove, assuming you are asking about java.util.LinkedList which is in fact a double linked list.</p>
<p>...or are you asking about what the name of the algorithm to remove an element from that type of data structure is called? Well.. t... | 34,069 |
<p>I'm looking at starting a project in C++ using the Qt 4 framework (a cross-platform GUI is required). I've heard great things about the Boost libraries from friends and online. I've started reading up on both and wanted to ask a cursory question before I got too deep: Are these two development "systems" mutually e... | <p>Yes it makes perfect sense. I would generally prefer using the boost/stdlib functions where possible rather than their Qt alternatives. </p>
<p>It makes the code easier to port to the next framework.<br>
It makes is easier for new non-Qt programmers to get upto speed.<br>
Boost has some great functionality and is g... | <p>There are potential problems with using Boost.Signals alongside QT. These are documented in the <a href="http://www.boost.org/doc/libs/release/doc/html/signals/s04.html" rel="nofollow noreferrer">Boost.Signals FAQ</a>.</p>
| 47,003 |
<p>In my java application, I need to create a comment box for the users to add comments. Moreover, I need to provide the user with the provision for resizing and dragging the comment box. For this, I need to show a boundary around the comment box as in the case of comment box in Microsoft Excel which I have shown below... | <p>I would perhaps look at using <a href="https://jxlayer.dev.java.net/" rel="nofollow noreferrer">JXLayer</a> for this. It looks like what you're trying to do here is paint some context outside the of component's bounds. This is the kind of thing JXLayer excels at.</p>
| <p>This can be a little bit tricky. When you need semitransparent border it will be pain. If not, it is easy. Just use popup with appropriate components and mouse listener to listen on mouse events occurred over active borders. </p>
| 28,811 |
<p>I am playing around with MVC and have started setting up an existing site we have built in standard .Net Forms.</p>
<p>I am only including a JS file and as all the requests are being routed via .Net it is trying to compile it.</p>
<p>It is the standard compilation error you would see with invalid c#:</p>
<p>CS101... | <p>I have resolved my problem. I had the script tag in my Master Page with a runat="server" in the declaration. This then made .NET try and compile the included JavaScript file?? I have done this quite happily in .NET 2.0 without problems.</p>
| <p>As far as I know that was the behavior of ASP.NET since ASP.NET 1.0. Any tag with runat="server" gets interpreted as server code and not a client script include.</p>
| 29,239 |
<h2>Question</h2>
<p>Using XSLT 1.0, given a string with arbitrary characters how can I get back a string that meets the following rules.</p>
<ol>
<li>First character must be one of these: a-z, A-Z, colon, or underscore</li>
<li>All other characters must be any of those above or 0-9, period, or hyphen</li>
<li>If any... | <p>You <em>could</em> write a recursive template to do this, working through the characters in the string one by one, testing them and changing them if necessary. Something like:</p>
<pre><code><xsl:template name="normalizeName">
<xsl:param name="name" />
<xsl:param name="isF... | <p>As another alternative there is a string function that might work for you in the XSLT standard library. <a href="http://xsltsl.sourceforge.net/string.html#template.str:string-match" rel="nofollow noreferrer">http://xsltsl.sourceforge.net/string.html#template.str:string-match</a></p>
| 15,970 |
<p>You can use ftplib for full FTP support in Python. However the preferred way of getting a directory listing is:</p>
<pre><code># File: ftplib-example-1.py
import ftplib
ftp = ftplib.FTP("www.python.org")
ftp.login("anonymous", "ftplib-example-1")
data = []
ftp.dir(data.append)
ftp.quit()
for line in data:
... | <p>Try using <a href="https://docs.python.org/3/library/ftplib.html#ftplib.FTP.nlst" rel="noreferrer"><code>ftp.nlst(dir)</code></a>.</p>
<p>However, note that if the folder is empty, it might throw an error:</p>
<pre><code>files = []
try:
files = ftp.nlst()
except ftplib.error_perm as resp:
if str(resp) == &q... | <p>This is from Python docs</p>
<pre><code>>>> from ftplib import FTP_TLS
>>> ftps = FTP_TLS('ftp.python.org')
>>> ftps.login() # login anonymously before securing control
channel
>>> ftps.prot_p() # switch to secure data connection
>>> ftps.retrlines('L... | 13,714 |
<p>Bearing in mind that I'll be performing calculations on lat / long pairs, what datatype is best suited for use with a MySQL database?</p>
| <p>Use MySQL's <a href="https://dev.mysql.com/doc/refman/8.0/en/spatial-types.html" rel="noreferrer">spatial extensions</a> with GIS.</p>
| <p>A <code><a href="http://dev.mysql.com/doc/refman/5.1/en/numeric-type-overview.htm" rel="nofollow noreferrer">FLOAT</a></code> should give you all of the precision you need, and be better for comparison functions than storing each co-ordinate as a string or the like.</p>
<p>If your MySQL version is earlier than 5.0.... | 19,264 |
<p>There are <code><meta></code> tags and other things you can place in the <code><head></code> of your HTML document. What <code><meta></code> tags etc. and best practices do you make use of in your HTML document to make it more accessible, searchable, optimized etc.</p>
| <p>In my case:</p>
<ul>
<li>Title (should do [Section Name - Site Name] for better SEO)</li>
<li>Meta tag for <code>Content-type</code>, <code>description</code>, and <code>keywords</code></li>
<li>Link to stylesheet(s) (don't forget to specify the <code>media=""</code>).</li>
<li><code><script></code> tag that ... | <p>Title, meta tags for keywords, content-type (if not explicitly set by the web server), and any CSS to be applied to the page.</p>
<p>Declaring the CSS up front allows the browser to lay out the page more efficiently (see <a href="http://developer.yahoo.com/performance/rules.html#css_top" rel="nofollow noreferrer">h... | 34,749 |
<p>Can someone give me some working examples of how you can create, add messages, read from, and destroy a private message queue from C++ APIs? I tried the MSDN pieces of code but i can't make them work properly.</p>
<p>Thanks</p>
| <p>Actualy this is the code i was interested in:</p>
<pre><code>#include "windows.h"
#include "mq.h"
#include "tchar.h"
HRESULT CreateMSMQQueue(
LPWSTR wszPathName,
PSECURITY_DESCRIPTOR pSecurityDescriptor,
LPWSTR wszOutFormatName,
... | <p>Not quite sure how you'd go about creating or destroying message queues. Windows should create one per thread. </p>
<p>If you're using MFC, any CWinThread and CWnd derived class has a message queue that's trivial to access (using PostMessage or PostThreadMessage and the ON_COMMAND macro). To do something similar wi... | 14,579 |
<p>When reading the registry for file names I get 3 entries loading into my combo box for every 1 registry entry. If I have 1 file listed in the registry I would see :</p>
<p>Combo box values:</p>
<p>c:\file1.txt</p>
<p><-----Blank here</p>
<p>c:\file1.txt</p>
<p>I have found the problem lies in this code, it h... | <p>Well, it should hit the if() statement 6 times, the comboBox1.Items.Add() statement 3 times. The logical explanation is that the real problem is located in the code that writes the registry keys. Run Regedit.exe to find out what is really stored in these registry key values.</p>
| <p>just add a "break;" after the first comboBox1.Items.Add().
it will leave the loop after the insert (if this is what you want).</p>
| 29,662 |
<p>I want my web application users to download some data as an Excel file. </p>
<p>I have the next function to send an Input Stream in the response object. </p>
<pre><code>public static void sendFile(InputStream is, HttpServletResponse response) throws IOException {
BufferedInputStream in = null;
try... | <p>The problem with your question is that you are mixing OutputStreams and InputStreams. An InputStream is something you read from and an OutputStream is something you write to. </p>
<p>This is how I write a POI object to the output stream.</p>
<pre><code>// this part is important to let the browser know what you'r... | <p>I think I understand what you're trying to do (maybe I am undershooting, though)</p>
<p>you don't really need that much code - check out the write method - </p>
<pre><code>HSSFWorkbook wb = new HSSFWorkBook();
//populate
ServletOutputStream out = response.getOutputStream();
try {
wb.write(out);
out.flush();... | 49,634 |
<p>I have a free standing set of files not affiliated with any C# project at all that reside in a complicated nested directory structure.</p>
<p>I want to add them in that format to a different directory in an ASP.NET web application I am working on; while retaining the same structure. So, I copied the folder into the... | <p>Drag the files / folders from Windows Explorer into the Solution Explorer. It will add them all. Note this doesn't work if Visual Studio is in Administrator Mode, because Windows Explorer is a User Mode process.</p>
| <p>It's annoying that Visual Studio doesn't support this natively, but CMake could generate the Visual Studio project as a work around.</p>
<p>Other than that, just use Qt Creator. It can then export a Visual Studio project.</p>
| 8,218 |
<p>In Java, what is the difference between the twin methods?</p>
<pre><code>public void methodA() throws AnException {
//do something
throw new AnException();
}
public void methodA() {
//do the same thing
throw new AnException();
}
</code></pre>
<p>I have a intuition that it has something to do with ... | <p>If AnException is a checked exception (in other words, if it doesn't extend RuntimeException) then methodA won't compile. Checked exceptions must always be declated.</p>
<p>If AnException is an unchecked exception (if it does extend RuntimeException), then either is allowed by the java compiler, and either is inte... | <p>In the second method the AnException class need to be a subclass of RuntimeException which means that the declaration is not mandatory and the method callers don't have to handle it.
An example of RuntimeException is ArrayOutOfBoundException, imagine if you would have explicitly handle the exception (by declaring a ... | 39,914 |
<p>I have found jQuery to be a great tool to simplify my MVC Views.</p>
<p>For example, instead of including complicated logic to add alternating styles to my tables I just do this...</p>
<pre><code>$(document).ready(function() {
$("table.details tr:odd").addClass("detailsAlternatingRow");
$("table.details tr:e... | <p>MVC Framework has a JsonResult that can be very nice to eliminate server round trips and might be able to get rid of some of the logic in your view page. I wrote a tutorial on this available at : </p>
<p><a href="http://www.dev102.com/2008/08/19/jquery-and-the-aspnet-mvc-framework/" rel="nofollow noreferrer">http:/... | <p>Note if you use PHP on the server you can use <a href="http://code.google.com/p/phpquery/" rel="nofollow noreferrer">phpQuery</a> (and I'm sure there are similar server-side jQuery ports for other languages) to do stuff like that without expecting the user to have Javascript enabled.</p>
| 24,135 |
<p>I have just started using Boost 1.36. These libraries would be very useful in reducing the amount of code needed in the unmanaged C++ software project that I am working on.</p>
<p>However when I tried to used these libraries my compile times increased ten fold. This would pretty much offset the productivity gains I... | <p>Have you tried using precompiled headers? That is including the boost headers in StdAfx.h or whatever header file you use for precompiled headers?</p>
| <p>Did you try <a href="http://www.xoreax.com/" rel="nofollow noreferrer">Incredibuild</a>? It will allow you to distribute your build on multiple computers. I have seen it used successfully.</p>
| 19,979 |
<p>At the moment I pull data from remote MS SQL Server databases using custom-built JDBC connectors. This works fine but doesn't feel like the way to do it.</p>
<p>I feel I should be able to put a JDBC connection string into tnsnames on the server and have it "just work". I've looked around a little for this functiona... | <p><a href="http://www.oracle.com/pls/db102/search?remark=quick_search&word=Generic+Connectivity&tab_id=&format=ranked" rel="nofollow noreferrer">Generic Connectivity</a> is what you are after, it will let you setup a remote database link against MS SQL Server, so you can do queries like</p>
<pre><code>sel... | <p>Another product to look at is Oracle Gateways.</p>
<p>Have a look at:</p>
<p><a href="http://www.oracle.com/technology/documentation/gateways10g.html" rel="nofollow noreferrer">http://www.oracle.com/technology/documentation/gateways10g.html</a></p>
| 22,557 |
<p>I am about to start on a journey writing a windows forms application that will open a txt file that is pipe delimited and about 230 mb in size. This app will then insert this data into a sql server 2005 database (obviously this needs to happen swiftly). I am using c# 3.0 and .net 3.5 for this project. </p>
<p>I am ... | <p>Do you have to write a winforms app? It might be much easier and faster to use SSIS. There are some built-in tasks available especially <a href="http://denster.spaces.live.com/Blog/cns!125D53A08EC75357!1210.entry" rel="noreferrer">Bulk Insert task</a>. </p>
<p>Also, worth checking <a href="http://weblogs.sqlteam.co... | <p>If the column format of the file matches the target table where the data needs to end up, I prefer using the command line utility <strong>bcp</strong> to load the data file. It's blazingly fast and you can specify and error file for any "odd" records that fail to be inserted.</p>
<p>Your app could kick off the com... | 17,107 |
<p>A lot of OS projects I know (I am PHP developer) uses versions as milestones, but is this the best way?
Should milestones mean something in process of project iterations (meaningfull names)?
Are there any rules? Or maybe its totally subjective?</p>
| <p>In our development process, versions and milestones are something different.
One of our standard milestones is the <em>release</em>. That has, of course, a version.
But to me, a milestone is somthing in the future, something that I have to plan for. A version is coupled to a release, so it is something that is in th... | <p>Version numbers are convenient because you can instantly take any two versions and see which one is the newer of the two. It is always going to be subjective to a degree, because who is to say what feature(s) or bug fix(es) constitutes a milestone?</p>
<p>The scheme I like is x.y.z where x is the major release num... | 44,658 |
<p>I create business applications with heavy database use. Most of the programming work is just to connect components to the database and modifying components to adapt to general interface behaviour. I mostly use Delphi with its rich VCL library, and generally buy components needed. I keep most of the business logic in... | <p>The answer to this question is not totally language-agnostic;</p>
<p>Some languages like Java have a fairly limited set of language features available, meaning that subclassing is fairly often used because it's a convenient method for re-use, technical inheritance.</p>
<p>Closures and lambdas of C# make inheritanc... | <p>It really depends on the types/phases of the projects you're working on. I happen to do that everyday because I'm working on database internals for a new database, creating related libraries/frameworks. I'd imagine doing that a lot less if I'm working within a mature framework using other people's libraries.</p>
| 47,857 |
<p>I have a controller with an action method as follows:</p>
<pre><code>public class InventoryController : Controller
{
public ActionResult ViewStockNext(int firstItem)
{
// Do some stuff
}
}
</code></pre>
<p>And when I run it I get an error stating:</p>
<blockquote>
<p>The parameters dictionar... | <p>Your routing needs to be set up along the lines of <code>{controller}/{action}/{firstItem}</code>. If you left the routing as the default <code>{controller}/{action}/{id}</code> in your <code>global.asax.cs</code> file, then you will need to pass in <code>id</code>.</p>
<pre><code>routes.MapRoute(
"Inventory",
... | <p>Or, you could try changing the parameter type to string, then convert the string to an integer in the method. I am new to MVC, but I believe you need nullable objects in your parameter list, how else will the controller indicate that no such parameter was provided? So...</p>
<pre><code>public ActionResult ViewNextI... | 18,852 |
<p>If I have an array of a fixed size depending on how it is defined and used, I typically use one of two ways to reference it.</p>
<p>Array type 1: Since it is a fixed size based on a define, I just use that define in all my loops referencing it.</p>
<pre><code>#define MAXPLAYERS 4
int playerscores[MAXPLAYERS];
fo... | <p>This will work for both of your cases, regardless of array element type:</p>
<pre><code>#define ARRAY_COUNT(x) (sizeof(x)/sizeof((x)[0]))
...
struct foo arr[100];
...
for (i = 0; i < ARRAY_COUNT(arr); ++i) {
/* do stuff to arr[i] */
}
</code></pre>
| <p>Addition to the answers so far, if you are using T[] arrays in C++:
Use template argument deduction to deduce the array size. It's much safer:</p>
<p><code>template<int N> void for_all_objects(MYSTRUCT_DEF[N] myobjects)</code></p>
<p>Your <code>sizeof(mystruct)/sizeof(MYSTRUCT_DEF)</code> expression fails qu... | 23,040 |
<p>Is it possible to unsubscribe an anonymous method from an event?</p>
<p>If I subscribe to an event like this:</p>
<pre><code>void MyMethod()
{
Console.WriteLine("I did it!");
}
MyEvent += MyMethod;
</code></pre>
<p>I can un-subscribe like this:</p>
<pre><code>MyEvent -= MyMethod;
</code></pre>
<p>But if I ... | <pre><code>Action myDelegate = delegate(){Console.WriteLine("I did it!");};
MyEvent += myDelegate;
// .... later
MyEvent -= myDelegate;
</code></pre>
<p>Just keep a reference to the delegate around.</p>
| <p>if you want refer to some object with this delegate, may be you can use Delegate.CreateDelegate(Type, Object target, MethodInfo methodInfo)
.net consider the delegate equals by target and methodInfo</p>
| 22,165 |
<p>I want to save the objects I generated in a program. After restart the App should load automaticly all Objects in an Array. I want to write them in a file and parse them after restart. Are the other smarter possibilities than do it by hand?
Thank you</p>
| <p>Yes, the concept you are looking for is called serialization. There's a fine tutorial at Sun <a href="http://java.sun.com/developer/technicalArticles/Programming/serialization/" rel="noreferrer">here</a>.</p>
<p>The idea is that classes you want to persist have to implement the Serializable interface. After that yo... | <p>java.io.Object[Input/Output]Stream are the two classes you need to look at. <br>Any class you wish to persist to file needs to implement the java.io.Serializable interface.</p>
| 20,575 |
<p>Is there any free or commercial component written in .NET (no COM interop) that will work with most twain scanners?</p>
| <blockquote>
<h3><a href="https://github.com/tmyroadctfig/twaindotnet" rel="noreferrer">TwainDotNet</a></h3>
</blockquote>
<p>I've just wrapped up the code from Thomas Scheidegger's article (<a href="http://www.codeproject.com/KB/dotnet/twaindotnet.aspx" rel="noreferrer">CodeProject: .NET TWAIN image scanning</a>) into... | <p>Just started a project in .net and found great info <a href="http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=60471" rel="nofollow noreferrer">here</a> (*dead link as of Feb 2014) about using Windows Image Acquisition. Lots of sample VB code and some c#.</p>
| 6,032 |
<p>What are the best practices around creating flat file database structures in PHP?</p>
<p>A lot of more matured PHP flat file frameworks out there which I attempt to implement SQL-like query syntax which is over the top for my purposes in most cases. (I would just use a database at that point).</p>
<p>Are there any... | <p>Well, what is the nature of the flat databases. Are they large or small. Is it simple arrays with arrays in them? if its something simple say userprofiles built as such:</p>
<pre><code>$user = array("name" => "bob",
"age" => 20,
"websites"... | <p>If you're going to use a flat file to persist data, use XML to structure the data. PHP has a <a href="http://uk.php.net/xml" rel="noreferrer">built-in XML parser</a>.</p>
| 2,251 |
<p>Does anyone have links to documentation or guides on making the decision between REST vs. SOAP? I understand both of these but am looking for some references on the key decision points, eg, security, which may make you lean towards one or the other.</p>
| <p><a href="http://www.prescod.net/rest/rest_vs_soap_overview/" rel="noreferrer">Google first hit</a> seems pretty comprehensive.</p>
<p>I think the problem here is there are too many advocates of one or the other, may be better of googling and getting more of a handle of the pro's/con's yourself and making your own d... | <p>I Think both REST and SOAP can be used to implement similar functionality, but in general SOAP should be used when a particular feature of SOAP is needed, and the advantages of REST make it generally the best option otherwise. However, both REST and SOAP are often termed "Web services," and one is often us... | 4,861 |
<p>In Ruby, what's the difference between <code>{}</code> and <code>[]</code>?</p>
<p><code>{}</code> seems to be used for both code blocks and hashes.</p>
<p>Are <code>[]</code> only for arrays?</p>
<p>The documention isn't very clear.</p>
| <p>It depends on the context:</p>
<ol>
<li><p>When on their own, or assigning to a variable, <code>[]</code> creates arrays, and <code>{}</code> creates hashes. e.g.</p>
<pre><code>a = [1,2,3] # an array
b = {1 => 2} # a hash
</code></pre></li>
<li><p><code>[]</code> can be overridden as a custom method, and is ge... | <p>a few examples:</p>
<pre><code>[1, 2, 3].class
# => Array
[1, 2, 3][1]
# => 2
{ 1 => 2, 3 => 4 }.class
# => Hash
{ 1 => 2, 3 => 4 }[3]
# => 4
{ 1 + 2 }.class
# SyntaxError: compile error, odd number list for Hash
lambda { 1 + 2 }.class
# => Proc
lambda { 1 + 2 }.call
# => 3
</cod... | 3,358 |
<p>In a <a href="https://stackoverflow.com/questions/224138/infinite-loops-top-or-bottom">coding style question about infinite loops</a>, some people mentioned they prefer the for(;;) style because the while(true) style gives warning messages on MSVC about a conditional expression being constant.</p>
<p>This surprised... | <p>A warning doesn't automatically mean that code is <em>bad</em>, just suspicious-looking.</p>
<p>Personally I start from a position of enabling all the warnings I can, then turn off any that prove more annoying than useful. That one that fires anytime you cast anything to a bool is usually the first to go.</p>
| <p>A simple way to avoid the warning would be:</p>
<pre><code>#ifdef CONFIG_FOO
extern int foo_enabled;
#else
extern int foo_enabled = 0;
#endif
</code></pre>
| 27,723 |
<p>In the PHP manual, to show the syntax for functions with optional parameters, they use brackets around each set of dependent optional parameter. For example, for the <a href="http://php.net/date" rel="noreferrer"><code>date()</code></a> function, the manual reads:</p>
<pre><code>string date ( string $format [, int ... | <p>Much like the manual, use an equals (<code>=</code>) sign in your definition of the parameters:</p>
<pre><code>function dosomething($var1, $var2, $var3 = 'somevalue'){
// Rest of function here...
}
</code></pre>
| <p>Starting with 7.1 there is a type hinting for nullable parameters</p>
<pre><code>function func(?Object $object) {}
</code></pre>
<p>It will work for these cases:</p>
<pre><code>func(null); //as nullable parameter
func(new Object()); // as parameter of declared type
</code></pre>
<p>But for optional value signature... | 5,524 |
<p>I have a problem with a many-to-many relation in my tables, which is between an employee and instructor who work in a training centre. I cannot find the link between them, and I don't know how to get it. The employee fields are:</p>
<ul>
<li>employee no.</li>
<li>employee name</li>
<li>company name</li>
<li>departm... | <p>in a many-to-many relationship the relationships will be in a 3rd table, something like </p>
<pre><code>table EmployeeInstructor
EmployeeID
InstructorID
</code></pre>
<p>to find all the employees for a specific instructor, you'd use a join against all three tables.</p>
| <p>First of all, you will need a unique key in both tables. The employee number may work for the employee table, but you will need another for the instructor table. Personally, I tend to use auto incrementing identity fields called ID in my tables. This is the primary key.
Second, create a new table, InstructorEmplo... | 47,606 |
<p>I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction:</p>
<ol>
<li><p>Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's fi... | <p>Here's the general plan for Twisted. I was originally going to blog this, but then I thought: why blog about it when I could get <em>points</em> for it?</p>
<ol>
<li><p><strong>Wait until somebody cares.</strong></p>
<p>Right now, nobody has Python 3. We're not going to spend a bunch of effort until at least one... | <p>Some of my more complex 2.x code is going to stay at 2.5 or 2.6.
I am moving onto 3.0 for all new development once some of the 3rd party libraries I use often have been updated for 3.</p>
| 20,768 |
<p>In our processing software we are moving from one version of an external assembly to a newer version. While the overall task that the assembly performs are the same, the API is radically different and no backwards compatibility have been maintained. The API is responsible for extracting data from external stations w... | <p>A good post about the options for this can be found here:
<a href="http://kevin-berridge.blogspot.com/2008/01/two-versions-of-same-shared-assembly.html" rel="nofollow noreferrer">http://kevin-berridge.blogspot.com/2008/01/two-versions-of-same-shared-assembly.html</a> </p>
| <p>You could sign the assemblies yourself using <a href="http://www.microsoft.com/downloads/details.aspx?familyid=22914587-b4ad-4eae-87cf-b14ae6a939b0&displaylang=en" rel="nofollow noreferrer">ILMerge</a> and then use <a href="http://kentb.blogspot.com/2008/11/visual-studio-referencing-same-assembly.html" rel="nofo... | 37,702 |
<p>Is it possible to subscribe to a url with log4j logs?
I understand that many applications do have daily error logs notification by email. But a problem with this approach is that the server that host the application may not provide smtp capability. Thus the RSS subscribe approach seens to be more flexibile.</p>
<p>... | <p>A log4j RSS appender has already been written. Have a look at <a href="http://code.google.com/p/rssappender/" rel="nofollow noreferrer">http://code.google.com/p/rssappender/</a></p>
| <p>A pretty simple solution would be to use log4j (or log4net in my case) to persist the logging information to some store (database or file). Then you can easily create a service that exposes that log as an RSS feed.</p>
| 17,804 |
<p>At work we have two servers, one is running an application a lot of people use which has an SQL Server 2000 back end. I have been free to query this for a long time but can't add anything to it such as stored procedures or extra tables. </p>
<p>This has lead to us having a second SQL Server linked to the first one ... | <p>Avoid joins to linked server tables.</p>
<p>Using a four part naming for your join can be used but is more expensive. Your join could contain criteria that can be used to limit the data set from the linked server and use the indexed columns.</p>
<p>Example:</p>
<pre><code>SELECT loc.field1, lnk.field1
FROM MyTabl... | <p>Is there a possibility that you could set up a separate database on the server rather than using a linked server? </p>
| 16,041 |
<p>I'm trying to figure out how to automatically extract the part after it was printed.</p>
<p>One of the ideas is to wait until the bed get cooled enough (let's say to 40-50 °C, usually the part can be just slide of at this bed temperature) and turn on the powerful fan blowing off the part to a tray or something.</p>
... | <p>You can do this provided the part releases consistently after cooling. Your filament choice may cause problems, though. ABS is prone to warping and a fan constantly blowing on the part would make it worse. The second thing to consider would be the release agent. I assume you are using gluestick or something similar ... | <p>In theory you could knock the item off the build plate and into a bin by positioning the print head behind the part and then pushing.</p>
<p>However your build plate would need to have a smooth front edge, so no clips in the way.</p>
<p>You'd also want to have some delay to let the bed cool down before attempting th... | 2,026 |
<p>I'm trying to generate a sitemap.xml on the fly for a particular asp.net website.</p>
<p>I found a couple solutions:<br /></p>
<ol>
<li><a href="http://sitemap.chinookwebs.com/" rel="nofollow noreferrer">chinookwebs</a></li>
<li><a href="http://web.archive.org/web/20080307061444/http://www.cervoproject.info:80/sitem... | <p>Usually you'll use an <a href="http://www.google.com/search?q=HTTPHandler+ASP.NET&spell=1" rel="noreferrer">HTTP Handler</a> for this. Given a request for...</p>
<blockquote>
<p><a href="http://www.yoursite.com/sitemap.axd" rel="noreferrer">http://www.yoursite.com/sitemap.axd</a></p>
</blockquote>
<p>...your... | <p>Custom handler to generate the sitemap. </p>
| 3,076 |
<p>Can I get some constructive feedback about the following architecture? </p>
<p><strong>Simplified Architecture Summary:</strong></p>
<p><em>Return XML from your SQL Server (using FOR XML) and pass it straight into a XSL transform to produce a rich HTML web site.</em></p>
<p>What are the pro’s and con’s of such a ... | <p>We have done something like this. And it works for very simple pages. But as soon as you would like to include some client side javascript and similar, you are doomed.</p>
<p>The generated output is hidden in the XSLT stylesheets and it is very hard to read, maintain and fix bugs. </p>
<p>Testing can be done, but ... | <p>Two cons.</p>
<ol>
<li><p>Data manipulation with C# or VB.net becomes harder because you don't have classes with properties (code intellisense) but xml-documents. </p></li>
<li><p>There are built in asp.net controls for data entry validation (both client side and server side). You can't use them if you use XSLT to ... | 49,901 |
<p>Is there a way to use Profiler to determine whether a table is being accessed by queries?</p>
<p>I saw an event named <code>Object:Opened</code> (Indicates when an object has been accessed, such as for SELECT, INSERT, or DELETE statements) and <code>Object:Closed</code>, but these do not seem to work.</p>
<p>In pa... | <p>It may help to investigate the locks SQL is acquiring. Select statements will generally aquire shared Locks (LCKMS), so you can filter for this.</p>
<p>In profiler look for the Locks:Acquired event. The ObjectID will resolve to the table which you can easily lookup with <code>OBJECT_NAME(objectid)</code>. The Mod... | <p>I'm not seeing those in SQL Server 2005.</p>
<p>In my experience, I look at <code>SQL:StmtStarting</code> <strong>AND</strong> <code>SP:StmtStarting</code> - you can filter <code>TextData</code> on <code>%TABLE_NAME%</code>. This will even catch things inside SPs when you use <code>SP:StmtStarting</code>.</p>
<p>... | 37,969 |
<p>I created my model in onshape then exported it to stl file then imported it to simplify 3d to convert to gcode.</p>
<p>However my model didn't go any in fill, it just continue to print layer after layer in the same fasion as the 1st layer. </p>
<p>Correct me if am wrong infill is used so that the middle of your mo... | <p>I don't use either of the two piece of software, but the first things to pop to mind:</p>
<ul>
<li><strong>Inspect the slicing preview</strong>: it should be self-evident if your GCODE is being generated correctly. In my slicer the infill is red and you can discern the typical pattern within:</li>
</ul>
<p><a hre... | <p>The infill portion of your model is configured during the Simplify3D process. After loading your STL file into S3D, edit the process and examine the Infill tab and Infill slider. You'll see a percentage indicator, as well as an extruder selection (left or right, if you have two) to be used for the infill. There are ... | 782 |
<p>Is there a way to suppress warnings in Xcode?</p>
<p>For example I am calling an undocumented method and since the method is not in the header I get a warning on compile. I know I can add it to my header to stop the warning, but I am wondering if there is a way other than adding it to the header (so I can keep the ... | <p>To disable warnings on a per-file basis, using Xcode 3 and llvm-gcc-4.2 you can use:</p>
<pre><code>#pragma GCC diagnostic ignored "-Wwarning-flag"
</code></pre>
<p>Where warning name is some gcc warning flag.</p>
<p>This overrides any warning flags on the command line. It doesn't work with all warnings though. ... | <p>Suppressing that particular warning is not safe. The compiler needs to know the types of the arguments and returns to a method to generate correct code. </p>
<p>For example, if you're calling a method like this</p>
<p>[foo doSomethingWithFloat:1.0];</p>
<p>that takes a float, and there is no prototype visible, ... | 23,657 |
<p>Has anyone had any luck with printing multi-colored prints with the Palette 2 on an Ender 3? If so, what is your steps/mm for the Ender 3 and your flow rate in whatever slicer you are using? I currently have my flow rate at 100 % and my steps/mm at 104.4, and I believe this is what is causing my Palette 2 to no... | <p>On this thread, <a href="https://support.mosaicmfg.com/hc/en-us/community/posts/360021788573-Does-anyone-tried-Palette-2-0-on-Creality-Ender-3-or-Ender-3-Pro-" rel="nofollow noreferrer">Does anyone tried Palette 2.0 on Creality Ender 3 or Ender 3 Pro?</a>, there are a couple of useful links:</p>
<ul>
<li><p>There i... | <p>The guide is at <a href="https://support.mosaicmfg.com/hc/en-us/articles/360011124234-Getting-Started-With-Palette-2-Setup-to-Printing-" rel="nofollow noreferrer">Getting Started With Palette 2 (Setup to Printing)</a>, which includes guides to use the correct slicer software and swapping <a href="https://support.mos... | 1,269 |
<p>Okay, we know that the following two lines are equivalent - </p>
<ol>
<li><code>(0 == i)</code></li>
<li><code>(i == 0)</code></li>
</ol>
<p>Also, the first method was encouraged in the past because that would have allowed the compiler to give an error message if you accidentally used '=' instead of '=='.</p>
<p>... | <p>I prefer the second one, (i == 0), because it feel much more natural when reading it. You ask people, "Are you 21 or older?", not, "Is 21 less than or equal to your age?"</p>
| <p>We might go on and on about how good our IDEs have gotten, but I'm still shocked by the number of people who turn the warning levels on their IDE down.</p>
<p>Hence, for me, it's always better to ask people to use (0 == i), as you never know, which programmer is doing what.
It's better to be "safe than sorry"</p>... | 17,871 |
<p>I'm a complete Ada newbie, though I've used Pascal for 2-3 years during HS.</p>
<p>IIRC, it is possible to call Pascal compiled functions from C/C++. Is it possible to call procedures & functions written in Ada from C++?</p>
| <p>According to this <a href="http://www.ghs.com/download/whitepapers/ada_c++.pdf" rel="nofollow noreferrer">old tutorial</a>, it should be possible.</p>
<p>However, as illustrated by <a href="http://archives.devshed.com/forums/programming-132/problem-passing-in-out-parameter-from-c-to-ada-1023388.html" rel="nofollow ... | <p>Yes. Several years ago I wrote a short simple demo to prove it. There were two DLLs, one written in C++ and the other in Ada. They just added constants to floating point values. Two apps, one in C++ and one in Ada, each used both the DLL. So every possible combination of C++ calling/called from Ada existed. It... | 31,911 |
<p>I am evaluating datamining packages.
<br/>I have find these two so far:
<li><a href="http://rapid-i.com/content/blogcategory/38/69/" rel="noreferrer">RapidMiner</a></li>
<li><a href="http://www.cs.waikato.ac.nz/~ml/weka/" rel="noreferrer">Weka</a></li>
Do you have any experience to share with these two products, or ... | <p>According to the yearly KDnuggets Polls 2007, 2008, and 2009, RapidMiner is the most widely used Open Source Data Mining Solution among data mining experts world-wide:
<a href="http://www.kdnuggets.com/polls/2009/data-mining-tools-used.htm" rel="noreferrer">KDnuggets Data Mining Tool Poll 2009</a></p>
<p>RapidMiner... | <p>As said before, Pentaho is a powerful Business Intelligence suite which WEKA belong to.</p>
<p>So I'd also recommand Weka, just for the sake that you have a great solution to extend your application and a great community also.</p>
| 30,097 |
<p>How can I add an HyperLink in a TRichEdit (using Delphi).</p>
<p>I need to have something like:</p>
<p>"This is my text, click here to do something." </p>
| <p>According to <a href="http://delphi.about.com/od/vclusing/l/aa111803a.htm" rel="nofollow noreferrer">this</a> article on <a href="http://delphi.about.com" rel="nofollow noreferrer">delphi.about.com</a></p>
<blockquote>
<p>Unfortunately, Delphi's implementation of the RichEdit control leaves out a lot of the funct... | <p>The richedit in <a href="http://woll2woll.com/InfoPower.html" rel="nofollow noreferrer">Infopower</a> supports hyperlinks.</p>
| 11,903 |
<p>inside my C# app I runs a 7z process to extract an archive into it's directory</p>
<p>the archive is located in a random-named directory on the %TEMP% directory for example</p>
<blockquote>
<p>C:\Documents and Settings\User\Local
Settings\Temp\vtugoyrc.fd2</p>
</blockquote>
<p>(fullPathFilename = "C:\Document... | <p>You're using 7 Zip as an external process here. Its the equivalent of calling the commands directly from the command line.</p>
<p>Have you considered using an actual Library for zipping/unzipping your files. Something you can reference in your C# project.</p>
<p><a href="http://www.icsharpcode.net/OpenSource/Sharp... | <p>Thanks for all help.</p>
<p>Anyhow the problem was the use of 'long-path-name' -> command-line process can't find C:\Documents and Settings\ (because of the spaces in the name). Solutions to this can be found
here <a href="https://stackoverflow.com/questions/258367/standard-way-to-convert-to-long-path-in-net">stan... | 32,222 |
<p>I'm using Wise Package Studio 7.0 SP2 on Windows XP.</p>
<p>I've got an MSI Wrapped EXE installation that goes about happily installing some files and then running one of the files from the installation which we can refer to as app.exe.</p>
<p>So on the "Execute Deferred" tab of the MSI Editor, I had to add the li... | <p>6 months ago we were using VBScript actions to do the same thing, then right around the time that SP3 was released the objProcess.Terminate() function just refused to work on some machines. No matter what we did, it just froze. This happened on around 10% of our test machines so we were forced to find an alternative... | <p>You can insert VBscript elements into the MSI as custom actions. Something like this should do the job:</p>
<pre><code>strMachine = "localhost"
strAppName = "notepad.exe"
Set objProcesses = GetObject("winmgmts://" & strMachine).ExecQuery("SELECT * FROM Win32_Process WHERE Caption LIKE '" & strAppName &... | 31,275 |
<p>For example I want to be able to programatically hit a line of code like the following where the function name is dynamically assigned without using Evaluate(). The code below of course doesn't work but represents what I would like to do.</p>
<pre><code>application.obj[funcName](argumentCollection=params)
</code></... | <p>According to the docs, you can do something like this:</p>
<pre><code><!--- Create the component instance. --->
<cfobject component="tellTime2" name="tellTimeObj">
<!--- Invoke the methods. --->
<cfinvoke component="#tellTimeObj#" method="getLocalTime" returnvariable="localTime">
<cfinvok... | <p>You can also do something very similar, to the way you wanted to use it. You can access the method within the object using the syntax you used, you just can't call it at the same time. However, if you assign it to a temp variable, you can then call it</p>
<pre><code><!--- get the component (has methods 'sayHi' a... | 11,006 |
<p>My professor assigned a project where a simulation is ran through a GUI. To edit it, we need to create a "New" menu item. We haven't learned how to get data from a GUI, and our book does not cover it at all. </p>
<p>What I'm trying to do, is when the "New" command is hit, focus gets shifted back to the CMD prompt, ... | <p>DEP runs in one of two modes:</p>
<ol>
<li><p>Hardware DEP is for CPUs that can mark memory pages as non-executable. This helps to prevent certain exploits such as buffer overflows.</p>
</li>
<li><p>Software DEP is for CPUs that do not have hardware DEP support. It doesn't prevent execution of code in data pages, bu... | <p>Start by trying to figure out where and how your program is failing. Can you replicate the issue on your system? With enabling DEP for the application on your system? When you can replicate the issue and get the error (access violation), you can look to fixing your program.</p>
<p>See the <a href="http://msdn.mi... | 45,691 |
<p>I am trying to do some simple formatting stuff with 'sed' in linux, and i need to use a regex to trim a string after the 15th character, and append a '...' to the end. Something like this:</p>
<pre><code>before: this is a long string that needs to be shortened
after: this is a long ...
</code></pre>
<p>Can anyone ... | <p>The following works for me:</p>
<pre><code>echo "This is a test with more than 15 characters" | sed "s/\(.\{15\}\).\+$/\1…/"
</code></pre>
<p>What happens here is that we match any character ( <code>.</code>) 15 times (<code>{15}</code>). We capture the text so matched inside parentheses. The following part (<code... | <p>In perl, you could write <code>s/(.{15}).*/$1.../</code>. I'm not sure sed can use the {15} notation but if not, <code>s/\(...............\).*/\1.../</code> (with 15 dots in the group).</p>
<p>I can never remember whether you need to escape <code>(</code> when grouping in sed. I just tried it and you do need <cod... | 46,153 |
<p>It seems like there is a lot of overhead involved in rapidly opening and closing sqlconnections. Should I persist a connection (one, per client, per database), or continue declaring a new sqlconnection object whenever I need one, and making sure I clean up after myself?</p>
<p>What have you done? What worked well a... | <p>In most cases, .NET connection pooling handles this for you. Even though you're opening and closing connections via code, that's not what's happening behind the scenes. When you instantiate and open a connection, .NET looks for an existing connection in the connection pool with the same connectionstring and gives yo... | <p>For years we had the client keep a single persistent connection to the database. The problem comes in detecting an intermittent connection failure and gracefully reconnecting. Quite often you won't know that a connection failed until you try to use it (i.e. issuing a select will throw a 'General SQL Error')</p>
<p>... | 30,710 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.