instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>In the installation documentation to RoR it mentions that there are many limitations to running Ruby on Rails on Windows, and in some cases, whole libraries do not work.</p>
<p>How bad are these limitations, should I always default to Linux to code / run RoR, and is Iron Ruby expected to fix these limitations or ar... | <p>Here's an overview of the current issues with Rails on Windows:</p>
<ul>
<li>Ruby and Rails are slower on Windows than they are on Unix-like OS's.</li>
<li>A few gems and libraries don't work on Windows.</li>
<li>Some Unix-isms aren't available on Windows (<a href="http://tomayko.com/writings/unicorn-is-unix" rel="n... | <p>For a speedup you could try my loader speeder upper (helps rails run faster in doze): <a href="https://github.com/rdp/faster_require" rel="nofollow">https://github.com/rdp/faster_require</a>
Also checkout spork, which works in doze</p>
| 19,929 |
<p>I am writing some JNI code in C that I wish to test using cunit. In order to call the JNI functions, I need to create a valid JNIEnv struct.</p>
<p>Does anyone know if there is a mocking framework for such a purpose, or who can give me some pointers on how to create a mock JNIEnv struct myself?</p>
| <p>jni.h contains the complete structure for JNIEnv_, including the "jump table" JNINativeInterface_. You could create your own JNINativeInterface_ (pointing to mock implementations) and instantiate a JNIEnv_ from it.</p>
<p>Edit in response to comments: (I didn't look at the other SO question you referenced)</p>
<p... | <p>Quote: "jnimock is implemented on top of gmock. It provides two C++ classes 'JNIEnvMock' and 'JavaVMMock' to separately mock 'JNIEnv' and 'JavaVM'."</p>
<p><a href="https://github.com/ifokthenok/jnimock" rel="nofollow noreferrer">https://github.com/ifokthenok/jnimock</a></p>
| 24,554 |
<p>There are a few books about specific ORM products such as Hibernate or Linq to SQL, but I would be quite interested in any material on the more general principles, history etc of ORM.</p>
<p>Do you know of any books, white papers, well researched blog posts etc on this topic?</p>
<p>Thanks /Erik</p>
| <p>The fundamental pieces that make up an ORM are described in Martin Fowlers' <a href="http://martinfowler.com/eaaCatalog/" rel="nofollow noreferrer">Patterns of Enterprise Application Architecture</a> </p>
<p>Read all the patterns in the Object Relational categories.</p>
<p>Frans Boumas' <a href="http://weblogs.asp... | <p>Try Patterns of Enterprise Application Architecture by Martin Fowler. It's not specifically about ORM's but it shows all the design patterns that a good ORM implements for you.</p>
| 35,475 |
<p>How to restrict the maximum number of characters that can be entered into an HTML <code><textarea></code>? I'm looking for a cross-browser solution.</p>
| <p>The <code>TEXTAREA</code> tag does not have a <code>MAXLENGTH</code> attribute the way that an
<code>INPUT</code> tag does, at least not in most standard browsers. A very simple and effective way to limit the number of characters that can be <em>typed</em> into a <code>TEXTAREA</code> tag is:</p>
<pre><code><tex... | <pre><code>$(function(){
$("#id").keypress(function() {
var maxlen = 100;
if ($(this).val().length > maxlen) {
return false;
}
})
});
</code></pre>
<p>Reference <a href="https://stackoverflow.com/questions/4459610/set-maxlength-in-html-textarea">Set maxlength in Html Textarea</a></p>
| 6,517 |
<p>I have an SKR PRO control board with a dead (shorted, it's burning hot) main processor. I ordered a new board, it was my mistake.</p>
<p>The voltage regulators work, so I ordered a replacement STM32F407 processor from STM (a free sample actually) and I'll repair the board in my free time.</p>
<p>How can I test all p... | <p>"Completely" is always relative, but for water at the pressures involved it's probably achievable. Normally you need some sort of <em>gasket</em> (material that can bend/compress to slight imperfections in the mating surfaces), and a means of holding the two surfaces tight against the gasket, to get such a... | <p>I know this sounds obvious, but given the box has holes in the top – does it only need to be watertight when it's the right way up? If not, you could just do something like:</p>
<p><a href="https://i.stack.imgur.com/JXft9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JXft9.jpg" alt="enter image... | 1,765 |
<p>I am looking for different ways to pause and resume programmatically a particular process via its process ID under Windows XP.</p>
<p><a href="http://www.codeproject.com/KB/threads/pausep.aspx" rel="noreferrer">Process suspend/resume tool</a> does it with <code>SuspendThread</code> / <code>ResumeThread</code> but w... | <p>If you "debug the debugger" (for instance, using <code>logger.exe</code> to trace all API calls made by <code>windbg.exe</code>), it appears that the debugger uses <code>SuspendThread()</code>/<code>ResumeThread()</code> to suspend all of the threads in the process being debugged. </p>
<p>PsSuspend may use a differ... | <p>I think there is a good reason why there is no SuspendProcess() function in Windows. Having such a function opens the door for an unstable system. You shall not suspend a process unless you created that process yourself.
If you wrote that process yourself, you could use an event (see ::SetEvent() etc. in MSDN) or an... | 12,579 |
<p>I've had a lot of users complain that the little "i" info button is difficult to touch on the iPhone. Ok, simple enough -- I just stuck a big-fat invisible button behind it that you can't miss even with the sloppiest of finger touches and, when you touch it, it does the infoButtonAction.</p>
<p>Thing is, I'd like ... | <p>The problem is that you are marking your button as needing display (calling <code>-setNeedsDisplay</code> is unecessary; the button calls that internally), but then never allowing the run loop a chance to display the new image.</p>
<p>In Cocoa, you could use something like <code>-performClick:</code> but that is no... | <p>I don't know exactly what happens in your <code>infotap</code> method, but there doesn't appear to be anything there to cause much of a delay between your first <code>setImage:</code> call and the second. My guess is that things are happening faster than the eye can see. I'd suggest looking at <code>NSTimer</code> t... | 45,825 |
<p>When writing multithreaded applications, one of the most common problems experienced is race conditions.</p>
<p>My questions to the community are:</p>
<ul>
<li>What is the race condition?</li>
<li>How do you detect them?</li>
<li>How do you handle them?</li>
<li>Finally, how do you prevent them from occurring?</li>
... | <p>A race condition occurs when two or more threads can access shared data and they try to change it at the same time. Because the thread scheduling algorithm can swap between threads at any time, you don't know the order in which the threads will attempt to access the shared data. Therefore, the result of the change i... | <p>Here is the classical Bank Account Balance example which will help newbies to understand Threads in Java easily w.r.t. race conditions:</p>
<pre class="lang-java prettyprint-override"><code>public class BankAccount {
/**
* @param args
*/
int accountNumber;
double accountBalance;
public synchronized boolean Depo... | 5,478 |
<p>I have an interface - here's a nicely contrived version as an example:</p>
<pre><code>public interface Particle {
enum Charge {
POSITIVE, NEGATIVE
}
Charge getCharge();
double getMass();
etc...
}
</code></pre>
<p>Is there any difference in how implementations of this would behave if... | <p>No, it makes no difference. However the reason is not because it is a member declaration inside an interface, as Jon says. The real reason is according to language spec (<strong>8.9</strong>) that </p>
<blockquote>
<p>Nested enum types are implicitly
static. It is permissable to
explicitly declare a nested en... | <p>No, it makes no difference. From the <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-9.html#jls-9.5" rel="noreferrer">language spec, section 9.5</a>:</p>
<blockquote>
<p>Interfaces may contain member type
declarations (<a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.5" r... | 31,564 |
<p>In continuation of the my <a href="https://stackoverflow.com/questions/138331/any-decent-text-diffmerge-engine-for-net">previous question</a>, are the any good controls for text diffs visualization?</p>
<p>Something like StackOverflow's revision diff viewer but for WinForms or WPF</p>
<p>Requirements:</p>
<ul>
<l... | <p>There is (as part of GitSharp) an open source diff engine in c# with a very easy to use API and (as part of GitSharp.Demo) a WPF diff viewer. The code should not be too difficult to extract from the project.</p>
<p>Find more information here: <a href="http://www.eqqon.com/index.php/GitSharp#GitSharp.Demo" rel="nore... | <p>I never heard about a specific .NET component for diff visualization (it's kind a niche), but perhaps you could rely on advanced editor to build your own without too much trouble.</p>
<p>Syncfusion proposes a <a href="http://www.syncfusion.com/products/edit/windows/features/default.aspx" rel="nofollow noreferrer">c... | 16,774 |
<p>For example if I put "C:\docs" in address bar of Firefox, it shows all files in the directory. Is it possible to customize this page with CSS?</p>
<p>Apache 2.2 allows us to do it using IndexStyleSheet directive, so I wondered if Firefox can do it.</p>
| <p>Firefox has a file userContent.css for each profile (found in the profile's settings folder). That file defines the standard CSS, why may then be overwritten by a website. So they also apply to directory listings.</p>
<p>You should have a look at the actual HTML code Firefox is creating for the directory listing to... | <p>I think the easiest way is to create an own skin which custom css. You have to modify dirListing.css in this case. (chrome://global/skin/dirListing/dirListing.css)</p>
<p>I know the walnut theme (<a href="https://addons.mozilla.org/en-US/firefox/addon/122" rel="nofollow noreferrer">https://addons.mozilla.org/en-US/... | 37,467 |
<p>In a Visual Basic project, I created a homemade TabControl in order to fix a visual bug. The control works properly, however whenever I modify the form using my tab, Visual Studio adds MyProject in front of the control in its declaration:</p>
<pre><code>Me.tabMenu = New MyProject.MyClass 'Gives a BC30002 compile e... | <p>What is the actual compile error you are getting? Is it possable that the VB compiler is interpreting MyProject as something other than a namespace identifier? You could also try changing the default namespace for the project, then see what it does, it might give you a hint as to what the actual problem is.
You co... | <p>By default, Visual Basic .NET assigned a default namespace to your project. (I believe the default is, in fact, <code>MyProject</code>.)</p>
<p>This is what's being prepended, and it's being done to explicitly identify your class in the designer. </p>
<p>No matter what your default namespace is for your project, t... | 29,823 |
<p>I've been using <a href="http://code.google.com/p/moq/" rel="noreferrer">moq</a> to mock objects in my unit tests and I've seen on the site about moq that it is able to mock both classes and interfaces.</p>
<p>I had a discussion with one of my work mates the other day and they stated that there is never a reason to... | <p>Mocking a class is perfectly valid. With MoQ, you can only mock virtual methods and properties on a class, though.</p>
<p>It's useful when you have abstract base classes instead of interfaces, or classes with default implementations and virtuals as extension points. There are many cases where you don't have access ... | <p>If the class does not implement an interface or if the mocking framework allows partial mocks then you would want to be able to mock the class. In the former case, because there is no interface to mock. In the latter, so you can inherit existing behavior from the class that you don't want to mock out.</p>
<p>Typi... | 45,469 |
<p>Ok, this is bit of an obscure question, but hopefully someone can help me out with it.</p>
<p>The system I'm working on builds a dynamic SQL string for execution inside a stored procedure, and part of that dynamic SQL defining column aliases, which themselves are actually values retrieved from another table of user... | <p>Can you just put another character instead of double quotes and replace that with double quotes in the code?</p>
<p>Something like this:</p>
<pre><code>SELECT table1.Col1 AS "This is |not| an alias" FROM table1
</code></pre>
<p>Then just replace | with ".</p>
<p>I know it's a hack, but I can't think of any bette... | <p>a possibly fruitful area of investigation would be to look into the quote method. <br></p>
<p><strong>my $quotedString = $dbh->quote( $string );</strong> <br></p>
| 8,056 |
<p>I have the following code:</p>
<pre><code>ListBox.DataSource = DataSet.Tables("table_name").Select("some_criteria = match")
ListBox.DisplayMember = "name"
</code></pre>
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.data.datatable.select(VS.80).aspx" rel="noreferrer"><code>DataTable.Select()</code>... | <p>Use a <a href="http://msdn.microsoft.com/en-us/library/hy5b8exc(VS.71).aspx" rel="noreferrer">DataView</a> instead.</p>
<pre><code>ListBox.DataSource = new DataView(DataSet.Tables("table_name"), "some_criteria = match", "name", DataViewRowState.CurrentRows);
ListBox.DisplayMember = "name"
</code></pre>
| <p>Josh has it right with the DataView. If you need a very large hammer, you can take the array of rows from any DataTable.Select("...") and do a merge into a different DataSet.</p>
<pre>
<code>
DataSet copy = new DataSet();
copy.Merge(myDataTable.Select("Foo='Bar'"));
// copy.Tables[0] has a clone
</code>
</pre>
... | 14,015 |
<p>I have a client whose desired Web UI is graphically intense; we would like to gather statistics on the average bandwidth of those connecting to the site. Is there an easy way to do that? The "simplest thing that could possibly work" would seem to be a Flash or Silverlight component that times the download of a file ... | <p>The <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/" rel="nofollow noreferrer">FreeBSD Handbook</a> contains a section on <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-building.html" rel="nofollow noreferrer">Building and Installing a Custom Kernel</a>. The Handb... | <p>Why do this over a simple load-balancing solution? The goal of TCP/IP is to handle data reliably between two machines over a network. There are other layers of abstraction that are much more capable of dealing with the problem of server congestion that won't require drastic changes to fundamental internet protocols.... | 29,934 |
<p>Does anyone have experience deploying GWT apps to EC2?</p>
<p>If I were to install tomcat or apache on a ec2 instance, could I have users connect directly to a url pointing there?</p>
<p>Would that be cost effective, or would java hosting services be best?</p>
<p>Is there any downside to hosting the edge HTTP ser... | <p>Other answers are correct but I just wanted to share the fact that we are are developing a product that is 100% EC2/S3 based and also have a pure GWT front end.</p>
<p>We use maven2 for builds and the excellent gwt-maven plugin. This makes it easy to produce a WAR package of our web application as output. We use Je... | <p>You definitely can host an http server in EC2, but you need to take into consideration the following:</p>
<ul>
<li>As mentioned before the cost can be much higher than alternative hosting solutions</li>
<li>Your instance (the machine you've started in EC2) can go off unexpectedly. There is no guarantee from Amazon ... | 36,834 |
<p>I'm working on a SaaS application where each customer will have different configurations depending on the edition they have purchased, additional features they have purchased, etc. For example, a customer might have a limit of 3 custom reports.</p>
<p>Obviously I want to store this configuration in the database, bu... | <p>I think this would depend on how your product was sold to the customer.</p>
<p>If you only sell it in packages...</p>
<pre><code>PACKAGE 1 -> 3 reports, date entry, some other stuff.
PACKAGE 2 -> 6 reports, more stuff
PACKAGE 3 -> 12 reports, almost all the stuff
UBER PACKAGE -> everything
</code></pre... | <p>The key value pair table, but with everything is stored as a string and with another column (if necessary) saying which type should the value be casted to.</p>
<pre><code>CREATE TABLE configKVP(clientId int, key varchar, value varchar, type varchar)
</code></pre>
<p>If the value cannot be casted to the type, then ... | 17,872 |
<p>Is there any way to 'hide' the name of a class, whose sole purpose is to provide extension methods, from Intellisense? </p>
<p>I would like to remove the class name from the Intellisense list but need the extension methods of the class to be available to external assemblies via Intellisense in the usual way.</p>
| <p>Ok, I have the answer to this. Hallgrim's suggestion of marking the class with..</p>
<pre><code>[EditorBrowsable(EditorBrowsableState.Never)]
</code></pre>
<p>..does actually work but only where the <strong>assembly</strong> is being referenced, rather than the project, as would be the case in my own VS solution w... | <p>If you put your extension methods in a module there is a attribute called HideModuleName which will hide the module name from showing up in Intellisense.</p>
| 37,730 |
<p>I want to make a project involving many small dots indents and I would like to know how I can calculate the smallest dot hole the Prusa i3 MK3S can extrude around on a layer using PLA. In other words, if I printer a mesh with circle shaped holes, how would I know the minimum diameter of the holes. Is it simply the s... | <p>There is no direct limit on the size of a hole in XY-plane (that means: oriented so that the hole is visible from above).</p>
<p>The movement accuracy of MK3S (and most other modern 3D printers) is about 0.01 mm. So theoretically you could move around a circle that has diameter of the (default) 0.4 mm extrusion wid... | <p>That depends on the ability how fast you get filament to stick to the build plate and whether the filament is loaded in the extruder. It also matters which size of nozzle you are using. The filament diameter has no influence other than smaller filament width (e.g. 1.75 mm) requires more length to extrude with r... | 1,527 |
<p>What is the meaning of the concepts 'covariance' and 'contravariance'?</p>
<p>Given 2 classes, <strong>Animal</strong> and <strong>Elephant</strong> (which inherits from <strong>Animal</strong>), my understanding is that you would get a run-time errors if you try and put an Elephant into an array of Animals, and th... | <p>You have it backwards. You can add an Elephant to an Animal array because it <em>is an</em> Animal, and it's guaranteed to have all of the methods an Animal is required to have. You can't add an Animal to an Elephant array because it does <strong>not</strong> have all of the methods that an Elephant is required to... | <p><a href="https://i.stack.imgur.com/0goxP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0goxP.jpg" alt="enter image description here"></a></p>
<pre><code>public interface IGoOut<out T>
{
T Func();
}
public interface IComeIn<in T>
{
void Action(T obj);
}
public class GoOutClas... | 34,282 |
<p>I'm running VS2008 and have used <a href="http://msdn2.microsoft.com/en-us/library/ms724947.aspx" rel="noreferrer">SystemParametersInfo</a> to activate "Focus Follows Mouse" and "Do not Raise On Focus." Sadly though, VS2008 (with and without SP1) doesn't honour the "Do not Raise" part and eagerly pushes into the for... | <p>I know this problem is very old, but it still occurs with VS2019 and this thread is one of the first hits when someone searches for 'auto-raise'.<br />
In my case, I enabled X-mouse via a regedit, and had to live with this behaviour for quite a while.<br />
A couple of days ago I found a solution for Visual Studio a... | <p>I've noticed that Visual Studio only seems to auto-raise when a "document" has focus in VS. If you select a Find Results window or the Solution Explorer in VS, then the auto-raise doesn't occur.</p>
| 14,728 |
<p>I'm currently in the process of replacing my homebrewn build script by an Ant build script.</p>
<p>Now I need to replace various tokens by the size of a specific file. I know how to get the size in bytes via the <code><length></code> task and store in in a property, but I need the size in kilobytes and megaby... | <p>I found a solution that does not require any third-party library or custom tasks using the <a href="http://ant.apache.org/manual/Tasks/script.html" rel="noreferrer"><code><script></code> task</a> that allows for using JavaScript (or any other <a href="http://jakarta.apache.org/bsf" rel="noreferrer">Apache BSF<... | <p>There is a math task at <a href="http://ant-contrib.sourceforge.net/" rel="nofollow noreferrer">http://ant-contrib.sourceforge.net/</a> that may be useful</p>
| 40,297 |
<p>We want to throw an exception, if a user calls DataContext.SubmitChanges() and the DataContext is not tracking anything.</p>
<p>That is... it is OK to call SubmitChanges if there are no inserts, updates or deletes. But we want to ensure that the developer didn't forget to attach the entity to the DataContext.</p>
... | <p>I don't think there are any public/protected methods that would let you get at this directly. You'd probably have to use reflection, like I did about 3 messages down <a href="http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/1ad473b24976235e/345083e2f19884b1" rel="nofollo... | <p>Look at the ObjectTracker or something that hangs off DataContext. It has the change list stored in there. </p>
<p>Also, I believe SubmitChanges is virtual, so you can intercept the SubmitChanges call and do some checking there.</p>
| 33,663 |
<p>I'm curious as to what versions of Flash stuff is tested with. How do you manage it across different browsers?</p>
<p>I'm wanting to test things with both swfdec and gnash and hoping maybe there's some way I didn't know about...</p>
| <p>All the test i run are made over IE 7, Firefox 2 and 3, Safari, Google Chrome and the Stand Alone Player. The Flash Player version i use was 9 (always the last version) and now i use Flash Player 10. Sometimes i come back with the 9 version, but always you can ask to update the flash player version.</p>
| <p>When i was working in the software quality team at my old part-time, we usually tested all the versions possible to guarantee that some old legacy problem wouldn't appear.</p>
<p>If you want to do some serious testing then i would suggest you to test on:</p>
<ul>
<li>IE 6 and 7</li>
<li>Firefox 2 and 3</li>
<li>Sa... | 26,218 |
<p>What is the best approach to synchronizing a DataSet with data in a database? Here are the parameters: </p>
<ul>
<li>We can't simply reload the data because it's bound to a UI control which a user may have configured (it's a tree grid that they may expand/collapse)</li>
<li>We can't use a changeflag (like a Updated... | <p>DataSet.Merge works well for this <em>if</em> you have a primary key defined for each DataTable; the DataSet will raise changed events to any databound GUI controls</p>
<p>if your table is small you can just re-read all of the rows and merge periodically, otherwise limiting the set to be read with a timestamp is a ... | <p>I think it would be easier to store a list of the nodes that the user has expanded (assuming you can uniquely identify each one), then re-load the data and re-bind it to the tree view, and then expand all the nodes previously expanded.</p>
| 19,186 |
<p>I need to run 8-10 instances of my application on IIS 6.0 that are all identical but point to different backends (handled via config files, which would be different for each virtual directory). I want to create multiple virtual directories that point to different versions of the app and I want to know if there is a... | <p>IIS on Windows Server 2003 is built to handle lots of sites, so the number of sites itself is not a concern. The resource needs of your application is much more of a factor. I.e., How much, i/o, cpu, threads, database resources does it consume?</p>
<p>We have a quad-core Windows Server 2003 server here handling sev... | <p>The short answer is no, there should be no concerns. </p>
<p>In effect, you are asking if IIS can host 8 - 10 websites... of course it can. Perhaps, you might want to configure it as individual websites rather than virtual directories, and perhaps with individual application pools so that each instance is entirely ... | 47,521 |
<p>I got a templated control (a repeater) listing some text and other markup. Each item has a radiobutton associated with it, making it possible for the user to select ONE of the items created by the repeater.</p>
<p>The repeater writes the radiobutton setting its id and name generated with the default ASP.NET naming ... | <p>Google-fu: <a href="http://www.google.se/search?q=asp.net+radiobutton+repeater+problem&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a" rel="nofollow noreferrer">asp.net radiobutton repeater problem</a></p>
<p>Indeed an unfortunate consequence of the id mangling. My take w... | <p>This may not be the ideal solution for everyone, but I did the following using jQuery.</p>
<p><code><asp:RadioButton ID="rbtnButton1" groupName="Group1" runat="server" /></code>
<code><asp:RadioButton ID="rbtnButton2" groupName="Group1" runat="server" /></code></p>
<p><code>etc...</code></p>
<p>Then i... | 49,417 |
<p>I'm part of a team that develops a pretty big Swing Java Applet. Most of our code are legacy and there are tons of singleton references. We've bunched all of them to a single "Application Context" singleton. What we now need is to create some way to separate the shared context (shared across all applets currently sh... | <p>Singletons are evil, what do you expect? ;)</p>
<p>Perhaps the most comprehensive approach would be to load the bulk of the applet in a different class loader (use java.net.URLClassLoader.newInstance). Then use a WeakHashMap to associate class loader with an applet. If you could split most of the code into a common... | <p>If I understand you correctly, the idea is to get a different "singleton" object for each caller object or "context".
One thing you can do is to create a thread-local global variable where you write the ID of the current context. (This can be done with AOP.) Then in the singleton getter, the context ID is fetched fr... | 2,890 |
<p>I want to disable the selection of certain rows in a datagridview.</p>
<p>It must be possible to remove the select property for one or more datagridview rows in a datagridview shown in a winform. The goal is that the user can't select certain rows. (depending on a condition)</p>
<p>Thankx,</p>
| <p>If SelectionMode is FullRowSelect, then you'll need to override SetSelectedRowCore for that DataGridView, and not call the base SetSelectedRowCore for rows you don't want selected.</p>
<p>If SelectionMode is not FullRowSelect, you'll want to additionally override SetSelectedCellCore (and not call the base SetSelect... | <pre><code>Private Sub dgvSomeDataGridView_SelectionChanged(sender As Object, e As System.EventArgs) Handles dgvSomeDataGridView.SelectionChanged
dgvSomeDataGridView.ClearSelection()
End Sub
</code></pre>
| 9,692 |
<p>What are the differences between the free sql express 05 management studio and the licensed version?</p>
| <p>Management Studio Express cannot manage the following:</p>
<ul>
<li>SQL Server Analysis Services</li>
<li>Integration Services</li>
<li>Notification Services</li>
<li>Reporting Services</li>
<li>SQL Server Agent</li>
<li>SQL Server 2005 Mobile Edition</li>
</ul>
<p>( from <a href="http://www.microsoft.com/DownLoad... | <p>See the "SQL Server 2005 Features Comparison" at <a href="http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx" rel="nofollow noreferrer">http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx</a></p>
| 19,255 |
<p>Could someone recommend any good resources for creating Graphics User Interfaces, preferably in C/C++?</p>
<p>Currently my biggest influence is <a href="http://www.3dbuzz.com" rel="nofollow noreferrer">3DBuzz.com</a>'s <a href="http://www.3dbuzz.com/xcart/product.php?productid=30&cat=12&page=1" rel="nofollo... | <p>I wouldn't use OpenGL for the GUI unless you are planning for hardware accelerated and/or 3D effects that you don't think you would get with a more traditional GUI toolkit (e.g <a href="http://trolltech.com/" rel="nofollow noreferrer">Qt</a>, <a href="http://www.wxwidgets.org/" rel="nofollow noreferrer">wxWidgets</a... | <p>I'll second Qt. It's cross platform, and I found it <em>much</em> easier to work with than the built in Visual Studio GUI stuff. It's dual-licensed, so if you don't want your code to be GPL you could purchase a license instead.</p>
| 3,456 |
<p>I was curious if anyone out there has experience getting the necessary legal documents (user agreements, privacy policies, disclaimers, etc.) for a small software business. For example if you just want to have a software 'company' that sells a few piece of software that you have written, are there cheap solutions f... | <p>In <a href="https://rads.stackoverflow.com/amzn/click/com/1590596013" rel="noreferrer" rel="nofollow noreferrer">Micro-ISV: From Vision to Reality</a>, Bob suggests <a href="http://www.megadox.com/index.php/search/?for=Software+Licence++" rel="noreferrer">MegaDox.com</a> and <a href="http://www.soft14.com/upload/sof... | <p>I have recently been looking for the same info as the OP and found a great book which includes standard agreements for software companies which you may use as is or modify with the help of a lawyer.</p>
<pre>
The IT/Digital Legal Companion: A Comprehensive Business Guide to Software,
Internet, and IP Law Includes ... | 11,466 |
<p>I need a standard, Microsoft delivered, encryption library that works for both .NET 2.0 and C++. What would you suggest?</p>
<p>We find that AES is only offered in .NET 3.5 (and available in C++)</p>
<p>We find that Rijndael is used in .NET 2.0 but not available in the standard C++ libraries.</p>
<p>If I am wrong... | <p>We successfully do a similar thing that I hope might help you:</p>
<h3>C++ CryptoAPI</h3>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa380239(VS.85).aspx" rel="nofollow noreferrer">CryptoAPI</a> is pure Win32 (c/c++), native to all Microsoft OS's.</li>
<li>Use <a href="http://msdn.microsoft.com/en-us/... | <p>3DES is available via Capicom. See <a href="http://msdn.microsoft.com/en-us/library/aa382010(VS.85).aspx" rel="nofollow noreferrer">here</a> for info.</p>
| 42,948 |
<p>I'm going to be including some code in a word document. Specifically some sql statements but this question applies to any sort of language. I'd like to make the code look a bit nicer and easier to read with some highlighting.</p>
<p>Is there any tool that will do syntax highlighting on some code and allow me to cop... | <p><a href="http://quickhighlighter.com/" rel="nofollow noreferrer">Quickhighlighter.com</a> can generate html in a variety of languages which you can then put in Word. No download needed.</p>
| <p>Use a syntax higlighter of your choice. </p>
<p>This will depend on whether it a server or desktop app. </p>
<p>QT has a nice library for syntax higlighting code.</p>
<p>HTMLTidy is good for HTML.</p>
<p><a href="http://qbnz.com/highlighter/" rel="nofollow noreferrer">http://qbnz.com/highlighter/</a></p>
<p><a ... | 45,770 |
<p>I've got a few very short audio clips (less than a second long) to be played on various events (button hover, click, etc). However, there is usually a significant lag between the action and the actual playing of the sound. I have tried both embedding the sound in the .swf, and loading it externally at the start, b... | <p>It's a little thing but:</p>
<pre><code>function playSound( name:String ):void
{
for( var nameSrc:String in soundArray )
{
if( name == nameSrc )
{
var channel:SoundChannel = soundArray[ name ].play();
return;
}
}
}
</code></pre>
<p>Should be:</p>
<pre><code>function pl... | <p>I was having bad sound lancency (about 1 full second) with Flash Player 10.0.2.x. The lantency was the same when stopping the sound channel. </p>
<p>I just upgraded to 10.0.22.x and the problem is gone. </p>
| 28,181 |
<p>Sometimes two image files may be different on a file level, but a human would consider them perceptively identical. Given that, now suppose you have a huge database of images, and you wish to know if a human would think some image X is present in the database or not. If all images had a perceptive hash / fingerprint... | <p><a href="http://www.jhnc.org/findimagedupes/" rel="noreferrer">findimagedupes</a> is pretty good. You can run "findimagedupes -v fingerprint images" to let it print "perceptive hash", for example.</p>
| <p>You could use diff to see if they are REALLY different.. I guess it will remove lots of useless comparison. Then, for the algorithm, I would use a probabilistic approach.. what are the chances that they look the same.. I'd based that on the amount of rgb in each pixel. You could also find some other metrics such as ... | 43,604 |
<p>I have a little trouble with RAD Studio 2009.<br>
As you know, it is possible to switch Unicode support off in MSVS (right click on solution->properties->character set=not set). I need to find this feature in RAD Studio, I know it exists but do not know where exactly.<br>
It`s the only thing that stops my work on a ... | <p>Short answer: No, there is no such feature to turn off Unicode in RAD Studio 2009.</p>
| <p>I`ve solved the problem this way:</p>
<pre><code>
wchar_t* str = Form2->Edit1->Text.w_str();
char* mystr = new char [Form2->Edit1->Text.Length() + 1];
WideCharToMultiByte(CP_ACP, 0, str, -1, mystr, Form2->Edit1->Text.Length() + 1, NULL, NULL);
MessageBox(NULL, mystr, "It`s ok", MB_OK);
delete []... | 49,197 |
<p>When developing a module (device driver, middleware, etc...) that will run in the kernel space, we would like to have some way to capture the reason an operation might fail. </p>
<p>In VxWorks, The errno mechanism seems to be a good way to do this.</p>
<p>Is it possible to define my own errno values?</p>
| <p>In the context of VxWorks errno is defined as two 16-bit: </p>
<ul>
<li>The upper 16-bit identifies the "module" where the error occured.</li>
<li>The lower 16-bit represent the particular error for that module.</li>
</ul>
<p>The official vxWorks module values (for errno) are located in the ../h/vwModNum.h file.
... | <p>Errno is just a number and functions like strerror() return a describing text. If you want to extend it just provide an own function similar to strerror() that looks into your error list or delegates to strerror().</p>
| 15,646 |
<p>The code in <a href="https://stackoverflow.com/questions/17181/test-cases-vs-assertion-statement">this question</a> made me think</p>
<pre><code>assert(value>0); //Precondition
if (value>0)
{
//Doit
}
</code></pre>
<p>I never write the if-statement. Asserting is enough/all you <em>can</em> do.
"Crash early... | <p>The problem with trusting just Asserts, is that they may be turned off in a production environment. To quote the wikipedia article:</p>
<blockquote>
<p>Most languages allow assertions to be
enabled or disabled globally, and
sometimes independently. Assertions
are often enabled during development
and disab... | <p>A problem with assertions is that they can (and usually will) be compiled out of the code, so you need to add both walls in case one gets thrown away by the compiler.</p>
| 8,006 |
<p>I've got an ASP.NET app using NHibernate to transactionally update a few tables upon a user action. There is a date range involved whereby only one entry to a table 'Booking' can be made such that exclusive dates are specified.</p>
<p>My problem is how to prevent a race condition whereby two user actions occur almos... | <ul>
<li>make the isolation level of your transaction SERIALIZABLE (<code>session.BeginTransaction(IsolationLevel.Serializable</code>) and check and insert in the same transaction. You should not in general set the isolationlevel to serializable, just in situations like this.</li>
</ul>
<p>or </p>
<ul>
<li><p>lock th... | <p>Your database should manage your data integrity. </p>
<p>You could make your 'date' column unique. Therefore, if 2 threads try to get the same date. One will throw a unique key violation and the other will succeed.</p>
| 14,565 |
<p>What is the best method for applying drop shadows? I'm working on a site right now where we have a good deal of them, however, I've been fighting to find the best method to do it. The site is pretty animation heavy so shadows need to work well with this.<br /><br /></p>
<p>I tried a jQuery shadow pulgin. The sha... | <p><a href="http://www.ruzee.com/blog/shadedborder/" rel="nofollow noreferrer">ShadedBorder</a> is a good looking and easy to use Shadow-Library. check it out</p>
| <p>if your main problem is to navigate the DOM, just add a class and/or id to your element, and refer it with JQuery selectors. even better if you store the ref in a variable, so you don't need to select it too frequently</p>
| 29,681 |
<p>How do you <em>(using .NET)</em> use WebDAV to get a listing of emails in a user's inbox (not your own inbox) and then get the properties and/or contents of each email?</p>
<p>I'd like to do this without <a href="http://www.independentsoft.de/webdavex/index.html" rel="nofollow noreferrer">WebDAV.NET</a>, if at all ... | <p>I'm looking into doing the same thing and the best solution I've come across is Henning Krause's article "<a href="http://www.infini-tec.de/post/2004/12/Access-the-Exchange-store-via-WebDAV-with-Form-Based-Authentication-turned-on-Updated.aspx" rel="nofollow noreferrer">Access the Exchange store via WebDAV with Form... | <p>I know you said you didn't want to use the Independentsoft library, but we've been using this, and it makes this almost trivial. So my recommendation would be to use that. Their support is good as well.</p>
| 33,020 |
<p>I'm trying to open a folder in explorer with a file selected.</p>
<p>The following code produces a file not found exception: </p>
<pre><code>System.Diagnostics.Process.Start(
"explorer.exe /select,"
+ listView1.SelectedItems[0].SubItems[1].Text + "\\"
+ listView1.SelectedItems[0].Text);
</code></pre>... | <pre><code>// suppose that we have a test.txt at E:\
string filePath = @"E:\test.txt";
if (!File.Exists(filePath))
{
return;
}
// combine the arguments together
// it doesn't matter if there is a space after ','
string argument = "/select, \"" + filePath +"\"";
System.Diagnostics.Process.Start("explorer.exe", arg... | <p>Simple C# 9.0 method based on <a href="https://stackoverflow.com/questions/334630/opening-a-folder-in-explorer-and-selecting-a-file/73406872#answer-9904834">Jan Croonen's answer</a>:</p>
<pre><code>private static void SelectFileInExplorer(string filePath)
{
Process.Start(new ProcessStartInfo()
{
File... | 43,387 |
<p>One of the most difficult problems in my javascript experience has been the correct (that is "cross-browser") computing of a <strong>iframe height</strong>.
In my applications I have a lot of dynamically generated iframe and I want them all do a sort of autoresize at the end of the load event to adjust their height ... | <p>Although I like your solution, I've always found IFRAMEs to be more trouble than they're worth.</p>
<p>Why ? 1. The sizing issue. 2. the iframe has that src attribute to worry about. i.e. absolute path. 3. the extra complexity with the pages.</p>
<p>My solution - DIVs which are dynamically loaded through AJAX ca... | <p>Here is a solution that seems to work. Basically, the scrollHeight is the correct value in most cases. However, in IE (specifically 6 and 7), if the content is simply contained in text nodes, the height is not calculated and just defaults to the height set in CSS or on the "height" attribute on the iframe. This w... | 25,453 |
<p>I'm trying to redirect the java compiler output to a file.
I thought it's supposed to be:</p>
<pre><code>javac file.java > log.txt
</code></pre>
<p>or something. Instead, I see all the output on the terminal and nothing in log.txt!</p>
<p>Also, if I want to log errors too, do I do</p>
<pre><code>javac file.j... | <pre><code>javac file.java 2> log.txt
</code></pre>
<p>The reason is that you have <em>two</em> output file descriptors instead of one. The usual one is stdout, which you can redirect with > and it's supposed to be used for resulting output. The second one, stderr, is meant for human readable output like warnings, ... | <p>Have you tried</p>
<pre><code>javac -Xstdout log.txt file.java
</code></pre>
<p>This will send compiler errors to a log file instead of stderr.</p>
| 41,046 |
<p>Is there a way to manually increase / decrease the timeout of a specific aspx page?</p>
| <p>In the web.config:</p>
<pre><code> <configuration>
<location path="~/Default.aspx">
<system.web>
<httpRuntime executionTimeout="1000"/>
</system.web>
</location>
</configuration>
</code></pre>
| <p>If you are talking about the amount of time it takes before the page returns a timeout, then mnour's example - you may want to look at the machine.config file as well. If you talking about a session timing out, then you will need to use a JS timer that posts back when it reaches 0.</p>
| 27,602 |
<p>I'm working on a stripes app that uses a bit of jQuery to make the UI more dynamic/usable.</p>
<p>I set up an Error Resolution, so if an error is thrown, the user is redirected to an error.jsp page.</p>
<p>However, if an error is thrown during a jQuery Ajax call, instead of redirecting to the error.jsp page, I get... | <pre><code>$(document).ajaxError(function(event, XMLHttpRequest, ajaxOptions, thrownError) {
// redirect here.
}
</code></pre>
<p>I should add that I don't redirect when there is an exception in an Ajax call. Instead, I have the server return an error description in JSON format and display that in the page.</p>
| <p>What about using $.ajax() instead of $.post()? The more general $.ajax() offers an error callback that you can call in case of an error.</p>
| 32,832 |
<p>im creating a Factory class that will contruct and return an object. I normally would do all of the data stuff at the Data Access Layer, but i dont think i could reach my objective and still do so. What i want to do is use a SQLDataReader to quickly read the data information and populate the object to be returned ... | <p>In most cases this is a good idea as this way provides two major benefits: </p>
<ol>
<li><p>This way you can seperate the data access and business logic, which means if you change database design the upper layer algorithms do not need to be changed.</p></li>
<li><p>From OO stand point, you are converting some pure ... | <p>If you're sure you're going to be using all of the data you load from the SQLDataReader, then yes, you could do it at construction time in the factory. However if the data set has many fields, which only a minority of will be used, then demand-loading the data at the time the accessors are called would be a better ... | 23,016 |
<p>This request is based in MS Access VBA. I would like to know what the most efficient way is, to see if an item exists in a listbox control.</p>
| <p>Here is a sample function that might be adapted to suit.</p>
<pre><code>Function CheckForItem(strItem, ListB As ListBox) As Boolean
Dim rs As DAO.Recordset
Dim db As Database
Dim tdf As TableDef
Set db = CurrentDb
CheckForItem = False
Select Case ListB.RowSourceType
Case "Value List"
... | <p>Unfortunately there is no more efficient way than a linear search, unless you know that your listbox is sorted or indexed in some particular fashion.</p>
<pre><code>For i = 1 To TheComboBoxControl.ListCount
if TheComboBoxControl.ItemData(i) = "Item to search for" Then do_something()
Next i
</code></pre>
| 13,143 |
<p>I'm dealing with a MySQL table that defines the JobName column as UNIQUE. If somebody tries to save a new Job to the database using a JobName that is already in the database, MySQL throws a warning.</p>
<p>I would like to be able to detect this warning, just like an error, in my PHP script and deal with it appropr... | <p>For warnings to be "flagged" to PHP natively would require changes to the mysql/mysqli driver, which is obviously beyond the scope of this question. Instead you're going to have to basically check every query you make on the database for warnings:</p>
<pre><code>$warningCountResult = mysql_query("SELECT @@warning_... | <p>Updated to remove the stuff about errno functions which I now realize don't apply in your situation...</p>
<p>One thing in MySQL to be wary of for <code>UPDATE</code> statements: <code>mysqli_affected_rows()</code> will return zero even if the <code>WHERE</code> clause matched rows, but the <code>SET</code> clause ... | 6,985 |
<p>I'm writing some code for a class constructor which loops through all the properties of the class and calls a generic static method which populates my class with data from an external API. So I've got this as an example class:</p>
<pre><code>public class MyClass{
public string Property1 { get; set; }
public int... | <p>Do you want to call DoStuff<T> with T = the type of each property? In which case, "as is" you would need to use reflection and MakeGenericMethod - i.e.</p>
<pre><code>var properties = this.GetType().GetProperties();
foreach (PropertyInfo p in properties)
{
object value = typeof(MyClass)
.GetMethod("Do... | <p>If you don't use DoStuff from another place, I also suggest to write a non-generic method.</p>
<p>Maybe you created the generic method to be able to use default(T). To replace that in a non-generic method, you can use Activator.CreateInstance(T) for value types and null for reference types:</p>
<pre><code>object d... | 23,936 |
<p>On the Stackoverflow podcast this week, Jeff mentioned that in 2004 he wrote a script which queried Google with 110,000 English words and collected a database containing the number of hits for each word. They use this on Stackoverflow e.g. for the "Related" list on the right-hand side of each question page.</p>
<p>... | <p>A quick Google search(!) turns up a few hits. This <a href="http://ucrel.lancs.ac.uk/bncfreq/flists.html" rel="noreferrer">link</a> looks promising: </p>
<p>But it's not targeted at IT words.</p>
| <p>You can split a list between your friends/collegues and use sufficiently large timeouts so you don't exceed 50,000 requests per day per IP, and then merging the results. I'm not sure about the legality of this approach, but the probability of having Google people "knocking at your door" using this method is pretty l... | 44,162 |
<p>Does anyone know of a way to alter a computed column without dropping the column in SQL Server. I want to stop using the column as a computed column and start storing data directly in the column, but would like to retain the current values.</p>
<p>Is this even possible?</p>
| <p>Not that I know of but here is something you can do</p>
<p>add another column to the table
update that column with the values of the computed column then drop the computed column</p>
| <p>Ok, so let me see if I got this straight. You want to take a column that is currently computed and make it a plain-jane data column. Normally this would drop the column but you want to keep the data in the column.</p>
<ol>
<li>Make a new table with the primary key columns from your source table and the generated ... | 6,578 |
<p>Assume that write operation throws an exception half-way. Is there any data written into the file, or is no data written in the file?</p>
| <p>Since you have no view of the internals of CFile (or shouldn't, if it's encapsulated properly), you need to rely on the 'contract' of the API. In other words, unless the documentation tells you specifically what happens in certain cases, you can't rely on it.</p>
<p>Even if you had the source code and could figure... | <p>Short answer: Most likely some data will be written to the file, unless the disk is full at the start of the write operation. </p>
<p>Longer answer: It will depend on what CFileException is thrown from the Write call.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/as5cs056(VS.80).aspx" rel="nofollow noref... | 42,736 |
<p>This causes a compile-time exception:</p>
<pre><code>public sealed class ValidatesAttribute<T> : Attribute
{
}
[Validates<string>]
public static class StringValidation
{
}
</code></pre>
<p>I realize C# does not support generic attributes. However, after much Googling, I can't seem to find the reason... | <p>Well, I can't answer why it's not available, but I <em>can</em> confirm that it's not a CLI issue. The CLI spec doesn't mention it (as far as I can see) and if you use IL directly you can create a generic attribute. The part of the C# 3 spec that bans it - section 10.1.4 "Class base specification" doesn't give any j... | <p>My workaround is something like this:</p>
<pre><code>public class DistinctType1IdValidation : ValidationAttribute
{
private readonly DistinctValidator<Type1> validator;
public DistinctIdValidation()
{
validator = new DistinctValidator<Type1>(x=>x.Id);
}
public override b... | 37,555 |
<p>I was wondering about the best practices regarding this? I know there are two ways to use IIS and host multiple websites. </p>
<p>The first is to have an IP for every website </p>
<p>The second is to use host headers, and a single IP Address for IIS</p>
<p>I was wondering which was the best practice, and why one... | <p>It's easier to implement and manage SSL if each site has its own IP address/domain name. You simply get a cert for that name and install it on that site. Doing <a href="http://technet.microsoft.com/en-us/library/cc738897.aspx" rel="nofollow noreferrer">SSL with Host Headers</a> requires a wildcard server certifica... | <p>Host headers are prefered because they conserve IPv4 address space. They have been mandatory since HTTP/1.1.</p>
<p>With https things are a little more complex; you need a modern browser that supports the TLS/SSL server_name extension (RFC 4366 and previously RFC 3546). This includes:</p>
<ul>
<li>Opera 8.0 or l... | 27,522 |
<p>I'm looking for the best/easiest way to add extensions to an existing protocol (can't change the actual protocol easily) to allow the user to do windows authentication (NTLM?) in .NET. I looked at the AuthenticationManager class already but it requires that I use Web(Http)Request which isn't an option. NegotiateStre... | <p>It looks very inspired by Ruby. It says that it's RESTful but I don't see how exactly. Compare with <a href="http://en.wikipedia.org/wiki/Boo_(programming_language)" rel="nofollow noreferrer">boo</a>, which is more mature yet similar in many ways (its syntax is Python inspired, though).</p>
<p>The design decisions ... | <p>This is very interesting.</p>
<p>Java (or C#) was created in order to eliminate Platform dependency by creating a JVM (or CLR) that will compile the code into a specific machine code at run time.</p>
<p>Now , There is a languege which is <strong>Virtual Machine independent</strong>? umm .... what the hell?!?!</p>
... | 16,163 |
<p>Would it not make sense to support a set of languages (Java, Python, Ruby, etc.) by way of a standardized virtual machine hosted in the browser rather than requiring the use of a specialized language -- really, a specialized paradigm -- for client scripting only?</p>
<p>To clarify the suggestion, a web page would c... | <p>Well, yes. Certainly if we had a time machine, going back and ensuring a lot of the Javascript features were designed differently would be a major pastime (that, and ensuring the people who designed IE's CSS engine never went into IT). But it's not going to happen, and we're stuck with it now.</p>
<p>I suspect, in ... | <p>JavaScript is your only native, standard option available. If you want lots of power, grab jQuery, but if you need to do a bunch more, consider writing an addon for Firefox? or similar for IE etc.</p>
| 11,192 |
<p>I can't make td "Date" to have fixed height. If there is less in Body section td Date element is bigger than it should be - even if I set Date height to 10% and Body height to 90%. Any suggestions?</p>
<pre><code><tr>
<td class="Author" rowspan="2">
<a href="#">Claude</a><br />
... | <p>When you use percentages, they're relative to their container and even then, that only works on some types of element. I imagine for this to work, you need to apply the height to the <code><tr></code>s, and give the <code><table></code> a height. If the <code><table></code> height is relative too, ... | <p>CSS</p>
<pre><code>.Date {
height: 50px;
}
</code></pre>
| 14,994 |
<p>What are the best algorithms for sorting data in C#? </p>
<p>Is there one sorting algorithm that can handle 80% of sorts well? </p>
<p>Please give code examples if applicable.</p>
| <p>Check out this site:
<a href="http://www.sorting-algorithms.com/" rel="noreferrer">Sorting Comparisons with Animations</a>
<br/></p>
<p>Short answer: Quick Sort</p>
<p>Longer answer:
The above site will show you the strengths and weaknesses of each algorithm with some nifty animations.</p>
<p>The short answer is ... | <p>try quicksort: <a href="http://www.codeproject.com/KB/recipes/QuickSort_gen.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/recipes/QuickSort_gen.aspx</a></p>
| 32,848 |
<p>As part of our unit tests, we restore a blank database when the tests start . The unit tests then perform their tests by calling web services (hosted in the Visual Studio ASP.NET host). </p>
<p>This works fine for us the first time the unit tests are run, however if they are re-run without restarting the web servic... | <p>After killing SQL Server, your connection pool will contain stale connections to the old instance of SQL Server.</p>
<p>You can call SqlConnection.ClearAllPools() to clear the stale connections from the pool after restarting SQL Server, e.g.:</p>
<pre><code>static void Main(string[] args)
{
DoDBStuff(); ... | <p>For unit testing purposes, can you adjust the connection pool timeout? That way, connections become stale much quicker, and they'd expire during your checkout/compile process, and would have all been cleaned out by the time your actual unit tests run?</p>
<p>Or, as another option, could you write a unit test that's... | 43,155 |
<p>What is the best way to have my C# Compact Framework program running in the background on a Windows Mobile device ? I need to respond to different events, such as a text message arriving with a specific content. I would like not to start up any UI when the process is started, but just run in the background until UI ... | <p>Just create the app as a Console app. If you need a message pump, you need to call Run without any parameters, and the CF doesn't have that. OpenNETCF's <a href="http://opennetcf.com/library/sdf/html/2105e26d-8657-81a4-f0f7-b569ddab14fa.htm" rel="nofollow noreferrer">Application2 class</a> in the <a href="http://w... | <p>How about this project?</p>
<p><a href="http://managedserviceswm.codeplex.com" rel="nofollow noreferrer">managedserviceswm.codeplex.com</a></p>
| 29,228 |
<p>Does anyone ever develop some application to control the spi device on OMAP3? I can load the spi driver "mcspi", but I don't know how to use it.</p>
| <p>SSOption sets it background to the Windows Button Face on Windows XP. This the same background you get when you make a new form. You will need to use a frame or another type of enclosure that has a background of button face if you want to use it on a multi-colored form. Otherwise use VB6's Option button. </p>
<p>Th... | <p>Threed32.ocx is ancient - it was designed for VB4. I would replace it with the built-in VB6 option control.</p>
| 41,378 |
<p>I want your suggestion on the following pseudo-code. Please suggest how could I improve it, whether or not I could use some design patterns.</p>
<pre><code>
// i'm receiving a string containing : id operation arguments
data = read(socket);
tokens = tokenize(data," "); // tokenize the string based on spaces
if(t... | <p>Have a class for each ID which implements a common interface. Basically the <a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="noreferrer">Strategy pattern</a> IIRC.</p>
<p>So you'd call (pseudo)code like:</p>
<p><code>StrategyFactory.GetStrategy(tokens[0]).parse(tokens[1..n])</code></p>
| <p>Create a map of functions. Then you'd have code like:</p>
<pre><code>consumed_count = token_mapper[tokens[0]](tokens)
remove amount of consumed tokens according to the return value and repeat.
</code></pre>
<p>Though, I don't understand your approach anyway, You are going to write a language that's hard to handle ... | 29,614 |
<p>I am currently building a .Net userform using C# and I am populating it with custom user controls. The controls each have an accessor that gets and sets the object that contains the data that the control will be populated with.</p>
<p>At runtime, everything works great, but at design time I will get errors in the ... | <p>It sounds like it could be the way that the object is being serialized.</p>
<p>The designer is doing a binary serialization of the object into the resx file, what you probably need is code to be produced in you .Designer.cs file.</p>
<p>Try putting the following attribute line on the property:
[DesignerSerializati... | <p>Here is an example of design-time-aware code in a user control:</p>
<pre><code>protected override void OnPaintBackground(PaintEventArgs e)
{
if (this.DesignMode)
{
base.OnPaintBackground(e);
}
}
</code></pre>
<p>This may not work for you, but if you wrap any problematic code in an "if (**!**thi... | 41,242 |
<p>For a windows script I am writing, I need to detect if the machine has Apache 2.2 installed, and to find the application path. </p>
<p>One solution I came up with is to wget <a href="http://localhost:8080/server-info" rel="nofollow noreferrer">http://localhost:8080/server-info</a> and parse the root and the config... | <p>Not a lot of great options if they didn't install it using the installer. If they used the MSI/installer, you can check the registry:</p>
<pre><code>HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Apache\2.2.2\ServerRoot
HKEY_CURRENT_USER\SOFTWARE\Apache Software Foundation\Apache\2.2.2\ServerRoot
</code></... | <p>As I recall, Apache writes some registry keys. If you know how to read them from a script, that might help.</p>
| 33,965 |
<p>Using VS2005 and VB.NET.</p>
<p>I have a project that is an API for a data-store that I created. When compiled creates <code>api.dll</code>.</p>
<p>I have a second project in the same solution that has a project reference to the API project which when compiled will create <code>wrapper.dll</code>. This is basicall... | <p>@Jas, it's a special feature in Visual Studio. The procedure is outlined in <a href="http://blogs.msdn.com/shawnfa/archive/2006/04/24/582278.aspx" rel="nofollow noreferrer">this blog entry, called "Sharing a Strong Name Key File Across Projects"</a>. The example is for sharing strong name key files, but will work f... | <p>I think you could compile api.dll as a resource into wrapper.dll. Then manually access that Resource out of api.dll and manually load it. I have manually loaded assemblies from disk, so loading one from a Stream should not be any different.</p>
<p>I would try including the dll in your project as a file, similar t... | 5,068 |
<p>Within an application, I've got Secret Keys uses to calculate a hash for an API call. In a .NET application it's fairly easy to use a program like Reflector to pull out information from the assembly to include these keys.</p>
<p>Is obfuscating the assembly a good way of securing these keys?</p>
| <p>Probably not.</p>
<p>Look into cryptography and Windows' built-in information-hiding mechanisms (DPAPI and storing the keys in an ACL-restricted registry key, for example). That's as good as you're going to get for security you need to keep on the same system as your application.</p>
<p>If you are looking for a wa... | <p>I wouldn't think so, as obfuscating (as I understand it at least) will simply mess around with the method names to make it hard (but not impossible) to understand the code. This won't change the data of the actual key (which I'm guessing you have stored in a constant somewhere). </p>
<p>If you just want to make it... | 5,333 |
<p>I can get Python to work with Postgresql but I cannot get it to work with MySQL. The main problem is that on the shared hosting account I have I do not have the ability to install things such as Django or PySQL, I generally fail when installing them on my computer so maybe it's good I can't install on the host.</p>
... | <p>MySQLdb is what I have used before.</p>
<p>If you host is using Python version 2.5 or higher, support for sqlite3 databases is built in (sqlite allows you to have a relational database that is simply a file in your filesystem). But buyer beware, sqlite is not suited for production, so it may depend what you are tr... | <p>Take a pick at</p>
<p><a href="https://docs.djangoproject.com/en/1.8/ref/databases/" rel="nofollow">https://docs.djangoproject.com/en/1.8/ref/databases/</a></p>
<p>MySQLdb is mostly used driver, but if you are using python3 and django 1.8.x that will not work, then you should use mysqlclient that is a folk of MySQ... | 2,319 |
<p>What does generator comprehension do? How does it work? I couldn't find a tutorial about it.</p>
| <p>Do you understand list comprehensions? If so, a generator expression is like a list comprehension, but instead of finding all the items you're interested and packing them into list, it waits, and yields each item out of the expression, one by one.</p>
<pre><code>>>> my_list = [1, 3, 5, 9, 2, 6]
>>>... | <p>Generators are same as lists only, the minor difference is that in lists we get all the required numbers or items of the list at ones, but in generators the required numbers are yielded one at a time. So for getting the required items we have to use the for loop to get all the required items.</p>
<pre><code>#to get ... | 47,620 |
<p>I have LINQ statement that looks like this:</p>
<pre><code>return ( from c in customers select new ClientEntity() { Name = c.Name, ... });
</code></pre>
<p>I'd like to be able to abstract out the select into its own method so that I can have different "mapping" option. What does my method need to return?</p>
<p>I... | <p>New answer now I've noticed that it's Linq to SQL... :)</p>
<p>If you look at the version of Select that works on <code>IQueryable<T></code> it doesn't take a <code>Func<In, Out></code>. Instead, it takes an <code>Expression<Func<In, Out>></code>. The compiler knows how to generate such a th... | <p>This is for linq to objects? Or for a linq to ?</p>
<p>Because ... select new Mapper(c), requires that 'c' is already materialized into an object, and then passed to the Mapper() CTor. (as 'c' is not known at the db level, only at the .NET level)</p>
| 46,557 |
<p>I have this 'simplified' fortran code</p>
<pre><code>real B(100, 200)
real A(100,200)
... initialize B array code.
do I = 1, 100
do J = 1, 200
A(J,I) = B(J,I)
end do
end do
</code></pre>
<p>One of the programming gurus warned me, that fortran accesses data efficiently in column order, while c accesses d... | <p>In C, multi-dimensional arrays work like this:</p>
<pre><code>#define array_length(a) (sizeof(a)/sizeof((a)[0]))
float a[100][200];
a[x][y] == ((float *)a)[array_length(a[0])*x + y];
</code></pre>
<p>In other words, they're really flat arrays and <code>[][]</code> is just syntactic sugar.</p>
<p>Suppose you do th... | <p>Are you sure your FORTRAN guys did things right? </p>
<p>The code snippet you originally posted is already accessing the arrays in row-major order (which is 'inefficient' for FORTRAN, 'efficient' for C).</p>
<p>As illustrated by the snippet of code and as mentioned in your question, getting this 'correct' can be ... | 28,176 |
<p>I'm making a request from an <code>UpdatePanel</code> that takes more then 90 seconds. I'm getting this timeout error:</p>
<blockquote>
<p>Microsoft JScript runtime error:
Sys.WebForms.PageRequestManagerTimeoutException: The server request
timed out.</p>
</blockquote>
<p>Does anyone know if there is a way to... | <p>There is a property on the ScriptManager which allows you to set the time-out in seconds. The default value is 90 seconds.</p>
<pre><code>AsyncPostBackTimeout="300"
</code></pre>
| <p>Well, I suppose that would work if you just want the request thrown away with the potential that it never completely executed...</p>
<p>Add an AsyncPostBackTimeOut property to the ScriptManager tag to change your default timeout from 90 seconds to something more reasonable for your application.</p>
<p>Further, loo... | 19,233 |
<p>I want to be able to capture the exception that is thrown when a user requests a non-existent controller and re-direct it to a 404 page. How can I do this?</p>
<p>For example, the user requests <code>http://www.nosite.com/paeges/1</code> (<em>should be</em> <code>/pages/</code>). How do I make it so they get re-dir... | <p>Take a look at <a href="http://richarddingwall.name/2008/08/09/three-common-aspnet-mvc-url-routing-issues/" rel="noreferrer">this page</a> for routing your 404-errors to a specified page.</p>
| <p>Found this on the same site - <a href="http://richarddingwall.name/2008/08/17/strategies-for-resource-based-404-errors-in-aspnet-mvc/" rel="nofollow noreferrer">Strategies for Resource based 404s</a></p>
| 4,028 |
<p>Currently I have a structure like this:</p>
<pre><code>A
|
+--B
|
+--C
</code></pre>
<p>It's mapped with one table per subclass using joined tables. For historic reasons I also use a discriminator, so the current situation is as described in <a href="http://www.hibernate.org/hib_docs/v3/reference/en-US/html/inheri... | <p><strong><em>not tested</em></strong> but, according to the link you posted if you are using hibernate3</p>
<pre><code><hibernate-mapping>
<class name="A" table="A">
<id name="id" type="long" column="a_id">
<generator class="native"/>
</id>
<discriminator column="... | <p>Using Annotations, it can be done as follows:</p>
<pre><code>@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name="LoanType",discriminatorType="String")
@Table(name = "A")
public class A implements Serializable{
}
@Entity
@Table(name= "B")
@PrimaryKeyJoinColumn(name = "B_ID", reference... | 32,683 |
<p>any tool to generate incremental release script for oracle database.</p>
<p>like Redgate DBComparer for SQLServer.</p>
| <p>See <a href="https://stackoverflow.com/questions/47366/sql-compare-like-tool-for-oracle">here</a>.</p>
<p>Other links, tools:</p>
<p><a href="http://www.sqlmanager.net/de/products/oracle/dbcomparer" rel="nofollow noreferrer">http://www.sqlmanager.net/de/products/oracle/dbcomparer</a></p>
<p><a href="http://www.sq... | <p>Maybe a year late for you but Red Gate now has a schema comparison tool for Oracle!</p>
<p>Try <a href="http://www.red-gate.com/products/schema_compare_for_oracle/index.htm" rel="nofollow noreferrer">http://www.red-gate.com/products/schema_compare_for_oracle/index.htm</a> </p>
| 42,500 |
<p>Is there a widely accepted class for dealing with URLs in PHP?</p>
<p>Things like: getting/changing parts of an existing URL (e.g. path, scheme, etc), resolving relative paths from a base URL. Kind of like a two-way <a href="http://php.net/parse_url" rel="nofollow noreferrer">parse_url()</a>, encapsulated with a b... | <p>You've got the <a href="http://pear.php.net/package/Net_URL2/docs" rel="nofollow noreferrer">Net_URL2</a> package over at PEAR, which appears to have replaced the <a href="http://pear.php.net/package/Net_URL/docs" rel="nofollow noreferrer">original Net_URL</a>. I have no first hand experience with it, but I'll almo... | <p><a href="http://framework.zend.com/manual/en/zend.uri.html" rel="nofollow noreferrer"><code>Zend_Uri</code></a> is a good candidate.</p>
| 43,188 |
<p>I set up MbUnit and have been trying to get it to work with VS 2008 using the MbUnit GUI but every time I run a test it closes and I get a this program needs to close error.</p>
<p>I had a similar problem with Gallio where I got a runner exception every time I ran a test.</p>
<p>Do I need an addin for VS like test... | <p>Same here. TestDriven.Net really makes things slick and easy. Right-click on a test and run it... MBUnit integrates fine with that add-in.</p>
| <p>You don't need TestDriven.Net but it sure helps.</p>
<p>When you say you use the MBUnit GUI "but every time I run a test it closes..." do you mean that MBUnit closes or VS2008? If is MBUnit, then perhaps there is something wrong with your installation. If it is VS2008, then something is fishy since MBunit shouldn... | 34,499 |
<p>An easy jQuery question.</p>
<p>I have several identical forms ( except their name ) on one page with a few hidden inputs in each. I want to refer to them by using the form name and then the input name. ( the input names are not unique in my page )</p>
<p>So for instance: </p>
<pre><code>var xAmt = $('#xForm'+nu... | <pre><code>function queryX( args ) {
var queryString = [ "XID=", args.XID, "&xNumber=", args.xNumber, "&xAmt=", args.xAmt ].join("");
$.ajax({
url: "X.asp",
cache: false,
type: "POST",
data: queryString,
success : function( data ) {
return data;
... | <p><strong>Edited:</strong></p>
<p>You need to start with getting them all selected, then you can work with them.</p>
<p>To access just the xForm# elements, you can do a selector like this (you should check the syntax, I haven't run this, it's just an example):</p>
<pre><code>$('form input[name*='xAmt'] ').each(fun... | 31,320 |
<p>Our site has the default Stack Exchange logo (text balloon with text 3D), is it possible to change this logo?</p>
<p>I was thinking of something like this:</p>
<p><a href="https://i.stack.imgur.com/n4VXE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n4VXE.png" alt="enter image description here" ... | <p>Yes, we can! Or at least discuss if we like a different logo.</p>
<p>From <a href="https://meta.stackexchange.com/a/298341/">this answer</a> on Meta Stack Exchange question "<a href="https://meta.stackexchange.com/questions/298338/whats-the-process-to-change-a-site-logo">What's the process to change a site logo... | <p>i'd like to remind my old suggestion :)</p>
<p><a href="https://i.stack.imgur.com/oVISY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oVISY.png" alt="enter image description here" /></a></p>
<p>here is the original post
<a href="https://3dprinting.meta.stackexchange.com/a/248/1211">https://3dpri... | 80 |
<p>I have a project which is source controlled using Subversion and VisualSVN. Since the version of web.config is different on the server and the developers' computers I want the file to remain on the computers but to be ignored by Subversion. I added it to the svn:ignore but it still remains (and still has a red excla... | <p>you'll have to do both the remove and ignore operation</p>
<ul>
<li>first make a backup of your local file (like @ibz said)</li>
<li>then remove the web.config from the repository.</li>
<li>then copy back the web.config to the same folder</li>
<li>finally use svn:ignore so that subversion does not try to add it aga... | <p>I have solved this issue using nant with ccnet. Following nant build script replaces web.test.config file with local web.config file;</p>
<pre><code><?xml version="1.0"?>
<project name="Project1" default="build">
<target name="init" depends="clean" />
<target name="clean" />
... | 7,999 |
<p>I have an script that receives an encrypted url and from that generates a download, the most critic par of the script is this:</p>
<pre><code>$MimeType = new MimeType();
$mimetype = $MimeType->getType($filename);
$basename = basename($filename);
header("Content-type: $mimetype");
header("Content-Disposition: att... | <p><a href="http://bytes.com/forum/thread554529.html" rel="nofollow noreferrer">This site</a> has a problem similar to yours in IE6. To summarize:</p>
<blockquote>
<p>session_start() by default sends a cache control header including "no-store".
Internet Explorer takes this a bit too literally, but doesn't have app... | <p>Use this</p>
<p>In IE7 Browser go to internet option--> security--->custom level --->downloads
then enabled autometic prompting for file download.</p>
<p>this will solve the problem.</p>
<p>hope this will help</p>
| 14,295 |
<p>I have using the following code for developing tabs.</p>
<pre><code>$(document).ready(function() {
$('#container-1').tabs();
}
....
<div id="container-1">
<ul>
<li><a href="#fragment-1"><span>Home</span></a></li>
<li><a href="#fragmen... | <p>Set the id of the <em>Home</em> tab span element:</p>
<pre><code><li><a href="#fragment-1"><span id="home">Home</span></a></li>
</code></pre>
<p>And add the click handler to it somewhere:</p>
<pre><code>$("#home").click(function()
{
alert("Home tab is selected!");
});
</co... | <p>If you want the tab click event, you would do something like one of the following.</p>
<pre><code>$("#tabid").click(function(e) {
e.preventDefault();
// Do tab click logic
});
</code></pre>
<p>or</p>
<pre><code>$(".tabclass").click(function(e) {
e.preventDefault();
// Do tab click logic
});
</code... | 46,424 |
<p>For years, one of my most important tools has been incremental copy utility that compares the contents of two directories and shows me which files are newer / older / added / deleted. Every day I find myself copying folders of source code between my two desktop machines and the server, and such a utility is critica... | <p><a href="http://samba.anu.edu.au/rsync/" rel="nofollow noreferrer">rsync</a>. All the time.</p>
<p>The biggest benefit to rsync is that it trades increased CPU time for decreased transfer bandwidth, as CPUs are super fast nowadays, and even disk-copy is relatively slow, this is a good thing.</p>
| <p>robocopy. It's in Vista, and is also part of the Windows Resource Kit. It has a strange command line interface, but it's very powerful & good for this kind of thing.</p>
<p>Still, I find myself wondering whether source control would be a better choice for you.</p>
| 12,867 |
<p>I'd like to print modifications for my bird feeder, both to patch over the hail damage from last summer and to try to deter the neighborhood squirrels. I have an FDM printer (and experience with nylon, ABS, and PLA, though don't restrict answers to those if there's something else that's better), what kind of filame... | <p>PET(G) is a strong contender. It is very strong and water-resistant, and as such is often used to make pop bottles.</p>
<p>PLA has a reputation for being "biodegradable" and therefore it is often discouraged to use PLA outside and/or in contact with water. However, PLA only biodegrades under very specific condition... | <p>I think ABS would be your best bet. It's not biodegradable and realtivley easy to print.</p>
<p>But you can use more or less any material if you use some form of coating on it. I would always go for coated PLA instead of other materials just because PLA is the easiest to print and it's nontoxic.</p>
| 88 |
<p>Which one is recommended considering readability, memory usage, other reasons?</p>
<p><strong>1.</strong></p>
<pre><code>String strSomething1 = someObject.getSomeProperties1();
strSomething1 = doSomeValidation(strSomething1);
String strSomething2 = someObject.getSomeProperties2();
strSomething2 = doSomeValidation(s... | <p>I would probably go in-between:</p>
<pre><code>String strSomething1 = doSomeValidation(someObject.getSomeProperties1());
String strSomething2 = doSomeValidation(someObject.getSomeProperties2());
someObject.setSomeProperties(strSomething1 + strSomething2);
</code></pre>
<p>Option #2 seems like a lot to do in one li... | <p>Personally, I prefer the second one. It's less cluttered and I don't have to keep track of those temporary variables.</p>
<p>Might change easily with more complex expressions, though.</p>
| 41,041 |
<p>I'm working on an assigned group project at University where we have to re-implement the TCP/IP stack to support some extra stuff (<a href="http://discolab.rutgers.edu/mtcp/" rel="nofollow noreferrer">http://discolab.rutgers.edu/mtcp/</a>), and then demonstrate it.</p>
<p>The thesis/design we're working from says t... | <p>The <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/" rel="nofollow noreferrer">FreeBSD Handbook</a> contains a section on <a href="http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-building.html" rel="nofollow noreferrer">Building and Installing a Custom Kernel</a>. The Handb... | <p>Why do this over a simple load-balancing solution? The goal of TCP/IP is to handle data reliably between two machines over a network. There are other layers of abstraction that are much more capable of dealing with the problem of server congestion that won't require drastic changes to fundamental internet protocols.... | 29,933 |
<p>are there any additional WPF themes from microsoft except that default ones provided in
PersentationFrameWork.Aero,
PersentationFrameWork.Luna,
PersentationFrameWork.Royale &
PersentationFrameWork.Classic</p>
<p>i am specially interested in a Office 2007 Blue theme</p>
| <p>If you happen to have <a href="http://www.infragistics.com/dotnet/netadvantage/wpf.aspx#Overview" rel="nofollow noreferrer">Infragistics NetAdvantage</a>: it has some Office 2007 themes.</p>
| <p>You might want to try www.reuxables.com - we have both commercial and free themes, and it is the largest and most diverse theme library for WPF.</p>
| 41,417 |
<p>I have a range of Win32 VCL applications developed with C++Builder from BCB5 onwards, and want to port them to ECB2009 or whatever it's now called.</p>
<p>Some of my applications use the old TNT/TMS unicode components, so I have a good mix of AnsiStrings and WideStrings throughout the code. The new version introduc... | <p>The biggest issue is compatibility for C++Builder 2009 and previous versions, the Unicode differences are some, but the project configuration files have changed as well. From the discussions I've been following on the <a href="https://forums.codegear.com/category.jspa?categoryID=8" rel="nofollow noreferrer">CodeGea... | <p>The biggest issue is compatibility for C++Builder 2009 and previous versions, the Unicode differences are some, but the project configuration files have changed as well. From the discussions I've been following on the <a href="https://forums.codegear.com/category.jspa?categoryID=8" rel="nofollow noreferrer">CodeGea... | 18,404 |
<pre><code>$pee = preg_replace( '|<p>|', "$1<p>", $pee );
</code></pre>
<p>This regular expression is from the Wordpress source code (formatting.php, wpautop function); I'm not sure what it does, can anyone help?</p>
<p>Actually I'm trying to port this function to Python...if anyone knows of an existing p... | <p>wordpress really calls a variable "pee" ?</p>
<p>I'm not sure what the $1 stands for (there are no braces in the first parameter?), so I don't think it actually does anything, but i could be wrong.</p>
| <p>It replace the match from the pattern </p>
<pre><code>"|<p>|"
</code></pre>
<p>by the string </p>
<pre><code>"$1<p>"
</code></pre>
<p>The | in the replacement pattern is causes the regex engine to match either the part on the left side, or the part on the right side. </p>
<p>I do not get why it's u... | 45,549 |
<p>I saw this the other day (scroll <em>all the way</em> down to see some of the clever stuff): </p>
<blockquote>
<p><a href="http://www.mono-project.com/docs/tools+libraries/tools/repl/" rel="nofollow noreferrer">http://www.mono-project.com/docs/tools+libraries/tools/repl/</a></p>
</blockquote>
<p>And wondered whe... | <p>One project I'm aware of that provides similar features (inline plotting, customisable rendering) is <a href="http://fishsoup.net/software/reinteract/" rel="noreferrer">Reinteract</a>. Another (though possibly a bit heavyweight for general usage) is <a href="http://www.sagemath.org/" rel="noreferrer">SAGE</a> which... | <p><a href="http://www.lighttable.com/" rel="nofollow">Light Table</a> is working on this. The IDE is simultaneously a REPL -- it has in-line plotting with iPython.</p>
| 34,971 |
<p>I'm just trying to time a piece of code. The pseudocode looks like:</p>
<pre><code>start = get_ticks()
do_long_code()
print "It took " + (get_ticks() - start) + " seconds."
</code></pre>
<p>How does this look in Python?</p>
<p>More specifically, how do I get the number of ticks since midnight (or however Python o... | <p>In the <code>time</code> module, there are two timing functions: <code>time</code> and <code>clock</code>. <code>time</code> gives you "wall" time, if this is what you care about.</p>
<p>However, the python <a href="http://docs.python.org/lib/module-time.html" rel="noreferrer">docs</a> say that <code>clock</code> s... | <p>If you have many statements you want to time, you could use something like this:</p>
<pre><code>class Ticker:
def __init__(self):
self.t = clock()
def __call__(self):
dt = clock() - self.t
self.t = clock()
return 1000 * dt
</code></pre>
<p>Then your code could look like:</p... | 18,909 |
<p>So I've just recently made the step from ad hoc debugging with <code>dump</code>, <code>print_r</code> and <code>echo</code> to some more sophisticated methods and I'm having a struggle. </p>
<p>I work with Zend Framework, Aptana and Zend Debugger.</p>
<p>At this moment I'm trying to debug a custom controller and ... | <p>You want to change the current user's authentication details mid-way through a request? </p>
<p>I don't think this is possible. Zend Debugger is pretty much a read-only tool. Even if it were, you're assuming that whatever framework you're using can handle this. That would mean it would have to constantly try to syn... | <p>Ok so I played with zend debugger some more. (your question stirred up old demons) and I finally figured out the "proper" way to debug. To answer your initial question to debug after login I would say install the zend toolbar for firefox or IE. To the right of the Debug menu item there is a drop down with some optio... | 44,711 |
<p>I am using HtmlAgilityPack. I create an HtmlDocument and LoadHtml with the following string:</p>
<pre><code><select id="foo_Bar" name="foo.Bar"><option selected="selected" value="1">One</option><option value="2">Two</option></select>
</code></pre>
<p>This does some unexpected t... | <p>The exact same error is reported on the HAP home page's discussion, but it looks like no meaningful fixes have been made to the project in a few years. Not encouraging.</p>
<p>A quick browse of the source suggests the error might be fixable by commenting out line 92 of HtmlNode.cs:</p>
<pre><code>// they sometimes... | <p>It seems that there is some reason not to parse the Option tag as a "generic" tag, for XHTML compliance, however this can be a real pain in the neck.</p>
<p>My suggestion is to do a whole-string-replace and change all "option" tags to "my_option" tags, that way you:</p>
<ol>
<li>Don't have to modify the source of ... | 37,436 |
<p>Just trying to get my head around Generics by reading <a href="http://msdn.microsoft.com/en-us/library/ms379564.aspx" rel="noreferrer">this enlightening article by Juval Lowy</a> </p>
<p>Paraphrasing.. When you define a Generic class definition, it is compiled into IL.</p>
<ul>
<li>For value-types, as soon as you ... | <p>Upcasting to object doesn't require an execution time check - it will always work, and is just a no-op basically.</p>
<p>Downcasting requires an execution time check to make sure you're not casting a Stream to a String for example. It's a pretty small penalty, and very unlikely to be a bottleneck - but avoiding it ... | <p>Reading up on the IL that gets generated (this <a href="http://www.hanselman.com/blog/BackToBasicsThisIsNotTheObjectYoureLookingwaitOhItIsTheObject.aspx" rel="nofollow noreferrer">article</a> mentions it)... aha - isinst.</p>
<p>If you weren't downcasting, you wouldn't have to call <a href="http://msdn.microsoft.co... | 39,330 |
<p>How can I create a new Word document pro grammatically using Visual Studio Tools for Office? </p>
| <p>What you are actually after is Office Automation using the PIA's (Primary Interop Assemblies).</p>
<p>VSTO is actually a set of Managed .net extensions which make writing add-ins for Office far easier. For external interaction VSTO is not used at all (though you can still reference VSTO libraries and use some of th... | <p>Now, I might be wrong on this, but I don't believe you can actually make a new Word doc using VSTO. I'm not intimately familiar with VSTO, so forgive me if I'm incorrect on that point.</p>
<p>I do know that you can use Office Interop libraries to do this, however.</p>
<p>To download the libraries, just do a searc... | 19,501 |
<p>I have an application where I accept a socket connection from a telnet client and put up a simple, keyboard driven character GUI.</p>
<p>The telnet client, at least on Linux, defaults into line-at-a-time mode, so I always have to do <code>^]mode char</code> manually.</p>
<p>A skim of the relevant RFCs suggests tha... | <p>For what it's worth, solved it myself.</p>
<pre><code>// IAC WONT LINEMODE IAC WILL ECHO
write(s,"\377\375\042\377\373\001",6);
</code></pre>
<p>gets the remote (at least telnet from an Xterm on a Linux box) into the right state.</p>
| <p>Kevin's solution works great:</p>
<pre><code>write(s,"\377\375\042\377\373\001",6);
</code></pre>
<p>Although the comment is slightly wrong. It should say "DO LINEMODE", not "WONT LINEMODE", ie:</p>
<pre><code>// IAC DO LINEMODE IAC WILL ECHO
</code></pre>
<p>(Source: <a href="https://w... | 34,419 |
<p>We're in an early stage of a new web project. The project will grow and become complex over time. From the beginning we will have unit and integration tests using JUnit and system tests using HtmlUnit. We might also add some static code analysis tools to the build process if they prove to be of value to us.</p>
<p>... | <p>Hudson (the best). <a href="http://hudson-ci.org/" rel="nofollow noreferrer">Hudson Website</a></p>
| <p>CruiseControl works reasonably well once you get it configured.</p>
<p><a href="http://cruisecontrol.sourceforge.net/" rel="nofollow noreferrer">http://cruisecontrol.sourceforge.net/</a></p>
| 12,259 |
<p>I often find a need to put paths in my code in order to find data or in some cases tool-specific modules. I've so far always used autotools because of this--it's just so easy to call sed to replace a few strings at build time. However, I'd like to find a more Pythonic way of doing this, i.e. use distutils or some ... | <p>For modules paths, a common practice is putting them in <em>.pth</em> files, as <a href="http://docs.python.org/library/site.html#module-site" rel="nofollow noreferrer">documented here</a>. The <em>site</em> module provides a space for Site-specific configuration hooks, you can use it to tailor your environment.</p>... | <p>"I often find a need to put paths in my code" -- this isn't very Pythonic to begin with.</p>
<p>Ideally, your code lives in some place like site-packages and that's the end of that.</p>
<p>Often, we have an installed "application" that uses a fairly fixed set of directories for working files. In linux, we get th... | 33,618 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.