instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'd like to know if Flash/AS3 has any nice way to convert an AS3 'Date' object to/from rfc-850 timestamp format (as used by HTTP date and last-modified).</p> <p>This question is very similar to <a href="https://stackoverflow.com/questions/17017/how-do-i-parse-and-convert-datetimes-to-the-rfc-3339-date-time-format">...
<p>Alright, so here's a couple of functions to do RFC-802/<code>Date</code> conversion in Flash.</p> <p>I learned that the <code>Date</code> object doesn't really have any notion of a timezone, and assumes that it is in the local timezone. If you pass an RFC-802 date to the <code>Date()</code> constructor, it parses i...
<p>The <a href="http://as3corelib.googlecode.com" rel="nofollow noreferrer">as3corelib</a> libraries have DateUtil.toRFC822() and DateUtil.parseRFC822() methods (among others). Don't know if these are exactly what you are looking for. </p> <p>The specific docs for the DateUtil class is here: <a href="http://as3corelib...
22,460
<p>I was doing some testing and straight LINQ-to-SQL queries run at least 80% faster than if calling stored procedures via the LINQ query</p> <p>In SQL Server profiler a generic LINQ query </p> <pre><code> var results = from m in _dataContext.Members select m; </code></pre> <p>took only 19 milliseconds as opposed t...
<p>1) Compare like with like. Perform exactly the same operation in both cases, rather than fetching all values in one case and doing a query in another.</p> <p>2) Don't just execute the code once - do it lots of times, so the optimiser has a chance to work and to avoid one-time performance hits.</p> <p>3) Use a prof...
<p>A noted in the comments some of this is that you are not comparing apples to apples. You are trying to compare two different queries, thus getting different results.</p> <p>If you want to try and determine performance you would want to compare the SAME queries, with the same values etc.</p> <p>Also, you might try...
32,925
<p>Having played around a little with both Tkinter and wxPython, I like Tkinter much better in terms of how clean my source code looks. However, it doesn't seem to have as many features; in particular it doesn't have tabs (as in, the tabs at the top of a Firefox window).</p> <p>A little Googling on the subject offers...
<p>On recent Python (> 2.7) versions, you can use the <a href="https://docs.python.org/2/library/ttk.html" rel="noreferrer"><code>ttk</code></a> module, which provides access to the <em>Tk themed widget</em> set, which has been introduced in <code>Tk 8.5</code>.</p> <p>Here's how you import <code>ttk</code> in Python ...
<p>"Or is it simply the case that anyone who needs more powerful windowing components has to use wxPython?"<br> Short answer: yes.</p> <p>Long answer: It may take some practice for your wxPython code to feel "clean," but it is nicer and much more powerful than Tkinter. You will also get better support, since more peo...
36,055
<p>I'm looking for a post processing method for increasing the functional strength of a 3d printed part originally made by FDM. I've tried printing my part with solid infill but the layer separation is still the primary failure point. I'm looking for a way to get something closer to a cast or injection molded part. Obv...
<p>Recognizing that the posting party feels that FDM constructed parts are of insufficient strength for his purpose and allowing for proper layer bonding, one can understand that the model can be perfectly constructed and not reach the strength objective.</p> <p>Filling a model with an epoxy or a casting resin will pr...
<p>Layer separation will always be the primary failure point of FDM. So your best action would be to design parts in such a way that forces are applied across the Z axis, not along it. </p> <p>If layer bonding is too weak, this is a problem that should be solved during printing. Possible reasons are: </p> <ul> <li>No...
544
<p>When I try to do any svn command and supply the <code>--username</code> and/or <code>--password</code> options, it prompts me for my password anyways, and always will attempt to use my current user instead of the one specified by <code>--username</code>. Neither <code>--no-auth-cache</code> nor <code>--non-interacti...
<p>Do you actually have the single quotes in your command? I don't think they are necessary. Plus, I think you also need <code>--no-auth-cache</code> and <code>--non-interactive</code></p> <p>Here is what I use (no single quotes)</p> <pre> --non-interactive --no-auth-cache --username XXXX --password YYYY </pre> <p>S...
<p>Best I can give you is a "works for me" on SVN 1.5. You may try adding <code>--no-auth-cache</code> to your <code>svn update</code> to see if that lets you override more easily.</p> <p>If you want to permanently switch from user2 to user1, head into ~/.subversion/auth/ on *nix and delete the auth cache file for do...
5,501
<p>I'm trying to write a simple ruby function that can prompt the user for a value and if the user presses ENTER by itself, then a default value is used. In the following example, the first call to the Prompt function can be handled by pressing ENTER by itself and the default value will be used. However, the second tim...
<p>This isn't technically an answer, but it'll help you anyways: use Highline (<a href="http://highline.rubyforge.org/" rel="nofollow noreferrer">http://highline.rubyforge.org/</a>), it'll save you a lot of grief if you're making a command-line interactive interface like this</p>
<p>I also tried your code (under OSX) with ruby 1.8.6 and it worked fine:</p> <pre><code>:! ruby prompt.rb Prompt&gt;(sdfsdf) sdfsdf Prompt&gt;(default) default </code></pre> <p>What do you get when you run the following?</p> <pre><code>c = gets b = gets a = gets p [ a, b, c ] </code></pre> <p>I just hit 'Enter' ...
43,116
<p>Has anyone been able to use the SSCrypto Framework for Cocoa to encrypt text and then decrypt it in C#/.NET ? Or can someone offer some guidance?</p> <p>I'm pretty sure my issue has to do with getting the crypto settings correct but I am far from fluent in Cocoa so I can't really tell what settings are being used i...
<p>You could use OpenSSL directly in C# with the <a href="http://openssl-net.sourceforge.net" rel="nofollow noreferrer">OpenSSL.NET</a> wrapper!</p>
<p>IIRC, OpenSSL uses what MS calls PKCS7 padding (though OpenSSL refers to it as PKCS5, and I'm not enough of a standards wonk to care why).</p>
38,536
<p>Coming from C++, I find generic programming indispensable. I wonder how people approach that in Haskell?</p> <p>Say how do write generic swap function in Haskell?</p> <p>Is there an equivalent concept of partial specialization in Haskell?</p> <p>In C++, I can partially specialize the generic swap function with a ...
<p>This is closely related to your other question about Haskell and quicksort. I think you probably need to read at least the <em>introduction</em> of a book about Haskell. It sounds as if you haven't yet grasped the key point about it which is that it bans you from modifying the values of existing variables.</p> <p>S...
<p>After reading enough in a Haskell book to really understand Earwicker's answer I'd suggest you also read about type classes. I'm not sure what “partial specialization” means, but it sounds like they could come close.</p>
49,370
<p>So I have a column with different numbers and wish to categorize them by range within 30 minute intervals. So 5 would be 0-30, 697 would be 690-720, and 169 would be 150-180. I was first thinking of doing a case statement, but it doesn't look like Access 2003 supports it. Is there perhaps some sort of algorithm that...
<p>Take the integer portion of (number / 30) using the Int function and multiply it by 30 to get your lower bound, then add 30 to that number to get your upper bound.</p> <p>Examples<br></p> <pre><code>Int(5 / 30) = 0 * 30 = 0 Int(697 / 30) = 23 * 30 = 690 </code></pre>
<p>Use / (integer division) and * (multiplication). 5/30*30 = 0 697/30*30 = 690 169/30*30 = 150 ...</p>
32,928
<p>I have a java me application and now I want to place that application at the server. I want to write the download page with servlet. I mean when the user keys in the servlet url and hit to that servlet, my jad file will send to the phone(user no need to click to download button or link.After page loading, the servle...
<p>you should add variety of other lines that usually come in jad file ;)</p> <p>in this example below jad and jar files are in the same directory. if they are not in the same dir, you should provide MIDlet-Jar-URL: either with relative path to the jad file or an absolute path to your jar file. I mean this has to be f...
<p>i guess the problem lies in the contents of jad file - path to jar file must be invalid.</p> <p>besides, handsets frequently are quite picky about the format of jad file - order of rows, newline character, etc</p>
48,003
<p>I am trying to print a model that has (at the start of the print) several small parts attached to the bed. Some of these parts have bed contact 2.5mm x 20mm.</p> <p>After a few layers, if there are any imperfections in the previous layer, the hotend is bumping the imperfection and knocking the part loose.</p> <p>I...
<p>One technique is to add your own custom brims to the model. A couple of "Mickey Mouse ears", attached to each end of the piece, may be enough to keep it in place (and will also be easy to remove).</p>
<p>My low-tech solution is to smear on some school/craft glue-stick. This is so quick and so easy yet it has saved me so many times from going any further troubleshooting adhesion problems.</p> <p>My <a href="https://3dprinting.stackexchange.com/a/5781/9719">answer to a similar question</a> describes this in full.</p>...
703
<p>I'd like my .NET Compact Framework app to delete itself after it finishes executing. What's the best way to do this?</p> <p>On a Windows machine it's possible to do this using a .bat file, but that's not an option on mobile devices.</p>
<p>In Windows Mobile there is the directory:</p> <p>\application data\volatile</p> <p>This directory is kept for as long as the device has power.</p> <p>So what we do is:</p> <ol> <li>copy a exe over to this directory, or a sub-directory (I normally use a sub-directory to make sure we don't clash with another appli...
<p>One idea is you could use wceload:</p> <p><a href="http://msdn.microsoft.com/en-us/library/bb158700.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb158700.aspx</a></p> <p>Write a cab file that has a custom step (I think you might need to create a setup.dll) that will delete your applicati...
34,024
<p>I have a listbox containing and image and a button. By default the button is hidden. I want to make the button visible whenever I hover over an item in the listbox. The XAML I am using is below. Thanks</p> <pre><code>&lt;Window.Resources&gt; &lt;Style TargetType="{x:Type ListBox}"&gt; &lt;Setter Propert...
<p>Ok, try this in your button declaration:</p> <pre><code>&lt;Button x:Name="sideButton" Width="20"&gt; &lt;Button.Style&gt; &lt;Style TargetType="{x:Type Button}"&gt; &lt;Setter Property="Visibility" Value="Hidden" /&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Bindi...
<p>One solution to find what item was clicked is to add the following Event setter</p> <p>XAML </p> <p>C# void ListBoxItem_MouseEnter(object sender, MouseEventArgs e) { _memberVar = (sender as ListBoxItem).Content; }</p>
25,298
<p>Whoops, I need some info from a file I deleted, a while ago. In CVS I would just go to the ATTIC to find it, how do I find a file in SVN without having to go back to a revision where it existed (especially annoying since I have no idea really when I deleted -- one week ago, two weeks ago...)</p>
<p>Browse the SVN Log of the directory it was in, find the revision where you deleted it. In the bottom pane, right click the file, and choose the option "Save Revision To..".</p> <p>To help you find which revision you deleted it in, look for the icon of a doc with an X in the lower left of it in the Actions column o...
<p>The "attic" in CVS is more of an implementation detail. The file can't be deleted <em>completely</em> from the repository, since the file history is in the "<code>,v</code>" file itself, so CVS moves it aside.</p> <p>Subversion uses a more sophisticated repository storage mechanism where files don't need to be move...
19,790
<p>I've got a situation where I have a main form that pops up an advanced configuration form that just has half a dozen matched check boxes and combo boxes to select some advanced options (the check boxes to enable/disable, the combo to select a media if enabled).</p> <p>If I just pass the individual settings for the ...
<p>I personally would create a carrier object to store the values. You then get the nice intellisense for it, and changes to it would be quite straightforward. It would also be faster than dictionary lookups for parameter values. And of course, you get type safety. :)</p>
<p>Something like this should be good:</p> <pre><code>MyConfigurationDialog dialog = new MyConfigurationDialog(); //Copy the dictionary so that the dialog can't mess with our settings dialog.Settings = new Dictionary(existingSettings); if(DialogResult.OK == dialog.Show()) { //grab the settings that the dialog may ...
6,135
<p>I'm trying to understand how hibernate query cache really works. What I see now is that Hibernate does not update its second-level cache automatically when I insert new entities into the database (although I'm using only Hibernate calls). The only way I have found to make it work was to manually clean the cache aft...
<p>You might find my blog on query cache workings to be helpful in understanding what the query cache does and why it might not work the way you think it works:</p> <ul> <li><a href="http://tech.puredanger.com/2009/07/10/hibernate-query-cache/" rel="noreferrer">http://tech.puredanger.com/2009/07/10/hibernate-query-cac...
<p>Yes, query cache auto invalidation is absent for native SQL-queries. For HQL-queries it just CLEARS ALL CACHES if any of tables participated in query have INSERT/UPDATE/DELETE for any object.</p> <p>So you may try <a href="https://github.com/mrniko/hibernate-dsc" rel="nofollow">Hibernate Dynamic SQL Cache</a> proje...
19,509
<p>I'm trying to run PHPDocumentor on my WAMPServer setup. It runs fine, but I'd like to exclude certain directories, such as \sqlbuddy\ which don't contain my own code. Ironically, PHPDocumentor appears to be ignoring my --ignore switch. I've tried several ways of expressing the same thing, but with the same result. B...
<p>Which version of phpDocumentor are you using?</p> <p>Because the <a href="http://phpdoc.org/news.php?id=57" rel="nofollow noreferrer">phpDocumentor 1.4.2 release notes</a> states:</p> <blockquote> <p>This release fixes two Windows-specific bugs, one involving usage of the "--ignore" option, and one involvi...
<p>You might need to change that ignore value to forward slash...</p> <p>Internally, old PHP4-era PhpDocumentor still has some slash-handling of its own, where it tries to make all directory separators read as forward-slashes only. Compound this with the --ignore option values effectively being a regex mask, and it g...
47,284
<p>I've been assigned the task of buying a digital certificate for my company to sign our code. We develop applications in the Microsoft space - mostly WPF or Web Based.</p> <p>I've investigated options and found Comodo to be well priced and responsive, and we're ready to go ahead and purchase a cert through them.. ho...
<p>For "most purposes" the following options are recommended:</p> <ul> <li>Microsoft Base Cryptographic Provider</li> <li>Key Size: 2048</li> <li>Exportable: Yes</li> <li>User Protected: Yes</li> </ul> <p>To be honest, I'm not familiar with the different CSPs, but the Base does the job every time for me.</p> <ul> <l...
<p>Regarding "Microsoft Software Cryptographic Provider" - I think that should be "strong" (not "software").</p> <p>In practice where I work, base gives a 512-bit key length (which is no longer supported or working on MS servers after a recent patch - read on KB2661254). You want at least 1024, but 2048 is a better ch...
31,417
<p>Does ODBC support asynchronous calls? If it does, then can you tell me about any reference materials?</p> <p>My preferred language is C++.</p>
<p>I've wanted to know the exact same thing. An obvious workaround is to maintain a pool of threads that each perform synchronous ODBC calls and are signalled (and signal back) asynchronously.</p>
<p>Typically it seems like such things are implemented at another abstraction level of an application, or you roll your own. Just about anything that involves a blockable "open" action can spawn a thread for the purpose of managing the open and raising a signal or setting a flag somewhere globally when it happens.</p> ...
39,338
<p>When running a web application project, at seemingly random times a page may fail with a CS0433 error: type exists in multiple DLL's. The DLL's are all generated DLL's residing in the "Temporary ASP.NET Files" directory.</p>
<p>Add the batch="false" attribute to the "compilation" element of the web.config file.</p> <p>This problem occurs because of the way in which ASP.NET 2.0 uses the application references and the folder structure of the application to compile the application. If the batch property of the element in the web.config file...
<p>Sometimes it may help to remove the solution and create it again. Since this use to happen when converted from VS2005 to vs2010 some references to framework 4.0 (after upgrading ) remains in the solution, even all projects are defined as 3.5.</p> <p>Normally rebuilding the solution should clear these problems.</p>
48,540
<p>Unsure if I've phrased this correctly, but in the callback how do I reference the controls property of the base class?</p> <p>This has been bugging me for some time and I usually work around it, but I'd be grateful if anybody can enlighten me on how I should do this properly.</p> <pre><code>var base = function() {...
<p>Use the power of closures:</p> <pre><code>var base = function() { var controls = {}; return { init: function(c) { this.controls = c }, foo: function(args) { var self = this; this.init(args.controls); $(this.controls.Dr...
<p>You need to leverage closures here.</p> <pre><code>var base = function() { var controls = {}; return { init: function(c) { this.controls = c }, foo: function(args) { this.init(args.controls); $(this.controls.DropDown).change(function(controls) { r...
31,700
<p>When doing small icons, header graphics and the like for websites, is it better to use GIFs or PNGs?</p> <p>Obviously if transparency effects are required, then PNGs are definitely the way to go, and for larger, more photographic images I'd use JPEGs - but for normal web "furniture", which would you recommend and ...
<p>As a general rule, PNG is never worse, and often better than GIF because of superior compression. There might be some edge cases where GIF is slightly better (because the PNG format may have a slightly larger overhead from metadata) but it's really not worth the worry.</p> <blockquote> <p>It may just be the tools...
<p>I use jpg for all non-transparent images. You can control the compression, which I like. I found <a href="http://www.wfu.edu/~matthews/misc/jpg_vs_gif/JpgVsGif.html" rel="nofollow noreferrer">this</a> web site that compares the two. jpg is smaller and looks better.</p>
14,117
<p>I'm wanting to write a method that I can use to initialise a Map. First cut:</p> <pre><code>Map map(Object ... o) {for (int i = 0; i &lt; o.length; i+=2){result.put(o[i], o[i+1])}} </code></pre> <p>Simple, but not type-safe. Using generics, maybe something like:</p> <pre><code>&lt;TKey, TValue&gt; HashMap&lt;TKe...
<p>To make life easier for yourself, never use a return type that contains wildcards. Wildcard types, in general, are for method parameters only.</p> <p>So, try this:</p> <pre><code>public static &lt;TKey, TValue, TMap extends Map&lt;TKey, TValue&gt;&gt; TMap map(TMap map, Pair&lt;? extends TKey, ? extends TValue&gt;...
<p>pgdx: Your technique certainly works but it does not prevent me from saying something like:</p> <pre><code>Map&lt;Long, Date&gt; map = toHash("hello", "world"); </code></pre> <p>I was looking for a way which would allow the compiler to pick up on any type-mismatch errors.</p>
42,153
<p>I have only this in my mxml source code:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="components.*" width="770" height="330"&gt; &lt;mx:Label x="185.5" y="150" text="Placeholder for Future UI." fontSize="...
<p>I solved this problem already. The problem was I created my multi module project with maven and imported the projects to eclipse. So by default the flex project wasn't recognized by eclipse as a flex project. What I did was I deleted the flex project, and recreated it with 'File -> New -> Flex Project' option, and ...
<p>It sounds like it's not liking the "Canvas" element. I've never used Flex, but in the example of doing an WPF application in Visual Studio, there are only certain elements that are excepted for the root element depending on how the file is being used. If it's the main MXML file, it's probably expecting something els...
45,174
<p>If anyone is trying to do agile, i am trying to figure out a way to use JIRA / Greenhopper for this. We are a global dev team so the distributed nature is crucial here.</p> <p>We were initially using Scrumworks but the team complained that they had duplicate information in JIRA and scrumworks all the time and thou...
<p>You can add your own Issue types in JIRA. Just add a type called User Story.</p> <p>Then make sure to enable your sub-tasks feature in JIRA. You will then be able to explode your stories int multiple Subtasks. The integration of the subtasks is pretty nice if you reuse the Ranking feature. See: <a href="http://www....
<p>You might also try using an Agile Lifecycle Management product such as Rally, www.rallydev.com. Rally is built from the ground up to support any agile process and create comprehensive reports across teams. Check it out. </p>
37,518
<p>There are a number of framework out there that provide the skeleton for building applications such as <a href="http://www.lhotka.net/cslanet/" rel="nofollow noreferrer">CSLA</a>, <a href="http://www.devexpress.com/Products/NET/Application_Framework/" rel="nofollow noreferrer">XAF</a>, <a href="http://msdn.microsoft....
<p>.NET is my favorite framework.</p> <p>The applications I work on are usually too complex to fit into a "skeleton". However when working on Winforms, I like to take advantage of <a href="http://msdn.microsoft.com/en-us/library/aa480450.aspx" rel="nofollow noreferrer">CAB</a> for the UI. I wouldn't say this is the sk...
<p>.NET is my favorite framework.</p> <p>The applications I work on are usually too complex to fit into a "skeleton". However when working on Winforms, I like to take advantage of <a href="http://msdn.microsoft.com/en-us/library/aa480450.aspx" rel="nofollow noreferrer">CAB</a> for the UI. I wouldn't say this is the sk...
47,181
<p>I have a webservice, which takes java.lang.object objects as parameters (because at runtime only know hte type of object)...after doing process, reply response setting java.lang.Object to it.</p> <p>I am able to send the reuest objects to webservice from calling program, but getting NotSerializable exception while ...
<blockquote> <p>I have a webservice, which takes java.lang.object objects as parameters (because at runtime only know hte type of object)</p> </blockquote> <p>This part worries me. Not knowing the type while programming is a code smell. If you have no idea what it is, how can you make code to handle it?</p> <...
<p>If the members of the class don't implement Serializable then you can't use native Java serialisation for it. That's basically what your error message is telling you.</p> <p>If you cannot cause the underlying objects to implement Serializable, then you are probably going to have to find a different method of seria...
26,380
<p>I've looked this up a thousand times, and I always forget it, so, here for eternity:</p> <p>Solaris has a bit of an awkward syntax for <code>tail</code>.</p> <p>How do I do the equivalent of BSD's <code>tail -n<i>N</i></code>?</p> <p>What I want are the last N lines from tail's input.</p>
<p>Just remove the "n"</p> <pre><code>tail -100 </code></pre>
<p>Cross-platform variant of <code>tail -n 10</code> for scripts:</p> <pre><code>sed -e :a -e '$q;N;11,$D;ba' file </code></pre> <p>This works the same for Linux and Solaris.</p>
40,550
<p>I have the following five tables:</p> <ul> <li>ISP</li> <li>Product</li> <li>Connection</li> <li>AddOn</li> <li>AddOn/Product (pivot table for many-to-many relationship).</li> </ul> <p>Each Product is linked to an ISP, each Connection is listed to a Product. Each product can have a number of add-ons, through the u...
<pre><code>GROUP BY set-of-column HAVING SUM(CASE WHEN ISNULL(pa.addon_id, 0) IN (1,14,237) THEN 1 ELSE 0 END) = 3 </code></pre>
<p>You could add to the WHERE clause:</p> <pre><code>AND NOT EXISTS (SELECT NULL FROM addon a2 WHERE a2.addon_id IN (1,14,237) AND NOT EXISTS ( SELECT NULL FROM product_addon pa2 WHERE pa2.addon_id = a2.addon_id A...
43,268
<p>In C++, you can specify that a function may or may not throw an exception by using an exception specifier. For example:</p> <pre><code>void foo() throw(); // guaranteed not to throw an exception void bar() throw(int); // may throw an exception of type int void baz() throw(...); // may throw an exception of some uns...
<p>No.</p> <p>Here are several examples why:</p> <ol> <li><p>Template code is impossible to write with exception specifications,</p> <pre><code>template&lt;class T&gt; void f( T k ) { T x( k ); x.x(); } </code></pre> <p>The copies might throw, the parameter passing might throw, and <code>x()</code> might ...
<p>Exception specifications = rubbish, ask any Java developer over the age of 30</p>
11,425
<p>I have a 3D surface ( such as a cone). It is projected to a 2D plan in the form of contour, meaning that different Z will have different lines on 2D plan. The problem is from the contour, how to recover the 3D surface by using interpolation? We only know about the z difference between different contor lines. </p>
<p>The technical term for the "contours" you mentioned is "iso-lines".<br> Given the set of iso-lines you first need to construct a point cloud in 3D (just a collection of points in 3D space). You do that in two stages. first by sampling each iso-line at a uniform intervals, You get 2D points and then you raise the poi...
<p>A surface reconstruction algorithm would a waste of time in this case if your points are in the z=f(x,y) or your shape is convex.</p> <p>For z=f(x,y) is the easy solution</p> <ol> <li>delaunay triangulation using only x,y coordinates </li> <li>plot the surface with previous triangulation, this time use z too. Job...
44,613
<p>I'm using MySQL in particular, but I'm hoping for a cross-vendor solution. I'm using the NOW() function to add a timestamp as a column for each record.</p> <pre><code>INSERT INTO messages (typeId, messageTime, stationId, message) VALUES (?, NOW(), ?, ?) </code></pre>
<pre><code>SELECT * FROM messages WHERE DATE_SUB(CURDATE(),INTERVAL 1 DAY) &lt;= messageTime </code></pre>
<p>There is no cross database solution, as most of them have their own date handling (and mainly interval representation) syntax and semantics. </p> <p>In <code>PostgreSQL</code> it would be</p> <pre><code>SELECT * FROM messages WHERE messagetime &gt;= messagetime - interval '1 day' </code></pre>
8,401
<p>So for e.g. 0110 has bits 1 and 2 set, 1000 has bit 3 set 1111 has bits 0,1,2,3 set</p>
<p>If there are really only 4 bits, then the fastest method would certainly involve a lookup table. There are only 16 different possibilities after all.</p>
<p>Depends on what you mean by fastest. </p> <p>If you mean "simple to code", in .NET you can use the BitArray class and refer to each bit as a boolean true/false.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.collections.bitarray.aspx" rel="nofollow noreferrer">BitArray Class</a></p>
9,440
<p>I have a not-so-small class under development (that it changes often) and I need not to provide a public copy constructor and copy assignment. The class has objects with value semantics, so default copy and assignment work.</p> <p>the class is in a hierarchy, with virtual methods, so I provide a virtual Clone() to ...
<p>An object from a polymorphic hierarchy, and with value semantics ? Something is wrong here.</p> <p>If you really do need your class to have a value semantics, have a look at J.Coplien's Envelop-Letter Idiom, or at this article about Regular Objects [1].</p> <p>[1] Sean Parent. “Beyond Objects”. Understanding The S...
<p>I don't think there is anything in the C++ language that allows you to do this. Although I'd love to be wrong on this point.</p> <p>I've run into this in the past and come up with the following solution. Asumme the class is C1. </p> <ol> <li>Define a private inner class called Data</li> <li>Put all of my members...
33,813
<p>With a <code>TreeMap</code> it's trivial to provide a custom <code>Comparator</code>, thus overriding the semantics provided by <code>Comparable</code> objects added to the map. <code>HashMap</code>s however cannot be controlled in this manner; the functions providing hash values and equality checks cannot be 'side-...
<p>.NET has this via IEqualityComparer (for a type which can compare two objects) and IEquatable (for a type which can compare itself to another instance).</p> <p>In fact, I believe it was a mistake to define equality and hashcodes in java.lang.Object or System.Object at all. Equality in particular is hard to define i...
<p>good question, ask josh bloch. i submitted that concept as an RFE in java 7, but it was dropped, i believe the reason was something performance related. i agree, though, should have been done.</p>
26,330
<p>I'm kind of new to ASP.NET MVC and to the MVC pattern in general but I'm really digging the concept and the rapidity with which I can compose an app. One thing that I'm struggling with is how to expose more than one object to a view. I use a lot of strongly typed views, which works well but what if my view relies ...
<p>You can simply store each object in the ViewData then cast the appropriate object type in your View.</p> <p>Controller:</p> <pre><code> ViewData["ObjectA"] = objectA; ViewData["ObjectB"] = objectB; </code></pre> <p>View:</p> <pre><code> &lt;%= ((ObjectA)ViewData["ObjectA"]).PropertyA %&gt; &lt;%= ((ObjectB)Vie...
<p>Use the <strong>ViewData</strong> collection to pass object to the view. You might want to pass a Controller instead of 1 by 1 object of your model.</p>
40,829
<p>Domain Driven Design encourages you to use a rich domain model. This means all the domain logic is located in the domain model, and that the domain model is supreme. Persistence becomes an external concern, as the domain model itself ideally knows nothing of persistence (e.g. the database).</p> <p>I've been using t...
<p>There are at least two ways to look at this problem, one is a technical "what can I do to load my data smarter" version. The only really smart thing I know about is dynamic collections that are partially loaded with the rest loaded on-demand, with possible preload of parts. There was an interesting talk at <a href="...
<p>No, not really. Not that I'm aware of anyway (though I'm interested to hear any of DDD's proponents' responses to the contrary).</p> <p>In my own experience, and that of the very experienced team that I work with, if you want optimal performance from a database-backed application the transformation of its architect...
49,564
<p>I am converting an excel sheet formula to java but I can't understand how excel manages to take the following: 0.22 Applies a formula: =TEXT(R5/14, "h:mm") and somehow arrives at: 0.22</p> <p>Again if I provide: 2.8 it arrives at 4.48 Can someone please explain to me how it does this. I have read a little regarding...
<p>Excel stores datetime values as:</p> <ul> <li>The number to the left of the decimal represents the number of days since January 1, 1900</li> <li>The number to the right of the decimal represents the fractional portion of a 24-hour day</li> </ul> <p>In your example, you are converting a decimal to a textual represe...
<p>Yeah it is a bit goofy. Take the /14 out and that helps. Basically 1=1 day so R5 is expressed in 14ths of a day. You could probably do </p> <pre><code>int msInADay= 86400000; Time value = new Time(R5/14 * msInADay); </code></pre> <p>but it is untested. </p>
18,257
<p>Just came across this quote in a book on OOP that I'm reading,</p> <blockquote> <p>A child is only allowed to augment functionality and add functionality. A child is never allowed to remove functionality. If you do find that a child need to remove functionality, this is an indication that the child ...
<p>You can remove functionality with overriding. But normally you use it to change the behaviour. To let the class behave as it should be.</p> <p>If behaviour is removed then it is very often a sign of a bad class design.</p>
<p>And that's kinda why overriding (and in general, any virtual members) is something that should be done very carefully... In fact, generally, when overriding, you should try to code both the base class and the derived class, so that the derived class implementation first calls the base implementation, and then execu...
42,325
<p>How does one design loosely-coupled systems which may often require data from each-other but don't necessarily belong in the same category?</p> <p>For instance, lets take the old Pet-shop example one-step further and create a pet-store franchise. Each pet-store has its own website listing their contact information,...
<p>I've been thinking about that problem, and I express it by saying that the relationships between classes are contextually determined. And any model that assumes global static associations (inherent coupling) between classes is problematic.</p> <p>Another example I like to use is Products. </p> <p>A Product can p...
<p>I mostly agree with the above proposed solution (using SOA). ESB might be a good approach depending upon the complexity of the application. But, I think that ESB has a large footprint and brings unnecessary complexity for most real-world applications.</p> <p>But, IMHO any good Architecture should be easily adaptabl...
37,568
<p>I am trying to get a specific colour used by Windows XP in my .NET application. </p> <p>In Windows XP, if you go the Control Panel in 'category view', on the left hand side you have some 'See Also' options (Windows Update, Help and Support, Other Control Panel Options). The colour I'm trying to get is the light blu...
<p>Thanks for the hint tamberg</p> <p>I found the answer I needed in System.Windows.Forms.VisualStyles</p> <p>I used a VisualStyleRenderer to draw the colour I needed.</p> <p>If anyone is interested, the colour I was after was the VisualStyleElement.ExplorerBar.NormalGroupBackground. <a href="http://msdn.microsoft.c...
<p>Quick guess: <a href="http://www.google.com/search?q=visualstyles.dll" rel="nofollow noreferrer">Google "VisualStyles.dll"</a> and maybe there's a hint in the source of <a href="http://www.codeproject.com/KB/miscctrl/ThemedExplorerControls.aspx?display=Print" rel="nofollow noreferrer">http://www.codeproject.com/KB/m...
34,229
<p>If you have a hash (or reference to a hash) in perl with many dimensions and you want to iterate across all values, what's the best way to do it. In other words, if we have $f->{$x}{$y}, I want something like</p> <pre><code>foreach ($x, $y) (deep_keys %{$f}) { } </code></pre> <p>instead of </p> <pre><code>foreac...
<p>Here's an option. This works for arbitrarily deep hashes:</p> <pre><code>sub deep_keys_foreach { my ($hashref, $code, $args) = @_; while (my ($k, $v) = each(%$hashref)) { my @newargs = defined($args) ? @$args : (); push(@newargs, $k); if (ref($v) eq 'HASH') { deep_keys_...
<p>It's easy enough if all you want to do is operate on values, but if you want to operate on keys, you need specifications of how levels will be recoverable.</p> <p>a. For instance, you could specify keys as <code>"$level1_key.$level2_key.$level3_key"</code>--or any separator, representing the levels.</p> <p>b. Or y...
19,370
<p>I am having a .cs file, i need to execute that file.. I don't have experience in C#.. Please help.. Do we have to install any software to run it.. </p> <p>Currently i am using windows XP.. </p> <p>Please help me... </p>
<p>Grab the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=fe6f2099-b7b4-4f47-a244-c96d69c35dec&amp;displaylang=en" rel="nofollow noreferrer">.NET SDK</a> (perhaps not needed, see comments) and see if you can compile your .cs file with <a href="http://msdn.microsoft.com/en-us/library/78f4aasd.aspx" r...
<p>Download and install the .NET framework from Microsoft, current version at the time of writing is v3.5 SP1 from <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ab99342f-5d1a-413d-8319-81da479ab0d7&amp;displaylang=en" rel="nofollow noreferrer">here</a>.</p> <p>If you're going to do any serious deve...
34,134
<p>What would be the best way to do this.</p> <p>The input string is </p> <pre><code>&lt;133_3&gt;&lt;135_3&gt;&lt;116_2&gt;The other system worked for about 1 month&lt;/116_2&gt; got some good images &lt;137_3&gt;on it then it started doing the same thing as the first one&lt;/137_3&gt; so then I quit using either ca...
<p>Use expat or another XML parser; it's more explicit than anything else, considering you're dealing with XML data anyway.</p> <p>However, note that XML element names can't start with a number as your example has them.</p> <p>Here's a parser that will do what you need, although you'll need to tweak it to combine dup...
<p>Here's an unreliable inefficient recursive regexp solution:</p> <pre><code>import re re_tag = re.compile(r'&lt;(?P&lt;tag&gt;[^&gt;]+)&gt;(?P&lt;content&gt;.*?)&lt;/(?P=tag)&gt;', re.S) def iterparse(text, tag=None): if tag is not None: yield tag, text for m in re_tag.finditer(text): for tag, text...
42,790
<p>Our application is structured something like:</p> <p>UI &lt;--> REST API &lt;--> Workflow &lt;--> Business Logic &lt;--> DAL &lt;--> DB</p> <p>However, I am seeing a few examples where it looks like people are doing</p> <p>UI &lt;--> Workflow &lt;--> REST API &lt;--> Business Logic &lt;--> DAL &lt;--> DB</p> <...
<p>It really is relative to what you mean workflow.</p> <p>Hypermedia as the engine of application state will give you a directed graph of states/resources. It is not necessary that these graphs form a workflow (e.g have a specific start and end point). They may well form a cycle, have bidirectional links and whatnot....
<p>REST is access to resources. The question is "What's a resource"? Most answers are that it's a pretty low-level piece of information.</p> <p>A composite application or workflow depends on one or more resources.</p> <p>It's hard to say that a resource depends on a workflow. Not imspossible. But hard.</p> <p>Wh...
20,987
<p>I installed Python 2.6 for one user on Windows Vista. Python works okay, but when I try: <code>import Tkinter</code>, it says the side-by-side configuration has errors. I've tried tinkering with the Visual Studio runtime, with no good results. Any ideas on how to resolve this?</p>
<p>Maybe you should downgrade to 2.5 version?</p>
<p>python 2.6.2 + tkinter 8.5, no problems</p>
26,976
<p>I'm creating a plugin framework, where my application loads a series of plugin DLL's, then creates a new window and pass this new window's handle to the plugin. The plugin can, then, use this handle to create their own GUI.</p> <p>Everything seems to be working very well. The only problem is that when I press TAB o...
<p>It's very complex matter indeed.</p> <p>When you hit TAB focus jumps to another control only when these controls belong to a Modal Dialog Box. In fact there are some buttons like ESC, LEFT, RIGHT, DOWN, UP, TAB which modal dialog message function treats in a special way. If you want these keys to behave in similar ...
<p>I believe you'll have to take the following steps:</p> <ol> <li><a href="http://msdn.microsoft.com/en-us/library/ms997565.aspx" rel="nofollow noreferrer">Subclass</a> your edit controls (and other controls as needed).</li> <li>Capture the <a href="http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx" rel="n...
3,622
<p>If I remove all the ' characters from a SQL query, is there some other way to do a SQL injection attack on the database?</p> <p>How can it be done? Can anyone give me examples?</p>
<p>Yes, there is. An excerpt from <a href="http://en.wikipedia.org/wiki/SQL_injection" rel="noreferrer">Wikipedia</a></p> <p><code>"SELECT * FROM data WHERE id = " + a_variable + ";"</code></p> <p>It is clear from this statement that the author intended a_variable to be a number correlating to the "id" field. Howeve...
<p>It depends on how you put together the query, but in essence yes.</p> <p>For example, in Java if you were to do this (deliberately egregious example):</p> <pre><code> String query = "SELECT name_ from Customer WHERE ID = " + request.getParameter("id"); </code></pre> <p>then there's a good chance you are opening y...
9,729
<p>Are there any tools to give some sort of histogram of where most of the execution time of the program is spent at?</p> <p>This is for a project using c++ in visual studio 2008.</p>
<p>The name you're after is a <strong>profiler</strong>. Try <a href="http://msdn.microsoft.com/en-gb/magazine/cc337887.aspx?pr=blog" rel="noreferrer">Find Application Bottlenecks with Visual Studio Profiler</a></p>
<p>So now that you know you need a profiler, you might not have the Visual Studio one, so <a href="http://www.codersnotes.com/sleepy/" rel="nofollow noreferrer">Very Sleepy</a> might be of help.</p>
43,514
<p>I've been aware of Steve Yegge's advice to <a href="http://steve.yegge.googlepages.com/effective-emacs#item1" rel="nofollow noreferrer">swap Ctrl and Caps Lock</a> for a while now, although I don't use Emacs. I've just tried swapping them over as an experiment and I'm finding it difficult to adjust. There are severa...
<p>I actually don't swap control and caps and just make caps ANOTHER control key. I can't think of a single time in my life when I have ever hit caps-lock on <strong>purpose</strong>, so I haven't missed it.</p> <p>That way, you get used to using it, but if you slip up and use the old control, things still work. It'...
<p>I had no problem making the transition. I use keyboards with both configurations without issue. Perhaps having it as a hardware solution (and the labels properly printed) makes it easier than doing it through software and having to remember how each machine/keyboard is setup.</p>
15,575
<p>I'm trying to build a console application without using the CRT, or any other imports than kernel32.lib in any case. I get my code to compile, but can't wrap the linker around a few problems:</p> <pre><code>unresolved external symbol @__security_check_cookie@4 unresolved external symbol "int __cdecl FreeLibrary(voi...
<p>_wmainCRTStartup is the function that calls wmain()</p> <p>IIRC it should be available in some .o file that you can link with, look in your lib directory.</p> <p>Maybe this is useful reading too: <a href="http://msdn.microsoft.com/en-us/magazine/cc301696.aspx" rel="nofollow noreferrer">Reduce EXE and DLL Size with...
<p>The proper entry point is <code>main()</code>, not <code>wmain()</code> (since you're compiling a console app). The security cookie code can be nicked from the CRT source code; no need to link it in.</p>
39,230
<p>I'm creating window using pure Win32 API (RegisterClass and CreateWindow functions). How can I specify a font for the window instead of system defined one?</p>
<p>As vividos said just use <a href="http://msdn.microsoft.com/en-us/library/ms534214.aspx" rel="noreferrer">CreateFont()/CreateFontIndirect</a>:</p> <pre><code>HFONT hFont = CreateFont (13, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFA...
<p>In case you superclass a standard common control that already has its own font handle, use this approach: Just create a font using <code>CreateFont</code> or <code>CreateFontIndirect</code> and set it using <code>WM_SETFONT</code> message (in MFC and ATL there would be a corresponding <code>SetFont</code> function)....
27,289
<p>Does anyone have experience with <a href="http://llvm.org/" rel="nofollow noreferrer"><strong>LLVM</strong></a>, <a href="http://dragonegg.llvm.org/" rel="nofollow noreferrer"><strong>llvm-gcc</strong></a>, or <a href="http://clang.llvm.org/" rel="nofollow noreferrer"><strong>Clang</strong></a>?</p> <p>The whole id...
<p>I've had an initial play around with LLVM and working through <a href="http://llvm.org/docs/tutorial/LangImpl1.html" rel="noreferrer">this tutorial</a> left me very very excited about it's potential; the idea that I can use it to build a JIT into an app with relative ease has me stoked.</p> <p>I haven't gone deep e...
<p>You asked about tools and I would like to mention that there is LLVM plugin for Eclipse CDT (for Windows, Linux and Mac). It integrates LLVM nicely to IDE and the user does not need to know anything about LLVM. Pressing build button is enough to produce .bc and executable files (and intermediate files on the backgro...
20,825
<p>In git, it is up to each user to specify the correct author in their local git config file. When they push to a centralized bare repository, the commit messages on the repository will have the author names that they used when committing to their own repository.</p> <p>Is there a way enforce that a set of known aut...
<p>We use the following to prevent accidental unknown-author commits (for example when doing a fast commit from a customer's server or something). It should be placed in .git/hooks/pre-receive and made executable.</p> <pre><code>#!/usr/bin/env python # -*- coding: utf-8 -*- import subprocess from itertools import isli...
<p>What you could do is create a bunch of different user accounts, put them all in the same group and give that group write access to the repository. Then you should be able to write a simple incoming hook that checks if the user that executes the script is the same as the user in the changeset.</p> <p>I've never don...
14,256
<p>I'd like to indicate to the user of a web app that a long-running task is being performed. Once upon a time, this concept would have been communicated to the user by displaying an hourglass. Nowadays, it seems to be an animated spinning circle. (e.g., when you are loading a new tab in Firefox, or booting in Mac OS ...
<p>Google <strong>Ajax activity indicator</strong> to find lots of images and image generators (the "spinning" image itself is an animated GIF). </p> <p>Here is <a href="http://www.ajaxload.info/" rel="nofollow noreferrer">one link</a> to get you started.</p> <p>With the image in hand, use JQuery to toggle the visibi...
<p>I assume you meant something to indicate background activity during an Ajax call.</p> <p>I tend to have a CSS class which sets the background image to a little animated GIF, with appropriate padding and positioning (remember to turn background-repeat off), and then add and remove that class using a couple of JavaSc...
6,243
<p>There seem to be many ways to define <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="noreferrer">singletons</a> in Python. Is there a consensus opinion on Stack&nbsp;Overflow?</p>
<p>I don't really see the need, as a module with functions (and not a class) would serve well as a singleton. All its variables would be bound to the module, which could not be instantiated repeatedly anyway. </p> <p>If you do wish to use a class, there is no way of creating private classes or private constructors in ...
<p>In cases where you don't want the metaclass-based solution above, and you don't like the simple function decorator-based approach (e.g. because in that case static methods on the singleton class won't work), this compromise works:</p> <pre><code>class singleton(object): """Singleton decorator.""" def __init__(...
5,182
<p>I've got a relatively large .Net system that consists of a number of different applications. Rather than having lots of different app.config files, I would like to share a single configuration file between all the apps.</p> <p>I would also like to have one version when developing on my machine, one version for some...
<p>For large amounts of configuration which is needed by multiple applications, I would put this configuration into a central repository, e.g. a database, file in a common location.</p> <p>To use different versions of a configuration file for different environments, create a build configuration for each of the differe...
<p>You can also put the configuration settings into the machine.config to share them amongst multiple applications. This makes deployment more problematic though.</p>
18,758
<p>In C++ we acquiring a resource in a constructor and release it in a destructor.</p> <p>So when an exception rises in a middle of a function there will be no resource leak or locked mutexes or whatever.</p> <p>AFAIK java classes don't have destructors. So how does one do the resource management in Java.</p> <p>For...
<p>Yes you can and should put try/catch/finally block around your code. In C# there is a shorthand "using" statement, but in Java you are stuck with:</p> <pre><code>public int foo() { Resource f = new Resource(); try { DoSomething(f); } finally { f.Release(); } } </code></pre>
<p>Sorry to disappoint you but in Java we <strong>do</strong> use try\catch\finally blocks a lot. And with "a lot", I mean <strong>A LOT</strong>. I do sometimes wish that Java has the C# using block. Most of the time you won't need to free up resources as Java's garbage collector will take care of that.</p> <p>Howeve...
8,292
<p>I am stuck at properly aligning the generalization arrow between the classes. I could not make them appear as in the UML books.</p>
<p>Visio UML stencils are not very good and is very frustrating to work with them. Have a look at <a href="http://softwarestencils.com/uml/index.html" rel="nofollow noreferrer">http://softwarestencils.com/uml/index.html</a>, there are some very nice, free stencil updates for Visio UML 2.0. It takes very little time to ...
<p><a href="http://office.microsoft.com/en-us/visio/CH010266691033.aspx" rel="nofollow noreferrer">UML Model Diagrams - Visio - Microsoft Office Online</a></p> <p>One note. If you want UML diagramm looks like classic book examples you should use Rational Rose instead of Visio.</p>
42,765
<p>I am bit confused about ADO.Net Data Services.</p> <p>Is it just meant for creating RESTful web services? I know WCF started in the SOAP world but now I hear it has good support for REST. Same goes for ADO.Net data services where you can make it work in an RPC model if you cannot look at everything from a resource ...
<p>In my view ADO.Net data services is for creating restful services that are closely aligned with your domain model, that is the models themselves are published rather then say some form of DTO etc.</p> <p>Using it for RPC style services seems like a bad fit, though unfortunately even some very basic features like be...
<p>Actually, there are options to filter and skip to get the page like feature among others.</p> <p><a href="http://msdn.microsoft.com/en-us/library/cc668791.aspx" rel="nofollow noreferrer">See here:</a> </p>
7,149
<p>We are given an undirected graph G = (V, E) and two vertices s, t ∈ V . We consider simple paths between s and t. A path is simple if every vertex is visited at most once.</p> <p><del>Are the following in P or NP-complete?</del></p> <p>Does an efficient algorithm polynomial time exist for the following?</p> <p>"n...
<p>You're on the right track. I wrote <a href="https://stackoverflow.com/questions/308213/explaining-computational-complexity-theory#309507">another piece on NP-complete</a> to which I'm going to refer you for some of the details, but recall that basically you need to do two things to prove something NP-complete:</p> ...
<p>What I've come up with:</p> <ol> <li>Same as you said, use any applicable SPP algorithm.</li> <li>This is the longest path decision problem, which is NP-Hard even for unweighted graphs.</li> <li>For unweighted graphs, a linear number of applications would suffice to solve 2, so it is NP-Hard as well.</li> <li>You c...
47,257
<p>I have this code:</p> <pre><code>CCalcArchive::CCalcArchive() : m_calcMap() { } </code></pre> <p><code>m_calcMap</code> is defined as this:</p> <pre><code>typedef CTypedPtrMap&lt;CMapStringToPtr, CString, CCalculation*&gt; CCalcMap; CCalcMap&amp; m_calcMap; </code></pre> <p>When I compile in Visual Studio 2008, ...
<p>The <code>int</code> is coming from the fact that <code>CTypedPtrMap</code> has a constructor that takes an <code>int</code> argument that is defaulted to 10.</p> <p>The real problem that you're running into is that the <code>m_calcMap</code> reference initalization you have there is trying to default construct a t...
<p>It's a common MO for C++ compilers, when they can't figure out what a type is, to spit out an error message and assume that the user meant 'int' in order to be able to continue (...and generate even more error messages ;-)</p> <p>You do need to initialize all references in a class in your constructors, though.</p>
33,902
<p>In C#/VB.NET/.NET, which loop runs faster, <code>for</code> or <code>foreach</code>?</p> <p>Ever since I read that a <code>for</code> loop works faster than a <code>foreach</code> loop a <a href="https://learn.microsoft.com/previous-versions/dotnet/articles/ms973839(v=msdn.10)" rel="noreferrer">long time ago</a> I ...
<p>Patrick Smacchia <a href="http://codebetter.com/blogs/patricksmacchia/archive/2008/11/19/an-easy-and-efficient-way-to-improve-net-code-performances.aspx" rel="noreferrer">blogged about this</a> last month, with the following conclusions:</p> <blockquote> <ul> <li>for loops on List are a bit more than 2 times ch...
<p>I would suggest reading <a href="http://www.codeproject.com/KB/cs/foreach.aspx" rel="nofollow noreferrer">this</a> for a specific answer. The conclusion of the article is that using for loop is generally better and faster than the foreach loop.</p>
47,734
<p>Is there a way of reducing the amount and strength of Model support when slicing in Cura?</p> <p>Cleaning a model with large amounts of support can consume large amounts of time.</p>
<p>There's a lot that can be done to improve the removability of supports, and much of this is not widely known/published.</p> <p>One big wrong default in Cura that contributes to problems with support is <em>Limit Support Retractions</em>, which defaults to on. This causes heavy stringing between components of the sup...
<p>You could reduce the <code>Support Density</code>:</p> <blockquote> <p>A higher value results in better overhangs, but the supports are harder to remove.</p> </blockquote> <p>Furthermore read <a href="https://3dprinting.stackexchange.com/a/7991/">this answer</a> on question: &quot;<a href="https://3dprinting.stackex...
1,722
<p>I have a connection string being passed to a function, and I need to create a DbConnection based object (i.e. SQLConnection, OracleConnection, OLEDbConnection etc) based on this string.</p> <p>Is there any inbuilt functionality to do this, or any 3rd party libraries to assist. We are not necessarily building this ...
<pre><code>DbConnection GetConnection(string connStr) { string providerName = null; var csb = new DbConnectionStringBuilder { ConnectionString = connStr }; if (csb.ContainsKey(&quot;provider&quot;)) { providerName = csb[&quot;provider&...
<p>You should be able to parse out the Provider section and pass it into DbProviderFactories.GetFactory which will return a OdbcFactory, OleDbFactory or SqlClientFactory and let you then perform CreateConnection etc.</p> <p>I'm not sure how this would work with Oracle unless they provide an OracleDbFactory.</p>
22,431
<p>I have a query that runs super fast when executed in the sql editor (oracle): 1ms.</p> <p>The same query (as stored procedure) when executed by a DataSet-TableAdapter takes 2 seconds. I'm just retrieving 20rows.</p> <p>Since I'm using a TableAdapter, the return values are stored in a ref cursor.</p> <p>If I was f...
<p>Which data provider do you use? </p> <p>Do you reference System.Data.OracleClient or do you use odp.net (Oracle's data provider for connecting .NET apps with Oracle) or do you use devart's (formerly known as corelab) provider. </p> <p>I have good experiences with odp.net in combination with Oracle 9. You can downl...
<p>How long does it take when you use a datareader instead of a TableAdaptor? I would try the datareader. I have never encountered problems with the datareader. </p>
45,977
<p>I have two vista Business machines. I have IE 7 installed on both. On my first machine (Computer1) if I go to this site (<a href="http://www.quirksmode.org/js/detect.html" rel="nofollow noreferrer">http://www.quirksmode.org/js/detect.html</a>), it says I am using "Explorer 6 on Windows". If I use Computer2 with V...
<pre><code>Computer1: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; MS-RTC LM 8; .NET CLR 1.1.4322) Rick Kierner (11 minutes ago) Compute...
<p>This is just a guess, but the first string you posted explicitly has "MSIE 6.0" in the query string. If the site is lazy and doesn't properly parse the string, that could override the "MSIE 7.0" in the string earlier on, and give you a false result.</p>
19,138
<p>I was reading a book on templates and found the following piece of code:</p> <pre><code>template &lt;template &lt;class&gt; class CreationPolicy&gt; class WidgetManager : public CreationPolicy&lt;Widget&gt; { ... void DoSomething() { Gadget* pW = CreationPolicy&lt;Gadget&gt;().Create(); ... } }; </code></pre> <p>I...
<p>It means that <code>CreationPolicy</code> must also be a template, which accepts one type parameter. You can think of it as a little like the template equivalent of function pointers, or callbacks.</p> <p>As you can see in that example, <code>CreationPolicy</code> is used with an argument:</p> <pre><code>CreationP...
<p>It's a Template Template Parameter.</p> <p>See <a href="http://www.comeaucomputing.com/techtalk/templates/#ttp" rel="nofollow noreferrer">http://www.comeaucomputing.com/techtalk/templates/#ttp</a></p> <p>Basically CreationPolicy is the template parameter, with the constraint that it must be a templated class with ...
47,654
<p>I'm not sure why finding any frameworks or good example projects for developing windows application is so difficult. I'm sure that for web application framework, we have Castle Project or ASP.NET MVC that are very great stuffs and have many examples that follow the best practices like IoC, Caching, and etc. </p> <p...
<p>The <a href="http://msdn.microsoft.com/en-us/library/aa480450.aspx" rel="nofollow noreferrer">Smart Client</a> from MS uses MVP patterns.</p>
<p><a href="http://mvcsharp.org/Default.aspx" rel="nofollow noreferrer">MVC#</a></p>
45,831
<p>I have a div that contains several child elements, one of which is a flash movie.</p> <p>When rolling over this div, I want it to change style to indicate it is rolled over. My problem is that the <code>mouseover</code> and <code>mouseout</code> events don't always trigger, especially if the user moves the mouse ove...
<p>Change the <strong><em>wmode</em></strong> parameter of the object/embed tag to <strong><em>opaque</em></strong>.</p> <p>Your code should look something like the following.</p> <pre><code>&lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia .com/pub/shockwave/cabs/fl...
<p>The simple answer is you can't, given your constraints.</p> <p>The complex answer you seem to know already. The flash movie runs in a sandbox that doesn't trigger regular DOM events. If you want to trigger mouse events in the flash, you can't cover it up with DOM elements. If you don't have access to the source of ...
24,374
<p>This is driving me nuts. I am using some 3rd-party code in a Windows .lib that, in debug mode, is causing an error similar to the following:</p> <pre><code>Run-Time Check Failure #2 - Stack around the variable 'foo' was corrupted. </code></pre> <p>The error is thrown when either the object goes out of scope or is...
<p>OK, I tracked the problem down and it's a cracker, if anyone's interested. Basically, my .LIB, which exhibited the problem. had defined <code>_WIN32_WINNT</code> as <code>0x0501</code> (Windows 2000 and greater), but my EXE and the 3rd-party LIB had it defined as <code>0x0600</code> (Vista). Now, one of the header...
<p>Is your .lib file linked against the library's .lib? I assume from your example that you are including the header with the declaration of the destructor; without it, deleting such a type is allowed but can result in UB (in a bizarre manner contrary to the general rule that something must be defined before used). If ...
47,443
<p>I'm trying to run a process and do stuff with its input, output and error streams. The obvious way to do this is to use something like <code>select()</code>, but the only thing I can find in Java that does that is <code>Selector.select()</code>, which takes a <code>Channel</code>. It doesn't appear to be possible to...
<p>As you said, the solution <a href="https://stackoverflow.com/questions/60302/starting-a-process-with-inherited-stdinstdoutstderr-in-java-6#60578">outlined in this Answer</a> is the traditional way of reading both stdout and stderr from a Process. A thread-per-stream is the way to go, even though it is slightly annoy...
<p>You will indeed have to go the route of spawning a Thread for each stream you want to monitor. If your use case allows for combining both stdout and stderr of the process in question you need only one thread, otherwise two are needed.</p> <p>It took me quite some time to get it right in one of our projects where I ...
15,339
<p>I've written a small test application using the .Net FileSystemWatcher to keep an eye on a directory. When I copy a large-ish (a few Mb) file into that directory I get the following events listed (see screenshot - and ignore the Delete event to begin with).</p> <p><a href="http://robinwilson.homelinux.com/FSW.png" ...
<p>According to the <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx" rel="nofollow noreferrer">documentation</a> (see the first bullet point under <em>Events and Buffer Sizes</em>):</p> <blockquote> <p><strong>Common file system operations might raise more than one event.</strong> F...
<p>Usually the copying program is doing it in blocks, not entire file at once. I don't think you can do anything to avoid this, you will have to adopt your algorithms to deal with this.</p> <p>You can perform an attempt to open file with exclusive read rights, which should be granted to your program only when other pr...
20,737
<p>What does the option “convert to web application” do if I select it in visual studio? If I do convert my site to a web application what are the advantages? Can I go back?</p>
<p>Well, it converts your web site to a web application project. As for the advantages, here is some further reading:</p> <p>MSDN comparison -- <a href="http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5" rel="noreferrer">Comparing Web Site Projects and Web Application Projects</a></p> <p>Webcas...
<p>Visual studio 2010 will show this option Even if your project is started as a Project(Not website). This may be an Error from VS 2010.</p>
11,108
<p>i know this doesnt work but i dont know why, also how can i make it work?</p> <pre><code> &lt;% int result = referer.indexOf("smlMoverDetail.do"); %&gt; &lt;% if (result == -1){%&gt; &lt;%out.print("checking");%&gt; &lt;bean:define id="JOININGDATE" name="smlMoverDetailForm" property="empFDJoiningDate" type="j...
<p>Guess this was just a typing error, but the Equal in</p> <pre><code>&lt;logic:Equal name="result" value = "-1"&gt; </code></pre> <p>should actually be</p> <pre><code>&lt;logic:equal name="result" value = "-1"&gt; </code></pre> <p>The case could be the reason why the error is occurring.</p> <p>Of course, it ...
<p>It would help a lot if you say what the code actually does. I can see what you are trying to do, but what is actually happening? Any errors? Does it print out "checking"?</p>
25,697
<p>I am using Adobe Flex/Air here, but as far as I know this applies to all of JavaScript. I have come across this problem a few times, and there must be an easy solution out there!</p> <p>Suppose I have the following XML (using e4x):</p> <pre><code>var xml:XML = &lt;root&gt;&lt;example&gt;foo&lt;/example&gt;&lt;/roo...
<p>It seems you confuse variables for the values they contain. The assignment</p> <pre><code>node = textInput.text; </code></pre> <p>changes the value the <em>variable</em> <code>node</code> points to, it doesn't change anything with the object that <code>node</code> currently points to. To do what you want to do you...
<p>If you're trying to change the root element of a document, you don't really need to-- just throw out the existing document and replace it. Alternatively, just wrap your element in a more proper root element (you shouldn't be editing the root node anyway) and you'd be set.</p> <p>Of course, that doesn't answer your...
8,744
<p>Silly question, but I'm unable to figure out..</p> <p>I tried the following in Ruby:</p> <pre><code>irb(main):020:0&gt; JSON.load('[1,2,3]').class =&gt; Array </code></pre> <p>This seems to work. While neither</p> <pre><code>JSON.load('1').class </code></pre> <p>nor this </p> <pre><code>JSON.load('{1}').class ...
<p>I'd ask the guys who programmed the library. AFAIK, <code>1</code> isn't a valid JSON object, and neither is <code>{1}</code> but <code>1</code> is what the library itself generates for the fixnum 1.</p> <p>You'd need to do: <code>{"number" : 1}</code> to be valid json. The bug is that</p> <pre><code>a != JSON.par...
<p>As said only arrays and objects are allowed at the top level of JSON. </p> <p>Maybe wrapping your values in an array will solve your problem. </p> <pre><code>def set( value ); @data = [value].to_json; end def get; JSON.parse( @data )[0]; end </code></pre>
48,459
<p>I'm trying to set up an inheritance hierarchy similar to the following:</p> <pre><code>abstract class Vehicle { public string Name; public List&lt;Axle&gt; Axles; } class Motorcycle : Vehicle { } class Car : Vehicle { } abstract class Axle { public int Length; public void Turn(int numTurns) { ... } } cl...
<p>Use more generics</p> <pre><code>abstract class Vehicle&lt;T&gt; where T : Axle { public string Name; public List&lt;T&gt; Axles; } class Motorcycle : Vehicle&lt;MotorcycleAxle&gt; { } class Car : Vehicle&lt;CarAxle&gt; { } abstract class Axle { public int Length; public void Turn(int numTurns) { ... } }...
<p>2 options spring to mind. 1 is using generics:</p> <pre><code>abstract class Vehicle&lt;TAxle&gt; where TAxle : Axle { public List&lt;TAxle&gt; Axles; } </code></pre> <p>The second uses shadowing - and this assumes you have properties:</p> <pre><code>abstract class Vehicle { public IList&lt;Axle&gt; Axles {...
5,097
<p>I want to let users specify a date that may or may not include a day and month (but will have at least the year.) The problem is when it is stored as a datetime in the DB; the missing day/month will be saved as default values and I'll lose the original format and meaning of the date.</p> <p>My idea was to store the...
<p><a href="https://stackoverflow.com/questions/90246/how-would-i-store-a-date-that-can-be-partial-ie-just-the-year-maybe-the-month-t#90273">As proposed by Jhenzie</a>, create a bitmask to show which parts of the date have been specified. 1 = Year, 2 = Month, 4 = Day, 8 = Hour <em>(if you decide to get more specific)</...
<p>Is it really necessary to store it as a datetime at all ? If not stored it as a string 2008 or 2008-8 or 2008-8-1 - split the string on hyphens when you pull it out and you're able to establish how specific the original input was </p>
11,566
<p>I could do this myself given time but does anyone have a nice asp.net implementation of an a-z list coming from a sql query. I would like it to come in the form:</p> <p>A<br /> aardvark<br /> anagram<br /> apple</p> <p>B<br /> barry<br /> brown....</p> <p>That is with each entry being a link.</p>
<p>Whatever your sql is, just add <code>Upper(Substring([myfield],1,1)) AS Letter</code> to the select list. Then it's just a matter of showing the letter when it changes.</p> <p>Unfortunately, that may be easier said than done. ASP.Net doesn't have very good built-in support for control/break style output.</p>
<p>You need to select you column "name" and column "link". Order the list by "name" ascending. In your ASP.Net you need to check when the first letter of the String change... if it change write the first letter so you will get what you want.</p>
46,438
<p>this kind of follows on from another <a href="https://stackoverflow.com/questions/41290/file-access-strategy-in-a-multi-threaded-environment-web-app">question</a> of mine.</p> <p>Basically, once I have the code to access the file (will review the answers there in a minute) what would be the best way to <strong>test<...
<p>In .NET, <code>ThreadPool</code> threads won't return without setting up <code>ManualResetEvent</code>s or <code>AutoResetEvent</code>s. I find these overkill for a quick test method (not to mention kind of complicated to create, set, and manage). Background worker is a also a bit complex with the callbacks and such...
<p>Your idea should work fine. Basically you just want to spawn a bunch of threads, and make sure the ones writing the file take long enough to do it to actually make the readers wait. If all of your threads return without error, and without blocking forever, then the test succeeds.</p>
6,289
<p>I want to use pretty 3d button images on my website. However, currently the way this works is the text is part of the image.</p> <p>So, when I want to change the text (or make a new button) it's a 10 minute editing chore instead of a 20 second text change.</p> <p>I've seen a few websites that have a blank button w...
<p>Make the button a background image:</p> <pre><code>&lt;style&gt; div.button a { display: block; width: /* image width */; line-height: /* image height */; text-align: center; background: url(/* image uri */) no-repeat; } &lt;/style&gt; </code></pre>
<p>perhaps something like</p> <pre><code>a { width: something ; height: something; display: block; background: url('hi.png'); } </code></pre> <p>also, </p> <pre><code>input { background: url('hi.png'); } </code></pre> <p>is an alternative</p>
47,131
<p>What is the best way to backup VMWare Servers (1.0.x)? The virtual machines in question are our development environment, and run isololated from the main network (so you can't just copy data from virtual to real servers).</p> <p>The image files are normally in use and locked when the server is running, so it is di...
<p>VMWare server includes the command line tool "vmware-cmd", which can be used to perform virtually any operation that can be performed through the console.</p> <p>In this case you would simply add a "vmware-cmd susepend" to your script before starting your backup, and a "vmware-cmd start" after the backup is compl...
<p>If I recall correctly, VMWare Server has a scripting interface, available via Perl or COM. You might be able to use that to automatically pause the VMs before running the backup.</p> <p>If your backup software was shadow-copy aware, that might work, too.</p>
9,608
<p>In Flex, I have an xml document such as the following:</p> <pre><code>var xml:XML = &lt;root&gt;&lt;node&gt;value1&lt;/node&gt;&lt;node&gt;value2&lt;/node&gt;&lt;node&gt;value3&lt;/node&gt;&lt;/root&gt; </code></pre> <p>At runtime, I want to create a TextInput control for each node under root, and have the values ...
<h2>Windows</h2> <p>Some of the above values are easily available from the appropriate Win32 API, I just list them here for completeness. Others, however, need to be obtained from the Performance Data Helper library (PDH), which is a bit &quot;unintuitive&quot; and takes a lot of painful trial and error to get to work....
<p>I used this following code in my C++ project and it worked fine:</p> <pre><code>static HANDLE self; static int numProcessors; SYSTEM_INFO sysInfo; double percent; numProcessors = sysInfo.dwNumberOfProcessors; //Getting system times information FILETIME SysidleTime; FILETIME SyskernelTime; FILETIME SysuserTime; ...
8,875
<p>I have the following data</p> <p><a href="https://i.stack.imgur.com/KWyXz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KWyXz.png" alt="alt text"></a> </p> <p>How do I transform it (with SQL Server 2005) into the following format?</p> <p><a href="https://i.stack.imgur.com/1FVoX.png" rel="nofo...
<p>You can use the PIVOT() function</p> <pre><code>SELECT P.PRODUCT_ID, P.Czech, P.Other languages FROM TABLE AS T PIVOT ( AGGREGATE(LANGUAGE) FOR LANGUAGE IN ([Czech], ...) ) AS P </code></pre> <p>If you don't name the columns explicitly you are forced into do...
<p>Here's an idea... Use the Pivot Keyword... available in sql2005</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms177410.aspx" rel="nofollow noreferrer">Pivot and UnPivot</a></p> <p>Then after you have this working, outputting the column names as data values, embed this entire sql statemnt as the subquer...
49,789
<p>How can I tell if an assembly is in use by any process?</p>
<p>Here's an answer in PowerShell</p> <pre><code>if ( Get-Process | ? { $_.Modules | ? {$_.ModuleName -eq "AssemblyName.dll" } }) { "in use" } </code></pre>
<p>If you want to know if your application has loaded the assembly, you can inspect the AppDomain for loaded assemblies. If you want to know if the assembly is loaded by <em>any</em> process on the machine, it gets a little bit trickier. Which of the above do you need ?</p>
22,872
<ul> <li>VMware server 1.0.7 installed with vmware-package</li> <li>Debian GNU/Linux testing (lenny)</li> <li>Kernel 2.6.26-1-686</li> </ul> <p>There were several compile problems when trying to build the binary kernel modules from the vmware-server-kernel-source package made by vmware-package from the VMware server t...
<p>I've bludgeoned the kernel module into working with the 2.6.26 kernel. Here is <a href="http://pastebin.com/f200c4eb0" rel="nofollow noreferrer">my patch</a>.</p>
<p>Did you try searching the <a href="http://www.vmware.com/support/" rel="nofollow noreferrer">VMware support website</a>? This has been <a href="http://kb.vmware.com/selfservice/search.do?cmd=displayKC&amp;docType=kc&amp;externalId=150-150690xml4" rel="nofollow noreferrer">asked in the VMware forums</a>.</p>
13,640
<p>Having read an existing post on <a href="https://stackoverflow.com/questions/305605/weird-scope-issue-in-bat-file">stackoverflow</a> and done some reading around on the net. I thought it was time to post my question before I lost too much hair!</p> <p>I have the following code within a batch file which I double cli...
<p>Your immediate problem is that you're setting the variable to the value &lt; "Two"> which you can see here:</p> <pre><code>@echo off SETLOCAL ENABLEDELAYEDEXPANSION ::Observe variable is not defined SET test ::Define initial value SET test = "Two" ::Observe initial value is set SET test echo %test% echo..%test...
<p>The SET command takes everything after the equal sign through the last non-blank character. Your command...</p> <pre><code>SET test = "Two" </code></pre> <p>...is setting the variable test to the value "Two" with a leading blank and the quotes, not just the string Two.</p> <p>So when you test ...</p> <pre><code...
48,026
<p>I've always had a thing for C++/CLI. Maybe because not many developers use it... or just because it's different.</p> <p>Suppose Microsoft fully supported C++/CLI as they do VB.NET and C# (ie. LINQ, WPF, etc.). Would you use it? </p> <p>If not, why?</p>
<p>I <em>do</em> use it. Even with the relative lack of tool support, it still beats raw P/Invoke for dealing with Win32. </p> <p>As for LINQ, i don't really care to see too much more hacked into the C++ language. LINQ is usable enough as-is - if they're gonna enhance the compiler, they should work on C++ 0x support.....
<p>I use it to support legacy code as well as writing shims between managed and native code. Love that VS11 supports it much better</p>
21,675
<p>I've been working with Perl long enough that many of its idiosyncracies have become second nature to me. When new programmers join our group, they frequently have little to no experience with Perl, and it's usually my task to train them (to the extent necessary). I'd like to know what to focus on when training a p...
<p>Check out the tables of contents for my books. Both <a href="http://www.learning-perl.com" rel="nofollow noreferrer">Learning Perl</a> and <a href="http://www.intermediateperl.com" rel="nofollow noreferrer">Intermediate Perl</a> are designed to teach programmers the Perl language. We cover the 80% of Perl that most ...
<p>For C++/Java/C# coders two differences I stress very strongly up-front are that:</p> <p>No 1: In Perl almost everything has a meaning, just not always what you want. Good examples include:</p> <ul> <li>Variable names without sigils don't stop execution - they are interpreted as barewords</li> <li>Try to store an a...
17,120
<p>I just received an old 3D printer from one of my school teachers. I have no idea whatsoever as to which brand it is, no instruction manual attached to it, or any other info about it. </p> <p>How can I find some information about it? </p> <p>Some links would be very useful. Remember when giving advice that I know...
<p>Here are some further details on:</p> <ul> <li>The control board, and;</li> <li>The stepper motors</li> </ul> <h2>Control board</h2> <p>The electronics board has this marking:</p> <p><a href="https://i.stack.imgur.com/Ui1WV.png" rel="nofollow noreferrer" title="EJE Electronics Gubbel Engineering"><img src="https...
<p>As far as I can see on the pictures - the main board shall be capable to upload Marlin software and run smoothly.</p> <p>If you connect power and PC/Mac over the USB connection, then using <a href="http://www.pronterface.com" rel="nofollow noreferrer">Pronterface</a> you can validate mechanical movements of the pri...
945
<p>I've inherited an ASP.NET application built on top of webforms, and the application suffers from having all of its business logic embedded in the codebehind. As a result, this application can't be unit tested.</p> <p>I want to break out the functionality of every form into an MVC style, but I've found that ASP.NET ...
<p>Is it not easier to re-write this using asp.net mvc?</p>
<p>Well the nature of the POSTback is dictating your state changes, so you should react on that. Any framework you use would work pretty much the same way, it'll rebuild/bind the state with each request. You should look into savind the state (read data) into your user's session.</p>
46,497
<p>Sorry, I couldn't figure out a good way to phrase my real question.</p> <p>I run a high-traffic ASP.NET site on a 64-bit machine. I have IIS running in 32-bit mode, however, due to some legacy components of the app. I am running this particular web app inside an application pool that has the web garden option on ...
<ul> <li><a href="http://msdn.microsoft.com/en-us/library/ms979205.aspx" rel="nofollow noreferrer">(MSDN) How To: Use CLR Profiler</a></li> <li><a href="http://msdn.microsoft.com/en-us/magazine/cc163528.aspx" rel="nofollow noreferrer">(MSDN Magazine) Investigating Memory Issues</a></li> </ul>
<p>Dude - not sure if this helps, but maybe try this.</p> <ol> <li>Copy c:\windows\microsoft.net\framework\v2.0.50727\sos.dll to the same directory where windbg is installed to (eg. c:\program files\Debugging Tools for Windows\ ). Why? make it easy to load the sos file</li> <li>run windbg</li> <li>load the memory dump...
21,549
<p>I have a site, and it will be sold to different clients but for maintenance reasons, we will be keeping one codebase. So this means that this one codebase will have to be dynamic enough to have different styles and so forth, depending on the client.</p> <p>The domain would be a subdomain-type system, so: projectnam...
<p>You can use different master pages to accomplish this.</p> <p>Code a default against one master page (or set of masters) and then change the master page programmatically at runtime based on the host domain.</p> <p>To do this you must set the page's MasterPageFile property during the OnPreInit phase of the page's l...
<pre><code>/* Do you have a folder in "Themes" or "APP_Themes" called Savillis? */ </code></pre> <p>When you designate a Theme for a page, all stylesheets in that theme folder will be loaded. They will be loaded alphabetically, so watch the order.</p> <p>On a page level, you can set the theme in the Page directive (a...
27,891
<p>I'm trying to build a video recorder without jailbreaking my iPhone (i've a Developer license). I began using PhotoLibrary private framework, but i can only reach 2ftp (too slow). Cycoder app have a fps of 15, i think it uses a different approach. I tried to create a bitmap from the previewView of the CameraControll...
<p>Here is the code:</p> <pre><code>image = [window _createCGImageRefRepresentationInFrame:rectToCapture]; </code></pre> <p>Marco</p>
<p>If you're intending to ever release your app on the App Store, using a private framework will ensure that it will be rejected. Video, using the SDK, simply isn't supported.</p>
43,024
<p>The following is a simplified version of what I'm trying to do, because I'm sure you don't want to wade through an entire set of structs and function prototypes for a particle system.</p> <pre><code>float const materials[24][4][4] = {{{...}}}; typedef struct EmitterStruct { float *material[4][4]; } Emitter; typede...
<p>I'm answering to your updated question (which appeared in your own answer). First your code:</p> <pre><code>float const materials[24][4][4] = {{{...}}}; typedef struct EmitterStruct { float *material; } Emitter; /*Use just a plain pointer*/ typedef struct ParticleStruct { float material[4][4]; } Particle; Emitter ...
<p>Of course, the second I ask for help, I figure out exactly what I needed to do.</p> <pre><code>float const materials[24][4][4] = {{{...}}}; typedef struct EmitterStruct { float *material; } Emitter; /*Use just a plain pointer*/ typedef struct ParticleStruct { float material[4][4]; } Particle; Emitter *myEmitter; ...
45,813
<p>I bought a new printer, and unfortunately the left nut for the lead screw isn't tapped.</p> <p>Does anyone know the thread size, w.r.t. both pitch and lead, of the lead screws?</p>
<p>I have the Anet A8, I confirm the threads are Tr8x8(p2). This is explained as "Tr" for trapezoidal thread followed by the nominal diameter in mm. The digits after the "x" denotes the lead of the screw (how much does the nut advance per revolution). The value between the brackets "p2" denotes the pitch. This means th...
<p>The pitch no matter the screw is the distance between the threads. The lead can be different based on a one or two start threads.</p>
848
<p>I have a Windows GUI application that's using the Qt framework (currently version 3.3.5, might change to Qt4).</p> <p>I want to combine other Windows GUI applications in the main application. I can't use the widgets directly in the main application due to several constrains which I can't control. The final layout s...
<p>Here is how some Windows applications deal with this problem:</p> <p>If the widget application <em>must</em> be in it's own EXE, then you could use OLE document object embedding (I think that's the right term). This is the same technology that is used to embed a live Excel document into a Word document. Basically, ...
<p>HWNDs are the most basic building blocks of Win32 GUIs. Anything beyond that would need cooperation of the hosted application. e.g. by sending the parent HWND to the hosted app.</p>
40,285
<p>I wanted to write a Visual Studio Macro or something similar which can fetch function name and insert into preset location in the error report part. It's clearer if you look at the example</p> <pre><code>Class SampleClass { public void FunctionA() { try { //Do some work here ...
<p>Take a look at System.Diagnostics.StackTrace and then you can create just one log call getting the function from the stack. </p>
<p>Look at <a href="http://www.postsharp.org/about/features/" rel="nofollow noreferrer">PostSharp</a>. It allows you do this with very easy way and much more.</p> <p>There is samples with loging too.</p>
31,243
<p>What is the best method for determining if a users browser has cookies enabled in ASP.NET</p>
<p>Set a cookie, force a redirect to some checking page and check the cookie.</p> <p>Or set a cookie on every pageload, if it's not already set. For instance, I assume this is to check if cookies are supported to display a message when they try to login that they need to enable cookies. Set your login cookie to some d...
<p>this is the best way </p> <p>taken from <a href="http://www.eggheadcafe.com/community/aspnet/7/42769/cookies-enabled-or-not-.aspx" rel="nofollow noreferrer">http://www.eggheadcafe.com/community/aspnet/7/42769/cookies-enabled-or-not-.aspx</a></p> <pre><code>function cc() { /* check for a cookie */ if (document....
25,811