instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>On my team, we usually do string concatentation like this:</p>
<pre><code>var url = // some dynamically generated URL
var sb = new StringBuffer();
sb.append("<a href='").append(url).append("'>click here</a>");
</code></pre>
<p>Obviously the following is much more readable:</p>
<pre><code>var url = // ... | <p>Your example is not a good one in that it is very unlikely that the performance will be signficantly different. In your example readability should trump performance because the performance gain of one vs the other is negligable. The benefits of an array (StringBuffer) are only apparent when you are doing many conc... | <p>Yes, according to the usual benchmarks. E.G : <a href="http://mckoss.com/jscript/SpeedTrial.htm" rel="nofollow noreferrer">http://mckoss.com/jscript/SpeedTrial.htm</a>.</p>
<p>But for the small strings, this is irrelevant. You will only care about performances on very large strings. What's more, in most JS script, ... | 13,730 |
<p>Does MSTest have standalone GUI similar to nUnit that lets me use it and run test without visual studio? What is the official site for MSTest where I can learn more about how to use it?</p>
| <p>It doesn't have a GUI (apart from Visual Studio) but there's a command line tool: <a href="http://msdn.microsoft.com/en-us/library/ms182489.aspx" rel="noreferrer">MSTest.exe</a></p>
<p>Here is the official documentation on <a href="http://msdn.microsoft.com/en-us/library/ms182469.aspx" rel="noreferrer">running MSTe... | <p>Uset "dotnet test", it is compatible with all versions, eg:</p>
<pre><code>'dotnet test yourassembly.dll -l console -v detailed'
</code></pre>
| 32,663 |
<p><strong>problem</strong></p>
<p>how to best parse/access/extract "excel file" data stored as binary data in an SQL 2005 field?</p>
<p>(so all the data can ultimately be stored in other fields of other tables.)</p>
<p><strong>background</strong></p>
<p>basically, our customer is requiring a large volume of verbos... | <p>My thought is that anything can be done, but there is a price to pay. In this particular case, the price seems to bee too high. </p>
<p>I don't have a tested solution for you, but I can share how I would give my first try on a problem like that.</p>
<p>My first approach would be to install excel on the SqlServer ... | <p>It sounds like you're trying to store an entire database table inside a spreadsheet and then inside a single table's field. Wouldn't it be simpler to store the data in a database table to begin with and then export it as an XLS when required?</p>
<p>Without opening up an instance Excel and having Excel resolve work... | 10,500 |
<p>Currently I have two MediaWikis, one a slightly older version than the other. I want to merge the contents of both together, without eliminating duplicate pages. So far the best option I can think of is to use a bot (like pywikipedia) to go through all the pages of one wiki, and try inserting them into the other, ... | <p>MediaWiki has <a href="http://meta.wikimedia.org/wiki/Help:Import" rel="noreferrer">import</a> and <a href="http://meta.wikimedia.org/wiki/Help:Export" rel="noreferrer">export</a> features, that you can use for moving the contents. It does merge histories of existing pages (see import link).</p>
<p>However, it does... | <p>As a committer of <a href="https://github.com/WolfgangFahl/py-3rdparty-mediawiki" rel="nofollow noreferrer">https://github.com/WolfgangFahl/py-3rdparty-mediawiki</a> i recommend using the wikibackup/wikirestore feature of that tool - it will do the export/import in a way that allows to use standard unix tools while ... | 37,804 |
<p>I'm generating some XML documents and when it comes to the address part I have fragments that look like this:</p>
<pre><code><Address>15 Sample St
Example Bay
Some Country</Address>
</code></pre>
<p>The XSLT that I have for converting this to XHTML has some funky recursive template to convert newline c... | <p>It's generally considered bad practice to rely on linebreaks, since it's a fragile way to differentiate data. While most XML processors will preserve any whitespace you put in your XML, it's not guaranteed. </p>
<p>The real problem is that most applications that output your XML into a readable format consider all... | <p>Yes, I think using a <a href="http://en.wikipedia.org/wiki/CDATA" rel="nofollow noreferrer">CDATA</a> block would protect the whitespace. Although some parser APIs allow you to preserve whitespace.</p>
| 2,892 |
<p>Is it safe to assume that event subscribers are called in order of subscription?<br>
Example: </p>
<pre><code>void One(object sender, EventArgs e) {}
void Two(object sender, EventArgs e) {}
event EventHandler foo;
foo += One;
foo += Two;
</code></pre>
<p>Is One() always called before Two() when the event is fir... | <p>Given that implementation, yes, they will always be called in that order.</p>
<p>If the event actually uses some weird and wonderful way of handling subscriptions, it could do different things - but "normal" implementations will do the right thing.</p>
<p>To be clear, subscribing to an event handler just means inv... | <p>In general, events subscribers are expected to behave independently from each other. It should make no difference whether they're invoked in order of subscription, reverse order of subscription, or in seemingly-random order which varies arbitrarily each time the event is raised. Subscribers shouldn't care about ot... | 48,959 |
<p>I'd sort of like to use SQLite from within C#.Net, but I can't seem to find an appropriate library. Is there one? An official one? Are there other ways to use SQLite than with a wrapper?</p>
| <p>From <a href="https://system.data.sqlite.org/" rel="noreferrer">https://system.data.sqlite.org</a>:</p>
<blockquote>
<p>System.Data.SQLite is an ADO.NET adapter for SQLite.</p>
<p>System.Data.SQLite was started by Robert Simpson. Robert still has commit privileges on this repository but is no longer an activ... | <p>Version 1.2 of Monotouch includes support for System.Data. You can find more details here:
<a href="http://monotouch.net/Documentation/System.Data" rel="nofollow noreferrer">http://monotouch.net/Documentation/System.Data</a></p>
<p>But basically it allows you to use the usual ADO .NET patterns with sqlite.</p>
| 11,922 |
<p>I've honestly <a href="https://stackoverflow.com/questions/35420/mysql-software-any-suggestions-to-oversee-my-mysql-replication-server">tried</a> <a href="https://stackoverflow.com/questions/8365/mysql-administrator-backups-compatibility-mode-what-exactly-is-this-doing">this</a> <a href="https://stackoverflow.com/qu... | <p>Your master executes in parallel and your slave executes in serial. If your master can process 1.5 hours of inserts/updates/executes in 1 real hour, your slave will fall behind.</p>
<p>If you can't find ways to improve the write performance on your slave (more memory, faster disks, remove unnecessary indexes), you'... | <p>Adding memory to the slave would probably help. We went from 32 to 128 megs and the lagging more or less went away. But its neither cheap nor will it be enough in all situations.</p>
<p>Buying a third server will probably not help that much though, you will most likely just get another lagging slave.</p>
| 34,333 |
<p>With the help of the Stack Overflow community I've written a pretty basic-but fun physics simulator.</p>
<p><img src="https://i.stack.imgur.com/EeqSP.png" alt="alt text" /></p>
<p>You click and drag the mouse to launch a ball. It will bounce around and eventually stop on the "floor".</p>
<p>My next big fe... | <p>To detect whether two balls collide, just check whether the distance between their centers is less than two times the radius. To do a perfectly elastic collision between the balls, you only need to worry about the component of the velocity that is in the direction of the collision. The other component (tangent to th... | <p>I would consider using a quadtree if you have a large number of balls. For deciding the direction of bounce, just use simple conservation of energy formulas based on the collision normal. Elasticity, weight, and velocity would make it a bit more realistic.</p>
| 44,999 |
<p>Inside my code I'm generating hashes of URLs, (which are practically of unbounded length). I'm currently using sha1(), which I know has a tiny chance of a collision, but I have up to 255 bytes to store the hash in so feel that I might as well use that available space to lower the chance of collision even further.</... | <blockquote>
<p>Or, is sha1's 20-byte has good enough for anything and I should stop worrying about it?</p>
</blockquote>
<p>Exactly.</p>
<p>Hashtables, Pigeonholes, and Birthdays<br>
<a href="http://www.codinghorror.com/blog/archives/001014.html" rel="nofollow noreferrer">http://www.codinghorror.com/blog/archives/... | <p>You could always prepend/append a sequential ID (in decimal or hex) to your existing hash?</p>
<p>Sure you wouldn't have a fixed length hash but you'd know the code was a) unique and b) non-guessable (even if someone noticed the sequential part they wouldn't know the way you were salting/hashing the rest of the cod... | 37,767 |
<p>Is there really that much of a difference between the performance of <code>Vector</code> and <code>ArrayList</code>? Is it good practice to use ArrayLists at all times when thread safety isn't an issue?</p>
| <p>Vector originates back from the pre-Collections API days, and have been retrofitted since to be a part of it. From what I've read, the reason it is not deprecated is because the core API depends on it.</p>
<p>ArrayList was written from scratch as a part of the Collections API and as such should be used unless you n... | <p>If thread safety isn't an issue you should always use <code>ArrayList</code>. Vector has the overhead of synchronization and it has been shown that the performance differences between <code>ArrayList</code> and <code>Vector</code> are abysmal. You can google for a lot of performance benchmarks. </p>
<p>Here's one <... | 38,526 |
<p>You can use </p>
<p>SelectFolder() to get a folder</p>
<p>or </p>
<p>GetOpenFolderitem(filter as string) to get files</p>
<p>but can you select either a folder or file? ( or for that matter selecting multiple files )</p>
| <p>The MonkeyBread plugin allows this in the OpenDialogMBS class.</p>
<p><a href="http://www.monkeybreadsoftware.net/pluginhelp/navigation-opendialogmbs.shtml" rel="nofollow noreferrer">http://www.monkeybreadsoftware.net/pluginhelp/navigation-opendialogmbs.shtml</a></p>
<pre><code>OpenDialogMBS.AllowFolderSelection a... | <p>Assuming you're using .Net I think you'll need to create your own control (or buy one). </p>
| 12,549 |
<p>I would like to print a custom version of something akin to this rugged case that was originally created using injection molding:</p>
<p><a href="https://i.stack.imgur.com/oL8JW.jpg" rel="nofollow noreferrer" title="ea weather proofed tablet with over-molded rubber"><img src="https://i.stack.imgur.com/oL8JW.jpg" alt... | <p>I do it a couple of ways.</p>
<p>I use TPU which is pretty good for impacts and either make it thick or stiffen it with another filament as an inside or outside shell.</p>
<p>But TPU is what you want for this project because it's flexible in the way you need it to be.</p>
| <p>Case designers usually use TPU for flexibility and polycarbonate for stiffness</p>
| 2,201 |
<p>When I'm initializing a dialog, I'd like to select one of the radio buttons on the form. I don't see a way to associate a Control variable using the Class Wizard, like you would typically do with CButtons, CComboBoxes, etc...</p>
<p>Further, it doesn't like a CRadioButton class even exists.</p>
<p>How can I selec... | <p>Radio buttons and check buttons are just buttons. Use a <code>CButton</code> control and use <code>GetCheck</code>/<code>SetCheck</code>.</p>
| <pre><code>void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
...
DDX_Radio(pDX, IDC_RADIO1, m_Radio);
...
}
</code></pre>
<p>but it is the same thing Wizard generates</p>
| 9,919 |
<p>I have a business user who tried his hand at writing his own SQL query for a report of project statistics (e.g. number of tasks, milestones, etc.). The query starts off declaring a temp table of 80+ columns. There are then almost 70 UPDATE statements to the temp table over almost 500 lines of code that each contain ... | <p>First off, if this is not causing a business problem, then leave it until it becomes a problem. Wait until it becomes a problem, then fix everything.</p>
<p>When you do decide to fix it, check if there is one statement causing most of your speed issues ... issolate and fix it.</p>
<p>If the speed issue is over al... | <p>I would rewrite it from scratch.</p>
<p>You say that you understand what it supposed to do so it should not be that difficult. And I bet that the requirements for that piece of code will keep changing so if you do not rewrite it now you may end up maintaining some ugly monster</p>
| 41,516 |
<p>I have to simultaneously load data into a table and run queries on it. Because of data nature, I can trade integrity for performance. How can I minimize the overhead of transactions?</p>
<p>Unfortunately, alternatives like MySQL cannot be used (due to non-technical reasons). </p>
| <p>Other than the general optimization practices that apply to all databases such as eliminating full table scans, removing unused or inefficient indexes, etc., etc., here are a few things you can do.</p>
<ol>
<li>Run in <a href="http://www.adp-gmbh.ch/ora/admin/backup_recovery/archive_vs_noarchive_log.html" rel="nofo... | <p>What kind of performance volumes are you looking at? Are inserts batched or numerous small ones?</p>
<p>Before banging your head against the wall trying to think of clever ways to have good performance, did you create any simple prototypes which would give you a better picture of the out-of-the-box performance? It ... | 32,485 |
<p>Given a jQuery result set, how do you convert that back into plain HTML?</p>
<pre><code><div class="abc">
foo <strong>FOO</strong>
</div>
<div class="def">
bar
</div>
</code></pre>
<p>--</p>
<pre><code>var $mySet = $('div');
</code></pre>
<p>Given <code>$mySet</code>, ... | <p>i'd suggest creating a temporary container, then grabbing the <code>html()</code> of that new container:</p>
<pre><code>var html = $('<div>').append( $('div').clone() ).html();
alert(html);
// alerts:
<div class="abc">
foo <strong>FOO</strong>
</div><div class="def">
ba... | <pre><code>var $mySet = $('div');
var html = $mySet.html();
</code></pre>
<p>If you want the element's HTML as well (untested):</p>
<pre><code>var $mySet = $('div');
var html = $mySet.clone().wrap('<div></div>').html();
</code></pre>
<p>By the way, here $ is part of the variable name. Javascript doesn't... | 42,092 |
<p>Is there a CIL instruction to exchange the first two elements in the stack?</p>
| <p>There is no single instruction exchange. However, using <a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.stloc.aspx" rel="noreferrer">stloc</a>, <a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.pop.aspx" rel="noreferrer">pop</a>, and <a href="http://msdn.... | <p>For future reference, you can create an assembly that does what you want to learn the IL for, then view the assembly in Reflector. You can select the language you wish the code to be in, and IL is one of the options. I did this when trying to figure out how to code a dynamic method...</p>
| 23,319 |
<p>I just started using CCNet, and in the process of getting my build projects set up I racked up a lot of build history from trial and error. I really don't want to keep that old stuff around, but I can't seem to see where/how to get rid of it. I'm sure this is a silly question, and I apologize if I'm overlooking some... | <p>Assuming you have a project called "Dev" and you've installed CCNet into the default location, you'll have a folder called:</p>
<p>c:\Program Files\CruiseControl.NET\server\Dev </p>
<p>and a Dev.state file in:</p>
<p>c:\Program Files\CruiseControl.NET\server</p>
<p>Just delete both the folder and the state file.... | <p>As mentioned above, use the Artifact Cleanup Publisher to keep the number of artifacts to a sensible level. </p>
<p>If you have a lot of projects and need to do a retrospective cleanup, you could use the following Powershell script to remove old log files:</p>
<pre><code>$limit = (Get-Date).AddDays(-60)
get-child... | 40,770 |
<p>Is there any way to access the Windows Event Log from a java class. Has anyone written any APIs for this, and would there be any way to access the data from a remote machine?</p>
<p>The scenario is:</p>
<p>I run a process on a remote machine, from a controlling Java process.
This remote process logs stuff to the E... | <p>On the Java side, you'll need a library that allows you to make native calls. Sun offers <a href="http://java.sun.com/javase/6/docs/technotes/guides/jni/index.html" rel="noreferrer">JNI</a>, but it sounds like sort of a pain. Also consider:</p>
<ul>
<li><a href="https://github.com/twall/jna/" rel="noreferrer">https... | <p>If you want true event log access from a remote machine, you will have to find a library which implements the <a href="http://msdn.microsoft.com/en-us/library/cc231215.aspx" rel="nofollow noreferrer">EventLog Remoting Protocol Specification</a>. Unfortunately, I have not yet found any such library in Java. However, ... | 39,985 |
<p>I need to find out the <strong>external</strong> IP of the computer a C# application is running on. </p>
<p>In the application I have a connection (via .NET remoting) to a server. Is there a good way to get the address of the client on the server side?</p>
<p><em>(I have edited the question, to be a little more cl... | <p>This is one of those questions where you have to look deeper and maybe rethink the original problem; in this case, "Why do you need an external IP address?"</p>
<p>The issue is that the computer may not have an external IP address. For example, my laptop has an internal IP address (192.168.x.y) assigned by the rout... | <p>You can basically parse the page returned by doing a WebRequest of <a href="http://whatismyipaddress.com" rel="nofollow noreferrer">http://whatismyipaddress.com</a></p>
<p><a href="http://www.dreamincode.net/forums/showtopic24692.htm" rel="nofollow noreferrer">http://www.dreamincode.net/forums/showtopic24692.htm</a... | 9,188 |
<p>I'm hoping that it isn't to pass each as a parameter to the controller post method..</p>
<p>Have a grid of 52 text boxes representing weeks in a year, each will be containing a decimal value, need ALL of these passed back to the controller for mass updating of the database..</p>
<p>edit: Adding more details.</p>
... | <p>I would suggestion using a Model Binder:</p>
<p><a href="http://www.singingeels.com/Articles/Model_Binders_in_ASPNET_MVC.aspx" rel="nofollow noreferrer">http://www.singingeels.com/Articles/Model_Binders_in_ASPNET_MVC.aspx</a></p>
<p><a href="http://www.singingeels.com/Articles/Model_Binders_in_ASPNET_MVC__Part_2.a... | <p>Hey, I got the solution I wanted after a bit of messing about. I just passed in the parameter "FormCollection myForm" and after a bit of exploring within that object I found my 52 values! Thanks for the help.</p>
<p>edit: I deleted this due to peer pressure probably over a year ago... but looking back on it I don't... | 42,157 |
<p>I have a MySQL table that will only have one row. What should my statement be for the first time I insert to this row, and for subsequent updates? I tried an insert where the primary key equals 1, but this doesn't account for the first time around when no row exists yet.</p>
| <pre><code>INSERT INTO table(col1,col2,col3) VALUES(val1,val2,val3) ON DUPLICATE KEY UPDATE col1 = val1, col2 = val2, col3 = val3;
</code></pre>
| <p>If your table will only ever have one row, you might consider preloading initial data into the row in your database creation script. Then your code will only ever need to issue an UPDATE statement. Also, you will not need a primary key column because there is only ever one row. You can then issue UPDATE statements w... | 37,614 |
<p>What are the things to consider when choosing between ByRef and ByVal.</p>
<p>I understand the difference between the two but I don't fully understand if ByRef saves resources or if we even need to worry about that in the .Net environment.</p>
<p>How do you decide between the two if the functionality doesn't matte... | <p>There's a lot of misinformation around about this. The main thing is that you understand the <a href="http://pobox.com/~skeet/csharp/references.html" rel="noreferrer">difference between value types and reference types</a>, and the <a href="http://pobox.com/~skeet/csharp/parameters.html" rel="noreferrer">difference b... | <p>Marking certain arguments as ByRef shows the user of your function that the <strong>variable</strong> allocated to that argument **will be modified.****</p>
<p><strong>If you use ByRef</strong> for all args, there'll be no way to tell which variables are modified by the function, and which are just read by it. <em>... | 36,981 |
<p>I would like to be a PHP/MySQL programmer </p>
<p>What are the technologies that I must know?</p>
<p>Like:</p>
<ol>
<li>Frameworks</li>
<li>IDEs</li>
<li>Template Engines</li>
<li>Ajax and CSS Frameworks</li>
</ol>
<p>Please tell me the minimum requirements that I must know, and tell me your favourite things in ... | <p>First off, there is <em>no</em> must know about learning PHP and MySQL... You go into it not knowing anything, and you'll come out of it knowing a bunch. If there was a must know, then nobody would be able to get into PHP and MySQL development. I personally think you are at a slight advantage going into this without... | <p>You should know how to use effectively at least one Debugger/IDE. It is amazing what you can learn from your code by stepping through it and watching it run. It both makes it much simpler to track down bugs, and improves the quality of your code. I believe you should never commit code to a project that you haven't s... | 39,426 |
<p>I have an application that needs to hit the ActiveDirectory to get user permission/roles on startup of the app, and persist throughout. </p>
<p>I don't want to hit AD on every form to recheck the user's permissions, so I'd like the user's role and possibly other data on the logged-in user to be globally available o... | <p>Set <a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.currentprincipal.aspx" rel="nofollow noreferrer">Thread.CurrentPrincipal</a> with either the <a href="http://msdn.microsoft.com/en-us/library/system.security.principal.windowsprincipal.aspx" rel="nofollow noreferrer">WindowsPrincipal</a>, a... | <p>You can use the Profile provider from the asp.net in you Windows App. Check it out @ <a href="http://fredrik.nsquared2.com/viewpost.aspx?PostID=244&showfeedback=true" rel="nofollow noreferrer">http://fredrik.nsquared2.com/viewpost.aspx?PostID=244&showfeedback=true</a></p>
<p>Hope it helps,
Bruno Figueiredo
... | 34,391 |
<p>We want to maintain 3 webservices for the different steps of deployment, but how do we define in our application which service to use? Do we just maintain 3 web references and ifdef the uses of them somehow?</p>
| <p>Don't maintain the differences in code, but rather through a configuration file. That way they're all running the same code, just with different configuration values (ie. port to bind to, hostname to answer to, etc.)</p>
| <p>Put the service address and port into your application's configuration. It's probably a good idea to do the same thing in the service's config, at least for the port, so that your dev service listens on the right port. This way you don't have to modify your code just to change the server/port you're hitting.</p>
... | 13,093 |
<p>I'm talking about <a href="http://en.wikipedia.org/wiki/Quality_of_service" rel="noreferrer">http://en.wikipedia.org/wiki/Quality_of_service</a>. With streaming stackoverflow podcasts and downloading the lastest updates to ubuntu, I would like to have QoS working so I can use stackoverflow without my http connection... | <p>I don't know if this will help you, but I've never been a fan of using the ISP provided box directly. Personally I use a <a href="http://www.newegg.com/Product/ProductList.aspx?Submit=ENE&DEPA=0&Description=wrt54gl&x=0&y=0" rel="nofollow noreferrer">Linksys wrt54gl</a>, with <a href="http://www.dd-wr... | <p>You just need the <a href="http://www.arvanta.net/~mps/linux-tc.html" rel="nofollow noreferrer">tc command</a> to handle the QoS on Linux boxen. However I wouldn't expect that much from it because of the results I obtained and <a href="https://stackoverflow.com/questions/583532/software-router-traffic-monitoring/583... | 2,656 |
<p>I am writing multi-thread socket chat in C++Builder 2009.<br>
It is almost complete in accordance with what I need to do but I have a little problem.
I need to pass the TMemo* pointer into CreateThread WinAPI function which upcasts it to void*.</p>
<p>I tryed this way:<br></p>
<pre><code>HANDLE xxx = MemoChat->... | <p>Call:</p>
<pre><code>TMemo* MemoChat = // You defined that somewhere I assume
HANDLE hNetThread = CreateThread(NULL, 0, NetThread, MemoChat, 0, &dwNetThreadId);
</code></pre>
<p>What is happening here is that any pointer you pass as the third parameter is being auto converted into a void pointer (or ... | <p>This is more to try and clarify the handle vs. pointer thing, because I don't think Martin has it exactly right.</p>
<p>A "pointer to a pointer" is indeed called a HANDLE, and is a common CS approach to allowing the operating system to physically move heap-allocated memory blocks around without the explicit knowle... | 34,630 |
<p>I have a project that I'm currently working on but it currently only supports the .net framework 2.0. I love linq, but because of the framework version I can't use it. What I want isn't so much the ORM side of things, but the "queryability" (is that even a word?) of Linq. </p>
<p>So far the closest is <a href="http... | <p>Have a look at this:</p>
<p><a href="http://www.albahari.com/nutshell/linqbridge.html" rel="noreferrer">http://www.albahari.com/nutshell/linqbridge.html</a></p>
<p>Linq is several different things, and I'm not 100% sure which bits you want, but the above might be useful in some way. If you don't already have a bo... | <p>There's a way to reference LINQ in the .NET 2.0 Framework, but I have to warn you that it <em>might</em> be against the terms of use/EULA of the framework:</p>
<p><a href="https://stackoverflow.com/questions/2138/linq-on-the-net-20-runtime#2146">LINQ on the .NET 2.0 Runtime</a></p>
| 2,921 |
<p>When writing a T-SQL script that I plan on re-running, often times I use temporary tables to store temporary data. Since the temp table is created on the fly, I'd like to be able to drop that table only if it exists (before I create it).</p>
<p>I'll post the method that I use, but I'd like to see if there is a bet... | <pre><code>IF Object_Id('TempDB..#TempTable') IS NOT NULL
BEGIN
DROP TABLE #TempTable
END
</code></pre>
| <pre><code>SELECT name
FROM sysobjects
WHERE type = 'U' AND name = 'TempTable'
</code></pre>
| 2,476 |
<p>I'm wondering if there is an easy way to load data from analysis services (SSAS) into SPSS.</p>
<p>SPSS offers a product to put SPSS functionality on the analysis server, but to me this is backwards. I don't want to learn about SPSS or have the SPSS users in the office learn something else. </p>
<p>I just want t... | <p>You would be better just to point SSPS at the relational datasource that SSAS is using. SSAS is not designed for doing bulk exporting of data. Evne if we did figure out a series of queries it would be many times slower than just querying the original source.</p>
| <p>SSAS has actions. You can fire an action which calls VB.net or c# code to format and import data into SPSS.</p>
| 22,867 |
<p>I'm working on a web-based contest which is supposed to allow anonymous users to vote, but we want to prevent them from voting more than once. IP based limits can be bypassed with anonymous proxies, users can clear cookies, etc. It's possible to use a Silverlight application, which would have access to isolated stor... | <p>The short answer is: no. The longer answer is: but you can make it arbitrarily difficult. What I would do:</p>
<ul>
<li>Voting requires solving a captcha (to avoid as much as possible automated voting). To be even more effective I would recommend to have prepared multiple types of simple captchas (like "pick the ph... | <p>Nope, it's the user's computer and they're in control.
Unfortunately the only solution is to bring it back on your court so to speak and require authentication.</p>
<p>However, a CAPTCHA helps limit the votes to human users at least.</p>
<p>Of course even with authentication you can't enforce single voting because... | 7,965 |
<p>Based on the advice provided at <a href="http://www.tweakguides.com/VA_4.html" rel="nofollow noreferrer">http://www.tweakguides.com/VA_4.html</a> to prevent Windows Vista from "intelligently" rearranging column formats in Windows Explorer, I have written a script to automate the process a little.</p>
<pre><code>Dim... | <p>Does your registry setting have subkeys? I think you have to delete those before you can delete the key.</p>
| <p>Disable UAC in Windows Vista, then this script will just work fine.</p>
| 39,076 |
<p>When using Google Reader and browsing RSS entries in the "Expanded" view, entries will automatically be marked as 'read' once a certain percentage of the div is visible on the screen (difficult to tell what percentage has to be visible in the case of Google Reader). So, as I scroll down line-by-line, the javascript ... | <p>The real trick is to keep track of where the scrollbar is in the element containing your items. Here's some code I once whipped up to do it: <a href="http://pastebin.com/f4a329cd9" rel="nofollow noreferrer">http://pastebin.com/f4a329cd9</a></p>
<p>You can see that as you scroll it changes focus. You just need to ... | <p>In my experience, Reader has only ever marked something as read if I have moused-over or clicked on it. Assuming that as you scroll your mouse is over the div (I tend to put my mouse to the right edge of the screen when I scroll) that might explain the appearance that it only gets marked off when a certain % has be... | 46,128 |
<p>I'm running into a problem trying to anchor a textbox to a form on all 4 sides. I added a textbox to a form and set the Multiline property to True and the Anchor property to Left, Right, Up, and Down so that the textbox will expand and shrink with the form at run time. I also have a few other controls above and be... | <p>The textbox I originally posted about was not inherited from a baseclass form (although it was added to a custom User Control class; I probably should have mentioned that earlier), but I recently ran into the same problem on a totally unrelated set of controls that were inherited from a baseclass form. It's easy to ... | <p>Does the form snap back to the expected layout when you resize it after it's been initialized weirdly? Also, have you set a Height or MinimumHeight/MaximumHeight property for the text box?</p>
<p>If possible, a few snippets from the designer code might be useful. :)</p>
<p>One possibility that I've run into in t... | 41,184 |
<p>I set up my svn in assembla, and I code and test on my local machine that is set up identical to the production server. THen, I commit changes to assembla svn and also ftp upload to my production server.</p>
<p>How can I improve my workflow? I would like to keep my svn on assembla because I can often move to anothe... | <p>Better way is to build nant or MSBuild script that will do all dirty work automated. Those scripts also can ftp upload.</p>
<p>I've using on production server script to checkout last changes from svn, build and sync with production folder.</p>
| <p>If you're working with interpreted languages like PHP, Python or Ruby for example, you can do a clean <a href="http://svnbook.red-bean.com/en/1.0/re10.html" rel="nofollow noreferrer">svn export</a> directly from your repository to the production server, instead of uploading by ftp the source files from your machine.... | 47,638 |
<p>I can write a trivial script to do this but in my ongoing quest to get more familliar with unix I'd like to learn efficient methods using built in commands instead.</p>
<p>I need to deal with very large files that have a variable number of header lines. the last header line consists of the text 'LastHeaderLine'. I ... | <p>Similar to the answer of <a href="https://stackoverflow.com/questions/197150/skip-file-lines-until-a-match-is-found-then-output-the-rest#197169">Avi</a>, but without including the line with "LastHeaderLine".</p>
<pre><code>sed -e '1,/LastHeaderLine/d'
</code></pre>
| <p>Using sed:</p>
<pre><code>sed -ne '/LastHeaderLine/,$p' <inputfile
</code></pre>
<p>will match everything from the regex match to the end of the file. 'p' prints the lines that match.</p>
<p>Edit:</p>
<p>On second thought, you don't want to print the line matching LastHeaderLine. This is difficult to do with ... | 23,975 |
<p>Does anyone have any suggestions as to how I can clean the body of incoming emails? I want to strip out disclaimers, images and maybe any previous email text that may be also be present so that I am left with just the body text content. My guess is it isn't going to be possible in any reliable way, but has anyone tr... | <p>In email, there is couple of agreed markings that mean something you wish to strip. You can look for these lines using <a href="http://www.regular-expressions.info/" rel="noreferrer">regular expressions</a>. I doubt you can't really well "sanitize" your emails, but some things you can look for:</p>
<ol>
<l... | <p>If you creating your own application i'd look into Regex, to find text and replace it. To make the application a little nice, i'd create a class Called Email and in that class i have a property called RAW and a property called Stripped.</p>
<p>Just some hints, you'll gather the rest when you look into regex!</p>
| 47,875 |
<p>I'd like to use sqlmetal to generate dbml data contexts for my project, but the data context and all classes created are marked as <code>public</code>. As this is supposed to be an API layer I'd like to instead mark many of these classes or at least the context itself as <code>internal</code>. Is there a way to do t... | <p>I believe this is one of the options that you can't do directly at the command line. You may indeed have to edit the dbml. However, this isn't a tricky change, so you should be able to automate it with a basic command-line tool.</p>
| <p>You could try using my <a href="http://damieng.com/blog/2008/09/14/linq-to-sql-template-for-visual-studio-2008" rel="nofollow noreferrer">LINQ to SQL template</a> that provides a drop-in replacement for the DBML to C#/VB.NET code generation process that you can completely customize.</p>
<p>[)amien</p>
| 45,991 |
<p>I have always written regexes like this</p>
<pre><code><A HREF="([^"]*)" TARGET="_blank">([^<]*)</A>
</code></pre>
<p>but I just learned about this <a href="http://www.regular-expressions.info/examples.html" rel="nofollow noreferrer">lazy thing</a> and that I can write it like this</p>
<pre><code>&... | <p>Another thing to consider is how long the target text is, and how much of it is going to be matched by the quantified subexpression. For example, if you were trying to match the whole <BODY> element in a large HTML document, you might be tempted to use this regex:</p>
<pre><code>/<BODY>.*?<\/BODY>/i... | <p>“lazy” is the wrong word here. You mean non-greedy as opposed to greedy. There's no disadvantage in using it, that I know of. But in your special case, neither should it be <em>more</em> efficient.</p>
| 47,874 |
<p>What's your preferred method of providing a search facility on a website? Currently I prefer to use <a href="http://incubator.apache.org/lucene.net/" rel="noreferrer" title="Lucene.net">Lucene.net</a> over Indexing Service / SQL Server full-text search (as there's nothing to set up server-side), but what other ways ... | <p>We used both Lucene.net, Indexing Service and SQL Server full-text. For a project with large and heavy DB search functionality SQL search has an upper hand in terms of performance/resource hit. Otherwise Lucene is much better in all aspects.</p>
| <p>you could use google, it's not going to be the fastest indexer but it does provide great results when you have no budget.</p>
| 14,716 |
<p>I'm having a hard time understanding some git/DCVS concepts. Here's what happened:</p>
<ol>
<li>I created a git project, and imported it from an SVN repo</li>
<li>I made some commits</li>
<li>I wanted to experiment something, so I created a branch called <strong>constants-update</strong></li>
<li>I switched to <str... | <p>I solved the problem <a href="http://www.dont-panic.cc/capi/2007/07/13/git-on-windows-you-have-some-suspicious-patch-lines/" rel="nofollow noreferrer">hacking my pre-commit hook</a> (commenting these lines in <code>.git/hooks/pre-commit</code> with a <code>#</code>):</p>
<pre><code># if (/\s$/) {
# bad_... | <p>Lookup git-stash for changing branches while there are unsaved changes in the current branch.</p>
| 32,174 |
<p>I am porting an MFC application to .NET WinForms. In the MFC application, you can right click on a menu or on a context menu item and we show another context menu with diagnostic and configuration items. I am trying to port this functionality to .NET, but I am having trouble.</p>
<p>I have been able to capture the ... | <p>Edit, due to a comment:</p>
<p>In:</p>
<pre><code>protected override void OnClick(EventArgs e)
{
if (SecondaryContextMenu == null || MouseButtons != MouseButtons.Right)
{
base.OnClick(e);
}
}
</code></pre>
<p>this part </p>
<pre><code> MouseButtons != MouseButtons.Right
</code></pre>
<p>shou... | <p>This shows how to use multiple ContextMenus as well as different ones with any combination of mouse clicks.</p>
<p>More here: <a href="http://code.msdn.microsoft.com/TheNotifyIconExample" rel="nofollow noreferrer">http://code.msdn.microsoft.com/TheNotifyIconExample</a></p>
| 35,671 |
<p>I am about to build a piece of a project that will need to construct and post an XML document to a web service and I'd like to do it in Python, as a means to expand my skills in it. </p>
<p>Unfortunately, whilst I know the XML model fairly well in .NET, I'm uncertain what the pros and cons are of the XML models in... | <p>Personally, I've played with several of the built-in options on an XML-heavy project and have settled on <a href="http://docs.python.org/lib/module-xml.dom.pulldom.html" rel="noreferrer">pulldom</a> as the best choice for less complex documents.</p>
<p>Especially for small simple stuff, I like the event-driven theo... | <p>I assume that the .NET way of processing XML builds on some version of MSXML and in that case I assume that using, for example, minidom would make you feel somewhat at home. However, if it is simple processing you are doing, any library will probably do.</p>
<p>I also prefer working with ElementTree when dealing wit... | 2,284 |
<p>Does string immutability work by statement, or by strings within a statement? </p>
<p>For example, I understand that the following code will allocate two strings on the heap.</p>
<pre><code>string s = "hello ";
s += "world!";
</code></pre>
<p>"hello" will remain on the heap until garbage collected; and s now refe... | <p>The compiler has special treatment for string concatenation, which is why the second example is only ever <strong>one</strong> string. And "interning" means that even if you run this line 20000 times there is still only 1 string.</p>
<p>Re testing the results... the easiest way (in this case) is probably to look in... | <p>If the compiler is "intelligent", it will only be one string with "goodbye cruel world!"</p>
| 48,675 |
<p>Say I have a web service <a href="http://www.example.com/webservice.pl?q=google" rel="noreferrer">http://www.example.com/webservice.pl?q=google</a> which returns text "google.com". I need to call this web service (<a href="http://www.example.com/webservice.pl" rel="noreferrer">http://www.example.com/webservice.pl</a... | <p>Take a look at one of the many javascript libraries out there. I'd recommend <a href="http://www.jquery.com" rel="noreferrer">jQuery</a>, personally. Aside from all the fancy UI stuff they can do, it has really good <a href="http://docs.jquery.com/Ajax" rel="noreferrer">cross-browser AJAX libraries</a>.</p>
<pre><c... | <p><strong>EDIT:</strong> </p>
<p>It has been a decade since I answered this question and we now have support for cross-domain XHR in the form of <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" rel="nofollow noreferrer">CORS</a>.</p>
<p>For any modern app consider using <a href="https://developer.moz... | 14,435 |
<p>I'm writing a little desktop app that should be able to encrypt a data file and protect it with a password (i.e. one must enter the correct password to decrypt). I want the encrypted data file to be self-contained and portable, so the authentication has to be embedded in the file (or so I assume).</p>
<p>I have a ... | <h3>Key Generation</h3>
<p>I would recommend using a recognized algorithm such as PBKDF2 defined in <a href="ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-5v2/pkcs5v2-0.pdf" rel="nofollow noreferrer">PKCS #5 version 2.0</a> to generate a key from your password. It's similar to the algorithm you outline, but is capable of ge... | <p>Is there really need to save the hashed password into the file. Can't you just use the password (or hashed password) with some salt and then encrypt the file with it. When decrypting just try to decrypt the file with the password + salt. If user gives wrong password the decrypted file isn't correct.</p>
<p>Only dra... | 7,971 |
<p>In Internet Explorer I can use the clipboardData object to access the clipboard. How can I do that in FireFox, Safari and/or Chrome?</p>
| <p>For security reasons, Firefox doesn't allow you to place text on the clipboard. However, there is a workaround available using Flash.</p>
<pre><code>function copyIntoClipboard(text) {
var flashId = 'flashId-HKxmj5';
/* Replace this with your clipboard.swf location */
var clipboardSWF = 'http://appengin... | <p>A slight improvement on the Flash solution is to detect for Flash 10 using swfobject:</p>
<p><a href="http://code.google.com/p/swfobject/" rel="nofollow noreferrer">http://code.google.com/p/swfobject/</a></p>
<p>And then if it shows as Flash 10, try loading a Shockwave object using JavaScript. Shockwave can read/wri... | 15,460 |
<p>I'm looking for a very specific USB device for debugging systems that may use USB but not with a regular computer (proprietary hardware). I want a device that has a USB host controller and two USB device connections. The device to be debugged is connected to the USB host controller and one of the device connections ... | <p>Sniffing the USB shouldn't be too hard if you have the right hardware. And that is the tricky question. I haven't seen anything that describes the USB breakout box that you want. However I can say that this is in the realm of the following two magazines:</p>
<ol>
<li><a href="http://www.nutsvolts.com" rel="nofol... | <p>Sorry for the long delay in my reply -- I checked out one of our USB developer's toolchain, and he uses a <a href="http://www.avrfreaks.net/index.php?module=Freaks%20Tools&func=viewItem&item_id=913" rel="nofollow noreferrer">Beagle USB Sniffer</a>. He seems happy with it.</p>
| 41,590 |
<p>Just to clarify, I'm running Sybase 12.5.3, but I am lead to believe that this holds true for SQL Server 2005 too. Basically, I'm trying to write a query that looks a little like this, I've simplified it as much as possible to highlight the problem:</p>
<pre><code>DECLARE @a int, @b int, @c int
SELECT
@a = h... | <p>The error does appear as described in 12.5.3 esd 4 & 7, it runs fine in 12.5.4 esd 4 & 6.</p>
<p>Looks like a bug that's been patched, your only options seem to be workaround or patch.</p>
<p>Have found what appears to be the <a href="http://search.sybase.com/kbx/changerequests?bug_id=377625" rel="nofollow... | <p>I've just ran your code against 12.5.3 and it parses fine...doesn't return anything but it does run. Have you maybe simplified the problem a bit too much because I'm not seeing any error messages at all.</p>
<p>Just to be clear, the following runs and returns what you'd expect.</p>
<pre><code>DECLARE @a int, @b i... | 29,581 |
<p>I posted a <a href="https://stackoverflow.com/questions/81306/wcf-faults-exceptions-versus-messages">question</a> about using Messages versus Fault Exceptions to communicate business rules between services.</p>
<p>I was under the impression it carried overhead to throw this exception over the wire, but considering ... | <p>Well... In general you shouldn't be throwing exceptions for expected conditions, or anything you <em>expect</em> to happen regularly. They are massively slower than doing normal methods. E.g., if you expect a file open to fail, don't throw a that exception up to your caller, pass the back a failure code, or provid... | <p>It's just like a normal exception, and uses the same wrapping code as a normal exception would to marshal into a fault, including unwinding the stack.</p>
<p>Like exceptions SOAP faults shouldn't, to my mind, be used for program flow, but to indicate errors.</p>
| 12,524 |
<p>Is there an openID implementation in Java? I would like to use this in a tomcat application.</p>
| <p>The <a href="https://github.com/jbufu/openid4java" rel="nofollow noreferrer">openid4java</a> library seems to be the most popular.</p>
| <p>If you don't mind using a service there is <a href="http://rpxnow.com" rel="nofollow noreferrer">RPX</a></p>
| 49,295 |
<p>I am trying to install VS2008 sp1 to my work machine - it has a pathetic 10Gb C drive. The SP1 bootstrapper doesn't give the option to install items to D, only C. It needs 3Gb free and the machine only has about 700Mb.</p>
<p>VS allowed me to install to D originally why not the SP. The only thing I can think of tha... | <p>Worth a read:</p>
<p><a href="http://blogs.msdn.com/heaths/archive/2008/07/24/why-windows-installer-may-require-so-much-disk-space.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/heaths/archive/2008/07/24/why-windows-installer-may-require-so-much-disk-space.aspx</a></p>
| <p>You could also download the full VS2008 SP1 ISO image from <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=27673c47-b3b5-4c67-bd99-84e525b5ce61&displaylang=en" rel="nofollow noreferrer">here</a>.</p>
<p>Then you can either burn it to DVD or use a tool such as <a href="http://download.microsoft... | 3,016 |
<p>What's the fastest way to count the number of keys/properties of an object? Is it possible to do this without iterating over the object? I.e., without doing:</p>
<pre><code>var count = 0;
for (k in myobj) if (myobj.hasOwnProperty(k)) ++count;
</code></pre>
<p>(Firefox did provide a magic <code>__count__</code> prop... | <p>To do this in any <em><a href="https://en.wikipedia.org/wiki/ECMAScript#5th_Edition" rel="noreferrer">ES5</a>-compatible environment</em>, such as <a href="http://nodejs.org" rel="noreferrer">Node.js</a>, Chrome, <a href="https://en.wikipedia.org/wiki/Internet_Explorer_9" rel="noreferrer">Internet Explorer 9+</a>, F... | <p>If jQuery in previous answers does not work, then try</p>
<pre><code>$(Object.Item).length
</code></pre>
| 15,332 |
<p>I have a Stored procedure which schedules a job. This Job takes a lot of time to get completed (approx 30 to 40 min). I need to get to know the status of this Job.
Below details would help me</p>
<p>1) How to see the list of all jobs that have got scheduled for a future time and are yet to start</p>
<p>2) How to s... | <p>You could try using the system stored procedure sp_help_job. This returns information on the job, its steps, schedules and servers. For example</p>
<pre><code>EXEC msdb.dbo.sp_help_job @Job_name = 'Your Job Name'
</code></pre>
<p><a href="http://msdn.microsoft.com/en-us/library/ms186722(SQL.90).aspx" rel="noreferr... | <p>The most simple way I found was to create a stored procedure. Enter the 'JobName' and hit go.</p>
<pre><code>/*-----------------------------------------------------------------------------------------------------------
Document Title: usp_getJobStatus
Purpose: Finds a Current Jobs Run Status
... | 24,411 |
<p>Is it possible to reset the alternate buffer in a vim session to what it was previously?</p>
<p>By alternate buffer, I mean the one that is referred to by #, i.e. the one that is displayed when you enter cntl-^.</p>
<p>Say I've got two files open main.c and other.c and :ls gives me:</p>
<pre><code> 1 %a "main.... | <p>In this case, "alternate" just means "previous". So, yes, :b2 (or 2 ctrl-6) is probably the easiest way to change which two buffers will be toggled by ctrl-6.</p>
<p>Also, take a look at the :keepalt command.</p>
| <p>As you'll come to expect with Vim, there is an excellent reason for this behaviour. <code>:bd</code> (mnemonic for buffer delete) does <em>not</em> delete the buffer, per se, it <em>deletes it from the main buffer list</em>!</p>
<p>If you try <code>:ls!</code> or <code>:buffers!</code> you will see it is is still a... | 19,227 |
<p>What's the best way for determining whether the user's browser can view PDF files? </p>
<p>Ideally, it shouldn't matter on the browser or the operating system.</p>
<p>Is there a specific way of doing it in ASP.NET, or would the answer be just JavaScript?</p>
| <p>Neither, none, don't try.</p>
<p>Re <a href="https://stackoverflow.com/questions/76179/how-to-determine-if-the-users-browser-can-view-pdf-files#76220">dawnerd</a>: Plug-in detection is not the right answer. I do not have a PDF plugin installed in my browser (Firefox on Ubuntu), yet I am able to view PDF files using... | <p>A quick google search <a href="http://www.oreillynet.com//cs/user/view/cs_msg/9920" rel="nofollow noreferrer">found this</a>. Useful for all kinds of plugins.</p>
| 10,175 |
<p>I say properly because everyone I have spoken to in the past said running Django on IIS was a hack. I had it working somewhat but it never did quite right and did feel like a hack. I like python but had to give it up because I could never make Django work with IIS and Django was my excuse to use Python in producti... | <p>Django is WSGI-based framework so as soon as IIS get proper WSGI handling there should be no problem in running Django under this environment. Anything that connects WSGI and IIS will do.</p>
<p>Quick googling reveals <a href="http://code.google.com/p/isapi-wsgi/" rel="nofollow noreferrer">some project on Google Co... | <p>You should be able to use the FastCGI isapi developed by MS. It works on 6 but has better integration on 7. Disclaimer: I haven't tried it with Django.</p>
| 49,021 |
<p>Is there a way to emulate mixins or traits in java? basically, I need a way to do multiple inheritance so I can add common business logic to several classes</p>
| <p>I would encapsulate all of the business logic into a new class <code>BusinessLogic</code> and have each class that needs <code>BusinessLogic</code> make calls to the class. If you need a single rooted heirarchy for your classes that make calls to <code>BusinessLogic</code>, you'll have to create an interface as we... | <p>Implementing simple mixin/traits support in java using CGLib/javassit is quite easy.
You can take a look for instance <a href="http://justonjava.blogspot.com/2011/10/mixins-aka-traits-implementation-in.html" rel="nofollow">here</a> for small example.
More complete, ready to use solution might be found: <a href="http... | 32,938 |
<p>I am building a FAQ module for my site and I want to be able to control single elements on the page even though they all have the same class. I believe this comes under siblings which I am not yet familiar with.</p>
<p>Basically I want the user to be able to click the question div and then when they click it the an... | <p>If I understand your question correctly, you should
Start by setting all answers as hidden in the css:
.answer {display:none;}</p>
<p>Then you can use jquery to show the correct answer to the clicked questions : </p>
<pre><code>$(document).ready ( function () {
$('.question').click(function() {
$(this... | <p>You should probably check out this <a href="https://stackoverflow.com/questions/233936/jquery-swapping-elements">question</a> where something similar is done.</p>
<p>Basically, you first need to setup ID's for your elements so that you can identify single elements within the set classes.</p>
<p>You could then add ... | 32,716 |
<p>I need to copy hundreds of gigs of random files around on my computer and am pretty leery of using the vanilla file copy built into Windows.</p>
<p>I don't want it to hang on a "Are you sure?", "Are you really sure?", "Even zip files?", "Surely not read-only files too!" loop as soon as I step away.</p>
<p>I don't ... | <p>Use <a href="http://en.wikipedia.org/wiki/Robocopy" rel="noreferrer">Robocopy (Robust File Copy)</a>.</p>
<p>NOTE:</p>
<p>In Windows Vista and Server 2008 when you type:</p>
<pre><code>xcopy /?
</code></pre>
<p>you get:</p>
<blockquote>
<p>NOTE: Xcopy is now deprecated, please use Robocopy.</p>
</blockquote>
... | <p>Reboot into Linux, mount the drive, and use GNU <code>cp</code>.</p>
| 2,375 |
<p>What is the best way to store a large number of data points?</p>
<p>For example temperature values which are measured every minute over lots of locations?</p>
<p>SQL databases with one row per data points doesn't seem very efficient.</p>
| <p>I would like to know why you reckon it to be "not efficient". Probably you need to explain your data model and schema to give a better context of the scenario.</p>
<p>Storing multiple data points into a single row, when they are not related to each other, and should indeed stand on their own, is not a good approach... | <p>Store them in a data table as rows and columns because the data table can later be partitioned by Year, Month, and Location for your temperatures for extraction speed using parallel processing.</p>
| 31,893 |
<p>Web parts seem to be used extensively in Sharepoint related development, but examples of using them in asp.net webforms applications are few and far between. I'm implementing a domain specific portal framework and like the "widgetlike" functionality in iGoogle or pageflakes and would like to get that kind of featur... | <p>i think they are (dead), at least for developing the types of UI modern web-browsers are looking for. My recommendation ... ASP.NET MVC and a nice .js library. It's more work out of the gate, but with the proper planning and implementation it will serve you much better in the long run.</p>
| <p>Webparts are a part of the .NET infrastructure and are a foundation technology. There are few interface technologies, to make webparts compatible with their J2EE counterparts.</p>
| 38,911 |
<p>How do I connect to Gmail and determine which messages have attachments? I then want to download each attachment, printing out the Subject: and From: for each message as I process it.</p>
| <p>Hard one :-)</p>
<pre><code>import email, getpass, imaplib, os
detach_dir = '.' # directory where to save attachments (default: current)
user = raw_input("Enter your GMail username:")
pwd = getpass.getpass("Enter your password: ")
# connecting to the gmail imap server
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.log... | <p>Have you taken a look at the <a href="http://en.wikipedia.org/wiki/Gmail#Gmail_3rd_party_Add-Ins" rel="nofollow noreferrer">GMail 3rd party add-ons</a> at wikipedia?</p>
<p>In particular, <a href="http://en.wikipedia.org/wiki/PhpGmailDrive" rel="nofollow noreferrer">PhpGmailDrive</a> is an open source add-on that y... | 45,358 |
<p>Please excuse the vague title. If anyone has a suggestion, please let me know! Also please retag with more appropriate tags!</p>
<p><strong>The Problem</strong></p>
<p>I want to have an instance of an imported class be able to view things in the scope (globals, locals) of the importer. Since I'm not sure of the... | <p>In this example, you can simply hand over functions as objects to the methods in <code>C1</code>:</p>
<pre><code>>>> class C1(object):
>>> def eval(self, x):
>>> x()
>>>
>>> def f2(): print "go f2"
>>> c = C1()
>>> c.eval(f2)
go f2
</code></pr... | <p>Functions are always executed in the scope they are defined in, as are methods and class bodies. They are never executed in another scope. Because importing is just another assignment statement, and everything in Python is a reference, the functions, classes and modules don't even know where they are imported to.</p... | 14,267 |
<p>Ok, this is a weird one. The junk data isn't random either, it appears to be substrings of the executable itself.</p>
<pre><code>private void Form1_Load(object sender, EventArgs e)
{
string s = GetValue();
// at this point, s == "400". Why isn't really relevant (dumbed down a test)
if (s != "18446744073... | <p>"And I'm checking it in the "Locals" window in VS"</p>
<p>That explains it. Contrary to popular belief, C# is allowed to do some amount of optimization. If you don't add a "KeepAlive" at the end of your function, the value doesn't really have to be stored.</p>
| <p>If you're checking the variable after the exception has been thrown and is now out of scope, then it should be pointing to nothing more than garbage sitting in memory. Have you tried checking the value of this variable both before and after the exception has been thrown?</p>
| 21,867 |
<p>I have the following preprocessor divective:</p>
<pre><code>#ifndef NDEBUG
#define TRACE printf
#else
#define TRACE(...)
#endif
</code></pre>
<p>and example of usage is:</p>
<pre><code>TRACE("TRACE: some parameter = %i\n", param);
</code></pre>
<p>In C all works perfectly well when I build both debug and release... | <p>You could do:</p>
<pre><code>inline void TRACE(...) {}
</code></pre>
| <p>You could do:</p>
<pre><code>inline void TRACE(...) {}
</code></pre>
| 20,054 |
<p>I have C# wrapper of a C Library. It has a method that returns an sbyte that is supposed to represent a char. I can use Convert.ToChar but this is not CLS-compliant. What is the best practice for converting this sbyte to a char compliantly?</p>
| <p>System.Buffer.BlockCopy can be used to convert sbyte arrays to byte arrays. Then, you can use the System.Text.ASCIIEncoding to do the conversion of the byte array to ASCII text. </p>
| <p>System.Buffer.BlockCopy can be used to convert sbyte arrays to byte arrays. Then, you can use the System.Text.ASCIIEncoding to do the conversion of the byte array to ASCII text. </p>
| 27,454 |
<p>The controllers in my ASP.NET MVC web app are starting to get a bit bloated with business logic. The examples on the web all show simple controller actions that simply pull data out of a repository and pass it to the view. But what if you also need to support business logic on top of that? </p>
<p>Say, for insta... | <p>Your controllers (in the MVC project) should be calling your objects in the Service project. The services project is where all the business logic is handled.</p>
<p>A good example is this:</p>
<pre><code>public ActionResult Index()
{
ProductServices productServices = new ProductServices();
// top 10 produ... | <p>Your business logic should be encapsulated in business objects - if you have an Order object (and you do, don't you?), and a business rule states that an email should be sent when the Order is fulfilled, then your Fulfill method (or, if more appropriate, the setter for IsFulfilled) should trigger that action. I woul... | 43,990 |
<p><strong>Here is the context</strong><br/>
I've got an old car for which I have a small plastic piece who is broken. As it's an old car and a very specific piece, I can't find it anymore. So I was thinking about 3D printing it.</p>
<p>My problem is this piece is on the carburetor, so close to the engine. This means,... | <p>The number you're looking for is the <a href="https://en.wikipedia.org/wiki/Glass_transition" rel="noreferrer">glass transition temperature</a> (the lowest temperature at which the material can flow or warp), not the melting point. This depends on what material you're using; approximate temperatures for common prin... | <p>Nylon is probably your best bet.
It is resistant to some chemicals as well.
Figure on printing it at around 250 °C.</p>
<p>It might do the job.</p>
| 1,530 |
<p>I am using the <strong><a href="http://en.wikipedia.org/wiki/JQuery" rel="noreferrer">jQuery</a> validation plugin</strong>. Great stuff! I want to migrate my existing ASP.NET solution to use jQuery instead of the ASP.NET validators. I am missing a replacement for the <strong>regular expression</strong> validator. I... | <p>Thanks to the answer of redsquare I added a method like this:</p>
<pre class="lang-js prettyprint-override"><code>$.validator.addMethod(
"regex",
function(value, element, regexp) {
var re = new RegExp(regexp);
return this.optional(element) || re.test(value);
},
"Please check your input... | <p>Have you tried this??</p>
<pre><code>$("Textbox").rules("add", { regex: "^[a-zA-Z'.\\s]{1,40}$", messages: { regex: "The text is invalid..." } })
</code></pre>
<p>Note: make sure to escape all the "\" of ur regex by adding another "\" in front of them else ... | 35,511 |
<p>What's the best way to use Bazaar (bzr) as the version control system in Visual Studio 2008?</p>
| <p>The best I found is <a href="http://bazaar-vcs.org/TortoiseBzr" rel="noreferrer">TortoiseBZR</a> and the command-line - nothing integrated with VS.</p>
| <p>Unified SCC has support for bzr. It is commercial but claims to be free for OSS projects.</p>
<p><a href="http://aigenta.com/products/UnifiedScc.aspx" rel="nofollow" title="UnifiedSCC">UnifiedSCC</a></p>
| 43,977 |
<p>I have a scenario where I'm not really sure my approach is the best one, and I would appreciate feedback / suggestions.</p>
<p>scenario:
I have a bunch of flash based (swf) 'modules' which are hosted in my aspnet application. Each flash has it's own directory on the filesystem, which contains assets for the flash. ... | <p>Have you considered simply validating resource access through an HTTP request to the server after the swf loads?</p>
<p>Where I work we provide online trainings to users through flash but rather than verify the HTTP request itself, we allow the swf's to load first and then make a request to the server to verify tha... | <p>Why not go with an ISAPI filter?<br>
Okay, dont answer that - plenty of reasons ;-). But seriously, if you have the dev power for it, you might want to consider that route.</p>
<p>Otherwise, HTTP Module does seem the better route, IF you have a short, closed list of extensions you have to deal with (GIF, JPG, MP3).... | 20,531 |
<p>Is there any reason for the use of 'T' in generics? Is it some kind of abbreviation? As far as I know, everything works. For example </p>
<pre><code>public G Say<G>(){ ... }
</code></pre>
<p>or even</p>
<pre><code>public Hello Say<Hello>(){ ... }
</code></pre>
| <p>T is for <strong>T</strong>ype. But it's really just a tradition and there is nothing to prevent you from using other names. For example, generic dictionaries use <code><TKey, TValue></code>.</p>
<p>There is also a <a href="http://msdn.microsoft.com/lv-lv/library/ms229040(en-us).aspx" rel="noreferrer">Microso... | <blockquote>
<p><em>T for Type</em></p>
</blockquote>
<p>Also, E is used for Element that's very common too. You're right G also works.</p>
| 48,906 |
<p>In a Delphi Form, I would like to replace one visual component with another. Example: I want to replace a Panel component with an ElPanel from a 3rd party package. </p>
<p>I would like all identical properties and events of the first component to be transferred to the new one, and all the components that belong to ... | <p>I do it as following:</p>
<ol>
<li>Right click on the form and choose (View as Text).</li>
<li>Press Ctrl + F to search for the Component class name like TPanel and replace it with TElPanel</li>
<li>Switch back to back to the form (View as form)</li>
<li>In the interface section replace the TPanel with TElPanel.</l... | <p>In my project I had to convert few doezens forms from one set of components to another.
I have created small perl script to convert components and its properties and do all neccesary mapings.
The script is quick&dirty solution but it is highly configurable. It scanns all dfm and pas files in project direcotory ... | 29,552 |
<p>Is it possible to set the cursor to 'wait' on the entire html page in a simple way? The idea is to show the user that something is going on while an ajax call is being completed. The code below shows a simplified version of what I tried and also demonstrate the problems I run into:</p>
<ol>
<li>if an element (#id1)... | <p>If you use this slightly modified version of the CSS you posted from Dorward,</p>
<pre><code>html.wait, html.wait * { cursor: wait !important; }
</code></pre>
<p>you can then add some really simple <a href="http://api.jquery.com/" rel="noreferrer">jQuery</a> to work for all ajax calls:</p>
<pre><code>$(document).... | <p>Late to the party but simply give the Html tag an id by targeting</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>document.documentElement</code></pre>
</div>
</div>
</... | 23,441 |
<p>I'm planning to write a javascript-based web application. I'm wondering what the best way to implement it in terms of file stucture is.</p>
<p>There is one main page (main.html) containing a menu and a main div section. The way it works is simple: When the user clicks on one of the links in the menu (for example 'P... | <p>It might be of no consequence to you but you know that from an SEO perspective this is a terrible idea. Your site will be a Javascript version of a flash site. There will be only one page as far as the search engines are concerned.</p>
<p>That's why sites based on frames, which were quite popular for a number of ye... | <p>Loading of JavaScript files is synchronous, which negatively affects page loading time/perceived responsiveness.</p>
<p>For that reason I think it's best to merge all scripts into one file, compress it with YUI compressor and send gzipped. You'll get best compression and least HTTP overhead this way, and cached JS ... | 41,116 |
<p>I'm using repository pattern with LINQ, have IRepository.DeleteOnSubmit(T Entity). It works fine, but when my entity class has interface, like this: </p>
<pre><code>public interface IEntity { int ID {get;set;} }
public partial class MyEntity: IEntity {
public int ID {
get { return this.IDfield; }
... | <p>It appears Microsoft dropped support for <code>==</code> operator in interfaces when using linq-to-sql in MVC4 (or maybe it was never supported). You can however use <code>i.ID.Equals(someId)</code> in place of the <code>==</code> operator.</p>
<p>Casting <code>IQueryable</code> to <code>IEnumerable</code> works bu... | <p>Try this:</p>
<pre><code>using System.Data.Linq.Mapping;
public partial class MyEntity: IEntity
{ [Column(Storage="IDfield", DbType="int not null", IsPrimaryKey=true)]
public int ID
{
get { return this.IDfield; }
set { this.IDfield=value; }
}
}
... | 3,514 |
<p>I have a dev, that will get around our code coverage by writing tests that never fail.</p>
<p>The code is just atrocious, but the tests never catch it because they assert(true).</p>
<p>I code review, but I can't do everyones work for them, all the time. How do you get people like this motivated to make good softwa... | <p>Real motiviation comes from within. Some people will game the system every chance they get sometimes for no other reason than they can. Others do it simply because they are hacks.</p>
<p>That said, assuming your the manager, have a "come to jesus" meeting with the dev. If that still doesn't work, there's always ... | <p>You should really specify the language / framework you're using.</p>
<p>In the simplest case, I suppose it should be easy to detect <code>assert(true)</code> strings with simple <code>grep</code>-ping.</p>
| 13,084 |
<p>On the web side we are working on getting source control. Now, I want to see what can be done for the iSeries side. What is your favorite source control application for iSeries and why? I am looking for low-cost if possible.</p>
| <p>The two most common source control packages for the iSeries are <a href="http://www.softlanding.com/turnover/index.htm" rel="nofollow noreferrer">Turnover</a> and <a href="http://www.aldon.com/products/lmi/" rel="nofollow noreferrer">Aldon</a>. Neither are low cost but integrate well with the iSeries.</p>
<p>I pref... | <p>If you're using the <strong>WebSphere Development Studio</strong> or <strong>Rational</strong> from a PC then any source control system that will play nicely with that is an option if you don't want to shell out for the native iSeries one.</p>
| 16,376 |
<p>Sometimes I have made some local changes and for whatever reason don't want to commit them to the source repository. In this case I like to zip up and save off my changes on my local file system until I am ready to commit them at a later date.</p>
<p>I recall that in an earlier version of eclipse, there was a cont... | <p>It's not on the context menu, but going to the Navigate menu up top and selecting "Show In->Navigator" will apply that selection. Whether or not you can export just the selected files, I don't know.</p>
| <p>This is how I do in eclipse 2019-06 (4.12.0)</p>
<p>Suppose, I am working on an issue of Primeface Upgrade and a new issue came. I need to take a backup of the existing changes related to the PF upgrade to a specific changeset, say <em>upgrade</em> first. Following is the process</p>
<ol>
<li>Open Team Synchronizing... | 25,077 |
<p>When attempting to call functions in <code>math.h</code>, I'm getting link errors like the following </p>
<pre><code>undefined reference to sqrt
</code></pre>
<p>But I'm doing a <code>#include <math.h></code><br>
I'm using gcc and compiling as follows:</p>
<pre><code>gcc -Wall -D_GNU_SOURCE blah.c -o blah
... | <p>Add -lm to the command when you call gcc:<br>
gcc -Wall -D_GNU_SOURCE blah.c -o blah -lm</p>
<p>This will tell the linker to link with the math library. Including math.h will tell the compiler that the math functions like sqrt() exist, but they are defined in a separate library, which the linker needs to pack with... | <p>You need to link the math library explicitly. Add <code>-lm</code> to the flags you're passing to gcc so that the linker knows to link <code>libm.a</code></p>
| 12,896 |
<p>I want to install a gem on all my application servers, but gem install requires sudo access - how can I enable sudo only for running this capistrano command? </p>
<p>In other words, I don't wish to use sudo for all my deployment recipes, just when I invoke this command on the command line.</p>
| <p>Found it - cap invoke COMMAND="<em>command that requires sudo</em>" SUDO=1</p>
| <p>It would be best to use unix ACLs or similar permissions for this. Give the deploy user sudoer access, then you can call <code>run "sudo do_something"</code> and it will be sudo-level access only for that call.</p>
| 15,678 |
<p>I have worked on projects for embedded systems in the past where we have rearranged the order of declaration of stack variables to decrease the size of the resulting executable. For instance, if we had:</p>
<pre><code>void func()
{
char c;
int i;
short s;
...
}
</code></pre>
<p>We would reorder th... | <p>As there is nothing in the standard prohibiting that for C or C++ compilers, yes, the compiler can do that. </p>
<p>It is different for aggregates (i.e. structs), where the relative order must be maintained, but still the compiler may insert pad bytes to achieve preferable alignment. </p>
<p>IIRC newer MSVC compil... | <p>it is compiler specifics, one can make his own compiler that would do the inverse if he wanted it that way.</p>
| 29,487 |
<p>I'm trying to load test data into a test DB during a maven build for integration testing. persistence.xml is being copied to <code>target/test-classes/META-INF/</code> correctly, but I get this exception when the test is run.</p>
<blockquote>
<p>javax.persistence.PersistenceException:
No Persistence provider fo... | <p>Just solved the same problem with a Maven/Eclipse based JPA project.</p>
<p>I had my META-INF directory under <code>src/main/java</code> with the concequence that it was not copied to the target directory before the test phase.</p>
<p>Moving this directory to <code>src/main/resources</code> solved the problem and ... | <p>we got the same problem, does some tweaking on the project and finaly find following
problem (more clear error description):
at oracle.toplink.essentials.ejb.cmp3.persistence.
PersistenceUnitProcessor.computePURootURL(PersistenceUnitProcessor.java:248)</p>
<p>With that information we recalled a primary rule:
NO ... | 10,222 |
<p>How do you handle update refresh rate from your worker function to your UI ?</p>
<p>Sending everything to the UI or maybe using a timer (from which side ? worker or UI ?)</p>
| <p>Just for some clarification. In the early microprocessor days of the 1970's, CPUs had only a small number of registers and a very limited instruction set. Typically, the arithmetic unit could only operate on a single CPU register, often referred to as the "accumulator". The accumulator on the 8 bit 8080 & Z80 pr... | <p>In the old 8-bit days, there was the A register.</p>
<p>In the 16-bit days, there was the 16 bit AX register, which was split into two 8 bit parts, AH and AL, for those times when you still wanted to work with 8 bit values.</p>
<p>In the 32-bit days, the 32 bit EAX register was introduced, but the AX, AH, and AL r... | 28,241 |
<p>CSS and Javascript files don't change very often, so I want them to be cached by the web browser. But I also want the web browser to see changes made to these files without requiring the user to clear their browser cache. Also want a solution that works well with a version control system such as Subversion.</p>
<hr ... | <p>I found that if you append the last modified timestamp of the file onto the end of the URL the browser will request the files when it is modified. For example in PHP:</p>
<pre><code>function urlmtime($url) {
$parsed_url = parse_url($url);
$path = $parsed_url['path'];
if ($path[0] == "/") {
$filenam... | <p>Some solutions I have seen involve adding a version number to the end of the file in the form of a query string.</p>
<pre><code><script type="text/javascript" src="funkycode.js?v1">
</code></pre>
<p>You could use the SVN revision number to automate this <a href="https://stackoverflow.com/questions/2308/aspne... | 2,539 |
<p>I have a series of text that contains mixed numbers (ie: a whole part and a fractional part). The problem is that the text is full of human-coded sloppiness:</p>
<ol>
<li>The whole part may or may not exist (ex: "10")</li>
<li>The fractional part may or may not exist (ex: "1/3")</li>
<li>The two parts may be separa... | <p>Here's a regex that will handle all of the data I can throw at it:</p>
<pre><code>(\d++(?! */))? *-? *(?:(\d+) */ *(\d+))?.*$
</code></pre>
<p>This will put the digits into the following groups:</p>
<ol>
<li>The whole part of the mixed number, if it exists</li>
<li>The numerator, if a fraction exits</li>
<li>The ... | <p>If you are using <code>Perl 5.10</code>, this is how I would write it.</p>
<pre>
m{
^
\s* # skip leading spaces
(?'whole'
\d++
(?! \s*[\/] ) # there should not be a slash immediately following a whole number
)
\s*
(?: # the rest should fail or succeed as a group
-? # igno... | 30,435 |
<p><strong>Concrete use case:</strong>
In the Eclipse IDE, new 'plugins' can be added by copying a plugin's file(s) into the <code>$ECLIPSE_HOME/plugins</code> directory. However, I want to keep my original Eclipse installation 'clean' without additional plugins because I want to run this basic installation on its own ... | <p>You could use an overlay filesystem for this. The three overlay filesystems that I know of in Linux are <a href="http://en.wikipedia.org/wiki/UnionFS" rel="nofollow noreferrer">unionfs</a>, <a href="http://aufs.sourceforge.net/" rel="nofollow noreferrer">aufs</a>, and <a href="http://www.denx.de/wiki/Know.MiniFOHome... | <p>Have a look at <strong><a href="http://www.ibm.com/developerworks/library/os-ecl-manage/" rel="nofollow noreferrer">Manage your eclipse environment</a></strong> article, especially the Method 3</p>
<blockquote>
<p>Creating a links folder to manage product extensions</p>
<p>If you have product extensions sitting on y... | 18,990 |
<p>I have a div tag styled through CSS. I set the padding to 10px (padding:10px), it works just as I wanted in Firefox and IE7, but in IE6 it adds additional padding at the bottom (about 2-3px I think). Anyone has idea about what's happening here?</p>
<p>[update]</p>
<p>I just noticed this, the div tag I'm talking a... | <p>Is there an image in your div? If there's an image, there's a bug in IE 6 that can cause white space within the div to create extra padding on the bottom</p>
<p>Extra padding shows up with</p>
<pre><code><div>
<img src="myimage.jpg">
</div>
</code></pre>
<p>Extra padding doesn't show up when you... | <p>potentially 'margin' or 'border' properties?</p>
| 47,217 |
<p>I have an MFC legacy app that I help to maintain. I'm not quite sure how to identify the version of MFC and I don't think it would make a difference anyway. </p>
<p>The app can take some parameters on the command line; I would like to be able to set an errorlevel on exiting the app to allow a bat/cmd file to chec... | <p>I can't take credit for this so please don't up this reply.</p>
<p>CWinApp::ExitInstance();
return myExitCode;</p>
<p>This will return the errorlevel to the calling batch file for you to then evaluate and act upon.</p>
| <p>There are a couple of solutions listed <a href="http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/00d97998-f0b2-439a-9fa3-5dbcdd47cac4/" rel="nofollow noreferrer">here</a> I can't comment on which is better, but I'm sure at least one of them will get you there.</p>
| 33,782 |
<p>Do you still use session or entity EJBs in your project? Why?</p>
| <p>EJB3 is a <strong>vast</strong> improvement over previous versions. It's still <em>technically</em> the standard server-side implementation toolset for JavaEE and since it now has none of the previous baggage (thanks to annotations and Java Persistence), is quite usable and being deployed as we speak. As one comme... | <p>I've just started back to work on an EJB project. I didn't remember how heavy and hard was to work with this technology. It was luck when Spring, Hibernate and Maven came. Since then everything was different and much easier.</p>
<p>I always could see this technology was never used properly and was taken as a pattern... | 13,409 |
<p>Do you bother initialising java bean values? Say, for example:</p>
<p>([g|s]etters omitted)</p>
<pre><code>public class SomeClass {
private String foo;
private Date bar;
private Baz someObject;
}
</code></pre>
<p>(Yes, this is a POJO being used as a bean rather than a Java Bean in the strictest se... | <p>It depends on the use case.</p>
<p>If I use properties as service dependencies, they should be initialized to operate properly (btw, Spring DI has handy way to do it). </p>
<p>If I use bean as part of domain model, it is usually illegal state to have some null property. It may not be initialized at startup, but I ... | <p>If at all possible, I initialize variables at declaration if they need to be initialized. These initialization statements actually wind up being called from the constructor.</p>
<p>I do generally leave them as null if there's not a compelling reason to initialize them.</p>
| 27,752 |
<p>I need to be able to change a user's password from a cron task or from an ssh session. Is there an easy way to do that with a bash script? If not, what's the easiest way to do it in Cocoa?</p>
| <p>Use the <code>passwd</code> shell command.</p>
| <p>Use the <code>passwd</code> shell command.</p>
| 46,072 |
<p>I've read <a href="http://chriscavanagh.wordpress.com/2008/03/11/aspnet-routing-goodbye-url-rewriting/" rel="noreferrer">ASP.NET Routing… Goodbye URL rewriting?</a> and <a href="http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx" rel="noreferrer">Using Routing With WebForms</a> which are great ar... | <p>A simple example of how to use routing in ASP.NET </p>
<ol>
<li>Create Empty Web Application</li>
<li>Add first form - Default.aspx</li>
<li>Add second form - Second.aspx</li>
<li>Add third form - Third.aspx</li>
<li><p>Add to default.aspx 3 buttons -</p>
<pre><code>protected void Button1_Click(object sender, Even... | <p>Mike Ormond's step-by-step guide to setting up URL routing with ASP.NET is excellent (<a href="http://blogs.msdn.com/mikeormond/archive/2008/11/06/getting-asp-net-routing-up-and-running-the-definitive-guide.aspx" rel="nofollow noreferrer">Getting ASP.NET Routing Up and Running - The Definitive Guide </a>) </p>
| 21,080 |
<p>I've got a Lua program that seems to be slower than it ought to be. I suspect the issue is that I'm adding values to an associative array one at a time and the table has to allocate new memory each time. </p>
<p>There did seem to be a table.setn function, but it fails under Lua 5.1.3:</p>
<pre><code>stdin:1: 'se... | <p>Let me focus more on your question:</p>
<blockquote>
<p>adding values to an associative array
one at a time</p>
</blockquote>
<p>Tables in Lua are associative, but using them in an array form (1..N) is optimized. They have double faces, internally.</p>
<p>So.. If you indeed are adding values associatively, fo... | <p>There is still an internal luaL_setn and you can compile Lua so that
it is exposed as table.setn. But it looks like that it won't help
because the code doesn't seem to do any pre-extending.</p>
<p>(Also the setn as commented above the setn is related to the array part
of a Lua table, and you said that your are usin... | 15,146 |
<p>While creating a file synchronization program in C# I tried to make a method <code>copy</code> in <code>LocalFileItem</code> class that uses <code>System.IO.File.Copy(destination.Path, Path, true)</code> method where <code>Path</code> is a <code>string</code>.<br>
After executing this code with destination. <code>Pa... | <p>It seems you have misplaced the parameters in File.Copy(), it should be File.Copy(string source, string destination).</p>
<p>Also is "C:\Test2" a directory? You can't copy file to a directory.
Use something like that instead:
<pre>
File.Copy(
sourceFile,
Path.Combine(destinationDir,Path.GetFileName(sourc... | <p>I'm kinda guessing here, but could it be because:</p>
<ul>
<li>You are trying to perform file operations in C: root? (there may be protection on this by Vista if you are using it - not sure?)</li>
<li>You are trying to copy to a non-existant directory?</li>
<li>The file already exists and may be locked? (i.e you ha... | 4,399 |
<p>I'm using the <a href="http://libodbcxx.sourceforge.net/" rel="nofollow noreferrer">freeodbc++</a> library to access data on a MS SQL Server 2000 database (SP3? SP4?). In particular, I'm running a particularly long and nasty stored procedure. I can watch the procedure execute in SQL Profiler, however, it tends to ... | <p>In <a href="http://www.autoitscript.com/autoit3/" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wOUx6.jpg" alt="" /> autoit</a>, you have a <a href="http://www.autoitscript.com/forum/index.php?showtopic=48585" rel="nofollow noreferrer">script</a> which does just that.</p>
<p>It basically comes from t... | <p>You could spawn a process and use a <a href="http://quick.mixnmojo.com/readmes/USBDiskEjector.html" rel="nofollow noreferrer">command line tool</a>. This would also work from other languages such as java where calling the Win32 api is harder.</p>
| 25,270 |
<p>For development, I use a local LAMP stack, for production I'm using <a href="http://mediatemple.net/webhosting/gs/django.html" rel="noreferrer">MediaTemple's Django Container</a> (which I'm loving BTW). MT's container uses lighthttpd. Honestly I've never had any other experience with it. I've always used Apache. I... | <p>The way you interface between the web server and Django might have even a greater impact on performance than the choice of web server software. For instance, mod_python is known to be heavy on RAM.</p>
<p><a href="https://stackoverflow.com/questions/26025/cleanest-fastest-server-setup-for-django">This question</a> ... | <p>Use a standard web server. Apache is used by 50% of web sites (<a href="http://news.netcraft.com/archives/2008/09/30/september_2008_web_server_survey.html" rel="nofollow noreferrer">Netcraft</a>), therefore, if you use Apache, peoples' web browsers, spiders, proxies etc, are pretty much guaranteed to work with your ... | 20,749 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.