instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>In SQL Server 2005, is there a way of deleting rows and being told how many were <strong>actually</strong> deleted? </p> <p>I could do a <code>select count(*)</code> with the same conditions, but I need this to be utterly trustworthy. </p> <p>My first guess was to use the <code>@@ROWCOUNT</code> variables - but t...
<p>Have you tried <code>SET NOCOUNT OFF</code>?</p>
<p>Create temp table with one column, id.</p> <p>Insert into temp table selecting the ids you want to delete. That gives you your count.</p> <p>Delete from your table where id in (select id from temp table)</p>
20,979
<p>I'm working on an ASP .NET 2.0 site which uses a Web Application project file, and therefore compiles to a dll rather than deploying the source code as you do with the older style Web Site projects.</p> <p>The site works fine on my test server (Windows Server 2003 R2, IIS6) when it runs in the root of a website. Ho...
<p>Turns out the problem was related to inheriting the config settings of the site above mine in the virtual hierarchy.</p> <p>That site uses a custom profile whose properties are defined under system.web, profile, properties in the config file. The type of one of the properties was specified in the "Namespace.ClassNa...
<pre><code>namespace Rectangle { class Name { int length1; int width1; int sum; Console.Write("Enter the length: "); length = int.Parse(Console.ReadLine()); Console.Write("Enter the width: "); width = int.Parse(Console.ReadLine()); sum =...
46,390
<p>Is there any way to access the file object used by a CSV writer/reader object after it has been instantiated? I openned up the csv module, and it appears it's contest are builtin. I also tried setting the file object as a property but I get the following error:</p> <pre><code>AttributeError: '_csv.writer' object ...
<p><code>csv.writer</code> is a "builtin" function. That is, it is written in compiled C code rather than Python. So its internal variables can't be accessed from Python code.</p> <p>That being said, I'm not sure <strong>why</strong> you would need to inspect the csv.writer object to find out the file object. That ...
<p>From what I can tell, there is no straightforward way to get the file object back out once you put it into a csv object. My approach would probably be to subclass the csv writer and readers you're using so they can carry that data around with them. Of course, this assumes the ability to be able to directly access ...
24,176
<p>Say you get a recordset like the following:</p> <pre><code>| ID | Foo | Bar | Red | |-----|------|------|------| | 1 | 100 | NULL | NULL | | 1 | NULL | 200 | NULL | | 1 | NULL | NULL | 300 | | 2 | 400 | NULL | NULL | | ... | ... | ... | ... | -- etc. </code></pre> <p>And you want:</p> <pre><cod...
<p>The query you had above works just fine for VARCHAR fields as it did for INT fields. The problem with your query though is that if you have two rows with the same ID, and both of those rows had something in the "Foo" column, then only the one with the highest value (both for INT and VARCHAR) will be displayed.</p>
<p>The query you had above works just fine for VARCHAR fields as it did for INT fields. The problem with your query though is that if you have two rows with the same ID, and both of those rows had something in the "Foo" column, then only the one with the highest value (both for INT and VARCHAR) will be displayed.</p>
31,046
<p>I have this gigantic ugly string:</p> <pre class="lang-none prettyprint-override"><code>J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM J0000010: Project name: E:\foo.pf J0000011: Job name: MBiek Direct Mail Test J0000020: Document 1 - Completed successfully </code></pre> <p>I'm trying to extract piec...
<p>Make <code>.*</code> non-greedy by adding '<code>?</code>' after it:</p> <pre><code>Project name:\s+(.*?)\s+J[0-9]{7}: </code></pre>
<p>(Project name:\s+[A-Z]:(?:\\w+)+.[a-zA-Z]+\s+J[0-9]{7})(?=:)</p> <p>This will work for you.</p> <p>Adding (?:\\w+)+.[a-zA-Z]+ will be more restrictive instead of .*</p>
4,246
<p>I would like to allow the logged user to edit MediaWiki/Common.css without adding them to the sysop group.</p> <p>I understand that this will allow user to change it to harful ways but it is a closed wiki so that is not a problem.</p> <p>Any solution is acceptable even changing php code :)</p>
<p>Create a new group, add give it "editinterface" privilege. In LocalSettings.php it's done like this:</p> <pre><code>$wgGroupPermissions['mynewgroup']['editinterface'] = true; </code></pre> <p>Then add the user to you new group.</p> <p>Or if you want to give that right to all logged-in users, do it like this:</p> ...
<p>Probably safer to use;</p> <pre><code>$wgAllowUserCss = true; </code></pre> <p><a href="https://www.mediawiki.org/wiki/Manual:$wgAllowUserCss" rel="nofollow">See Mediawiki Manual</a> for the complete details.</p> <p><em>"When enabled, users are able to make personalised customisations over and above the normal ch...
19,556
<p>I have an animation which moves some views around. When this animation completes I want the window to recalculate the keyview loop. My code is simmilar to the follow mock code:</p> <pre><code>[NSAnimationContext beginGrouping]; [newView setAlpha: 0.0]; //hide newView [self addSubView:newView]; //position t...
<p>Something that's not so obvious, or at least wasn't to me, is that there are two animations going on when you do a <code>setFrame:</code>, with keys <code>frameSize</code> and <code>frameOrigin</code>.</p> <p>Depending on what your original and final frames are you may need to register yourself as a delegate for on...
<p>Check out my post here: <a href="https://stackoverflow.com/questions/7788998/how-would-i-do-this-ios-animation-on-osx/7880009#7880009">How would I do this iOS animation on OSX?</a></p> <p>I wrote a class that handles this for you, using blocks. Hopefully your target allows blocks! :)</p>
42,830
<p>I am working on a project to enhance our production debugging capabilities. Our goal is to reliably produce a minidump on any unhandled exception, whether the exception is managed or unmanaged, and whether it occurs on a managed or unmanaged thread.</p> <p>We use the excellent <a href="http://www.debuginfo.com/too...
<p>Windows Forms has a built-in exception handler that does the following by default:</p> <ul> <li>Catches an unhandled managed exception when: <ul> <li>no debugger attached, and</li> <li>exception occurs during window message processing, and</li> <li>jitDebugging = false in App.Config.</li> </ul></li> <li>Shows dial...
<p>SetUnhandledExceptionFilter installs a handler that is invoked when a Win32-excpetion reaches the top of a threads callstack without being handled.</p> <p>In many language runtimes including managed, language exceptions are implemented using Win32 exceptions. But, the managed runtime will have a top level __try __c...
28,875
<p>I have a page with a Google Maps mashup that has pushpins that are color-coded by day (Monday, Tuesday, etc.) The IFrame containing the map is dynamically sized, so it gets resized when the browser window is resized. </p> <p>I'd like to put a legend in the corner of the map window that tells the user what each colo...
<p>You can add your own Custom Control and use it as a legend.</p> <p>This code will add a box 150w x 100h (Gray Border/ with White Background) and the words "Hello World" inside of it. You swap out the text for any HTML you would like in the legend. This will stay Anchored to the Top Right (G_ANCHOR_TOP_RIGHT) 10px d...
<p>I would use HTML like the following:</p> <pre><code>&lt;div id="wrapper"&gt; &lt;div id="map" style="width:400px;height:400px;"&gt;&lt;/div&gt; &lt;div id="legend"&gt; ... marker descriptions in here ... &lt;/div&gt; &lt;/div&gt; </code></pre> <p>You can then style this to keep the legend in the bottom right...
5,712
<p>I have a question about <a href="https://stackoverflow.com/questions/372812/how-do-get-some-of-the-object-from-a-list-without-linq">this question</a>. I posted a reply there but since it's been marked as answered, I don't think I'll get a response to my post there.</p> <blockquote> <p>I am running C# framework 2...
<p>If your requirement is to find things quickly in an arbitrary collection, then perhaps a list isn't the best data structure for the job. :)</p>
<p>If you're only looking for the first match, then the Find method will do the job. It won't loop through the entire list, rather it will return the first occurrence of the object. However, if you want to find all of them, how exactly do you expect to search through only a subset of the data if it isn't sorted?</p>
49,053
<p>To lay the groundwork for this question, I'm going to state that I'm getting my definitions for MVC, MVP, and Passive View from the following:</p> <p><a href="http://en.wikipedia.org/wiki/Model-view-controller" rel="nofollow noreferrer">Model View Controller (MVC)</a><BR> <a href="http://en.wikipedia.org/wiki/Model...
<p>Any code of any complexity has many places where different patterns may apply. MVC is prominent in the Cocoa documents because it explains the relationships between your functional code (the model), your UI code or IB design (the view), and the Cocoa services that tie them together (the controller). That's worth emp...
<p>Uh-oh. MVC = the most misquoted pattern ever. I have read at least 5 different definitions of it.</p> <p>You may want to read this article by <a href="http://martinfowler.com/eaaDev/uiArchs.html" rel="nofollow noreferrer">Martin Fowler</a> </p>
46,068
<p>I am trying to do some very simple form validation checking for null or '' (empty) using a conditional, but when I submit my form with ALL BLANK FIELDS, it does the latter section of my code.</p> <p>And when I fill out all of my fields it does that other part. So when they are blank, tell the user, which is the fir...
<p>In general it should be sufficient to check for empty string (such as f_name &lt;> ""). I however usually do this with a trim and len. len(trim(f_name)) > 0. It takes care of all spaces. You should reconsider your parenthesis since they are not necessary. if len(trim(f_name)) > 0 or ... then</p>
<ol> <li>you do not need all the parentheses</li> <li>if fname et al are the textboxes, you need fname.Text instead</li> </ol>
47,900
<p>Can anyone please help me to get the keycodes for the arrow keys in c# .net keypress events? Can you help me to get out of this check point?</p> <p>best regards, Arun.</p>
<p>Do you mean the KeyUp event? KeyPress doesn't get fired for Arrows and the event args doesn't have a KeyCode property but for Arrow Keys in keyUp event they are:</p> <p>Keys.Up, Keys.Down, Keys.Left, Keys.right</p>
<p>You can look up the keycodes here: <a href="http://msdn.microsoft.com/en-in/library/aa243025(v=vs.60).aspx" rel="nofollow">http://msdn.microsoft.com/en-in/library/aa243025(v=vs.60).aspx</a></p> <p>It states:</p> <pre> vbKeyLeft 37 LEFT ARROW key vbKeyUp 38 UP ARROW key vbKeyRight 39 RIGHT ARROW key vbKey...
42,767
<p>Is there any way I can push a new record to SqlDataReader after i pull a table down? I have this piece of trash code that I need to modify, and this seems like the easiest way to do what I need. I understand that this should not be done, and if you have to do it there is something seriously wrong with your logic, bu...
<p>SqlDataReaders are forward read only so I doubt you can add a record in (regardless of whether you have pulled the whole table down). In fact anything that inherits DbDataReader is forward read only.</p> <p>I'm guessing you need to do some manipulation with the records. Maybe what you can do instead is use the SqlD...
<p>You need to expand your question a bit, </p> <p>If, for example, you need to walk through a million records and update a field on the same table while walking through the data. </p> <p>You can create a second SqlConnection to your db and execute update statements on the table (prone to locking issues), or better s...
21,907
<p>As title. </p> <p>ruby test/functionals/whatevertest.rb doesn't work, that requires me to replace all <code>require 'test_helper'</code> to <code>require File.dirname(__FILE__) + '/../test_helper'</code>. For some reason most of those test templates have such issue, so I rather to see if there is a hack I could get...
<p>The following answer is based on: <a href="https://stackoverflow.com/q/1506780/664833">How to run single test from rails test suite?</a> (stackoverflow)</p> <p>But very briefly, here's the answer:</p> <pre><code>ruby -I test test/functional/whatevertest.rb </code></pre> <p>For a <em>specific</em> <code>functional...
<p>most conventional method for 2 and 3 is:</p> <p>ruby -I test test/functional/your_test_file.rb</p>
34,561
<p>I'm trying to have text spans pop up on a hover pseudo-class for different lines in a menu (list items). I can have the pop-ups occupy the same space in the div if the menu/list is horizontal, but a vertical list places the popups at the same vertical height as the "parent" list/menu item.</p> <p>Here is the relev...
<p>My my, that's a whole lot of HTML and css for a simple task. I wont try to read through it all, but just give you your answer</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;a href=""&gt;item 1&lt;span&gt;this is popup1.&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;item 2&lt;span&gt;This is popup 2's t...
<p>So you want all the different spans to be appeared in the same place? You set the relative position in A, which make the span appear "relative" to it.</p> <p>Fix:</p> <ul> <li>Remove relative positioning in anchor. // Though, it doesn't seem to matter in FF for some reason</li> <li>Set positioning(top, lef...
49,447
<p>I have been working on some legacy C++ code that uses variable length structures (TAPI), where the structure size will depend on variable length strings. The structures are allocated by casting array <code>new</code> thus:</p> <pre class="lang-cpp prettyprint-override"><code>STRUCT* pStruct = (STRUCT*)new BYTE[size...
<p>Technically I believe it could cause a problem with mismatched allocators, though in practice I don't know of any compiler that would not do the right thing with this example.</p> <p>More importantly if <code>STRUCT</code> where to have (or ever be given) a destructor then it would invoke the destructor without hav...
<p>Rob Walker <a href="https://stackoverflow.com/questions/73134/will-this-c-code-cause-a-memory-leak-casting-vector-new#73163">reply</a> is good.</p> <p>Just small addition, if you don't have any constructor or/and distructors, so you basically need allocate and free a chunk of raw memory, consider using free/malloc ...
9,883
<p>Is there any way to force a listview control to treat all clicks as though they were done through the Control key?</p> <p>I need to replicate the functionality of using the control key (selecting an item sets and unsets its selection status) in order to allow the user to easily select multiple items at the same tim...
<p>It's not the standard behaviour of the ListView control, even when MultiSelect is set to true. </p> <p>If you wanted to create your own custom control you would need to do the following:</p> <ol> <li>Derive a control from ListView</li> <li>add a handler to the "Selected" event. </li> <li>In the "OnSelected", mai...
<p>The Ctrl+Click behavior is as implemented by the browser, and has little to do with the actual .NET Control. The result you're trying to achieve can be acquired with a lot of additional JavaScript - the easiest way would probably be to build a JavaScript control from default that works this way, rather than trying t...
10,947
<p>Say I have the following Objective-C class:</p> <pre><code>@interface Foo { int someNumber; NSString *someString; } </code></pre> <p>and for reasons I won't get into here, I want to use KVC to update, in a generic fashion, the values for those variables:</p> <pre><code>[f setValue:object forKey:@"someNu...
<p>You should do the conversion yourself with a number formatter, it gives you finer control than anything that the framework might consider to be appropriate. It is also, probably, not a good idea to use a single instance of an object to update the values for your ivars. More appropriately, you could perform your upd...
<p>I'm with wisequark on this one. I think of setValue:forKey: as equivalent to calling the setter directly. If you had a method:</p> <pre><code>- (void)setSomeValue:(NSInteger)aValue </code></pre> <p>You wouldn't expect to be able to pass in an NSString and hope the method can figure it out.</p> <p>Put another way,...
38,352
<p>I am currently loading a lightbox style popup that loads it's HTML from an XHR call. This content is then displayed in a 'modal' popup using <code>element.innerHTML = content</code> This works like a charm.</p> <p>In another section of this website I use a Flickr 'badge' (<a href="http://www.elliotswan.com/2006/08/...
<p>In general, script tags aren't executed when using innerHTML. In your case, this is good, because the <code>document.write</code> call would wipe out everything that's already in the page. However, that leaves you without whatever HTML document.write was supposed to add.</p> <p>jQuery's HTML manipulation methods wi...
<p>Can I get some clarification first to make sure I get the problem?</p> <p><code>document.write</code> calls will add content to the markup at the point in the markup at which they occur. For example if you include <code>document.write</code> calls in a function but call the function elsewhere, the <code>document.wr...
7,751
<p>I am getting this linker error.</p> <blockquote> <p><strong>mfcs80.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj)</strong></p> </blockquote> <p>Please tell me the correct way of eliminating this bug. I read solution on microsoft support site about this bug but it didnt ...
<p>I had the same error message, but none of the answers here solved it for me. So if you Encounter that Problem when creating a DLL Project that uses MFC, it can be resolved by entering the following line:</p> <pre><code>extern "C" { int _afxForceUSRDLL; } </code></pre> <p>to the cpp file where <code>DllMain</code...
<p>There is a common theme running through some of the answers here.</p> <p>Avishek Bose:-</p> <blockquote> <p>Declare the mfc80ud.lib and mfcs80ud.lib in the Additional Dependancies field in the Project Properties -> Linker Tab -> Input of Visual Studio to fix the issue.</p> </blockquote> <p>vmb100:-</p> <bl...
44,653
<p>Is there a way to edit the log message of a certain revision in Subversion? I accidentally wrote the wrong filename in my commit message which could be confusing later.</p> <p>I've seen <em><a href="https://stackoverflow.com/questions/179123/how-do-i-edit-an-incorrect-commit-message-in-git">How do I edit an incorre...
<p>Essentially you have to have admin rights (directly or indirectly) to the repository to do this. You can either configure the repository to allow all users to do this, or you can modify the log message directly on the server. </p> <p>See <a href="http://subversion.apache.org/faq.html#change-log-msg" rel="noreferre...
<p>I found a nice implementation of the server side pre-rev-prop-change hook at the svnforum: <a href="https://www.svnforum.org/forum/opensource-subversion-forums/scripts-contributions/8571-pre-revprop-change-shell-script-allows-commiters-to-change-own-log-within-x-hours" rel="nofollow noreferrer">https://www.svnforum....
39,112
<p>In an OLAP database I work with there is a 'Location' hierarchy consisting of the levels Company, Region, Area, Site, Room, Till. For a particular company I need to write some MDX that lists all regions, areas and sites (but not any levels below Site). Currently I am achieving this with the following MDX</p> <pre><...
<pre><code>DESCENDANTS([Location].[Test Company],[Location].[Site], SELF_AND_BEFORE) </code></pre>
<p>The command you want is DESCENDANTS. Keep the 'family tree' analogy in mind, and you can see that this will list the descendants of a member, down as far as you want. </p> <p>You can specify the 'distance' (in levels) from the chosen member, 3 in your case.</p> <p>There are a few weird options you can specify with...
17,820
<p>We need a mailing list package similar to <a href="http://www.gnu.org/software/mailman/index.html" rel="nofollow noreferrer">Python Mailman</a>. I'd use Mailman except for one thing: we want to link the subscriber list to a table in our MySQL database. We want people to be able to opt in/out and control delivery opt...
<p>There is a MySQL member adapter in</p> <p><a href="https://sourceforge.net/tracker/?func=detail&amp;atid=300103&amp;aid=839386&amp;group_id=103" rel="nofollow noreferrer">https://sourceforge.net/tracker/?func=detail&amp;atid=300103&amp;aid=839386&amp;group_id=103</a></p> <p>I haven't tried it, and from the readme,...
<p>Do either of these posts answer the question?</p> <p><a href="https://stackoverflow.com/questions/66677/simplelightweight-alternative-to-gnu-mailman">Simple/lightweight alternative to GNU Mailman?</a></p> <p><a href="https://stackoverflow.com/questions/203453/does-listserv-have-an-api">Does LISTSERV have an API?</...
31,908
<p>I need to get the value of the 'test' attribute in the xsl:when tag, and the 'name' attribute in the xsl:call-template tag. This xpath gets me pretty close: </p> <pre><code>..../xsl:template/xsl:choose/xsl:when </code></pre> <p>But that just returns the 'when' elements, not the exact attribute values I need.</p...
<p>do you want <code>.../xsl:template/xsl:choose/xsl:when/@test</code></p> <p>If you want to actually get the value 'First Name' out of the test attribute, you're out of luck -- the content inside the attribute is just a string, and not a piece of xml, so you can't xpath it. If you need to get that, you must use strin...
<p>do you want <code>.../xsl:template/xsl:choose/xsl:when/@test</code></p> <p>If you want to actually get the value 'First Name' out of the test attribute, you're out of luck -- the content inside the attribute is just a string, and not a piece of xml, so you can't xpath it. If you need to get that, you must use strin...
12,297
<p>I know there is a way to add a IE control, how do you add a chrome control...? Is it even possible right now?</p> <p>I'm need this because of the fast javascript VM found in chrome.</p>
<p>I searched around and I don't think Google Chrome registers itself as a Windows COM+ component. I think you're out of luck.</p>
<p>IE control is actually ActiveX component - so it can be wrapped in .Net component. It is not real IE, it's mainly only its rendering engine (HTML+CSS+JS) plus web client (HTTP and some more protocols) Control itself has no menu, bookmarks etc. Chrome is full featured browser. So you should be asking for WebKit (rend...
12,286
<p>Why must class members declared as <code>const</code> be initialized in the constructor initializer list rather than in the constructor body?</p> <p>What is the difference between the two?</p>
<p>In C++, an object is considered fully initialised when execution enters the body of the constructor.</p> <p>You said: </p> <blockquote> <p>"i wanted to know why const must be intialized in constructor initializer list rather than in it's body ?."</p> </blockquote> <p>What you are missing is that <strong>ini...
<p>Because constant variables and references must be initialized at time of declaration i.e before use. But Constructors will assign value to a varaible not initailize the variable therefore you must use initailizier list for constant and references</p>
46,301
<p>I have a string that is HTML encoded: </p> <pre><code>'''&amp;lt;img class=&amp;quot;size-medium wp-image-113&amp;quot;\ style=&amp;quot;margin-left: 15px;&amp;quot; title=&amp;quot;su1&amp;quot;\ src=&amp;quot;http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg&amp;quot;\ alt=&amp;quot;&amp;quot; width=&...
<p>Given the Django use case, there are two answers to this. Here is its <code>django.utils.html.escape</code> function, for reference:</p> <pre><code>def escape(html): """Returns the given HTML with ampersands, quotes and carets encoded.""" return mark_safe(force_unicode(html).replace('&amp;', '&amp;amp;').r...
<p>Below is a python function that uses module <code>htmlentitydefs</code>. It is not perfect. The version of <code>htmlentitydefs</code> that I have is incomplete and it assumes that all entities decode to one codepoint which is wrong for entities like <code>&amp;NotEqualTilde;</code>:</p> <p><a href="http://www.w3...
34,680
<p>This is a somewhat bizarre question. My objectives are to understand the language design decision and to identify the possibilities of reflection in C++.</p> <ol> <li><p>Why C++ language committee did not go towards implementing reflection in the language? Is reflection too difficult in a language that does not run...
<p>There are several problems with reflection in C++.</p> <ul> <li><p>It's a lot of work to add, and the C++ committee is fairly conservative, and don't spend time on radical new features unless they're sure it'll pay off. (A suggestion for adding a module system similar to .NET assemblies has been made, and while ...
<p>Reflection in C++ , I believe is crucially important if C++ is to be used as a language for Database Access, Web session handling/http and GUI development. The lack of reflection prevents ORMs (like Hibernate or LINQ), XML and JSON parsers that instancinate classes, Data serialization and many other thigns (wher...
46,851
<p>Is there a way to execute a query(containing built in DB function) using PreparedStatement?</p> <p>Example: insert into foo (location) values (pointfromtext('12.56666 13.67777',4130)) Here pointfromtext is a built in function.</p>
<p>By what I've seen, the first parameter on pointfromtext function is a string, and the second a number. So, try the following:</p> <pre><code>PreparedStatement preparedStatement = getConnection().prepareStatement("insert into map_address (location) values(pointfromtext('POINT(' || ? || ' ' || ? || ')',4130))"); prep...
<p>The scope of a PreparedStatement object is exactly to execute queries. If the query contains built in DB function is ok, and everything should work if the same query works outside the PreparedStatement.</p> <p>As Thilo said, test your query form SQL command line, or with the SQL graphical tool that you usually use....
38,646
<p>Looking for suggestions on file system management tools. We have several terabytes of images, pdfs, excel sheets, etc.</p> <p>We're looking at some sort of software that will help us to manage, archive, etc the images. </p> <p>We don't store all the files information in a database but some are and we were hoping t...
<p>I have always seen these guys in the trade magazines. <a href="http://www.dtsearch.com/" rel="nofollow noreferrer">http://www.dtsearch.com/</a> I believe they've been around long before even Google. Not sure if this is what you're looking for.</p>
<p>If some of the data is saved on disks perhaps a search application is more appropriate. You can use google, microsoft search or similar program.</p>
14,201
<p>First of all, some background.</p> <p>We have an order processing system, where staff enter billing data about orders in an app that stores it in a sql server 2000 database. This database isn't the real billing system: it's just a holding location so that the records can be run into a mainframe system via a nightl...
<p>First off, you can get rid of the second LEFT JOIN.</p> <p>Your WHERE was removing out any matches, anyhow... For instance, if S.OrderID was 1 and there was a R.OrderID with a value of 1, the IS NULL enforcement in the WHERE wouldn't allow it. So it'll only return records where s.OrderID IS NULL, if I'm reading it ...
<p><strong>Update:</strong><br> In case it wasn't already obvious, I made a mistake in the code for the original question. That's now fixed, but unfortunately it means some of the better responses here are actually going the completely wrong direction.</p> <p>I also have some statistics updates: I can make the query...
34,329
<p>Any ideas how to stop the system bell from sounding when <kbd>CTRL</kbd>-<kbd>A</kbd> is used to select text in a Winforms application?</p> <p>Here's the problem. Create a Winforms project. Place a text box on the form and add the following event handler on the form to allow <kbd>CTRL</kbd>-<kbd>A</kbd> to select a...
<pre><code> private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.Control &amp;&amp; e.KeyCode == Keys.A) { this.textBox1.SelectAll(); e.SuppressKeyPress = true; } } </code></pre> <p>hope this helps</p>
<p>This worked for me:</p> <p>Set the KeyPreview on the Form to True.</p> <p>Hope that helps.</p>
27,903
<p>I want to use XMLHttpRequest in JavaScript to POST a form that includes a file type input element so that I can avoid page refresh and get useful XML back.</p> <p>I can submit the form without page refresh, using JavaScript to set the target attribute on the form to an iframe for MSIE or an object for Mozilla, but ...
<p>You can construct the 'multipart/form-data' request yourself (read more about it at <a href="http://www.faqs.org/rfcs/rfc2388.html" rel="noreferrer">http://www.faqs.org/rfcs/rfc2388.html</a>) and then use the <code>send</code> method (ie. xhr.send(your-multipart-form-data)). Similarly, but easier, in Firefox 4+ (als...
<p>I don't see why iframe (an invisible one) implies XHTML and not ANY content. If you use an iframe you can set the onreadystatechange event and wait for 'complete'. Next you could use frame.window.document.innerHTML (please someone correct me) to get the string result.</p> <pre><code>var lFrame = document.getElement...
18,789
<p>X = 01001001 and Y = 10101010<br/> <br/> If I want to add them together how do I do that? They are "Two's Complement"... I have tried a lots of things but I am not quite sure I am getting the right answer since there seems to be different type of rules.<br/> <br/> Just want to make sure it is correct:<br/> 1. Add t...
<p>The beauty of two's complement is that at the binary level it's a matter of interpretation rather than algorithm - the hardware for adding two signed numbers is the same as for unsigned numbers (ignoring flag bits). </p> <p>Your first example - "just add them" - is exactly the right answer. Your example numbers </p...
<p>Adding in two's complement doesn't require any special processing when the signs of the two arguments are opposite. You just add them as you normally would in binary, and the sign of the result is the sign you keep.</p>
45,118
<p>Everything I read about better PHP coding practices keeps saying don't use <code>require_once</code> because of speed.</p> <p>Why is this?</p> <p>What is the proper/better way to do the same thing as <code>require_once</code>? If it matters, I'm using PHP&nbsp;5.</p>
<p><code>require_once</code> and <code>include_once</code> both require that the system keeps a log of what's already been included/required. Every <code>*_once</code> call means checking that log. So there's definitely <em>some</em> extra work being done there but enough to detriment the speed of the whole app?</p> ...
<p>I think in PEAR documentation, there is a recommendation for require, require_once, include and include_once. I do follow that guideline. Your application would be more clear.</p>
22,544
<p>What is the best way to encrypt an URL with parameters in Java?</p>
<p>The only way to do this is to use SSL/TLS (https). If you use plain old HTTP, the URL will definitely be sent in the clear.</p>
<p>Are you sure you don't mean URL <strong>encode</strong>? </p> <p>Encoding is available through <code>java.net.URLEncoder.encode</code>.</p>
15,078
<p>I have a form where controls are dynamically added to a Panel. However, when they do so, they are many times added below the fold (bottom of the container). It's nice that the .NET Framework provides this ScrollControlIntoView method, however, for added usability, it would also be nice if there was an easy way to ...
<p>I highly recommend reading <a href="http://msdn.microsoft.com/en-us/library/498928w2(VS.80).aspx" rel="nofollow noreferrer">Cleaning Up Unmanaged Resources</a> on MSDN, it has articles touching on when to use Dispose and how to implement IDisposable correctly. Your gut instinct is mostly correct as you rarely have t...
<p>The <code>Dispose()</code> method is used for cleaning up any resources early. Although the garbage collector reclaims any unused memory for you, it's up to you to do deal with things like network/database connections and file handles. Normally, you'd want these things freed up as soon as they're no longer needed, s...
21,171
<p>I have been trying for quite a while to figure out how to encrypt Application blocks that are stored in an external file called dev_entlib.config</p> <p>I can see in entlib (4.1) that it's possible to use the default protection providers to encrypt the blocks but, I really need to deploy this Application on differe...
<h2>Encrypt external Enterprise Library configuration files with your custom RSA key container using the Enterprise Library Configuration tool.</h2> <ul> <li>EntLib (4.1) uses the default protection provider <em>RsaProtectedConfigurationProvider</em>. But it is possible to remove this provider within your configuratio...
<p>It doesn't seem to be possible yet. My solution is to just encrypt the blocks as part of the web.config and then copy and paste those blocks into an external entLib.config file. These block should then be able to be decrypted on the target servers with the exported key.</p>
49,898
<p>My colleague insists on explicitly specifying the namespace in code as opposed to using the <a href="http://msdn.microsoft.com/en-us/library/sf0df423.aspx" rel="noreferrer">using directive</a>. In other words he wants to use the fully qualified name for each type every time this type occurs in code. Something like <...
<p>For a slightly different answer: LINQ.</p> <p>Extension methods are obtained only via "using" statements. So either the query syntax or the fluent interface will <em>only</em> work with the right "using" statements.</p> <p>Even without LINQ, I'd say use "using"... reasoning that the more you can understand in fewe...
<p>The <a href="http://en.wikipedia.org/wiki/Law_of_Demeter" rel="nofollow noreferrer">Law of Demeter</a> says you should use <em>only one dot</em>:</p> <blockquote> <p>For many modern object oriented languages that use a dot as field identifier, the law can be stated simply as "use only one dot". That is, the code ...
26,406
<p>For those of you that like puzzles: I had this problem recently and am sure there must be a nicer solution.</p> <p>Consider :</p> <ul> <li>an ObservableCollection of <strong>Foo</strong> objects called <em>foos</em>.</li> <li><strong>Foo</strong> contains a string ID field</li> <li>I have no control over <em>foos<...
<p>There really isn't a reason...it's just old convention.</p> <p>To save space, programmers would often do the final math in the return line instead of on it's own line and the parens ensure are mostly there to make it easier to see that it is a single statement that is returned, like this:</p> <pre><code>return (x+...
<p>Using parentheses in a return statement shows a deficient grasp of <code>C/C++</code> syntax. It's as simple as that. But it's not as bad as putting everything in curly braces:</p> <pre><code>int foo(int x) { if (x) { return (-1); } else { return (0); } } </code></pre> <p>So many programmers do thi...
19,576
<p>What is the best way to check if a given url points to a valid file (i.e. not return a 404/301/etc.)? I've got a script that will load certain .js files on a page, but I need a way to verify each URL it receives points to a valid file.</p> <p>I'm still poking around the PHP manual to see which file functions (if an...
<p>The file_get_contents is a bit overshooting the purpose as it is enough to have the HTTP header to make the decision, so you'll need to use curl to do so:</p> <pre><code>&lt;?php // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://www.exam...
<p>one such way would be to request the url and get a response with a status code of 200 back, aside from that, there's really no good way because the server has the option of handling the request however it likes (including giving you other status codes for files that exist, but you don't have access to for a number o...
31,416
<p>I'm having a syntax error. I want to take the floor of a function that returns a floating point number.</p> <p>I <em>thought</em> this would give me the right answer</p> <pre><code>let cyclesPerInterrupt bps bpw cpu factor = floor (fudge (float(factor) cyclesPerWord cpu wordsPerSec bps bpw)) </code></pre> <p>Bu...
<p>Note also that you can use parens to nest the function calls the way you were originally trying to, e.g.</p> <pre><code>...(cyclesPerWord cpu (wordsPerSec bps bpw)) </code></pre> <p>(Without the inner set of parens above, it's kinda like you're trying to pass 4 arguments to cyclesPerWord, which is not what you wan...
<p>Looking at your function definition, it seems like you are using a C# like syntax for calling your functions, the function name exists right before the ( ) and the associated parameters for that function are within the ( ). An example would be FunctionName(Parameter1 Parameter2). F# doesn't use that style. Instea...
38,094
<p>I need to create a database table to store different changelog/auditing (when something was added, deleted, modified, etc). I don't need to store particularly detailed info, so I was thinking something along the lines of:</p> <ul> <li>id (for the event)</li> <li>user that triggered it</li> <li>event name</li> <li>ev...
<p>In the project I'm working on, audit log also started from the very minimalistic design, like the one you described:</p> <pre><code>event ID event date/time event type user ID description </code></pre> <p>The idea was the same: to keep things simple. </p> <p>However, it quickly became obvious that this minimalist...
<p>There are many ways to do this. My favorite way is:</p> <ol> <li><p>Add a <code>mod_user</code> field to your source table (the one you want to log).</p></li> <li><p>Create a log table that contains the fields you want to log, plus a <code>log_datetime</code> and <code>seq_num</code> field. <code>seq_num</code> i...
24,611
<p>Edit: This behaviour is reproducible with <a href="https://stackoverflow.com/questions/301766/mutability-and-reference-of-php5-get-variables">query globals</a> on.</p> <p>I have the following:</p> <pre><code> $_SESSION['query_key'] = $_GET['query_key']; print($query_key); </code></pre> <p>Vs.</p> <pre><code> ...
<p>You must be doing something very weird with your code. <a href="http://www.php.net/clone" rel="nofollow noreferrer">clone</a> is for use on objects. Unless you're stuffing objects into $_GET then that code will result in a fatal error (or a warning in older PHP versions).</p> <p>@Michael Haren - clone actually doe...
<p>I know this doesn't really answer the question specifically, but based on your comment to Roborg I don't think this is a good solution for the problem you refer to in your other question (<a href="https://stackoverflow.com/questions/301766/php5-get-variables">here</a>) - you would be better off disabling register_gl...
38,721
<p>The framework I am developing for my application relies very heavily on dynamically generated domain objects. I recently started using Spring WebFlow and now need to be able to serialize my domain objects that will be kept in flow scope. </p> <p>I have done a bit of research and figured out that I can use <code>wri...
<p>Are you using spring's <code>ApplicationContext</code>, or <code>BeanFactory</code>? If you are using <code>ApplicationContext</code>, you can implement ApplicationContextAware instead and spring will supply you with the application context. I've never used spring's <code>BeanFactory</code> before but I have used <c...
<p>Are you sure that your Configurable class has been properly weaved wither by compiling it with the ApsectJ compiler or with runtime weaving.</p> <p>You also need to specify the attributes in you configuration file marking the bean as prototype. Something along the lines of:</p> <p><code>&lt;aop:spring-configured /...
29,435
<p>I noticed the specificaition for Collections.sort:</p> <pre><code>public static &lt;T&gt; void sort(List&lt;T&gt; list, Comparator&lt;? super T&gt; c) </code></pre> <p>Why is the "<code>? super</code>" necessary here? If <code>ClassB</code> extends <code>ClassA</code>, then wouldn't we have a guarantee that a <co...
<p>Josh Bloch had a talk at Google I/O this year, called <a href="http://sites.google.com/site/io/effective-java-reloaded" rel="nofollow noreferrer">Effective Java Reloaded</a>, which you may find interesting. It talks about a mnemonic called "Pecs" (producer <code>extends</code>, consumer <code>super</code>), which ex...
<p>It's obvious to you that, in the case of <code>Comparator</code>, any ancestor of <code>T</code> would work. But the compiler doesn't know that class <code>Comparator</code> functions like that - it just needs to be told whether it should allow <code>&lt;T&gt;</code> or <code>&lt;? super T&gt;</code>.</p> <p>Viewed...
31,287
<p>I've been knocking my head against this for some time now. I'm not really sure why it isn't working. I'm still pretty new to this whole WPF business. </p> <p>Here's my XAML for the combobox</p> <pre><code>&lt;ComboBox SelectedValuePath="Type.FullName" SelectedItem="{Binding Path=Type}" Name="cmoBox" /...
<p>In the XAML, set <code>ItemsSource="{Binding}"</code> and (in the code behind) set the <code>DataContext</code> to <code>myAssembly.PossibleTypes</code>.</p>
<p>I agree: bindings should be in the XAML. I put ... checking .. nothing at all in the code behind, ever. Data sources are all re-usable "resources". </p> <p>(well, OK, the code-behind constructor calls InitializeComponent()). </p>
40,055
<p>Suppose you have the following string:</p> <pre><code>white sand, tall waves, warm sun </code></pre> <p>It's easy to write a regular expression that will match the delimiters, which the Java String.split() method can use to give you an array containing the tokens "white sand", "tall waves" and "warm sun":</p> <pr...
<p>This should be pretty resilient, and handle stuff like delimiters at the end of the string ("foo and bar and ", for example)</p> <pre><code>\s*(?:\band\b|,)\s* </code></pre>
<pre><code>(?:(?&lt;!s)and\s+|\,\s+) </code></pre> <p>Might work</p> <p>Don't have a way to test it, but took out the just space matcher.</p>
12,292
<p>Is it possible to export a picture with custom animation from PowerPoint to an animated gif?</p>
<p>Powerpoint 2010 can save directly to windows video format.</p> <p>Convert to gif from there.</p>
<p>There are a number of services and pieces of software to convert PowerPoint presentations to videos of various types. <a href="http://www.authorstream.com/" rel="nofollow noreferrer">AuthorStream</a> is a website that converts PPT to MPEG4. A bunch of programs that do conversion are listed <a href="http://www.mydi...
40,718
<p>I currently use the following function to do a simple HTTP GET.</p> <pre><code>public static String download(String url) throws java.io.IOException { java.io.InputStream s = null; java.io.InputStreamReader r = null; //java.io.BufferedReader b = null; StringBuilder content = new StringBuilder(); ...
<p>In this case, I would do as you are doing (use a byte array for buffering and not one of the stream buffers).</p> <p>There are exceptions, though. One place you see buffers (output this time) is in the servlet API. Data isn't written to the underlying stream until <em>flush()</em> is called, allowing you to buffer ...
<p>My gut tells me that since you're already performing buffering by using the byte array, it's redundant to use the BufferedReader.</p>
5,131
<p>Is there any way to "dock" a Silverlight control to the browser window? For example, I'd like to have an HTML header at the top of a page and then have the Silverlight control take up precisely the rest of the window, neatly resizing whenever the window is resized.</p> <p>The default page Visual Studio creates uses...
<p>Split everything on spaces removing special characters (commas, periods, etc). Then use something like <a href="http://en.wikipedia.org/wiki/Soundex" rel="nofollow noreferrer">soundex</a> to handle misspellings. Or you could go with something like <a href="http://lucene.apache.org/java/docs/" rel="nofollow noreferre...
<p>pure old regular expression scripting will do the job.</p> <p>use Ruby, it's quite fast. read lines and match words.</p> <p>cheers </p>
43,968
<h2>How is it possible to call a client side javascript method after a <em>specific</em> update panel has been loaded?</h2> <p><strong><code>Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler)</code></strong> does not work for me because this will fire after ANY update panel finishes loadin...
<p>Thanks - both good answers. I went with the client side script "pageloaded" in the end. That is a fairly buried method that google did not reveal to me. For those who are interested, this code works with FireBug to give a good demo of the PageLoaded method working to find the updated panels:</p> <pre><code>&lt;sc...
<p>This may be your solution. </p> <p>In the code behind for the UpdatePanel's OnLoad event, register a startup script. </p> <pre><code>string scriptText = "alert('Bar!');"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "foo", scriptText, true); </code></pre>
43,973
<p>I am using a specific command in in my C# code, which works well. However, it is said to misbehave in "unmanaged" code.</p> <p>What is managed or unmanaged code?</p>
<p><a href="http://www.developer.com/net/cplus/article.php/2197621/Managed-Unmanaged-Native-What-Kind-of-Code-Is-This.htm" rel="noreferrer">This</a> is a good article about the subject.</p> <p>To summarize,</p> <ol> <li><strong>Managed code</strong> is not compiled to machine code but to an intermediate language which ...
<p>First of all understand this, before <code>.NET framework</code>, <code>Microsoft</code> were providing the stand-alone products like <code>MFC (Visual C++), VB, FoxPro</code> etc. </p> <p>In 2002, Microsoft combined its products and made .NET framework. Now there is a difference between how code was executed befor...
43,345
<p>I have a colleague who is looking into opcode caching/Zend Acceleration (I've always assumed these are the same thing) for our PHP based application. His Benchmarks appear to indicate that we're NOT seeing a performance benefit if we include our (large) class libraries with require_once, but we DO see the performan...
<p>For starters, both calls (require_once and include_once) double-check if a file has not been included before.</p> <p>So the way they both achieve this is by searching the file in all available paths and by essentially checking if it hasn't been in the mix before etc..</p> <p>In the background what happens is that ...
<p>I can't guarantuee anything as i haven't looked deeply enough into it, but yes, i have seen speed differences between the two. They were never significant enough to me to move to include_once instead of require_once though.</p> <p>I always assumed the difference was because require_once has to do more work underwat...
25,736
<p>My program has to read files that use various encodings. They may be ANSI, UTF-8 or UTF-16 (big or little endian). </p> <p>When the BOM (Byte Order Mark) is there, I have no problem. I know if the file is UTF-8 or UTF-16 BE or LE.</p> <p>I wanted to assume when there was no BOM that the file was ANSI. But I have f...
<p>Maybe you can shell out to a Python script that uses <a href="http://chardet.feedparser.org/" rel="noreferrer">Chardet: Universal Encoding Detector</a>. It is a reimplementation of the character encoding detection that used by Firefox, and is used by <a href="http://diveintomark.org/archives/2008/03/05/upstream" rel...
<p>ASCII? No modern OS uses ASCII any more. They all use 8 bit codes, at least, meaning it's either UTF-8, ISOLatinX, WinLatinX, MacRoman, Shift-JIS or whatever else is out there.</p> <p>The only test I know of is to check for invalid UTF-8 chars. If you find any, then you know it can't be UTF-8. Same is probably poss...
48,782
<p>I need to copy a text from a textbox into the clipboard with ASP.NET. I want a code that is comparable with Mozilla Firefox and IE.</p>
<p>Internet Explorer clipboard copy is trivial:</p> <pre><code>// set the clipboard var x = 'Whatever you want on the clipboard'; window.clipboardData.setData('Text',x); // get the clipboard data window.clipboardData.getData('Text'); </code></pre> <p>Firefox, not trivial at all. Impossible actually with pure JS unle...
<p>For non-IE browsers use this common-all-over-the-world-used script. Google for "_clipboard.swf" file. (though, this code will NOT work on newest Flash 10 becouse of security reasons)</p> <p>var flashcopier = 'flashcopier';</p> <pre><code> if(!document.getElementById(flashcopier)) { var divholder = docu...
46,805
<p>Anyone know a good lib where i can run the strings before they are inserted, that can strip out sql/javascript code? To be run in jsp pages.</p> <p>Idealy the lib would be:</p> <ul> <li>Free</li> <li>Lightweight</li> <li>Easy to use</li> </ul> <p>Thanks in advance to the SO community who will happily reply :)</p>...
<p>Apache Commons lang StringEscapeUtils will get you some of the way. It escapes, doesnt strip.</p> <p><a href="http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html" rel="noreferrer">http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html</a></p> <p>Edit: Escapi...
<p>The what you're saying is that for every possible entry being added to the string I have to remove first the "malicious" data. Yeah it makes sense as I wouldn't be able to tell which was added as an input and what would be part of the query itself.</p> <p>Ok ty i guess i need to restart changing some code :) still ...
45,574
<p>I would like to customize TDBGrid:</p> <p>1) add onSelect/onUnselect events - e.g. good for show count of selected items.</p> <p>2) remove select item on left mouse click. I have inherited TDBGrid and rewritten MouseDown, but then it is not possible to move or resize columns :( </p> <p>So, how to do it?</p> <p>D...
<p>You would need to check changes in the Selected property.</p>
<p>I think you probably need to make sure you allow the inherited Mousedown to run so that the standard move and resize behaviour will execute.</p>
48,988
<p>I have been working on a project that has 2 interfaces - windows forms and web. Over the past 8 months, we have faced more issues with maintenance of our web apps (works in IE not in FF, ajax breaks in some weird ways that is not easy to debug... ) and so on.<br /></p> <p>On the other hand, the winform app is easy ...
<p>We had a PHP website for our intranet utility. We have switches since 2 years over a C# application with ClickOnce and everybody love to works with a desktop application. Update are done automaticly and the developement team have reduce to about 70% all GUI/Visual times. We might have this high level or success beca...
<p>Stuff like java web start also exist since millenniums but it didn't take off...</p> <p>On the programmer perspective, those techs are definitely the better way. To make an application on the web, you really are just hacking around. Will they take off one day? Only time will tell. I hope so though.</p>
44,885
<p>Given the below XML snippet I need to get a list of name/value pairs for each child under DataElements. XPath or an XML parser cannot be used for reasons beyond my control so I am using regex.</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;StandardDataObject xmlns="myns"&gt; &lt;DataElements&gt; &lt;EmpStatus...
<p>XML is not a regular language. You <b>cannot</b> parse it using a regular expression. An expression you think will work will break when you get nested tags, then when you fix that it will break on XML comments, then CDATA sections, then processor directives, then namespaces, ... It cannot work, use an XML parser.</p...
<p>Try to parse the Reg Ex via a property file and create then pattern object. I sorted out the same issue I faced while injecting Reg Ex via xml beans.</p> <p>Ex :- I needed to parse the Reg Ex '(.)(D[0-9]{7}.D[0-9]{9}.D[A-Z]{3}[0-9]{4})(.)' by injecting in Spring. But it didn't work. Once tried to use the same Reg E...
43,475
<p>A friend and I were discussing C++ templates. He asked me what this should do:</p> <pre><code>#include &lt;iostream&gt; template &lt;bool&gt; struct A { A(bool) { std::cout &lt;&lt; "bool\n"; } A(void*) { std::cout &lt;&lt; "void*\n"; } }; int main() { A&lt;true&gt; *d = 0; const int b = 2; co...
<p>AFAIK it would be compiled as <code>new A&lt;b>(c) > d</code>. This is the only reasonable way to parse it IMHO. If the parser can't assume under normal circumstances a > end a template argument, that would result it much more ambiguity. If you want it the other way, you should have written:</p> <pre><code>new A&lt...
<p>The greediness of the lexer is probably the determining factor in the absence of parentheses to make it explicit. I'd guess that the lexer isn't greedy.</p>
7,575
<p>The question posed came about during a 2nd Year Comp Science lecture while discussing the impossibility of generating numbers in a deterministic computational device.</p> <p>This was the only suggestion which didn't depend on non-commodity-class hardware.</p> <p>Subsequently nobody would put their reputation on th...
<p>No.</p> <p>A malicious machine on your network could use ARP spoofing (or a number of other techniques) to intercept your pings and reply to them after certain periods. They would then not only know what your random numbers are, but they would also control them.</p> <p>Of course there's still the question of how d...
<p>Eh, I find that this kind of question leads into discussions about the meaning of 'truly random' pretty quickly.</p> <p>I think that measuring pings would yield decent-quality random bits, but at an insufficient rate to be of much use (unless you were willing to do some serious DDOSing).</p> <p>And I don't see tha...
16,611
<p>What code do you need to add in PHP to automatically have the browser download a file to the local machine when a link is visited?</p> <p>I am specifically thinking of functionality similar to that of download sites that prompt the user to save a file to disk once you click on the name of the software?</p>
<p>Send the following headers before outputting the file:</p> <pre><code>header("Content-Disposition: attachment; filename=\"" . basename($File) . "\""); header("Content-Type: application/octet-stream"); header("Content-Length: " . filesize($File)); header("Connection: close"); </code></pre> <p><a href="https://stack...
<p>my code works for txt,doc,docx,pdf,ppt,pptx,jpg,png,zip extensions and I think its better to use the actual MIME types explicitly.</p> <pre><code>$file_name = "a.txt"; // extracting the extension: $ext = substr($file_name, strpos($file_name,'.')+1); header('Content-disposition: attachment; filename='.$file_name);...
6,221
<p>I've gone through just about every property I can think of, but haven't found a simple way to hide the header on a winform UltraCombo control from Infragistics.</p> <p>Headers make sense when I have multiple visible columns and whatnot, but sometimes it would be nice to hide it.</p> <p>To give a simple example, le...
<p><code>&lt;DropDownLayout ColHeadersVisible="No"&gt;&lt;/DropDownLayout&gt;</code> works for us. This is on Infragistics NetAdvantage for .NET 2008.</p>
<p>My understanding of the Infragistics WinForms suite is that the UltraCombo is designed for multi-column (or embedded UltraGrid) use. </p> <p>What I did to get around this was to replace those UltraCombos with UltraComboEditor controls. These are IG's "enhanced" versions of the standard .NET combobox. </p> <p>That ...
16,256
<p>My JavaScript is pretty nominal, so when I saw this construction, I was kind of baffled:</p> <pre><code>var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); shareProxiesPref.disabled = proxyTypePref.value != 1; </code></pre> <p>Isn't it better to do an if on <code>proxyTypePref.val...
<p>It depends on the context of this code. If it's running on page load, then it would be better to put this code in an if block.</p> <p>But, if this is part of a validation function, and the field switches between enabled and disabled throughout the life of the page, then this code sort of makes sense.</p> <p>It's i...
<p>It's hard to say what's better to do without more context.</p> <p>If this code being executed every time that proxyTypePref changes, then you're always going to need set <code>shareProxiesPref.disabled</code>.</p> <p>I would agree than an if statement would be a bit more readable than the current code.</p> <block...
4,668
<p>I have a .NET Set and Deployment project which has to execute a set of really long SQL Scripts as a part of the installation process. I have used SMO dlls to make calls to the .sql script files.These SMO dlls are however not a part of the .NET framework but they come bundled with SQL Server 2005 or 2008. Now, if the...
<p>Assuming you're talking about a static library, <code>DUMPBIN /SYMBOLS</code> shows the functions and data objects in the library. If you're talking about an import library (a <code>.lib</code> used to refer to symbols exported from a DLL), then you want <code>DUMPBIN /EXPORTS</code>.</p> <p>Note that for function...
<p>1) Open a Developer Command Prompt for VS 2017 (or whatever version you have on your machine)(It should be located under: Start menu --> All programs --> Visual Studio 2017 (or whatever version you have on your machine) --> Visual Studio Tools --> Developer Command Prompt for VS 2017.</p> <p>2) Enter the followin...
39,258
<p>How can I use Connection pool in Java+MySQL+Tomcat 6? </p> <p>I've read this article <a href="http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html" rel="noreferrer">http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html</a> but it is still not quite clea...
<p>You should read the <a href="http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html" rel="nofollow noreferrer">Tomcat 6 JNDI document</a>. Look for the "JDBC Data Sources" section and it will tell you everything you need to know about pooling connections with Tomcat.</p>
<p>You can easily implement MySQL connection pooling in Java by using Java's GenericObjectPool that provides robust pooling functionality for arbitrary objects.</p> <p>See detailed example in this post: <a href="http://www.rndblog.com/how-to-set-up-a-mysql-connection-pool-in-java/" rel="nofollow">How to set up a MySQL...
42,711
<p>How would you go about dead code detection in C/C++ code? I have a pretty large code base to work with and at least 10-15% is dead code. Is there any Unix based tool to identify this areas? Some pieces of code still use a lot of preprocessor, can automated process handle that?</p>
<p>You could use a code coverage analysis tool for this and look for unused spots in your code.</p> <p>A popular tool for the gcc toolchain is gcov, together with the graphical frontend lcov (<a href="http://ltp.sourceforge.net/coverage/lcov.php" rel="noreferrer">http://ltp.sourceforge.net/coverage/lcov.php</a>).</p> ...
<p><a href="http://www.bullseye.com/" rel="nofollow noreferrer">Bullseye</a> coverage tool would help. It is not free though.</p>
28,353
<p>Sometimes it might be useful, but mostly just looking cool or impressive to visualize log files (anything from http requests and to bandwith usage to cups of coffee drunk per day). I know about <a href="http://www.visitorville.com/" rel="noreferrer">Visitorville</a> which I think look a bit silly, and then there's ...
<p>You may take a look at Apache Chainsaw. This nifty tool allows Log incomes from nearly everyqhere and has live filtering and colering. If you have an already written Log, I'm not sure if it can read it, it's been a while since I used it last time (was very usefull for the prototyping phase of our JBoss server)</p>
<p>Using SciTe, Notepad++ or other powerful text editor which have file processing routines, so you can create a script that colorizes parts of the log or just delete some non-important lines from it</p>
12,018
<p>I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on <a href="http://wiki.python.org/moin/PythonInMusic" rel="nofollow noreferrer">music</a> and <a href="http://wiki.python.org/moin/Audio/" rel="nofollow noreferrer">basic audio</a> as well as a StackOverflo...
<p>Take a close look at <a href="http://www.csounds.com/" rel="noreferrer">cSounds</a>. There are Python bindings allow you to do pretty flexible digital synthesis. There are some pretty complete packages available, too. </p> <p>See <a href="http://www.csounds.com/node/188" rel="noreferrer">http://www.csounds.com/n...
<p>There is a variety of Python music software, you can find a catalog <a href="http://wiki.python.org/moin/PythonInMusic" rel="nofollow noreferrer">here</a>.</p> <p>If you scroll down the linked page, you find a section on <strong>Music Programming in Python</strong> describing several music creation packages includi...
13,417
<p>I am new to 3d printing having only recieved it for christmas. The filament is jammed somewhere in the extruder of my Wanhao Duplicator i3 Plus. I have tried removing it with the included hook but was unsuccessful. Is there anything else I should try before I before I dismantle the extruder, which i very much want t...
<p>Try to preheat your printer, the temperature should be above 180°C then push the filament to come out from the nozzle just 4 to 7 mm, then take out the filament from the extruder. With this step the plastic lump will get soft and will release the filament.</p> <p>Then use the tool to clean the nozzle pushing the re...
<p>Try to preheat your printer, the temperature should be above 180°C then push the filament to come out from the nozzle just 4 to 7 mm, then take out the filament from the extruder. With this step the plastic lump will get soft and will release the filament.</p> <p>Then use the tool to clean the nozzle pushing the re...
778
<p>I have done the calibration for the x, y, and z axis and everything works fine there. However when I went to do the calibration for extruder things got a little weird. The original number programmed on the board for the step per mm was 98 When I did my first measurements I used 120mm as the mark on the filament then...
<p>It is really strange that although you <em>increased</em> the steps per mm, the amount extruded was <em>less</em>. I can think of two possible explanations:</p> <ul> <li><p>You are extruding too quickly, at a rate at which the extruder can't keep up melting the filament fast enough, causing the filament to slip or ...
<p>I understand you marked at 120mm then tried to extrude 100mm and measured 37.66mm remaining. Take the 120mm - 37.66mm (remaining)= 82.34mm (that was extruded (so you were 17.66mm short of your 100mm).</p> <p>The formula I use is [New Setting=(Wanted Distance X old setting)/ Actual Distance].</p> <p>So [New Settin...
236
<p>I am wondering if anyone else is experiencing these same issues:</p> <p>My main dev machine is a Dell, running Vista Home Premium and Visual Studio 2008 - both fully patched / up-to-date.</p> <p>There are some quirks, such as the play/pause media controls on my keyboard not working while running Visual Studio 2008...
<p>VS2008 runs fine on my Vista. All service packs (both VS &amp; Vista) are installed.</p> <p>I'm also using a MS keyboard: <a href="http://www.microsoft.com/hardware/mouseandkeyboard/ProductDetails.aspx?pid=094&amp;active_tab=overview" rel="nofollow noreferrer">Laser Desktop 4000</a>.</p>
<p>have you tried doing things in elevated privileges mode? including reinstalling and all...</p>
4,812
<p>I just finished watching the Google clean code video on YouTube (see <a href="http://googletesting.blogspot.com/" rel="nofollow noreferrer">link</a>, first article) about removing <code>if</code> statements from your code and using polymorphism instead. </p> <p>After watching the video I had a look at some code th...
<p>Just a cautionary note here after seeing some of these (technically correct) reponses, just getting rid of an If statement should not be your sole aim, the aim should be to make your code extensible, maintainable and simple, if that means getting rid of an if statement, great, but it shouldn't be an aim in an of its...
<p>I would maybe consider passing off the fetching of the return value to another class that could be injected at runtime.</p> <pre><code>public class Thing { public IValueFetcher ValueFetcher { get; set; } public int Number { get { return this.ValueFetcher.GetValue&lt;int&gt;(/* parameters to ...
46,736
<p>At work, we have a windows server 2003 with IIS and Subversion installed. We use it to publish and test locally our ASP.NET websites. Every programmer has Tortoise installed on his PC and can update/commit content to the server. Hosting the repositories is working fine. But the files kept in those repositories need...
<ol> <li><p>Just keep the web server's file area as a working copy, and perform an svn up in it whenever you want to "publish". Configure it to hide the contents of the .svn folders if they seem untidy to you (I don't specifically know how to do this, but I assume it can be done). They will already have the filesystem ...
<p>Use can use the free <a href="http://www.visualsvn.com/server/" rel="nofollow noreferrer">Visual-SVN Server</a> to quickly install Subversion with Apache front end. It also have a nice MMC snap-in for managing the server and repositories.</p> <p>You will than be able to access subversion with HTTP or HTTPS, but the...
14,388
<p>I have a data acquisition hardware device attached to a PC via USB that I'd like to send some information and settings, acquire some data, and then retrieve the acquired data on the client and send it to the server. The plan is to use a web portal to communicate with the device attached to the client PC. I was plann...
<p>It's not the web <em>browser</em> that is communicating with the device, it's the web <em>server</em>. In other words, write a small web application that instead of (or in addition to) reading data from a database, reads from the device, and present to the user as HTML.</p> <p>A different way to achieve the same wo...
<p>You can take the easy way and use an embedded web server as a service to collect the data and access it like an ordinary web site from the browser. It requires the client to start the service though.</p> <p>You can use it as a proxy to your portal also, in which case you don't have to deal with security restriction...
25,665
<p>Good afternoon,</p> <p>I have a web query in <code>Excel 2002</code> going against a web page that returns a date column. The dates are returned as <code>DD/MM/YYYY</code>, as I would like to show them in my spreadsheet. My machine running Excel has its regional settings set to en-GB, and the only language set un...
<p>Can you modify the "web query"?</p> <p>The universal date format is the better way for Office products to recognise dates/times. I've had similar problems working with GB to US dates and found that coding your dates into this format saves you a lot of trouble.</p> <pre><code>Universal Date format is : "yyyy-mm-dd ...
<p>Maybe you are lucky and Excel understands either the HTML <code>lang</code> attribute or <code>&lt;meta http-equiv="content-language" content="..."&gt;</code> meta tag. To be honest - my guess is that it doesn't make a difference.</p> <p>If you have control over the web site, you can try to add them and see if it m...
38,951
<p>I'm having a problem where a jQuery setting against an .html() property on a selected element is returning the error 'nodeName' is null or not an object. This only occurs on IE6 and IE7, but not FF2, FF3, Opera (latest Nov 12,2008) or Safari (again, latest).</p>
<p>I resolved the problem. The example looks like this:</p> <p>$('#section #detail .data').html(data);</p> <p>...where data is HTML returned from an AJAX call, and this bug only occurs on IE6 and IE7 on the second attempt AJAX call, not the first. It's inexplicable. The error returned is:</p> <pre><code>'nodeName' i...
<p>I don't know if it's connected, but we've had what sounds like a similar issue where the DOM doesn't have the children/text of a element that we know exist (because we see them rendered on the screen!)</p> <p>Selecting something else, then selecting the elememt again seemed to fix the issue - suddenly, the children...
35,912
<p>What are the differences between <code>htmlspecialchars()</code> and <code>htmlentities()</code>. When should I use one or the other?</p>
<p>From the PHP documentation for <a href="http://us2.php.net/htmlentities" rel="noreferrer">htmlentities</a>:</p> <blockquote> <p>This function is identical to <code>htmlspecialchars()</code> in all ways, except with <code>htmlentities()</code>, all characters which have HTML character entity equivalents are transl...
<pre><code>**HTML Character Entity Reference Chart at W3.org** </code></pre> <p><a href="https://dev.w3.org/html5/html-author/charref" rel="nofollow noreferrer">https://dev.w3.org/html5/html-author/charref</a></p> <pre><code>&amp;Tab; &amp;NewLine; ! &amp;excl; " &amp;quot; &amp;QUOT; # &amp;num; $ &amp;dollar; % &am...
6,860
<p>What features might our team find lacking if we adopted <a href="http://basecamphq.com" rel="nofollow noreferrer">Basecamp</a> for bug tracking, task tracking, external documentation, collaboration, and project management?</p> <p>I've used the free version before and think that 37Signals makes excellent products - ...
<p>I've been using BaseCamp for 2 years now and found it to be an excellent general project information portal. The ability to store documents, to-do tasks, and milestones with a living project view is pretty impressive.</p> <p>Unfortunately their mantra of 'keep it simple' also has quite a few drawbacks in regards t...
<p>Task estimates vs actuals is a big issue I've noticed. Also being able to mark tiem as billed would be a nice feature it currnetly lacks.</p>
35,372
<p>Why don't 3D printer heads use ceramic inner walls? PTFE tubes melt with high enough temperatures and all metal ends risk jamming as heat makes its way up the head.</p>
<p>It <em>can</em> be done cheaply, as two different users have proven, see </p> <ul> <li><a href="https://reprap.org/forum/read.php?1,538786" rel="nofollow noreferrer">A practical 10 Cents Ceramic tube hotend</a>, and;</li> <li><a href="https://reprap.org/forum/read.php?70,172916" rel="nofollow noreferrer">Hotend wit...
<p>Because PTFE doesn't transmit heat very well? The whole idea when using a PTFE tube (and this is just my understanding ... which could be wrong), is for the tubing not to transmit heat, therefore allowing the filament to pass through it without melting or at the very least, collecting a lot of heat along the way (wh...
1,454
<p>What are the benefits of passing by pointer over passing by reference in C++?</p> <p>Lately, I have seen a number of examples that chose passing function arguments by pointers instead of passing by reference. Are there benefits to doing this?</p> <p>Example:</p> <pre><code>func(SPRITE *x); </code></pre> <p>with...
<p>A pointer can receive a NULL parameter, a reference parameter can not. If there's ever a chance that you could want to pass "no object", then use a pointer instead of a reference.</p> <p>Also, passing by pointer allows you to explicitly see at the call site whether the object is passed by value or by reference:</p...
<p>Not really. Internally, passing by reference is performed by essentially passing the address of the referenced object. So, there really aren't any efficiency gains to be had by passing a pointer.</p> <p>Passing by reference does have one benefit, however. You are guaranteed to have an instance of whatever object...
43,428
<p>What is the issue with the Silverlight Tools for VS2008? I can't seem to place controls on the designer surface. This didn't work for me on two different machines. Do you have to tweak the XAML to be able to place the first control?<br> Cursor stays a compass-like-cross when over the surface. Are you supposed to dra...
<p>This is in response to your request for my thoughts on this question from your comments on <a href="https://stackoverflow.com/questions/539754/silverlight-getting-the-domain-information">this post</a>.</p> <p>As both Aaron Fischer and Boyan have mentioned, the Visual Studio 2008 Silverlight 2 Designer installed by ...
<p>The designer is read only. Your have to use expression blend until vs 2010</p>
44,986
<p>we're running in this issue. We're using a web service (using soap4r) to run some kind of searches and the problem appears when the webservice server is down and our aplication is trying to connect to it. At that point the application is unreachable, and all the customers are blocked.</p> <p>What can we do to avoi...
<p>This sounds to me like it may be more of a mod_proxy problem than one with Mongrel or Apache - are you setting Proxy Timeouts as described <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxytimeout" rel="nofollow noreferrer">here</a>?</p>
<p>Use mod_rewrite to reurn an error page that is more useful to the web service clients than Apache's proxy timeout errors. For example this Apache configuration will render <code>maintence.html</code> if it exists. So all you have to do is drop the file in and the server is automatically in maintence mode.</p> <pr...
22,555
<p>How to figure out if a table is in use in SQL (on any type database)? if somebody is already using it, or have it "open" then its in use.</p>
<p>Check for open locks on the table.</p> <p>Have a look on the syslockinfo table.</p>
<p>Actually this will give you a better result:</p> <pre><code>select spid from master..sysprocesses where dbid = db_id('Works') and spid &lt;&gt; @@spid </code></pre>
43,101
<p>I have a file (fasta file to be specific) that I would like to index, so that I can quickly locate any substring within the file and then find the location within the original fasta file.</p> <p>This would be easy to do in many cases, using a Trie or substring array, unfortunately the strings I need to index are 80...
<p>In some languages programmers have access to <strong><em>"direct byte arrays"</em></strong> or <strong><em>"<a href="http://en.wikipedia.org/wiki/Memory-mapped_file" rel="nofollow noreferrer">memory maps</a>"</em></strong>, which are provided by the OS. In java we have <strong><a href="http://java.sun.com/j2se/1.4....
<p>I talked to a few co-workers and they just use VIM/Grep to search when they need to. Most of the time I wouldn't expect someone to search for a substring like this though.</p> <p>But I don't see why MS Desktop search or spotlight or google's equivalent can't help you here.</p> <p>My recommendation is splitting the...
7,662
<p>I am trying to create an upload control for ASP.NET MVC with jQuery progress bar. In ASP.NET the implementation works no problems, but in MVC the problem is that the server doesn't respond to my callbacks until the file is uploaded.</p> <p>The upload control is based on html file upload element, and I cannot for th...
<p>Hrmmm,</p> <p>Thomas, MVC does not handle post-backs at all. Because a URL is directly routed to an Action method on a controller, a form is not meant to actually post-back to itself. Further more, all of the post back processing that Asp.Net had to handle post-backs on the server was pulled out of the .Net MVC fra...
<p>Suggestion:</p> <blockquote> <p>You can use the <a href="http://www.uploadify.com/" rel="nofollow">JQuery Uploadify control</a> to show the status of the upload. This control has a flash and html 5 type controls. Use whichever is applicable to you.</p> </blockquote>
44,060
<p>I had the following piece of code (simplified for this question):</p> <pre><code>struct StyleInfo { int width; int height; }; typedef int (StyleInfo::*StyleInfoMember); void AddStyleInfoMembers(std::vector&lt;StyleInfoMember&gt;&amp; members) { members.push_back(&amp;StyleInfo::width); members.pus...
<p>Remember a pointer to a member is just used like a member.</p> <pre><code> Obj x; int y = (x.*)ptrMem; </code></pre> <p>But like normal members you can not access members of subclasses using the member access mechanism. So what you need to do is access it like you would access a member of the object (in your ca...
<p>size (as in <code>&amp;StyleInfo::size::width</code>) is not the name of a type.</p> <p>try size->width or size.width instead, depending on how your 'AddStyleInfoMembers` knows about size at all.</p>
30,132
<p>Should I bind directly to objects returned from a webservice or should I have client-side objects that I bind to my gridcontrols? For instance if I have a service that returns object Car should I have a client side Car object that I populate with values from the webservice Car object? What is considered best-practi...
<p>This is a good question, which follows the sames lines as two questions I have asked myself:</p> <ol> <li><a href="https://stackoverflow.com/questions/17725/large-complex-objects-as-a-web-service-result">Large, Complex Objects as a Web Service Result</a>.</li> <li><a href="https://stackoverflow.com/questions/6681/a...
<p>This really depends on what you are getting from the web service. If they are simple data transfer objects and you are only displaying data, then yes, you can bind. If you plan to edit the objects, it may not be usefull as you will need to track changes.</p> <p>Do your objects and/or collections on the client track...
13,506
<p>I'm evaluating Server 2008. My C++ executable is getting this error. I've seen this error on MSDN that seems to have required a hot-fix for several previous OSes. Anyone else seen this? I get the same results for the 32 &amp; 64 bit OS.</p> <p>Code snippet:</p> <pre><code>HRESULT GroupStart([in] short iClientId, [...
<p>We ran into the same error recently with a client/server app communicating via DCOM. It turned out that the size of a marshalled interface pointer going across the wire (i.e., not local) had changed (gotten bigger). You might like to check whether your code is doing any special marshalling via CoMarshalInterface or ...
<p>We ran into the same error recently with a client/server app communicating via DCOM. It turned out that the size of a marshalled interface pointer going across the wire (i.e., not local) had changed (gotten bigger). You might like to check whether your code is doing any special marshalling via CoMarshalInterface or ...
9,086
<p>I have a class with two class methods (using the <code>classmethod()</code> function) for getting and setting what is essentially a static variable. I tried to use the <code>property()</code> function with these, but it results in an error. I was able to reproduce the error with the following in the interpreter:</...
<h3>3.8 &lt; Python &lt; 3.11</h3> <p>Can use both decorators together. See <a href="https://stackoverflow.com/a/64738850/674039">this answer</a>.</p> <h3>Python &lt; 3.9</h3> <p>A property is created on a class but affects an instance. So if you want a <code>classmethod</code> property, create the property on the met...
<p>Here's my suggestion. Don't use class methods. </p> <p>Seriously. </p> <p>What's the reason for using class methods in this case? Why not have an ordinary object of an ordinary class?</p> <hr> <p>If you simply want to change the value, a property isn't really very helpful is it? Just set the attribute value...
15,645
<p>I have a self-referential Role table that represents a tree structure </p> <pre><code>ID [INT] AUTO INCREMENT Name [VARCHAR] ParentID [INT] </code></pre> <p>I am using an ADO.NET DataTable and DataAdapter to load and save values to this table. This works if I only create children of existing rows. If I make a chil...
<p>I don't know ADO.net in particular, but most ORMs won't automatically insert the ID of a new record in a relationship. You'll have to resort to the 2-step process:</p> <ol> <li>build and save parent</li> <li>build and save child with relationship to parent</li> </ol> <p>The reason that this is difficult for ORMs ...
<p>Does it make any difference if you go</p> <pre><code>newRow.SetParentRow(parentRow, RoleTable.Relations("RoleToRole")) </code></pre>
2,724
<p>Does somebody know a Java library which serializes a Java object hierarchy into Java code which generates this object hierarchy? Like Object/XML serialization, only that the output format is not binary/XML but Java code.</p>
<p>Serialised data represents the internal data of objects. There isn't enough information to work out what methods you would need to call on the objects to reproduce the internal state.</p> <p>There are two obvious approaches:</p> <ul> <li>Encode the serialised data in a literal String and deserialise that.</li> <li...
<p>XStream is a serialization library I used for serialization to XML. It should be possible and rather easy to extend it so that it writes Java code.</p>
11,658
<p>How to disable standard ASP.NET handling of 401 response code (redirecting to login page) for AJAX/JSON requests?</p> <p>For web-pages it's okay, but for AJAX I need to get right 401 error code instead of good looking 302/200 for login page.</p> <p><strong>Update</strong>: There are several solutions from Phil Haa...
<p>The ASP.NET runtime is developed so that it always will redirect the user if the <code>HttpResponse.StatusCode</code> is set to 401, but only if the <code>&lt;authentication /&gt;</code> section of the Web.config is found.</p> <p>Removing the authentication section will require you to implement the redirection to t...
<p>You could choose to create a custom <code>FilterAttribute</code> implementing the <code>IAuthorizationFilter</code> interface.</p> <p>In this attribute you add logic to determine if the request are supposed to return JSON. If so, you can return an empty JSON result (or do whatever you like) given the user isn't sig...
15,049
<p>We put common prefixes on related tables to assure they display next to each other in our DB management software (Toad, Enterprise Manager, etc). </p> <p>So for example, all user tables start with the word User:</p> <ul> <li>User </li> <li>UserEvent </li> <li>UserPurchase</li> </ul> <p>Ideally, in honor of the <a...
<p>I tend to go against the grain in naming conventions on two counts here...</p> <ol> <li><p>I don't like using prefixes so that things group together in a given UI. To me the tables should be named such that in code they are easily readable and make sense. There have been numerous studies (mostly ignored by programm...
<p>I personally favor naming conditions similar to what you have listed there, as it is a very logical pattern, they are organized in a way that you can easily find them, and overall the extra bits of typing typically doesn't cause many issues or reductions in time.</p>
29,073
<p>I have some commits that I've decided, after the fact, are going to be more branch work then trunk work. How do I create the branch and revert the trunk while still ensuring merging isn't painful later?</p> <p>Is it as simple as copying the current trunk to a branch and reverting the trunk? Or will this create head...
<p>I think Philips method would be something like the following, assuming the last "good" revision was at 100 and you are now at 130, to create the new branch:</p> <pre><code>svn copy -r100 svn://repos/trunk svn://repos/branches/newbranch svn merge -r 100:130 svn://repos/trunk svn://repos/branches/newbranch </code></p...
<p>I don't have svn available right here but this is how I would try to do it :</p> <p>Determine the point in history where you started committing bad stuff (say revision "100" while you are at "130")</p> <pre><code>svn copy trunk branch # create your branch while preserving history svn copy trunk@100 trunk #replace ...
17,943
<p>We have an encryption service that we've exposed over net. tcp. Most of the time, the service is used to encrypt/decrypt strings. However, every now and then, we the need to encrypt large documents (pdf, JPG, bmp, etc.).</p> <p>What are the best endpoint settings for a scenario like this? Should I accept/return a s...
<p>MSDN describes <a href="http://msdn.microsoft.com/en-us/library/ms789010.aspx" rel="nofollow noreferrer">how to enable streaming over WCF</a> rather well. </p> <p>Note, if the link between client and server needs to be encrypted, then you'll need to "roll your own" encryption mechanism. The default <code>net.tcp</c...
<p>One pattern you could follow is to have an asynchronous service that works on files on a shared file system location:</p> <ol> <li>Place the file to be encrypted on a shared location</li> <li>Call the service and tell it to encrypt the file, passing both the location and name of the file, and the addres of a callba...
6,832
<p>I have the following code, which is the core part of my small AJAX application. I am not getting any errors, it is just that nothing happens. I am guessing there is a more efficient way to do what I am trying to do.</p> <p>Here is the code:</p> <pre><code>var xmlHttp var layername function update(layer, part, pk...
<p>Looks like you may have some javascript errors:</p> <pre><code>if (part=="1") { $url "get_auction.php?cmd=GetAuctionData&amp;pk="+pk+"&amp;sid="+Math.random() } else if (part=="2") { var url "get_records.php?cmd=GetRecordSet&amp;query="+query+"&amp;sid="+Math.random() } </code></pre> <p>Use Firefox and Ope...
<p><strong><code>json_encode</code> is a PHP function</strong>, and thus you need to modify that particular line like so:</p> <pre><code>child1.document.write(&lt;?php echo json_encode($row2["ARTICLE_DESC"]); ?&gt;); </code></pre>
46,388
<p>(Django 1.x, Python 2.6.x)</p> <p>I have models to the tune of:</p> <pre><code>class Animal(models.Model): pass class Cat(Animal): def __unicode__(self): return "This is a cat" class Dog(Animal): def __unicode__(self): return "This is a dog" class AnimalHome(models.Model): animal = models.Foreig...
<p>ForeignKey(Animal) is just that, a foreign key reference to a row in the Animal table. There's nothing in the underlying SQL schema that indicates that the table is being used as a superclass, so you get back an Animal object.</p> <p>To work around this:</p> <p>First, you want the base class to be non-abstract. Th...
<p>Regarding Generic Relations, note that normal Django queries cannot span GenerecForeignKey relations. Using multi-table inheritance avoids this issue at the cost of being a less generic solution.</p> <p>From the docs:</p> <blockquote> <p>Due to the way GenericForeignKey is implemented, you cannot use such fields...
40,352