instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I want to quickly test an ocx. How do I drop that ocx in a console application. I have found some tutorials in CodeProject and but are incomplete. </p>
<p>Sure..it's pretty easy. Here's a fun app I threw together. I'm assuming you have Visual C++.</p> <p>Save to test.cpp and compile: cl.exe /EHsc test.cpp</p> <p>To test with your OCX you'll need to either #import the typelib and use it's CLSID (or just hard-code the CLSID) in the CoCreateInstance call. Using #import...
<p>@orion thats so cool. Never thought of it that way.</p> <p>Well @jschroedl thats was fun indeed. </p> <p>Testing an activex in console app is fun. But I think its worth not trying down that path. You can call the methods or set and get the properties either through the way @jschroedl had explained or you can call ...
3,852
<p>I have the following problem:</p> <p>I open the dialog, open the SIP keyboard to fill the form and then minimize the SIP. Then when I close the current dialog and return to the main dialog the SIP keyboard appears again. Does anyone know how could I show/hide SIP keyboard programatically or better what could be don...
<p>You'll want to call <strong>SipShowIM</strong>() in coredll. See this MSDN article:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms838341.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms838341.aspx</a></p>
<p>You can use the Microsoft.WindowsCE.Forms.InputPanel component. You can show/hide the SIP programmatically using the Enabled property. There is an InputPanel component at the toolbox.</p> <p>There is also an EnabledChanged event for the InputPanel that you can handle. You usually want to show the SIP at a GetFocus ...
41,932
<p>I'm working on a billing system for a utility company, and we have the following requirements:</p> <ul> <li>Batch-generate and print approximately 1,500 bills per day that we then mail to customers</li> <li>Save the bill in a format that can emailed to the customer and also archived (probably PDF)</li> <li>Built wi...
<p>If you are using a SQL Server backend, Reporting Services should work for you.</p> <p>Otherwise I would recommend a third-party report generator that fits your reporting needs and create an app that uses it to create &amp; export the reports.</p>
<p>Maybe you should try with ActiveReports.NET or DevExpress XtraReports to generate the reports first by code. Both have PDF export support so you can generate PDF files and send them by mail.</p>
14,264
<p>I have a form that uses jQuery to submit an ajax post and it serializes the form that is sent up. The code looks like this:</p> <pre><code>var form = $("form"); var action = form.attr("action"); var serializedForm = form.serialize(); $.post(action, serializedForm, function(data) { ... }); </code></pre> <p>The pr...
<p>You could try looping through the object and triming everything.</p> <pre><code>//Serialize form as array var serializedForm = form.serializeArray(); //trim values for(var i =0, len = serializedForm.length;i&lt;len;i++){ serializedForm[i] = $.trim(serializedForm[i]); } //turn it into a string if you wish serializ...
<p>Neither of those solutions work, since they actually change the form fields on the page. I just want to modify the value of the field that without changing what the user typed in.</p>
26,923
<p>We have recently migrated a large, high demand web application to Tomcat 5.5 from Tomcat 4 and have noticed some peculiar slowdown behavior that appears to be related to JVM pauses. In order to run our application and support increased load over time on Tomcat 4, many not so standard JVM parameters were set and tun...
<p>One of the Java Champions, Kirk Pepperdine's blog : <a href="http://kirk.blog-city.com/how_to_cripple_gc_ergonomics.htm" rel="noreferrer">http://kirk.blog-city.com/how_to_cripple_gc_ergonomics.htm</a>. <br> Quote 1 "GC documentation will tell you what the setting affects but often without telling what the effect wil...
<p>It may also be worth experimenting with an alternative JVM (like JRockit) to see if the differences in the garbage collection model are well suited to your application.</p>
24,763
<p>I have a need to convert Pixels to Points in C#. I've seen some complicated explanations about the topic, but can't seem to locate a simple formula. Let's assume a standard 96dpi, how do I calulate this conversion?</p>
<p>There are <a href="http://en.wikipedia.org/wiki/Point_%28typography%29" rel="noreferrer">72 points per inch</a>; if it is sufficient to assume 96 pixels per inch, the formula is rather simple:</p> <p>points = pixels * 72 / 96</p> <p>There is a way to get the configured pixels per inch of your display in Windows us...
<p>Height lines converted into points and pixel (my own formula). Here is an example with a manual entry of 213.67 points in the Row Height field:</p> <pre class="lang-none prettyprint-override"><code>213.67 Manual Entry 0.45 Add 0.45 214.12 Subtotal 213.75 Round to a multiple of 0.75 213.00 Subtra...
16,892
<p>The title sort of explains itself. I am making some 'genrative' artwork in flash. Now I want to save the frame without making a screenshot so-on and sofort. And perhaps one day i would like to save a batch of frames. </p> <p>Is there an AS3 class/library out there that could help me out ?</p>
<p>Actually, using the just released Flash 10, you CAN save to the HD! It's very handy, for just this situation. It's perfectly secure, because it only lets you save a file after the user clicks 'Save' in the file dialog, you can't just go writing files willy-nilly. Also, there is code out there already written that al...
<p>Do you want to save the file to a hard-drive or to a website?</p> <p>If to a hard-drive, you might have a hard time unless you're open to using Air. Because of the security sandbox of Flash, you can't write arbitrary files to the user's hard disk. </p> <p>If you absolutely must save it to a user's hard-drive using...
34,416
<p>After successfully building dblink on solaris 10 using Sun C 5.9 SunOS_sparc 2007/05/03 and gmake.</p> <p>I ran gmake installcheck and got the following output:</p> <pre><code>========== running regression test queries ========== test dblink ... FAILED ====================== 1 of 1 tests f...
<p>To solve this issue I tried using the 8.2 dblink sources, instead of the latest version.</p> <p>You also need to make sure you use gnu make not the sun make.</p>
<p>Does the file it is looking for actually exist? Is it in that location?</p> <p>It may be one of a few things I can think of: 1) The thing did not compile, and therefore does not exist. 2) It exists, but somewhere else, and the environment variable that tells it where to find it is set wrong. 3) The permissions...
9,539
<p>we all writing code for single processor. i wonder when we all are able to write code on multi processors?</p> <p>what do we need (software tools, logic, algorithms) for this switching?</p> <p>edit: in my view, as we do many task parallely, same way we need to convert those real life solutions(algorithms) to compu...
<p>I think the most important requirement is a good language that has native constructs that support parallelism or one that can automatically generate parallel code. There are quite a few languages that fit that description, but none of them is popular enough to really be considered for mainstream use. That, in turn i...
<p>There is no simple answer, and in many ways even the complex answers are currently inadequate or incomplete. You'll get a better answer if you are more specific about the replies you want: pointers to dev libraries and tools, instructional materials, pointers to current research projects and issues in this area, or...
11,570
<p>I'm trying to create a query which uses a list of ids in the where clause, using the Silverlight ADO.Net Data Services client api (and therefore Linq To Entities). Does anyone know of a workaround to Contains not being supported?</p> <p>I want to do something like this:</p> <pre><code>List&lt;long?&gt; txnIds = ne...
<p><strong>Update:</strong> EF ≥ 4 supports <a href="http://msdn.microsoft.com/en-us/library/bb352880.aspx" rel="noreferrer" title="Enumerable.Contains&lt;T&gt;"><code>Contains</code></a> directly (Checkout <a href="http://msdn.microsoft.com/en-us/library/bb534972.aspx" rel="noreferrer" title="Enumerable.Any&lt;T&gt;">...
<p>Here's an example where I demonstrate how to write set-based queries using the DataServiceContext : <a href="http://blogs.msdn.com/phaniraj/archive/2008/07/17/set-based-operations-in-ado-net-data-services.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/phaniraj/archive/2008/07/17/set-based-operations-in-ado-ne...
48,945
<p>I am new to Python, and I'm working on writing some database code using the <code>cx_Oracle</code> module. In the <a href="http://cx-oracle.sourceforge.net/html/module.html" rel="nofollow noreferrer">cx_Oracle documentation</a> they have a code example like this:</p> <pre><code>import sys import cx_Oracle connect...
<pre><code>error, = exc.args </code></pre> <p>This is a case of <a href="http://docs.python.org/tutorial/datastructures.html#tuples-and-sequences" rel="noreferrer">sequence unpacking</a>.</p> <p>A more readable way to write the same, and the style I personally favor, is:</p> <pre><code>[error] = exc.args </code></pr...
<p>The comma serves to unpack the tuple, i.e. it extracts the single item of the tuple, and binds it to <code>error</code>. Without the comma, you would bind the tuple itself, rather than its content.</p>
39,014
<p>In Informix, how can I cast a <code>char(8)</code> type into a <code>money</code> type, so that I can compare it to another <code>money</code> type?</p> <p>Using "<code>tblAid.amt::money as aid_amt</code>" did not work. Using "<code>(tblAid.amt * 1) AS aid_amt</code>" did not work.</p>
<p>try this --> </p> <pre><code>select (disb_amt::NUMERIC) disb_amt from tmp_kygrants; </code></pre> <p>You may be able to compare the amounts as numeric.</p>
<p>'tis been a while since I played around with informix and I don't have a running instance handy at the moment. However, there are two things that can cause a problem here:</p> <p>1) since it is a char(8) it can contain values that can not be casted to numeric without a bit of 'cleanup'. E.g. "abc". Or "1,234,567.00...
21,474
<p>I guess this topic is often overseen, but is rather useful when debugging your code. Just today I have stumbled across this simple yet effective visualizer that visualizes images (it's on a german blog, but I guess the code content is self-explanatory):</p> <p><a href="http://blogs.msdn.com/dparys/archive/2007/10/2...
<p>I use <a href="http://karlshifflett.wordpress.com/mole-for-visual-studio/" rel="noreferrer">Mole</a>.</p> <blockquote> <p>Mole was designed to not only allow the developer to view objects or data, but to also allow the developer to drill into properties of those objects and then edit them. Mole allows u...
<p>There was a sample on an MSDN blog for the Microsoft.Xna.Framework.Matrix, I think it was. I later made my own, but it was still good.</p>
12,584
<p>I have a database with two tables (<code>Table1</code> and <code>Table2</code>). They both have a common column <code>[ColumnA]</code> which is an <code>nvarchar</code>. </p> <p>How can I select this column from both tables and return it as a single column in my result set?</p> <p>So I'm looking for something like...
<pre><code>SELECT ColumnA FROM Table1 UNION Select ColumnB FROM Table2 ORDER BY 1 </code></pre> <p>Also, if you know the contents of Table1 and Table2 will <strong>NEVER</strong> overlap, you can use UNION ALL in place of UNION instead. Saves a little bit of resources that way.</p> <p>-- Kevin Fairchild</p>
<p>You can use a union select: </p> <pre><code>Select columnA from table1 union select columnA from table2 </code></pre>
6,588
<p>I am working on a Windows Forms app for quite some time now, and I really find myself doing more typecasts in the GUI code than I ever did in my underlying business code.</p> <p>What I mean becomes apparent if you watch the ComboBox control that accepts some vague "object" as it's item. Then you go off and may dis...
<p>While the criticism of "didn't use generics" can't be fairly applied to controls developed before their existence... one must wonder about WPF controls (new in .NET 3.0, after generics in .NET 2.0).</p> <p>I checked out the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.addchi...
<p>I dont think you're missing anything. It's just that these classes were created back in the pre-Generics days, and WinForms is simply not cutting edge enough for MS to spend a lot of time changing or extending the API.</p>
42,930
<p>I've recently started using Eclipse Ganymede CDT for C development and I couldn't like it more. I'm aware the learning curve could be sort of pronounced, therefore and with your help, my goal is to flatten it as much as possible. I'm looking for the best hacks, hints, tips, tricks, and best practices to really unlea...
<p><strong>Accurate Indexing</strong></p> <p>With CDT you should be sure to enable the &quot;Full Indexing&quot; option rather than the &quot;Fast Indexing&quot; default. It's not perceptibly slower on modern hardware and it does a much better job. In that vein, you should be sure to enable semantic highlighting. Th...
<p><strong>If the Java Developer Tools aren't installed the Spellcheck won't work.</strong></p> <p>The Spellcheck functionality is dependent upon the Java Development Tools being installed. This can be a perplexing issue if you just install the C Development Tools exclusively, because it gives no reason for the Spell ...
9,469
<p>i'm wondering if there is any nice and neat tool to replace the GNU Autotools or Make to build a very large C++ project, which are such a complicated thing to use. </p> <p>It is simple to generate all the files that de Autotools require if the project is small, but if the source code is divided in many directories,...
<p>The <a href="http://code.google.com/p/v8/" rel="noreferrer">Google V8 JavaScript Engine</a> is written in C++ and uses <a href="http://www.scons.org/" rel="noreferrer">SCons</a>, so I guess that's one vote for it.</p>
<p>I use <a href="http://www.bakefile.org/index.html" rel="nofollow noreferrer">bakefile</a> for my build process and I became a big fan!</p> <p>I never have to write a Makefile myself anymore, let alone horrible GNU autotools scripts. All I have to do is provide an <code>XML</code> file that describes the build targe...
7,827
<p>Many frameworks seek to abstract away from HTML (custom tags, JSFs component system) in an effort to make dealing with that particular kettle of fish easier.</p> <p>Is there anything you folks have used that has a similar concept applied to CSS? Something that does a bunch of cross-browser magic for you, supports l...
<p>What I found works best is to really learn CSS. I mean <strong>really</strong> learn CSS.</p> <p>It can be a confusing language to learn, but if you read enough about it and practice, eventually you'll learn the best way to do things.</p> <p>The key is to do it enough that it comes natural. CSS can be very elegant...
<p>CSS takes a bit of time to learn, but the thing I initially found most discouraging was the fact that so many hacks were needed to get all browsers to behave the same way. Learning a system which doesn't adhere to logic seems dumb... but I've clung to the vague belief that there is logic behind each browser's idios...
4,507
<p>I have an existing website that uses the same code base, but is deployed in a number of different configurations on different servers. Each configuration has a set of users, and they can upload personal files. The files are stored in an "uploaded files" directory on each server, and this directory is stuck in right ...
<p>Don't check it in that way you can't overwrite anything. For config.ini files and the like you can store a template version with a different name (ie. config.ini.tmpl) in your repository that won't overwrite the actual file. </p> <p>Add the folder/files to your svn ignore so you don't check them in by accident.</...
<p>Just don't store that folder in your repository, eg. never check that folder in. I don't really see a problem here...</p>
28,592
<p>I'm writing a C# application which downloads a compressed database backup via FTP. The application then needs to extract the backup and restore it to the default database location.</p> <p>I will not know which version of SQL Server will be installed on the machine where the application runs. Therefore, I need to f...
<p>What I discovered is that </p> <pre><code>Microsoft.SqlServer.Management.Smo.Server(ServerName).Settings.DefaultFile </code></pre> <p>only returns non-null when there is no path explicitly defined. As soon as you specify a path which is not the default, then this function returns that path correctly.</p> <p>So, ...
<p>One option, that may be a simpler solution, is to create a new database on your destination server and then RESTORE over that database with your backup. Your backup will be in the right place and you will not have to fuss with "MOVING" the backup file when you restore it. SQL expects backups to be restored to exac...
8,854
<p>I am using Oracle adapter from the BizTalk Adapter Pack (WCF based for BTS 2006 R2). In the configuration of the "solicit-response" send ports, I have used Oracle's username and password to connect to the database. </p> <p>Now I would like to change that and use the SSO. So far I have created the Affiliate applicat...
<p>You can add an SSO ticket in a custom pipeline component on the send port. The following code works for me:</p> <pre><code> public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) { ISSOTicket ssoTicket = new ISSOTicket(); pInMsg.Context.Write("SSOTicket", "http://schemas....
<p>You might need to "Allow tickets" to the System properties in SSO Administrator. Without that it will not work even if you allow tickets to the Affiliate Application.</p>
24,287
<p>I've seen examples like this: </p> <pre><code>public class MaxSeconds { public static final int MAX_SECONDS = 25; } </code></pre> <p>and supposed that I could have a Constants class to wrap constants in, declaring them static final. I know practically no Java at all and am wondering if this is the best way to c...
<p>That is perfectly acceptable, probably even the standard.</p> <pre><code>(public/private) static final TYPE NAME = VALUE; </code></pre> <p>where <code>TYPE</code> is the type, <code>NAME</code> is the name in all caps with underscores for spaces, and <code>VALUE</code> is the constant value;</p> <p>I highly recom...
<p>I wouldn't call the class the same (aside from casing) as the constant ... I would have at a minimum one class of "Settings", or "Values", or "Constants", where all the constants would live. If I have a large number of them, I'd group them up in logical constant classes (UserSettings, AppSettings, etc.)</p>
9,174
<p>I am building a java server that needs to scale. One of the servlets will be serving images stored in Amazon S3.</p> <p>Recently under load, I ran out of memory in my VM and it was after I added the code to serve the images so I'm pretty sure that streaming larger servlet responses is causing my troubles.</p> <p>M...
<p>When possible, you should not store the entire contents of a file to be served in memory. Instead, aquire an InputStream for the data, and copy the data to the Servlet OutputStream in pieces. For example:</p> <pre><code>ServletOutputStream out = response.getOutputStream(); InputStream in = [ code to get source in...
<p>You have to check two things:</p> <ul> <li>Are you closing the stream? Very important</li> <li>Maybe you're giving stream connections "for free". The stream is not large, but many many streams at the same time can steal all your memory. Create a pool so that you cannot have a certain number of streams running at th...
7,952
<p>I am absolutely new to the .NET world, and started with C# on friday. I have some experience with database apps, though.</p> <p>We will go with LINQ-to-SQL for a medium scale project. I am used to generating my schema from classes and keep track of changes with subversion and equivalents to Ruby's Migrations. There...
<p>This <a href="http://blog.huagati.com/res/index.php/2008/07/17/tools-part-2-add-ins-dbml-synchronization-add-in-updated/" rel="nofollow noreferrer">tool</a> will help sync them, but I'm unsure if it'll show differences...may be of some use though. (:</p> <p>EDIT: As <a href="https://stackoverflow.com/users/11241/kr...
<p>This <a href="http://blog.huagati.com/res/index.php/2008/07/17/tools-part-2-add-ins-dbml-synchronization-add-in-updated/" rel="nofollow noreferrer">tool</a> will help sync them, but I'm unsure if it'll show differences...may be of some use though. (:</p> <p>EDIT: As <a href="https://stackoverflow.com/users/11241/kr...
38,173
<p>I can get simple examples to work fine as long as there's no master page involved. All I want to do is click a button and have it say "hello world" with the javascript in a .js file, using a master page. Any help very much appreciated :)</p>
<p><strong>EDIT</strong></p> <p>As @Adam points out in the comments, there is a native jQuery mechanism that basically does the same thing as the hack in my original answer. Using jQuery you can do</p> <pre><code> $('[id$=myButton]').click(function(){ alert('button clicked'); }); </code></pre> <p>My hack was origi...
<p>I also started with the simplest of examples and had no luck. I finally had to add the jquery .js file <em>outside</em> of the <code>&lt;head&gt;</code> section of the master page. It was the only way I could get anything to work in Firefox (haven't tried other browsers just yet).</p> <p>I also had to reference the...
37,358
<p>Where does Firefox store cookies and in what format are they stored</p>
<h1>For Windows</h1> <p>Your cookies are stored in:</p> <ul> <li>In Firefox 2.x: plain text file (<code>cookies.txt</code>) in a unix-format text file (eg LF instead of CRLF for newlines).</li> <li>In Firefox 3.0 and up: a binary file representing <a href="http://www.webdevbros.net/2008/07/31/query-your-firefox-cookies...
<p>The directory depends on your OS, but they appear to be stored in a SQLite database.</p>
38,812
<p>I am attempting to find xml files with large swaths of commented out xml. I would like to programmatically search for xml comments that stretch beyond a given number of lines. Is there an easy way of doing this?</p>
<p>Considering that XML doesn't use a line based format, you should probably check the number of characters. With a regular expression, you can create a pattern to match the comment prefix and match a minimum number of characters before it matches the first comment suffix.</p> <p><a href="http://www.regular-expression...
<p>I'm using this application to test the regex:</p> <p><a href="http://www.regular-expressions.info/dotnetexample.html" rel="nofollow noreferrer">http://www.regular-expressions.info/dotnetexample.html</a></p> <p>I have tested it against some fairly good data and it seems to be pulling out only the commented section....
11,179
<p>Can somebody in SO please provide me with a list of resources about Enterprise Mashups and technologies related to SharePoint platform?</p> <p><strong>Update</strong> (as per suggestion of @Spoon16 in the comments):- The mashup application may typically retrieve a list of contacts from a SharePoint site and display...
<p>There are a number of different ways to pull external information into SharePoint.</p> <p>For mashing up SharePoint data in external applications:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/ms479390.aspx" rel="nofollow noreferrer">Web Services</a>; great web services coverage for the underlying ...
<p>Also it is possible to customize List View in order to render Map using <a href="https://developers.google.com/maps/documentation/javascript/" rel="nofollow noreferrer">Google Maps</a>.</p> <h2>Solution description</h2> <p>For storing geographical locations and visualizing it on Map is used Custom List. Custom Lis...
12,557
<p>I'd like to upload (via ftp) a website when doing a release build in visual studio 2008. I don't want any source code files to be uploaded and it would be nice to configure which folders should get uploaded. I'm using either ASP.NET Web Applications or MVC. How do I configure VS.NET to automatically upload (and o...
<p>You can use the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&amp;displaylang=en" rel="nofollow noreferrer">Visual Studio Web Deployment Project</a> Add In from Microsoft.</p> <p>I use this with MSBuild as part of CruiseControl, its very nice, and with some o...
<p>Or you can use nant</p>
24,888
<p>If I click on File -> Close, it closes the buffer like I want, but doesn't list a key mapping. What is the key mapping?</p>
<p>You can use <code>C-x k</code> to kill current buffer. See <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Kill-Buffer.html">Emacs Manual</a> .</p>
<ol> <li><code>C-x k</code> to kill the current buffer.</li> <li><code>C-x 0</code> to close the current window.</li> <li><code>C-x 1</code> to close every other window.</li> </ol>
25,426
<p>I have around 1000 pdf filesand I need to convert them to 300 dpi tiff files. What is the best way to do this? If there is an SDK or something or a tool that can be scripted that would be ideal. </p>
<p>Use Imagemagick, or better yet, Ghostscript.</p> <p><a href="http://www.ibm.com/developerworks/library/l-graf2/#N101C2" rel="noreferrer">http://www.ibm.com/developerworks/library/l-graf2/#N101C2</a> has an example for imagemagick:</p> <pre><code>convert foo.pdf pages-%03d.tiff </code></pre> <p><a href="http://www...
<p>I like PDFTIFF.com to <a href="http://www.pdftiff.com" rel="nofollow noreferrer">convert PDF to TIFF</a>, it can handle unlimited pages</p>
10,114
<p>Are there any industry standard conventions for naming jar files?</p>
<p>I have been using </p> <pre><code>*Informative*-*name*-*M*.*m*.*b*.jar </code></pre> <p>Where:</p> <p><em>M</em> = <code>major version number</code> (changed when backward compatibility is not necessarily maintained)</p> <p><em>m</em> = <code>minor version number</code> (feature additions etc)</p> <p><em>b</em...
<p>If your jar is used for JEE then <a href="http://www.oracle.com/technetwork/java/namingconventions-139351.html" rel="nofollow">these guidelines</a> apply:</p> <blockquote> <p>The module name is used as the EJB archive name. By default, the module name should be based on the package name and should be written ...
14,525
<p>We have a project page which consists of users' files, multimedia stuff, etc and we want to allow the user to export all this out into a single zip file. We're using unix and mysql to store all of these currently and our primary goal is to minimize load/performance time from all the processing and compiling all the ...
<p>This reaks of premature optimization, just use a very light compression, aka 'fastest' and worry about the speed if it's actually a problem.</p>
<p>If bandwidth/download speed is not a concern, I recommend you use an uncompressed tar file. TAR is a very simple format, so it will be easy to write code to update sections of it when a few of the files have changed. Also, leaving it uncompressed will be a huge win on server CPU time.</p> <p>Of course, leaving it ...
37,619
<p>Eclipse is a really great editor, which I prefer to use, but the GUI design tools for Eclipse are lacking. On the other hand, NetBeans works really well for GUI design. </p> <p>Are there any tips, tricks or pitfalls for using NetBeans for GUI design and Eclipse for everything else on the same project?</p> <p><st...
<p>Create your GUI with Netbeans. copy a Eclipse .project file (like below) into the project folder change the MyProjectName. Open Eclipse and import the project into your workspace, so you can open the projekt from your Eclipse workspace with Netbeans. Now you able to use Netbeans to create and change the GUI and edit...
<p>For me using linked source folders works quite well. </p> <p>I build the GUIs in independent NetBeans projects - if they need some simple classes or interfaces, I use the "link source" (right click on project in NetBeans, choose properties), to include these in the NetBeans project.</p> <p>My main projects are in ...
21,001
<p>How do I return a constant from an sql statement? </p> <p>For example how would I change the code below so "my message" would return if my (boolean expression) was true</p> <pre><code>if (my boolean expression) "my message" else select top 1 name from people; </code></pre> <p>I am using ms sql 2000</p>
<p>Did you try:</p> <pre><code>select 'my message'; </code></pre>
<p>I just tried this on the AdventureWorks database and it works</p> <pre><code>Use AdventureWorks Declare @myVar int SET @myVar = 1 if (@myVar = 2) select top 2 * from HumanResources.Department else select top 1 * from HumanResources.Department </code></pre>
39,075
<p>I need to set a system environment variable from a Bash script that would be available outside of the current scope. So you would normally export environment variables like this:</p> <pre><code>export MY_VAR=/opt/my_var </code></pre> <p>But I need the environment variable to be available at a system level though. ...
<p>Not really - once you're running in a subprocess you can't affect your parent.</p> <p>There two possibilities:</p> <ol> <li><p><a href="https://en.wikipedia.org/wiki/Dot_(command)#Source" rel="nofollow noreferrer">Source</a> the script rather than run it (see <a href="http://www.gnu.org/software/bash/manual/bashref....
<p>You may want to use source instead of running the executable directly:</p> <pre class="lang-bash prettyprint-override"><code># Executable : exec.sh export var=&quot;test&quot; invar=&quot;inside variable&quot; </code></pre> <pre class="lang-bash prettyprint-override"><code>source exec.sh echo $var # test echo $in...
39,522
<p>I have the problem, that PHP replaces all spaces with underscores in POST and GET variables.</p> <p>For example if I have the URL: <code>http://localhost/proxy.php?user name=Max</code> the browser will convert it to <code>http://localhost/proxy.php?user%20name=Max</code>.</p> <p>But if I give the $_GET parameters ou...
<p>From the <a href="http://www.php.net/manual/en/language.variables.external.php" rel="noreferrer">PHP manual</a>:</p> <blockquote> <p>Dots in incoming variable names</p> <p>Typically, PHP does not alter the names of variables when they are passed into a script. However, it should be noted that the dot (...
<p>As far as i can remember, i've never seen spaces in URL parameter names...</p> <p>I think, it would be better to convert all spaces of parameter names into "_".</p>
35,985
<p>What is preferable, keeping a dataset in session or filling the dataset on each postback?</p>
<p>That would depend on many factors. It is usually best not to keep too many items in session memory if your session is inproc or on a state server because it is less scalable. </p> <p>If your session resides on the database, it might be better to just requery and repopulate the dataset unless the query is costly to ...
<p>Keep in session. Have option to repopulate if you need to, for example if the session memory is wiped.</p>
31,910
<p>I have a little utility that does a search of a number of files. I had to create it because both Google &amp; Windows desktop searches were not finding the appropriate lines in files. The searching works fine (I am willing to improve on it) but one of the things I would like to add to my util is a batch find/replace...
<p>I would do the following for each file:</p> <ul> <li>Do the search as normal. Also check for the token to replace. As soon as you've seen it, start that file again. If you don't see the token to replace, you're done.</li> <li>When you start again, create a new file and copy each line that you read from the input fi...
<p>If PowerShell is an option, the function defined below can be used to perform find and replace across files. For example, to find <code>'a string'</code> in text files in the current directory, you would do:</p> <pre><code>dir *.txt | FindReplace 'a string' </code></pre> <p>To replace <code>'a string'</code> with ...
44,460
<p>Following on from my recent question on <a href="https://stackoverflow.com/questions/17725/large-complex-objects-as-a-web-service-result">Large, Complex Objects as a Web Service Result</a>. I have been thinking about how I can ensure all future child classes are serializable to XML.</p> <p>Now, obviously I could imp...
<p>I'd write a unit/integration test that verifies that any class matching some given criteria (ie subclassing X) is decorated appropriately. If you set up your build to run with tests, you can have the build fail when this test fails.</p> <p>UPDATE: You said, "Looks like I will just have to roll my sleeves up and mak...
<p>A good FXCop rule (and one which I am finding I need right now) would be to check that all objects that are being added to the ASP.NET Session have the Serializable attribute. I'm trying to move from InProc session state to SQL Server. First time I requested a page, my site blew up on me because non-serializable o...
3,992
<p>got a new blog at wordpress few days ago (<a href="http://ghads.wordpress.com" rel="noreferrer">http://ghads.wordpress.com</a>) and I want to post some code snippets now or then. Is there anyway to make it look like code without paying for extra plugins?</p>
<p>See here: <a href="http://en.support.wordpress.com/code/posting-source-code/" rel="noreferrer">http://en.support.wordpress.com/code/posting-source-code/</a></p> <p>Wrap your code in these tags: [sourcecode language='css'] .. [/sourcecode]</p> <p>(or shorter [code lang='css'] .. [/code] )</p> <p>Note that Visual E...
<p>If you are hosting your own wordpress blog opposed to on WP.com you can get this functionality by installing this plugin, since it is the same plugin that the WP.com code relies on.</p> <p><a href="http://wordpress.org/extend/plugins/google-syntax-highlighter/" rel="nofollow noreferrer">http://wordpress.org/extend/...
10,696
<p>As I sometimes have path problems, where one of my own cmd scripts is hidden (shadowed) by another program (earlier on the path), I would like to be able to find the full path to a program on the Windows command line, given just its name.</p> <p>Is there an equivalent to the UNIX command 'which'?</p> <p>On UNIX, <...
<p>Windows Server 2003 and later (i.e. anything after Windows XP 32 bit) provide the <code>where.exe</code> program which does some of what <code>which</code> does, though it matches all types of files, not just executable commands. (It does not match built-in shell commands like <code>cd</code>.) It will even accept...
<p>Here is a function which I made to find executable similar to the Unix command 'WHICH`</p> <p><strong>app_path_func.cmd:</strong></p> <pre><code>@ECHO OFF CLS FOR /F &quot;skip=2 tokens=1,2* USEBACKQ&quot; %%N IN (`reg query &quot;HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\%~1&quot; /t REG_SZ /v &quo...
39,101
<p>Someone asserted on SO today that you should never use anonymous namespaces in header files. Normally this is correct, but I seem to remember once someone told me that one of the standard libraries uses anonymous namespaces in header files to perform some sort of initialization.</p> <p>Am I remembering correctly? ...
<p>The only situation in which a nameless namespace in header can be useful is when you want to distribute code as header files only. For example, a large standalone subset of Boost is purely headers.</p> <p>The token <code>ignore</code> for tuples, mentioned in another answer is one example, the <code>_1</code>, <cod...
<p>If it's initialization, it would likely be an <code>iostream</code>s header (like <code>istream</code>, <code>ios</code>, etc.).</p>
46,624
<p>Is it possible to use <a href="http://subversion.apache.org/" rel="noreferrer">Apache Subversion</a> (SVN) as general purpose backup tool? (As a kind of <a href="http://en.wikipedia.org/wiki/Rsync" rel="noreferrer">rsync</a> alternative.)</p>
<p>I found this article to be a pretty cool description of using svn to backup your home directory, and more:</p> <blockquote> <p>I use Subversion to backup my Linux boxes. With some minor creativity, it easily covers:</p> <ul> <li>Daily snapshots and offsite backup.</li> <li>Easy addition and removal of files and fold...
<p>I've used CVS as a substitute for ghost so I don't see why not.</p> <p>I'ts nice as you can tag a baseline: you can change manage machines.</p> <p>This works better on unixes than windows, obviously.</p>
8,720
<p>For the past few years whenever I learn something I tend to spend way too much time researching on the best materials for the subject than actually studying it. What should I do to get over this mentality? I am stuck. How to stop worrying about getting or using the BEST books, training videos and online materials on...
<p>Start doing a project with a deadline. You will code and learn together. If you cannot do that at work, think of a hobby project with some real requirements (like building a photo sharing site).</p>
<p>When you work at a new job, you learn a lot because you have great individuals who transfer a lot of knowledge they find useful. You can review how they do things, which parts are done well and which parts are done poorly.</p> <p>Learning by isolation is hard especially when there are so many resources out there.<...
24,699
<p>In short: I'm trying to figure out if I should tell a mail administrator of a friend's employer whether their mail configuration should be fixed, or if I should revise my own policy to be more liberal in what I accept, or neither.</p> <p>A friend was complaining of being unable to reach anything on my mailserver. ...
<p>SMTP RFCs do not require it, but lots of popular systems will reject mail with bogus HELOs. Note that RFC 1033 and RFC 1912 both require all internet-reachable hosts to have a valid name; simply listing that name in the HELO will fix many problems. Some spam filters, unfortunately, also reject mail from hostnames co...
<p>Eh, I disagree. It can provide total garbage within the EHLO/HELO if it wants to. As long as it says something, <em>and</em> as long as I can resolve the ip address it's coming from, I'm happy.</p> <p>Inside the EHLO is often a short hostname, not a FQDN.</p>
12,263
<p>I'm looking for a simple solution for a yes/no dialog to use in a Java ME midlet. I'd like to use it like this but other ways are okey.</p> <pre><code>if (YesNoDialog.ask("Are you sure?") == true) { // yes was chosen } else { // no was chosen } </code></pre>
<p>You need an <a href="http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Alert.html" rel="nofollow noreferrer">Alert</a>:</p> <blockquote> <p>An alert is a screen that shows data to the user and waits for a certain period of time before proceeding to the next Displayable. An alert can contai...
<p>I dont have programed in Java ME, but i found in it's reference for optional packages the <a href="http://java.sun.com/javame/reference/apis/jsr209/" rel="nofollow noreferrer">Advanced Graphics and User Interface API</a>, and it's used like the Java SE API to create these dialogs with the <a href="http://java.sun.co...
8,108
<p>What I have so far is </p> <pre><code>#!/bin/sh php_syntax_check() { retval=0 for i in $(git-diff-index --name-only --cached HEAD -- | grep -e '\.php$'); do if [ -f $i ]; then output=$(php -l $i) retval=$? if [ $retval -gt 0 ]; then echo "========...
<p>If the commit is a partial commit (not all the changes in the working tree are committed), then this make give incorrect results since it tests the working copy and not the staged copy.</p> <p>One way to do this could be:</p> <pre><code>git diff --cached --name-only --diff-filter=ACMR | xargs git checkout-index --...
<p>If you've got the php5-cli installed you can write your pre-commit in PHP and use the syntax your more familiar with.</p> <p>Just do something more like.</p> <pre><code>#!/usr/bin/php &lt;?php /* Your pre-commit check. */ ?&gt; </code></pre>
6,499
<p>How can one determine, in code, how long the machine is locked?</p> <p>Other ideas outside of C# are also welcome.</p> <hr> <p>I like the windows service idea (and have accepted it) for simplicity and cleanliness, but unfortunately I don't think it will work for me in this particular case. I wanted to run this on...
<p>I hadn't found this before, but from any application you can hookup a SessionSwitchEventHandler. Obviously your application will need to be running, but so long as it is:</p> <pre><code>Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch); void Sys...
<p>Below is the 100% working code to find if the PC is locked or not.</p> <p>Before using this use the namespace <code>System.Runtime.InteropServices</code>.</p> <pre><code>[DllImport("user32", EntryPoint = "OpenDesktopA", CharSet = CharSet.Ansi,SetLastError = true, ExactSpelling = true)] private static extern Int32 ...
6,677
<p>I'm running my workstation on Server 2008 and a few servers in Hyper-V VM's on that server. I connect to my corporate LAN using VPN from the main OS (the host) but my VM's aren't seeing the servers in the corporate LAN. Internet and local access to my home network work fine. Each of the VMs has one virtual network a...
<p>Like I said you need to setup some routes. Add a route to your Corp LAN via your Host as the gateway. Just the fact alone you telling me that it gets it from home DHCPP tells me that is the issue. Your VM's only see 1 default gateway, and that is to the internet. The VM's have no idea whatsoever that the Host has a ...
<p>Setup some routes in your routing tablke. It really depends on how its setup but if you can access your corp network fine on the host, then setup the routes in your vm machines.</p> <p>Also, as I am not familiar with that VM, are the network adapters like VMWares bridged adapaters? If so you need to setup the route...
15,139
<p>So what is the easiest way to accomplish this?</p>
<p>We use <a href="http://www.statsvn.org/" rel="nofollow noreferrer">StatSVN</a> and set up a scheduled task to create nightly reports.</p>
<p>Path of least resistance is to download <a href="http://tortoisesvn.tigris.org/" rel="nofollow noreferrer">Tortoise</a>, which supports this out of the box. </p> <p>From their features page:</p> <blockquote> <p>Can create a graph of all revisions/commits. You can then easily see where you created a tag/bra...
28,888
<p>Here is what I am trying to do: Given a date, a day of the week, and an integer <code>n</code>, determine whether the date is the <code>n</code>th day of the month.</p> <p>For example:</p> <ul> <li><p>input of <code>1/1/2009,Monday,2</code> would be false because <code>1/1/2009</code> is not the second Monday</p><...
<p>You could change the check of the week so the function would read:</p> <pre><code>private bool NthDayOfMonth(DateTime date, DayOfWeek dow, int n){ int d = date.Day; return date.DayOfWeek == dow &amp;&amp; (d-1)/7 == (n-1); } </code></pre> <p>Other than that, it looks pretty good and efficient.</p>
<p>In <a href="https://stackoverflow.com/questions/288513/how-do-i-determine-if-a-given-date-is-nth-weekday-of-the-month/288542#288542">this answer</a>, the following code needs to be flipped:</p> <pre><code>// Complete the gap to the nth week dt = dt.AddDays((nth - 1) * 7); if(dt.Month != month) { // we skip to the ...
36,729
<p>I have a .net client application which is connected to a remote database. Is it safe to keep a single connection open for the lifetime of the client (hours)?</p> <p>Does the answer hold if I have multiple (10 or 100) clients running?</p>
<p>Absolutely it is safe to do this. This is how client-server applications work. If you are using a three-tier application, the application server will keep a pool of connections open anyway.</p> <p>Scalability is an issue, or at least used to be in the days that machines had less memory than modern kit. With a tw...
<p>Depends on the database and what you're doing with it. There is an expense to opening and closing any connection for the most part. For example, if you're using SQLCE on a mobile device (SQL Server Compact Edition) then it's actually a recommended approach to leave the connection open on the device since the expense...
40,303
<p><sup><strong>Note:</strong> This question was asked at a time when C# did not yet support optional parameters (i.e. before C# 4).</sup></p> <p>We're building a web API that's programmatically generated from a C# class. The class has method <code>GetFooBar(int a, int b)</code> and the API has a method <code>GetFooBa...
<p>Surprised no one mentioned C# 4.0 optional parameters that work like this:</p> <pre><code>public void SomeMethod(int a, int b = 0) { //some code } </code></pre> <p><strong>Edit:</strong> I know that at the time the question was asked, C# 4.0 didn't exist. But this question still ranks #1 in Google for "C# optio...
<p>You can try this too<br/> Type 1<br/> <code>public void YourMethod(int a=0, int b = 0) { //some code }</code></p> <p><br/> Type 2 <br/> <code>public void YourMethod(int? a, int? b) { //some code } </code></p>
24,359
<p>Let me first of all say that I'm NOT interested in a flame war about what is better: .NET or Java... PLEASE don't post if you want to tell me how killer .NET is or how Microsoft is the evil empire so there is no way that a developer with a soul could write .NET or whatever. We've all heard it far too much before.</p...
<p><a href="http://martinfowler.com/" rel="nofollow noreferrer">Martin Fowler</a> has written about both.<br> <a href="http://www.xprogramming.com/" rel="nofollow noreferrer">Ron Jeffries</a> would be another who has written a lot about java and has more recently written a fair bit about C#</p>
<p>The company I work for has about half of it's development in Java (internal apps) and half in .Net (public facing apps). What is it that you want to know? there are several people in the company I work at that can contrast and compare. I admit to not knowing Java all that well though. Are you looking for specific...
49,810
<p>I have a client-server app where the client is on a Windows Mobile 6 device, written in C++ and the server is on full Windows and written in C#. </p> <p>Originally, I only needed it to send messages from the client to the server, with the server only ever sending back an acknowledgement that it received the message...
<p>When I needed to write an application with a client-server model where the clients could leave and enter whenever they want, (I assume that's also the case for your application as you use mobile devices) I made sure that the clients send an <em>online</em> message to the server, indicating they were connected and re...
<p>I'm not clear on whether or not you're wanting to add the asynchronous bits to the server in C# or the client in C++.</p> <p>If you're talking about doing this in C++, desktop Windows platforms can do socket I/O asynchronously through the API's that use overlapped I/O. For sockets, WSASend, WSARecv both allow asyn...
2,364
<p>I believe that quantifying the productivity increase (extra working hours) is the most effective way to do this.</p> <p>My case in point: I have a fast machine at home and a slow one at work. My estimate is that I would gain about 30 minutes a day of extra productivity at work if I had my home machine at work. This...
<p>Break it down into pieces you can quantify. For example, I compile every 4 minutes and each compile would save 10 seconds. But after a while I get bored of waiting to seconds so I go to Stack Overflow and I'm there for two minutes. Sometimes I'll start talking to Jim and that takes 4 minutes for both of us. So 15 ti...
<p>On *nix, I'd use <code>time</code> when doing builds and such.</p> <p>Snagging the output of that is very simple, and easy to compare machine to machine.</p> <p>Also - you can time certain "non-work" things, for example a build of GCC or KDE or something else fairly big from source.</p> <p><strong>Additionally</s...
31,241
<p>I'm creating an ASP.NET web site where all pages hang off a database-driven tree-hierarchy. Pages typically present HTML content. But, some will execute programming.</p> <p><em>Examples:</em> <br></p> <ol> <li>a "contact us" form </li> <li>a report generator</li> </ol> <p>How should I represent/reference the pr...
<p>You might consider inserting placeholders like <code>&lt;my:contact-us-form/&gt;</code> in the database on specific pages; that way the database can describe all the static text content instead of completely replacing that database-driven content with an <code>.ascx</code> control.</p>
<p>Our development team has had success with defining the name of a Web User Control in the database. Upon page load it checks too see what controls to dynamically load from the database. </p> <p>We use Web User Controls instead of Web Forms in order to ensure we can use the control on any page.</p> <p>You can also d...
8,087
<p>Nearly all programming languages used are <a href="http://en.wikipedia.org/wiki/Turing_Complete" rel="noreferrer">Turing Complete</a>, and while this affords the language to represent any <a href="http://en.wikipedia.org/wiki/Computability_theory_(computer_science)" rel="noreferrer">computable</a> algorithm, it also...
<p>Don't listen to the naysayers. There are very good reasons one might prefer a non-Turing complete language in some contexts, if you want to guarantee termination, or simplify code, for example by removing the possibility of runtime errors. Sometimes, just ignoring things may not be sufficient. </p> <p>The paper <...
<p>Any non-Turing-complete language wouldn't be very useful as a general purpose language. You might be able to find something that bills itself as a general purpose language without being Turing-complete but I've never seen one.</p>
40,708
<p>I am working on a .NET-based server component that talks to a set of destinations (equity options exchanges, to be specific) using a variety of destination-specific protocols. The next destination we plan to add uses CORBA, so I am researching .NET libraries that can speak CORBA.</p> <p>So far I have found three po...
<p>IIOP.NET is a good opensource project unfortenely the project stoped in 2007. The project doesn´t have much documentation, but it works.</p> <p>I´m using valuetype in CORBA and IIOP.NET works well.</p>
<p>IONA ORBIX is the only one I have experience with.</p> <p>It works as well as any CORBA broker could be expected too, but, its expensive.</p>
44,312
<p>When using the following function (compare 2 user's group membership), I get results that do not make sense.</p> <pre><code>function Compare-ADUserGroups &lt;br&gt; { #requires -pssnapin Quest.ActiveRoles.ADManagement param ( [string] $FirstUser = $(Throw "logonname required."), [string] $Sec...
<p>There's <em>something</em> in them which is throwing off the comparison. You'll see something similar if you run...</p> <p>get-process | export-clixml c\procs.xml Diff (get-process) (import-clixml c:\procs.xml)</p> <p>Because SOME properties of those objects - things like VM and PM, for example, change in the brie...
<p>My best guess is that the MemberOf property provided by <code>Get-QADUser</code> is probably returning an object instead of just the distinguished name of the group as a string. Here is the script that I use for comparing Active Directory Group memberships:</p> <pre><code># Compare the group memberships of 2 Active...
45,515
<p>I would like to use an ajax toolkit/framework like ZK (www.zkoss.org) or GWT. But I don't know whether it's possible to bundle resources in a JAR? Do you know which one support such resource loading?</p>
<p>Not sure what your goal is, but if its to bundle a web application into one file, then you can do that with a WAR file - assuming your deploying onto a java webcontainer like tomcat or jboss.</p>
<p>My goal is to summarize the Java-classes and also their Templates-files for the view of various application modules, each in one Java-Jar-File. These modules I use in another application, which of course I summarize in a WAR-File for Deployment. I would like to know which ajax-Framework/Toolkit does support this.</p...
25,573
<p>I've got HTML code that roughly looks like this:</p> <pre><code>&lt;li id="someid-11"&gt; &lt;img src="..." alt="alt" /&gt; &lt;h2&gt;&lt;a href="somelink"&gt; sometext &lt;/a&gt; &lt;span&gt;&lt;a class="editcontent" href="?action=editme"&gt;Edit&lt;/a&gt;&lt;/span&gt; &lt;/h2&gt; &lt;div id="11" class="conte...
<p>I recommended the Sprintstar Solution. but if you don't like it, use this:</p> <pre><code>$("a.editcontent").click(function(){ $(this).parents("h2").next(".content").trigger("edit"); }); </code></pre> <p>If you have more that one "h2":</p> <pre><code>$("a.editcontent").click(function(){ $(this).parents("h...
<p>I think its hard to read because you're having to go up from one element back down to another. If you reference both from a common container, those paths will seem more meaningful.</p> <pre><code>var listitem11 = $("#someid-11"); listitem11.find('a.editcontent').bind('click'), (function(){ listitem11.find('....
48,921
<p>I would like to experiment with ideas about distributed file synchronization/replication. To make it efficient when the user is working, I would like to implement some kind of daemon to monitor changes in some directory (e.g. /home/user/dirToBeMonitored or c:\docs and setts\user\dirToBeMonitored). So, I could be abl...
<p><em>A bonified answer, albeit one that requires a largish library dependency (well-worth it IMO)!</em></p> <p>QT provides the <a href="http://doc.trolltech.com/4.4/qfilesystemwatcher.html" rel="nofollow noreferrer">QFileSystemwatcher</a> class, which uses the native mechanism of the underlying platform. </p> <p>Ev...
<p>In Linux it is called <a href="http://linux.die.net/man/7/inotify" rel="nofollow noreferrer">inotify</a>.</p>
18,807
<p>Does python have the ability to create dynamic keywords?</p> <p>For example:</p> <pre><code>qset.filter(min_price__usd__range=(min_price, max_price)) </code></pre> <p>I want to be able to change the <strong>usd</strong> part based on a selected currency.</p>
<p>Yes, It does. Use <code>**kwargs</code> in a function definition.</p> <p>Example:</p> <pre><code>def f(**kwargs): print kwargs.keys() f(a=2, b="b") # -&gt; ['a', 'b'] f(**{'d'+'e': 1}) # -&gt; ['de'] </code></pre> <p>But why do you need that?</p>
<p>Yes, sort of. In your filter method you can declare a wildcard variable that collects all the unknown <a href="http://www.python.org/doc/2.5.2/tut/node6.html#SECTION006720000000000000000" rel="nofollow noreferrer">keyword arguments</a>. Your method might look like this:</p> <pre><code>def filter(self, **kwargs): ...
43,819
<p>HI,</p> <p>I have a large table from which i can query to get the following table</p> <pre><code>type no of times type occurs 101 450 102 562 103 245 </code></pre> <p>also i can get another table</p> <pre><code>code no of times code occurs 0 1222 1 ...
<p>I think you want this:</p> <pre><code>req.Credentials = CredentialCache.DefaultCredentials; </code></pre>
<p>You're going to need to enable Integrated Windows Authentication.</p> <p>I don't know what happens in ASP.NET MVC, but in ASP.NET Web Forms impersonation is turned on by:</p> <pre><code>&lt;identity impersonate="true"&gt; </code></pre> <p>in web.config.</p>
46,338
<p>What is your single favorite mocking library for Python?</p>
<p>I've only used one, but I've had good results with Michael Foord's Mock: <a href="http://www.voidspace.org.uk/python/mock/" rel="noreferrer">http://www.voidspace.org.uk/python/mock/</a>.</p> <p>Michael's introduction says it better than I could:</p> <blockquote> <p>There are already several Python mocking libraries ...
<p>I've used <a href="http://pmock.sourceforge.net/" rel="nofollow noreferrer">pMock</a> in the past, and didn't mind it, it had pretty decent docs too. However, Foord's Mock as mentioned above is also nice.</p>
12,354
<p>I'm working on an application that is implemented as an HTA. I have a series of links that I would like to have open in the system's default web browser. Using <code>&lt;a href="url" target="_blank"&gt;</code> opens the link in IE regardless of the default browser.</p> <p>Is there a way to use the default browser? ...
<p>Create a shell and attempt to run a URL.</p> <p>This works for me (save as whatever.hta and execute it) on my system. Clicking on the button opens Google in Firefox:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;html lang="en"&gt; &lt;head&gt; ...
<p>Nope, sadly I believe this is a browser specific implementation that will open new links with target="_blank" within the same browser.</p> <p>If you wanted to open it in the default browser, then you would need to interact with the OS, which JavaScript cannot do.</p>
22,421
<p>Here is a little test program: </p> <pre><code>#include &lt;iostream&gt; class Test { public: static void DoCrash(){ std::cout&lt;&lt; "TEST IT!"&lt;&lt; std::endl; } }; int main() { Test k; k.DoCrash(); // calling a static method like a member method... std::system("pause"); return 0; } </c...
<p>The standard states that it is not necessary to call the method through an instance, that does not mean that you cannot do it. There is even an example where it is used:</p> <p>C++03, 9.4 static members</p> <blockquote> <p>A static member s of class X may be referred to using the qualified-id expression X::s; ...
<p>static methods can be called also using an object of the class, just like it can be done in Java. Nevertheless, you shouldn't do this. Use the scope operator like <code>Test::DoCrash();</code> Maybe you think of namespaces:</p> <pre><code>namespace Test { void DoCrash() { std::cout &lt;&lt; "Crashed!!" ...
42,163
<p>I am looking for either a FireFox extension, or a similar program, that allows you to craft GET and POST requests. The user would put in a form action, and as many form key/value pairs as desired. It would also send any cookie information (or send the current cookies from any domain the user chooses.) The Web Develo...
<p>If you're a windows user, use <a href="http://www.fiddler2.com/fiddler2/version.asp" rel="nofollow noreferrer">Fiddler</a>. It is invaluable for looking at the raw Http requests and responses. It also has the ability to create requests with the request builder and it has an auto responder also, so you can intercep...
<p>If you've got Greasemonkey installed you might want to try the XSS Assistant user script: <a href="http://www.whiteacid.org/greasemonkey/#xss_assistant" rel="nofollow noreferrer">http://www.whiteacid.org/greasemonkey/#xss_assistant</a></p>
3,655
<p>I'm currently using AntLR to parse some files with a proprietary language. I have a need of highlighting sections of it on an editor (think of highlighting a method in a Java class, for instance).</p> <p>Does anyone has a hint on how to get them? Say I have this code:</p> <pre><code>function test(param1, param2) {...
<p>If I understand your question, I think you can use attribute 'pos' on each token</p> <pre><code>func: FUNCTION ID '(' ID (',' ID)* ')' { System.out.println("Position = " + $FUNCTION.pos); } </code></pre> <p>which refers to the character position within the line counting from zero.</p>
<p>Not quite following why the first position you are getting is the position of test. You should easily be able to get the character offset of the "function" token if you designed the pattern specification correctly. Can you list the relevant parts of the specification?</p>
35,632
<p>The type 'x' is defined in an assembly that is not referenced. You must add a reference to assembly 'abc123'.</p> <p>I have a .NET 2.0 web application that references my assembly 'abc123'. The assembly exists in the GAC and I've verified that it is the correct(same) version. The rest of application has no issues ...
<p>I'm Mike's coworker, and we worked out a solution.</p> <p>The type X is defined in his assembly, that is only in the GAC. Even though his ASP.NET web appplication did have a reference, it was failing to load from the GAC only for this UserControl. The rest of the application worked as expected. We confirmed the fai...
<p>I had the exact same error, but I had a <strong>public</strong> constructor in my class that used as a parameter, an object from another project.</p> <p>I resolved the problem by making that constructor internal.</p>
36,088
<p>Everytime i retrieve data from a mysql stored procedure with a concat function an error will occur after binding the datagridview to the datatable that holds the returned rows.</p>
<p>I suppose you should make an alias for selected value:</p> <pre><code>select concat(column1, column2) as concatenated from table1 </code></pre>
<p>I suppose you should make an alias for selected value:</p> <pre><code>select concat(column1, column2) as concatenated from table1 </code></pre>
48,211
<p>Is there a better way to watch for new entries in a table besides selecting from it every n ticks of time or something like that?</p> <p>I have a table that an external program updates very often, and clients can watch for this new data as it arrive, how can I make that without having to set a fixed period of repea...
<p>In MySQL there's no best way than to poll (you create a specific table to simplify the polling though), in other databases you can have triggers that have impact outside the database. In MySQL <a href="http://dev.mysql.com/doc/refman/5.0/en/triggers.html" rel="noreferrer">triggers</a> can only do stuff inside the da...
<p>For those who are doing this in go. You can enable binlog and read binlog for new insert/update/delete on any table. There is a go package <a href="https://github.com/siddontang/go-mysql" rel="nofollow noreferrer">here</a> that does the trick. And <a href="https://github.com/JackShadow/go-binlog-example" rel="nofoll...
20,200
<p>I am looking at connecting to a openSuse 11.1 Beta 3 virtual machine from my Vista 64-bit development workstation. I found UltraVNC Viewer to be the only option for this purpose. Is there any other clients that I can use to connect from Vista to openSuse/other Linux installs? </p> <p>Note: Bandwidth is not a worry,...
<p>I don't know about Vista but I have successfully used <a href="http://sourceforge.net/projects/xming" rel="nofollow noreferrer">X-Ming</a> on Windows XP to talk to a Debian box.</p>
<p>I will double Adam's suggestion to use XMing. You can also enable X11-Forwarding in SSH and use, say, PuTTy, to open up different X applications running on the SUSE box (this, if I remember correctly, requires some sort of a X server to be running on the Windows box, and for which, I have been using <a href="http://...
30,996
<p><strong>This question isn't about unit-testing. And it is for a desktop product.</strong></p> <p>This is about testing of the gui and testing that the right stuff is input in the right text box at the right time.</p> <p>A company I used to work at used WinRunner (different department so I don't know much more that...
<p>We use the <a href="http://safsdev.sourceforge.net/Default.htm" rel="noreferrer">SAFS framework</a> for Rational Robot (RRAFS). There are also SAFS implementations for WinRunner (WRAFS) and it looks like they have a new "Image-Based Testing" implementation, which I'm not familiar with.</p> <p>This framework does a ...
<p>There are a lot more (open source) alternatives if you are testing a web product. For a desktop product, some popular general purpose desktop GUI automation tools below (in no particular order). I've worked with all of these personally, and they all get the job done. If you choose to go with a vendor tool, get PO...
27,984
<p>I'm pretty new to the C++ build flow, and I'm thinking of switching to use partial linking for my libraries instead of creating <code>ar</code> archives. I'm hoping to reduce link time in an inevitable final compilation step that I have, and I figure partial linking some libraries once could save me time over linkin...
<p>You lose an important effect of having the object files in an <code>ar</code> archive, which is that only the referenced objects will be linked in.</p> <p>If you have both <code>foo.o</code> with the symbol <code>foo</code> and bar.o with the symbol <code>bar</code> in an <code>ar</code> archive, and only reference...
<p>The other time that you want to use ld -r to do a partial link is if you have some object files that contain static initialisation that are required to provide certain functionality but that is never called directly by any of the code.</p> <p>If you'd like I can write up a document that showcases how this works and...
34,071
<p>What is a strong way to protect against sql injection for a classic asp app?</p> <p>FYI I am using it with an access DB. (I didnt write the app)</p>
<p>Stored Procedures and/or prepared statements:</p> <p><a href="https://stackoverflow.com/questions/1973/what-is-the-best-way-to-avoid-sql-injection-attacks">https://stackoverflow.com/questions/1973/what-is-the-best-way-to-avoid-sql-injection-attacks</a></p> <p><a href="https://stackoverflow.com/questions/139199/can...
<p>Switching to SQL Express at the very least is a great option. It will make things much more secure. Even though using parameters and Stored Procedures can help greatly. I also recommend that you validate the inputs carefully to be sure they match what you're expecting.</p> <p>For values like numbers it is fairly ea...
18,056
<p>I'm looking for embedded database engine supporting <a href="http://msdn.microsoft.com/en-us/library/3ak841sy(VS.80).aspx" rel="nofollow noreferrer">isolating storage</a>. Currently I'm aware of VistaDB. What else you can recommend?</p> <p>Requirements are pretty simple:</p> <ul> <li>xcopy deployment </li> <li>su...
<p><a href="http://www.vistadb.net" rel="nofollow noreferrer">VistaDB</a> seems to have <a href="http://www.vistadb.net/vistadb3/technical/zero-config.aspx" rel="nofollow noreferrer">support</a> for isolated storage. I've been using it for nearly a year now and am very happy with it all round.</p> <p>It's not free bu...
<p>You could do something like that with <a href="http://firebirdsql.org" rel="nofollow noreferrer">Firebird Embedded</a>.<br> Although it does not natively support Isolated Storage, it should be pretty easy to create a new database for each user. </p>
13,376
<p>How can I add new application mapping in IIS using vbscript?</p> <p>Thanks,</p>
<p>Basically you <em>could</em> use <code>adsutil.vbs</code> to manipulate the ScriptMaps within the MetaBase.</p> <p>Unfortunately, <code>adsutil.vbs</code> is unable to set single items in LIST properties like ScriptMaps. You can only set or delete the list as a whole. Any additional processing would require your ow...
<p>Use a combination of ADSI with VBScript. There are several examples here: <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/library/IIS/4b976f46-3751-4f6b-ab68-5e19fa73a7b1.mspx" rel="nofollow noreferrer">http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/library/IIS/4b976f46-3751-4...
33,300
<p>This error should be a simple one but I cant seem to make it work. The problem lies in the fact that this very same code works earlier in the program. I don's see any reason for it to be sending an error on this instance and not the four previous ones. Reference the code below, and feel free to provide any criticism...
<pre><code>.8m instead of .8 </code></pre>
<p>In this line here:</p> <p>z = (x<em>y)</em>(.8 * 1.732050808m);</p> <p>you specify .8 as a literal, but without the 'm' suffix, the literal specifies a double.</p> <p>z = (x<em>y)</em>(.8m * 1.732050808m);</p> <p>will fix it.</p>
47,477
<p>I want to be able to link to sharepoint documents without having to refer to the document name which may change. Is there anyway to programmatically add a unique key to the meta-data and then somehow use this in a link?</p>
<p>Every library has a GUID as an identifier. You can programmatically get that GUID and get the url from that.</p>
<p>Every library has a GUID as an identifier. You can programmatically get that GUID and get the url from that.</p>
36,423
<p>How do I use the profiler in Visual Studio 2008?</p> <p>I know theres a build option in Config Properties -> Linker -> Advanced -> Profile (/PROFILE), however I can't find anything about actauly using it, only articles I was able to find appear to only apply to older versions of Visual Studio (eg most say to goto B...
<p>Microsoft has released stand-alone Profiler for VS 2008 <a href="http://www.microsoft.com/downloads/details.aspx?familyid=fd02c7d6-5306-41f2-a1be-b7dcb74c9c0b&amp;displaylang=en" rel="noreferrer">here</a></p>
<p>As I understood from reading a few sites, when you use VS 2008 stand alone profiler to create <code>.vsp</code> files, you will need either VS2008 Premium or Ultimate to view <code>.vsp</code> files.</p> <p>By the way, I installed VS2012 Release candidate which is available for free (trial version?) and I can use ...
8,689
<p>This might be a naive question. I have to manually edit a .WXS file to make it support select features from command line.</p> <p>For example, there are 3 features in .WXS file.</p> <pre><code>&lt;Feature Id="AllFeature" Level='1'&gt; &lt;Feature Id="Feature1" Level='1'&gt; &lt;/Feature&gt; &lt;Feature Id...
<p>I would change Feature1, Feature2 and Feature3 to Components, then would declare something like this:</p> <pre><code>&lt;Feature Id="FEATUREA" Title="Super" Level="1" &gt; &lt;ComponentRef Id="Component1" /&gt; &lt;ComponentRef Id="Component2" /&gt; &lt;/Feature&gt; &lt;Feature Id="FEATUREB" Title="Super1" Lev...
<p>There are a number of properties that can control the install states of Features. Check out this MSI SDK documentation and the links from it: <a href="http://msdn.microsoft.com/en-us/library/aa367536(VS.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa367536(VS.85).aspx</a></p>
30,574
<p>Using reflection, how can I get all types that implement an interface with C# 3.0/.NET 3.5 with the least code, and minimizing iterations?</p> <p>This is what I want to re-write:</p> <pre><code>foreach (Type t in this.GetType().Assembly.GetTypes()) if (t is IMyInterface) ; //do stuff </code></pre>
<p>Mine would be this in c# 3.0 :)</p> <pre><code>var type = typeof(IMyInterface); var types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s =&gt; s.GetTypes()) .Where(p =&gt; type.IsAssignableFrom(p)); </code></pre> <p>Basically, the least amount of iterations will always be:</p> <pre><code>loop ass...
<p>You could use some LINQ to get the list:</p> <pre><code>var types = from type in this.GetType().Assembly.GetTypes() where type is ISomeInterface select type; </code></pre> <p>But really, is that more readable?</p>
4,630
<p>Is it possible to reload a page that was loaded thru link_to_remote? I'm doing this in my controller: <br></p> <pre><code>def create if captchas_verified do_something else render :action=&gt;'new' end </code></pre> <p>But when the captchas is wrong, it do not render a form that is inside of the new template....
<p>You need to <code>render :update</code>, rather than <code>render :action</code>.</p> <p>I do this sort of thing all the time. Similar to the response from jdl you can use inline rjs (don't know if that's the right term) to render the page.</p> <pre><code>render(:update) do |page| page.replace_html("div_to_updat...
<p>Something like this should do what you want.</p> <pre><code>render :update do |page| page &lt;&lt; 'window.location.reload()' end </code></pre>
25,165
<p>I use a stream reader to import some data and at the moment I hardcode a small sample file in the test to do the job.</p> <p>Is it sensible to use Mock Objects with this and how ?</p>
<p>I don't see any points to mock StreamReader unless you're making StreamReader derived class. If you need to provide test input via StreamReader, just read some predefined data from any suitable source.</p>
<p>When testing code that depends on streams, streamreaders and streamwriters I usually use the memorystream object for testing. No mocking framework needed here.</p>
8,753
<p>In <a href="http://en.wikipedia.org/wiki/Vim_%28text_editor%29" rel="noreferrer">Vim</a>, how do I insert characters at the beginning of each line in a selection?</p> <p>For instance, I want to comment out a block of code by prepending <code>//</code> at the beginning of each line assuming my language's comment s...
<ol> <li>Press <kbd>Esc</kbd> to enter 'command mode'</li> <li>Use <kbd>Ctrl</kbd>+<kbd>V</kbd> to enter visual block mode</li> <li>Move <kbd>Up</kbd>/<kbd>Down</kbd>to select the columns of text in the lines you want to comment.</li> <li>Then hit <kbd>Shift</kbd>+<kbd>i</kbd> and type the text you want to insert.</li>...
<p>Mapping of most voted answer:</p> <p>1st visual select the desired lines, then execute <code>&lt;leader&gt;zzz</code>, which values:</p> <pre><code>vnoremap &lt;leader&gt;zzz &lt;C-V&gt;^I-&lt;Space&gt;&lt;Esc&gt; </code></pre> <ul> <li><code>&lt;C-V&gt;</code> to enter visual mode</li> <li><code>^</code> goes to st...
31,584
<p>I know there have been a few threads on this before, but I have tried absolutely everything suggested (that I could find) and nothing has worked for me thus far...</p> <p>With that in mind, here is what I'm trying to do:</p> <p>First, I want to allow users to publish pages and give them each a subdomain of their cho...
<p>As far as how to set up the DNS subdomain wildcard, that would be a function of your DNS hosting provider. This would be different steps depending on which hosting provider you have and would be a better question for them.</p> <p>Once you've set that up with the DNS host, from your web app you really are just URL re...
<blockquote> <p>First, I want to allow users to publish pages and give them each a subdomain of their choice (ex: user.mysite.com). From what I can gather, the best way to do this is to map user.mysite.com to mysite.com/user with mod_rewrite and .htaccess - is that correct?</p> </blockquote> <p>You may...
10,517
<p>I have a web application written using CherryPy, which is run locally on <code>127.0.0.1:4321</code>. We use mod-rewrite and mod-proxy to have Apache act as a reverse proxy; Apache also handles our SSL encryption and may eventually be used to transfer all of our static content.</p> <p>This all works just fine for ...
<p><code>SetEnv proxy-nokeepalive 1</code> would probably tell you right away if the problem is keepalive between Apache and CP. See the <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#envsettings" rel="noreferrer">mod_proxy docs</a> for more info.</p>
<p>You might run the netstat command and see if you have a bunch of sockets in the TIME_WAIT state. Depending on your MaxUserPort setting you might be severly limited in the number of ports available to use. In addition the TcpTimedWaitDelay is usually set to 240 seconds so any sockets that are used cannot be reused fo...
19,779
<p>I have tried:</p> <ol> <li>Xdebug and Eclipse. Eclipse launches a web browser, but the browser tries to access a non-existent file in Eclipse's .app bundle.</li> <li>Xdebug and NetBeans. It does a little bit better; a browser opens a page in /tmp which says "Launching. Please wait…" but nothing happens beyond that....
<p>You may want to look into <a href="http://www.bluestatic.org/software/macgdbp/" rel="noreferrer">MacGDBp</a>. It's new, free, and the UI looks great. It utilizes the Xdebug PHP extension as well. You can find instructions in the <a href="http://www.bluestatic.org/software/macgdbp/help.php" rel="noreferrer">help</a> ...
<p>I guess I don't get bonus points, but Zend Studio works for me on my Mac connecting to Apache running in VMware.</p>
10,584
<p>Suppose I have three classes. It is valid to instantiate A, but there are also special cases B and D which subclass A, adding additional information.</p> <p>How would I do the mapping files for this in (fluent) NHibernate?</p> <pre><code>public class A { public int ID { get; set;} public string CommonProp...
<p>I'm not sure I understand what you mean by "map a subclass one-to-one", but if you want to map inheritance where the subclasses have properties that are not nullable, you can do like this in Fluent-NHibernate:</p> <pre><code>// Domain classes public class Animal { public virtual int Id { get; set; } public ...
<p>The syntax may have changed in FNH since Erik's post, but his example is right on target. Here's some code I used based on Erik's post to work through FNH the two FNH subclass strategies I know of right now (SubClass (the commented out code below, and JoinedSubClass). As an aside, I've seen other names used to descr...
37,961
<p>FxCop has the <a href="http://msdn.microsoft.com/en-ca/ms182327.aspx" rel="nofollow noreferrer">CollectionPropertiesShouldBeReadOnly rule</a> that complains if your class has some kind of collection property that clients can set. Instead, it suggests making the property read-only and supplying a Clear() method and A...
<p>If the collection property only has a getter exposed, we will assume the FxCop recommended patterns you list is used and add to the collection. The first pattern is also supported. </p> <p>For generic collections this is only working if the exposed property is of the type IList. We have a <a href="http://jira.sp...
<p>Is the problem as bad as you think? My understanding is that FxCop will complain if you have a read/write property like this:</p> <pre><code>public List&lt;Foo&gt; Items { get; set; } </code></pre> <p>... because users of your class would then be able to do this:</p> <pre><code>myInstance.Items = new List&lt;Foo&...
25,329
<p>Is there available any tool for PHP which can be used to generate code for consuming a <a href="http://en.wikipedia.org/wiki/Web_service" rel="noreferrer">web service</a> based on its <a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language" rel="noreferrer">WSDL</a>? Something comparable to clicking ...
<p>In PHP 5 you can use <a href="http://www.php.net/manual/en/ref.soap.php" rel="noreferrer">SoapClient</a> on the WSDL to call the web service functions. <a href="http://www.php.net/manual/en/soapclient.construct.php" rel="noreferrer">For example</a>:</p> <pre><code>$client = new SoapClient("some.wsdl"); </code></pre...
<p>Well, those features are specific to a tool that you are using for development in those languages.</p> <p>You wouldn't have those tools if (for example) you were using notepad to write code. So, maybe you should ask the question for the tool you are using.</p> <p>For PHP: <a href="http://webservices.xml.com/pub/a/...
2,643
<p>I've been trimming the UI of our website by doing the following in the onload event of that control:</p> <pre><code>btnDelete.isVisible = user.IsInRole("can delete"); </code></pre> <p>This has become very tedious because there are so many controls to check again and again. As soon as I get it all working, designe...
<p>One simple suggestion would be to group controls into panels based on access rights</p>
<p>A quick and dirty option is using the asp:loginview controls, which can be wired up to user roles.</p> <p>Not as elegant as the custom page class option suggested by Jonathan, and can be a bit of a performance hit if they are all over the page.</p>
11,487
<p>How to configure Tomcat 5.5 to authenticate against Win2003 Activedirectory(LDAP)</p> <p>What changes are needed to default tomcat configuration, at least server.xml needs to be changed somehow to have IP of Win2003 server?</p>
<p>I don't know if "automatic" login with IE is possible.</p> <p>But you can use a "classic" login form (Java EE style) and let Tomcat perform the login against Active Directory using a JNDI Realm.</p> <p>change the default realm in your server.xml or set the realm in your application's context.xml like this:</p> <p...
<p><a href="http://wiki.openi.org/index.php/Configuring_Tomcat_With_Active_Directory" rel="nofollow noreferrer">Configuring Tomcat With Active Directory</a>. Have not tried it. Good luck.</p>
44,718
<p>I'm working on a programming language, and today I got the point where I could compile the factorial function(recursive), however due to the maximum size of an integer the largest I can get is factorial(12). What are some techniques for handling integers of an arbitrary maximum size. The language currently works b...
<p>If you need larger than 32-bits you could consider using 64-bit integers (long long), or use or write an arbitrary precision math library, e.g. <a href="http://gmplib.org/" rel="noreferrer">GNU MP</a>.</p>
<p>Other posters have given links to libraries that will do this for you, but it seem like you're trying to build this into your language. My first thought is: are you sure you need to do that? Most languages would use an add-on library as others have suggested.</p> <p>Assuming you're writing a compiler and you do n...
39,978
<p>Say I have an array of strings in a php array called $foo with a few hundred entries, and I have a MySQL table 'people' that has a field named 'name' with a few thousand entries. What is an efficient way to find out which strings in $foo aren't a 'name' in an entry in 'people' without submitting a query for every s...
<p>I'd put your $foo data in another table and do a LEFT OUTER JOIN with your names table. Otherwise, there aren't a lot of great ways to do this that don't involve iteration at some point.</p>
<p>I'm not sure there is a more efficient way to do this other than to submit all the strings to the database.</p> <p>Basically there are two options: get a list of all the strings in MySQL and pull them into PHP and do the comparisons, or send the list of all the strings to the MySQL server and let it do the comparis...
27,146
<p>Python allocates integers automatically based on the underlying system architecture. Unfortunately I have a huge dataset which needs to be fully loaded into memory. </p> <p>So, is there a way to force Python to use only 2 bytes for some integers (equivalent of C++ 'short')?</p>
<p>Nope. But you can use short integers in arrays:</p> <pre><code>from array import array a = array("h") # h = signed short, H = unsigned short </code></pre> <p>As long as the value stays in that array it will be a short integer.</p> <ul> <li>documentation for the <a href="http://docs.python.org/dev/library/array" ...
<p>You can also store multiple any size of integers in a single large integer.</p> <p>For example as seen below, in python3 on 64bit x86 system, 1024 bits are taking 164 bytes of memory storage. That means on average one byte can store around 6.24 bits. And if you go with even larger integers you can get even higher b...
14,627
<p>I am looking for any tool which will allow the performance testing/tuning of Sybase nested stored procedures. There are many tools around and of course Sybase's own for performance tuning and testing SQL but none of these can handle nested stored procedures (i.e. a stored proc calling another stored proc). Does anyo...
<p>Inside of an ASP.Net web.config you can setup locations to add security to specific files and folders. In addition, you can remove all verbs from those directories:</p> <pre><code>&lt;location path="Secret" allowOverride="false"&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;deny users="*" /&gt; ...
<p>There are some things you can do with web.config like defining security settings etc... Other times you have to use HttpModules or HttpHandlers, look here: <a href="http://msdn.microsoft.com/en-us/library/aa719858(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa719858(VS.71).aspx</a>...
40,966