instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have a variable of type <code>Dynamic</code> and I know for sure one of its fields, lets call it <code>a</code>, actually is an array. But when I'm writing </p>
<pre><code>var d : Dynamic = getDynamic();
for (t in d.a) {
}
</code></pre>
<p>I get a compilation error on line two:</p>
<blockquote>
<p>You can't i... | <p>Haxe can't iterate over <code>Dynamic</code> variables (as the compiler says).</p>
<p>You can make it work in several ways, where this one is probably easiest (depending on your situation):</p>
<pre><code>var d : {a:Array<Dynamic>} = getDynamic();
for (t in d.a) { ... }
</code></pre>
<p>You could also chang... | <p>Another way to do the same is to use an extra temp variable and explicit typing:</p>
<pre><code>var d = getDynamic();
var a: Array<Dynamic> = d.a;
for (t in a) { ... }
</code></pre>
| 7,497 |
<p>I don't think this is possible just using the color setting in SpriteBatch, so I'm trying to work out a simple shader that would take every pixel and make it white, while respecting the alpha value of the pixel.</p>
<p>The answer Joel Martinez gave looks right, but how do I incorporate that when I draw the sprite w... | <p>I think this is what you're looking for </p>
<pre><code>sampler2D baseMap;
struct PS_INPUT
{
float2 Texcoord : TEXCOORD0;
};
float4 ps_main( PS_INPUT Input ) : COLOR0
{
float4 color = tex2D( baseMap, Input.Texcoord );
return float4(1.0f, 1.0f, 1.0f, color.w);
}
</code></pre>
<p>It's very simple, it ju... | <p>I haven't wrote my own pixel shaders, mostly modified samples from the net, what you would do is you would increase the value of the R,G,B components in the pixel respectively as long as they're under 255, this would gradually shift the color of the sprite towards white. Hey that rhymes.</p>
| 10,858 |
<p>I have a System.Diagnostics.Process object in a program targeted at the .Net framework 3.5</p>
<p>I have redirected both <code>StandardOutput</code> and <code>StandardError</code> pipes and I'm receiving data from them asynchronously. I've also set an event handler for the Exited event.</p>
<p>Once I call <code>P... | <p>The answer to this is that <a href="https://msdn.microsoft.com/en-us/library/system.diagnostics.datareceivedeventhandler%28v=vs.110%29.aspx" rel="noreferrer"><code>e.Data</code> will be set to <code>null</code></a>:</p>
<pre><code>static void proc_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
if(... | <p>It will be more comfortable if e.Data set to null, but actually, the value will be an empty string. Please note the first value also could be Empty string. The real answer is once you receive some value other than Empty string, then look for next Empty string. I am using Visual Studio 2019.</p>
| 8,881 |
<p>I'd like to find a good object oriented C++ (as opposed to C) wrapper for sqlite. What do people recommend? If you have several suggestions please put them in separate replies for voting purposes. Also, please indicate whether you have any experience of the wrapper you are suggesting and how you found it to use.</p>... | <p>This is really inviting down-votes, but here goes...</p>
<p>I use sqlite directly from C++, and don't see any value with an added C++ abstraction layer. It's quite good (and efficient) as is.</p>
| <p>I've used this one <a href="http://www.codeproject.com/KB/database/CppSQLite.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/database/CppSQLite.aspx</a> but I've moved to C#, so there may be newer/better ones now</p>
| 14,631 |
<p>I'm looking for a dummy SQL statement that will work from a C# SQL connection to check for connectivity.</p>
<p>Basically I need to send a request to the database, I don't care what it returns I just want it to be successful if the database is still there and throw an exception if the database isn't.</p>
<p>The sc... | <p>Most SQL databases have a 'table' for this purpose.</p>
<p>In DB2, it's:</p>
<pre><code>select * from sysibm.sysdummy1
</code></pre>
<p>while Oracle has, from memory,</p>
<pre><code>select * from dual
</code></pre>
<p>It'll depend on the database at the back end.</p>
| <p>It would be better to catch your implementation's not-connected exception for EVERY sql statement you execute, rather than using a dummy statement to test for connectivity. I have seen systems where upwards of 10% of database CPU time is spent responding to these dummy queries.</p>
| 32,738 |
<p>I am developing an iPhone application, in my table view I wanted custom color for Cell Selection Style, I read the <em>UITableViewCell Class Reference</em> but there are only three constants defined for Selection style (Blue, Gray, None). I saw one application that used a different color than those defined in the re... | <p>The best way to set the selection is to set the <code>selectedBackgroundView</code> on the cell when you construct it.</p>
<p>i.e.</p>
<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewC... | <pre><code>- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
// Set Highlighted Color
if (highlighted) {
self.backgroundColor = [UIColor colorWithRed:234.0f/255 green:202.0f/255 blue:255.0f/255 alpha:1.0f];
} else {
self.backgroundColor = [UIColor clearColor];
}
}
</code></pr... | 32,571 |
<p>In MS Access 2003 (I know, I know), I'm using the OLE Object data type to persist the sate of some objects that are marked as serializable (just using a IO.BinaryFormatter to serialize to a MemoryStream, and then saving that to the db as a Byte array). Does this work pretty much like a varbinary, or a blob? Are th... | <p>In access I never figured out how to properly use the OLE object data type without real performance problems (and structural too -- lots of compact and repair jobs). The solution path I've always taken (mind you I haven't used Access in anger now for <strong><em>years</em></strong>) is to just store the blogs onto ... | <p>I can't answer your specific question, but you might want to look at the GetChunk and AppendChunk methods in Access help, since those are the methods used for writing and manipulating data in binary fields.</p>
| 5,170 |
<p>What are your favorite supplementary tools for Java development?</p>
<p>Mine are:</p>
<p>1) Total Commander (due to the ability to search inside JARs).</p>
<p>2) JAD + Jadclipse (to understand and debug libraries)</p>
<p>And of-course, Google. (can't really live without it)</p>
| <p><a href="http://www.jython.org/" rel="nofollow noreferrer">Jython</a> for interactive testing and exploration of all sorts of things. </p>
| <p><a href="http://findbugs.sourceforge.net/" rel="nofollow noreferrer">FindBugs</a>, <a href="http://proguard.sourceforge.net/" rel="nofollow noreferrer">Proguard</a>, <a href="http://www.ej-technologies.com/products/jprofiler/overview.html" rel="nofollow noreferrer">JProfiler</a>, <a href="http://cobertura.sourceforg... | 13,622 |
<p>I saw a code snippet yesterday in one of the responses here on StackOverflow that intrigued me. It was something like this:</p>
<pre><code> List<string> myList = new List<string> {"aBc", "HELLO", "GoodBye"};
myList.ForEach(d=>d.ToLower());
</code></pre>
<p>I was hoping I could use it to convert al... | <p>Easiest approach:</p>
<pre><code>myList = myList.ConvertAll(d => d.ToLower());
</code></pre>
<p>Not too much different than your example code. <code>ForEach</code> loops the original list whereas <code>ConvertAll</code> creates a new one which you need to reassign.</p>
| <pre><code>var _reps = new List(); // with variant data
_reps.ConvertAll<string>(new Converter<string,string>(delegate(string str){str = str.ToLower(); return str;})).Contains("invisible"))
</code></pre>
| 28,585 |
<p>How do I create a grails war file so that it doesn't have the version number</p>
<p>(e.g. foo-0.1.war) </p>
<p>attached to the end when I execute the 'grails war' command?</p>
| <p>I think you can specify the war name in the war command.</p>
<pre><code>grails war foo.war
</code></pre>
<p>Also check the latest Grails documentation for where to set this as a configuration option. See the other answers for details.</p>
| <p>I am kind of late to the party... but anyway:</p>
<p>I think the reason behind removing the version number is to eliminate the need to rename the war file so it deploys on "<em>correct</em>" context path <strong>/appName</strong>. If that's the case then a better option is to use a versioned war filename so you can... | 19,902 |
<p><img src="https://i.stack.imgur.com/wPPuZ.jpg" alt="example picture"></p>
<p>I'd assume insufficient z offset but some areas of the first layer look fine. I've been struggling with this problem despite lots of attempts including z offset, infill overlap, belt retensioning, etc.</p>
<p>Anyone else experienced this ... | <p>From the picture it is clearly seen that the filament is not flattened properly. This implies that your nozzle bed distance is too large. Try decreasing the gap by leveling the bed at temperature and have a piece of "A4" or "Letter" print paper between the nozzle and bed have a little friction when pulled.</p>
<p>A... | <p>White PLA is some of the nastiest stuff to print with, it's very impure. Could you try to make the same print, but with another filament?</p>
<p>230 degrees might be a bit too high of a temperature, normally PLA is printed between 215-225. Try to decrease and increase the temperature with 5 degrees to see if there ... | 1,424 |
<p>How do I bind a CheckBoxField in my GridView to an underlying db field that is a string. The string is either "1" or "0" but all the same the GridView won't willingly bind to it. What do I do. What is the best way to have a checkbox in the GridView and have it get and set the string in the database (or the underlyin... | <p>This should work:</p>
<pre><code>Checked='<%# DataBinder.Eval(Container.DataItem, "MyStringField") = "1" %>'
</code></pre>
<p>Normally a checkbox value would be mapped to a bit value in your database so you wouldn't get this issue.</p>
| <p>The CheckBoxField binds to a boolean.
You can either convert the string to a boolean in the binding expression, or cast it in the db return.</p>
<p>It would make more sense for the database to store the checkbox state as a bit rather than a string. Then this problem would go away completely.</p>
<p>Of course, if y... | 44,426 |
<p>I recently got started in 3D printing but here's an issue I can't seem to find a solution for (I don't know what exactly to look for).</p>
<p>Here's what I did:</p>
<ul>
<li>I used InkScape to convert an emoji in to a svg and imported it in to Blender</li>
<li>Used the Solidify modifier to make the curve a solid a... | <p>here is just a addenum to Tom van der Zanden's answer</p>
<p>this is (an example of) what you may design - nice object with virtual outline, and virtual fill
so this is what you see (and what you potentially expect)</p>
<p><a href="https://i.stack.imgur.com/61gRm.png" rel="noreferrer"><img src="https://i.stack.img... | <p>This is likely not a problem with your mesh. It's a problem in the slicer software.</p>
<p>Because your 3D printer prints with a (for example) 0.4mm nozzle, it lays down lines of plastic that are around (for example) 0.5mm wide. The slicer has to create a pattern, consisting of 0.5mm wide lines, that fills in your ... | 718 |
<p>So i am reorganizing a winforms C# solution to help decouple and make it cleaner and more organized. The solution tracks a small business orders,etc . .</p>
<p>I have broken out the projects so far into</p>
<p><strong>App.View</strong> - all GUI Related Code<br>
<strong>App.Data</strong> - just data structures an... | <p>Actually, I think you have things a little off from a traditional layered architecture. Normally, the models of your data that your application works on would be kept in a business layer, along with the code to operate on them. Your data layer would have both the data models of your persistence framework and the c... | <p>I would probably go with </p>
<ol>
<li>Data</li>
<li>Data</li>
<li>Data, although I'm not entirely sure what the class is doing</li>
<li>Data</li>
<li>BusinessLogic</li>
</ol>
| 26,635 |
<p>I have a simple WCF service that I'm exposing using a .svc. The service has some related DataContract classes that are used with the ServiceContracts. When calling a method that gets some data, the json that comes back has all the properties just as you'd expect. </p>
<p>My question is how can I get a new instance ... | <p>If you browse to ./Service1.svc/js you can see the exact client proxy script that is generated by the server.</p>
<p>At the end of this file you should see lines that register your data contract types as client types - this just makes them available in the client type system and lets you call a well-known construct... | <p>Thanks @Sam, I was hoping that there was a way that all the properties could be created so that when I did new MyDataContractClassname(); I could have a nice complete object I could pass around and didn't have to test for existence of properties and such - just treat it like an object I got from a service that retur... | 46,684 |
<p>I have some written a number of unit tests that <strong><em>test a wrapper around a FTP server API</em>.</strong></p>
<p>Both the unit tests and the FTP server are on the same machine.</p>
<p>The wrapper API gets deployed to our platform and are used in both remoting and web service scenarios. The wrapper API esse... | <p>You seem to be mixing unit & component testing concerns.</p>
<ul>
<li>If you're unit-testing your wrapper, you should use a mock FTP server and don't involve the actual server. The plus side is, you can usually achieve 100% automation like this.</li>
<li>If you're component-testing the whole thing (the wrapper ... | <p>What are you testing the wrapper or the API. The API should work as is, so you don't need to test it I would think. Focus your testing efforts on the wrapper and pretend like the API doesn't exist, when I write a class that does file access I don't unit test the build in streamreader...I focus on my code.</p>
| 26,264 |
<p>I was reading the Math.random() javadoc and saw that random is only psuedorandom. </p>
<p>Is there a library (specifically java) that generates random numbers according to random variables like environmental temperature, CPU temperature/voltage, or anything like that?</p>
| <p>Check out <a href="http://random.org/" rel="noreferrer">http://random.org/</a></p>
<p>RANDOM.ORG is a true random number service that generates randomness via atmospheric noise.</p>
<p>The Java library for interfacing with it can be found here:
<a href="http://sourceforge.net/projects/trng-random-org/" rel="norefe... | <p>As far as i know they work with <strong>time</strong> of the machine ... !</p>
<p><strong>What Random Numbers Are Used For</strong></p>
<blockquote>
<p>Random numbers have been used for many thousands of years. Whether
it’s flipping a coin or rolling a dice, the goal is to leave the end
result up to random c... | 49,935 |
<p>The title should say it all, then I can solidify 2 more ticks on the Joel test. </p>
<p>I've implemented build automation using a makefile and a python script already and I understand the basics and the options. </p>
<p>But how can I, the new guy who reads the blogs, convince my cohort of its inherent efficacy?</p... | <p>Ask for forgiveness, instead of permission.</p>
<p>Get it working in private (which it looks like you have) and then demonstrate its advantages.</p>
<p>One thing that always gets people is using CruiseControl's Tray utility - people love it when they can see, through their system tray, that the build succeeded. (t... | <p>I would set up the automated build as a nightly process such that every night it grabs the most recent code revision, builds it, and generates a report. Now you will know first thing every morning whether or not the build is broken, and if it is, you can notify the team. If broken builds are much of a problem on y... | 11,379 |
<p>In C the following horror is valid:</p>
<pre><code>myFunc()
{
return 42; // return type defaults to int.
}
</code></pre>
<p>But, what about in C++? I can't find a reference to it either way...</p>
<p>My compiler (Codegear C++Builder 2007) currently accepts it without warning, but I've had comments that this <s... | <p>It's <em>ill-formed</em> in C++. Meaning that it doesn't compile with a standard conforming compiler. Paragraph <strong>7.1.5/4</strong> in Annex C of the Standard explains the change "Banning implicit int". </p>
| <p>As posted, it is ill-formed. MSVC 8 gives the following error:</p>
<pre><code>error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
</code></pre>
| 42,892 |
<p>Did Microsoft abandon support for Windows Presentation Foundation (WPF) on Visual Studio 2005?</p>
<p>There was the a Community Technology Preview (CTP) for the WPF and WCF, but <a href="http://tinyurl.com/5hn2yd" rel="nofollow noreferrer">it's no longer available</a> for download. There are <a href="http://www.mic... | <p>Yes, unfortunately it looks like the extensions are no longer supported - see <a href="http://blogs.msdn.com/acangialosi/archive/2008/06/27/vs-2005-extensions-for-net-framework-3-0-wpf-wcf-ctp-is-coming-off-the-ms-download-center.aspx" rel="nofollow noreferrer">this</a> MSDN blog post for further details.</p>
| <p>Yes, unfortunately it looks like the extensions are no longer supported - see <a href="http://blogs.msdn.com/acangialosi/archive/2008/06/27/vs-2005-extensions-for-net-framework-3-0-wpf-wcf-ctp-is-coming-off-the-ms-download-center.aspx" rel="nofollow noreferrer">this</a> MSDN blog post for further details.</p>
| 30,215 |
<p>There are several different methods for converting floating point numbers to Integers in JavaScript. My question is what method gives the best performance, is most compatible, or is considered the best practice?</p>
<p>Here are a few methods that I know of:</p>
<pre><code>var a = 2.5;
window.parseInt(a); // 2
Math... | <p>According to <a href="http://www.jibbering.com/faq/faq_notes/type_convert.html#tcParseIn" rel="noreferrer"><strong>this website</strong></a>:</p>
<blockquote>
<p>parseInt is occasionally used as a means of turning a floating point number into an integer. It is very ill suited to that task because if its argument is ... | <p>parseInt() is probably the best one. <code>a | 0</code> doesn't do what you really want (it just assigns 0 if a is an undefined or null value, which means an empty object or array passes the test), and Math.floor works by some type trickery (it basically calls parseInt() in the background).</p>
| 15,947 |
<p>I am parsing XML file. In this file there is one tag containing date string <code>"2008-11-10T05:51:33Z"</code> and I want convert this string in to <code>java.util.Date object.</code></p>
<p>How can this be done?</p>
| <p>Use <a href="http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html" rel="nofollow noreferrer">java.text.DateFormat</a> - or more likely, <a href="http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html" rel="nofollow noreferrer">SimpleDateFormat</a>.</p>
<p>Alternatively, go for <a href="htt... | <pre><code>DateTime dateToGetFromString;
dateToGetFromString = DateTime.Parse(stringContainingDate);
</code></pre>
<p>You can also use the TryParse function of DateTime class, look in the documentation.</p>
| 49,879 |
<p>I have a web application that generates a long report and I need to print it. If I just print the page it will break at the end of the physical page. How can I calculate where to make a break in the web page so that the page breaks line up with the physical pages when they print?</p>
| <ul>
<li><a href="http://www.w3.org/TR/CSS2/page.html" rel="nofollow noreferrer">Paged media</a></li>
<li><a href="http://www.w3schools.com/CSS/css_ref_print.asp" rel="nofollow noreferrer">Print Reference</a>
<ul>
<li><a href="http://www.w3schools.com/CSS/pr_print_pageba.asp" rel="nofollow noreferrer">page-break-after... | <p>Either with CSS <a href="http://www.w3schools.com/Css/css_ref_print.asp" rel="nofollow noreferrer"><code>page-break-before/after</code></a></p>
<p>Other ways:</p>
<ul>
<li>use <a href="http://jasperforge.org/plugins/project/project_home.php?group_id=102" rel="nofollow noreferrer">JasperReports</a> and load the dat... | 20,101 |
<p>Is it possible to print toothbrush bristles using a common FDM 3D printer? I am particularly interested in the width of bristles, closeness together of each bristle, and the flexibility of each particular bristle.</p>
| <p>Actually last year a group did use a normal FDM printer to 3d print hair, brushed, etc. See the press release from Carnegie Mellon University</p>
<p><a href="https://www.engadget.com/2015/10/29/3d-printing-hair-is-as-easy-as-using-a-hot-glue-gun/" rel="noreferrer">https://www.engadget.com/2015/10/29/3d-printing-hai... | <p>I have had a go at doing something for a <a href="http://www.thingiverse.com/thing:552770" rel="nofollow">christmass tree</a> using a drop loop technique. You could use the same method or somthing similar to try and create something that looks like toothbrush bristles, but I don't think you would want to try cleanin... | 317 |
<p>fellow anthropoids and lily pads and paddlewheels!</p>
<p>I'm developing a Windows desktop app in C#/.NET/WPF, using VS 2008. The app is required to install and run on Vista and XP machines. I'm working on a Setup/Windows Installer Project to install the app.</p>
<p>My app requires read/modify/write access to a SQ... | <p>I have learned the answer to my question through other sources, yes, yes! Sadly, it didn't fix my problem! What's that make me -- a fixer-upper? Yes, yes!</p>
<p>To put stuff in a sub-directory of the Common Application Data folder from a VS2008 Setup project, here's what you do:</p>
<ol>
<li><p>Right-click your s... | <p>I'm not sure if this will help in your case or not.</p>
<p>But if you add a private section to your app's config file</p>
<p>
</p>
<p>You can specify extra folders to check in your app.</p>
<p>If what you are saying is that you want to be able to install
into other folders on the machine, the... | 10,236 |
<p>I need some help with WPF binding syntax:</p>
<pre><code>public class ApplicationPresenter
{
public ObservableCollection<Quotes> PriceList {get;}
}
public class WebSitePricesView
{
private IApplicationPresenter presenter
{
get { return (ApplicationPresenter)DataContext; }
}
// p... | <p>Not sure what your problem is, the bindings (apart from the missing end quotes) appear to be fine. The following code works fine for me.</p>
<pre><code>public class Quotes
{
public string Description { get; set; }
public decimal Value { get; set; }
}
public class ApplicationPresenter
{
public Applicati... | <p>I am not sure, since it is not very clear from your code where data go to PriceList, but what I see is that this collection is just empty in second xaml.</p>
<p>Creating ObjectDataProvider in xaml in both cases just creates object of type ApplicationPresenter through default constructor. Your constructor creates em... | 31,929 |
<p>I'm experimenting with <a href="http://en.wikipedia.org/wiki/Latent_Dirichlet_allocation" rel="noreferrer">Latent Dirichlet Allocation</a> for topic disambiguation and assignment, and I'm looking for advice.</p>
<ol>
<li>Which program is the "best", where best is some combination of easiest to use, best prior estim... | <ol>
<li><p><a href="http://mallet.cs.umass.edu/" rel="noreferrer">http://mallet.cs.umass.edu/</a> is IMHO the most awesome plug-n-play LDA package out there.. It uses Gibbs sampling to estimate topics and has a really straightforward command-line interface with a lot of extra bells-n-whistles (a few more complicated m... | <p>i second that. Mallet's lda uses a sparselda data structure and distributed learning, so its v fast. switching on hyperparameter optimization will give a better result, imo.</p>
| 23,223 |
<p>For the following HTML:</p>
<pre><code><form name="myForm">
<label>One<input name="area" type="radio" value="S" /></label>
<label>Two<input name="area" type="radio" value="R" /></label>
&l... | <pre><code>$( function() {
$("input:radio")
.click(radioClicks)
.filter("[value='S']")
.attr("checked", "checked");
});
</code></pre>
| <p>I think something like this should work (but it's untested):</p>
<pre><code>$("input[@type='radio']").each(function(i) {
if (this.val() == 'E') {
radioClicks();
this.get().checked = true;
}
}
$("input[@type='radio']").click(radioClicks);
</code></pre>
| 6,888 |
<p>What would cause this effect, and how can it be avoided? </p>
<p>This is a PLA print, and it should look like <a href="http://www.thingiverse.com/thing:1560347" rel="noreferrer">this</a>. I tried 215 and 225°C and both had the same effect. An earlier similar print at 220°C was not as bad but it still had some catc... | <p>I think that you should first verify that you have the latest firmware and a newer version of MakerWare. I experienced similar issues around that version of MakerWare and remember a lot of print errors came with it.</p>
<p>I believe the MakerBot Dual firmware is somewhere around 7.? and is no longer in development.... | <p>As pointed out in the comments, what you are seeing could very well be related to <em>lack of cooling</em>: </p>
<p>You may notice that the irregularity in the print become more and more pronounced the further up you see. I believe this happens because <em>the area that is printed is reduced gradually closer to the... | 433 |
<p>When a class field is accessed via a getter method by multiple threads, how do you maintain thread safety? Is the synchronized keyword sufficient?</p>
<p>Is this safe:</p>
<pre><code>public class SomeClass {
private int val;
public synchronized int getVal() {
return val;
}
private void se... | <p>If you use 'synchronized' on the setter here too, this code is threadsafe. However it may not be sufficiently granular; if you have 20 getters and setters and they're all synchronized, you may be creating a synchronization bottleneck.</p>
<p>In this specific instance, with a single int variable, then eliminating th... | <p>Synchronization exists to protect against thread interference and memory consistency errors. By synchronizing on the getVal(), the code is guaranteeing that other synchronized methods on SomeClass do not also execute at the same time. Since there are no other synchronized methods, it isn't providing much value. A... | 14,410 |
<p>My scenario is:</p>
<p>I have a WPF Window with 3 data-bound text boxes</p>
<pre class="lang-xml prettyprint-override"><code>SettingsUI : Window
<Grid Name="SettingsUIGrid1">
<TextBox Text="{Binding val1}" ....
<TextBox Text="{Binding val2}" ....
<TextBox Text="{Binding val3}" ....
<... | <p>The Binding works two way: it takes the value and sets it editable in the textbox, and if the value changes, it updates the original object's value...</p>
<p>If you only wish to show the data, you can use the Mode=OneTime option in the Binding</p>
<pre><code>{Binding Path =val1, Mode=OneTime}
</code></pre>
<p>Thi... | <p>I would suggest putting some code into your cancel button click event to check whether any of the data has been changed from what was initially loaded as I am assuming that if they don't click cancel the other button would be save/ok meaning that the data would be committed to the database.</p>
<p>What is coll?</p>... | 38,727 |
<p>I found this in Handbook of Compliant Mechanisms (2013), page 162, or at the start of "Chapter 11, Elements of Mechanisms," subsection 11.1.2 Revolute</p>
<p>I don't understand how it's supposed to go from 1 to 2 when b rotates around c.</p>
<p>The description reads:</p>
<blockquote>
<p>This element is a r... | <p>The picture looks as if there is a printed back surface to which the central part is attached. This can not be the case, since otherwise the curved members would not be able to flex. Everything inside the outer ring must be detached from the back shell.</p>
<p>Like all couplers, especially flexible couplers, there... | <p>I would try and print it in PLA because it is quite flexible.
ABS is harder in my experience and breaks more easily.
If you are able to print PET, you should also try that for the same reasons.
There might also be better materials I've never heard of, also please leave a comment if I'm wrong with anything.</p>
| 1,711 |
<p>Sorry if the title is poorly descriptive, but I can't do better right now =(</p>
<p>So, I have this master-detail scheme, with the detail being a tree structure (one to many self relation) with n levels (on SQLServer 2005)</p>
<p>I need to copy a detail structure from one master to the another using a stored proce... | <p>If I understand the problem, this might be what you want:</p>
<pre><code>INSERT dbo.Master VALUES (@NewMaster_ID, @NewDescription)
INSERT dbo.Detail (parent_id, master_id, [name])
SELECT detail_ID, @NewMaster_ID, [name]
FROM dbo.Detail
WHERE master_id = @OldMaster_ID
UPDATE NewChild
SET parent_id = NewParent.det... | <p>you'll have to provide create table and insert into statements for little sample data.
and expected results based on this sample data.</p>
| 16,530 |
<p>I'm slowly getting back into PHP, and now I run into a problem, I want to install some web software on our host and I need to have either the latest Zend (which they don't have) or IonCube on the server and IonCube requires enable_dl to be on in the php.ini. Now a colleague of mine thinks I can update this via an .h... | <p>The thing about stringbuilder is you're still trying to keep the entire contents in memory. You want to only keep a small portion in memory at a time, and that means using filestreams. Don't read an entire file into memory, open a stream on it and keep reading from the stream.</p>
<p>The problem with xml is that ... | <p>It depends what you mean by merge, since you haven't posted any information about the schema.</p>
<p>In the simplest case of homogeneous simple elements in a single collection, you would just merge directly to a new file on disk avoiding much in-memory work, ensuring that the outer containing elements are stripped ... | 17,989 |
<p>Which would be quicker.</p>
<p>1) Looping a datareader and creating a custom rows and columns based populated datatable</p>
<p>2) Or creating a dataAdapter object and just (.Fill)ing a datatable.</p>
<p>Does the performance of a datareader still hold true upon dynamic creation of a datatable? </p>
| <p>The DataAdapter uses a DataReader under the hood so your experience would likely be the same.</p>
<p>The benefit of the DataAdapter is you cut out a lot of code that would need maintenance.</p>
<p>This debate is a bit of a religious issue so definitely look around and decide what works best for your situation:</p>... | <p>Depends. DataAdapter can be 2X-25X faster if you wish to get all the records at once. The datareader is good when you just need a column or 2 back and wish to make changes one at a time, but, execution times are pretty slow as expected. DA's biggest problem is the lack of asynchronous methods - MS has no plans of ma... | 43,393 |
<p>I have a seemingly unique problem. I'm trying to design models that print with single extrusion walls and are not closed volumes. For example, a topographical map model printed on an edge. It has height and width, but no depth. I want the model to print with a single, non-closed extrusion per layer. Printing back an... | <p>Use Cura to slice and check out the "Surface Mode" option (might be hidden by default; if so, search for and unhide it). Also known as <code>magic_mesh_surface_mode</code>. The "Surface" choice sounds close to what you want and might suffice.</p>
| <p>If you are designing a model that has single extrusion walls, you are constructing a design which has volume. A single extrusion wall will be dependent on the nozzle diameter and extrusion multiplier. For the sake of discussion, consider the theoretical nozzle 0.4 mm with a true 0.4 mm extrusion and a 0.2 mm layer t... | 2,020 |
<p>This is all hypothetical, so please bear with me.</p>
<p>Say I'm writing a tool in C# called Foo. The output is foo.exe. I've found some really great library that I like to use called Bar, which I can reference as bar.dll in my project. When I build my project, I have foo.exe and bar.dll in my output directory. ... | <p>There's ILMerge. <a href="http://research.microsoft.com/~mbarnett/ILMerge.aspx" rel="noreferrer">Link</a></p>
| <p>Thanks everyone who answered!</p>
<p>I ended up with <a href="http://www.genetibase.com/cforce/nugenunify.php" rel="nofollow noreferrer">NuGenUnify</a> which provides a GUI wrapper for ilmerge.</p>
| 11,080 |
<p>Can someome provide code or pseudo-code for how the paging links on StackOverflow are generated?</p>
<p>I keep racking my brain but can't think of a decent way to build the dynamic links that always show the 2 pages around the current, plus the first and last.</p>
<p>Example: <code>1 ... 5 6 7 ... 593</code></p>
| <p>There are several other answers already, but I'd like to show you the approach I took to solve it:
First, let's check out how Stack Overflow handles normal cases and edge cases. Each of my pages displays 10 results, so to find out what it does for 1 page, find a tag that has less than 11 entries: <a href="https://s... | <p>This is my approach to make a paging link. The following <strong><em>java code</em></strong> is just a pseudo.</p>
<pre><code>package com.edde;
/**
* @author Yang Shuai
*/
public class Pager {
/**
* This is a method used to display the paging links(pagination or sometimes called pager).
* The tota... | 6,632 |
<p>Technical Debt <a href="http://www.martinfowler.com/bliki/TechnicalDebt.html" rel="noreferrer">via Martin Fowler</a>, <a href="http://forums.construx.com/blogs/stevemcc/archive/2007/11/01/technical-debt-2.aspx" rel="noreferrer">via Steve McConnell</a></p>
<p>YAGNI (You Ain't Gonna Need It) <a href="http://en.wikipe... | <p>There was an interesting discussion of Technical Debt based on your definition of done on HanselMinutes a couple of weeks ago -- <a href="http://www.hanselminutes.com/default.aspx?showID=137" rel="nofollow noreferrer">What is Done</a>. The basics of the show were that if you re-define 'Done' to increase perceived v... | <p>That's why it's always easier to write nice "acadamic papers" talking about how Agile development is good, what are the "best practices" and so on.</p>
<p>That's why you find a lot of "suited engineers" making up new software engineering techniques.</p>
<p>Process is important, keeping best practices is cool but o... | 8,595 |
<p>Using Visual Studio 2008 Team Edition, is it possible to assign a shortcut key that switches between markup and code? If not, is it possible to assign a shortcut key that goes from code to markup?</p>
| <p>The following is a macro taken from a comment by Lozza on <a href="https://blog.codinghorror.com/visual-studio-net-2003-and-2005-keyboard-shortcuts/" rel="nofollow noreferrer">https://blog.codinghorror.com/visual-studio-net-2003-and-2005-keyboard-shortcuts/</a>. You just need to bind it to a shortcut of your choice:... | <p>Not sure if this is what you mean, as I don't do ASPX development myself, but don't the F7 (show code) and Shift-F7 (show designer) default key bindings switch between code and design? They do in my VS2008 (on WinForms designable items) with the largely default C# key bindings I use.</p>
| 14,577 |
<p>I'm trying to hide the "Title" field in a list.
This doesn't seem to work:</p>
<pre><code>SPList myList;
...
SPField titleField = myList.Fields.GetField("Title");
//titleField.PushChangesToLists = true; <-- doesn't seem to make a difference
titleField.ShowInEditForm = false;
titleField.ShowInDisplayForm = false;... | <p>Try this:</p>
<pre><code>field.Hidden = true;
field.Update();
</code></pre>
| <p>Make sure you are grabbing a <em>new</em> SPWeb instance.</p>
<pre><code>using (SPSite site = new SPSite(webUrl))
{
using (SPWeb web = site.OpenWeb())
{
try
{
//... Get SPList ...
}
}
}
</code></pre>
| 37,005 |
<p>I was wondering if there was a way to tell if an instance of Oracle on a system has a database installed or not?</p>
<p>This is for an installation script, and I need to verify that there is an actual database in place before proceeding with the loading of my own tablespace onto that database. Has anyone tackled th... | <p>Check for the existence of an ORACLE_HOME. It's also reasonable to expect that this environment should be configured for the installation, so testing the environment variables and exiting with a sensible diagnostic (possibly suggesting they run oraenv) is a good first start. If you have an ORACLE_HOME, ORACLE_SID ... | <p>I'm not sure about Oracle, but for MySQL and PostgreSql I do the following:</p>
<pre><code>$yum grouplist | grep SQL
</code></pre>
<p>This returns:</p>
<pre><code>MySQL Database client
MySQL Database server
PostgreSQL Database client
PostgreSQL Database server
</code></pre>
<p>So I assume you should try: </p>
<... | 39,210 |
<p>I have a block of product images we received from a customer. Each product image is a picture of something and it was taken with a white background. I would like to crop all the surrounding parts of the image but leave only the product in the middle. Is this possible?</p>
<p>As an example: [<a href="http://www.5... | <p>I found I had to adjust Dmitri's answer to ensure it works with images that don't actually need cropping (either horizontally, vertically or both)...</p>
<pre><code> public static Bitmap Crop(Bitmap bmp)
{
int w = bmp.Width;
int h = bmp.Height;
Func<int, bool> allWhiteRow = row... | <p>I copied to a version that works with SkiaSharp.</p>
<pre><code>using SkiaSharp;
using System;
//
// Based on the original stackoverflow post: https://stackoverflow.com/questions/248141/remove-surrounding-whitespace-from-an-image
//
namespace BlahBlah
{
public static class BitmapExtensions
{
public static... | 30,831 |
<p>A string will be made up of certain symbols (ax,bx,dx,c,acc for example) and numbers.</p>
<p>ex:
ax 5 5
dx 3 acc
c ax bx</p>
<p>I want to replace one or all of the symbols (randomly) with another symbol of the same set. ie, replace one of {ax,bx,dx,c,acc} with one of {ax,bx,dx,c,acc}.</p>
<p>replacement example:
... | <p>I think this is the most clean solution for replacing a certain set of symbols from a string containing a superset of them.
appendreplacement is the key to this method.
one important caveat: do not include any unescped dollar characters ($) in your elements list. escape them by using "\$"
eventually use<br>
.rep... | <p>thanks a bunch guys. here's what i came up with. see if you can come up with a more efficient way.</p>
<pre><code>private final String[] symbolsPossible = {"ax","bx","cx","dx","foo"};
private boolean exists;
private final String mutate(String s)
{
String[] tokens=s.split(" ");
for(int j=0; j<tokens.length; j++)
... | 29,327 |
<p><strong>edit #2:</strong> Question solved halfways. Look below</p>
<p>As a follow-up question, does anyone know of a non-intrusive way to solve what i'm trying to do below (namely, linking objects to each other without triggering infinite loops)?</p>
<hr>
<p>I try to create a asp.net-mvc web application, and get ... | <p>Hai! I think your models are recursively calling a method unintentionally, which results in the stack overflow. Like, for instance, your Subregion object is trying to get Country objects, which in turn have to get Subregions. </p>
<p>Anyhow, it always helps to check the stack in a StackOverflow exception. If yo... | <p>To answer your edited question, namely: "linking objects to each other without triggering infinite loops":</p>
<p>Assuming you've got some sort of relation where both sides need to know about the other... get hold of all the relevant entities in both sides, then link them together, rather than trying to make the fe... | 29,496 |
<p>Not sure what's going on here.</p>
<p>I have a DateTime object, and when I try:</p>
<pre><code>String.Format( "{0:dd/MM/yyyy}", _date)
</code></pre>
<p>the value returned is:</p>
<pre><code>"24-05-1967"
</code></pre>
<p>What I want is</p>
<pre><code>"24/05/1967"
</code></pre>
<p>Can anyone explain why my form... | <p>The / is actually the date separator for your specific culture which could be -, in other words, the format string is not ignored but actually used correctly. Look at what CultureInfo is associated with the running thread:</p>
<pre><code>System.Threading.Thread.CurrentThread.CurrentCulture
</code></pre>
<p>If you ... | <p>That's odd. That formatting works correctly for me. You might want to try _date.ToString("dd/MM/yyyy") instead (though that's just a shot in the dark).</p>
| 41,089 |
<p>I have a flat-file schema that has a header and detail records. It looks something like this:</p>
<pre><code>HDR**2401*XX0062484*22750***20081006000000*000*******
LIN**001*788-0538-001*4891-788538010*20000*EA**0000***
</code></pre>
<p>I need to append two blank lines at the end of the message. Right now, if I have... | <p>You should be able to accomplish what you want by using the Delimiter properties of the flat file schema.</p>
<p>Based on your example file I created a schema with the following record structure:</p>
<pre>
<Schema>
<Root>
<HDRGroup>
&nbs... | <p>For anybody who cares, I finally caved in and wrote a custom pipeline component to accomplish this.</p>
| 27,551 |
<p>I want to reveal a div with an input inside when you click a button, and set its focus.</p>
<p>If I use show(), it works, but if I use slideDown() <strong>the focus is lost after the animation completes</strong>. How can I prevent this from happening?</p>
<p>Sample code:</p>
<pre><code>$("document").ready(functio... | <p>Try this:</p>
<pre><code>$(function(){
$("#MyButton").click(function(e){
e.preventDefault();
$(".SlidingDiv").slideDown(function(){
// Callback function - will occur when sliding is complete.
$("#MyInput").focus();
});
});
});
</code></pre>
| <p>I think you can only focus the element once the DIV has fully stopped sliding?<br>
not sure...</p>
| 39,875 |
<p>Is there a built in Javascript function to turn the text string of a month into the numerical equivalent? </p>
<p>Ex.
I have the name of the month "December" and I want a function to return "12".</p>
| <p>You can append some dummy day and year to the month name and then use the <a href="http://www.cev.washington.edu/lc/CLWEBCLB/jst/js_datetime.html" rel="nofollow noreferrer">Date</a> constructor:</p>
<pre><code>var month = (new Date("December 1, 1970").getMonth() + 1);
</code></pre>
| <p>I recommend jQuery's <a href="http://docs.jquery.com/UI/Datepicker/%24.datepicker.parseDate#formatvaluesettings" rel="nofollow noreferrer">datepicker utility functions</a>.</p>
| 44,136 |
<p>How can I build a loop in JavaScript?</p>
| <p><strong>For loops</strong></p>
<pre><code>for (i = startValue; i <= endValue; i++) {
// Before the loop: i is set to startValue
// After each iteration of the loop: i++ is executed
// The loop continues as long as i <= endValue is true
}
</code></pre>
<p><strong>For...in loops</strong></p>
<pre>... | <p>A loop in JavaScript looks like this:</p>
<pre><code>for (var = startvalue; var <= endvalue; var = var + increment) {
// code to be executed
}
</code></pre>
| 7,531 |
<p>My understanding is that C/C++ produces native code to run on a particular machine architecture. Conversely, languages like Java and C# run on top of a virtual machine which abstracts away the native architecture. Logically it would seem impossible for Java or C# to match the speed of C++ because of this intermedi... | <p>Generally, C# and Java can be just as fast or faster because the JIT compiler -- a compiler that compiles your IL the first time it's executed -- can make optimizations that a C++ compiled program cannot because it can query the machine. It can determine if the machine is Intel or AMD; Pentium 4, Core Solo, or Core ... | <p>On top of what some others have said, from my understanding .NET and Java are better at memory allocation. E.g. they can compact memory as it gets fragmented while C++ cannot (natively, but it can if you're using a clever garbage collector).</p>
| 17,497 |
<p>Considering the full list of PDC videos published <a href="http://channel9.msdn.com/posts/pdc2008/RSS/Default.aspx" rel="nofollow noreferrer">here</a> what are, in your opinion, the best session to download and see, considering their relevance to your work, technology and so on? Pleas, one session per answer (except... | <p>I would have to say that my favorite session was the "future of C#" video, very nice to be able to see what is coming in the future for C# and the .NET framework.</p>
| <p>I realy enjoyed watching <a href="http://channel9.msdn.com/pdc2008/TL47/" rel="nofollow noreferrer">A Lap Around VSTS 2010</a>. But the <a href="http://channel9.msdn.com/pdc2008/TL46/" rel="nofollow noreferrer">C# IDE tips and tricks</a> session is my favourite of those I've watched so far. I shows a lot of simple s... | 35,019 |
<p>I'm writing a search & replace function in a kind of spreadsheet program. What I want is that if you search for a string, the program shows a table with the element that has been found.</p>
<p>So far so good, but I cannot get the element to obtain the focus, with the cursor in it so you can immediately start ty... | <p>With some googling i found a forum thread : <a href="http://coding.derkeiler.com/Archive/Java/comp.lang.java.gui/2006-06/msg00188.html" rel="nofollow noreferrer">programmatically start editing a cell in a JTable</a> answered with following idea:</p>
<p>(in a subclass of JTable)</p>
<pre><code>editCellAt(row,column... | <p>Did you try the editcellat without the requestfocus ?</p>
<p>also make sure that you override/implemenet to return true</p>
<pre><code> /**
* Returns true.
* @param anEvent an event object
* @return true
*/
public boolean shouldSelectCell(EventObject anEvent) {
return true;
}
... | 49,861 |
<p>Has anyone implemented a very large EAV or open schema style database in SQL Server? I'm wondering if there are performance issues with this and how you were able to overcome those obstacles.</p>
| <p>Regardless of MS SQL Server versus any other brand of database, the worst performance issue with EAV is that people try to do monster queries to reconstruct an entity on a single row. <em>This requires a separate join per attribute</em>.</p>
<pre><code>SELECT e.id, a1.attr_value as "cost", a2.attr_value as "color"... | <p>I'm not an expert on EAV, but several more experienced developers than I have commented that Magento's open-source e-commerce framework is slow primarily because of the EAV architecture through MySQL. The most obvious disadvantage can't easily be overcome. That being the difficulty with which it is to troubleshoot w... | 23,440 |
<p>I've been evaluating ActiveMQ as a candidate message broker. I've written some test code to try and get an understanding of ActiveMQ's performance limitations. </p>
<p>I can produce a failure state in the broker by sending messages as fast as possible like this:</p>
<pre><code>try {
while(true) {
byte... | <p>You are testing the <a href="http://activemq.apache.org/producer-flow-control.html" rel="nofollow noreferrer">'slow consumer' and producer flowcontrol</a> issue all message brokers have to deal with. Do you wanna fail producers, block them or spool to disk? </p>
<p>Basically the out of the box default in ActiveMQ i... | <p>Not sure about ActiveMQ config, but other JMS providers have various configuration options - so you maybe able to get ActiveMQ to do as you wish in that situation.</p>
<p>I know Fiorano has options to specify whether providers block or not in this situation.</p>
| 44,755 |
<p>I can query the AD and find all the IIS sites and their virtual directories, now I need to be able to update those home directories and save the changes.</p>
<p>After I fetch the directory entry I can display the site path using <code>$site.Path</code>, however setting it doesn't seem to have any effect. It never ... | <pre><code>Import-Module WebAdministration
Set-ItemProperty 'IIS:\Sites\Default Web Site\' -name physicalPath -value $siteConfig.path
</code></pre>
<p><a href="http://technet.microsoft.com/en-us/library/ee909471(WS.10).aspx" rel="noreferrer">http://technet.microsoft.com/en-us/library/ee909471(WS.10).aspx</a></p>
| <p>Ok, I tried this and it seems to work:</p>
<pre><code> $s.psbase.properties.path[0] = $siteConfig.path
$s.psbase.CommitChanges()
</code></pre>
<p>Is there a better cleaner way of handling this?</p>
| 38,381 |
<p>I have code from PowerBuilder 5 that can't be built. The compiler just stops before it is done without any error codes.</p>
<p>I would like to upgrade the code to the recent version of PowerBuilder but there are some intermediate versions of PowerBuilder that have binary dependencies to an old Microsoft java dll th... | <p>Firstly, you don't need to use "intermediate versions of PowerBuilder" to migrate up to a current version, so even if this java DLL dependency sounds questionable to me (at least it doesn't ring a bell), it's irrelevant unless it affects the target version of PowerBuilder. </p>
<p>For migrating, you might want to c... | <p>From here:<a href="http://forums.sybase.com/cgi-bin/webnews.cgi?cmd=item-4558&group=sybase.public.powersite" rel="nofollow noreferrer">http://forums.sybase.com/cgi-bin/webnews.cgi?cmd=item-4558&group=sybase.public.powersite</a></p>
<p>I just learned that the combination of "severe" message, and message
that... | 19,856 |
<p>I'm building a site right now, so far I've painfully forced everything to be compliant and it looks pretty much the same across browsers. However, I'm starting to implement some third party/free javascripts which do things like add attributes (eg. order=2). I could work around this but it's a pain, and I'm starting ... | <p>The validation is useful to determine when things are failing to meet standards you presumably agree with. If you are purposefully using a tool that specifically adds something not in the validation standards, obviously that does not break your personal standards agreement.</p>
<p>This discussion gets much more dif... | <p>I try write compliant code most of the time weighing the time/cost vs the needs of the audience in all cases but one. Where you code needs to be 503 compliant, it is in your best interest and the interest of your audience to write compliant code. I've come across a bunch of screen readers that blow up when the cod... | 12,732 |
<p>I am fairly new to MySQL and have a project in which I need to design a database that will store responses from an online questionnaire. Reports will need to be written from the data. Does anyone have any tips on what type of fields to use? The questions will either have a Yes No answer, a choice of 4 options fro... | <p>I think comments like that are useless, unless of course the code is awful. With proper formatting of code it's not difficult to see where a block starts and where a block ends because usually those blocks are indented.</p>
<p>Edit:
If a procedure is so big that is not readily apparent what block of code is being ... | <p>If you have to consider whether or not a certain type of comment is usable or not, it's most likely the latter. </p>
<p>Comments are for explaining certain blocks of code or an entity in its whole, to ease up on comprehension; not to make the formatting easier to read. </p>
<p>Having a plugin always conform to thi... | 41,929 |
<p>I have a couple of lines of trivial code such as the following:</p>
<pre><code>NSData *dataReply;
NSString *stringReply;
dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
stringReply = [[NSString alloc] initWithData:dataReply encoding:NSUTF8StringEncoding... | <p>A "type mismatch" from the compiler when you try to use stringReply in another location has nothing to do with the object being returned from initWithData:encoding: and everything to do with where stringReply is subsequently being used.</p>
<p>For example, if you are getting a type mismatch when you do this:</p>
<... | <p>Not really sure what's going on, I ran the code below and got an NSString returned. Switching out the data with nil also works fine.</p>
<pre><code>const char* os = "12345";
NSString* str = [[NSString alloc] initWithData:[NSData dataWithBytes:os length:5 ] encoding:NSUTF8StringEncoding];
NSLog(@"%@", str);
</cod... | 43,957 |
<p>I've a a customer using IIS and an application, developed by us, in ASP.NET 1.1.
Monday, for 4 times in a row the following error has appeared:</p>
<blockquote>
<p>A process serving application pool 'xxxx' suffered a fatal communication error with the World Wide Web Publishing Service. The process id was 'yyyy'. The... | <p>I'm sure you already know this, but the App Pool contains 1.1 applications only right? I don't remember the error you get when the pool dies by trying to mix frameworks (something like Server Unavailable), but it's more common then I thought in the wild so I would double check.</p>
<p>While not likely the case, it... | <p>One more popular reason (as in my case) - one of windows logs is full. </p>
| 25,441 |
<p>I need a database where one (or more) fields behave like a wiki. I want the free-form content creation aspects of a wiki bolstered by the strict semantic structure of a database.</p>
<p>Specifically, I need this database field to hold wiki-style markup, track multi-user changes, allow reverts, etc...</p>
<p>I've ... | <p>Just for future reference, anybody interested in this may also want to check out the <a href="http://semantic-mediawiki.org/wiki/Semantic_MediaWiki" rel="noreferrer">semantic-mediawiki</a> extension:</p>
<blockquote>
<p><strong>Semantic MediaWiki (SMW)</strong> is a free extension of MediaWiki – the wiki-system ... | <p>The <a href="http://www.mediawiki.org/wiki/Extension:Attribute" rel="nofollow noreferrer">Attribute extension</a> of <a href="http://www.mediawiki.org/wiki/MediaWiki" rel="nofollow noreferrer">MediaWiki</a> will let you add custom attributes to a page.</p>
<p>If you really need more than this, the database structur... | 31,261 |
<p>I want to write an app to test whether a Windows machine is responding correctly to <strong>RDP (Remote Desktop)</strong> - i.e. to check if the machine not only allows the connection, but is also responding normally, and is not hung or otherwise responding abnormally.</p>
<p>Is there a library or utility that I ca... | <p>As <a href="https://stackoverflow.com/users/2525/blowdart">blowdart</a> mentioned, WCF Sessions are not the same as ASP.NET Sessions. You can read up on them here: <a href="http://msdn.microsoft.com/en-us/library/ms733040.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms733040.aspx</a>. Befo... | <p>If you host the service within IIS, you can still use the session that is from ASP.NET
by enabling aspnetcompatibility for the service behaviour.</p>
| 29,756 |
<pre><code>if __name__=='__main__':
parser = OptionParser()
parser.add_option("-i", "--input_file",
dest="input_filename",
help="Read input from FILE", metavar="FILE")
(options, args) = parser.parse_args()
print options
</code></pre>
<p>result is</p>
<pre><c... | <p>Python has nothing to do with this -- it's the shell.</p>
<p>Call</p>
<pre><code>$ python convert.py -i 'video_*'
</code></pre>
<p>and it will pass in that wildcard.</p>
<p>The other six values were passed in as args, not attached to the <code>-i</code>, exactly as if you'd run <code>python convert.py -i video_1... | <p>It isn't obvious, even if you read some of the standards (like <a href="http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html" rel="nofollow noreferrer">this</a> or <a href="http://www.faqs.org/docs/artu/ch10s05.html" rel="nofollow noreferrer">this</a>).</p>
<p>The <em>args</em> part of a command l... | 40,299 |
<p>The classic "Design Patterns: Elements of Reusable Object-Oriented Software" actually introduced most of us to the idea of design patterns.</p>
<p>However these days I find a book such as "Patterns of Enterprise Application Architecture" (POEA) by Martin Fowler, much more useful in my day to day work. </p>
<p>In ... | <p><a href="http://c2.com/cgi/wiki?CategoryPattern" rel="noreferrer">CategoryPatterns</a> on Ward's wiki contains a categorized list of patterns.</p>
<p>The first three are the GoF patterns</p>
<ul>
<li>Creational</li>
<li>Structural</li>
<li>Behavioural</li>
</ul>
<p>Then there are problem specific problems</p>
<ul>
<... | <p>The GoF patterns are also strictly applicable to code only. Fowler's patterns are not just for code but also for how data and system components are arranged and interconnected.</p>
<p>Also, some patterns are not necessary if they're already baked in the programming language. In some languages they are simply idioms... | 15,278 |
<p>Using .Net what limitations (if any) are there in using the XmlSerializer?
For example, can you serialize Images to XML?</p>
| <p>The XmlSerializer has a few drawbacks. </p>
<ol>
<li>It must know all the types being serialized. You cannot pass it something by interface that represents a type that the serializer does not know.</li>
<li>It cannot do circular references.</li>
<li>It will serializes the same object multiple times if referenced m... | <p>For collections they need to have an Add method taking a single argument. If you just need a text format and not specifically xml you might try JSON. I've developed one for .NET, <a href="http://jsonexserializer.googlecode.com" rel="nofollow noreferrer">JsonExSerializer</a>, and there are others available as well ... | 13,461 |
<p>Whilst starting to learn lisp, I've come across the term <em>tail-recursive</em>. What does it mean exactly?</p>
| <p>Consider a simple function that adds the first N natural numbers. (e.g. <code>sum(5) = 0 + 1 + 2 + 3 + 4 + 5 = 15</code>).</p>
<p>Here is a simple JavaScript implementation that uses recursion:</p>
<pre class="lang-js prettyprint-override"><code>function recsum(x) {
if (x === 0) {
return 0;
} else {
... | <p>This question has a lot of great answers... but I cannot help but chime in with an alternative take on how to define "tail recursion", or at least "proper tail recursion." Namely: should one look at it as a property of a particular expression in a program? Or should one look at it as a property of an <em>implementat... | 5,405 |
<p>I have reached the point where I've decided to replace my custom-built replication system with a system that has been built by someone else, mainly for reliability purposes. Can anyone recommend any replication system that is worth it? Is <a href="http://fibre.sourceforge.net" rel="noreferrer">FiBRE</a> any good?</p... | <p>I have used CopyCat to create a replication project. It allows you create your own replication client/server configuration using CodeGear Delphi. This allows you complete flexibilty as to how you want your replication to work.</p>
<p>If you don't use Delphi, or need a prefabricated solution, CopyTiger does the s... | <p>The Ibphoenix site list replication tools</p>
<p><a href="http://www.ibphoenix.com/download/tools/replication" rel="nofollow noreferrer">IbPhoenix Replication Tools</a></p>
| 8,727 |
<p>I have a multithreded application in perl for which I have to rely on several non-thread safe modules, so I have been using <code>fork()</code>ed processes with <code>kill()</code> signals as a message passing interface.</p>
<p>The problem is that the signal handlers are a bit erratic (to say the least) and often e... | <p>You can always have a pipe between parent and child to pass messages back and forth.</p>
<pre><code>pipe my $reader, my $writer;
my $pid = fork();
if ( $pid == 0 ) {
close $reader;
...
}
else {
close $writer;
my $msg_from_child = <$reader>;
....
}
</code></pre>
<p>Not a very comfortable w... | <p>From perl 5.8 onwards you should be looking at the core threads module. Have a look at <a href="http://metacpan.org/pod/threads" rel="nofollow noreferrer">http://metacpan.org/pod/threads</a></p>
<p>If you want to use modules which aren't thread safe you can usually load them with a require and import inside the thr... | 16,798 |
<p>I want to hold a bunch of const char pointers into an std::set container [1]. std::set template requires a comparator functor, and the standard C++ library offers std::less, but its implementation is based on comparing the two keys directly, which is not standard for pointers.</p>
<p>I know I can define my own fun... | <p>If you don't want to wrap them in <code>std::string</code>s, you can define a functor class:</p>
<pre><code>struct ConstCharStarComparator
{
bool operator()(const char *s1, const char *s2) const
{
return strcmp(s1, s2) < 0;
}
};
typedef std::set<const char *, ConstCharStarComparator> stringset_t... | <p>Presumably you don't want to use std::string because of performance reasons.</p>
<p>I'm running MSVC and gcc, and they both seem to not mind this:</p>
<pre><code>bool foo = "blah" < "grar";
</code></pre>
<p>EDIT: However, the behaviour in this case is unspecified. See comments... </p>
<p>They also don't com... | 29,127 |
<p>Let's aggregate a list of free quality web site design templates. There are a million of these sites out there, but most are repetitive and boring. </p>
<p>I'll start with <a href="http://www.freecsstemplates.org/" rel="noreferrer">freeCSStemplates.org</a></p>
<p>I also think other sites should follow some sort of... | <p>Check out:</p>
<ul>
<li><a href="http://www.oswd.org/" rel="noreferrer">Open Source Web Designs</a></li>
<li><a href="http://cssremix.com/" rel="noreferrer">CSS Remix</a></li>
<li><a href="http://bestwebgallery.com/" rel="noreferrer">Best Web Gallery</a></li>
<li><a href="http://www.cssbased.com/" rel="noreferrer">... | <p>+1 for <a href="http://www.csszengarden.com/" rel="nofollow noreferrer">Zen garden.</a></p>
<p>I like the resources at <a href="http://inobscuro.com/" rel="nofollow noreferrer">inobscuro.com</a></p>
| 2,481 |
<h3>TL;DR</h3>
<p>Is ABS a better material to use for structural parts of a 3D printer, as opposed to PLA?</p>
<hr />
<p>I have been looking at various suppliers of printed parts for a <a href="http://reprap.org/wiki/Wilson_TS#Wilson_II" rel="noreferrer">Wilson II</a>, on eBay.</p>
<p><a href="http://www.ebay.co.uk/itm... | <p>To answer the main question "Is ABS better for structural parts of a 3D printer as opposed to PLA".</p>
<p>The answer, unfortunately is it depends.</p>
<p>ABS has lower yield and ultimate strengths compared to PLA. This means that at room temperatures, ABS is weaker than PLA. However the difference between yield a... | <p>Actually, Both PLA and ABS could use for structural parts. PLA has high strength and is brittleness. ABS has better thermal resistance and durable. <a href="https://ecoreprap.com/pla-vs-abs/" rel="nofollow noreferrer">PLA and ABS</a> are the main types of 3D printing material, each has cons and pros.</p>
<p>If you w... | 584 |
<p>(I've asked the same question of the jmeter-user mailing list, but I wanted to try here as well - so at the least I can update this with the answer once I find it).</p>
<p>I'm having trouble using <a href="http://jakarta.apache.org/jmeter/" rel="noreferrer">JMeter</a> to test a Tomcat webapp using a self-signed SSL... | <p>Most <code>javax.net.SocketFactory</code> implementations define all <code>createSocket()</code> methods <strong>that have parameters</strong> as abstract. But have a <code>createSocket()</code> method without parameters that looks like this:</p>
<pre><code>public Socket createSocket() throws IOException {
throw... | <p>I had Web Service problems similar to this with jdk 1.6.0_10.</p>
<p>I upgraded to 1.6.0_16 and everything worked.</p>
| 14,209 |
<p>We are developing in an embedded type environment and find ourselves needing to create our own UI framework.</p>
<p>I have done this before, but I am interested in doing a little bit of research around common design patterns for frameworks.</p>
<p>Types of things that I am thinking of as patterns (somewhat far rea... | <p>I have two for you, the callback or notification, maybe this is what you call "attaching commands to widgets", somehow you want to react to changes in state in your UI element. The controller needs to be informed that a change has occured. </p>
<p>Cocoa/UIKit has a pattern that is called "Delegation" and notificati... | <p>Study <a href="http://msdn.microsoft.com/en-us/library/ms752059.aspx" rel="nofollow noreferrer">XAML</a>, especially bindings. </p>
<p>Microsoft have done a really nice job on a clean XML language to describe GUI layout and if you use a simplified version of XAML for your UI description you will be able to use thei... | 41,164 |
<p>I've gotten to grips with the basics of Python and I've got a small holiday which I want to use some of to learn a little more Python. The problem is that I have no idea what to learn or where to start. I'm primarily web development but in this case I don't know how much difference it will make.</p>
| <p>Well, there are great ressources for advanced Python programming :</p>
<ul>
<li>Dive Into Python (<a href="http://www.diveintopython.net/" rel="nofollow noreferrer">read it for free</a>)</li>
<li>Online python cookbooks (e.g. <a href="http://code.activestate.com/recipes/langs/python/" rel="nofollow noreferrer">here... | <p>I'd suggest writing a non-trivial webapp using either Django or Pylons, something that does some number crunching.
No better way to learn a new language than commiting yourself to a problem and learning as you go!</p>
| 11,768 |
<p>How do you automate <a href="http://en.wikipedia.org/wiki/Integration_testing" rel="noreferrer">integration testing</a>? I use JUnit for some of these tests. This is one of the solutions or is totally wrong? What do you suggest?</p>
| <p>I've used JUnit for doing a lot of integration testing. Integration testing can, of course, mean many different things. For more system level integration tests, I prefer to let scripts drive my testing process from outside.</p>
<p>Here's an approach that works well for me for applications that use http and database... | <p>Definitely!
We use a combination of JUnit, ANT tasks to run them, and <a href="http://hudson-ci.org/" rel="nofollow noreferrer">Hudson</a> for continues integration tests. Works like a charm.</p>
| 36,136 |
<p>Suppose I have a directory of 100 .ISO files. Do you know how I could automate burning them to DVDs? I'd basically like to send them to a DVD burner with a hopper of DVDs similar to how you can print sheets of paper on a printer.</p>
<p>Any ideas on how to do this on Windows?</p>
| <p><a href="http://www.imgburn.com/" rel="nofollow noreferrer">http://www.imgburn.com/</a></p>
<p>"There is an image queue system for when you're burning several images (which you can automatically share between multiple drives if you have more than one)"</p>
| <p>On Mac OS, you could probably use Toast and AppleScript it.</p>
<p>BTW, what do you mean by "hopper"? You don't think of a mechanism to swap the media for you, do you? There are such machines, but that's not really programming related, and they come with software for such a task.</p>
| 46,046 |
<p>What's the best way to calculate percentile rankings (e.g. the 90th percentile or the median score) in MSSQL 2005?</p>
<p>I'd like to be able to select the 25th, median, and 75th percentiles for a single column of scores (preferably in a single record so I can combine with average, max, and min). So for example, t... | <p>I would think that this would be the simplest solution:</p>
<pre><code>SELECT TOP N PERCENT FROM TheTable ORDER BY TheScore DESC
</code></pre>
<p>Where N = (100 - desired percentile). So if you wanted all rows in the 90th percentile, you'd select the top 10%.</p>
<p>I'm not sure what you mean by "preferably in a... | <p>i'd probably use a the sql server 2005 </p>
<blockquote>
<p>row_number() over (order by score ) / (select count(*) from scores)</p>
</blockquote>
<p>or something along those lines. </p>
| 10,509 |
<p>After reading many of the replies to <a href="https://stackoverflow.com/questions/244302/what-do-you-think-of-the-new-c-40-dynamic-keyword">this thread</a>, I see that many of those who dislike it cite the potential for abuse of the new keyword. My question is, what sort of abuse? How could this be abused so badly a... | <p>Some see it as a tool that will be abused. Like "Option Strict Off" and "On Error Resume Next" in VB which "pure" languages like C# and Java have never had. </p>
<p>Many said the same about the "var" keyword, yet I don't see it being abused, once it became understood that it wasn't the same as VB's "Variant"</p>
... | <p>I don't see a reason why the current way of invoking methods dynamicly is flawed:</p>
<p>It takes three lines to do it, or you can add a extension method on System.Object to do it for you:</p>
<pre><code>class Program
{
static void Main(string[] args)
{
var foo = new Foo();
Cons... | 30,429 |
<p>I'm learning xForms, but apparently not well enough because I can't figure out why <a href="http://www.logomachist.info/temp/fix_me.xhtml.xml" rel="nofollow noreferrer">this code</a> doesn't work. </p>
<p>It parses in FF2 w/ the xForms extension but does not render the form controls. IE7 and X-Smiles give me differ... | <p>This document contains a ton of problems unfortunately, I'll go through each of them in turn.</p>
<p>1) The biggest problem occurs a few times and seems to stem from some confusion between the <code>model</code> and the UI. The two are entirely separate beasts in XForms, which adheres to the model-view-controller d... | <p>You shouldn't place your models in the body section. Instead all model definitions should be in the head section. As it is now, your code isn't standard compliant and is very difficult to understand. </p>
<p><a href="http://en.wikibooks.org/wiki/XForms" rel="nofollow noreferrer">Xforms Wiki book</a> is a good resou... | 37,682 |
<p>I recently installed MySQL 5 on Windows 2003 and tried configuring an instance. Everything worked fine until I got to "Applying Security settings", at which point it gave me the above error (<code>Can't connect to MySQL server on 'localhost' (10061)</code>).</p>
<p>I do have a port 3306 exception in my firewall for... | <p>You'll probably have to grant 'localhost' privileges to on the table to the user. See the <code>'GRANT'</code> syntax documentation. Here's an example (from some C source).</p>
<blockquote>
<p>"GRANT ALL PRIVILEGES ON %s.* TO '%s'@'localhost' IDENTIFIED BY '%s'";</p>
</blockquote>
<p>That's the most common acc... | <ol>
<li>Right click on My Computer </li>
<li>Click on Manage</li>
<li>Go to Services and Application</li>
<li>Select Services and find MySQL service</li>
<li>Right click on MySQL and select Start </li>
</ol>
| 14,478 |
<p>I'm building a demo app in WPF, which is new to me. I'm currently displaying text in a FlowDocument, and need to print it.</p>
<p>The code I'm using looks like this:</p>
<pre><code> PrintDialog pd = new PrintDialog();
fd.PageHeight = pd.PrintableAreaHeight;
fd.PageWidth = pd.PrintableAreaWi... | <p>yes, make a copy of the FlowDocument before printing it. This is because the pagination and margins will be different. This works for me.</p>
<pre><code> private void DoThePrint(System.Windows.Documents.FlowDocument document)
{
// Clone the source document's content into a new FlowDocument.
... | <p>I am also generating a WPF report off a Flow document, but I am purposely using the flow document as a print preview screen. I there for want the margins to be the same. You can read about <a href="http://kiwiingenuity.net.nz/post/My-First-WPF-Report" rel="nofollow noreferrer">how I did this here</a>.</p>
<p>In y... | 44,887 |
<p>I have a .z80 memory dump. How do I reverse engineer it? What do I need to know? How can I minimize manual labour?</p>
| <p>Most powerful disassembler - <a href="http://www.hex-rays.com/idapro" rel="noreferrer">IDA</a> supports z80.</p>
<p>Also list of disassemblers published at "<a href="http://www.z80.info/z80sdt.htm" rel="noreferrer">Software Development Tools for Z80 Family</a>" page</p>
| <p>It depends on what operating system your in, there are a lot of good tools here:</p>
<p><a href="http://www.z80.info/z80sdt.htm" rel="nofollow noreferrer">http://www.z80.info/z80sdt.htm</a></p>
<p>The first program I ever wrote was in Z80 Assembly language. </p>
| 13,388 |
<p>Here is a simplification of my database:</p>
<pre>Table: Property
Fields: ID, Address
Table: Quote
Fields: ID, PropertyID, BespokeQuoteFields...
Table: Job
Fields: ID, PropertyID, BespokeJobFields...</pre>
<p>Then we have other tables that relate to the <strong>Quote</strong> and <strong>Job</strong> tables indi... | <p>Create one Message table, containing a unique MessageId and the various properties you need to store for a message.</p>
<pre><code>Table: Message
Fields: Id, TimeReceived, MessageDetails, WhateverElse...
</code></pre>
<p>Create two link tables - QuoteMessage and JobMessage. These will just contain two fields each,... | <p>Why not just have both QuoteId and JobId fields in the message table? Or does a message have to be regarding either a quote or a job and not both?</p>
| 3,998 |
<p>I'm wondering why the <code>assert</code> keyword is so underused in Java? I've almost never seen them used, but I think they're a great idea. I certainly much prefer the brevity of:</p>
<pre><code>assert param != null : "Param cannot be null";
</code></pre>
<p>to the verbosity of:</p>
<pre><code>if (param == nul... | <p><em>assertions</em> are, in theory, for testing <a href="http://en.wikipedia.org/wiki/Invariant_(computer_science)" rel="nofollow noreferrer">invariants</a>, assumptions that <strong>must</strong> be true in order for the code to complete properly. </p>
<p>The example shown is testing for valid input, which isn't a... | <p>In fact they arrived in Java 1.4.</p>
<p>I think the main problem is that when you code in an environment where you do not manage JVM options directly by yourself like in <a href="https://en.wikipedia.org/wiki/Eclipse_%28software%29" rel="nofollow noreferrer">Eclipse</a> or J2EE servers (in both cases it is possibl... | 38,281 |
<p>In our application we enable users to print pages. We do this by supplying a button which when click calls the window.print() function.<br>
Some of the pages would look better if they were printed in landscape mode rather than portrait. Is there a way to control the page layout from JavaScript? </p>
<p>Update: Fol... | <p>You should use a print stylesheet.</p>
<pre><code><link rel="stylesheet" href="print.css" type="text/css" media="print" />
</code></pre>
<p>More info...</p>
<p><a href="https://stackoverflow.com/questions/224078/how-to-print-only-parts-of-a-page">How to print only parts of a page?</a></p>
<p>Edit: to coerc... | <p>Unfortunately, this is still not possible cross-browser. For Internet Explorer, there is an <a href="http://www.meadroid.com/scriptx/about.asp" rel="nofollow noreferrer">ActiveX control</a> that does it. </p>
<p>Otherwise your best bet might be to offer the option of a PDF version for printing.</p>
| 29,597 |
<p>On my busiest production installation, on occasion I get a single thread that seems to get stuck in an infinite loop. I've not managed to figure out who is the culprit, after much research and debugging, but it seems like it should be possible. Here are the gory details:</p>
<p><strong><em>Current debugging notes... | <p>It looks like the <strong>nid</strong> in the jstack output is the Linux LWP id.</p>
<pre><code>"http-342.877.573.944-8080-360" daemon prio=10 tid=0x0000002adaba9c00 nid=0x754c in Object.wait() [0x00000000595bc000..0x00000000595bccb0]
</code></pre>
<p>Convert the nid to decimal and you have the LWP id. In your cas... | <p>From memory if you CTRL-BREAK on the console you will get a dump of the current threads and a few of their stack trace frames.</p>
<p>From memory (I'm not sure if this is an IntelliJ IDEa feature, or it is default in java) but it will tell you which thread is deadlocked, and which object they are waiting on. You sh... | 27,395 |
<p>I'm learning objective-C and Cocoa. In the Apple tutorial I'm working through there's a side note that says: </p>
<blockquote>
<p><code>IBOutlet</code> is a null-defined macro, which the C preprocessor removes at compile time.</p>
</blockquote>
<p>I'm curious - what's a null-defined macro?</p>
| <pre><code>#define IBOutlet
</code></pre>
<p>Whenever IBOutlet is used in program text, it will be replaced with nothing at all.</p>
| <p>Also - if you're unsure how anything is defined - command double-click it and Xcode will open the definition in the original source file.</p>
| 4,203 |
<p>I've created a DeskBand toolbar and I want to display a button on the toolbar that has the style visual style as a taskbar button.</p>
<p>In .NET you can use the VisualStyleRenderer to render the Taskbar BACKGROUND, but there's way to render a button.</p>
<p>Are there any Win32 API's I can use to draw the button u... | <p>I know this topic is old but,...:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstyleelement.taskband.flashbuttongroupmenu.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstyleelement.taskband.flashbutt... | <p>So far, I have only been able to find <a href="https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1761337&SiteID=1" rel="nofollow noreferrer">a solution that reportedly works on Vista</a> according to the forum discussion linked. It would seem that the UxTheme.dll for XP does not support the retrieval of sub... | 32,543 |
<p>I receive this message (see image below) when I try to edit in debugging. This occur only in my Vista64bits OS, not in my XP computer. Why and what should I do?</p>
<p><strong>Update</strong>
I found that I need to compile in x86 to be able to change value when debugging. So my question is WHY that I can't do it in... | <p>There is no technical reason, it is just simply not implemented. According to some sources, Microsoft wants to implement it by the next release of the CLR.</p>
<p>See:
<a href="http://blogs.msdn.com/stevejs/archive/2005/11/15/493018.aspx#499593" rel="nofollow noreferrer">http://blogs.msdn.com/stevejs/archive/2005/1... | <p>Presumably they just haven't implemented edit-and-continue yet for x64 code. I don't think there's any deeper reason to it.</p>
| 25,354 |
<p>In a Java project (SWT desktop app), I want to inform the user about events through animated notification box (actually, it's not required to be animated). Something like MSN or any other IM client.</p>
<p>There is <a href="http://jtoaster.sourceforge.net/" rel="nofollow noreferrer">JToaster</a> for Swing, but I wo... | <p>The <a href="http://www.eclipse.org/mylyn" rel="nofollow noreferrer">MyLyn</a> plugin for Eclipse does this. Since it's open source, maybe you can check the MyLyn code to see how it's done there?</p>
| <p>Check the <a href="http://www.novocode.com/swt/" rel="nofollow noreferrer">BallonWindow from Novocode</a>, it does something similar to what you need, without delving deep into an open source project. It is not animated, but it does show a notification as a separate window with an irregular background.</p>
<p>I ha... | 48,997 |
<p>What is the shortcut in eclipse to terminate debugging/running? Looking under Preferences -> Keys says <kbd>Ctrl</kbd> + <kbd>F2</kbd> but it doesn't work.</p>
| <p>As said <a href="http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg21758.html" rel="noreferrer">here</a>, you can add/enable the Debug command group to any perspective using<br>
<code>Window / Customize Perspective > Commands</code>.<br>
(Select the 'Debug' group)</p>
<p>Then open the Debug view in the J... | <p>F2 could be already used by your Operating System, which can intercept the keystroke before Eclipse gets a chance.</p>
<p>On macs, the F2 key is often used to increase the screen brightness. This will take precedence over anything that Eclipse will assign it. Translation: when you hit F2 on some macs (depending o... | 41,549 |
<p>I need to do some process injection using C++ but I would prefer to use C# for everything other than the low level stuff. I have heard about "function wrapping" and "marshaling" and have done quite a bit of google searching and have found bits of information here and there but I am still really lacking. </p>
<p>Thi... | <p>I think P/Invoke is really the most straightforward approach:</p>
<ul>
<li>Create a DLL in <em>unmanaged</em> C++, containing all the functionality you need to do the injection.</li>
<li>In your C# code, declare some <code>static extern</code> methods, and use the <code>DllImport</code> attribute to point them to y... | <p>If Pinvoking isn't what you want to do, then create a managed C++ application. Use native C++ to do the process injection stuff. Use managed c++ to create a .NET friendly interface to this native behaviour. This can then be called from C#.</p>
| 37,314 |
<p>I am creating a small app to teach myself ASP.NET MVC and JQuery, and one of the pages is a list of items in which some can be selected. Then I would like to press a button and send a List (or something equivalent) to my controller containing the ids of the items that were selected, using JQuery's Post function.</p>... | <p>I modified my response to include the code for a test app I did.</p>
<p><strong>Update: I have updated the jQuery to set the 'traditional' setting to true so this will work again (per @DustinDavis' answer).</strong></p>
<p>First the javascript:</p>
<pre><code>function test()
{
var stringArray = new Array();
... | <p>The answer helped me a lot in my situation so thanks for that.
However for future reference people should bind to a model and then validate. This post from Phil Haack describes this for MVC 2. <a href="http://haacked.com/archive/2010/04/15/sending-json-to-an-asp-net-mvc-action-method-argument.aspx" rel="nofollow">h... | 39,828 |
<p>In python you can use a tuple in a formatted print statement and the tuple values are used at the indicated positions in the formatted string. For example:</p>
<pre><code>>>> a = (1,"Hello",7.2)
>>> print "these are the values %d, %s, %f" % a
these are the values 1, Hello, 7.200000
</code></pre>
... | <p>printf will have a declaration along the lines of:</p>
<pre><code>public PrintString printf(String format, Object... args);
</code></pre>
<p>... means much the same as <code>[]</code>. The difference is <code>...</code> allows the caller to omit explicitly creating an array. So consider:</p>
<pre><code> out.pr... | <p>You might be interested by the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html" rel="nofollow noreferrer" title="java.text.MessageFormat">MessageFormat</a> class too.</p>
| 17,633 |
<p>I'm working on a program that will be processing files that could potentially be 100GB or more in size. The files contain sets of variable length records. I've got a first implementation up and running and am now looking towards improving performance, particularly at doing I/O more efficiently since the input file g... | <p>I was trying to find the final word on mmap / read performance on Linux and I came across a nice post (<a href="http://marc.info/?l=linux-kernel&m=95496636207616&w=2" rel="noreferrer">link</a>) on the Linux kernel mailing list. It's from 2000, so there have been many improvements to IO and virtual memory in... | <p>I think the greatest thing about mmap is potential for asynchronous reading with:</p>
<pre><code> addr1 = NULL;
while( size_left > 0 ) {
r = min(MMAP_SIZE, size_left);
addr2 = mmap(NULL, r,
PROT_READ, MAP_FLAGS,
0, pos);
if (addr1 != NULL)
{
... | 6,800 |
<p>I'm working with a large (270+ project) VS.Net solution. Yes, I know this is pushing the friendship with VS but it's inherited and blah blah. Anyway, to speed up the solution load and compile time I've removed all projects that I'm not currently working on... which in turn has removed those project references from... | <p>These solutions come to my mind:</p>
<ul>
<li>You can try to use <a href="http://www.dependencywalker.com" rel="nofollow noreferrer">Dependency Walker</a> or similar program to analyze dependecies.</li>
<li>Parse MSBuild files (*.csproject) to get list of dependencies</li>
</ul>
<p><strong>EDIT:</strong><br>
Just ... | <p>One thing you can try is opening up the old .csproj file in notepad and replacing the ProjectReference tags with Reference tags. If you can write a parser, feel free to share. :)</p>
<p>Entry in .csproj file if it is a project reference</p>
<pre><code> <ItemGroup>
<ProjectReference Include="..\Window... | 7,753 |
<p>What algorithm does twitter use to determine the 10 topics that you can see at <a href="http://search.twitter.com" rel="nofollow noreferrer">search.twitter.com</a>? I would like to implement that algorithm and I would also like to show the 50 most popular topics (instead of 10). Can you describe the most efficient a... | <p>Twitter's trending algorithm is not just volume of keywords. That's part of it, but there's also a decay factor so that "justin beiber" isn't top trending forever. </p>
<p>This post on quora backs this up. <a href="http://www.quora.com/Trending-Topics-Twitter/What-is-the-basis-of-Twitters-current-Trending-Topics-... | <p>So what Twitter probably does is it counts the number of mentions of a particular term minus stop words (stop words like : do, me, you, I, not, on etc)
So "the cat is out of the bag" and "my dog ate my cat" would mean that cat ,dog and bag would be the terms it extracted (the rest are all stop words)
And it then co... | 17,348 |
<p>When can 64-bit writes be guaranteed to be atomic, when programming in C on an Intel x86-based platform (in particular, an Intel-based Mac running MacOSX 10.4 using the Intel compiler)? For example:</p>
<pre><code>unsigned long long int y;
y = 0xfedcba87654321ULL;
/* ... a bunch of other time-consuming stuff happe... | <p>Your best bet is to avoid trying to build your own system out of primitives, and instead use locking unless it <strong>really</strong> shows up as a hot spot when profiling. (If you think you can be clever and avoid locks, don't. You aren't. That's the general "you" which includes me and everybody else.) You sho... | <p>GCC has intrinsics for atomic operations; I suspect you can do similar with other compilers, too. Never rely on the compiler for atomic operations; optimization will almost certainly run the risk of making even obviously atomic operations into non-atomic ones unless you explicitly tell the compiler not to do so.</p... | 10,374 |
<p>I'd like the canonical way to do this. My Google searches have come up short. I have one ActiveRecord model that should map to a different database than the rest of the application. I would like to store the new configurations in the database.yml file as well.</p>
<p>I understand that establish_connection should... | <p>Also, it is a good idea to subclass your model that uses different database, such as:</p>
<pre><code>class AnotherBase < ActiveRecord::Base
self.abstract_class = true
establish_connection "anotherbase_#{RAILS_ENV}"
end
</code></pre>
<p>And in your model</p>
<pre><code>class Foo < AnotherBase
end
</code>... | <p>Heh. I was right! More cleanly:</p>
<pre><code>class Foo < ActiveRecord::Base
establish_connection "foo_#{ENV['RAILS_ENV']}"
end
</code></pre>
<p>Great post <a href="http://pragdave.me/blog/2006/01/03/sharing-external-activerecord-connections/" rel="nofollow noreferrer">at pragedave.pragprog.com</a>.</p>
| 17,053 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.