instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>One of my nasty (?) programming habits in C++ and Java is to always precede calls or accesses to members with a <code>this</code>. For example: <code>this.process(this.event)</code>.</p>
<p>A few of my students commented on this, and I'm wondering if I am teaching bad habits. </p>
<p>My rationale is:</p>
<ol>
<li... | <p>I think it's less readable, especially in environments where fields are highlighted differently from local variables. The only time I want to see "this" is when it is required, for example:</p>
<pre><code>this.fieldName = fieldName
</code></pre>
<p>When assigning the field.</p>
<p>That said, if you need some way... | <p>From a .Net perspective, some of the code analysis tools I used saw the "this" and immediately concluded the method could not be static. It may be something to test with Java but if it does the same there, you could be missing some performance enhancements.</p>
| 17,698 |
<p>I currently maintain 3 websites all revolving around the same concept. 2 of them are WinForms applications where the website gives a few basic details, and download links. The third is a web application to query data. I also have a forum (SMF/TinyPortal) that has been serving as a tech support/news hub for the three... | <p>If you want to quickly compare features on CMS's, then take a look at <a href="http://www.cmsmatrix.org/" rel="nofollow noreferrer">CMS Matrix</a> - has practically every cms known to man on there.</p>
<p><em>Edit</em>
To be a little more precise, from the site</p>
<blockquote>
<p>CMSMatrix is the number one con... | <p>DotNetNuke out of the box contains a lot of features, content management, link management, documents list modules, forum modules, and items of that nature. There is also a very good third-party module and skin market out there for getting the enhancements needed to really get a full solution implemented.</p>
<p>Wi... | 11,271 |
<p>What is the simplest SOAP example using Javascript?</p>
<p>To be as useful as possible, the answer should:</p>
<ul>
<li>Be functional (in other words actually work)</li>
<li>Send at least one parameter that can be set elsewhere in the code</li>
<li>Process at least one result value that can be read elsewhere in th... | <p>This is the simplest JavaScript SOAP Client I can create. </p>
<pre><code><html>
<head>
<title>SOAP JavaScript Client Test</title>
<script type="text/javascript">
function soap() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST', 'https:/... | <pre><code>function SoapQuery(){
var namespace = "http://tempuri.org/";
var site = "http://server.com/Service.asmx";
var xmlhttp = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0");
xmlhttp.setOption(2, 13056 ); /* if use standard proxy */
var args,fname = arguments.callee.caller.toString().match(/ ([^\(]+)/)[... | 15,117 |
<p>Yes, like those pretty buttons on the iPhone. ;)</p>
<p>I've been searching and reading for days now and everytime I find something that will get me close (like CreateRoundRectRgn), it blows up because Windows Mobile 6 GDI+ doesn't support it.</p>
<p>I can do the whole owner draw thing and such. But how do I cu... | <p>Getting pretty buttons like that is typically done by doing a complete owner-drawn button and drawing an image that a graphic designer created to it rather than letting GDI do any of the control painting. You simply need an image for "up" and an image for "pressed". You can manually draw in the focus or use yet an... | <p>You can use the RoundRect GDI function to do it on an owner drawn control.</p>
<pre><code>//Set up a brush and pen
HBRUSH brush = CreateSolidBrush(RGB(255, 0, 0));
HPEN pen = CreatePen(PS_SOLID, 1, RGB(0, 255, 0));
//Select it
HGDIOBJ old_brush = SelectObject(hdc, brush);
HGDIOBJ old_pen = SelectObject(hdc, pen);
... | 44,047 |
<p>I have a tabview controller to which I added a UIViewController to each tab. I want to have multiple UIViews inside the UIViewController.</p>
<p>So in the implementation of the UIViewController class I added [self.view addSubView:uiview1] and [self.view addSubView:uiview2]. The problem is that when I run the app, i... | <p>Assuming you are doing this programmatically, you're supposed to create the view in the view controller's loadView method. So you must do this:</p>
<pre><code>self.view = [[[UIView alloc] initWithFrame:someFrame] autorelease];
</code></pre>
<p>before you do this:</p>
<pre><code>[self.view addSubview:uiview1];
[se... | <p>There's no reason you can't have multiple views within your UIViewController's main view member variable. However, there are quite a few items left unanswered in your question:</p>
<ul>
<li>How are you obtaining view1 and view2? </li>
<li>Are they outlets in your XIB file (are you using a XIB file, or creating ever... | 29,432 |
<p>Where did the idea of design patterns come from, who decided what is and isn't a pattern and gave them their names? Is there an official organisation that defines them, or do they exist through some community consensus?</p>
| <p>I think there's a basic "life cycle of a design pattern"</p>
<ol>
<li>Author writes about design pattern in a book.</li>
<li>Book becomes well read, possibly best seller</li>
<li>Design pattern enters public conscious, gains mindshare.</li>
<li>Design pattern gets used. It works well. design pattern gets more minds... | <p>There is a canonical book: Gamma, Helm, Johnson, Vlissides: "Dessign Patterns - Elements of Reusable Object-Oriented Software" which started it all. It contains 23 patterns.</p>
| 16,501 |
<p>Is it possible to code a Dojo DnD target to accept external objects, such as files or folders from a file explorer? Windows Explorer, for example.</p>
| <p>I doubt it, because it will be the browser that will receive the DnD event...<br>
At best you can count on a plugin or extension to handle it, like the excellent <a href="http://www.teslacore.it/wiki/index.php?title=DragDropUpload" rel="nofollow noreferrer" title="DragDropUpload">DragDropUpload</a> extension does fo... | <p>What kind of file explorer are you talking about? From what I can recall you'd be lucky to get dnd working properly even for table rows, the api is a pain in the @$$.</p>
| 19,677 |
<p>Using Scala's command line REPL:</p>
<pre><code>def foo(x: Int): Unit = {}
def foo(x: String): Unit = {println(foo(2))}
</code></pre>
<p>gives</p>
<pre><code>error: type mismatch;
found: Int(2)
required: String
</code></pre>
<p>It seems that you can't define overloaded recursive methods in the REPL. I thought th... | <p>The issue is due to the fact that the interpreter most often has to <em>replace</em> existing elements with a given name, rather than overload them. For example, I will often be running through experimenting with something, often creating a method called <code>test</code>:</p>
<pre><code>def test(x: Int) = x + x
<... | <p>As shown by <a href="https://stackoverflow.com/users/89872/extempore">extempore's</a> answer, it is possible to overload. <a href="https://stackoverflow.com/users/9815/daniel-spiewak">Daniel's</a> comment about design decision is correct, but, I think, incomplete and a bit misleading. There's no <em>outlawing</em> o... | 14,678 |
<p>I'm not looking for a general discussion on <a href="https://stackoverflow.com/questions/157354/is-mathematics-necessary-for-programming">if math is important or not for programming</a>. </p>
<p>Instead I'm looking for real world scenarios where you have actually used some branch of math to solve some particular pr... | <p>I frequently find myself using <a href="http://en.wikipedia.org/wiki/De_Morgan's_laws" rel="nofollow noreferrer">De Morgan's theorem</a> when as well as general Boolean algebra when trying to simplify conditionals</p>
<p>I've also occasionally written out truth tables to verify changes, as in the example below ... | <p>Computing sizes of caches to optimize performance. Not as simple as it sounds when this is your critical path, and you have to go back and work out the times saved by using the cache relative to its size.</p>
| 42,217 |
<p>Does anyone have any experience with a tool that generates test strings from a BNF grammar that could then be fed into a unit test?</p>
| <p>I don't have an answer to the tool question, but I will say it is fairly easy in any text processing language (perl/python/etc) to randomly generate sentences from a BNF grammar, and slightly more verbose in a bigger language (Java/C/etc), but it shouldn't be too hard to roll your own.</p>
<p>The problem with this,... | <p>If, say, you're developing a compiler, then you likely have an abstract syntax tree datatype. If so, then you could write a function to generate an random AST -- with that, you can print it to a string and feed that to your unit test. It's guaranteed to be a valid program this way, since you <em>started</em> with ... | 7,541 |
<p>I followed the commonly-linked tip for reducing an application to the system tray : <a href="http://www.developer.com/net/csharp/article.php/3336751" rel="noreferrer">http://www.developer.com/net/csharp/article.php/3336751</a> Now it works, but there is still a problem : my application is shown when it starts ; I wa... | <p>In your main program you probably have a line of the form:</p>
<pre><code>Application.Run(new Form1());
</code></pre>
<p>This will force the form to be shown. You will need to create the form but <em>not</em> pass it to <code>Application.Run</code>:</p>
<pre><code>Form1 form = new Form1();
Application.Run();
</co... | <p>Here you go:</p>
<p>Create 2 classes, 1 which inherits from ApplicationContext. The other only contains a Main routine. I've made an example that has a form and a notifyicon that when double clicked brings up the form and back again.</p>
<p>Remember to set "Sub Main" as your startup object in My Project settings a... | 35,965 |
<p>Is there a maximum number of inodes in a single directory? </p>
<p>I have a directory of over 2 million files and can't get the <code>ls</code> command to work against that directory. So now I'm wondering if I've exceeded a limit on inodes in Linux. Is there a limit before a 2^64 numerical limit?</p>
| <p><code>df -i</code> should tell you the number of inodes used and free on the file system.</p>
| <p>Another option is <a href="http://www.gnu.org/software/findutils/" rel="nofollow noreferrer"><code>find</code></a>:</p>
<p><code>find . -name * -exec somcommands {} \;</code></p>
<p><code>{}</code> is the absolute filepath.</p>
<p>The advantage/disadvantage is that the files are processed one after each other.</... | 6,160 |
<p>There are lots of people out there asking "why shouldn't we use tables for structuring our HTML" and while a lot of answers come in, I rarely see anyone being converted to the world of semantics. That said, I've yet to see any convincing rebuttals to support the rationale for why we should (or might) use tables.</p>... | <p>Tables are valid when you have a table of data. I've seen interactive grid widgets where they go out of their way to use a bunch of divs to avoid the dreaded table tag. When it's tabular data, make it a table.</p>
<p>A more controversial view of mine is that when you have problems dealing with vertical layout issue... | <p>Tables are supported even in crusty old HTML v1.0 browsers. If your target market includes people using embedded browsers in mobile phones from the 1990s, that might be a good reason to go with tables.</p>
<p>Lots of existing auto-generated HTML uses tables. If your code needs to interact with or include those tabl... | 12,171 |
<p>I just posted the question <a href="https://stackoverflow.com/questions/246575/how-to-determine-why-the-browser-keeps-trying-to-load-a-page">how-to-determine-why-the-browser-keeps-trying-to-load-a-page</a> and discovered that my problem is with Gravatar. </p>
<p>I also noticed that StackOverflow is suffering from ... | <p>You can have a different process that is periodically checking the status of the site. Set a rule about what is down for you, for instance you could say: "ping time > 1500 ms = down". Have this process to leave a note in a database table or config file. Then you check this value on each page rendering at almost no c... | <p>For Gravatar you can cache all theses images instead of taking them from their server everytime. Of course, if user change their icon, it might not refresh as fast as it would be if it were direct access to the main server but at least you do not have to request gravar server everytime.</p>
| 30,611 |
<p>We know that code coverage is a poor metric to use when gauging the quality of test code. We also know that testing the language/framework is a waste of time. </p>
<p>On the other hand, what metrics can we use to identify quality tests? Are there any best practices or rules of thumbs that you've learned to help y... | <ol>
<li>Make sure your tests are independent of each other. A test shouldn't depend on the execution or results of some other test.</li>
<li>Make sure each test has clearly defined entry criteria, test steps and exit criteria.</li>
<li>Set up a Requirements Verification Traceability Matrix (RVTM). Each test should ver... | <p>My rules of thumb:</p>
<ol>
<li>Cover even simpler test cases in your test plan (don't risk leaving the most used functionality untested)</li>
<li>Trace the corresponding requirement near each test case</li>
<li>As <a href="http://www.joelonsoftware.com/articles/fog0000000043.html" rel="nofollow noreferrer">Joel</a... | 23,804 |
<p>I am using IIS6, I've written an HttpModule, and I get this error? After googling the web I find that this problem is caused by the .NET framework 3.5, so I put this on a machine where I didn't install .NET 3.5, but the problem is still there!</p>
| <p>My attempt at psychic debugging: you're using a statement like:</p>
<pre><code>Response.Headers("X-Foo") = "bar"
</code></pre>
<p>If this is indeed the case, changing this as shown below will work around the problem:</p>
<pre><code>Response.AddHeader("X-Foo", "bar")
</code></pre>
| <p>Inspired by other answers, I've found that it's accessing the <code>Response.Headers</code> <em>object</em> that causes the "operation requires IIS integrated pipeline mode" exception.</p>
<p>Avoid <code>.Headers</code> and call other (older?) helper functions like:</p>
<ul>
<li><code>Response.AddHeader()</code> ... | 22,575 |
<p>I got a program with a fscanf like this:</p>
<p>fscanf(stdin, "%d %d,....</p>
<p>I got many fscanf and files that I'd like to test, the files are like this</p>
<p>10485770 15 51200000
-2 10
10 10485760 10485760
10 10485760 10485760
10 10485760 10485760</p>
<p>Well my question is how can I tell to the program o... | <p>Try freopen. Eg.</p>
<pre><code>freopen( "somefile.txt", "r", stdin );
</code></pre>
| <p>Look up the FILE structure. You'll be wanting to use FILE pointers for this solution.</p>
| 24,862 |
<p>When I am unsure about some thing for a project, I usually use a small separate project and make it my playground for things need to be tested. How do you do that ?</p>
| <p>This depends on what I want to try out. For simple algorithmic stuff, I have a console application that consists of many classes, one for every thing I want to try out. This way I have everything inside a single project and can browse through the ideas and approaches I've tried out during the years. I use folders fo... | <p>I do it the same way. A temporary project has some disadvantages... You have to setup a new project as soon as you want to test something else. Also I found playgrounds to be pretty good references. Often I remember that I tried something previously and then I can look into the old playground files and even change i... | 16,747 |
<p>After reading the Head First Design Patterns book and using a number of other design patterns, I'm trying to understand the Observer pattern. Isn't this already implemented using Events in the .NET Framework?</p>
| <p>Yes, it is. The observer pattern is also called the publish/subscribe pattern, which is exactly what events allow you to do.</p>
| <p>No, they achieve the same intent, however they are different.
I would say that the Observer pattern is quite a hack of over design to achieve something you could have achieved easily with functional programming, and that .NET events uses functional programming to achieve the same goal.</p>
| 5,198 |
<p>I need your advice with converting plain text to an URL.</p>
<p>The scenario will be this: The user will select some entry and then click a "convert to link" button. </p>
<p>The entry text the user selected will convert to <code>(link: selected_text)</code>. I do it with JavaScript. And after that, when he clicks ... | <p>If you must save processed input for some reason</p>
<pre><code>(link: here)
</code></pre>
<p>must be converted to</p>
<pre><code>(link: <a href="http://www.mysite.com?t=here">here</a>)
</code></pre>
| <p>To store in database, you'll have to track the changes separately somehow and post them back to the server. I'd suggest a HiddenInput control.</p>
| 36,218 |
<p>I am attempting to insert a mass of records into SQL Server 2005 from Vb.Net. Although the insertion is working fine, I am doing my best to try to make it as fast as possible. Currently, it takes ~ 11 mins for 100,000 records. What would be the suggested approach to inserting a large number of records into SQL Se... | <p>Use the <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx" rel="nofollow noreferrer">SqlBulkCopy</a> class, it will be able to run through those 100K rows much faster than individual inserts.</p>
<p>Oh, and if you can, I would urge you to implement a <a href="http://msdn.micros... | <p>It depends how the bulk copy class is implemented. But there is a command line tool included with installs of SQL Server that does exactly this (it's probably the same). It's called "bcp". I'm using it right now and it should be able to storm through 100k rows in a matter of seconds.</p>
<p>MSDN documentation refer... | 43,436 |
<p>I'm thinking of using PDO in all of my future webapp. Currently (using what I've learned from SO so far), what I have in my site to handle database connection is a Singleton class like this :</p>
<pre><code>class DB {
private static $instance = NULL;
private static $dsn = "mysql:host=localhost;dbname=... | <p>Your implementation is just fine, and it'll work perfectly well for most purposes.</p>
<p>It's not necessary to put every query inside a try/catch block, and in fact in most cases you actually don't want to. The reason for this is that if a query generates an exception, it's the result of a fatal problem like a sy... | <p>A couple of caveats here are:</p>
<ul>
<li>This code is written to take several legacy issues into account such as the database logging and database configuration management. </li>
<li>I would strongly recommend that you look at an existing solution before building your own. A lot of people think to themselves when... | 34,261 |
<p>So for my text parsing in C# <a href="https://stackoverflow.com/questions/13963/best-method-of-textfile-parsing-in-c">question</a>, I got directed at YAML. I'm hitting a wall with this library I was recommended, so this is a quickie.</p>
<pre><code>heading:
name: A name
taco: Yes
age: 32
heading:
name: Another... | <p>Partially. YAML supports the notion of multiple consecutive "documents". If this is what you are trying to do here, then yes, it is correct - you have two documents (or document fragments). To make it more explicit, you should separate them with three dashes, like this:</p>
<pre><code>---
heading:
name: A name
ta... | <p>Just to make an explicit comment about it: You have a duplicate mapping key issue. A YAML processor will resolve this as a !!map, which prohibits duplicate keys. Not all processors enforce this constraint, though, so you might get an incorrect result if you pass an incorrect YAML stream to a processor.</p>
| 3,652 |
<p>How do I create the default for a generic in VB? in C# I can call:</p>
<pre><code>T variable = default(T);
</code></pre>
<ol>
<li>How do I do this in VB?</li>
<li>If this just returns null (C#) or nothing (vb) then what happens to value types?</li>
<li>Is there a way to specify for a custom type what the default v... | <h2>Question 1:</h2>
<pre><code>Dim variable As T
' or '
Dim variable As T = Nothing
' or '
Dim variable As New T()
</code></pre>
<p>Notice that the latter only works if you specify the <code>Structure</code> constraint for the generic type (for reference types, <code>New T()</code> in VB does something else than <co... | <p>Not really being a VB guy, I made some mistakes in my original answer that Konrad set me straight on. The original answer is below, but I wanted to update my answer to be correct based on Konrad's input.</p>
<p>As Konrad says, <code>default(T)</code> and <code>Nothing</code> are in fact equivalent for both value a... | 46,127 |
<p>I just joined a new C++ software project and I'm trying to understand the design. The project makes frequent use of unnamed namespaces. For example, something like this may occur in a class definition file:</p>
<pre><code>// newusertype.cc
namespace {
const int SIZE_OF_ARRAY_X;
const int SIZE_OF_ARRAY_Y;
bo... | <p>Unnamed namespaces are a utility to make an identifier <a href="https://stackoverflow.com/a/1106167/">translation unit</a> local. They behave as if you would choose a unique name per translation unit for a namespace:</p>
<pre><code>namespace unique { /* empty */ }
using namespace unique;
namespace unique { /* namesp... | <p>An anonymous namespace makes the enclosed variables, functions, classes, etc. available only inside that file. In your example it's a way to avoid global variables. There is no runtime or compile time performance difference.</p>
<p>There isn't so much an advantage or disadvantage aside from "do I want this variab... | 46,600 |
<p>I have a KMainWindow:</p>
<pre><code>//file.h
class MainWindow: public KMainWindow {
public:
MainWindow(QWidget *parent = 0);
...
...
...
private slots:
void removeClick();
//file.cpp
MainWindow::MainWindow(QWidget *parent) :
KMainWindow(parent) {}
void MainWindow::removeClick()
{
std::cout <... | <p>You forgot the Q_OBJECT macro.</p>
<pre><code>class MainWindow: public KMainWindow
{
Q_OBJECT
public:
// [snip]
}
</code></pre>
| <p>solved using KXmlGuiWindow instead of KMainWindow and the Q_OBJECT macro</p>
| 40,714 |
<p>I need to run a simple request/response python module under an
existing system with windows/apache/FastCGI.</p>
<p>All the FastCGI wrappers for python I tried work for Linux only
(they use socket.fromfd() and other such shticks).</p>
<p>Is there a wrapper that runs under windows?</p>
| <p>You might find it easier to ditch FastCGI altogether and just run a python webserver on a localhost port. Then just use mod_rewrite to map the apache urls to the internal webserver.</p>
<p>(I started offering FastCGI at my hosting company and to my surprise, nearly everyone ditched it in favor of just running their... | <p>I'd suggest <a href="http://www.modpython.org/" rel="nofollow noreferrer">mod_python</a> or <a href="http://code.google.com/p/modwsgi/" rel="nofollow noreferrer">mod_wsgi</a>.</p>
| 40,333 |
<p>I have some documentation written in OpenOffice, and I would like to include some of it as PDF files in the final build deliveries. I would like to do this with the automated build script.</p>
<p>Is there a way to create a PDF file from OpenOffice with a command line command?</p>
| <p><a href="http://www.artofsolving.com/opensource/jodconverter" rel="nofollow noreferrer">Art of Solving</a> has also a very good API to perform the conversion in Java. It is a little slow but it is simple enough. This is how I use it:</p>
<pre><code> File inputFile = new File("C:\\oreyes\\hola.doc");
... | <p>There is <a href="http://code.google.com/p/anytopdf/" rel="nofollow noreferrer">anytopdf</a>. Haven't tried it myself.</p>
<p>Quoting...</p>
<blockquote>
<p>anytopdf is a perl script that converts OpenOffice.org, Microsoft Office (Word DOC, Excel XLS), RTF, HTML, and other openoffice.org readable file formats to... | 46,325 |
<p>I have a method <code>fetchObjects(String)</code> that is expected to return an array of <code>Contract</code> business objects. The <code>className</code> parameter tells me what kind of business objects I should return (of course this doesn't make sense in this construed case because I already said I will return <... | <p>You may use the class as the parameter rather then the class name.</p>
<pre><code> static <T extends Contract> T[] buildArray(Class<T> clazz){
ArrayList<T> l=new ArrayList<T>();
return l.toArray((T[]) java.lang.reflect.Array.newInstance(clazz, l.size()));
}
</code></pre>
<p>E... | <p>So why not use </p>
<pre><code>static <T> T[] buildArray(Class<T> clazz){
ArrayList<T> l=new ArrayList<T>();
return l.toArray((T[]) java.lang.reflect.Array.newInstance(clazz, l.size()));
}
</code></pre>
<p>Note. Modified the code from above.</p>
| 49,925 |
<p>I'm trying to detect the size of the screen I'm starting emacs on, and adjust the size and position the window it is starting in (I guess that's the frame in emacs-speak) accordingly. I'm trying to set up my .emacs so that I always get a "reasonably-big" window with it's top-left corner near the top-left of my scree... | <p>If you want to change the size according to resolution you can do something like this (adjusting the preferred width and resolutions according to your specific needs):</p>
<pre><code>(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
;; use 120 char wide window for lar... | <pre><code>(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
;; use 120 char wide window for largeish displays
;; and smaller 80 column windows for smaller displays
;; pick whatever numbers make sense for you
(if (> (x-display-pixel-width) 1280)
... | 11,846 |
<p>Suppose I have a hash_map and a code like</p>
<pre><code>// i is an iterator
i = hash_map.erase(i)
</code></pre>
<p>But GCC's STL doesn't return iterator in erase, but a void. Now is a code like</p>
<pre><code>hash_map.erase(i++)
</code></pre>
<p>safe (i.e. does not invalidate the iterator or does any other unex... | <p>Yes, this is safe, because the value of <code>i</code> will have been set to the next value, before the current value is erased.</p>
<p>According to the <a href="http://www.sgi.com/tech/stl/HashedAssociativeContainer.html" rel="noreferrer">SGI documentation about hashed containers</a> invalidation does not occur fo... | <p>Hate to rain on the parade, but I don't think what you propose is safe.</p>
<p>i++ is the post-increment operator, which means i is incremented after the call to erase. But erase invalidates all iterators pointing to the element being erased. So by the time i is incremented it's not valid any more.</p>
<p>If you... | 26,786 |
<p>I am currently developing a .NET application, which consists of 20 projects. Some of those projects are compiled using .NET 3.5, some others are still .NET 2.0 projects (so far no problem).</p>
<p>The problem is that if I include an external component I always get the following warning:</p>
<blockquote>
<p>Found con... | <p>This warning means that two projects reference the same assembly (e.g. <code>System.Windows.Forms</code>) but the two projects require different versions. You have a few options:</p>
<ol>
<li><p>Recompile all projects to use the same versions (e.g. move all to .Net 3.5). This is the preferred option because all cod... | <p>This happened to me too. One dll was referenced twice: once directly (in references) and once indirectly (referenced by another referenced project).
I removed direct reference, cleaned & rebuilt solution. Problem fixed.</p>
| 3,840 |
<p>We are working with an oracle database in which the person that set it up is "long gone" and thus do not know the sysdba password, but need it. We have root access to the box (its on linux). Is there any way to recover or change the sys passwords?</p>
| <p>Have you tried logging into Linux as your installed Oracle user then</p>
<pre><code>sqlplus "/ as sysdba"
</code></pre>
<p>When you log in you'll be able to change your password.</p>
<pre><code>alter user sys identified by <new password>;
</code></pre>
<p>Good luck :)</p>
| <p>You can connect to the database locally using the combination of environment variables:</p>
<ul>
<li><strong>ORACLE_HOME</strong> </li>
<li><strong>ORACLE_SID</strong> .</li>
</ul>
<p>Depending on your <strong>OS</strong>:</p>
<p><strong>Unix/Linux:</strong></p>
<pre><code>export ORACLE_HOME=<oracle_home_dire... | 7,549 |
<p>Is it possible to write a GUI from inside a function?</p>
<p>The problem is that the callback of all GUI-functions are evaluated in the global workspace. But functions have their own workspace and can not access variables in the global workspace. Is it possible to make the GUI-functions use the workspace of the fun... | <p>There are a number of ways to <a href="https://www.mathworks.com/help/matlab/creating_guis/ways-to-build-matlab-guis.html" rel="nofollow noreferrer">build a GUI</a>, such as using the App Designer, GUIDE, or creating it programmatically (I'll illustrate this option below). It's also important to be aware of the <a h... | <p>You can declare a variable global in your function and global in the GUI code, certainly if the callback is in a separate function rather than inline. I've done this in a little skeleton GUI I use to make quick menu system.</p>
<p>In your code above you may be able to add the global keyword to your initial declarat... | 34,300 |
<p>My web application sends email fairly often, and it sends 3 kinds of emails: initiated by user, in response to an event in the system, and in automatic response to an email received by the application.</p>
<p>I would like to make sure that the third type of email does not get stuck in an endless loop of auto-respon... | <p><a href="http://www.faqs.org/rfcs/rfc2076.html" rel="noreferrer">RFC 2076</a> discourages the use of the precedence header. as you have noted, many clients will just filter that off (especially the precedence: junk variety). it may be better to use a null path to avoid auto responder wars:</p>
<pre><code>Return-Pat... | <p>How about configuring a white list on your email account?</p>
<p>I would assume that any email key words could get flagged by a junk filter.</p>
| 18,708 |
<p>I have a test environment for a database that I want to reload with new data at the start of a testing cycle. I am not interested in rebuilding the entire database- just simply "re-setting" the data. </p>
<p>What is the best way to remove all the data from all the tables using TSQL? Are there system stored procedur... | <p>For SQL 2005, </p>
<pre><code>EXEC sp_MSForEachTable 'TRUNCATE TABLE ?'
</code></pre>
<p>Couple more links for <a href="http://www.databasejournal.com/scripts/article.php/2226781" rel="noreferrer">2000</a> and <a href="http://www.keithrull.com/2007/09/07/HowToTruncateMultipleTablesInSQLServerAndTheMagicOfSpMSfo... | <p>I do not see why clearing data would be better than a script to drop and re-create each table.</p>
<p>That or keep a back up of your empty DB and restore it over old one</p>
| 18,772 |
<p>I'd like to write some (java) code that takes a PDF document, and creates named destinations from all of the bookmarks. I think the iText API is the easiest way of doing this, but I have never used the API before.</p>
<p>How would you go about writing this sort of code with the iText API? Can iText do the parsing ... | <p>I'll just warn you up front that you may be disappointed with this. iText isn't really intended to be used as a parser. It's really more for creating <em>entirely new</em> PDF documents, but you can take a whack at it.</p>
<p>To start, using iText, you won't be able to modify the existing PDF document. What you ... | <p>I'll just warn you up front that you may be disappointed with this. iText isn't really intended to be used as a parser. It's really more for creating <em>entirely new</em> PDF documents, but you can take a whack at it.</p>
<p>To start, using iText, you won't be able to modify the existing PDF document. What you ... | 20,903 |
<p>I'm trying to determine what situations MySQL updates an index. Say I have the following table:</p>
<pre><code>CREATE TABLE MyTable (
ID INT NOT NULL AUTO_INCREMENT,
MyIndexedColumn VARCHAR NOT NULL,
MyNonIndexedColumn VARCHAR,
PRIMARY KEY (ID),
INDEX MyNewIndex(MyIndexedColumn)
)
</code></pre>
<p>Then ... | <p>If you run that query in the MySQL client, you'll see something like </p>
<blockquote>
<p>Rows matches: 1, Rows Updated: 0</p>
</blockquote>
<p>So MySQL definitely knows when a row has changed or not - I'd assume from there that they're smart enough not to update the index from there.</p>
| <p>When you perform an UPDATE MySQL reports the number of rows matched and the number changed. Running your example query gives the output:</p>
<p>Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0</p>
<p>I would be very surprised if MySQL didn't then use that information to determine whet... | 36,074 |
<p>I'm doing some research for my end of degree project: a multiplattform application developed using .net3.5 and mono2.0 </p>
<p>I need some opinion about what you people think is the best Object Relational Mapping framework which will also run with mono.</p>
<p>Additionaly, any opinion about what ORM will work the ... | <p>NHibernate is by far the best choice
there are also very good tools out there, I recommend:
<a href="http://ayende.com/projects/nhibernate-query-analyzer.aspx" rel="nofollow noreferrer">NHibernate Analyzer</a></p>
| <p>NHibernate.</p>
<p>It will also be usefull when you decide to switch to Java.</p>
| 36,884 |
<p>Well I have a videos website and a few of its tables are:</p>
<p><strong>tags</strong></p>
<pre><code>id ~ int(11), auto-increment [PRIMARY KEY]
tag_name ~ varchar(255)
</code></pre>
<p><strong>videotags</strong></p>
<pre><code>tag_id ~ int(11) [PRIMARY KEY]
video_id ~ int(11) [PRIMARY KEY]
</code></pre>
<p><st... | <p><a href="https://stackoverflow.com/questions/346842/mysql-query-takes-15-seconds-to-run-what-can-i-do-to-cacheimprove-it-php#346851">MarkR</a> mentioned the index. Make sure you:</p>
<pre><code>create index videotags_tag_id on videotags(tag_id);
</code></pre>
| <p>I think your best bet is to create some kind of summary table which you maintain when things change.</p>
<p>The query above needs to scan all the rows in the table in order to find the aggregates in the group by - there is NO WHERE CLAUSE. A query with no where clause has no hope of optimisation, as it necessarily ... | 45,130 |
<p>Is there anyway in Java to delete data (e.g., a variable value, object) and be sure it can't be recovered from memory? Does assigning <code>null</code> to a variable in Java delete the value from memory? Any ideas? Answers applicable to other languages are also acceptable.</p>
| <p>Due to the wonders virtual memory, it is nearly impossible to delete something from memory in a completely irretrievable manner. Your best bet is to zero out the value fields; however: </p>
<ul>
<li>This does not mean that an old (unzeroed) copy of the object won't be left on an unused swap page, which could persis... | <p>Totally and completely irretrievable is something almost impossible in this day and age.
When you normally delete something, the onlything that happens is that the first spot in your memory is emptied. This first spot used to contain the information as to howfar the memory had to be reserved for that program or some... | 14,639 |
<p>I've inherited this really weird codebase where they've built an <strong>external</strong> web service over a bunch of <strong>internal</strong> web services just to add authentication/authorization using <em>WS-Security</em>, <em>WS-Encryption</em>, et al. Less than a month into this engagement, I'm already feeling... | <p>I saw that very thing being built one year ago. I almost cried when the team took months to build 4 web services, 2 of which simply wrapped other internal ones, using WCF and some serious encryption. The only reason they wrapped the internal ones was to change the potential error numbers coming back.</p>
<p>So, w... | <p>I have seen similar implementations if you are exposing the services to the outside world and if you need to tighten down the security..check this <a href="http://msdn.microsoft.com/en-us/magazine/cc793961.aspx" rel="nofollow noreferrer">MSDN column</a>..</p>
| 20,016 |
<p>Would it be possible to print <code>Hello</code> twice using single <code>condition</code>?</p>
<pre><code>if "condition"
printf ("Hello");
else
printf("World");
</code></pre>
| <pre><code>if ( printf("Hello") == 0 )
printf ("Hello");
else
printf ("World");
</code></pre>
<p>:-)</p>
| <p>The condition to this question is:</p>
<pre><code> if(printf("hello")? 0 : 1) { }
</code></pre>
| 5,318 |
<p>As a follow up to <a href="https://stackoverflow.com/questions/104224/how-do-you-troubleshoot-wpf-ui-problems">my previous question</a>, I am wondering how to use transparent windows correctly. If I have set my window to use transparency, the UI will occasionally appear to stop responding. What is actually happeni... | <p>Are you using .NET 3.0, or .NET 3.5 on Windows XP SP2? If so, this is a known problem with the transparent window API that has been fixed in .NET 3.5 and SP3 of XP (and I think SP1 of Vista). Basically when you set the AllowsTransparency to True, the WPF pipeline has to render in software only mode. This will cau... | <p>I am running on Windows XP Pro SP3 and using .NET 3.5 SP1. I have also verified that the project is targeting version 3.5 of the framework.</p>
| 14,952 |
<p>I am relatively new to Java, and often find that I need to sort a <code>Map<Key, Value></code> on the values.</p>
<p>Since the values are not unique, I find myself converting the <code>keySet</code> into an <code>array</code>, and sorting that array through <strong>array sort</strong> with a <strong>custom co... | <p>Here's a generic-friendly version:</p>
<pre><code>public class MapUtil {
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
List<Entry<K, V>> list = new ArrayList<>(map.entrySet());
list.sort(Entry.comparingByValue(... | <p>If your Map values implement Comparable (e.g. String), this should work</p>
<pre><code>Map<Object, String> map = new HashMap<Object, String>();
// Populate the Map
List<String> mapValues = new ArrayList<String>(map.values());
Collections.sort(mapValues);
</code></pre>
<p>If the map values t... | 13,467 |
<p>If I have data like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Key</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Dan</td>
</tr>
<tr>
<td>2</td>
<td>Tom</td>
</tr>
<tr>
<td>3</td>
<td>Jon</td>
</tr>
<tr>
<td>4</td>
<td>Tom</td>
</tr>
<tr>
<td>5</td>
<td>Sam</td>... | <p>Couldn't be simpler...</p>
<pre class="lang-sql prettyprint-override"><code>Select Name, Count(Name) As Count
From Table
Group By Name
Having Count(Name) > 1
Order By Count(Name) Desc
</code></pre>
<p>This could also be extended to delete duplicates:</p>
<pre class="lang-sql prettyprint-overri... | <p>This could also be accomplished by joining the table with itself,</p>
<pre><code>SELECT DISTINCT t1.name
FROM tbl t1
INNER JOIN tbl t2
ON t1.name = t2.name
WHERE t1.key != t2.key;
</code></pre>
| 2,537 |
<p>I'm trying to run powershell commands through a web interface (ASP.NET/C#) in order to create mailboxes/etc on Exchange 2007. When I run the page using Visual Studio (Cassini), the page loads up correctly. However, when I run it on IIS (v5.1), I get the error "unknown user name or bad password". The biggest problem ... | <p>Here is a class that I use to impersonate a user.</p>
<pre><code>using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace orr.... | <p>You might need a patch.</p>
<p>From: <a href="http://support.microsoft.com/kb/943937" rel="nofollow noreferrer">http://support.microsoft.com/kb/943937</a></p>
<blockquote>
<p><strong>An application cannot impersonate a
user and then run Windows PowerShell
commands in an Exchange Server 2007
environment</st... | 3,292 |
<p>I have an SQL Server 2005 server, and I'd like to run a .Net CLR stored procedure on it. However, I'd like to use .NET Framework 3.5.</p>
<p>If I try this right now, I get this error:</p>
<pre><code>Error: Assembly 'system.core, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089.' was not found in t... | <p>This might be a stupid question but... If system.core can't be found, do you have the framework 3.5 installed on the database server?</p>
| <p><a href="http://forums.microsoft.com/technet/showpost.aspx?postid=2639225&siteid=17" rel="nofollow noreferrer">This thread</a> might be helpful to you.</p>
| 43,519 |
<p>Is there a Windows equivalent of the Unix command, <em>nice</em>?</p>
<p>I'm specifically looking for something I can use at the command line, and <strong>not</strong> the "Set Priority" menu from the task manager.</p>
<p>My attempts at finding this on Google have been thwarted by those who can't come up with bett... | <p>If you want to set priority when launching a process you could use the built-in <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/start" rel="noreferrer">START</a> command:</p>
<pre class="lang-batch prettyprint-override"><code>START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SE... | <p>Maybe you want to consider using <a href="http://www.donationcoder.com/Software/Mouser/proctamer/index.html" rel="noreferrer">ProcessTamer</a> that "automatize" the process of downgrading or upgrading process priority based in your settings. </p>
<p>I've been using it for two years. It's very simple but really effe... | 2,619 |
<p>I am trying to locate an evil plugin that includes a stoneage version of a certain jar file. How do I do that ?</p>
| <p>also, mvn -X will spit out all kinds of info, i believe it includes dependency versions.</p>
| <p><code>mvn dependency:tree</code> - shows you a tree of all dependencies including transitive dependencies</p>
| 40,309 |
<p>If I open a connection to the server from firefox browser, and then I open a new tab within the same instance of browser to make a connection to the server, is it considered one session to server or considered as two diff sessions?</p>
| <p>It's the same session (you can easily test this out yourself).</p>
| <p>It seems to be the same session.
However, if I use diff user to login, both seems to be categorized under same session? Is this the correct behaviour?</p>
| 49,853 |
<p>I'm trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but this event never fires.</p>
<p>I'm using FireFox 2.0.0.16 / GreaseMonkey 0.8.20080609</p>
<p><a href="https://stackoverflow.com/questions/59205/enhancing-stackoverflow-user-experience">This</a> is the full scri... | <p>So I googled <a href="http://www.google.com/search?q=greasemonkey%20dom%20ready" rel="noreferrer">greasemonkey dom ready</a> and the <a href="http://www.sitepoint.com/article/beat-website-greasemonkey/" rel="noreferrer">first result</a> seemed to say that the greasemonkey script is actually running at "DOM ready" so... | <p>@Sam: yeah, I was trying the same:</p>
<pre><code>// ==UserScript==
// @name Stack Overflow highlight viewed questions
// @namespace *
// @include http://stackoverflow.com/questions
// @include http://stackoverflow.com/questions?*
// @include http://stackoverflow.com/questions
//... | 9,765 |
<p>I'm trying to get a postgres jdbc connection working in eclipse. It would be nice to use the Data Source Explorer, but for now I'm just trying to get a basic connection. What I have done so far is download the postgres JDBC connector. I then tried two different things. First, Preferences-> Data Management, I tried t... | <p>This is how I have made a connection: (I do not know if this is "best practice", but it works.)</p>
<p>Importing the driver:</p>
<ol>
<li>Right click on your project</li>
<li>Choose property</li>
<li>Choose <code>Java build path</code></li>
<li>Choose <code>Add external JARS..</code> and select the location to the... | <p>Here's one way to get PostgreSQL connectivity to your application:</p>
<ol>
<li>Get an instance of <code>org.postgresql.ds.PGSimpleDataSource</code></li>
<li>Setup it with values matching to your database (see methods below)</li>
<li>Proceed using the DataSource as you would use any other, I'd assume at this point ... | 24,362 |
<p>The new ASP.NET routing is great for simple path style URL's but if you want to use a url such as:</p>
<p><a href="http://example.com/items/search.xhtml?term=Text+to+find&page=2" rel="nofollow noreferrer">http://example.com/items/search.xhtml?term=Text+to+find&page=2</a></p>
<p>Do you have to use a catch a... | <p>Any view data items that are not listed in the route are automatically mapped to the querystring, so if you map "items/search.xhtml" to an action:</p>
<pre><code>Search(string term, int page)
</code></pre>
<p>Then you should get the results you are looking for.</p>
| <p>I was also having trouble passing an encoded URL to a route as a route parameter.</p>
<p>You can't use url encoded chars in a URL, but you can in a query string.</p>
<p>Therefore I needed my route to also have a query string element to it.</p>
<p>Say I have a route:</p>
<pre><code>MapPageRoute("myroute", "myrout... | 25,187 |
<p>I've got quite a few GreaseMonkey scripts that I wrote at my work which automatically log me into the internal sites we have here. I've managed to write a script for nearly each one of these sites except for our time sheet application, which uses HTTP authentication. </p>
<p>Is there a way I can use GreaseMonkey ... | <p>It is possible to log in using HTTP authentication by setting the "Authorization" HTTP header, with the value of this header set to the string "basic username:password", but with the "username:password" portion of the string Base 64 encoded. </p>
<p><a href="http://frontier.userland.com/stories/storyReader$2159" r... | <p>"<a href="http://username:password@host/" rel="nofollow noreferrer">http://username:password@host/</a>" doesn't work on IE, FireFox works ok.</p>
| 7,160 |
<p>Are there any what in the Java community would be called "application servers" for .NET? Similar to Tomcat, Resin, and Jetty. I'm not interested in a JSP equivalent, I'm looking for a servlet-based technology for XML/HTTP transaction processing (no UI).</p>
<p>If there is not a product like this, what would a good ... | <p><a href="http://msdn.microsoft.com/en-us/netframework/aa663324.aspx" rel="nofollow noreferrer">WCF</a> or web services (ASMX) both seem like good candidates for what you want. WCF is probably more appropriate if you don't want to go the full SOAP route. You can host WCF in IIS, a console app, or a windows service.... | <blockquote>
<p>I'm not interested in a JSP equivalent, I'm looking for a servlet-based technology for XML/HTTP transaction processing (no UI).</p>
</blockquote>
<p>Sounds like what I do all the time. I use WCF for communication and host the program as a Windows Service. Windows Services have lots of nice things lik... | 44,761 |
<p>Does anyone know if the problems that have been affecting Stack Overflow with regards to SQL Server 2008 Full Text Search performance have implications for the search in SharePoint? As far as I understand it SharePoint search uses SQL Server full text search.</p>
| <p>SharePoint 2007 has its own search database, to store items such as search scopes and other things.
The actual search index does not use full text search, but stores it's information inside a file based index.</p>
<p>So any search queries run on SharePoint will not cause the issue.</p>
<p>Search crawling of a site... | <p>I'm not aware of any problem with SQL Server under 2008, but <strong>I'm sure it won't affect SharePoint 2007</strong>.<br>
Since 2007, SharePoint search no longer user SQL Search.</p>
<p>If you're running SharePoint 2003, I'm not sure SQL 2008 is supported.</p>
| 36,751 |
<p>The following program is very simple: it outputs a single dot each half a second. If it recieves a <strong>SIGQUIT</strong>, it proceeds to output ten <strong>Q</strong>s. If it recieves a <strong>SIGTSTP</strong> <em>(<kbd>Ctrl</kbd>-<kbd>Z</kbd>)</em>, it outputs ten <strong>Z</strong>s.</p>
<p>If it recieves a <s... | <p>Your larger problem is blocking in signal handlers.</p>
<p>This is usually discouraged since it can lead to strange timing conditions. But it's not quite the cause of your problem since the timing condition you're vulnerable to exists because of your choice of signal handlers.</p>
<p>Anyway, here's how to at leas... | <p>On Python 2.5.2 on Linux 2.6.24, your code works exactly as you describe your desired results (if a signal is received while still processing a previous signal, the new signal is processed immediately after the first one is finished).</p>
<p>On Python 2.4.4 on Linux 2.6.16, I see the problem behavior you describe.<... | 13,491 |
<p>How do you update this? I've never seen any current team that actually "checks out" a file. I don't compile, either. These seem to be from before the days of branching.</p>
<ol>
<li>You shall check in early and check
in often. You anger your coworkers
when you check out a file and insist
on keeping it checked out u... | <p><a href="http://martinfowler.com/articles/continuousIntegration.html" rel="noreferrer">Continuous Integration</a>.</p>
<ol>
<li>Maintain a Single Source Repository</li>
<li>Automate the Build</li>
<li>Make Your Build Self-Testing</li>
<li>Everyone Commits Every Day</li>
<li>Every Commit Should Build the Mainline on... | <p><em>You shall not go home for the day with files checked out, nor shall you depart for the weekend or for a vacation, with files checked out.</em></p>
<p><em>You shall use the 'Undo Checkout' option if you check out a file and do not make any changes. It displeases your coworkers when you check in code that has not... | 37,271 |
<p>How would you manually trigger additional team builds from a team build? For example, when we were in CC.Net other builds would trigger if certain builds were successful. The second build could either be projects that use this component or additional, long running test libraries for the same component. </p>
| <p>One way you could do it is you could an an AfterEndToEndIteration target to your TFSBuild.proj file that would runs the TfsBuild.exe command line to start you other builds. I'm thinking something like this (though I haven't tested it)</p>
<pre><code> <Target Name="AfterEndToEndIteration">
<GetBuildP... | <p>I've done the same thing Martin suggested on a number of occasions (his blog is beyond helpful, BTW). However, I ended up needing to trigger cascading builds like this (based on some other complicated rules) enough that I created a custom task to do it. Keep your build scripts nice and lean and gives you some more... | 23,228 |
<p>I'm using membership and roles for authentication in my vb .net application. We have about 5 roles in the application with certain roles filling out a specific profile value. Example is the role is store and the profile value is store number. Obviously if you work for headquarters you don't have a store number so I ... | <p>This is really the sort of thing you want to filter on in SQL. I don't think there is any trick to get around doing a linear scan of your data and get the results you want.</p>
<p>If doing this in SQL isn't an option then maybe you can avoid creating a second list and just sort your main user array and have the dis... | <p>You're using the built-in .NET role manager that saves to a SQL Server instance I take it? What format are your user object in when you're currently looking at them to evaluate the criteria? If you post a code sample I have an idea...</p>
| 10,133 |
<p>If you had a differential of either venturing into Delphi land or Qt land which would you choose? I know they are not totally comparable. I for one have Windows development experience with Builder C++ (almost Delphi) and MFC (almost Qt), with a bit more time working with Builder C++. Please take out the cross platfo... | <p>If you are talking UI frameworks, then you should be comparing Qt with the VCL, not the IDE (Delphi in this case). I know I'm being a stickler, but Delphi is the IDE, Object-Pascal is the language, and VCL is the graphical framework.</p>
<p>That being said, I don't think there is anything that even comes close to m... | <p>I'd choose delphi. Only because I have more experience with it. I don't think that there is other reasonabl criterias. </p>
| 9,841 |
<p>I have a PLA 3D-printed object made of several rings with a diameter of 150 mm and a thickness of 6 mm. The height of each ring is about 30-35 mm but it does not matter so much.</p>
<p>I'm looking for a way to keep the rings together (one on top of another). I cannot place anything inside the ring (like a thicker ar... | <h2>[Extruder] feed rate [modifier] is used synonymous to extrusion multiplier</h2>
<p>The feed rate of the extruder is the rate at which filament is pushed (fed) into the hotend. An overwrite value that modifies that rate from the normal rate is in most slicers called "extrusion multiplier".</p>
<p>It is a <... | <p>In the context of the linked source (in German <em>"Die Feeding Rate sollte mit 105 % eingestellt werden"</em>), with <em>"a feeding rate of 105 %"</em> is meant the extrusion multiplier (there is no reference in the source to Cura). This is explained in <a href="https://3dprinting.stackexchange.... | 2,212 |
<p>I'm building a with-source system which I am giving out on the 'net for providing adoptable virtual pets. The system will be owned mainly by kids. Since I want it to be usable for absolute beginner programmers, there are several complexity constraints on my system: It can't use libraries that don't commonly ship wit... | <p>If you are expecting a relatively low sophistication level, then you can do a very simple "xor" encryption and "store" the key as part of the URL. Then you can just use php's rand() or /dev/random or whatever to generate keys.</p>
<p>Low-sophistication users won't readily figure out that all they need to do is xor... | <p>Why not just give each user a long, random ID and then store all the details about their pet on the server? Best practice is not to store anything in the URL, encrypted or not. All you should need is a session ID.</p>
| 42,380 |
<p>I build VBA applications for both Word and Excel, is there any way to access the progress bar that sometimes appears in the Office status bar.</p>
| <p>The following will simulate a progress bar in Excel's status bar:</p>
<pre><code>Public Sub UpdateStatusBar(percent As Double, Optional Message As String = "")
Const maxBars As Long = 20
Const before As String = "["
Const after As String = "]"
Dim bar As String
Dim notBar As String
Dim num... | <p>I have not accessed the progress bar, but I have in the past used something like this to place task status text in the status bar...</p>
<pre><code>Sub StatusBarExample()
Application.ScreenUpdating = False
' turns off screen updating
Application.DisplayStatusBar = True
' makes sure that the status... | 26,769 |
<p>The default behavior of NHibernate is the write all changes to objects to the database when Session.Flush() is called. It does this whether you want it to or not.</p>
<p>How do we prevent writing bad data to the database when we need to do things like validate business rules or input?</p>
<p>For instance .. </p>
... | <p>Specifically for ActiveRecord: if you don't change the SessionScope yourself, AR defaults to a session management pattern of session-per-call, where a new session is created for every operation of ActiveRecordMediator. Thus all objects you retrieve are already disconnected from their parent session once you retrieve... | <p>You can also use a Session with FlushAction.Never. Ie:</p>
<pre><code>SessionScope session = new SessionScope(FlushAction.Never);
</code></pre>
<p>This will switch the default behaviour from automatically saving everything to you explicitly needing to call .Save() on your entities. So you can do whatever validatio... | 39,980 |
<p>I'd like to unit test responses from the Google App Engine webapp.WSGIApplication, for example request the url '/' and test that the responses status code is 200, using <a href="http://code.google.com/p/gaeunit" rel="noreferrer">GAEUnit</a>. How can I do this? </p>
<p>I'd like to use the webapp framework and GAEUni... | <p>I have added a <a href="http://code.google.com/p/gaeunit/source/browse/#svn/trunk/sample_app" rel="noreferrer">sample application</a> to the GAEUnit project which demonstrates how to write and execute a web test using GAEUnit. The sample includes a slightly modified version of the '<a href="http://pythonpaste.org/w... | <p>Actually WebTest does work within the sandbox, as long as you comment out </p>
<pre><code>import webbrowser
</code></pre>
<p>in webtest/__init__.py </p>
| 13,310 |
<p>I have been attempting to get my Anet to print for a couple months now. Haven't had a huge amount of time but when I have I've worked on it. A lot of the problems I have had I have been able to trouble shoot, for example for a while I was unable to get any filament to lay, and I have since fixed this issue. Now howe... | <p>The skirt <em>looks</em> ok, which tends to rule out the most extreme flow or blockage issues. However, skirt/bottom layer can be over-squashed so not ideal for calibration.</p>
<p>I assume this is intended to be a 100% layer rather than infill. It looks like you're achieving about 50% infill, which is a good clue.... | <p>I had similar issues with my A8 at first. If it <em>did</em> work fine and now it does not, then it is not a firmware issue. My issues were resolved when I got a <em>new</em> nozzle. If the tip is worn out or squished from crashing into the bed, no amount of cleaning is going to solve it. Also the filament it came w... | 1,322 |
<p>I am trying to add a timed delay in a C++ program, and was wondering if anyone has any suggestions on what I can try or information I can look at?</p>
<p>I wish I had more details on how I am implementing this timed delay, but until I have more information on how to add a timed delay I am not sure on how I should e... | <p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx" rel="noreferrer">In Win32</a>:</p>
<pre><code>#include<windows.h>
Sleep(milliseconds);
</code></pre>
<p><a href="http://linux.die.net/man/3/usleep" rel="noreferrer">In Unix</a>:</p>
<pre><code>#include<unistd.h>
uns... | <p>Syntax:</p>
<p>void sleep(unsigned seconds);</p>
<p>sleep() suspends execution for an interval (seconds).
With a call to sleep, the current program is suspended from execution for the number of seconds specified by the argument seconds. The interval is accurate only to the nearest hundredth of a second or to the a... | 19,185 |
<p>I have few different applications among which I'd like to share a C# enum. I can't quite figure out how to share an enum declaration between a regular application and a WCF service. </p>
<p>Here's the situation. I have 2 lightweight C# destop apps and a WCF webservice that all need to share enum values. </p>
<p>Cl... | <p>Using the Common library should be fine. Enumerations are serializable and the DataContract attributes are not needed. </p>
<p>See:
<a href="http://msdn.microsoft.com/en-us/library/ms731923.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms731923.aspx</a></p>
<blockquote>
<p>Enumeration types. Enu... | <p>you could assign int values to your Enum members and just use int's for transfer and when necessary cast them back into your Enum type</p>
| 22,708 |
<p>Several times now I've had Eclipse delete files for me seemingly randomly - then they appear under the 'Local History' option.</p>
<p>What is going on! I'm definitely not just deleting things by mistake. </p>
<p>Most recently it deleted my template files under <code>html-template</code> which are quite important!<... | <p>Under Local History you can find the previous versions of your files, after you modified it.</p>
<p>Didn't you set this folder as the output folder for compiling? Then eclipse could clear the files during build.</p>
| <p>I suspect it is an external application that is deleting or moving your files. Eclipse's local history simply keeps of copy of your files for quick reverting later.</p>
| 22,423 |
<p>I am trying to generate equivalent MD5 hashes in both JavaScript and .Net. Not having done either, I decided to use against a third party calculation - this <a href="http://www.johnmaguire.us/tools/hashcalc/index.php?strtohash=password&mode=hash" rel="nofollow noreferrer">web site</a> for the word "password". ... | <p>Running the code from the MSDN site you quote:</p>
<pre><code> // Hash an input string and return the hash as
// a 32 character hexadecimal string.
static string getMd5Hash(string input)
{
// Create a new instance of the MD5CryptoServiceProvider object.
MD5 md5Hasher = MD5.Create... | <p>I get the same value as that web site for the word "password":</p>
<pre><code>$ echo -n password | md5
5f4dcc3b5aa765d61d8327deb882cf99
</code></pre>
<p>Without seeing the code you are actually using, it's hard to tell what might be going wrong.</p>
<p>As for storing hashes in a database, I store them as a hex st... | 23,078 |
<p>I often marvel at how I can go to www.google.com, from anywhere in the world at any time, and get the returned page so fast.</p>
<p>Sure, they compress their output and keep to a minimal design - that helps.</p>
<p>But they must have <em>millions</em> of simultaneous hits to the box sitting on the web that DNS lis... | <p>google.com, update.microsoft.com, and other services which handle astonishingly high aggregate bandwidth do much of their magic via DNS.</p>
<p>BGP Anycast routing is used to announce the IP address of their DNS servers from multiple points around the world. Each DNS server is configured to resolve google.com to IP... | <p>This is normal internet traffic handling. Google literally has entire data centers all over the planet that respond to www.google.com</p>
| 25,896 |
<p>First off, I apologize if this doesn't make sense. I'm new to XHTML, CSS and JavaScript.</p>
<p>I gather that in XHTML, the correct way to have a nested page is as follows (instead of an iframe):</p>
<pre><code><object name="nestedPage" data="http://abc.com/page.html" type="text/html"
width="500" height="400" ... | <pre><code>d = document.getElementsByTagName('object').namedItem('nestedPage').getContentDocument();
d.styleSheets[d.styleSheets.length].href = 'whereever';
</code></pre>
<p>WARNING: hasn't been tested in all browsers.</p>
| <p>If the nested page is outside your domain, cross-domain restrictions will prevent you from fiddling with its stylesheet/html, I'm afraid.</p>
| 42,664 |
<p>I'm trying to collect wifi Bssid and Rssi information on Windows, and am looking for the most reliable way to do that across as many versions of Windows as possible. With Vista it's easy using Win32 calls with the Wireless LAN API. That API exists on XP SP2 (sometimes) and SP3, but as far as I can tell it doesn't su... | <p>Well, you can't get that information(from my understanding) from windows. I comes from the router itself. But Wireshark and nmap would be my guess.</p>
| <p>That's not correct, Windows provides the possibility to get these information. The bad news: there is not ONE such way but different APIs and Interfaces which have to be used depending on the operating system.</p>
<p>But you do not have to re-invent the wheel, the libwlocate already contains the functions you are l... | 22,333 |
<p>Is there a way to use .NET reflection to capture the values of all parameters/local variables?</p>
| <p>You could get at this information using the <a href="http://msdn.microsoft.com/en-us/library/bb384548.aspx" rel="nofollow noreferrer">CLR debugging API</a> though it won't be a simple couple of lines to extract it.</p>
| <p>I dont think this is possible, you can get the method and its parameters by looking at the StackTrace. </p>
<pre><code>System.Diagnostics.StackTrace sTrace = new System.Diagnostics.StackTrace(true);
for (Int32 frameCount = 0; frameCount < sTrace.FrameCount; frameCount++){
System.Diagnostics.StackFrame sFr... | 20,329 |
<p>Using only ANSI C, what is the best way to, with fair certainty, determine if a C style string is either a integer or a real number (i.e float/double)?</p>
| <p>Don't use atoi and atof as these functions return 0 on failure. Last time I checked 0 is a valid integer and float, therefore no use for determining type.</p>
<p>use the strto{l,ul,ull,ll,d} functions, as these set errno on failure, and also report where the converted data ended.</p>
<p>strtoul: <a href="http://ww... | <p>Well, if you don't feel like using a new function like strtoul, you could just add another strcmp statement to see if the string is 0.</p>
<p>i.e.</p>
<pre><code>if(atof(token) != NULL || strcmp(token, "0") == 0)
</code></pre>
| 10,392 |
<p>I need some help for executing my planned backup strategy.</p>
<p>My database is about 1 gig in size.
I want to perform a full backup once per week, and incremental every hour.</p>
<p>Is all of this built into SQL Server 2005 Express?</p>
<p>Is it possible to roll over the backups so I only keep 1 months of backu... | <p>You can do it, it's just harder.</p>
<p>You don't have maintenence plans, but that doesn't matter becuase they often cause more headaches than they solve. You will want to script the backup yourself.</p>
<p>The other issue is you won't have the SQL Server Agent, which is used for scheduling your scripts. You can... | <p>SQL Server express does not have the ability to setup maintenance plans, therefore you must manually execute the scripts. AFAIK.</p>
<p>With all other editions, a simple DB Maint. plan can be setup to do all of this, and it will even walk you through the process.</p>
| 28,941 |
<p>How do I manipulate images at the pixel level in C#?</p>
<p>I need to be able to read/modify each bitmap pixel RGB values separately. </p>
<p>A code sample would be appreciated.</p>
| <p>If you want speed, then <a href="http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx" rel="noreferrer">LockBits</a>. <strike>See here for a good walkthrough by Bob Powell</strike>. If you just want to edit a few, then <a href="http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.getp... | <p>If performance is critical, another alternative to LockBits is managed DirectX.</p>
<p>See the earlier Stack Overflow question <em><a href="https://stackoverflow.com/questions/58230/rendering-graphics-in-c#58242">Rendering graphics in C#</a></em> for more information.</p>
<p>Like Lockbits you will need to use the ... | 23,104 |
<p>I am trying to modify the below program to ensure each msg is converted to utf-8 using Encode::decode(), but I am unsure of how and where to place this to make it work.</p>
<pre><code>#!/usr/bin/perl
use warnings;
use strict;
use Mail::Box::Manager;
open (MYFILE, '>>data.txt');
binmode(MYFILE, ':encoding(UT... | <p>Here is a small example that shows the usefulness of the Action delegate</p>
<pre><code>using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
Action<String> print = new Action<String>(Program.Print);
List<String> names = new List<String&g... | <p>I used it as a callback in an event handler. When I raise the event, I pass in a method taking a string a parameter. This is what the raising of the event looks like:</p>
<pre><code>SpecialRequest(this,
new BalieEventArgs
{
Message = "A Message",
Action = UpdateMethod,
... | 48,489 |
<p>I have a user that keeps getting this error. Is there a tool that does window handle counting that i can use to figure out why he keeps getting this error.</p>
<p>System.ComponentModel.Win32Exception: Error creating window handle.
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.W... | <p>The best counter I know is Taskmgr.exe. View + Select Columns and check "User objects", "Handle count" and "GDI Objects".</p>
<p>The generic diagnostic is that you're leaking handles and consumed 10,000 of them. Beware of a handle leak bug in .NET 2.0 SP1 and .NET 3.5's Graphics.CopyFromScreen(), fixed in 3.5 SP... | <p>Maybe this could help:</p>
<p><a href="http://www.aboutmydot.net/index.php/unhandled-exception-win32exceptionerror-creating-window-handle" rel="nofollow noreferrer">Unhandled exception Win32Exception,Error creating window handle</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/7zxbks7z(VS.80).aspx" rel=... | 35,484 |
<p>Being primarily a C++ developer the absence of <a href="http://en.wikipedia.org/wiki/Resource_acquisition_is_initialization" rel="noreferrer">RAII (Resource Acquisition Is Initialization)</a> in Java and .NET has always bothered me. The fact that the onus of cleaning up is moved from the class writer to its consumer... | <p>A better title would be "Why is there no RAII in C#/VB". C++/CLI (The evolution of the abortion that was Managed C++) has RAII in the exact same sense as C++. It's all just syntax sugar for the same finalisation pattern that the rest of the CLI languages use (Destructors in managed objects for C++/CLI are effectivel... | <p>You can do a form of RAII in .net and java using finalize() methods. A finalize() overload is called before the class is cleaned up by the GC and so can be used to clean up any resources that absolutely shouldn't be kept by the class (mutexes, sockets, file handles, etc). It still isn't deterministic though. </p>
<... | 20,926 |
<p>I have the following javascript code, which loads without error, however the update function does not actually seem functional, as get_Records.php is never loaded. I can not test if get_auction.php is loaded as it is loaded from within get_records.php</p>
<p><strong>One of my main concerns</strong> is that I am doi... | <p>If you can use Firefox and reproduce the error, I would strongly suggest using <a href="http://getfirebug.com/" rel="nofollow noreferrer">Firebug</a> as it's really easy to use and step through scripts, set breakpoints, etc. Plus instead of having to use "alert" statements you can use things like <code>console.info(... | <p>Have you verified that the PHP code returns something sensible? (I assume, that you can view the source code of your html.)</p>
<p>Use good ol' alert-debugging: Insert alert statements (e.g. <code>windows.alert("GetXmlHttpObject started.");</code>) in your code to make sure that you reach them.</p>
<p><a href="htt... | 46,866 |
<p>I'm trying to integrate against a SOAP web service, running on Apache Axis. The WSDL specifies a namespace with a URI, that looks like:</p>
<pre><code><xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:stns="java:dk.tdc.serviceproviderweb.datatypes"
elementFormDefault="qualified"
attributeFor... | <p>Your snippet is the beginning of an XML schema that defines the contents of the "java:dk.tdc.serviceproviderweb.datatypes" namespace. (The targetNamespace attribute indicates this).</p>
<p>So it shouldn't matter if you're handling this with java or PHP on the client side,
as long as the rest of this schema is vali... | <p>Your snippet is the beginning of an XML schema that defines the contents of the "java:dk.tdc.serviceproviderweb.datatypes" namespace. (The targetNamespace attribute indicates this).</p>
<p>So it shouldn't matter if you're handling this with java or PHP on the client side,
as long as the rest of this schema is vali... | 30,125 |
<p>What is the cause of this exception in ASP.NET? Obviously it is a viewstate exception, but I can't reproduce the error on the page that is throwing the exception (a simple two TextBox form with a button and navigation links).</p>
<p>FWIW, I'm not running a web farm.</p>
<h2>Exception</h2>
<blockquote>
<p>Error... | <p>The most likely cause of this error is when a postback is stopped before all the viewstate loads (the user hits the stop or back buttons), the viewstate will fail to validate and throw the error. </p>
<p>Other potential causes:</p>
<ul>
<li>An application pool recycling between the time the viewstate was generated... | <p>Not sure if this would help anyone, but my solution was the exclusion of the machineKey in my webconfig for my cookie to get passed.</p>
| 16,973 |
<p>I've been trying to preserve the state of my iPhone application by serializing my main <code>UITabBarController</code> using <code>[NSKeyedArchiver archiveRootObject:toFile:]</code>, but I'm running into difficulties.</p>
<p>First I had a problem with <code>UIImage</code>, since it doesn't implement the <code>NSCod... | <p>The attributes on a @property have little or nothing to do with archiving behavior (they only describe how getters and setters work).</p>
<p>Also, just because UI classes support NSCoding, doesn't mean that it can be used to reconstruct state. Most of the time, they support NSCoding so that they can be constructed ... | <p>I was never able to get this approach to work either. What i eneded with was having my own protocol, and having each viewcontroller to be to save/restore the metadata needed for that view (you don't need to save the image data for example, just the name of the image). Once you have that, its fairly easy to write som... | 42,694 |
<p>I've had a <em>serious</em> issue with my Visual Studio 2008 setup. I receive the ever-so-useful error 'A problem has been encountered while loading the setup components. Canceling setup.' whenever I try to uninstall, reinstall or repair Visual Studio 2008 (team system version). If I can't resolve this issue I have ... | <p>A colleague found this <a href="http://go.microsoft.com/fwlink/?LinkId=105801" rel="noreferrer">MS auto-uninstall tool</a> which has successfully uninstalled VS2008 for me and saved me hours of work!!</p>
<p>Hopefully this might be useful to others. Doesn't speak highly of MS's faith in their usual VS maintenance t... | <p>Solution to this is </p>
<p><a href="http://www.dotnetzone.gr/cs/forums/48758/ShowThread.aspx#48758" rel="nofollow noreferrer">http://www.dotnetzone.gr/cs/forums/48758/ShowThread.aspx#48758</a></p>
| 13,968 |
<p>I've been using Git on Linux for about a year, and everything works fine. Since recently, a colleague has joined development and he's using Windows. Everything works fine there as well, but sometimes when he tries to push changes to a remote repository (bare) on Linux server it bails out with 'Invalid file descripto... | <p>Maybe you have problem with your anti virus. I had the same problem on my machine, I was(still) use nod32, just disable thread protection module IMON, that could fix the problem.</p>
| <p>git on Win32 is known to be iffy. Have you tried the <a href="http://code.google.com/p/msysgit/downloads/list" rel="nofollow noreferrer">latest msysgit</a>? It's a port of 1.6.0.2 (released September 23rd.) Also, is there any way you could get a more verbose / trace output from the failing git command?</p>
| 14,861 |
<p>I am using gravatar to load avatars for each user that posts a story on a page. I also am using jquery to round the corners of some span elements on the page. Unfortunately, it looks like grabbing the avatars from gravatar occurs before the jquery effects are applied (Without the gravatar code the elements are immed... | <p>I suppose you're loading gravatars using urls, not ajax etc.
document.ready() will execute when the DOM is loaded, not necessarily when all (gravatar) images are loaded. You might try to use window.onload event in your case.</p>
| <p>It sounds as though your gravatar loading script is executing before the appearance-modifying jQuery calls. Is there any way you can manually call the gravatar load? If so, you can use jQuery's document.ready to call your cosmetic changes first, then call the gravatar load. This way, you won't be waiting for the ... | 41,367 |
<p>I want to know how to use variables for objects and function names in Python. In PHP, you can do this:</p>
<pre><code>$className = "MyClass";
$newObject = new $className();
</code></pre>
<p>How do you do this sort of thing in Python? Or, am I totally not appreciating some fundamental difference with Python, and i... | <p>In Python,</p>
<pre><code>className = MyClass
newObject = className()
</code></pre>
<p>The first line makes the variable <code>className</code> refer to the same thing as <code>MyClass</code>. Then the next line calls the <code>MyClass</code> constructor through the <code>className</code> variable.</p>
<p>As a co... | <p>I prefer using dictionary to store the class to string mapping.</p>
<pre><code>>>> class AB:
... def __init__(self, tt):
... print(tt, "from class AB")
...
>>> class BC:
... def __init__(self, tt):
... print(tt, "from class BC")
...
>>> x = { "ab"... | 27,609 |
<p>Simple question, and probably reflects my inexperience with CSS, but...</p>
<p>When creating a style sheet I like to explicitly specify the '*' wild card, so:</p>
<pre><code>*.TitleText {
</code></pre>
<p>instead of just</p>
<pre><code>.TitleText {
</code></pre>
<p>I find it reminds me that TitleText is applied... | <p>I don't know whether it's good or bad, but I've been doing CSS work as part of web app development for several years and I've <em>never</em> seen anyone use the * character.</p>
| <p>EDIT: This is pointing out that there could well be a performance issue. Some people seemed to think I was some sort on way out there rant...</p>
<hr>
<p>While I don't know for certain, I'd like to give a word of warning! Consider the following identifier:</p>
<pre><code>div#foo a.bar {}
</code></pre>
<p>I hear ... | 49,251 |
<p>I just need a file (picture, pdf or other type file for printing) of the framework structure.
It is very usefull while learning .Net framework.</p>
| <p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7b645f3a-6d22-4548-a0d8-c2a27e1917f8&displaylang=en" rel="noreferrer">.NET Framework 3.5 Common Namespaces and Types Poster</a></p>
<blockquote>
<p>November 2007 Edition The .NET<br>
Framework 3.5 Common Namespaces and
Types Poster</p>
... | <p>I'm looking at one (and several others) right behind me at the moment, apparently it comes with Visual C#/Studio.</p>
| 19,003 |
<p>I have the following javascript:</p>
<pre><code>$.ajax({
type: "POST",
dataType: "json",
url: "/Home/Submit",
data: {
email: strEmail,
message: strMessage
},
success: function(result) {
//alert('here');
alert(result.message);
},
error: function(error) {
alert(error);
}
});
</co... | <p><code>Predicate<T></code> is a delegate type. You can never derive from delegates.</p>
<p>To be honest, it doesn't sound like inheritance is really appropriate here anyway - just write a method which returns an inverse of the original. It's as simple as this:</p>
<pre><code>public static Predicate<T> I... | <p>Predicate is a delegate. You can not inherit from a delegate type.
If you want to get the inverted value, use the following:</p>
<pre><code>Predicate<T> p;
Predicate<T> inverted = t => !p(t);
</code></pre>
| 26,444 |
<p>Attempting to print out a list of values from 2 different variables that are aligned correctly.</p>
<pre><code>foreach finalList ($correctList $wrongList)
printf "%20s%s\n" $finalList
end
</code></pre>
<p>This prints them out an they are aligned, but it's one after another. How would I have it go through each ite... | <p>You can iterate over both lists at the same time like this:</p>
<pre><code># Get the max index of the smallest list
set maxIndex = $#correctList
if ( $#wrongList < $#correctList ) then
set maxIndex = $#wrongList
endif
set index = 1
while ($index <= $maxIndex)
printf "%-20s %s\n" "$correctList[$index]" "$... | <p>try getting rid of the \n</p>
| 33,524 |
<p>I work in C#, and I've been pretty lax about using <code>using</code> blocks to declare objects that implement <code>IDisposable</code>, which you're apparently always supposed to do. However, I don't see an easy way of knowing when I'm slipping up. Visual Studio doesn't seem to indicate this in any way (am I just... | <p>FxCop <em>might</em> help (although it didn't spot a test I just fired at it); but yes: you are meant to check. <code>IDisposable</code> is simply such an important part of the system that you need to get into this habit. Using intellisense to look for <code>.D</code> is a good start (though not perfect).</p>
<p>Ho... | <p>I'm not getting the point of your question. Thanks to the garbage collector, memory leaks are close to impossible to occur. However, you need some robust logic.</p>
<p>I use to create <code>IDisposable</code> classes like this:</p>
<pre><code>public MyClass: IDisposable
{
private bool _disposed = false;
... | 31,809 |
<p>I am trying to set attributes for an IFRAME html control from the code-behind aspx.cs file.</p>
<p>I came across a <a href="https://web.archive.org/web/20210128094503/http://geekswithblogs.net/ranganh/archive/2005/04/25/37635.aspx" rel="nofollow noreferrer">post</a> that says you can use FindControl to find the non-... | <p>If the iframe is directly on the page where the code is running, you should be able to reference it directly:</p>
<pre><code>
contentPanel1.Attribute = value;
</code></pre>
<p>If not (it's in a child control, or the MasterPage), you'll need a good idea of the hierarchy of the page... Or use the brute-force method... | <p>aspx page</p>
<pre><code><iframe id="fblikes" runat="server"></iframe>
</code></pre>
<p>Code behind</p>
<p>this.fblikes.Attributes["src"] = "/productdetails/fblike.ashx";</p>
<p>Very simple....</p>
| 20,316 |
<p>In the iPhone 2.x firmware, can you make the iPhone vibrate for durations other than the system-defined:</p>
<pre><code>AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
</code></pre>
<p>In jailbroken phones, you used to be able to use the MeCCA.framework to do this:</p>
<p><a href="http://pastie.org/94481" r... | <p>Yes, this is something that has caused AppStore rejections in the past, and probably will again...which means it is still possible to do it.</p>
<p>Answering my own question, here's how to do it:</p>
<p>Add framework CoreTelephony in Build Phases. </p>
<p>declare:</p>
<pre><code>extern void * _CTServerConnection... | <p>iOS 5 has implemented Custom Vibrations mode. So in some cases variable vibration is acceptable. The only thing is unknown what library deals with that (pretty sure not CoreTelephony) and if it is open for developers.</p>
| 33,323 |
<p>When running the following code it leaves out one row. When I do a files.Count it says there are 4 rows but there is no data stored for the 4th row. When I run the stored procedure from within SQL Manager it returns all 4 rows and all the data. Any help?</p>
<pre><code> List<File> files = new List&... | <p>If you are saying your files collection has 4 items, but the 4 item contains no value, what do you mean by that? Is it null, does the object have no data, or does it throw an index out of range exception?</p>
<p>Are you doing a files[4] or something like the following?</p>
<pre><code>for(int x = 1; x < files.le... | <p>Have you tried stepping through this in a debugger, and checking your command params before you exec the reader? Do you get the same values in the result set as when you run the sproc direct on sql?</p>
<p>I could be wrong, cos there are a few ways of doing this, but something looks a little screwy in the way you a... | 39,121 |
<p>I've got a c# application that plays simple wav files through directsound. With the test data I had, the code worked fine. However when I used real-world data, it produced a very unhelpful error on creation of the secondary buffer: "ArgumentException: Value does not fall within the expected range."</p>
<p>The tes... | <p>Not all soundcards support 24 bit sample playback, and even when they do, they often have to be exclusively opened in that mode. There is a similar issue with sample rates. Your soundcard may be operating at 44.1kHz, in which case 48kHz needs to be resampled to be played.</p>
<p>I have written an open source .NET a... | <p>In addition to the sampling issue, WAV is just a container format and the audio could be compressed in any of a myriad of audio formats (just like AVI is a container of video). So you could use a tool like <a href="http://www.headbands.com/gspot/download.html" rel="nofollow noreferrer">GSpot</a> to find out if your ... | 12,593 |
<p>I'm looking for a way to get the name of the main HTML form so I can submit it from JavaScript.</p>
<p>The reason I can just set the name of the form is because the JavaScript is on a User Control that could get added to many different sites with different form names.</p>
<p>Thanks.</p>
| <p>I'm not totally sure that this will address what you're asking for, so please comment on it:</p>
<p>In your script, when the User Control renders, you could have this placed in there. So long as script doesn't have a "runat" attribute, you should be good.</p>
<pre><code><script type="text/javascript">
var f... | <p>ASP.NET pages can only have one form, so its safe to just do:</p>
<pre><code> document.forms[0].submit();
</code></pre>
| 30,451 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.