instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>How do you usually convert line breaks in a form textbox or input=text element to html line breaks?</p>
<p>Thanks</p>
<p>Edit: Is it always \r\n with all browsers?</p>
| <p>Or in C#:</p>
<pre><code>myString.Replace("\r\n", "<br />");
</code></pre>
<p>If you're worried about it being different on different platforms, you could also do: </p>
<pre><code>myString.Replace("\r\n", "<br />");
myString.Replace("\n", "<br />");
myString.Replace("\r", "<br />");
</code... | <p>You will most likely have to escape the back slashes for it to behave the way you are expecting.</p>
<pre><code>MyString.Replace("\\r\\n", "<br />")
</code></pre>
<p>or </p>
<pre><code>MyString.Replace("\\r\\n", Environment.NewLine)
</code></pre>
| 45,799 |
<p>I noticed that the generic <code>IEnumerator<T></code> inherits from IDisposable, but the non-generic interface IEnumerator does not. Why is it designed in this way?</p>
<p>Usually, we use foreach statement to go through a <code>IEnumerator<T></code> instance. The generated code of foreach actually has ... | <p>Basically it was an oversight. In C# 1.0, <code>foreach</code> <em>never</em> called <code>Dispose</code> <sup>1</sup>. With C# 1.2 (introduced in VS2003 - there's no 1.1, bizarrely) <code>foreach</code> began to check in the <code>finally</code> block whether or not the iterator implemented <code>IDisposable</code>... | <p>IIRC The whole thing about having <code>IEnumerable<T></code> and <code>IEnumerable</code> is a result of <code>IEnumerable</code> predating .Net's template stuff. I suspect that your question is in the same way.</p>
| 28,779 |
<p>JavaScript needs access to cookies if AJAX is used on a site with access restrictions based on cookies. Will HttpOnly cookies work on an AJAX site? </p>
<p><em>Edit:</em> Microsoft created a way to prevent XSS attacks by disallowing JavaScript access to cookies if HttpOnly is specified. FireFox later adopted this. ... | <p>Yes, HTTP-Only cookies would be fine for this functionality. They will still be provided with the XmlHttpRequest's request to the server.</p>
<p>In the case of Stack Overflow, the cookies are automatically provided as part of the XmlHttpRequest request. I don't know the implementation details of the Stack Overflo... | <p>No, the page that the AJAX call requests has access to cookies too & that's what checks whether you're logged in.</p>
<p>You can do other authentication with the Javascript, but I wouldn't trust it, I always prefer putting any sort of authentication checking in the back-end.</p>
| 4,764 |
<p>Anyone know this compiler feature? It seems GCC support that. How does it work? What is the potential gain? In which case it's good? Inner loops?</p>
<p>(this question is specific, not about optimization in general, thanks)</p>
| <p>It works by placing extra code to count the number of times each codepath is taken. When you compile a second time the compiler uses the knowledge gained about execution of your program that it could only guess at before. There are a couple things PGO can work toward:</p>
<ul>
<li>Deciding which functions should be... | <p>The fun thing about optimization is that speed gains are found in the unlikeliest of places.</p>
<p>It's also the reason you need a profiler, rather than guessing where the speed problems are.</p>
<p>I recommend starting with a profiler (<code>gperf</code> if you're using GCC) and just start poking around the resu... | 7,578 |
<p>ExtJS has Ext.each() function, but is there a map() also hidden somewhere?</p>
<p>I have tried hard, but haven't found anything that could fill this role. It seems to be something simple and trivial, that a JS library so large as Ext clearly must have.</p>
<p>Or when Ext really doesn't include it, what would be th... | <p>It appears, that my colleges here are using <a href="http://code.google.com/p/ext-basex/" rel="nofollow noreferrer">ext-basex</a>, which extends Array.prototype with map() and other methods.</p>
<p>So I can just write:</p>
<pre><code>[1, 2, 3].map( function(){ ... } );
</code></pre>
<p>Problem solved.</p>
| <p>ExtJS doesn't replace Javascript language itself. Array functions aren't in the focus of ExtJS core. However there is a special Ext.Array object type. You can extend it on your own.</p>
<p>EDIT: Not Ext.Array, but just extended Array object.</p>
| 31,344 |
<p>I'm helping a typical small company that started with a couple of outsourced systems (google apps, svn/trac). added an internal jabber server (ejabber for mostly iChat clients). subscribes to a couple of webservices (e.g. highrisehq). and has a vpn service provided by a pfsense freebsd firewall.</p>
<p>And the net ... | <p>It's been over a year since you originaly asked the question, so I'm guessing you've solved your problem by now. But if someone else is interested in a possible solution I suggest the following:</p>
<p>First of all, I don't know of any "all in one" solution to your problem. However it's quite easy to combine three ... | <p>This is something I was looking for as well, and <a href="http://www.turnkeylinux.org/openldap" rel="nofollow">http://www.turnkeylinux.org/openldap</a> looks like the solution: "appliance" installation, and it includes encrypted online backup which is easily restored to a new or replacement machine. </p>
| 41,364 |
<p>Is there a way to configure a Visual Studio 2005 Web Deployment Project to install an application into a named Application Pool rather than the default app pool for a given web site?</p>
| <p>There is a good article describing custom actions here:
<a href="http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx" rel="nofollow noreferrer">ScottGu's Blog</a></p>
<p>The question you asked is answered about halfway through the comments by 'Ryan'... | <p>You can use a CustomAction to modify IIS during deployment, Here is an article how to do it:
<a href="http://msdn.microsoft.com/en-us/library/aa289522.aspx" rel="nofollow noreferrer">Modifying Internet Information Services During Deployment with Custom Actions</a></p>
<p>The example in the article is in VB.Net, and... | 20,195 |
<p>I have the following code block in my xslt;</p>
<pre><code> <xsl:when test="StatusData/Status/Temperature > 27">
<td bgcolor="#ffaaaa">
<xsl:value-of select="StatusData/Status/Temperature" />
</td>
</xsl:when>
</code><... | <p>There is a <code>translate()</code> function in XPath:</p>
<pre><code>test="translate(StatusData/Status/Temperature, ",", ".") > 27"
</code></pre>
<p>Additionally you should make use of the number function, which converts it's argument to a number (or NaN, if that fails):</p>
<pre><code>test="number(translate(... | <p>Thanx a lot.</p>
<p>it works but with one simple modification:</p>
<pre><code>test="number(translate(StatusData/Status/Temperature, ',', '.')) > 27.0"
</code></pre>
<p>by the way it is not about XSLT it is about XPath :) good to learn...</p>
| 33,644 |
<p>Does anybody know good illustration for basic <a href="http://subversion.tigris.org/" rel="nofollow noreferrer">Subversion</a> usage? Something like images in this directory: <a href="http://www.ivy.fr/mercurial/ref/v1.0/" rel="nofollow noreferrer">http://www.ivy.fr/mercurial/ref/v1.0/</a> (they are for <a href="htt... | <p>That one is more detailed (From <a href="http://agata.in2p3.fr/dotclear/index.php?2005/05/13/6-subversion-svn-quickstart" rel="nofollow noreferrer">Subversion (svn) quickstart</a>):</p>
<p><img src="https://i.stack.imgur.com/aE3jL.png" alt="alt text"></p>
| <p>Another <a href="http://aji.techshu.com/svn/" rel="nofollow noreferrer">good introduction</a>:</p>
<p><a href="https://i.stack.imgur.com/egDkP.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/egDkP.gif" alt="alt text"></a><br>
<sub>(source: <a href="http://img.idealwebtools.com/blog/svn.gif" rel="... | 42,838 |
<p>I using the Win32 API and C/C++. I have a HFONT and want to use it to create a new HFONT. The new font should use the exact same font metrics except that it should be bold. Something like:</p>
<pre><code>HFONT CreateBoldFont(HFONT hFont) {
LOGFONT lf;
GetLogicalFont(hFont, &lf);
lf.lfWeight = FW_BOL... | <p>You want to use the <a href="http://msdn.microsoft.com/en-us/library/dd144904%28v=vs.85%29.aspx" rel="noreferrer">GetObject function</a>.</p>
<pre><code>GetObject ( hFont, sizeof(LOGFONT), &lf );
</code></pre>
| <p>Something like this - note that error checking is left as an exercise for the reader. :-)</p>
<pre><code>static HFONT CreateBoldWindowFont(HWND window)
{
const HFONT font = (HFONT)::SendMessage(window, WM_GETFONT, 0, 0);
LOGFONT fontAttributes = { 0 };
::GetObject(font, sizeof(fontAttributes), &font... | 48,483 |
<p>It's known that you should declare events that take as parameters <code>(object sender, EventArgs args)</code>. Why?</p>
| <p>This allows the consuming developer the ability to write a single event handler for multiple events, regardless of sender or event.</p>
<p><strong>Edit:</strong> Why would you need a different pattern? You can inherit EventArgs to provide any amount of data, and changing the pattern is only going to serve to confu... | <p>The <strong>EventArgs</strong> class alone is useless since it must be derived to instantiate with any content. This would indicate a subclass should be used, and many already exist in .NET. Sadly, I can't find any good generic ones. </p>
<p>Let's say you want to delegate logging to a generic event... WITHOUT WR... | 13,030 |
<p>I have printed a couple weeks perfectly fine with my Ender 3. Two weeks ago I changed the firmware but the settings were all fine and resulted in good prints.</p>
<p>Now, suddenly <em>during</em> a print the extruder motor started to under-extrude.</p>
<p>I thought "hey, could be the file" and used a test file tha... | <p>A close inspection of what happened when printing the first layer resulted in this:</p>
<ul>
<li>The missing steps on the new print came from the nozzle scraping too close to the print surface, which lead to no first layer</li>
<li>Readjusting the Z-axis end stop, which had moved down, resulted in no more lost step... | <p>Sounds similar to something I experienced with my Y-axis. The grub screw on the toothed wheel had come a little loose, and I was experiencing a reasonably consistent degree of slip.</p>
<p>In the extruder particularly, these locking screws might not be too obvious to check.</p>
| 1,026 |
<p>I'm not sure if this has been asked or not yet, but how much logic should you put in your UI classes?</p>
<p>When I started programming I used to put all my code behind events on the form which as everyone would know makes it an absolute pain in the butt to test and maintain. Overtime I have come to release how ba... | <p>Just logic dealing with the UI. </p>
<p>Sometimes people try to put even that into the Business layer. For example, one might have in their BL:</p>
<pre><code>if (totalAmount < 0)
color = "RED";
else
color = "BLACK";
</code></pre>
<p>And in the UI display totalAmount using color -- which is comple... | <p>Input validations attached to control.
Like emails,age,date validators with text boxes</p>
| 42,770 |
<p>In Visual Studio 2005, I have a solution with explicit dependencies specified via the Project Dependencies dialog.</p>
<p>When I build via devenv /rebuild Release for example, the projects are built in a different order than when loading up the IDE. This is an order not allowed by my specified dependencies.</p>
... | <p>Ok, here is the real answer, I believe.</p>
<p>Multiprocessor Builds are enabled. The dependency order is still enforced in the IDE, but not via command line, at least in VS 2005.</p>
<p>Turning it off is through Tools/Options/Build and Run. Set maximum to 1.</p>
| <p>If devenv didn't crash for you when building in the IDE, you've been lucky.</p>
<p>The following workaround is obnoxious but it worked for me, sigh. Reboot and set the BIOS to allow only a single CPU core to run.</p>
| 46,569 |
<p>We are working on a website for a client that (for once) is expected to get a fair amount of traffic on day one. There are press releases, people are blogging about it, etc. I am a little concerned that we're going to fall flat on our face on day one. What are the main things you would look at to ensure (in advance ... | <p>Measure first, and then optimize. Have you done any load testing? Where are the bottlenecks?</p>
<p>Once you know your bottlenecks then you can intelligently decide if you need additional database boxes or web boxes. Right now you'd just be guessing.</p>
<p>Also, how does your load testing results compare against yo... | <p>Look into using <a href="http://varnish.projects.linpro.no/" rel="nofollow noreferrer">Varnish</a> - it's a caching reverse proxy server (like <a href="https://en.wikipedia.org/wiki/Squid_%28software%29" rel="nofollow noreferrer">Squid</a>, but much more single purpose).</p>
<p>I've run some pretty big sites behind ... | 14,358 |
<p>I've recently purchased a Makerbot Replicator Dual clone made by CTC. I'm in the process of upgrading/adding a few parts to it, but noticed that I can't control or print via USB.</p>
<p>The machine prints perfectly from an SD card and I can see information in the terminal from the printer via USB in RepG and through... | <p>Good morning, and welcome to 3D Printing SE.</p>
<p>You said: "I can see information from the printer via USB in RepG and through OctoPrint, but can't send any prints, commands or upgrade firmware (I wanted to flash Sailfish 7.7 eventually)." This means that the USB communication is working fine. It isn't a quest... | <p>It is possible that your board has a cloned FT232R USB-to-serial bridge chip, and FTDI drivers supplied via the Windows update channel will not work with cloned chips. Try using the Windows setup executable from the following page:</p>
<p><a href="https://www.ftdichip.com/Drivers/VCP.htm" rel="nofollow noreferrer">... | 1,377 |
<p>Can anyone tell how Adobe Acrobat 9 was made? I like the look and feel of the GUI and I'm curious how it was made. Specifically, what programming language was used to make it?</p>
| <p>All of Adobe's major products are written in C++. Although they're mostly written using proprietary toolkits, Adobe has actually open-sourced some of their common low-level libraries. You can read more about them, and download them yourself, at <a href="http://stlab.adobe.com/" rel="noreferrer">Adobe's Software an... | <p>I believe it was programmed in C++ using the Evil framework.</p>
| 17,769 |
<p>How can I find the origins of conflicting DNS records?</p>
| <p>You'll want the SOA (Start of Authority) record for a given domain name, and this is how you accomplish it using the universally available <strong>nslookup</strong> command line tool:</p>
<pre><code>command line> nslookup
> set querytype=soa
> stackoverflow.com
Server: 217.30.180.230
Address: ... | <p>Unfortunately, most of these tools only return the NS record as provided by the actual name server itself. To be more accurate in determining which name servers are actually responsible for a domain, you'd have to either use "whois" and check the domains listed there OR use "dig [domain] NS @[root name server]" and ... | 5,892 |
<p>I'm aware of some of the test data generators out there, but most seem to just fill name and address style databases [feel free to correct me].</p>
<p>We have a large integrated and normalised application - e.g. invoices have part numbers linked to stocking tables, customer numbers linked to customer tables, change... | <p>Where I work we use <a href="http://www.red-gate.com/products/SQL_Data_Generator/index.htm" rel="nofollow noreferrer">RedGate Data Generator</a> to generate test data.</p>
<p>Since we work in the banking domain. When we have to work with nominative data (Credit card numbers, personnal ID, phone numbers) we develope... | <p>Joel also mentioned RedGate in <a href="https://blog.stackoverflow.com/2008/06/podcast-11/">podcast #11</a></p>
| 3,701 |
<p>I am running C# framework 2.0 and I would like to get some of the data from a list? The list is a List<>. How can I do that without looping and doing comparaison manually on each element of the List<>?</p>
| <p>You can try Predicate. Here is a code I wrote to illustrate the point. Of course, as you can see in this example, you can move the Predicate outside the calling class and have a control on it. This is useful if you need to have more option with it. Inside the predicate you can do many comparison with all property/fu... | <p>Unfortunately the List data structure requires iteration to find data (note that the FindAll methods above will iterate your collection under the covers - just in case you were trying to avoid that at all costs), unless you know the index of that data then you can do this:</p>
<pre><code>List<String> list = n... | 48,738 |
<p>With the code, forms and data inside the same database I am wondering what are the best practices to design a suite of tests for a Microsoft Access application (say for Access 2007).</p>
<p>One of the main issues with testing forms is that only a few controls have a <code>hwnd</code> handle and other controls only ... | <h1>1. Write Testable Code</h1>
<p>First, stop writing business logic into your Form's code behind. That's not the place for it. It can't be properly tested there. In fact, you really shouldn't have to test your form itself at all. It should be a dead dumb simple view that responds to User Interaction and then delegat... | <p>Data Access Pages have been deprecated by MS for quite some time, and never really worked in the first place (they were dependent on the Office Widgets being installed, and worked only in IE, and only badly then).</p>
<p>It is true that Access controls that can get focus only have a window handle when they have the... | 6,962 |
<p>I am not that hot at regular expressions and it has made my little mind melt some what.</p>
<p>I am trying to find all the tables names in a query. So say I have the query:</p>
<pre><code>SELECT one, two, three FROM table1, table2 WHERE X=Y
</code></pre>
<p>I would like to pull out "table1, table2" or "table1" a... | <p>RegEx isn't very good at this, as it's a lot more complicated than it appears:</p>
<ul>
<li>What if they use LEFT/RIGHT INNER/OUTER/CROSS/MERGE/NATURAL joins instead of the a,b syntax? The a,b syntax should be avoided anyway.</li>
<li>What about nested queries?</li>
<li>What if there is no table (selecting a const... | <p>This will pull out a table name on an insert Into query:</p>
<pre><code>(?<=(INTO)\s)[^\s]*(?=\(())
</code></pre>
<p>The Following will do the same but with a select including joins</p>
<pre><code>(?<=(from|join)\s)[^\s]*(?=\s(on|join|where))
</code></pre>
<p>Finally going back to an insert if you want to ... | 35,555 |
<p>Heres my link:</p>
<p><a href="http://tinyurl.com/6j727e" rel="noreferrer">http://tinyurl.com/6j727e</a></p>
<p>If you click on the link in test.php, it opens in a modal box which is using the jquery 'facebox' script.</p>
<p>I'm trying to act upon a click event in this box, and if you view source of test.php you'... | <p>First, the reason you're getting the alert on document load is because the <code>#click</code> method takes a function as an argument. Instead, you passed it the return value of <code>alert</code>, which immediately shows the alert dialog and returns null.</p>
<p>The reason the event binding isn't working is becau... | <p>Alternatively use event delegation</p>
<p>This basically hooks events to containers rather than every element and queries the event.target in the container event.</p>
<p>It has multiple benefits in that you reduce the code noise (no need to rebind) it also is easier on browser memory (less events bound in the dom)... | 45,585 |
<p>...just like packages do.</p>
<p>I use Emacs (maybe, it can offer some kind of solution).</p>
<p>For example <code>(defun the-very-very-long-but-good-name () ...)</code> is not to useful later in code. But the name like <code>Fn-15</code> or the first letters abbreviation is not useful too.
Is it possible either t... | <p>You want <code>defalias</code>. <code>(defalias 'newname 'oldname)</code> will preserve documentation and even show "newname is an alias for `oldname'" when its documentation is requested.</p>
| <p>You could simply have a function that just calls another function. </p>
| 23,333 |
<p>Using the default TWebBrowser makes things easy to embed a web browser. Unfortunately the one that comes in by default is IE<n>.</p>
<p>I'm wondering how does one integrate a Gecko or WebKit one.</p>
<ol>
<li>Are there VCL examples somewhere?</li>
<li>If not, how would one go about doing it?</li>
<li>Where's... | <p>TWebBrowser <strong>is</strong> IE. It is not a plugable construction for browsers. You can have other browsers integrated in your application. See</p>
<ul>
<li><a href="http://www.adamlock.com/mozilla/" rel="nofollow noreferrer">http://www.adamlock.com/mozilla/</a></li>
<li><a href="http://delphi.mozdev.org/article... | <p><strong>Edit:</strong> Lars beat me to it, unfortunately</p>
<p>Well there is an ActiveX control based on the Gecko engine that tries to present an exact copy of the IWebBrowser API (which TWebBrowser uses).</p>
<p>You can find it here: <a href="http://www.iol.ie/~locka/mozilla/control.htm" rel="nofollow noreferre... | 19,674 |
<p>I've built the mechanics of my 3D printer myself, because I need to print parts that are really huge, (and for budget reasons). <strong>So, I already have the 3D movement functionality.</strong></p>
<p>But what I need now, is the printing mechanism itself. I've been reading a lot, but it became clear to me that thi... | <p>You will certainly find that the print functionality of a 3d printer is a bit more complex than you suggest. The mechanical portions include a means to push the filament into a heated nozzle as well as the software portion to regulate the speed of the filament movement. You haven't referenced the heater cartridge an... | <p>The first point to start would be the RepRap wiki entry for <a href="http://reprap.org/wiki/Category:Extruders" rel="nofollow noreferrer">extruders</a>:</p>
<blockquote>
<h3>cold end</h3>
<p>The "Cold End" is usually the bulk of the extruder. It is
often the actual carriage on one axis and supports the res... | 384 |
<p>This problem started <a href="http://forums.asp.net/t/1304033.aspx" rel="nofollow noreferrer">on a different board</a>, but <a href="https://stackoverflow.com/users/60/dave-ward">Dave Ward</a>, who was very prompt and helpful there is also here, so I'd like to pick up here for hopefully the last remaining piece of t... | <p>Hey, Jason. Sorry you're still having trouble with this.</p>
<p>What I would do is set up a simple page like:</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
Response.Write(i + "<br />");
Response.Flush();
Thread.Sleep(1000);
}
}
<... | <p>I don't know that you can force buffering - but a reverse proxy server between you and the server would affect buffering (since the buffer then affects the proxy's connection - not your browser's).</p>
| 4,446 |
<p>I have a C# interface with certain method parameters declared as <code>object</code> types. However, the actual type passed around can differ depending on the class implementing the interface:</p>
<pre><code>public interface IMyInterface
{
void MyMethod(object arg);
}
public class MyClass1 : IMyInterface
{
... | <blockquote>
<p>The problem with MyClass2 is that the
conversion of byte[] to and from
object is boxing and unboxing, which
are computationally expensive
operations affecting performance.</p>
</blockquote>
<p>There is no boxing involved with array types, even one with value type elements. An array is a refer... | <p>Given you're using a recent version of mono, 2.0 if you can.</p>
<p>Generic interface performance on Mono is very good, on pair with regular interface dispatch.</p>
<p>Dispatch of generic virtual methods[1] is terrible on all released versions of mono, it has improved in 1.9 thou.</p>
<p>The problem is not that b... | 16,933 |
<p>In Apple's iPhone apps (like Contacts), they have a nice magnifying glass icon at the top of the table view index. Since the table view index API is character-based, I assume that this magnifying glass is a Unicode character. So far I've resorted to placing a question mark character there, but that looks lame.</p>
... | <p>Returning <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006943-CH3-SW49" rel="nofollow noreferrer"><code>UITableViewIndexSearch</code></a> as section index title (same as @"{search}") also works.</p>
<p>In Swift you ... | <p>Someone <a href="http://forums.macrumors.com/showthread.php?t=555877" rel="nofollow noreferrer">claims that Apple told them</a> this isn't supported in the SDK.</p>
| 29,098 |
<p>I am trying to insert about 50,000 objects (and therefore 50,000 keys) into a <code>java.util.HashMap<java.awt.Point, Segment></code>. However, I keep getting an OutOfMemory exception. (<code>Segment</code> is my own class - very light weight - one <code>String</code> field, and 3 <code>int</code> fields).</p>... | <p>You can increase the maximum heap size by passing -Xmx128m (where 128 is the number of megabytes) to java. I can't remember the default size, but it strikes me that it was something rather small.</p>
<p>You can programmatically check how much memory is available by using the <a href="http://java.sun.com/javase/6/do... | <p>Also might want to take a look at this:</p>
<p><a href="http://java.sun.com/docs/hotspot/gc/" rel="nofollow noreferrer">http://java.sun.com/docs/hotspot/gc/</a></p>
| 29,090 |
<p>I'm interested in finding good icons/images that can be used in both 'free' and proprietary programs. </p>
<p>Please include a description of any license restrictions associated with the source of the icons you suggest.</p>
| <p>I use two search engines:</p>
<p><a href="http://www.iconfinder.net/index.php?q=file" rel="noreferrer">IconFinder</a> and <a href="http://www.iconlook.com/search.icon?q=file&s12=on&s16=on&s22=on&s32=on&s48=on&s64=on&s128=on" rel="noreferrer">IconLook</a>.</p>
<p>If you can't find what y... | <p>I've had the best luck with <a href="http://www.iconbuffet.com" rel="nofollow noreferrer">Icon Buffet</a> and <a href="http://stockicons.com" rel="nofollow noreferrer">StockIcons</a></p>
| 7,025 |
<p>In the past, I used Microsoft Web Application Stress Tool and Pylot to stress test web applications. I'd written a simple home page, login script, and site walkthrough (in an ecommerce site adding a few items to a cart and checkout).</p>
<p>Just hitting the homepage hard with a handful of developers would almost al... | <p>Here's another vote for <a href="http://jakarta.apache.org/jmeter/" rel="noreferrer"><strong>JMeter</strong></a>.</p>
<p>JMeter is an open-source load testing tool, written in Java. It's capable of testing a number of different server types (for example, web, web services, database, just about anything that uses re... | <p>One more note, for our web application, I found that we had huge performance issues due to contention between threads over locks... so the moral was to think over the locking scheme very carefully. We ended up having worker threads to throttle too many requests using an asynchronous http handler, otherwise the appl... | 2,903 |
<p>For a while now, my AmazonBasics PETG filament has been working like a charm. Now, it is balling up on my nozzle. I've tried slowing it down, re-leveling the bed, etc. I don't want to go through the hassle of replacing my nozzle with a Micro-Swiss all metal 0.4 mm nozzle. I've tried the other extruder which I k... | <p>PETG does this. PETG is like glue when soft this is why when you level the bed you have to add an additional 0.1 mm distance for PETG. PETG should not be as close as PLA, but futher away. It will stick to the hotend so preferably change the hotend from brass to a nickle plated nozzle (e.g. Micro Swiss, PETG doe... | <p>PETG does this. PETG is like glue when soft this is why when you level the bed you have to add an additional 0.1 mm distance for PETG. PETG should not be as close as PLA, but futher away. It will stick to the hotend so preferably change the hotend from brass to a nickle plated nozzle (e.g. Micro Swiss, PETG doe... | 1,226 |
<p>So I have a self build Mendel Reprap style 3d printer.</p>
<p>I've not used it in sometime after moving house but I'm looking to use it again. What should I pay attention to before calibrating and running it again?</p>
| <p>Increase nozzle temperature. When the filament is new it will print easier, requiring less heat to print well. So if you didn't store your filament properly to begin with, increasing print temperature will make it jam less and increase layer bonding. </p>
<p>The reason for this is because the moisture that accumula... | <p>PLA absorbs moisture, so keeping the filament dry is a key factor. Aside from that, PLA is naturally more brittle than other plastics like ABS and Nylon Sorry, tried to find a graph to prove it, but couldn't find one.</p>
<p>There's a good <a href="https://groups.google.com/forum/#!topic/makerbot/Rdx2ZnJeQzs">Googl... | 326 |
<p>I am developing an iPhone application that persists data to a SQLite3 database. </p>
<p>For each row I persist I wish to include a 'created date' and a 'last modified date'</p>
<p>My question is what is the recommend approach for storing this information in a table? </p>
<p>The properties are represented as NSDat... | <p>I typically use a double, something like:</p>
<pre><code>sqlite3_bind_double(statement, index, [dateObject timeIntervalSince1970]);
</code></pre>
<p>where dateObject is an NSDate*. Then, when getting the data out of the DB, use</p>
<pre><code>[NSDate dateWithTimeIntervalSince1970:doubleValueFromDatabase];
</code>... | <p><a href="https://stackoverflow.com/questions/1711504/how-get-datetime-column-in-sqlite-objecite-c/1711591#1711591">How get a datetime column in SQLite with Objective C</a></p>
| 31,265 |
<p>Google Maps used to do this bit where when you hit the "Print" link, what would be sent to the printer wasn't exactly what you had on the screen, but rather a differently-formatted version of mostly the same information.</p>
<p>It appears that they've largely moved away from this concept (I guess people di... | <p>You can achieve this effect by creating a css stylesheet which is targeted directly to printing, and another targeted directly for the screen.</p>
<p>Use the link tag:</p>
<pre><code><link rel="stylesheet" type="text/css" href="print.css" media="print, handheld" />
<link rel="stylesheet" type="text/css" h... | <p>The easiest way is to use CSS media types. For each CSS file you include, you can specify where it ought to be used: on-screen, when printing, for handhelds, for screen-readers, or various combinations of these.</p>
<p>Example: <em><link rel="stylesheet" type="text/css" media="print, handheld" href="foo.css">... | 11,055 |
<p>On a website I'm working we have an onsite login and a private login, the problem I'm having is that Firefox doesn't seem to be able to differentiate between these login forms.</p>
<p>Does anybody know how I can make clear that these are different logins?</p>
<p>I already tried giving the form fields different nam... | <p>Apparently this is not possible due to the way Firefox stores its passwords.</p>
<p>A password-manager entry is stored with the following data</p>
<ul>
<li>The username (encrypted and secured with Firefox Master Password).</li>
<li>The password (encrypted and secured with Firefox Master Password).</li>
<li>The hos... | <p>I'm not sure.. but try to give them a different ID like <code><form method="POST" action="#" id="login1"></code></p>
| 46,354 |
<p>I want to dynamically add menuitems to my master page based on membership security login role. From what I've read RenderAction in the master page html could perhaps do this. Since I'm fumbling thru this I am not sure how it would look and how in the controller I check my current role. I am considering creating a ta... | <p>In the controller, I would create a MenuModel class or the like, that is the model for your menu. It would be a data only class. Create and populate it in the controller, taking into consideration the current user's access permissions. This will allow you to write unit tests that ensure your security code is correct... | <p>I'm not sure if this is what you are looking for, but I had a question along the same lines a few weeks ago:</p>
<p><a href="https://stackoverflow.com/questions/121000/stuck-creating-a-security-trimmed-htmlactionlink-extension-method">Stuck creating a "security trimmed" html.ActionLink extension method</a... | 28,159 |
<p>I am making a post from a .NET console app to a .NET web service. I know that the timeout on the server side is 20 min, but if my client takes more than 100 seconds to post my data to that service then I get a timeout exception. How would I tell my client to wait the available 20 min to timeout?</p>
| <p>on the client side, your webservice object has a timeout value. It should be pretty easy to set by going:</p>
<pre><code>myServiceInstance.Timeout = 1200000
</code></pre>
<p>for 20 minutes</p>
| <p>Yup the <code>ServiceInstance.Timeout</code> is the property to set.</p>
<p>I blogged about it here
<a href="http://stackpanel.com/blog/2008/10/client-timeout-accessing-asmx-web-service/" rel="nofollow noreferrer">http://stackpanel.com/blog/2008/10/client-timeout-accessing-asmx-web-service/</a></p>
| 36,251 |
<p>I have an object that I'm testing that raises an event. What is the best way of using Rhino Mocks to check that it was raised? </p>
<p>Best I could come up with (I am certain it gets better than this):</p>
<pre><code>public void MyCallback(object sender, EventArgs e) { _flag = true;}
[Test]
public void DoSometh... | <p>I found <a href="http://haacked.com/archive/2006/12/13/tip_jar_unit_test_events_with_anonymous_delegates.aspx" rel="noreferrer">this article by Phil Haack on how to test events using anonymous delegates</a></p>
<p>Here is the code, ripped directly from his blog for those too lazy to click through:</p>
<pre><code>[... | <p>I'm not sure how your test actually calls the DoSomething() Method. Maybe you're missing something to fire the event. Other than that, I think you have are on the right track for testing events with Rhino Mocks</p>
<p>In any case, here is another way I like to deal with events:</p>
<pre><code>[Test]
public void My... | 17,955 |
<p>We all know, that the best layer hight is, when you have multiples of full steps. If it is not, sometimes steps get skipped and end up bad layer-to-layer adhesion when one height step missed a tiny bit and then the next catches up, creating an extra-thick layer. For example, this was printed somewhat deliberately, a... | <blockquote>
<p>that the NEMA17 motor would be using 400 Steps per mm in Z. <code>configuration_adv.h</code> tells that the microsteps on the Z-axis motor are 16.</p>
</blockquote>
<p>Easy. There are 400 microsteps in a millimeter, and 16 microsteps in a full step. So, there are 400/16=25 full steps in a millimeter.... | <p>I see you've already accepted an answer, but based on your comments I think you have some misunderstandings of the topic which are worth clarifying as part of answering this question.</p>
<blockquote>
<p>0.2125 layer height (+1/4 microstep) and doing all the movements in absolute movements instead of relative for... | 1,464 |
<p>I want to make a .NET Form as a TopMost Form for another external App (not .NET related, pure Win32) so it stays above that Win32App, but not the rest of the apps running.</p>
<p>I Have the handle of the Win32App (provided by the Win32App itself), and I've tried <a href="http://msdn.microsoft.com/en-us/library/ms63... | <p>I think you're looking for is to P/Invoke <code>SetWindowLongPtr(win32window, GWLP_HWNDPARENT, formhandle)</code></p>
<p><a href="http://www.google.com/search?q=setwindowlongptr+parent" rel="noreferrer">Google Search</a></p>
| <p>It has now been 12 years since this question was asked so I thought I would provide an updated answer from <a href="https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptra" rel="nofollow noreferrer">here</a>.</p>
<blockquote>
<p>Do not call SetWindowLongPtr with the GWLP_HWNDPARENT i... | 16,116 |
<p>I have a .NET (C#) multi-threaded application and I want to know if a certain method runs inside the Finalizer thread. </p>
<p>I've tried using Thread.CurrentThread.Name but it doesn't work (returns null).</p>
<p>Anyone knows how can I query the current thread to discover if it's the Finalizer thread?</p>
| <p>The best way to identify a thread is through its managed id:</p>
<pre><code>Thread.CurrentThread.ManagedThreadId;
</code></pre>
<p>Since a finalizer always runs in the GC's thread you can create a finalizer that will save the thread id (or the thread object) in a static valiable.</p>
<p>Sample:</p>
<pre><code>pu... | <p>I don't think that is possible even using the debugging APIs, see <a href="http://blogs.msdn.com/jmstall/archive/2006/03/02/expose-finalizer-thread.aspx" rel="nofollow noreferrer">this</a> blog post for more info.</p>
| 41,155 |
<p>We have a third party dll that is used in our web service hosted in IIS6. The problem is that once this dll is loaded into memory, the exception <a href="http://msdn.microsoft.com/en-us/library/system.accessviolationexception.aspx" rel="nofollow noreferrer">AccessViolationException</a> gets thrown if a thread differ... | <p>I have read about a class in .net 3.0 called <a href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.aspx" rel="nofollow noreferrer">Dispatcher</a> that allows you to put a thread in a loop and then call the method Invoke() using a delegate to execute a method using the thread. But this ... | <p>You could create a service that hosts the extra DLL. Via remoting you access the service, this will dispatch the calls the the thread that manages the DLL.</p>
<p>This way you have control over the thread that calls the DLL, and over the lifetime of the thread.</p>
| 6,630 |
<p>I've got a problem similar to,but subtly different from, that described <a href="https://stackoverflow.com/questions/22012/loading-assemblies-and-its-dependencies">here</a> (Loading assemblies and their dependencies).</p>
<p>I have a C++ DLL for 3D rendering that is what we sell to customers. For .NET users we will... | <p>I finally have an answer for this that appears to work.</p>
<p>Compile both 32 & 64 bit versions - both managed & unmanaged - into separate folders. Then have the .NET app choose at run time which directory to load the assemblies from.</p>
<p>The problem with using the ResolveEvent is that it only gets cal... | <p>I encountered a similar scenario a while back. A toolkit I was using did not behave well in a 64-bit environment and I wasn't able to find a way to dynamically force the assemblies to bind as 32 bit.</p>
<p>It is possible to force your assemblies to work in 32 bit mode, but this requires patching the CLR header, (t... | 4,232 |
<p>How can one load custom (not an image, nor a sound file) resource file from /res within .jar using MIDP 2.0?</p>
| <p>I'm working with MIDP 2.1, but I hope this is in 2.0 too.</p>
<p>Class.getResource(path_to_resource) should give you an InputStream to the file.</p>
| <pre><code>getResourceAsStream("/res/yourresource");
</code></pre>
| 14,693 |
<p>What's the best way of adding spaces between strings</p>
<pre><code>myString = string.Concat("a"," ","b")
</code></pre>
<p>or</p>
<pre><code>myString = string.Concat("a",Chr(9),"b")
</code></pre>
<p>I am using stringbuilder to build an XML file and looking for something efficient.</p>
<p>Thanks</p>
<p>Edit ~ L... | <p>Create your XML file with the XmlDocument class. Your wasting your time creating a string from scratch.</p>
| <p>The simplest way is to use an aggregate function to combine the elements.</p>
<pre><code>string[] input = new string[]{"a", "b"};
var withSpaces = input.Aggregate( (x,y) => x + " " + );
</code></pre>
| 23,684 |
<p>I want to compress some files (into the <a href="http://en.wikipedia.org/wiki/ZIP_%28file_format%29" rel="nofollow noreferrer">ZIP</a> format) and encrypt them if possible using C#. Is there some way to do this?</p>
<p>Can encryption be done as a part of the compression itself?</p>
| <p>For compression, look at the <a href="http://msdn.microsoft.com/en-us/library/system.io.compression.aspx" rel="nofollow noreferrer"><code>System.IO.Compression</code></a> namespace and for encryption look at <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.aspx" rel="nofollow noreferrer"... | <p>Here is a useful topic:</p>
<p><a href="https://stackoverflow.com/questions/71000/help-in-creating-zip-files-from-net-and-reading-them-from-java">Help in creating Zip files from .Net and reading them from Java</a></p>
<p>System.IO.Packaging namespace gives you useful classes to compress data in zip format and <a h... | 9,652 |
<p>I am developing a web site and need to see how it will look at different resolutions. The catch is that it must work on our Intranet.</p>
<p>Is there a free solution?</p>
| <p>For Firefox, Web Developer Toolbar (<a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="noreferrer">https://addons.mozilla.org/en-US/firefox/addon/60</a>)</p>
| <p>Also on Internet Explorer 7 is <a href="http://www.ie7pro.com/" rel="nofollow noreferrer">IE7Pro</a>. It also provides some gadgets that aren't in the Developer Toolbar. I have both installed, and use both quite often.</p>
| 8,760 |
<p>I have a line that I draw in a window and I let the user drag it around. So, my line is defined by two points: (x1,y1) and (x2,y2). But now I would like to draw "caps" at the end of my line, that is, short perpendicular lines at each of my end points. The caps should be N pixels in length.</p>
<p>Thus, to draw my "... | <p>You need to compute a unit vector that's perpendicular to the line segment. Avoid computing the slope because that can lead to divide by zero errors.</p>
<pre><code>dx = x1-x2
dy = y1-y2
dist = sqrt(dx*dx + dy*dy)
dx /= dist
dy /= dist
x3 = x1 + (N/2)*dy
y3 = y1 - (N/2)*dx
x4 = x1 - (N/2)*dy
y4 = y1 + (N/2)*dx
</c... | <p>If you want to avoid a sqrt, do the following:</p>
<pre><code>in: line_length, cap_length, rotation, position of line centre
define points:
tl (-line_length/2, cap_length)
tr (line_length/2, cap_length)
bl (-line_length/2, -cap_length)
br (line_length/2, -cap_length)
rotate the four points by 'rotation'
o... | 16,200 |
<p>Are there any tools for just browsing SQL Server? I ask because sometimes SSMS is a little heavy weight when I just want to look through the database and find one record, and SQLCMD doesn't really seem like a good choice when browsing through a lot of different records or a lot of large records.</p>
| <p>Yes, <a href="http://www.albahari.com/queryexpress.aspx" rel="noreferrer">QueryExpress</a> is a great, lightweight tool (which also can be used from a USB stick) for browsing and querying SQL Server databases.</p>
| <p>I'm using and I really like <a href="http://www.linqpad.net/" rel="nofollow noreferrer">LINQPad</a></p>
| 23,221 |
<p>I have a fairly large codebase that depends on MooTools v1.11 and am about to convert to version 1.2. Since this is a pretty major overhaul, I've toyed with the idea of converting to jQuery. </p>
<p>Anyone have advice on whether to update to jQuery or just stick with MooTools?</p>
<p>I mostly use MooTools for Aj... | <p>If it's not broken. Don't fix it.</p>
<p>jQuery might have X or Y but if everything is dependent on MooTools, you might have a lot of work ahead of you to convert from MooTools.</p>
<p>Keep MooTools if you used it extensively through out your site. However, if you only have 2-3 pages with minor effects... the chan... | <p>JQuery is a smaller codebase with wider support. If it meets your needs it might be a good switch. I would say that the trade off that you need to decide on is whether the migration effort and learning curve are worth the effort versus the wider feature set, smaller code size and popularity and support for JQuery.... | 20,416 |
<p>I want to print multiple objects in a single G-code file on my Maker Select Plus 3D Printer.</p>
<p>On the Cura "Machine>Machine Settings..." menu, what are the correct settings for "Printer head size" in the upper right quadrant?</p>
<p>My best guess is below:</p>
<p><a href="https://i.stack.imgur.com/hJkip.png"... | <h3>TL;DR</h3>
<p>The settings that you seem to need can be found here: <a href="https://www.thingiverse.com/groups/i3/topic:6818" rel="noreferrer">Print One At a time settings? CURA</a>:</p>
<blockquote>
<p>You actually can!</p>
<p>Providing that none of your object is too tall (taller than the Gantry
clear... | <p>Like the OP, I'm confused by this as well. I figured I'd need measurements from the center of the nozzle to the left, right, front, and back of the print head, as well as a height from the print surface to the gantry while the head was homed. I've carefully measured, but things aren't going quite as I expected. In t... | 607 |
<p>I'm wondering if anyone has good resources to read or code to experiment for "autcomplete" </p>
<p>I would like to know what's the theory behind autocompletion, where to start what are the commonn mistakes etc. </p>
<p>I found fascinating the way products like Enso, Launchy, Google chrome and even tcsh perform the... | <ul>
<li><a href="http://humanized.com/weblog/2007/03/30/what_makes_a_good_autocomplete/" rel="noreferrer">http://humanized.com/weblog/2007/03/30/what_makes_a_good_autocomplete/</a> -- </li>
<li><a href="http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/2ccb37b9-c7e1-4113-86ac-ad3d33b4b4b1/" rel="norefe... | <p>Autocomplete is usually implemented using one of the following:</p>
<ul>
<li><strong>Trees</strong>. By indexing the searchable text in a tree structure (prefix tree, suffix tree, dawg, etc..) one can execute very fast searches at the expense of memory storage. The tree traversal can be adapted for approximate matc... | 28,073 |
<p>I am trying to create an application like the one here:</p>
<p><a href="http://www.eigenfaces.com/" rel="nofollow noreferrer">http://www.eigenfaces.com/</a></p>
<p>Basically lots of overlapping circles drawn with pygame. I cannot figure out how the blend the circles to make them translucent. That is to have overla... | <p>I got it to work by drawing to a surface that is not the display and combining the set colorkey and set alpha functions.</p>
<pre><code>import pygame
from pygame.locals import *
TRANSPARENT = (255,0,255)
pygame.init()
screen = pygame.display.set_mode((500,500))
surf1 = pygame.Surface((200,200))
surf1.fill(TRANSPA... | <p>I am Dave. Creator of the images at eigenfaces.com. Good luck with your experiments. I posted the code here:</p>
<p><a href="http://www.eigenfaces.com/" rel="nofollow noreferrer">http://www.eigenfaces.com/</a></p>
<p>Let me know if it's of use.</p>
<p>By the way.. I have also experimented with movies... Here i... | 46,011 |
<p>I am working on an application where i need to transfer mails from a mailbox to anoter one.I can not send these mails using smtp because this willchange the header information .I am using C# and out look api to process mails . is thre any way i can transfer mails to other mail box without changing mail header.</p>... | <p>If you cannot load all relevant mailboxes into a single Outlook profile, then this cannot be solved using the Outlook API. It should however be possible to run a standalone application from an administrative account that accesses the Exchange information store directly via Extended MAPI. You can then open the source... | <p>If you use the Outloook API I'm sure there is support for backup and restore. So backup your mails from one account and restore it on the other. This would be my first try. PS: I'm not familiar with the API.</p>
| 46,791 |
<p>How do you impose a character limit on a text input in HTML?</p>
| <p>There are 2 main solutions:</p>
<p>The pure HTML one:</p>
<pre><code><input type="text" id="Textbox" name="Textbox" maxlength="10" />
</code></pre>
<p>The JavaScript one (attach it to a onKey Event):</p>
<pre><code>function limitText(limitField, limitNum) {
if (limitField.value.length > limitNum) {
... | <p>you can set maxlength with jquery which is very fast</p>
<pre><code>jQuery(document).ready(function($){ //fire on DOM ready
setformfieldsize(jQuery('#comment'), 50, 'charsremain')
})
</code></pre>
| 13,843 |
<p>I'm pretty sure the answer to this question is no, but in case there's some PHP guru</p>
<p>is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of <code>'@'</code></p>
<p>Much like empty and isset do. You can pass in ... | <p>Summing up, the proper answer is <strong>no, you shouldn't</strong> (see caveat below). </p>
<p>There are workarounds already mentioned by many people in this thread, like using reference variables or isset() or empty() in conditions and suppressing notices in PHP configuration. That in addition to the obvious work... | <p>And going further up the abstraction tree, what are you using this for?</p>
<p>You could either initialize those values in each class as appropriate or create a specific class containing all the default values and attributes, like:</p>
<pre><code>class Configuration {
private var $configValues = array( 'cool'... | 7,877 |
<p>Am just wondering if any conclusions can be drawn from this:</p>
<p><a href="https://i.stack.imgur.com/0RNE3.png" rel="nofollow noreferrer" title="Photo of poor adhesion"><img src="https://i.stack.imgur.com/0RNE3.png" alt="Photo of poor adhesion" title="Photo of poor adhesion"></a></p>
<p>Three corners are solid, ... | <p>From here: <a href="https://io3dprint.com/review-anycubic-i3-mega-ultrabase/" rel="nofollow noreferrer">https://io3dprint.com/review-anycubic-i3-mega-ultrabase/</a></p>
<blockquote>
<p>Ultrabase Bed
The Anycubic i3 Mega Ultrabase is the latest version in the Anycubic i3 family. As hinted in the name, the main ... | <p>From here: <a href="https://io3dprint.com/review-anycubic-i3-mega-ultrabase/" rel="nofollow noreferrer">https://io3dprint.com/review-anycubic-i3-mega-ultrabase/</a></p>
<blockquote>
<p>Ultrabase Bed
The Anycubic i3 Mega Ultrabase is the latest version in the Anycubic i3 family. As hinted in the name, the main ... | 1,403 |
<p>I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?</p>
| <p>If you're having problems with syntax, you could try an editor with syntax highlighting. Until you get the feel for a language, simple errors won't just pop out at you.</p>
<p>The simplest form of debugging is just to insert some print statements. A more advanced (and extensible) way to do this would be to use the ... | <p>Eric4 IDE also has a great built-in debugger.</p>
| 38,408 |
<p>Can there be buffer overflow/overrun vulnerabilities in completely managed asp.net web portal.If yes how can this be tested.</p>
| <p>Not unless you exploit the webserver or .NET/ASP.NET stack itself.</p>
| <p>I had a tool (HP Dev Inspect) detect a possible "Possible Parameter Buffer Overflow" within my ASP.NET app and it was because we didn't have a MaxLength="20" in one of our TextBoxes...</p>
| 18,924 |
<p>In our current database development evironment we have automated build procceses check all the sql code out of svn create database scripts and apply them to the various development/qa databases.</p>
<p>This is all well and good, and is a tremdous improvement over what we did in the past, but we have a problem with ... | <p>I'm not sure how best to approach the problem in your specific environment, but I'd suggest reading up on Rail's migrations feature for some inspiration on how to get started. </p>
<p><a href="http://wiki.rubyonrails.org/rails/pages/UnderstandingMigrations" rel="nofollow noreferrer">http://wiki.rubyonrails.org/rail... | <p>if you want to have re-runnability in your scripts, then you can't have them as definitions... what I mean by this is that you need to focus on change scripts rather than here is my Table script.</p>
<p>let's say you have a table Customers:</p>
<pre><code>create table Customers (
id int identity(1,1) primary k... | 7,220 |
<p>Can anyone recommend a good library for generating an audio file, such as mp3, wav, or even midi, from python?</p>
<p>I've seen recommendations for working with the id tags (song name, artist, etc) in mp3 files, but this is not my goal.</p>
| <p>See <a href="http://wiki.python.org/moin/Audio/" rel="noreferrer">http://wiki.python.org/moin/Audio/</a> and <a href="http://wiki.python.org/moin/PythonInMusic" rel="noreferrer">http://wiki.python.org/moin/PythonInMusic</a>, maybe some of the projects listed there can be of help.</p>
<p>Also, <a href="http://www.go... | <p>I've never used it, but check out <a href="http://code.google.com/p/ounk/" rel="nofollow noreferrer">ounk</a>.</p>
| 6,723 |
<p>I have a Tronxy X5S and I am having issues calibrating my X and Y axis. When I print a 20 mm<sup>3</sup> cube it comes out 19.9 mm x 20.4 mm x 20 mm. I have already made the belt tensions as even as I can get them but it did not change the calibration cube size.</p>
<p>I have added <a href="https://www.thingiverse.... | <p>Indeed, <strong>even belt tension is important</strong>, what helped me enormously to set the same tension in the belts on my self build CoreXY is a tool like <a href="https://www.thingiverse.com/thing:2589577" rel="nofollow noreferrer">this</a>:</p>
<p><a href="https://i.stack.imgur.com/vmQKB.jpg" rel="nofollow no... | <p>Indeed, <strong>even belt tension is important</strong>, what helped me enormously to set the same tension in the belts on my self build CoreXY is a tool like <a href="https://www.thingiverse.com/thing:2589577" rel="nofollow noreferrer">this</a>:</p>
<p><a href="https://i.stack.imgur.com/vmQKB.jpg" rel="nofollow no... | 1,048 |
<p>Ok time to show my complete lack of knowladge for all things web forms but here goes. I am extending the Panel control and OnPreRender sticking some additional controls inside of it (lets just say 1 textbox for simplicity). From here I am just letting the Panels Render method do its thing. </p>
<p>The issue I am ha... | <p>You need to (re)create the child control (the textbox) in OnInit - so that it's there when LoadViewState and ProcessPostBackData is called.</p>
<p>See the <a href="http://www.digcode.com/default.aspx?page=ed51cde3-d979-4daf-afae-fa6192562ea9&article=d3ba7954-6235-446f-9801-584539cbb6bf" rel="nofollow noreferrer... | <p>Inside your code you will need to manage the restore of viewstate information should you need the services of viewstate.</p>
<p>A good example here is this <a href="http://msdn.microsoft.com/en-us/library/1whwt1k7.aspx" rel="nofollow noreferrer">View State example</a> by Microsoft. There are a few other items refe... | 45,563 |
<p>How useful, if at all, is for the testers on a product team to know about the internal code details of a product. This does not mean they need to know every line of code but a good idea of how the code is structured, what is the object model, how the various modules are inter-linked, what are the inter-dependencies ... | <p>That entirely depends upon the type of testing being done.</p>
<p>For functional system testing, the testers can and probably should be oblivious to the details of the implementation -- if they know the details they may inadvertently account for that in their test strategy and not properly test the product.</p>
<p... | <p>I would say they don't need to know the internal code details at all. However they do need to know the required functionality and system rules in full detail - like an analyst. Otherwise they won't test all the functionality, or won't realise when the system misbehaves.</p>
| 28,887 |
<p>I'd like to zoom and unzoom in ways the base class doesn't support.</p>
<p>For instance, upon receiving a double tap.</p>
| <p>I'm answering my own question, after playing with things and getting it working.</p>
<p>Apple has a very-simple example of this in their documentation on how to handle double taps.</p>
<p>The basic approach to doing programmatic zooms is to do it yourself, and then tell the UIScrollView that you did it.</p>
<ul>
... | <p>Darren, can you provide a link to said Apple example? Or the title so that I may find it? I see <a href="http://developer.apple.com/iphone/library/samplecode/Touches/index.html" rel="nofollow noreferrer">http://developer.apple.com/iphone/library/samplecode/Touches/index.html</a> , but that doesn't cover the zooming.... | 20,760 |
<p>Recently I was trying to make a calendar application that will display the current year-month-date to the user. The problem is, if the user is gonna keep my application running even for the next day, how do I get notified ?? How shall I change the date displayed ? I don't wanna poll the current date to update it. Is... | <p>Can you simply work out the number of seconds until midnight, and then sleep for that long?</p>
| <p>How about a thread that checks for change in date. The thread can have some events that the controls that need this information can subscribe to.</p>
| 37,723 |
<p>Is it possible to have both</p>
<ul>
<li>NetTcp bound endpoints, and</li>
<li>basicHttp bound endpoints with SSL</li>
</ul>
<p>within a single deployment, either using Windows Service or IIS6?</p>
| <p>Yes, a single service host can expose multiple endpoints with different bindings. However, normal IIS restrictions apply to IIS, so IIS 6 doesn't support NetTcp bindings to begin with.</p>
| <p>Beginning with IIS 7.0 you <em>can</em> use the net.tcp binding with IIS. And <em>Yes</em> you can expose multiple bindings (i.e. wsHttpBinding and net.tcp) in a single WCF service installation. The following (2) links should help:</p>
<p><strong>Multiple Endpoints:</strong><br>
<a href="http://msdn.microsoft.com/e... | 24,845 |
<p>I'm just talking about JavaScript here, not CSS or implementation of the DOM.</p>
<p>I know getters and setters are now available in the latest release of all major browsers except IE. What other JavaScript features are available cross-browser if we have the latest versions of the other browsers and forget about IE... | <p>With Gecko-engined browsers, you get:</p>
<ul>
<li><a href="https://developer.mozilla.org/en/New_in_JavaScript_1.6" rel="nofollow noreferrer">https://developer.mozilla.org/en/New_in_JavaScript_1.6</a></li>
<li><a href="https://developer.mozilla.org/en/New_in_JavaScript_1.7" rel="nofollow noreferrer">https://develop... | <p>I would recommend you visit <a href="http://www.quirksmode.org" rel="nofollow noreferrer">www.quirksmode.org</a> for a lot of detailed comparisons of different browsers/versions.</p>
| 43,229 |
<p>I would like to get Binding object from web.config or app.config.</p>
<p>So, this code works:</p>
<pre><code>wcfTestClient = new TestServiceClient("my_endpoint", Url + "/TestService.svc");
</code></pre>
<p>but I would like to do the following:</p>
<pre><code>Binding binding = DoSomething();
wcfTestClient = new T... | <p>You can instantiate a binding giving a binding configuration name from App.config/Web.config.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms575163.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms575163.aspx</a></p>
<blockquote>
<p>Initializes a new instance of the WSHttpBinding class wit... | <p>One cheeky option might be to create an instance with the default constructor, to use as a template:</p>
<pre><code>Binding defaultBinding;
using(TestServiceClient client = new TestServiceClient()) {
defaultBinding = client.Endpoint.Binding;
}
</code></pre>
<p>Then tuck this away and re-use it. Any help?</p>
| 46,347 |
<p>I'm writing a C# program that acts as a PowerPoint 2007 plugin. On some machines, some calls to the PowerPoint object model throw a <code>COMException</code> with the message <code>RPC_E_SYS_CALL_FAILED</code>. I couldn't find any specific advice on what to do regarding this error, or how to avoid it. From Googling ... | <p>I don't know it is related to your problem, but all your COM calls must come from within the same thread your add-in was created on. If you created new threads you must take special care. Details are described in these two articles:</p>
<ul>
<li><a href="http://blogs.msdn.com/andreww/archive/2008/11/19/implementing... | <p>are you making the call from a thread with its ApartmentState set? if not, that might be the culprit - COM interop is pretty finicky about that sort of thing</p>
| 12,448 |
<p>I have a console app in which I want to give the user <em>x</em> seconds to respond to the prompt. If no input is made after a certain period of time, program logic should continue. We assume a timeout means empty response.</p>
<p>What is the most straightforward way of approaching this?</p>
| <p>I'm surprised to learn that after 5 years, all of the answers still suffer from one or more of the following problems:</p>
<ul>
<li>A function other than ReadLine is used, causing loss of functionality. (Delete/backspace/up-key for previous input).</li>
<li>Function behaves badly when invoked multiple times (spawni... | <p>Another cheap way to get a 2nd thread is to wrap it in a delegate.</p>
| 8,196 |
<p>I seem to only be able to write to the Apache error log via stderr. Anyone know of a more structured logging architecture that I could use from my python web project, like commons?</p>
| <p>There isn't any built in support for mod_python logging to Apache currently. If you really want to work within the Apache logs you can check out this thread (make sure you get the second version of the posted code, rather than the first):</p>
<ul>
<li><a href="http://www.dojoforum.com/node/13239" rel="nofollow nore... | <p>I concur with Blair Conrad's post about the Python logging module. The standard log handlers sometimes drop messages however. It's worth using the logging module's SocketHandler and building a receiver to listen for messages and write them to file.</p>
<p>Here's mine: <a href="http://www.djangosnippets.org/snippets... | 20,554 |
<p>If by some miracle a segfault occurs in our program, I want to catch the SIGSEGV and let the user (possibly a GUI client) know with a single return code that a serious problem has occurred. At the same time I would like to display information on the command line to show which signal was caught.</p>
<p>Today our si... | <p>This <a href="http://docs.oracle.com/cd/E19963-01/html/821-1601/gen-61908.html#gen-95948" rel="nofollow noreferrer">table</a> lists all of the functions that POSIX guarantees to be async-signal-safe and so can be called from a signal handler.</p>
<p>By using the 'write' command from this table, the following relati... | <p>Write a launcher program to run your program and report abnormal exit code to the user.</p>
| 12,883 |
<p>I'm tinkering with Silverlight 2.0.</p>
<p>I have some images, which I currently have a static URL for the image source.
Is there a way to dynamically load the image from a URL path for the site that is hosting the control?</p>
<p>Alternatively, a configuration setting, stored in a single place, that holds the bas... | <p>In the code behind or a value converter you can do </p>
<pre><code> Uri uri = new Uri("http://testsvr.com/hello.jpg");
YourImage.Source = new BitmapImage(uri);
</code></pre>
| <p><a href="http://msdn.microsoft.com/en-us/library/system.windows.interop.silverlighthost.source(VS.95).aspx" rel="nofollow noreferrer">SilverlightHost.Source</a> will provide you the URL that was used to load the XAP file. You can use this to then construct a relative URL for your images.</p>
<p>So if for example yo... | 28,751 |
<p>In my WCF service, I have methods that are currently public, but I want to hide them from the outside world but be able to use them in my WCF service.</p>
<p>Is internal what I'm looking at?</p>
| <p>You can use the := syntax to assign the parameters to a Sub or Function by name, rather than strictly by position. For example:</p>
<pre><code>Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TestRoutine(Y:="TestString", X:=12)
... | <p>VB uses that operator for attribute value assignments:</p>
<p><a href="http://www.ondotnet.com/pub/a/dotnet/excerpt/vbnut_8/index1.html" rel="nofollow noreferrer">http://www.ondotnet.com/pub/a/dotnet/excerpt/vbnut_8/index1.html</a></p>
| 38,844 |
<p>Should libraries that the application relies on be stored in source control? One part of me says it should and another part say's no. It feels wrong to add a 20mb library that dwarfs the entire app just because you rely on a couple of functions from it (albeit rather heavily). Should you just store the jar/dll or ma... | <p>store everything you will need to build the project 10 years from now.I store the entire zip distribution of any library, just in case</p>
<p>Edit for 2017:
This answer did not age well:-). If you are still using something old like ant or make, the above still applies. If you use something more modern like maven or... | <p>store everything you'll need to build the project, so you can check it out and build without doing anything.</p>
<p>(and, as someone who has experienced the pain - please keep a copy of everything needed to get the controls installed and working on a dev platform. I once got a project that could build - but without... | 7,167 |
<p>If I have an Address object which implements IEditableObject, I might have EndEdit implementation like this:</p>
<pre><code>public void EndEdit()
{
// BeginEdit would set _editInProgress and update *Editing fields;
if (_editInProgress)
{
_line1 = _line1Editing;
_line2 = _line2Editing;
... | <p>First off, Kent is correct in wondering why setting a field would throw an exception.<br>
Ignoring that question; you could just use a simple:</p>
<pre><code>try {
//do stuff
}
catch (Exception ex) {
//reset
//rethrow exception
throw;
}
</code></pre>
<p>The complications come in with regards to what const... | <p>I don't use fields for storing values. Instead I use a hash table that the properties can read and write. This gives me a really simple design.</p>
<pre><code>Friend Sub BeginEdit()
m_Backup = New Dictionary(Of String, Object)(m_DataPoints, StringComparer.OrdinalIgnoreCase)
End Sub
Friend Sub CancelEdit()
... | 21,613 |
<p>I am programming in C against a third party library (in HP/Mercury Loadrunner) that allows a varargs-style variable size argument list for one of it's functions. I want to call this function but I do not know up front how many arguments I will have. </p>
<p>There is a function made by one of my predecessors that se... | <p>In CamelBones I use <a href="http://sourceware.org/libffi/" rel="noreferrer">libffi</a> to call objc_msgSend(), which is a varargs function. Works a treat.</p>
| <p>I know this is an old thread, but I just ran across it. The proper way to handle variable length submit form data in LoadRunner is to use a web_custom_request(). You build the name|value pair structure for the variable length of the arguments as a string and pass it in as a part of the function. </p>
<p>Rec... | 35,539 |
<p>What's the best strategy to use when writing JMeters tests against a web application where the values of certain query-string and post variables are going to change for each run.</p>
<p>Quick, common, example</p>
<ol>
<li>You go to a Web Page</li>
<li>Enter some information into a form</li>
<li>Click Save</li>
<li... | <p>Sounds to me like your on the right track. The best that can be achieved by JMeter is to extract page variables with a regular expression or xpath post processor. However your absolutely correct in that this is not a scalable solution and becomes increasingly tricky to maintain or grow. </p>
<p>If you've reached is... | <p>We have had great success in testing similar scenarios with JMeter by storing parameters in JMeter Variables within a JDBC assertion. We then do our http get/post and use a BSF Assertion and javascript do complex validation of the response. Hope it helps</p>
| 38,546 |
<p>That is, all text and subtags, without the tag of an element itself?</p>
<p>Having</p>
<pre><code><p>blah <b>bleh</b> blih</p>
</code></pre>
<p>I want </p>
<pre><code>blah <b>bleh</b> blih
</code></pre>
<p>element.text returns "blah " and etree.tostring(element) returns:</p>
... | <p>ElementTree works perfectly, you have to assemble the answer yourself. Something like this...</p>
<pre><code>"".join( [ "" if t.text is None else t.text ] + [ xml.tostring(e) for e in t.getchildren() ] )
</code></pre>
<p>Thanks to JV amd PEZ for pointing out the errors.</p>
<hr>
<p>Edit.</p>
<pre><code>>>... | <p>No idea if an external library might be an option, but anyway -- assuming there is one <code><p></code> with this text on the page, a jQuery-solution would be:</p>
<pre><code>alert($('p').html()); // returns blah <b>bleh</b> blih
</code></pre>
| 49,874 |
<p>I'm interested in seeing a good diff algorithm, possibly in Javascript, for rendering a side-by-side diff of two HTML pages. The idea would be that the diff would show the differences of the <em>rendered</em> HTML.</p>
<p>To clarify, I want to be able to see the side-by-side diffs <em>as</em> rendered output. So if... | <p>There's another nice trick you can use to significantly improve the look of a rendered HTML diff. Although this doesn't fully solve the initial problem, it will make a significant difference in the appearance of your rendered HTML diffs.</p>
<p>Side-by-side rendered HTML will make it very difficult for your diff t... | <p>I believe a good way to do this is to <a href="http://weblogs.mozillazine.org/roc/archives/2005/05/rendering_web_p.html" rel="nofollow noreferrer">render the HTML to an image</a> and then use some <a href="http://www.scootersoftware.com/" rel="nofollow noreferrer">diff tool that can compare images</a> to spot the di... | 5,165 |
<p>I have a batch file (in windows XP, with command extension activated) with the following line:</p>
<pre><code>for /f %%s in ('type version.txt') do set VERSION=%%s
</code></pre>
<p>On some computer, it works just fine (as illustrated by <a href="https://stackoverflow.com/questions/130116/dos-batch-commands-to-read... | <p>I got a first empiric answer:</p>
<pre><code>for /f %%s in (version.txt) do ...
</code></pre>
<p>works just fine, on every computer.</p>
<p>It seems <code>for /f</code> works with a filename, not with any dos command like 'type filename'.</p>
<p>However, it is not true for all my client's computer (on some, the ... | <p>Is it that the file doesn't have an extension and thus the cmd treats it like a directory that doesn't exist?</p>
| 32,664 |
<p>I have a local Git repository I've been developing under for a few days: it has eighteen commits so far. Tonight, I created a private Github repository I was hoping to push it to; however, when I did so, it only ended up pushing eight of the eighteen commits to Github. I deleted the Github repo and retried, with the... | <p>I took a look at the repository in question and here's what was going on:</p>
<ul>
<li>At some point, rpj had performed <code>git checkout [commit id]</code>. This pointed HEAD at a loose commit rather than a recognized branch. I believe this is the "dangling HEAD" problem that CesarB is referring to.</li>
<li>Not ... | <p>So, it turns out that both: the commit hash in .git/refs/heads/master was incorrect and the information in .git/logs/refs/heads/master was incomplete; in that I mean it only went up to and included the commit hash specified in .git/refs/heads/master.</p>
<p>Once I fixed these files (by hand), and pushed them back to... | 29,386 |
<p>Is it possible to protect flv files from download? I'd like to protect my files from download but I don't have the money for a streaming server which I think provides some sort of protection. The files are streamed via PHP and are located in an upload folder on my server.</p>
<p>I've used PHP to ensure that only su... | <p>I fully agree with the DRM consensus of other answers. But would like to add...</p>
<p>There are a couple of <em><strong><a href="http://en.wikipedia.org/wiki/Obfuscation" rel="noreferrer">obfuscation</a></strong></em> techniques that may meet you needs. <em>"Good enough"</em>, as they say. These aren't... | <p>No protection can beat a simple use of WireShark + NetMiner.</p>
<p>Period.</p>
<p>Oh and by the way, about youtube, if you use Chrome check out this extension:</p>
<p><a href="http://hosting.gmodules.com/ig/gadgets/file/113621719436589749332/ZiTube.crx" rel="nofollow noreferrer">http://hosting.gmodules.com/ig/ga... | 38,565 |
<p>In a multi-threaded program running on a multi-cpu machine do I need to access shared state ( _data in the example code below) using volatile read/writes to ensure correctness.</p>
<p>In other words, can heap objects be cached on the cpu?</p>
<p>Using the example below and assuming multi-threads will access the Ge... | <p>The <a href="http://msdn.microsoft.com/en-us/library/xfhwa508.aspx" rel="noreferrer">MSDN docs</a> for <code>Dictionary<TKey, TValue></code> say that it's safe for multiple <em>readers</em> but they don't give the "one writer, multiple readers" guarantee that some other classes do. In short, I wouldn't do this... | <p>Volatile is not locking, it has nothing to do with synchronization. It's generally safe to do lock-free reads on read-only data. Note that just because you don't remove anything from _data, you seem to call _data.Add(). That is NOT read-only. So yes, this code will blow up in your face in a variety of exciting and d... | 45,438 |
<p>I am looking for some recommendations on good places to find libraries of controls/templates/styles for WPF. I know about the usual places like Infragistics, but it seems to me that there should be some kind of community effort by now to share nice, clean, well written controls for WPF controls.</p>
<p>I am not big... | <p>I strongly recommend the <a href="http://mahapps.com/" rel="noreferrer">MahApps</a> it's simply awesome! </p>
| <p>Check out <a href="http://www.nukeation.com/reuxables.aspx" rel="nofollow noreferrer">Reuxables</a> although it comes at a cost.</p>
| 14,801 |
<p>In Linux environment, when getting "glibc detected *** free(): invalid pointer" errors, how do I identify which line of code is causing it?</p>
<p>Is there a way to force an abort? I recall there being an ENV var to control this?</p>
<p>How to set a breakpoint in gdb for the glibc error?</p>
| <p>I believe if you setenv <code>MALLOC_CHECK_</code> to 2, glibc will call <code>abort()</code> when it detects the "free(): invalid pointer" error. Note the trailing underscore in the name of the environment variable.</p>
<p>If <code>MALLOC_CHECK_</code> is 1 glibc will print "free(): invalid pointer" (and similar p... | <p>In general, it looks like you might have to recompile glibc, ugh.</p>
<p>You don't say what environment you're running on, but if you can recompile your code for OS X, then its version of libc has a free() that listens to this environment variable:</p>
<pre><code>MallocErrorAbort If set, causes abort(3... | 18,232 |
<p>I've been trying to design a database schema for a side project but I havent been able to produce anything that I'm comfortable with. I'm using ASP.Net with LINQ for my data access:</p>
<p>I'm going to allow users to specify up to 10 "items" each with 2 numeric properties, and 1 referential property, the item name.... | <p>I'd recommend the latter design you mention, create one dependent table with five columns:</p>
<pre><code>CREATE TABLE Items (
user_id INTEGER NOT NULL,
item_id INTEGER NOT NULL DEFAULT 1,
numeric_property1 INTEGER,
numeric_property2 INTEGER,
referential_property INTEG... | <p>use a single item table: </p>
<p>userId, itemIndex, isReference, numericValue, referenceValue</p>
<p>this way the value for item_3_name for user 999 translates to</p>
<p>999,3,true,null,value</p>
<p>You will have to enforce certain constraints yourself, s.a. the maximal number of items per user, etc.</p>
| 32,830 |
<p>A database application that I'm currently working on, stores all sorts of settings in the database. Most of those settings are there to customize certain business rules, but there's also some other stuff in there.</p>
<p>The app contains objects that specifically do a certain task, e.g., a certain complicated calcu... | <p>You could use Martin Fowlers ServiceLocator pattern. In php it could look like this:</p>
<pre><code>class ServiceLocator {
private static $soleInstance;
private $globalSettings;
public static function load($locator) {
self::$soleInstance = $locator;
}
public static function globalSettings() {
if... | <p>Usually this is handled by an ini file or XML configuration file. Then you just have a class that reads the setting when neeed.</p>
<p>.NET has this built in with the ConfigurationManager classes, but it's quite easy to implement, just read text files, or load XML into DOM or parse them by hand in code.</p>
<p>Hav... | 3,322 |
<p>I am trying to install SQL server express 2008 on my machine. I get an error message that says that older version of VS 2008 in installed on the computer. Upgrade to VS2008 SP1 before installing Sql server 2008. </p>
<p>I tried to install sp1 but I get an error message that a compatible version of vs2008 is not det... | <p>You need to have the full version of Visual Studio 2008 installed in order to upgrade to Service Pack 1. You should have a look on the MS site for an SP1 specific to the Express editions of Visual Studio.</p>
<p>In fact I'm not certain but try redownloading Visual Studio express and it should have SP1 already integ... | <p>It isn't compulsory to install the full version of Visual Studio 2008 to upgrade to Service Pack 1. You can install any of the express editions with sp1, ideally Visual C++ and C#. If you already have them installed on your PC, re-install and remove any old versions of SQL Server Express(2000 or 2005 in Add/Remove P... | 34,868 |
<p>Is there a way to change the default pages used to edit/create/view a Sharepoint list item without using SharePoint designer? Since I've already created the aspx files on the development machine, it seem's a bit silly to have to install SharePoint designer on the customers server just to set a few default pages.</p>... | <p>Take a look at <a href="http://www.red-gate.com/products/SQL_Prompt/index.htm" rel="noreferrer">Red Gate's SQL Prompt</a>.</p>
| <p>It's not Management Studio, but <a href="http://www.toadworld.com/Products/ToadforSQLServer/tabid/217/Default.aspx" rel="nofollow noreferrer">Toad</a> has a freeware version with autocomplete.</p>
| 30,369 |
<p>I am looking for a powerful meta-language to describa behaviour for an application i intend to use in offline mode (google-gears + javascript) and server side sqlite + (php/ruby/java etc) and looking for a good format to describe the model's behaviour which can be easily converted to the target languages.
Am I compl... | <p>Have you looked at <a href="http://code.google.com/webtoolkit/" rel="nofollow noreferrer">Google Web Toolkit</a>? GWT allows you to write server side Java objects which get translated into Javascript for you. This allows you to not deal with the browser quirks at all.
I'm not sure how well integrated the Gears and... | <p>Maybe you should consider using <a href="http://www.codeplex.com/scriptsharp" rel="nofollow noreferrer">Script#</a>?</p>
| 6,416 |
<p>Consider the following use of template template parameters...</p>
<pre><code>#include <iostream>
template <typename X>
class A
{
X _t;
public:
A(X t)
:_t(t)
{
}
X GetValue()
{
return _t;
}
};
template <typename T, template <typename T> class C >
... | <p>I assume you're after X, as well as A, in your code. </p>
<p>The usual pattern is to have</p>
<pre><code>template<typename C>
struct B
{
C c;
};
</code></pre>
<p>and then, inside classes eligible for substitution:</p>
<pre><code>template<typename X>
class A
{
typedef X type_name;
X t;
};
</c... | <p>What is wrong with:</p>
<pre><code>template <typename C >
struct B
{
C c;
};
int main()
{
B< A<int> > b;
return 0;
}
</code></pre>
| 40,520 |
<p>How to add new item in existing string array in C#.net?</p>
<p>I need to preserve the existing data.</p>
| <p>I would use a List if you need a dynamically sized array:</p>
<pre><code>List<string> ls = new List<string>();
ls.Add("Hello");
</code></pre>
| <pre><code>private static string[] GetMergedArray(string[] originalArray, string[] newArray)
{
int startIndexForNewArray = originalArray.Length;
Array.Resize<string>(ref originalArray, originalArray.Length + newArray.Length);
newArray.CopyTo(originalArray, startIndexForNewArray);
... | 31,013 |
<p>So I have a weird situation here... I have an System.Web.UI.WebControls.WebParts.EditorPart class. It renders a "Search" button, when you click this button, it's clickHandler method does a DB search, and dynamically creates a LinkButton for each row it returns, sets the CommandName and CommandArgument properties and... | <p>This is my favorite trick :)</p>
<p>Our scenario is to first render a control. Then using some input from the user, render further controls and have them respond to events.</p>
<p>The key here is state - you need to know the state of the control when it arrives at PostBack - so we use ViewState. The issue become... | <p>A dirty hack I just came up with, is to create dummy LinkButtons with the same IDs as the real buttons.
So let's say you are going to create a LinkButton "foo" at Pre_Render (which is too late), then also create a dummy foo at Page_Load:</p>
<pre><code> var link = new LinkButton();
link.ID = "foo";
... | 17,051 |
<p>I have a hidden field that i want to bind to either a function on the page's code behind. I don't quite recall the exact syntax and i can't find the answer via Google. Is the code below correct? Thank.</p>
<pre><code>print("<asp:HiddenField ID="dummy" Value='<%#Getdummy() %>' runat="server" />");
</code... | <p>The code you've put looks pretty good ...</p>
<p>The two step process is ... add the hidden field to the markup</p>
<pre><code><asp:HiddenField ID="hdnId" runat="server" Value='<%# GetValue() %>'/>
</code></pre>
<p>Then create the specified method signature ...</p>
<pre><code>protected string GetValu... | <p>If you have the hidden field with runat=server, you could write code to assign value in the code behind (rather than in the markup).</p>
| 39,001 |
<p>I'm new to 3D Printing and recently purchased an Ender 3D PRO I'm having an issue with the filament guide tube getting pushed out of the nozzle on the feeding mechanism. The assembly instructions don't include a whole lot of detail about installing this guide tube but there are blue clips that were included along w... | <p>The blue clips stick in the connector on the extruder end of the feed tube. They are to keep it from opening as the printer extrudes and retracts filament.</p>
<p>To install them, push them in between the white part of the fitting on the feed tube (not the hot end). You should only need one or two, and they are all... | <p>The clips or collet clips as they are called are to secure the Bowden tube more solidly to improve printer extrusion; more specifically: extruder retraction performance.</p>
<p>E3D has explained this very nicely on their site under <a href="https://e3d-online.com/blog/2017/10/27/bowden-tube-physics/" rel="nofollow ... | 1,624 |
<p>I had experience with struts, and briefly experimented with tiles. I know that within a layout each tile is a separate jsp page. Suppose I hit a button on each of four tiles, and each tile was (indirectly) calling a different web service. Would the tiles refresh asynchronously as results came in at different tim... | <p>Tiles are just fragments of one html page. There's no notion of ajax unless you manually add it. Therefor: Pressing 4 buttons on one page would be the same as clicking 4 links on any html page. The browser will send the appropriate request to the server. When the server answers very quickly, you wouldn't even have t... | <p>I think it would depend on the code in the background. You say that the tiles were indirectly calling web services. I would think it would refresh asynchronously unless you specified in your code for it not to do so. Say you push button 1 and then button 2. Action 1 comes back and your code says that the screen ... | 36,192 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.