instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I got this doubt while writing some code. Is 'bool' a basic datatype defined in the C++ standard or is it some sort of extension provided by the compiler ? I got this doubt because Win32 has 'BOOL' which is nothing but a typedef of long. Also what happens if I do something like this:</p>
<pre><code>int i = true;
</... | <p>bool is a fundamental datatype in C++. Converting <code>true</code> to an integer type will yield 1, and converting <code>false</code> will yield 0 (4.5/4 and 4.7/4). In C, until C99, there was no bool datatype, and people did stuff like</p>
<pre><code>enum bool {
false, true
};
</code></pre>
<p>So did the Win... | <p>Allthough it's now a native type, it's still defined behind the scenes as an integer (int I think) where the literal <code>false</code> is 0 and <code>true</code> is 1. But I think all logic still consider anything but 0 as true, so strictly speaking the true literal is probably a keyword for the compiler to test if... | 46,516 |
<p>I have a table of users which has a username column consisting of a six digit number e.g 675381, I need to prepend a zero to each of these usernames e.g. 0675381 would be the final output of the previous example, is there a query that could handle this?</p>
| <pre><code>UPDATE Tablename SET Username = Concat('0', Username);
</code></pre>
| <p>You might want to use CONCAT_WS('', '0', Username) because if there is a null value, then you'll end up with NULL instead of '0'. This probably isn't a problem, but something I've learnt the hard way.</p>
| 18,950 |
<p>Does anyone know how IE7 determines what Security Zone to use for a site? I see the basics for IE6 <a href="http://www.microsoft.com/technet/prodtechnol/ie/reskit/6/default.mspx?mfr=true" rel="nofollow noreferrer">here</a>, but I can't find the equivalent for IE7.</p>
| <p>I could use a little more information to narrow down my answer, but here is what I have:</p>
<p>Internet Explorer has 5 different security zones be default: Local Machine Zone, Intranet, Internet, Trusted, and Restricted
These are determined in urlmon.dll (Url Moniker)
More information here: <a href="http://msdn.mi... | <p>Not sure what the confusion is. Sites on your intranet are in the intranet zone, web sites are in the internet zone, and sites on your computer are in the local zone, unless you've specifically overridden something in the browser's preferences.</p>
| 4,326 |
<p>I am trying to build an iPhone web application using ASP.NET. The page is dynamically rendered once for each visitor. At this point the page can be bookmarked and it will never change again for that visitor. For this reason it should be cached locally from that point on so the application will run if referenced fro... | <p>I answered your previous question related to this, but it was not clear from that question that you were trying to cache dynamic content. The cache manifest is for getting static content you want for offline web apps to work.</p>
<p>I am not sure you can do what you want. Do you want the app to be able to function ... | <p>It could be to do with the size of the output. </p>
<p>I can't talk from any serious experience in tweaking things specifically for an iphone, but there is an intersting read from the YUI team here: <a href="http://yuiblog.com/blog/2008/02/06/iphone-cacheability/" rel="nofollow noreferrer">http://yuiblog.com/blog/... | 34,433 |
<p>In <em>StackOverflow podcast no. 19</em>, Joe describe Fogcreek's decision to have <strong>one database PER client</strong> instead of <strong>one database for ALL clients</strong>. That kinda sets me thinking about the following.</p>
<ol>
<li>Assuming I have <strong>1000 users</strong>. </li>
<li>Each user has <st... | <p>I imagine the answer depends on your choice of DBMS. With Oracle, for example, 1 big database would definitely be preferable, in fact 1000 identical databases would be condsidered absurd and unmanageable. </p>
<p>Also, would you never have a need to run queries across users? e.g. find the user with the most prod... | <p>You should have user and/or client as part of the PK in most cases, so your performance in the multi-tenant scenario should not be impacted much differently from the single-tenant case.</p>
| 23,032 |
<p>Other than unrolling it and measuring it, is there a method for telling how much filament is left on a spool, for example calculating a length bases on weight or number of turns left on the spook?</p>
<p>Is it possible to extract the amount of filament used from the printer's firmware?</p>
| <p>If you have an empty spool of the same brand, you could weigh the empty spool and the one you're trying to "measure" to get an approximate weight of the remaining filament. Divide by the (presumably available from manufacturer) weight per meter to get a rough length in meters, if that's more useful to you... | <p>Besides using the window on a spool that estimates the amount of filament left, I've used large calipers to measure the diameter of an empty spool and the diameter of the filament left on the spool.</p>
| 2,109 |
<p>I'm using a C# MailMessage to attach a wave file (8K) to an email message. I'd like to provide a player within the body of that email message that will play that wave file if the user chooses to do so. I've tried using the embedded <object> version of WMP, and a cid: reference to the file, but Outlook 2003 r... | <p>If it don't support objects tags, then try the Embed tag instead:</p>
<p><a href="http://www.mioplanet.com/rsc/embed_mediaplayer.htm" rel="nofollow noreferrer">http://www.mioplanet.com/rsc/embed_mediaplayer.htm</a></p>
<p>I don't know it if works, but it is worth a shot :)</p>
| <p>I would try using the <a href="http://www.htmlcodetutorial.com/embeddedobjects/_EMBED.html" rel="nofollow noreferrer">EMBED</a> tag. I'm not too surprised that OBJECT doesn't work, as invoking an ActiveX control is a potential "security hole" of sorts in the email system. I'm not sure that EMBED would work either ... | 9,980 |
<p>Clearly the following is incorrect.</p>
<pre><code>INSERT INTO `aTable` (`A`,`B`) VALUES((SELECT MAX(`A`) FROM `aTable`)*2),'name');
</code></pre>
<p>I get the value:</p>
<p>SQL query: </p>
<pre><code>INSERT INTO `aTable` (`A`, `B` )
VALUES
(
(
SELECT MAX(`A`)
FROM `aTable`
) *2
, 'name'
)
</code></p... | <p>try:</p>
<pre><code>insert into aTable select max(a)^2, 'name' from aTable;
</code></pre>
<p>or</p>
<pre><code>insert into aTable select max(a)^2, 'name' from aTable group by B;
</code></pre>
<p>If you need a join, you can do this:</p>
<pre><code>insert into aTable select max(a)^2, 'name' from aTable, bTable;
<... | <p>as soon as the Select is correct you can do this.</p>
| 25,140 |
<p>I have this query statement and want to only get records that has a certain column empty (<code>volunteers_2009.venue_id</code>)</p>
<p>Table is <code>volunteers_2009</code>, column I am looking to see if it is empty: <code>venue_id</code></p>
<p>Here is the current query:</p>
<pre><code>SELECT volunteers_2009.id... | <p>The WHERE clause is out of order in your 2nd query. It must go before the ORDER BY clause.</p>
<p>Also, I don't imagine you have any venues with an empty id. Perhaps what you really want is this:</p>
<pre><code>SELECT volunteers_2009.id, volunteers_2009.comments,
volunteers_2009.choice1, volunteers_2009.cho... | <p>By empty do you mean null? If the <code>venue_id</code> field can contain nulls then you can compare using the <code>is</code> operator like this:</p>
<pre><code>WHERE volunteers_2009.venue_id is null
</code></pre>
| 36,364 |
<p>Is there any performance reason to declare method parameters final in Java?</p>
<p>As in:</p>
<pre><code>public void foo(int bar) { ... }
</code></pre>
<p>Versus:</p>
<pre><code>public void foo(final int bar) { ... }
</code></pre>
<p>Assuming that <code>bar</code> is only read and never modified in <code>foo()<... | <p>The final keyword does not appear in the class file for local variables and parameters, thus it cannot impact the runtime performance. It's only use is to clarify the coders intent that the variable not be changed (which many consider dubious reason for its usage), and dealing with anonymous inner classes.</p>
<p>... | <p>Compilers that operate after class loading, such as JIT compilers, can take advantage of final methods. Consequently, methods declared final could have some performance benefit. </p>
<p><a href="http://www.javaperformancetuning.com/tips/final.shtml" rel="nofollow noreferrer">http://www.javaperformancetuning.com/tip... | 33,450 |
<p>Is it possible to get notified (without polling, but via an event) when a drive letter becomes accessible. For example if you have an external hard drive that always appears as drive F - is it possible to have an event raised when that is connected and F becomes accessible?</p>
| <pre><code>use POSIX qw(strftime);
print strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())) . "\n";
</code></pre>
| <p>Just using <code>POSIX::strftime()</code> has issues that have already been pointed out in other answers and comments on them:</p>
<ul>
<li>It will not work with MS-DOS aka Windows which produces strings like "W. Europe Standard Time" instead of "+0200" as required by <a href="https://www.rfc-edi... | 20,742 |
<p>In Delphi, the application's main help file is assigned through the TApplication.HelpFile property. All calls to the application's help system then use this property (in conjunction with CurrentHelpFile) to determine the help file to which help calls should be routed.</p>
<p>In addition to TApplication.HelpFile, ea... | <p>Assuming you have two help files called "Help File 1.chm" and "Help File 2.chm" and you are opening these help files from your Delphi code.</p>
<p>To open Help File 1, the following code will work:</p>
<pre><code>procedure TForm1.Button1Click(Sender: TObject);
begin
Application.HelpFile := 'Help File 1.chm';
A... | <p>Inexperienced with help files here, and even moreso with Vista, but I can offer you a possible workaround...</p>
<p>Build a second application whose only job is to open a help file. You can pass the help file name as a command line argument.</p>
<p>You can easily check from your main application whether this help ... | 10,683 |
<p>I have used extension methods to extend html helpers to make an RSS repeater:</p>
<pre><code> public static string RSSRepeater(this HtmlHelper html, IEnumerable<IRSSable> rss)
{
string result="";
foreach (IRSSable item in rss)
{
result += "<item>" + item.GetRS... | <p>Ahh... try:</p>
<pre><code> public static string RSSRepeater<T>(this HtmlHelper html, IEnumerable<T> rss)
where T : IRSSable
{
...
}
</code></pre>
<p>This then should allow you to pass any sequence of things that implement <code>IRSSable</code> - and the generic type inference should mean y... | <p>Try this:</p>
<pre><code><%=Html.RSSRepeater(ViewData.Model.GetIssues(null, null, "").Cast<IRSSable>()) %>
</code></pre>
| 42,166 |
<p>I'm working on a client-server solution that uses .NET 2.0 Remoting (server activation, binary formatting over TCP channel, Vista Ultimate) for communication purposes. Currently I'm profiling the application and run everything on the same machine. I noticed that if I start the application, everything works just fine... | <p>Use some network monitoring tool like <a href="http://www.wireshark.org/" rel="nofollow noreferrer">Wireshark</a> to see if your problem is network related or server sync related.</p>
<p>If it proves that it is not a network issue, then try to attach a simple custom sync in the chain (just before the channel) to lo... | <p>Never. Are you doing something that's causing extra instances of your remoting layer to be registered/instantiated??</p>
| 43,295 |
<p>I've been trying to install <a href="http://thoughtbot.com/projects/shoulda" rel="nofollow noreferrer">Shoulda</a></p>
<pre><code>script/plugin install git://github.com/thoughtbot/shoulda.git
</code></pre>
<p>but all I get is:</p>
<pre><code>removing: C:/Documents and Settings/Danny/My Documents/Projects/Ruby On ... | <p>Do you have git installed? If you don't, it will just not work. Rails assumes git is installed and can be found in your PATH.</p>
<p>You can get Git for Windows <a href="http://code.google.com/p/msysgit/downloads/list" rel="nofollow noreferrer">here</a>.</p>
| <p>For folks still having this problem, as of Rails 2.3.5 you are likely to get an error still, as recent Ruby/Win32 builds are done with MinGW. However, the problem's been patched between there and 2.3.8, and so long as you have msysgit installed at this point, it should Just Work.</p>
<p>If you're not comfortable wi... | 28,647 |
<p>Hey folks - I'm writing a pretty simple iPhone application. The data comes from a plist file (NSDictionary basically), that I'm trying to load into a singleton class and use across my various view controllers to access the data.</p>
<p>Here's the implementation for my singleton (heavily modeled after <a href="http... | <p>In your <code>-init</code> method you are directly accessing your instance variables and you are not retaining them. They're getting deallocated and their memory is being used up by other objects later on in your application's lifetime.</p>
<p>Either retain your objects that you're creating there or use the non-con... | <blockquote>
<p>Hi, Can you tell me what is the advantage, when we assign synthesized variables through 'self'? Thank you shiva</p>
</blockquote>
<p>the values are set through the setter; it releases the previous value and retains the one you assign.</p>
| 46,326 |
<p>What are the typical average bytes-per-character rates for different unicode encodings in different languages?</p>
<p>E.g. if I wanted the smallest number of bytes to encode some english text, then on average UTF-8 would be 1-byte per character and UTF-16 would be 2 so I'd pick UTF-8.</p>
<p>If I wanted some Korea... | <p>For any given language, your bytes-per-character rates are fairly constant, because most languages are allocated to contiguous code pages. The big exception is accented Latin characters, which are allocated higher in the code space than the unaccented forms. I don't have hard numbers for these.</p>
<p>For languages... | <p>UTF-8</p>
<p>There is a very good article about unicode on JoelOnSoftware:</p>
<p><a href="http://www.joelonsoftware.com/printerFriendly/articles/Unicode.html" rel="nofollow noreferrer">The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)</a>... | 11,758 |
<p>I see plans for various spool holders, either for PLA in the open, or for whatever filament in a dry box, that use 608 bearings. Elsewhere, I see warnings not to oil your filament to make it go through the extruder better, because problems going through mean something else is wrong, and it's better to fix the other ... | <p>Typically, oiling a filament would mean to use a vegetable based or non-petroleum type of lubricant, possibly even PTFE (teflon) or silicone. Those materials will not damage PLA filament. </p>
<p>Oiling filament is not the haphazard application of lubricant, however. One drop on the filament sponge guide will last ... | <p>Typically, oiling a filament would mean to use a vegetable based or non-petroleum type of lubricant, possibly even PTFE (teflon) or silicone. Those materials will not damage PLA filament. </p>
<p>Oiling filament is not the haphazard application of lubricant, however. One drop on the filament sponge guide will last ... | 988 |
<p>Could someone show me a regular expression that would look through this document and select the href value of every href that has <code>RELATION_ID</code> on the end of it?
Then if it does, I have to get the Id that is before the question mark (example <code>href="dctm://ISDOFSDdev/</code>37004e1f800021f3<code>?DMS_... | <p>You can use this regex expression:</p>
<pre><code>[a-fA-F0-9]+(?=\?DMS_OBJECT_SPEC=RELATION_ID)
</code></pre>
<p>which matches the the hex number immediately before the query string. </p>
<p>I'd also suggest using XPath to do this over regex.</p>
| <p>First find the href attribute using this regex:<br>
<code>href="[^=]*=RELATION_ID"</code></p>
<p>Once you have a collection of those attributes, use the following regex to find the ID:<br>
<code>dctm:[^?]*</code></p>
<p><strong><em>Explanation of first regex</em></strong>:</p>
<p><code>href="</code> : Match the c... | 37,985 |
<p>I have a number of solutions with a large number of projects in them. I would like to be able to define global settings for the solution that are used by all projects. For example an include directory. I want to be able to change the include directory in one place for all projects in the solutions. </p>
<p>When I s... | <p>We use property sheets to accomplish this. A single property sheet can be assigned to all the projects in the solution. From then on you can change a setting in that one property sheet and it will affect all the projects.</p>
<p>Advanced tip: We actually use multiple property sheets, (e.g. one for release target ty... | <p>I searched exactly the same thing some time ago but didn't find exactly what i wanted.</p>
<p>The only thing that might be close to this feature are <a href="http://msdn.microsoft.com/en-us/library/3z7t21ew(VS.80).aspx" rel="nofollow noreferrer">Property Sheets</a>. That's not exactly global as it's owned by a proj... | 49,366 |
<p>I'm looking for:</p>
<ul>
<li>documentation</li>
<li>blogs</li>
<li>books</li>
<li>ready-to-use pre-configured slice images</li>
<li>services</li>
<li>wrappers</li>
<li>libraries</li>
<li>tutorials</li>
</ul>
<p>...anything that would make it easier to start using EC2 to host a Rails application.</p>
| <p>There is a Rails image for EC2 at <a href="http://ec2onrails.rubyforge.org/" rel="nofollow noreferrer">http://ec2onrails.rubyforge.org/</a></p>
| <p>Here's a service you might want to try out to deploy your Rails app using EC2: <a href="http://www.mor.ph" rel="nofollow noreferrer">Morph AppSpace</a></p>
| 17,640 |
<p>My workplace has sales people using a 3rd party desktop application that connects directly the a Sql Server and the software is leaving hundreds of sleeping connections for each user. Is there anyway to clear these connection programmatically?</p>
| <p>Which version of SQL Server do you run? You can write a stored procedure to do this, looking at the data from sp_who and then making some guess about the last activity. There's a "LastBatch" column that does the last time something was submitted by this user. I'd say if that is over an hour old (or whatever interval... | <p>But, instead of killing these processes manually, shouldn't there be a way to avoid these? I have the same problem in a project</p>
<p>In our Web application, we are performing some updates using a Web service (i.e. a program calls a webservice method. The method opens a connection, does an update, commits and clos... | 10,731 |
<p>I'm currently working on a large project, where many developers worked over time and the code was terrible. After many refactorings we now arrived a point, where the code is ok. Now I'm thinking what "ok" means - probably for everyone something different.</p>
<p>Do you think it's possible to specify "ok"? What is i... | <p>I think for any non-trival project you should have coding guidelines in place (style, comments, etc.) and metrics to know if they are being followed or not. The list you've outlined is a very good start.</p>
| <p>There are so many things that can be said to be attributes of ok/good code.</p>
<ul>
<li>no errors or warnings when compiled</li>
</ul>
<p>there are also a few other threads on SO about this topic...</p>
| 38,304 |
<p>I would like to make a simple web app that displays 20 or so images to users and lets them manually sort the images from favorite to least favorite, either by dragging or by using some form of up/down controls, and then submit this ordering. Are there existing tools, either in Javascript or Silverlight, that make th... | <p>jQuery UI has <a href="http://dev.jquery.com/view/tags/ui/latest/demos/functional/#ui.sortable" rel="nofollow noreferrer">sortables</a>.</p>
| <p>I see you tagged using Silverlight, so I assume you are using ASP.NET technologies. You could use some variation of the ReorderList in the Ajax Control ToolKit:</p>
<p><a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ReorderList/ReorderList.aspx" rel="nofollow noreferrer">http://www.asp.net/AJAX/AjaxCont... | 45,034 |
<p>I use my mobile phone for connection to the internet on my laptop, I also have a wired connection to a LAN which doesn't have internet conectivity, it just has our TFS server on it.</p>
<p>The problem is that I can't use the internet (from the phone) with the LAN cable plugged in. Is there a way to set the default ... | <p>There's many OS specific ways to force routing over specific interfaces. What OS are you using? XP? Vista? *nix?</p>
<p>The simplest way is to configure your network card with a static IP and NO GATEWAY, the only gateway (ie. internet access) your laptop will find is then via the mobile.</p>
<p>The disadvantage of... | <p>You can actually configure what you want to be the default gateway globally using the "routes" command as described here: <a href="https://stackoverflow.com/questions/17785/default-internet-connection-on-dual-lan-workstation">Default Internet connection on Dual LAN Workstation</a></p>
<p>I admit though, on windows ... | 4,957 |
<p>I have a ListBox which until recently was displaying a flat list of items. I was able to use myList.ItemContainerGenerator.ConainerFromItem(thing) to retrieve the ListBoxItem hosting "thing" in the list.</p>
<p>This week I've modified the ListBox slightly in that the CollectionViewSource that it binds to for its it... | <p>You <strong>have</strong> to listen and react to the <code>ItemsGenerator.StatusChanged</code> Event and wait until the ItemContainers are generated before you can access them with ContainerFromElement.</p>
<hr>
<p>Searching further, I've found <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8be8... | <p>Try parsing the VisualTree up from the 'thing' until you reach a ListBoxItem type</p>
| 19,983 |
<p>I am confused by J2ee webservers !! I downloaded a free Glassfish server from sun, then as I am an Oracle developer downloaded the latest JDeveloper, which comes with a Weblogic server from BEa/Oracle. One is free the other costs $1000s. What is the real difference.</p>
<p>I want to write a SOAP interface to my O... | <p>Personally, if you are looking for an open source J2EE app server, I'd tend to go with JBoss if only because it has a much larger market share, making it a lot more likely that you are going to be able to find people that can answer questions or that have done some particular task and have posted instructions.</p>
... | <p>Though this is a bit older question, thought of sharing some details.</p>
<p><b>Glassfish</b> server comes as a bundle with the Java enterprise edition. You can do most of generic java related developments using this. <br><br>
However, <b>WebLogic server</b> bundled with the Oracle enterprise application suit and i... | 35,804 |
<p>Is there a simple way to duplicate all child components under parent component, including their published properties?</p>
<p>For example:</p>
<ul>
<li>TPanel
<ul>
<li>TLabel</li>
<li>TEdit</li>
<li>TListView</li>
<li>TSpecialClassX</li>
</ul></li>
</ul>
<p>Of course the most important factor, it should duplicate... | <p>have a read of this page</p>
<p><a href="http://www.blong.com/Conferences/BorConUK98/DelphiRTTI/CB140.htm" rel="nofollow noreferrer"><strong>Run-Time Type Information In Delphi - Can It Do Anything For You?</strong></a></p>
<p>Noting the section <a href="http://www.blong.com/Conferences/BorConUK98/DelphiRTTI/CB140... | <p>It's actually fairly easy to duplicate existing components at runtime. The difficult part is to copy all of their published properties to the new (duplicated) objects.</p>
<p>I'm sorry, but my code example is in C++Builder. The VCL is the same, just a different language. It shouldn't be too much trouble to trans... | 29,569 |
<p>I have the following code in my file to load a div with HTML from an AJAX call:</p>
<pre><code>$('#searchButton').click( function() {
$('#inquiry').load('/search.php?pid=' + $('#searchValue').val());
});
</code></pre>
<p>This works fine in Firefox and Google Chrome, but whenever I do the search in IE I get red... | <p>IE Handles default events differently (also beware of hitting enter in a text field). IE is causing some default event handler to fire. If searchButton is a link with HREF of "" it will reload the current page. You can try to set the href to "javascript:void(0)" or do something like:</p>
<pre><code>$('#search... | <p>set the action attribute of the form to a javascript function (e.g. your search handling function) or "return false"</p>
<p>MSIE is firing the form action when you hit enter</p>
| 21,574 |
<p>Does anyone know how to setup <a href="http://www.selenic.com/mercurial/wiki/index.cgi/Mercurial" rel="noreferrer">Mercurial</a> to use <a href="http://www.perforce.com/perforce/products/merge.html" rel="noreferrer">p4merge</a> as the merge/diff tool on OS X 10.5?</p>
| <p><strong>This will work for merging:</strong></p>
<p>Place this into your <code>~/.hgrc</code> (or, optionally, your <code>Mercurial.ini</code> on Windows):</p>
<pre><code>[merge-tools]
p4.priority = 100
p4.premerge = True # change this to False if you're don't trust hg's internal merge
p4.executable = /Applicatio... | <p>I'm guessing there's a CLI tool for p4merge (which I know nothing about).</p>
<p>I wrote a blog post about using Changes.app, and some other GUI tools with Mercurial: <a href="http://schinckel.net/2008/04/26/mercurial-with-os-x-gui-tools/" rel="nofollow noreferrer">Using Mercurial with GUI Tools.</a></p>
<p>Basica... | 6,459 |
<p>how to send rich text message in system.net.mail need code for send a mail as html</p>
| <pre><code>System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
mm.Body = "<html>...</html>";
mm.IsBodyHtml = true;
</code></pre>
| <p>You should be aware, that not every person/mailclient can present a message formatted in HTML. If you rely on layout to make your message clear this can be a problem. </p>
| 16,712 |
<p>I'm sure I once found a shell command which could print the common lines from two or more files. What is its name?</p>
<p>It was much simpler than <a href="https://linux.die.net/man/1/diff" rel="noreferrer"><code>diff</code></a>.</p>
| <p>The command you are seeking is <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/comm.html" rel="noreferrer"><code>comm</code></a>. eg:-</p>
<pre><code>comm -12 1.sorted.txt 2.sorted.txt
</code></pre>
<p>Here:</p>
<p><strong>-1</strong> : suppress column 1 (lines unique to 1.sorted.txt)</p>
<p><... | <pre><code>rm file3.txt
cat file1.out | while read line1
do
cat file2.out | while read line2
do
if [[ $line1 == $line2 ]]; then
echo $line1 >>file3.out
fi
done
done
</code></pre>
<p>This should do it.</p>
| 48,881 |
<p>I am working on a J2ME project that spawns worker threads for numerous tasks such as downloading HTTP content. The basic thread layout is similar to most java apps--there is a main UI thread and worker threads spawned to do stuff behind the scenes. My question is what is the best way to handle exceptions that occur ... | <p>You should NOT jam UI code into your workers!</p>
<pre><code>/**
* TWO CHOICES:
* - Monitor your threads and report errors,
* - setup a callback to do something.
*/
public class ThreadExceptions {
/** Demo of {@link RunnableCatch} */
public static void main(String[] argv) throws InterruptedException {
... | <p>Another option other than what Stuph has given is to set exceptions in the thread local. If another exception happens before that exception is cleared then an assert occurs. That at least gives someone a chance to notice the exception and process it.</p>
| 37,446 |
<p>I think many developers know that uncomfortable feeling when users tell them that <em>"The application is slow (again)."</em></p>
<p>In a complex web application there can be <strong>many possible reasons</strong> for a degradation in (perceived) performance: slow database response, bandwidth issues, bad caching et... | <p>I think the category of software you're looking for is ".net profiler" or ".net tracer". One such tool that you might consider is JetBrains' <a href="http://www.jetbrains.com/profiler/" rel="noreferrer">dotTrace</a>. It gives you runtime stack traces and an array of counters that indicate possible bottlenecks.</p>
| <p>I followed <a href="https://stackoverflow.com/questions/259105/tools-and-methods-for-live-monitoring-aspnet-web-applications#259242">urig's advice</a> and found <a href="http://www.gurock.com/products/smartinspect/" rel="nofollow noreferrer">this software called SmartInspect</a>.</p>
<p>Does anybody know this loggi... | 32,363 |
<p>Does anybody know why the following code only has effect in FF?</p>
<pre><code>$(document).ready(function() {
$('#powerSearchSubmitButton').click(function() {
startLoad();
});
});
function startLoad() {
$('.message').each(function(i) {
$(this).animate({ opacity: 0 }, 500);
... | <p>You can't do operations on the UI from a different thread - but you could make GetFromServer and GetFromPC <em>fetch</em> the data on the other thread and then call Control.Invoke to get back to the UI thread to update the treeview.</p>
<p>See <a href="http://pobox.com/~skeet/csharp/threads/winforms.shtml" rel="nof... | <p>For any single operation that only fetches data and then updates GUI and then its done till next time someone invokes it,
use BackgroundWorker.</p>
<p>Its a class that has simplified thread coding for you. That way you just write the code for fetching data in one function, and one method that displays the fetched d... | 43,697 |
<p>I am creating my application using Django, and am wondering how I can make Django use my CSS file? What settings do I need to do to make Django see the css file?</p>
<p>NB: On a local machine</p>
| <p>If you're using the development server follow the <a href="http://docs.djangoproject.com/en/dev/howto/static-files/" rel="nofollow noreferrer">django project's how-to guide for managing static files</a> to setup your URL's, then reference you media files in the template -- say, an image inside an image folder from <... | <p>Well the easiest way to use css with django, is to add it to your templates as static-files.</p>
<p>But it's a bit like ajax, I didn't find anything that tells how to include it in a standard way.</p>
<p>There is a <a href="http://github.com/dziegler/django-css" rel="nofollow noreferrer">css-compressor</a> module ... | 32,656 |
<p>I'm creating a batch file to make multiple directories from a list in a text file
however after the directory is listed sometimes a filename is as well. Is there an easy way to have it ignore all data after the last \ on a line?</p>
| <p>Define lightweight? (What DOES that mean anyway nowadays??)</p>
<p>With JAX-WS/Metro you need to simply make a boiler plate change to the web.xml, and then annotate a POJO with @WebService, and, tada, instant web service.</p>
<p>The distribution has several jars in it (around a dozen I think, but they're all in th... | <p>Check out <a href="http://xfire.codehaus.org/" rel="nofollow noreferrer">XFire</a>, which apparently has morphed into <a href="http://cxf.apache.org/" rel="nofollow noreferrer">CXF</a>.</p>
<p>They have a <a href="http://cwiki.apache.org/CXF20DOC/index.html" rel="nofollow noreferrer">user guide</a> to get you start... | 35,722 |
<p>I recently started building a console version of a web application. I copied my custom sections from my web.config. to my app.config. When I go to get config information i get this error:</p>
<p>An error occurred creating the configuration section handler for x/y: Could not load type 'x' from assembly 'System.Confi... | <p>it sounds like your config-section handler is not defined</p>
<pre><code><configSection>
<section
name="YOUR_CLASS_NAME_HERE"
type="YOUR.NAMESPACE.CLASSNAME, YOUR.NAMESPACE, Version=1.1.0.0, Culture=neutral, PublicKeyToken=PUBLIC_TOKEN_ID_FROM_ASSEMBLY"
allowLocation... | <p>If you want a custom config handler you have to define the class and reference it as shown by Steven Lowe. You can inherit from predefined handlers, or you can just use the value/key pair that is offered in appSetting section as you noted.</p>
| 39,436 |
<p>How does one preserve the settings in the Open Dialog box? For example, I would the Open Dialog to remember that I chose the Details view and sorted by date modified.</p>
| <p>Microsoft didn't see fit to give us any documented way of doing this, but some people have figured out bits of the puzzle. This link shows how to set the view, but not how to get the current setting:</p>
<p><a href="http://msdn.microsoft.com/en-us/magazine/cc164009.aspx" rel="nofollow noreferrer">http://msdn.micro... | <p>I'm not quite sure about this about isn't it an OS setting. If the user choose their Folder Preferences such as then Windows will remember or not. In this case from accessibility and usability point of view this is User's preferences.</p>
| 40,752 |
<p>I am wondering - What's the most effective way of parsing something like:</p>
<pre><code>{{HEADER}}
Hello my name is {{NAME}}
{{#CONTENT}}
This is the content ...
{{#PERSONS}}
<p>My name is {{NAME}}.</p>
{{/PERSONS}}
{{/CONTENT}}
{{FOOTER}}
</code></pre>
<p>Of course this is ... | <p>Is the expected output of this something like: </p>
<p>This is a header</p>
<p>Hello my name is David</p>
<pre><code>This is the content ...
My name is Heino.
My name is Sebastian.
</code></pre>
<p>This is the footer</p>
<hr>
<p>How are you managing the relationship of nested arrays in the hash map to repeat... | <p>You would bet better off using something with an existing parser like XML or JSON so you don't have to write your own parser, and so that others can easily write documents for your parser without needing specialized tools. However, if you want to write your own parser, you probably want to look into using <a href="h... | 26,208 |
<p>I have an ant build that makes directories, calls javac and all the regular stuff. The issue I am having is that when I try to do a clean (delete all the stuff that was generated) the delete task reports that is was unable to delete some files. When I try to delete them manually it works just fine. The files are app... | <p>I encountered this problem once.
It was because the file i tried to delete was a part of a <strong>classpath</strong> for another task.</p>
| <p>I've been having this problem a lot lately and it's random. One time it works, the next time it doesn't work. I'm using NetBeans (in case that matters) and I've added a lot of extra tasks to build.xml. I was having this problem in the -post-jar task. It would happen when I call unjar on the file, then delete. I susp... | 10,295 |
<p>I'm trying to design a model for a application allowing 2 people to bet with each other (I know, sounds stupid...). What I'm wondering about is how to connect the bet with users. The structure is like this</p>
<pre><code>|-------------| |----------|
| Bet | | User |
| BetUser1 | |--... | <p>I would probably add a third model to represent a specific wager someone has placed, as it is conceivable that more than two people could enter into a bet. It would look something like this:</p>
<pre><code>USER WAGER BET
User (FK(User)) Description
Bet (FK(Bet)) ... | <p>What you need is a Many-to-Many relation with extra data (e.g. the amount on the wager, the time entered,...)</p>
<p>There is a <a href="http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships" rel="nofollow noreferrer">chaper</a> on this in the excellent Django docs on wri... | 31,572 |
<p><a href="http://localhost:50034/Admin/Delete/723" rel="nofollow noreferrer">http://localhost:50034/Admin/Delete/723</a></p>
<p>Always needs this parameter to perform the action, however, if you go to the URL without the parameter, an exception occurs. How do you handle this and redirect back to the main page withou... | <p>I am not sure what you mean, do you mean that the url <a href="http://localhost:50034/Admin/Delete/" rel="noreferrer">http://localhost:50034/Admin/Delete/</a> is generating an exception? </p>
<p>Try setting the id parameter as nullable, like this:</p>
<pre><code>public class MyController : Controller
{
public vo... | <p>Assuming that you are using the default routing rules:</p>
<pre><code> routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
</code></pre>
<p>then create your Delete method... | 34,287 |
<p>This is a call for suggestions and even possible solutions. I haven't been at a company that really seemed to get credential management 'right'.</p>
<p>I've seen excel/word documents and even post-it note 'solutions'.</p>
<p>But my main question is what is the right way to do it?</p>
<p>I have initially thought i... | <p>The company I work for sells data center automation tools to assist with exactly this. I'm not going to say who I work for, nor how much it costs (but it's distinctly NOT cheap).</p>
<p>The basic approach we take with that tool (used by hundreds of large companies) is to integrate LDAP/AD authentication against the... | <p>To answer your question: very poorly.</p>
<p>We're looking to standardize on public keys for password-less authentication and shared group/passwd files. Our testing looks good so far, but we're still trying to smooth over some rough edges.</p>
| 9,433 |
<p>I would like to redirect/rewrite this two kinds of URLs:</p>
<ul>
<li>mydomain.com -> newdomain.com</li>
<li>mydomain.com/specificPage -> newdomain.com/newSpecificPage</li>
<li>mydomain.com/anyOtherPage -> mydomain.com/anyOtherPage (no redirect here)</li>
</ul>
<p>So I just want to redirect the root domain to a ne... | <p>Have you looked into <a href="http://www.jboss.org/jbossweb/modules/rewrite.html" rel="noreferrer">http://www.jboss.org/jbossweb/modules/rewrite.html</a>? It looks like what you're looking for, and it's pretty similar to Mod_rewrite for Apache. </p>
| <p>If you are routing through apache at all it is possible to use mod_rewrite; you just need to be careful as to where you declare the rewrite rules. Directory configs and .htaccess files won't work; you need it as a global configuration for the entire host. Similar <a href="https://serverfault.com/questions/76402/jbos... | 11,635 |
<p>To make it short: hibernate doesn't support projections and query by example? I found this post:</p>
<p>The code is this:</p>
<pre><code>User usr = new User();
usr.setCity = 'TEST';
getCurrentSession().createCriteria(User.class)
.setProjection( Projections.distinct( Projections.projectionList()
.add( Projections.p... | <p>The problem seems to happen when you have an alias the same name as the objects property. Hibernate seems to pick up the alias and use it in the sql. I found this documented <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-3371;jsessionid=aLJbC8zJhKhanJbr49?page=com.atlassian.jira.plugin.system... | <p>I do not really think so, what I can find is the word "this." causes the hibernate not to include any restrictions in its query, which means it got all the records lists. About the hibernate bug that was reported, I can see it's reported as fixed but I totally failed to download the Patch.</p>
| 11,016 |
<p>The subject says it all - normally easy and cross platform way is to poll, intelligently. But every OS has some means to notify without polling. Is it possible in a reasonably cross platform way? (I only really care about Windows and Linux, but I use mac, so I thought posix may help?)</p>
| <p>Linux users can use <a href="http://en.wikipedia.org/wiki/Inotify" rel="noreferrer">inotify</a></p>
<blockquote>
<p>inotify is a Linux kernel subsystem
that provides file system event
notification.</p>
</blockquote>
<p>Some goodies for Windows fellows:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/l... | <p>I believe OS X now has appropriate hooks/callbacks because they were needed for Spotlight indexing. </p>
<p>On linux you'll have the additional trouble that there are multiple file systems commonly used. If you need the functionality for only a limited amount of files/directories, I'd try about actively looking for... | 8,641 |
<p>I need an associative container that makes me index a certain object through a string, but that also keeps the order of insertion, so I can look for a specific object by its name or just iterate on it and retrieve objects in the same order I inserted them.</p>
<p>I think this <a href="http://www.ddj.com/cpp/1844062... | <p>You've asked for the canonical reason why Boost::MultiIndex was made: list insertion order with fast lookup by key. <a href="http://www.boost.org/doc/libs/1_36_0/libs/multi_index/doc/tutorial/basics.html#list_fast_lookup" rel="nofollow noreferrer">Boost MultiIndex tutorial: list fast lookup</a></p>
| <p>@wesc: STL has std::map... so what's the difference with unordered_map? I don't think STL would implement twice the same thing and call it differently.</p>
| 5,655 |
<p>I need to edit the web.config file on a live Sharepoint environment, but I'm unsure what will happen if I do (I want to output custom errors).</p>
<p>Will this cause the IIS6 worker process to recycle?</p>
<p>Will active users lose their session state because of this?</p>
<p>Or can I safely edit the file?</p>
| <p>The application pool will restart and session state will be lost. Imagine each ASP.NET application (as defined in IIS) is a program on the desktop. Saving web.config will do something similar to closing the program and reopening it.</p>
| <p>As already mentioned by some people: the application pool of the site in IIS will restart (this typically takes a couple of seconds). As a result the next page request(s) will be slower (since nothing will be cached anymore). Also the session state of the users will be lost; BUT in WSS session state is not used by d... | 21,497 |
<p>I'm building a quick csv from a mysql table with a query like:</p>
<pre><code>select DATE(date),count(date) from table group by DATE(date) order by date asc;
</code></pre>
<p>and just dumping them to a file in perl over a:</p>
<pre><code>while(my($date,$sum) = $sth->fetchrow) {
print CSV "$date,$sum\n"
}
<... | <p>When you need something like that on server side, you usually create a table which contains all possible dates between two points in time, and then left join this table with query results. Something like this:</p>
<pre class="lang-sql prettyprint-override"><code>create procedure sp1(d1 date, d2 date)
declare d da... | <p>I don't know if this would work, but how about if you created a new table which contained all the possible dates (that might be the problem with this idea, if the range of dates is going to change unpredictably...) and then do a left join on the two tables? I guess it's a crazy solution if there are a vast number of... | 10,140 |
<p>I'm currently playing with the Silverlight(Beta 2) Datagrid control. Before I wired up the SelectionChanged event, the grid would sort perfectly by clicking on the header. Now, when the grid is clicked, it will fire the SelectionChanged event when I click the header to sort. Is there any way around this?</p>
<p>... | <p>That looks like a Silverlight bug to me. I've just tried it and what's happening on my end is that the <strong>SelectionChanged</strong> event fires twice when you click the column header and to make matters worse, the index of the selected item doesn't stay synched with the currently selected item.</p>
<p>I'd sugg... | <p>This worked, but now if I sort twice, on the first one it sorts, and then does the popup as the first selected item of the grid . If I close the popup grid, and then try to sort a second time, it stack overflows, and crashes firefox out.</p>
<p>I'm thinking I may need to rethink working in silverlight until the sy... | 10,011 |
<p>Is it a good idea (from a design POV) to nest constructor calls for overloaded New or Factory style methods? This is mostly for simple constructors, where each overload builds on the previous one. </p>
<pre><code>MyClass( arg1 ) {
_arg1 = arg1;
_otherField = true;
_color="Blue"
}
MyClass( arg1, ar... | <p>I think it's reasonable to chain constructors together, but I do it the other way - the version with fewer parameters calls the version with more parameters. That way it makes it very clear what's happening, and all the real "logic" (beyond the default values) is in a single place. For example:</p>
<pre><code>publi... | <p><strong>2016 Edit</strong>: Still ahead of the time, C# is radically cutting back or eliminating its records support and default constructor support for C# 7, maybe C# 8 <em>finally</em>.</p>
<p><strong>2015 Edit</strong>: I was far ahead of the time. C#6 and C#7 are removing the need for constructors. </p>
<p>If ... | 36,159 |
<p>Ok, so it's <em>almost</em> as easy as pie already. But it really should be as easier than it is.</p>
<p>I think I should be able to connect to another database just by putting a JDBC connection string into TNSNAMES. Every database vendor has a type-4 JDBC driver and there's usually a good, free alternative.</p>
<... | <p>The answer is the same as for the following questions:</p>
<ol>
<li>Why doesn't Oracle provide an efficient way of unloading data into a non-proprietary format (e.g. comma-delimited or XML)</li>
<li>Why do most Oracle non-DB products only work with the Oracle RDBMS? (without having to use Oracle Database Gateways)<... | <p>TNS is a bit of a mess, imho. It seems to behave inconsistently between different platforms, in my (admittedly limited) experience.</p>
<p>Far be it for me to defend Oracle, but I've had no problems with the JDBC thin driver. (If you read the oracle jdbc docs, they discourage you from using oci unless you have a ve... | 24,214 |
<p>I'm using Spring, but this question applies to all JSP-controller type designs.</p>
<p>The JSP page references data (using tags) which is populated by the corresponding controller. My question is, where is the appropriate place to perform formatting, in JSP or the controller?</p>
<p>So far I've been preparing the ... | <p>JSPs typically do not have a lot (or any?) code in them, so your options would be</p>
<ul>
<li>controller</li>
<li>tag libraries</li>
</ul>
<p>I would say that a tag library would probably be what you want for most cases, because typically the view is the code that cares about things like formatting.</p>
<p>If st... | <p>The way I would do it is - </p>
<p>an instance of the Person class would be the only object in the Model of the ModelAndView</p>
<p>I would move the "presentation logic" into the Person class itself. For example, </p>
<pre><code>public class Person {
public String getLocation() {
return this.latitude.... | 47,187 |
<p>I'm attempting to convert a home-grown login system to the standard asp.net login control included in .net. I want all communication on the website for a user not logged in to be in clear text, but lock everything in SSL once the user logs in - including the transmission of the username and password.</p>
<p>I had ... | <p>You're not going to be able to do what you're talking about simply, because the postback (which is what the login control uses) is going to be whatever the page's security is (SSL or non-SSL).</p>
<p>Your best bet in this scenario is to use an IFRAME which contains an HTTPS (SSL) page that just contains thelogin co... | <p>You aren't going to be able to have your site as non-SSL, with a login box on every page, and then submit the username and password via SSL. </p>
<p>The only way to really accomplish this is to use frames of some sort. This way your entire page could be non-SSL, but the login frame would have to be SSL.</p>
<p>The... | 12,176 |
<p>is there any good Ruby audio libraries that we can build upon?</p>
<p>Need to manage/edit mp3 files!!!</p>
| <p>There's an <a href="http://rubyforge.org/projects/id3lib-ruby/" rel="noreferrer">interface</a> to a C++ mp3 editor, and an active <a href="http://rubyforge.org/projects/ruby-mp3info" rel="noreferrer">pure ruby</a> project.</p>
| <p>There's also <a href="https://rubygems.org/gems/earworm" rel="nofollow noreferrer">earworm</a> and <a href="http://icanhasaudio.com/" rel="nofollow noreferrer">icanhasaudio</a> which may be interesting...</p>
| 31,427 |
<p>Does anyone know of a good Command Prompt replacement? I've tried bash/Cygwin, but that does not really meet my needs at work because it's too heavy. I'd like a function-for-function identical wrapper on cmd.exe, but with highlighting, intellisense, and (critically) a tabbed interface. Powershell is okay, but the... | <p><em>Edited</em>: I've been using <strong>ConEmu</strong> (<a href="http://conemu.github.io/" rel="noreferrer">http://conemu.github.io/</a>) for quite some time now. This one is a wrapper too, since it is not really possible to replace the Windows console without rewriting the whole command interpreter. Below the lin... | <p>Nick, I know you asked this a long while ago but I've just found it while searching for something related. I have been using <a href="http://www.promptpal.com/" rel="nofollow noreferrer">PromptPal</a> and its been great. I got it about a year ago, early 2008, and it was through this discount software thing called ... | 4,015 |
<p>JavaScript doesn't seem to have a native <code>trim()</code> method. How can I trim white spaces at the start and end of a string with JavaScript?</p>
| <p>I know this question is ancient but now, Javascript actually does have a native .trim()</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim</a></p>
| <p>Actually, with jQuery this seems to be the way:</p>
<pre><code>jQuery.trim(string)
</code></pre>
<p><a href="http://docs.jquery.com/Utilities/jQuery.trim#str" rel="nofollow noreferrer">(Reference)</a></p>
| 23,934 |
<p>I am currently working on my first website. I have no idea where to start on the CSS page, or if there are any standards that I should be following.</p>
<p>I would appreciate any links or first-hand advise.</p>
| <p>An error that beginners make quite often:</p>
<p>CSS is semantic as well. Try to express concepts, not formats. Contrived example:</p>
<h3>Wrong:</h3>
<pre><code>div.red
{
color: red;
}
</code></pre>
<p>as opposed to:</p>
<h3>Good:</h3>
<pre><code>div.error
{
color: red;
}
</code></pre>
<p>CSS should be the ... | <p>The <a href="http://www.westciv.com/style_master/academy/css_tutorial/index.html" rel="nofollow noreferrer">Complete CSS Guide on westciv.com</a> has an exhaustive amount of information on CSS. It's a great place to start diving in.</p>
| 31,000 |
<p>Is it safe to assume that two itterations over the same collection will return the objects in the same order? Obviously, it is assumed that the collection has not otherwise been changed.</p>
| <p>Short answer - yes.</p>
<p>Obviously, though, the order of the items in the collection may not be exactly as they were inserted, depending on the type of collection (a dictionary, for example).</p>
<p>But you will get the same results each time you iterate over a single, unmodified collection using a foreach loop.... | <p>I would say that for most collection it is safe to assume this. It's not beyond the realms of possibility that a certain collection could have the enumerator implemented in a non-deterministic way, but that's probably not going to happen...</p>
| 20,180 |
<p>Recently started using my kit Prusa I3 Mk3 and noticed that with large horizontal surfaces a wrinkling pattern is emerging.</p>
<p>As you can see in the image the wrinkles seem to run parallel, the surface is 10 mm above the build plate with all bridges fully supported.</p>
<p>Has anyone seen this before? All... | <p><em>Waves in printed surfaces with <a href="https://en.wikipedia.org/wiki/Fused_filament_fabrication" rel="nofollow noreferrer">FFF</a> are observed at either the bottom layer (common) or the top layer (less common).</em></p>
<h2>Waves in bottom layer</h2>
<p>Rippling/wave generation/wrinkling is a common problem fo... | <p>Might just be that you are bridging without collapsing but still have some visible sag. Things to try:</p>
<p>1) increase the support/infil density. If slic3r has a configurable setting like Cura does, you only need to increase the density for the last couple mm prior to the top layer.</p>
<p>2) increase the top... | 1,236 |
<p>I need to print a rotor for a DC motor I'm designing. In the process of testing the behaviors of the motor performances, I would need a material that will not deform at a temperature range between 100 °C to 150 °C.</p>
<p>Since I don't have a 3D printer yet, I would like to know what would be the best choice for my ... | <p>PEEK (poly ether ether ketone) has a glass transition temperature of 145 °C (293 °F).</p>
<p>Melting temperature
345 °C (653 °F)</p>
<p>Nozzle temperature
370 - 410 °C</p>
<p>Heated bed
120 - 150 °C</p>
<hr />
<p>Polycarbonate has a glass transition temperature of about 147 °C (297 °F)</p>
<hr />
<p>Polypropylen... | <p>Using an Ender 3 for high temperature materials is possible but you need to enclose it to be able to heat the air up to 100 °C.</p>
<p>It's quite involved and it would be much better, if it's something you do seldomly, to have the parts printed professionally.</p>
<p>Many thing start warping or breaking at 100 °C.</... | 1,844 |
<p>I am experiencing a crash while using the Boost.Spirit and Boost.Thread
libraries in my application. This only happens if I have used the Spirit
parser during the lifetime of the process from the main thread.</p>
<p>The crash happens at exit and appears to be related to the clean-up of
thread specific storage al... | <p>Well I found a workaround. </p>
<p>Every place I use the boost::spirit::parse call, I basically spawn a workerthread to run it, while the calling thread is blocking on a join call with the workerthread. Not ideal, but it appears to be working without any sideeffects so far.</p>
<p>Still interested in any alternati... | <p>Boost.Spirit is header-only, i.e. it does not reside in its own dll, so maybe it is not the unloading order of dlls but rather a different issue.</p>
<p>Make sure the instance containing your spirit parser is deleted and doesn't leave dangling pointers.</p>
| 39,195 |
<p>I'm making a simple scheduler with C# in .Net. All it does is execute a simple select statement on a table in a SQL Server DB once per minute (this does not need to scale or anything... the db does not have a high load). Here is my proposed implementation:</p>
<pre><code>static void Main(string[] args)
{
whil... | <p>While it is technically legal you are probably better of using a timer. They are not much more code to set up and you can let the runtime take care of spawning new threads. If you ever needed to use this again in another program it would also create a performance bottleneck where a timer would not.</p>
<p>The tim... | <p>Close.</p>
<ol>
<li>This will run every (1 minute + time to call proc). Maybe that's OK, maybe it isn't. If it isn't OK you need to subtract the amount of time it took to ran.</li>
<li>You should have a try-catch block around it. You don't want it to die entirely just because of a temporary database or network issu... | 20,431 |
<p>I'm thinking the answer is no, but I'd love it it anybody had any insight into how to crawl a tree structure to any depth in SQL (MySQL), but with a single query</p>
<p>More specifically, given a tree structured table (id, data, data, parent_id), and one row in the table, is it possible to get <em>all</em> descenda... | <p>Here are several resources:</p>
<ul>
<li><a href="http://forums.mysql.com/read.php?10,32818,32818#msg-32818" rel="noreferrer">http://forums.mysql.com/read.php?10,32818,32818#msg-32818</a></li>
<li><a href="http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/" rel="noreferrer">Managing Hierarchical D... | <p>You're almost definitely going to want to employ some recursion for that. And if you're doing that, then it would be trivial (in fact easier) to get the entire tree rather than bits of it to a fixed depth. </p>
<p>In really rough pseudo-code you'll want something along these lines:</p>
<pre><code>getChildren(paren... | 20,495 |
<p>I see that within MySQL there are <code>Cast()</code> and <code>Convert()</code> functions to create integers from values, but is there any way to check to see if a value is an integer? Something like <code>is_int()</code> in PHP is what I am looking for.</p>
| <p>I'll assume you want to check a string value. One nice way is the REGEXP operator, matching the string to a regular expression. Simply do</p>
<pre><code>select field from table where field REGEXP '^-?[0-9]+$';
</code></pre>
<p>this is reasonably fast. If your field is numeric, just test for</p>
<pre><code>ceil(fi... | <p>for me the only thing that works is:</p>
<pre><code>CREATE FUNCTION IsNumeric (SIN VARCHAR(1024)) RETURNS TINYINT
RETURN SIN REGEXP '^(-|\\+){0,1}([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+|[0-9]+)$';
</code></pre>
<p>from kevinclark all other return useless stuff for me in case of <code>234jk456</code> or <code>12 inches</c... | 10,131 |
<p>Let's say I want to create the alias %xed for %edit -x. How would I do it?</p>
| <p><strong>Update:</strong> The first response( below) does not accept parameters. So put this snippet at the end of the ipy_user_conf.py file ( it is in your home directory ).</p>
<pre><code>def ed_xed(self,arg):
ip = self.api
return ip.magic.im_class.magic_edit(ip.IP," -x %s "%arg)
ip.expose_magic('xed',ed_... | <p>The answer given above uses the old magic system. <code>get_ipython().expose_magic</code> is dead. You now just import and use decorators for all this.</p>
<p>See <a href="http://ipython.org/ipython-doc/dev/api/generated/IPython.core.magic_arguments.html" rel="nofollow">here</a> for more details.</p>
| 37,861 |
<p>I've got no experience with this, so i suspect my logic is overly complicated, or perhaps not complete enough to do what I want. </p>
<p>I have a basic tile based system, but want to move units over the terrain in a coninuous fashion. Right now they are "teleporting" from one tile to another.</p>
<p>I already h... | <p>It wasn't clear from your question, but the approach I would use is different depending on whether your game is in 2D or 3D.</p>
<p>For a 2D game, you would be best off using pixels as your coordinates.That way you can use integers to store them keep things nice and simple. You can easily figure out which tile a u... | <p>Why not just have the player move onto the tile?
When they want to move to Tile B from Tile A, start moving the player in the direction of the tile. When they're within a reasonable distance from the center of the tile, you can switch the Tile that the player is on as far as the game logic is concerned.</p>
<p>So.... | 44,420 |
<p>OK, I have a somewhat complicated system in C++. In a nutshell, I need to add a method to a third party abstract base class. The third party also provides a ton of derived classes that also need the new functionality.</p>
<p>I'm using a library that provides a standard Shape interface, as well as some common shapes... | <p>We had a very similar problem in a project and we solved it by just NOT deriving ImprovedShape from Shape. If you need Shape functionality in ImprovedShape you can dynamic_cast, knowing that your cast will always work. And the rest is just like in your example.</p>
| <p>There exists a solution to your problem, as I understood the question. Use the <a href="http://en.wikipedia.org/wiki/Adapter_pattern" rel="nofollow noreferrer">addapter-pattern</a>. The adapter pattern is used to <strong>add functionality to a specific class or to exchange particular behaviour</strong> (i.e. methods... | 31,022 |
<p>I'm trying to trigger a progress animation when ever the ViewModel/Presentation Model is Busy. I have an IsBusy Property, and the ViewModel is set as the DataContext of the UserControl. What is the best way to trigger a "progressAnimation" storyboard when the IsBusy property is true? Blend only lets me add... | <p>What you want is possible by declaring the animation on the progressWheel itself:
The XAML:</p>
<pre><code><UserControl x:Class="TriggerSpike.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<Use... | <p>You can use Trigger.EnterAction to start an animation when a property is changed.</p>
<pre><code><Trigger Property="IsBusy" Value="true">
<Trigger.EnterActions>
<BeginStoryboard x:Name="BeginBusy" Storyboard="{StaticResource MyStoryboard}" />
</Trigger.EnterActions>
<T... | 10,586 |
<p>I want to display the current host and database names in a view.</p>
<p>Where can I get these names?</p>
<p>Are there some predefined environment or global variables? </p>
| <p>With Rails 3 you can use</p>
<pre><code>Rails.configuration.database_configuration[Rails.env]
</code></pre>
<p>or</p>
<pre><code>Rails.application.config.database_configuration[Rails.env]
</code></pre>
<p>or</p>
<pre><code>ActiveRecord::Base.connection_config
</code></pre>
| <p>Just this should work
<code>ActiveRecord::Base.connection.database_name</code></p>
| 33,512 |
<p>I've got a custom TObjectList descendant in Delphi 2009, and I'd like to play with its enumerator a bit and add some filtering functionality to the MoveNext method, to cause it to skip certain objects. MoveNext is called by DoMoveNext, which is a virtual method, so this shouldn't be difficult to override... except ... | <p>The enumerator <em>is</em> its own class. It just has a nested scope. To write a descendant for it, you simply declare a class as you normally would, and when you specify the new class's ancestor, you give the fully qualified type name.</p>
<pre><code>type
TMasonEnumerator = class(TObjectList.TEnumerator)
prote... | <p><a href="http://17slon.com/blogs/gabr/2007/03/fun-with-enumerators.html" rel="nofollow noreferrer">Excelent topics</a> about enumerators.</p>
| 47,887 |
<p>Does anyone have any experience hosting the Windows Workflow designer surface? I've seen a couple of rather difficult to follow examples on MSDN, but not much else - certainly nothing that offers an explanation into the process of hosting WF that is clear or easy to read... Are there better resources out there for h... | <p>There is a reference application from MSDN if you want to learn from code.</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=3a331d20-44d4-4fb4-a833-f6ec9aee1b82&displaylang=en" rel="nofollow noreferrer">WF Sample Workflow Designer Visual Studio 2005 Solution</a></p>
<p>There was a blog ... | <p>There are also a couple of books out there that describe how to host the workflow designer. For instance the Pro WF books (by Bruce Bukovics).</p>
| 24,137 |
<p>I was given a task of write the coding guidelines for my team, and it was going great until my manager asked me to write an explanation of <strong>Why Error Handling is Important</strong>.</p>
<p>I know it instinctively, but how do I express this in words?</p>
<p>I tried to google it first but came up empty, so I ... | <p>IMHO ... most programs are very large, very complex and written by multiple people. This combination of factors almost always leads to some kind of software bug. It's not that programmers are malicious, stupid or lazy ... it's just that in the rush to meet a deadline we often don't forsee every possible thing that a... | <p>First I would ask is it important?</p>
<p>I've seen (ugly) code where some errors were ignored (eg null reference) </p>
<p>So what type of errors are important to handle?</p>
<p>There is a big difference between <code>System.IO.FileNotFoundException</code>, <code>System.Data.SqlClient.SqlException</code> and <cod... | 48,056 |
<p>I am using a program that talks to my COMM port, but I have made another program that I want to "sniff" the comm port messages and perform it's own actions against those messages in addition. Is this possible in .NET c#?</p>
| <p>There are third party libraries/tools/products that expose the traffic f you are interested.</p>
<p>Here is one I used for serial port emulation - but I think it provides something you can use:
<a href="http://com0com.sourceforge.net/" rel="noreferrer">http://com0com.sourceforge.net/</a></p>
| <p>the code project (<a href="http://www.codeproject.com/Articles/75770/Basic-serial-port-listening-application" rel="nofollow">http://www.codeproject.com/Articles/75770/Basic-serial-port-listening-application</a>) that has a great tutorial on this.</p>
<p>It shows how to read data coming in from a serial port, and fr... | 46,686 |
<p>I know that php has md5(), sha1(), and the hash() functions, but I want to create a hash using the MySQL PASSWORD() function. So far, the only way I can think of is to just query the server, but I want a function (preferably in php or Perl) that will do the same thing without querying MySQL at all.</p>
<p>For exam... | <p>I originally stumbled across this question in my own search for a PHP implementation of the two MySQL password hashing functions. I was unable to find any implementations, so I adapted my own from the MySQL source code (sql/password.c). The following are tested and working in PHP 5.2:</p>
<pre><code>// The followin... | <p>Perl 5 implementation of old_password() based on the PHP example.</p>
<pre><code>sub old_hash_password {
my ($password) = @_;
my $nr = 1345345333;
my $nr2 = 0x12345671;
my $add = 7;
for (my $i = 0; $i < length($password); $i++) {
my $byte = substr($password, $i, 1);
next if... | 32,523 |
<p>We are slowly rolling out team foundation, and I have to get up to speed on setting up a Build process on TFS.</p>
<p>What are some good starting points TFS builds?</p>
<p>From what it seems, there is no GUI for TFS build right? It is just about learning MSBuild?</p>
| <p>Team Build in 2008 is completely revamped from what was provided in 2005. I am assuming that you are talking about 2008, since it is the more current version.</p>
<p>A great place to start is over at Buck Hodge's blog. Buck is the team lead for Team Build. Specifically, he has an article called <a href="http://b... | <p>In addition to Joseph's <a href="http://blogs.msdn.com/buckh/archive/2007/08/14/tfs-2008-a-basic-guide-to-team-build-2008.aspx" rel="nofollow noreferrer">pointers</a> the following talk I gave includes the majority of the slides from a session I did with Brian Randall on Team Foundation Build at TechEd EMEA in 2007.... | 48,101 |
<p>I would like to print edible cookies or ornamentation for a cake.</p>
<p>Is printing with edible materials achievable by standard thermoplastic-like 3D desktop printer? Or you need to buy a special printer to do that?</p>
| <p>You cannot print edible models using a "standard" consumer 3D printer without first installing an "hot end" capable of depositing edible - normally thicker - substances as well as a suitable extruder mechanism. </p>
<p>However, there are not necessarily any technical limitations in the electronics, software, slicer... | <p>You can, but that doesn't mean it's very easy.</p>
<p>You don't have to buy a special printer, but you need a special extruder (such as <a href="http://www.structur3d.io/" rel="noreferrer">http://www.structur3d.io/</a>). Most of these systems can print anything with the consistency of Nutella. However, many parts o... | 119 |
<p>When I have two mysql servers that have different jobs (holding different databases) but want to be able to use one of them to slip in when the other one fails, what would you suggest how I keep the data on both of them equal "close to realtime"? </p>
<p>Obviously it's not possible to make a full database dump ever... | <p>Binary log is definitely the way to go. However, you should be aware that with <strong>MySQL</strong> you can't just flip back and forth between servers like that.</p>
<p>One server will be the <strong>master</strong> and the other will be the slave. You write/read to the master, but can only read from the slave se... | <p>You may want to consider the <strong>master-master</strong> replication scenario, but with a slight twist. You can specify which databases to replicate and limit the replication for each server.</p>
<p>For server1 I would add <code>--replicate-do-db=server_2_db</code> and on server2 <code>--replicate-do-db=server_1... | 2,958 |
<p>I need to put an alpha blended gradient border around an image. My problem is in blending the corners so they are smooth where the horizontal and vertical gradients meet. I believe there is a standard algorithm that solves this problem. I think I even encountered it in school many years ago. But I have been unsuc... | <p>Presumably you're multiplying the two gradients where they overlap, right?</p>
<p>Dunno about a standard algorithm. But if you use a signoid shaped gradient instead of a linear one, that should eliminate the visible edge where the two overlap.</p>
<p>A simple sigmoid function is smoothstep(t) = t<em>t</em>(3 - 2*t... | <p>If you don't need it to be resizable, then you can just use a simple alpha map.</p>
<p>However, I once used a simple Gaussian fade, with the mean at the location where I wanted it to be the last fully-opaque pixels to be. If that makes sense.</p>
| 13,219 |
<p>I asked <a href="https://stackoverflow.com/questions/370024/sql-server-2005-public-database-role-doesnt-seem-to-apply">another question</a> about roles and permissions, which mostly served to reveal my ignorance. One of the other outcomes was the advice that one should generally stay away from mucking with permissi... | <p>Working from memory (no SQL on my gaming 'pooter), you can use <a href="http://msdn.microsoft.com/en-us/library/ms188367(SQL.90).aspx" rel="nofollow noreferrer"><code>sys.database_permissions</code></a> </p>
<p>Run this and paste the results into a new query.</p>
<p>Edit, Jan 2012. Added OBJECT_SCHEMA_NAME.<br>
<s... | <p>The idea of having a role is that you only need to setup the permissions once. You can then assign users, or groups of users to that role.</p>
<p>It's also possible to nest roles, so that a role can contain other roles.</p>
<p>Not sure if its best practice, but it makes sense that if you have a complex set of perm... | 48,635 |
<p>I created a GridView in an ASP.NET application and used the Auto Format tool to apply an attractive style. Now I'm moving the style markup to the CSS sheet and I'm having a weird problem where the text in the header row isn't the correct color (it should be white but it shows up a bright blue). <strong>This proble... | <p>I'm guessing the bright blue is very similar to the color of a hyperlink.
Making the gridview sortable means you'll have an a tag inside your header instead of just plain text.</p>
<p>This should sort it:</p>
<pre><code>.grid-header a { color: White; background-color: #507CD1; font-weight: bold; }
</code></pre>
| <p>The header color in the stylesheet is correct: #507CD1 is bright blue. Where does it show up as white, then? In Visual Studio's designer? Do you mean for the header <em>background</em> to be white, or the <em>text</em>?</p>
<p>Also, it couldn't hurt to remove the ForeColor="White" from the markup. It's already in t... | 39,819 |
<p>Exceptions in C++ don't need to be caught (no compile time errors) by the calling function. So it's up to developer's judgment whether to catch them using try/catch (unlike in Java).</p>
<p>Is there a way one can ensure that the exceptions thrown are always caught using try/catch by the calling function?</p>
| <p>No.</p>
<p>See <a href="http://www.gotw.ca/publications/mill22.htm" rel="noreferrer">A Pragmatic Look at Exception Specifications</a> for reasons why not. </p>
<p>The only way you can "help" this is to document the exceptions your function can throw, say as a comment in the header file declaring it. This is not en... | <p>Or you could start throwing critical exceptions. Surely, an access violation exception will <em>catch</em> your users' attention.</p>
| 2,353 |
<p>My link is here:</p>
<p><a href="http://tinyurl.com/5kr4ra" rel="nofollow noreferrer">Example Page</a></p>
<p>I'm using list-style-image: to give my horizontal lists ( very top and bottom ) seperators. I have a class of .first to remove the image from the first li in each list.</p>
<p>Lo and behold in IE6, it doe... | <p>I know this isn't really a solution, but I would recommend using <strong>background-image</strong> instead of <strong>list-style image</strong>.
You'll achive the same effect, and it will work in all browsers.</p>
| <p>Looks like a problem with margins and paddings of your objects inside site-navigation.</p>
<p>If you showed your CSS for those elements, we could check it faster :)</p>
| 32,310 |
<p>There seem to be 3 ways of telling GCC to weak link a symbol:</p>
<ul>
<li><code>__attribute__((weak_import))</code></li>
<li><code>__attribute__((weak))</code></li>
<li><code>#pragma weak symbol_name</code></li>
</ul>
<p>None of these work for me:</p>
<pre><code>#pragma weak asdf
extern void asdf(void) __attribu... | <p>I just looked into this and thought some others might be interested in my findings.</p>
<p>Weak linking with weak_import really only works well with dynamic libraries. You can get it to work with static linking (by specifying -undefined dynamic_lookup as suggested above) but this isn't such a hot idea. It means t... | <p>From the gcc doc manual:</p>
<p><strong>weak</strong></p>
<blockquote>
<p>The weak attribute causes the declaration to be emitted as a weak
symbol rather than a global. This is primarily useful in defining
library functions which can be overridden in user code, though it
can also be used with non-function... | 34,615 |
<p>I need to load a bunch of words (about 70,000) from a text file, add it to a hashtable (using soundex as a key) and sort the values. While doing all these I want to show a progress bar using JProgressBar. Articles such as <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html" rel="norefer... | <p>I would read the text file in a loop on a dedicated work thread, not the event-dispatch thread (EDT). If I know the total number of words to be read, then I can compute the percentage completed at each iteration of the loop and update the progress bar accordingly.</p>
<p><strong>Sample Code</strong></p>
<p>The fol... | <p>Get the file size and count the bytes processed on each iteration. That way, you don't have to cycle through the file twice.</p>
| 34,945 |
<p>I am trying to replace all occurences of ???some.text.and.dots??? in a html page to add a link on it. I've built this regexp that does it :</p>
<p>\?\?\?([a-z0-9.]*)\?\?\?</p>
<p>However, I would like to exclude any result that is inside a link : "<a ...> ... MY PATTERN ... </a>", and I am a little stu... | <p>It's not really clear what kind of "HTML" you are working on. If it is HTML <em>code</em>, something from an Ajax request maybe, then you can use a regular expression; matching both a link <em>or</em> the pattern, and then work out what to do in a callback:</p>
<pre><code>var html = document.body.innerHTML;
html = ... | <p>JavaScript doesn't inherently support look-behind. In order to do this, you'd need to run .match() and then for each of your matches, you'd need to do matches on your tags (such as /<a\s+.*?>/ being immediately before your match and then </a> after your match).</p>
<p>Good luck!!</p>
| 41,675 |
<p>I've just set up a new build server with the Windows 2008 .NET 3.5 SDK, and for some reason it hasn't installed c:\Program Files\Common Files\Microsoft Shared\TextTemplating so I can't run t4 templates on it. I had a look at the install options in add/remove programs and every single option is checked. </p>
<p>Any ... | <p>I came up with a solution that looks pretty good. Some sample XAML that I chalked up in Blend 2.0 SP1 looks like this:</p>
<pre><code><Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ScreenGlintApplication.Window... | <p>You can put a transparent panel on top like LBugnion said, but don't forget there are many ways you can do this:</p>
<ol>
<li>Change the visibility of the panel to Hidden. </li>
<li>Change the opacity to 0.</li>
<li>Change the Alpha of the color to 0.</li>
</ol>
<p>If you only change the Alpha it still is <em>clic... | 23,182 |
<p>I'm trying to build a DIY 3D printer for myself. I've been exploring many different styles of printers and found this type of printer that has a fixed bed that stays fixed in one place and the whole gantry moves which includes all axes.</p>
<ul>
<li>Why is this so rare?</li>
<li>Are there flaws in this design?</li>
... | <blockquote>
<p>Why is this so rare?</p>
</blockquote>
<p>Such kind of printers usually harder to assembles, calibrate, and maintain because 3 axes machine is a bit more complex than 2 axes. For instance, it's can be tricky to move an entire extruder among all 3 axis and some of such printer's designs may require even ... | <blockquote>
<p>Why is this so rare?</p>
</blockquote>
<p>This is rare because machine designers basically copy the designs that work, without trying to innovate too much. As a result of this, <a href="https://en.wikipedia.org/wiki/Adrian_Bowyer" rel="nofollow noreferrer">Adrian Bowyer</a>'s original <a href="https://r... | 1,767 |
<p>What are your favorite (G)Vim plugins/scripts?</p>
| <p><a href="http://www.vim.org/scripts/script.php?script_id=1658" rel="noreferrer">Nerdtree</a></p>
<p>The NERD tree allows you to explore your filesystem and to open files and
directories. It presents the filesystem to you in the form of a tree which you
manipulate with the keyboard and/or mouse. It also allows you t... | <p>During maintenance of a very big and old C++ project I've created two plugins and these are the only ones I use:</p>
<ul>
<li><a href="http://www.vim.org/scripts/script.php?script_id=1638" rel="nofollow noreferrer">SourceCodeObedience</a> </li>
<li><a href="http://www.vim.org/scripts/script.php?script_id=2507" rel=... | 4,184 |
<p>The company I work for has an old Access 2000 application that was using a SQL Server 2000 back-end. We were tasked with moving the back-end to a SQL Server 2005 database on a new server. Unfortunately, the application was not functioning correctly while trying to do any inserts or updates. My research has found ... | <p>I've had a similar problem before when using ODBC linked tables to connect to an Sql Server. The solution was to relink the tables and specify the primary key to the table. If Access doesn't know the primary key it cannot perform inserts or updates.</p>
<p>I haven't any experience with ADPs but it could be a simila... | <p>I'd say check the VBA in the Macros to see how it is doing it. It is probably using some form of VB connection to the Database in the back. I love the fact a Database is contacting a Database for it's data... :)</p>
| 3,588 |
<p>Is there some general guidelines online on how to tweak oracle for doing a high number of inserts and low number of reads?</p>
<p>All the answers below are pretty good recommendations. I have to clarify the following things. I am using 10g and this is an absolute requirement that we use Oracle. I am also more inter... | <p>Let me assume you want to do an excessive high number of inserts, so that you simply want to just ignore all other kinds of operations just to get those inserts to complete, without problems.</p>
<p>First, have you completely ruled out other types of databases? There are systems like industry databases that cope ve... | <p>What sort of application are we talking about? What version of Oracle?</p>
<p>If you are designing a data warehouse load process, for example, you would generally want to do direct-path inserts into staging table(s), then build any necessary indexes, then do a partition exhange to load the data into the partitione... | 23,613 |
<p>Not that I'm doing something like that, but I am kind of interested how bad a practice like that is.</p>
| <p>None as long as your server forbids access to all .svn directories from the web.</p>
| <p>Well, if this code you are checking out is baselined(stable) I don't think is much of a problem. </p>
<p>But you certainly should tag the code, so you know later what you put there.</p>
| 15,922 |
<p>I'm currently designing a very large and complicated model, because it's large and should be strong enough completely hollow I want to print it with no infill to save material.</p>
<p>However, there are some points in the model where there are indentations in the top shell.</p>
<p>The bottom of those indentations ... | <p>I'm not really sure if i get you right but it seems like you gotta switch on support material. That's all. Correct me if I'm wrong but it sounds like very common situation where some parts are hanging like your yellow disks.</p>
<p>Otherwise if your model is going to be closed at the bottom and at the top you can m... | <p>In Cura 2 you can do several things:</p>
<ol>
<li><p>Design internal support pillars, and make them an Infill Mesh via the Per-object settings. I suggest you also reduce the top/bottom thickness and Wall thickness of the infill mesh.</p></li>
<li><p>Enable Hollow Out Objects and enable support.</p></li>
<li><p>Enab... | 340 |
<p>Is there a way to hide private data members of a C++ class away from its users, in the cpp file? I think of the private members as part of the implementation and it seems a little backwards to declare them in the header file.</p>
| <p>The "pimpl" idiom is how this is generally handled.</p>
<p>See</p>
<ul>
<li><a href="http://www.gotw.ca/gotw/024.htm" rel="noreferrer">http://www.gotw.ca/gotw/024.htm</a></li>
<li><a href="http://www.gotw.ca/gotw/028.htm" rel="noreferrer">http://www.gotw.ca/gotw/028.htm</a></li>
<li><a href="http://herbsutter.com/... | <p>Going commercial? ;)</p>
<p>You can create header files, in which you only declare the public and protected API. </p>
<p>The user is only presented with these, which they can include. They link their code with a library, which you built using the complete API and the definitions.</p>
<p>For inlined functions: mak... | 25,273 |
<p>I have input consisting of a list of nested lists like this:</p>
<pre><code>l = [[[[[39]]]], [1, 2, 3], [4, [5, 3], 1], [[[[8, 9], 10], 11], 12]]
</code></pre>
<p>I want to sort this list based on the sum of all the numbers in the nested lists... so, the values I want to sort by of l would look like this:</p>
<pr... | <p>A slight simplification and generalization to the answers provided so far, using a recent addition to python's syntax:</p>
<pre><code>>>> l = [[[[[39]]]], [1, 2, 3], [4, [5, 3], 1], [[[[8, 9], 10], 11], 12]]
>>> def asum(t): return sum(map(asum, t)) if hasattr(t, '__iter__') else t
...
>>>... | <pre><code>l.sort(key=sum_nested)
</code></pre>
<p>Where <code>sum_nested()</code> is:</p>
<pre><code>def sum_nested(astruct):
try: return sum(map(sum_nested, astruct))
except TypeError:
return astruct
assert sum_nested([[([8, 9], 10), 11], 12]) == 50
</code></pre>
| 35,428 |
<p>I have a <code>JPanel</code> extension that I've written and would like to be able to use it in the NetBeans designer. The component is simply adds some custom painting and continues to function as a container to be customised on each use. </p>
<p>I have properties to expose in addition to the standard <code>JPan... | <p>I made JPanel component in NetBeans with overridden paint method:</p>
<pre><code>@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2 = (Graphics2D) g;
...
//draw elements
...
}
</code></pre>
<p>It has some custom properties accessible through NetBeans properties window... | <p><a href="http://www.netbeans.org" rel="nofollow noreferrer">http://www.netbeans.org</a> search for Matisse.</p>
| 29,345 |
<p>I'm building a C# application that will monitor a specified directory for changes and additions and storing the information in a database.</p>
<p>I would like to avoid checking each individual file for modifications, but I'm not sure if I can completely trust the file access time.</p>
<p>What would be the best met... | <p>Use the FileSystemWatcher object. Here is some code to do what you are looking for.</p>
<pre>
// Declares the FileSystemWatcher object
FileSystemWatcher watcher = new FileSystemWatcher();
// We have to specify the path which has to monitor
watcher.Path = @"\\somefilepath";
// This prop... | <p>If you only need it to check when the user asks rather then all the time, don't use the FileSystemWatcher. Especially if it's a shared resource - the last thing you want is 50 client machines watching the same shared directory. </p>
<p>It's probably just a typo, but you shouldn't be looking at the file access time,... | 13,743 |
<p>I've read time and time again that TDD/test first is more difficult with MSTest than it is with other testing frameworks such as nUnit, MBUnit, etc... What are some suggested manual workarounds and/or 3rd party bits that you suggest when MSTest is the only option due to infrastructure policy? I'm mainly wondering ab... | <p>MSTest is certainly not as efficient or extensible as some of the open source frameworks, but it is workable. Since the question asks about making life easier with MSTest and not about alternatives, here are my MSTest tips.</p>
<ul>
<li><strong>Shortcuts</strong>. Like Haacked said, take a few seconds to learn th... | <p>To answer a non-pointed question, my answer would be
"probably NUnit just stays out of your face."</p>
<p><strong>Disclaimer</strong>: I've no actual experience with MS version of xUnit, however I hear problems like 'You need to install the gigantic idea just to run your tests on a separate machine' - which is a c... | 4,922 |
<p>I am very interested in learning a Ruby on Rails / Django type web technology but am currently using Windows Server 2008 (for .Net web applications.) I have read that RoR is not very performant on Windows.</p>
<ol>
<li><p>Would it be unadvisable to create run a beta web application in RoR on a Windows Web server as... | <p>You can still learn a technology on Windows even if it isn't good at high performance on that platform yet.</p>
<p>I strongly recommend <em>against</em> trying to learn new technology at the same time as implementing an actual project you care about. It's better to write a pretend project while learning new tools ... | <p>Try MonoRail if you're just interested in learning the MVC pattern (not another language).</p>
| 40,705 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.