instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I would like to install SQLExpress2005 as an instance "SQLExpress"
and install SQLExpresss2008 as "SQLExpress2008" instance.</p>
<p>Is there any problem with doing this on the same machine?</p>
| <p>As Long as you give them distinct names, there shouldn't be any problems. The binaries are stored in directories based on version, and you can (and should) point their filegroups at different locations. This should also apply to the Full versions.</p>
| <p>I'm pretty sure you can with the full version of SQL, but you need to do it by installing named instances. This could be an issue with SQL Express where it doesn't give you that option.</p>
| 17,694 |
<p>I am opening a process (with os.popen() ) that, for some commands, detects certain keypresses (e.g. ESC - not the character, the key). Is there a way to send keypress events to the process?</p>
| <p>You probably want something like <a href="http://www.noah.org/wiki/Pexpect" rel="nofollow noreferrer"><code>Pexpect</code></a>. It's been around a while, and there may be a better alternative, now, but it will let you do what you want. </p>
<p>As far as I know, there is no easy way to do that kind of thing with o... | <p>The obvious way would be to start the process in it's own shell.<br>
something like os.popen("sh command") </p>
| 35,312 |
<p>Does anyone have any suggestions on how to mentor a junior programmer ? If you have mentored someone did you follow any process or was it quite informal ?</p>
<p>If you've been mentored in the past what kind of things did you find most helpful ?</p>
| <p>Try to set aside between 30-60 minutes a day to review their code together. If you can't do this, then try to get together to review their code whenever they make a code commit, unless it was very basic. Have them explain why they chose the approach they took in lieu of others. A process like this helps to establish... | <p>I have mentored several junior people under me before. My approach varied slightly based on the person a bit based on how they learned. </p>
<p>In short, I gave the junior people small, self-contained projects when I could and gave them a relatively fixed time to complete the task. Once the task was complete I w... | 4,471 |
<p>I would like to use the 7-Zip DLLs from Delphi but have not been able to find decent documentation or examples. Does anyone know how to use the 7-Zip DLLs from Delphi?</p>
| <p>As of release 1.102 the <a href="http://wiki.delphi-jedi.org/index.php?title=JEDI_Code_Library" rel="noreferrer">JEDI Code Library</a> has support for <a href="http://en.wikipedia.org/wiki/7-Zip" rel="noreferrer">7-Zip</a> built into the <a href="http://jcl.svn.sourceforge.net/viewvc/jcl/trunk/jcl/source/common/JclC... | <p>I tried many solutions and had problems, this one worked.</p>
<p>Download <a href="https://github.com/zedalaye/d7zip" rel="nofollow noreferrer">https://github.com/zedalaye/d7zip</a>
Copy 7z.dll and sevenzip.pas to your project diroctory and add sevenzip.pas to your project.</p>
<p>Then you can use this to unzip:</... | 10,017 |
<p>I'm a little unsure how the open source licensing stuff works. If I were to choose a particular open source license, what do you actually have to do to make it applicable to your software? I would imagine it would be a little more involved than just 'stating' that you're releasing your software under LGPL. And ho... | <p>It's as simple as deciding to license your software under a particular license. This is not technically contract law, but copyright law. As the owner/licenser of your intellectual property (the source and binaries) you may license its distribution anyway you see fit. Providing a clear disclaimer as to the recipie... | <p>it depends on the type of open source license you are trying to use, all of them has very different meanings and things to take into consideration. even your design may be impact depending on the type of open source license you use.</p>
| 29,899 |
<p>I'm working on a set of classes that will be used to serialize to XML. The XML is not controlled by me and is organized rather well. Unfortunately, there are several sets of nested nodes, the purpose of some of them is just to hold a collection of their children. Based on my current knowledge of XML Serialization... | <p>Are you not using the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx" rel="nofollow noreferrer">XmlSerializer</a>? It's pretty damn good and makes doing things like this real easy (I use it quite a lot!).</p>
<p>You can simply decorate your class properties with some at... | <p>You would only need to have Users defined as an array of User objects. The XmlSerializer will render it appropriately for you.</p>
<p>See this link for an example:
<a href="http://www.informit.com/articles/article.aspx?p=23105&seqNum=4" rel="nofollow noreferrer">http://www.informit.com/articles/article.aspx?p=2... | 10,239 |
<p>My team builds reusable libraries for other (internal) software development teams. We use FlexBuilder 3 as our development environment. Our SCM standards state that these projects must include test harnesses and a unit test runner, and (of course) we want to be able to use the debugger. For that reason, all the pr... | <p>I would also suggest breaking this up into 2 projects. Have 1 library project and 1 application for the tests and the testrunner.</p>
<p>On a sidenote: FlexBuilder 4 will have support for running FlexUnit tests in the IDE, for both Flex applications and Flex library projects. So you won't have to maintain an applic... | <p>Assuming it is possible, I'd suggest adjusting your SCM standards to allow test harnesses and unit test runners to exist in other projects. Simply mandate that any library project must include a companion test project. </p>
| 12,938 |
<p>We have a few developers working on the same VS2005 solution, but our source control is very bad. (Our company uses Harvest, which we give a vote of no confidence).</p>
<p>Right now, we're all just working off of the files on a shared lan drive. Obviously, this causes some problems. But we think it's better than ... | <p>Treat the share as if it were your source control system. Make the share read-only, which will force developers to get local copies in order to make changes. You then have a somewhat stable version to compare against. This would help facilitate being able to do "merges". "Checking" code in would have to consist of s... | <p>Working off of a shared drive is not a good idea, and gets my vote of "no confidence".</p>
<p>It would be too easy to overwrite other's changes, you have no change tracking, no way to branch or tag/label, etc.</p>
| 24,706 |
<p>Seeing this: <a href="http://www.suckless.org/wiki.html" rel="nofollow noreferrer">http://www.suckless.org/wiki.html</a>. A wiki based on Mercurial. Are there any other non-code related use to version control? Is there any other projects that uses version control tools inside instead of programming their own specifi... | <p>Simple bug-tracking system with a file per bug, folder structure to handle an statuses and naming convention for simpler searching.</p>
| <p>I would use VC to implement an archival (or backup) feature for data on disk.</p>
<p>Also:</p>
<ul>
<li>Any document related to a project.</li>
</ul>
| 44,273 |
<p>In ASP.NET, I'm looking for a way to audit a user leaving my application. To be specific, I'd like to insert a 'logout' record in an audit table in SQL Server when the user's session is abandoned/destroyed for any reason (not necessarily because of a call to session.abandon)</p>
<p>I have a 'SessionHelper' class th... | <p>The Session_End event is only fired if you have InProc sessions. SQL or state server session management will not fire this event. If you can, get back to InProc sessions and use this event.</p>
<p>Apart from that, you won't get very good solutions. ASP.NET doesn't offer a way to look at the current list of sessions... | <p>At best your logout record is going to be an intelligent guess, even if you do get the session events to work correctly, of when the user left your site/app. A technique you might use is to place the logout time into the db when the user logs in, and just keep updating the record with a future time as they use the ... | 24,635 |
<p>Is it a good idea to use while loop instead of a cursor?</p>
<p>What are the advantages/disadvantages of cursors?</p>
| <p>Some of these depends on the DBMS, but generally:</p>
<p>Pros:</p>
<ul>
<li><p>Outperform loops when it comes to row-by-row processing</p></li>
<li><p>Works reasonably well with large datasets</p></li>
</ul>
<p>Cons:</p>
<ul>
<li><p>Don't scale as well</p></li>
<li><p>Use more server resources</p></li>
<li><p>In... | <p>I would ask you what you are doing with that cursor/while loop.</p>
<p>If you are updating or returning data why don't you use a proper WHERE clause. I know people who would say you should never use cursors.</p>
| 16,915 |
<p>I am rewriting code to handle some embedded communications and right now the protocol handling is implemented in a While loop with a large case/switch statement. This method seems a little unwieldy. What are the most commonly used flow control methods for implementing communication protocols?</p>
| <p>It sounds like the "while + switch/case" is a statemachine implementation. I believe that a well thought out statemachine is often the easiest and most readable way to implement a protocol.</p>
<p>When it comes to statemachines, breaking some of the traditional programming rules comes with the territory. Rules like... | <p>For cases where you key off of a field in a protocol header to direct you to the next stage of processing for that protocol, arrays of function pointers can be used. You use the value from the protocol header to index into the array and call the function for that protocol.</p>
<p>You <strong>must</strong> handle al... | 9,004 |
<p>I have a .NET 3.5 C# library that uses OleDb to pull data from an Excel file and return it in a DataRowCollection which is used by a CLR Table-Valued Function in SQL Server 2005.</p>
<p>I deployed the <code>ASSEMBLY</code> in SQL Server as sa and used <code>PERMISSION_SET = EXTERNAL_ACCESS</code>. The sa login has... | <p>Solved it!</p>
<p>PERMISSION_SET = EXTERNAL_ACCESS was not enough. I had to go all the way down to PERMISSION_SET = UNSAFE and then it started working. I can't believe I didn't try that before.</p>
| <p>I am sorry that I am not providing a solution to the exact problem here.</p>
<p>But, you can use OPENROWSET function to work with Excel files from SQL Server.
CLR is not necessary, unless there is something that I don't know of.</p>
| 41,728 |
<p>I wrote an Active X plugin for IE7 which implements IObjectWithSite besides some other necessary interfaces (note no IOleClient). This interface is queried and called by IE7. During the SetSite() call I retrieve a pointer to IE7's site interface which I can use to retrieve the IHTMLDocument2 interface using the foll... | <p>I found the following code in the Google Gears code, <a href="http://code.google.com/p/gears/source/browse/trunk/gears/base/ie/activex_utils.cc?r=2157" rel="nofollow noreferrer">here</a>. I copied the functions I think you need to here. The one you need is at the bottom (GetHtmlWindow2), but the other two are needed... | <p>Well I was aware of the gears code already. The mechanism gears uses is based on a workaround through performing an explicit method call into the gears plugin from the gears loader to set the window object and use that as site interface instead of the IUnknown provided by IE Mobile in the SetSite call. Regarding to ... | 6,766 |
<p>I'm writing a web application that decodes Morse Code that is tapped in using mouse button.</p>
<p>I originally did a proof of concept using conventional JavaScript, but now I'm redoing it using jQuery.</p>
<p>Is there a clever way with jQuery to tell if a button has been pressed again within so many milliseconds,... | <p>I suspect you'll need to monitor the buttons' click events and do the timing yourself.</p>
| <p>To your point about the button NOT being pressed again within so many milliseconds, you'll need to use <code>setTimeout()</code> and <code>clearTimeout()</code>, keeping track of the targets yourself as theracoonbear said. You were probably doing it this way in your POC, and JQuery doesn't have this in the API (tha... | 25,679 |
<p>Is the source code for the common login controls available?</p>
<p>Those are the controls which are available under Login section in Toolbox: </p>
<ul>
<li>Login, </li>
<li>LoginView, </li>
<li>PasswordRecovery,</li>
<li>LoginStatus, </li>
<li>LoginName,</li>
<li>CreateUserWizard, </li>
<li>ChangePassword</li>
</... | <p>The source code for the entire framework is available. The link below provides some details as to how to access:</p>
<p><a href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/sburke/archive/2008/01/1... | <p>The source code for the entire framework is available. The link below provides some details as to how to access:</p>
<p><a href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/sburke/archive/2008/01/1... | 39,377 |
<p>Is there a way to find the size of a file object that is currently open?</p>
<p>Specifically, I am working with the tarfile module to create tarfiles, but I don't want my tarfile to exceed a certain size. As far as I know, tarfile objects are file-like objects, so I imagine a generic solution would work.</p>
| <pre><code>$ ls -la chardet-1.0.1.tgz
-rwxr-xr-x 1 vinko vinko 179218 2008-10-20 17:49 chardet-1.0.1.tgz
$ python
Python 2.5.1 (r251:54863, Jul 31 2008, 22:53:39)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
... | <p>I was curious about the performance implications of both, since once you open a file, the <code>name</code> attribute of the handle gives you the filename (so you can call <code>os.stat</code> on it).</p>
<p>Here's a function for the seek/tell method:</p>
<pre class="lang-py prettyprint-override"><code>import io
def... | 35,977 |
<p>What's the best way to import a CSV file into a strongly-typed data structure?</p>
| <p>Microsoft's <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.fileio.textfieldparser.aspx" rel="nofollow noreferrer">TextFieldParser</a> is stable and follows <a href="https://www.rfc-editor.org/rfc/rfc4180" rel="nofollow noreferrer">RFC 4180</a> for CSV files. Don't be put off by the <code>Mic... | <p>If you can guarantee that there are no commas in the data, then the simplest way would probably be to use <a href="http://msdn.microsoft.com/en-us/library/system.string.split(VS.71).aspx" rel="nofollow noreferrer">String.split</a>.</p>
<p>For example:</p>
<pre><code>String[] values = myString.Split(',');
myObject.... | 2,414 |
<p>For the purposes of tracking non-HTML documents via google analytics, I need the mentioned algorithm. It should:</p>
<ul><li>not hard-code the domain</li>
<li>ignore the protocol (i.e. http/https)</li>
<li>not worry about the presence/absence of "www" (any absolute links WILL prefix with "www" and all pages WILL be... | <p>I would like to point out that, if you're on so.com, the following links are URLs within the same domain:</p>
<ul>
<li><a href="http://test.so.com" rel="noreferrer">http://test.so.com</a></li>
<li><a href="http://so.com/index" rel="noreferrer">http://so.com/index</a></li>
<li>index</li>
<li>/index</li>
<li>#</li>
<... | <pre><code>if( someDomElementWhichIsALink.href.indexOf(window.location) != -1 ) {
// this is targeting your domain
}
</code></pre>
| 40,950 |
<p>I already know: "Don't use css expressions!" My question is not about whether I should be using an expression or if there is an alternative; my question is simply: <strong>Can I get a css expression to only be evaluated in versions of IE prior to version 7 without using conditional comments?</strong></p>
<p>I occa... | <p>I always use the star "hack" to target IE6 specifically, but it does require your browser to be in <strong>standards compliant</strong> mode (see below).</p>
<pre><code>/* IE6 only */
* html .myClass {
width: 500px;
}
</code></pre>
<p>I like it because it doesn't rely on parsing inconsistencies in browsers ... | <p>This answer may be what you are looking for:
<a href="https://stackoverflow.com/questions/213309/in-line-css-ie-hack#213458">In-line CSS IE hack</a></p>
| 30,774 |
<p>I have the simple class using auto-implemented properies: </p>
<pre><code>Public Class foo
{
public foo() { }
public string BarName {get; set;}
}
</code></pre>
<p>I obviously use the variable BarName throughout my class and now need to add logic when the property value is set (it must be all upper case... | <blockquote>
<p>Does this mean that I need to now
create a private variable for BarName</p>
</blockquote>
<p>Yes</p>
<blockquote>
<p>and change the current BarName
variable used throughout my class</p>
</blockquote>
<p>Do not change the rest of the code in your class to use the new private variable you creat... | <p>You are correct about the refactoring and it really shouldn't break anything.</p>
<p>Whether or not you actually need to go through the references within the class to the property name and change those to refer to the private field would depend on whether the internal code needed to access the underlying representa... | 20,001 |
<p>The original query looks like this (MySQL):</p>
<pre><code>SELECT *
FROM books
WHERE title LIKE "%text%" OR description LIKE "%text%"
ORDER BY date
</code></pre>
<p>Would it be possible to rewrite it (without unions or procedures), so that result will look like this:</p>
<ul>
<li>list of books where title matc... | <p>In sql server I would do the following:</p>
<pre><code>select * from books
where title like '%text%' or description like '%text%'
order by case when title like '%text%' then 1 else 2 end, date
</code></pre>
<p>I'm not sure if you can include columns in ORDER BY in mysql that aren't in the SELECT, but that's the p... | <p>The union command will help you. Something along these lines:</p>
<pre><code>SELECT *, 1 as order from books where title like '%text%'
union
SELECT *, 2 as order from books where description like '%text%'
ORDER BY order, date
</code></pre>
| 13,103 |
<p>I feel that my shop has a hole because we don't have a solid process in place for versioning our database schema changes. We do a lot of backups so we're more or less covered, but it's bad practice to rely on your last line of defense in this way. </p>
<p>Surprisingly, this seems to be a common thread. Many shops I... | <p>Must read <a href="http://blog.codinghorror.com/get-your-database-under-version-control/" rel="noreferrer">Get your database under version control</a>. Check the series of posts by K. Scott Allen.</p>
<blockquote>
<p>When it comes to version control, the database is often a second or even third-class citizen. Fro... | <p>We insist upon change scrips and a master data definition script. These are checked into CVS along with any other source code. The PL/SQL (were are an Oracle shop) is also source controlled in CVS. The change scripts are repeatable and can be passed to everyone on the team. Basically, just because it is a databa... | 14,065 |
<p>Does anybody use anything else to document their <code>PHP</code> code than <code>PHPDoc?</code>
Are there any tools that read the same documentation syntax but give richer output?</p>
| <p>I´ll go for doxygen too.</p>
<p>Here are several reasons :</p>
<ul>
<li>compatible with phpdoc tags and other popular ones : it´s interoperable</li>
<li>works with various programming languages : a better time investment</li>
<li>there is alternative syntaxes : can choose the commenting style that suit you</li>
<... | <p>If you need to document code for PHP 5.3+, eg. if it uses namespaces Ted Kulp's <a href="https://github.com/tedkulp/phpdoctor" rel="nofollow">fork of PHPDoctor</a> might be your answer.</p>
| 12,651 |
<p>I have just installed VMWare Server 2.0 on a fresh Fedora Core 8 install. The ports for the web access console of VMWare are 8222 and 8333 (like the defaults).</p>
<p>When I try a remote http access to myserver:8222 it fails. But when I run</p>
<pre><code>/sbin/service iptables stop
</code></pre>
<p>access become... | <p>Your rules for VMware need to come before the REJECT entry; otherwise they'll never be reached.</p>
<p>A good debugging tool is to add a LOG just before your rules to verify:</p>
<pre><code>-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# Custom authorization for VMWare administrati... | <p>A simple way to fix this would be to run system-config-securitylevel or system-config-securitylevel-tui and add 8222 and 8333 as trusted ports. This adds essentially the same iptables rules as you're doing manually.</p>
| 31,825 |
<p>What are best resources/tutorials for starting up with SQLAlchemy?
Maybe some simple step by step stuff like creating a simple table and using it and going up from there.</p>
| <p>Personally, I'd buy <a href="http://oreilly.com/catalog/9780596516147/" rel="noreferrer">this book</a> and cram it into the noggin over the course of a week or so.</p>
<p>I've tried tackling SQLAlchemy on the job without learning the details first. I had a hard time with it, because I found the online documentation... | <p><a href="http://www.ibm.com/developerworks/aix/library/au-sqlalchemy/" rel="nofollow noreferrer">Using SQLAlchemy</a> (IBM developerWorks)</p>
| 23,790 |
<p>I have a loop running that will process 1000's of records, currently once the loop is running it can't be stopped and the user must wait until it is finished. How can I stop the loop when someone clicks a 'Cancel' button? How do I break into that other routine?</p>
<p>Thanks</p>
| <p>You can run it in its own thread and abort the thread. Just beware that that might leave the operation in a bad state.</p>
<p>Instead, you <strong>should</strong> create an exit flag that the thread checks at safepoints. If it's marked for exiting, the thread will stop as soon as it's safe for it to do so.</p>
| <p>As Mark said you need to implement some kind of co-operative synchronization. People often gravitate to wanting to use Thread.Abort here ... but that is a bad idea.</p>
<p>There are a number of questions that address this, for example see: "<a href="https://stackoverflow.com/questions/44656/is-there-a-good-method-... | 29,919 |
<p>I would like to search through all of my procedures packages and functions for a certain phrase.</p>
<p>Since it is possible to retrieve the code for compiled procedures using toad I assume that the full text is stored in some data dictionary table. Does anyone know where that would be?</p>
<p>Thanks a lot</p>
| <p>You can do something like</p>
<pre><code>SELECT name, line, text
FROM dba_source
WHERE upper(text) like upper('%<<your_phrase>>%') escape '\'
</code></pre>
| <p>Do you mean using PL/SQL? Or just using TOAD? I know that you can use the "Find Objects" (or something like that) feature to manually search through all objects like procs, tables, etc...</p>
| 31,385 |
<p>In <code>PHP</code>, what is the best practice for laying out the responsibilities of a <code>Db Abstraction Layer</code>?</p>
<p>Is <code>OOP</code> a good idea in terms of performance? How much should be generic object code, and how much should be very specific functions? </p>
| <p>There are already some great solutions for this. A DAL is not a simple thing, especially since so many security concerns are involved. I would suggest checking out <a href="http://www.php.net/manual/en/class.pdo.php" rel="nofollow noreferrer">PDO</a> and <a href="http://www.php.net/manual/en/class.mysqli.php" rel="n... | <p>There are already some great solutions for this. A DAL is not a simple thing, especially since so many security concerns are involved. I would suggest checking out <a href="http://www.php.net/manual/en/class.pdo.php" rel="nofollow noreferrer">PDO</a> and <a href="http://www.php.net/manual/en/class.mysqli.php" rel="n... | 15,343 |
<p>Is there an elegant way to specialize a template based on one of its template parameters?</p>
<p>Ie.</p>
<pre><code>template<int N> struct Junk {
static int foo() {
// stuff
return Junk<N - 1>::foo();
}
};
// compile error: template argument '(size * 5)' involves template param... | <p>How's this:</p>
<pre><code>#include <iostream>
using namespace std;
template < typename T, T N, T D >
struct fraction {
typedef T value_type;
static const value_type num = N;
static const value_type denom = D;
static const bool is_div = (num % denom == 0);
};
template< typename T, T... | <p>I would hardly call it elegant, but here's my version of your code using only templates for computation (along with a test thing) --</p>
<pre><code>#include <iostream>
template < int N > struct JunkDivBy5 {
static int foo() {
return N;
}
};
template < int N > struct Junk {
te... | 33,541 |
<p>I am using a rich text editor on a web page. .NET has feature that prevent one from posting HTML tags, so I added a JavaScript snippet to change the angle brackets to and alias pair of characters before the post. The alias is replaced on the server with the necessary angle bracket and then stored in the database. ... | <p>There's actually a way to turn that "feature" off. This will allow the user to post whichever characters they want, and there will be no need to convert characters to an alias using Javascript. See this article for <a href="http://mdid.org/mdidwiki/index.php?title=Disabling_Request_Validation" rel="nofollow norefer... | <p>My first comment would be to avoid using JavaScript to change the angle brackets. Bypassing this is as simple as disabling JavaScript in the browser. Almost all server-side languages have some utility method that converts some HTML characters into their entity counterparts. For instance, PHP uses htmlentities(), and... | 8,706 |
<p>If there are any language designers out there (or people simply in the know), I'm curious about the methodology behind creating standard libraries for interpreted languages. Specifically, what seems to be the best approach? Defining standard functions/methods in the interpreted language, or performing the processing... | <p>The line between "interpreted" and "compiled" languages is really fuzzy these days. For example, the first thing Python does when it sees source code is compile it into a bytecode representation, essentially the same as what Java does when compiling class files. This is what *.pyc files contain. Then, the python run... | <p>As long as you are using a portable API for the compiled code base like the <a href="http://en.wikipedia.org/wiki/C_standard_library" rel="nofollow noreferrer">ANSI C standard library</a> or <a href="http://en.wikipedia.org/wiki/Standard_Template_Library" rel="nofollow noreferrer">STL</a> in C++, then taking advanta... | 3,452 |
<pre><code>class String
{
private:
char* rep;
public:
String (const char*);
void toUpper() const;
};
String :: String (const char* s)
{
rep = new char [strlen(s)+1];
strcpy (rep, s);
}
void String :: toUpper () const
{
for (int i = 0; rep [i]; i++)
rep[i] = toupper(... | <p><strong>A const member function, is a member function that does not mutate its member variables.</strong> </p>
<p><strong>const on a member function does not imply const char *. Which would mean that you can't change the data in the address the pointer holds.</strong> </p>
<p>Your example does not mutate the mem... | <p>toUpper() does not change the pointer (which belongs to the class). It only changes the data which rep points to (that do not belong to the class).</p>
<p>However, 'const' is a sort of warranty for the users of your class: if a method is declared const, who uses an instance of your class can expect it won't change ... | 37,512 |
<p>If I do this:</p>
<pre><code>// In header
class Foo {
void foo(bar*);
};
// In cpp
void Foo::foo(bar* const pBar) {
//Stuff
}
</code></pre>
<p>The compiler does not complain that the signatures for Foo::foo do not match. However if I had:</p>
<pre><code>void foo(const bar*); //In header
void Foo::foo(bar*) {} /... | <p>In the first, you've promised the compiler, but not other users of the class that you will not edit the variable.</p>
<p>In your second example, you've promised other users of the class that you will not edit their variable, but failed to uphold that promise.</p>
<p>I should also note that there is a distinct diff... | <p>In the former, the <code>const</code> doesn't affect the interface, only the implementation. You are saying to the compiler, "I am not going to change the value of the <code>bar*</code> within this function". You can still change what is pointed to by the pointer. In the latter, you are telling the compiler (and all... | 33,914 |
<p>I recently bought and read a box set of books on security (<a href="https://rads.stackoverflow.com/amzn/click/com/020172152X" rel="nofollow noreferrer" rel="nofollow noreferrer">Building Secure Software: How to Avoid Security Problems the Right Way</a>, <a href="https://rads.stackoverflow.com/amzn/click/com/02017869... | <p>I follow <a href="http://www.schneier.com/blog/" rel="noreferrer">Schneier on Security</a> in my RSS reader.</p>
| <p><strong><a href="http://www.twit.tv/sn" rel="nofollow noreferrer">Security Now!</a></strong> is not bad (I listen each week).<br>
It often contains good explanations of underlying technologies (e.g. how does a router know where to send an IP packet?), although I do think it does go on a bit. </p>
<p>If you want a ... | 13,638 |
<p>What are the differences between MyISAM and Inno DB types in MySql?</p>
| <p>The main difference is that InnoDB supports transactions while MyISAM does not.</p>
<p>There are numerous other differences, however the common one's i am aware of are:</p>
<ul>
<li>MyISAM has typically been considered faster at searching, but recent InnoDB improvements are removing this difference and improving h... | <p>Here is a description of differences between InnoDB and MyIsam:</p>
<p><a href="http://tag1consulting.com/MySQL_Engines_MyISAM_vs_InnoDB" rel="nofollow noreferrer">Differences between InnoDB and MyIsam</a></p>
<p>Few differences:</p>
<ul>
<li><strong>MYISAM</strong> doesnt support any database transactions, </li>... | 35,010 |
<p>In python, if I say</p>
<pre><code>print 'h'
</code></pre>
<p>I get the letter h and a newline. If I say </p>
<pre><code>print 'h',
</code></pre>
<p>I get the letter h and no newline. If I say</p>
<pre><code>print 'h',
print 'm',
</code></pre>
<p>I get the letter h, a space, and the letter m. How can I prev... | <pre><code>import sys
sys.stdout.write('h')
sys.stdout.flush()
sys.stdout.write('m')
sys.stdout.flush()
</code></pre>
<p>You need to call <a href="https://docs.python.org/library/io.html#io.IOBase.flush" rel="noreferrer"><code>sys.stdout.flush()</code></a> because otherwise it will hold the text in a buffer and you ... | <pre><code>import sys
a=raw_input()
for i in range(0,len(a)):
sys.stdout.write(a[i])
</code></pre>
| 31,835 |
<p>I don't like the AutoSize property of the Label control. I have a custom Label that draws a fancy rounded border among other things. I'm placing a <code>AutoSize = false</code> in my constructor, however, when I place it in design mode, the property always is True. </p>
<p>I have overridden other properties with su... | <p>I've seen similar behaviour when setting certain properties of controls in the constructor of the form itself. They seem to revert back to their design-time defaults.</p>
<p>I notice you're already overriding the OnLoad method. Have you tried setting AutoSize = false there? Or are you mainly concerned with providin... | <p>I don't see <code>this.AutoSize = false</code> in your constructor. Your class is marked as partial -- perhaps you have a constructor in another file with that line. The visual studio designer will call that parameterless constructor you've got there.</p>
| 4,483 |
<p>I'm programming an application in MFC (don't ask) and I have a CEdit box that holds a number. When that number is edited, I would like to act on the change, and then replace the caret where it was before I acted on the change - if the user was just before the "." in "35.40", I would like it to still be placed befor... | <p>Use the GetSel() function before your change to store the location of the cursor, then use SelSel() to set it back. You can use these functions to get/set the location of the caret, not just to get/set the selection the user has made.</p>
| <p>Could you explain the reason why you would want to change the behavior of the CEdit box?
As a user I would have a problem with the caret being changed every time I enter some character. Or is it what you would like to prevent if you change that value programmatically?</p>
| 11,812 |
<p>I need to create a 3D model of a cube with a circular hole punched at the center of one face passing completely through the cube to the opposite side. I am able to generate the vertices for the faces and for the holes.</p>
<p>Four of the faces (untouched by the hole) can be modeled as a single triangle strip. The i... | <p>To generate the index-buffer you want, you could do like this. Thinking in 2D with the face in question as a square with vertices (±1, ±1), and the hole as a circle in the middle.</p>
<ol>
<li>You walk along the edge of the circle, dividing it into some number of segments.</li>
<li>For each vertex, yo... | <p>Just a thought - </p>
<p>If you're into cheating (as done many times in games), you can always construct a regular cube but have the texture for the two faces you desire with a hole (alpha = 0), you can then either clip it in the shader, or blend it (in which case you need to render with Z sort).
You get the inside... | 47,245 |
<p>How can ALTER be used to drop a column in a MySQL table if that column exists? </p>
<p>I know I can use <code>ALTER TABLE my_table DROP COLUMN my_column</code>, but that will throw an error if <code>my_column</code> does not exist. Is there alternative syntax for dropping the column conditionally?</p>
<p>I'm using... | <p><strong>For MySQL, there is none:</strong> <a href="http://bugs.mysql.com/bug.php?id=10789" rel="noreferrer">MySQL Feature Request</a>. </p>
<p>Allowing this is arguably a really bad idea, anyway: <code>IF EXISTS</code> indicates that you're running destructive operations on a database with (to you) unknown structu... | <p>I realise this thread is quite old now, but I was having the same problem.
This was my very basic solution using the MySQL Workbench, but it worked fine...</p>
<ol>
<li>get a new sql editor and execute SHOW TABLES to get a list of your tables</li>
<li>select all of the rows, and choose copy to clipboard (unquoted) ... | 20,945 |
<p>Does SQL Server 2008 ship with the .NET 3.5 CLR, so that stored procedures written in CLR can use 3.5 features?</p>
| <p>Actually it ships with .NET 3.5 SP1. So yes, the stored procs can use 3.5 features and libraries.</p>
| <p>I swear this isn't being pedantic, but is an important distinction -- I don't know what specifically you need when you say ".NET 3.5 CLR" -- probably the .NET 3.5 Framework? Possibly C# 3.0 language features? But the CLR that .NET 3.5 runs on <a href="http://msdn.microsoft.com/en-us/netframework/aa663314.aspx" rel... | 3,255 |
<p>When I am writing code in Python, I often need to remove items from a list or other sequence type based on some criteria. I haven't found a solution that is elegant and efficient, as removing items from a list you are currently iterating through is bad. For example, you can't do this:</p>
<pre><code>for name in na... | <p>Two easy ways to accomplish just the filtering are:</p>
<ol>
<li><p>Using <code>filter</code>:</p>
<p><code>names = filter(lambda name: name[-5:] != "Smith", names)</code></p></li>
<li><p>Using list comprehensions:</p>
<p><code>names = [name for name in names if name[-5:] != "Smith"]</code></p></li>
</ol>
<p>Not... | <p>Well, this is clearly an issue with the data structure you are using. Use a hashtable for example. Some implementations support multiple entries per key, so one can either pop the newest element off, or remove all of them.</p>
<p>But this is, and what you're going to find the solution is, elegance through a differe... | 3,899 |
<p>Why are pointers such a leading factor of confusion for many new, and even old, college level students in C or C++? Are there any tools or thought processes that helped you understand how pointers work at the variable, function, and beyond level?</p>
<p>What are some good practice things that can be done to bring ... | <p>Pointers is a concept that for many can be confusing at first, in particular when it comes to copying pointer values around and still referencing the same memory block.</p>
<p>I've found that the best analogy is to consider the pointer as a piece of paper with a house address on it, and the memory block it referenc... | <p>I don't see what is so confusing about pointers. They point to a location in memory, that is it stores the memory address. In C/C++ you can specify the type the pointer points to. For example:</p>
<pre><code>int* my_int_pointer;
</code></pre>
<p>Says that my_int_pointer contains the address to a location that cont... | 2,758 |
<p>Is multiple inheritance possible in VB .Net? If so, what is the syntax?</p>
| <p>Short answer: No</p>
<p>Slightly longer answer: Yes, if you inherit multiple interfaces, and a single base class. Since this is usually the reason for MI (you want to implement multiple interfaces), it's usually enough. However, in those rare instances where "real" MI is useful, .NET prevents you from doing it.</p>... | <p>Likely what you want to do is really composition or aggregation ( see <a href="http://www.c-sharpcorner.com/uploadfile/pcurnow/compagg07272007062838am/compagg.aspx" rel="nofollow">here for design pattern</a>). Maybe you're defining a behavior. You can always implement an interface SomeInterface in the base class,... | 45,721 |
<p>In a Test project in Visual Studio 2008 (Pro), I created a Test project, and I want to configure the project properties to give a command line argument to the tests. I set the properties, but then realized I have no idea how to actually use the argument. </p>
<p>How do you get the arguments from MSTest?</p>
| <p>VS 2008 test are compiled into DLLs which can't directly receive command line arguments as far as I know. </p>
<p>You could add a configuration file 'app.config' for the dll and use that instead.</p>
<p>Just beware, mstest only copies .config files for the test container being run at the time. </p>
<p>if you have... | <p>Perhaps you can use <a href="http://msdn.microsoft.com/en-us/library/ms683156(VS.85).aspx" rel="nofollow noreferrer">GetCommandLine</a>().</p>
<p>Edit: GetCommandLine() is a win32-function, but there ought to be a corresponding .Net function for it.</p>
| 21,889 |
<p>I use BIRT since early days and still have riddles regarding PDF emitter. </p>
<p><strong>Short story</strong>:
Can I configure fontsConfig.xml to load fonts from relative path or from jars?</p>
<p><strong>Long story:</strong>
We are using both FOP and BIRT for generating PDF in our web application. It would be ni... | <p>With some BIRT versions, you can use a SystemProperty "birt.font.dirs". This overrides the fontsConfig.xml.</p>
<p>Well, this once worked, but obviously it was removed from the BIRT source code later.</p>
<p>Now you can call something like</p>
<pre class="lang-java prettyprint-override"><code>EngineConfig engineC... | <p>There is a way to have fonts on a relative path to be used in Birt.</p>
<p>What you need to do is copy the fonts to a location in your Web Application. Mine was in :
C:\\src\main\webapp\Reports</p>
<p>Now in the application, use the following command to register the fonts from the above mentioned location.</p>
<p... | 31,935 |
<p>What could be the problem with reversing the array of DOM objects as in the following code:</p>
<pre><code>var imagesArr = new Array();
imagesArr = document.getElementById("myDivHolderId").getElementsByTagName("img");
imagesArr.reverse();
</code></pre>
<p>In Firefox 3, when I call the <code>reverse()</code> method... | <p>Because getElementsByTag name actually returns a NodeList structure. It has similar array like indexing properties for syntactic convenience, but it is <em>not</em> an array. For example, the set of entries is actually constantly being dynamically updated - if you add a new img tag under myDivHolderId, it will autom... | <p>This worked for me, I did a reverse for loop and allocated the nodes to an array</p>
<pre><code>var Slides = document.getElementById("slideshow").querySelectorAll('li');
var TempArr = [];
for (var x = Slides.length; x--;) {
TempArr.push(Slides[x]);
}
Slides = TempArr;
</code></pre>
| 6,755 |
<p>I need to create a way to upload a bytestream using chunked encoding.</p>
<p>I have a byte array that contains an audio file, I would like to send that file to a server using a chunked stream.</p>
<p>I've been able to do a chunked upload via a native socket but I would really like to do this via one of the NSURL (... | <p>My experience with the NSURLConnection classes has been awful. They are full of memory leaks.</p>
<p>After much trial and failure, I now use an iPhone compiled version of libcurl; it's far better, see here..</p>
<p><a href="http://www.iphonedevsdk.com/forum/iphone-sdk-development/4580-curl-anyone-using-their-app.h... | <p>My experience with the NSURLConnection classes has been awful. They are full of memory leaks.</p>
<p>After much trial and failure, I now use an iPhone compiled version of libcurl; it's far better, see here..</p>
<p><a href="http://www.iphonedevsdk.com/forum/iphone-sdk-development/4580-curl-anyone-using-their-app.h... | 35,913 |
<p>First, context: I'm trying to create a command-line-based tool (Linux) that
requires login. Accounts on this tool have nothing to do with
system-level accounts -- none of this looks at /etc/passwd.</p>
<p>I am planning to store user accounts in a text file using the same format (roughly) as /etc/passwd.</p>
<p>Des... | <p>For the use of the crypt module:</p>
<p>When GENERATING the crypted password, you provide the salt. It might as well be random to increase resistance to brute-forcing, as long as it meets the listed conditions. When CHECKING a password, you should provide the value from getpwname, in case you are on a system that... | <p>Take a look at the article <a href="http://blog.bjrn.se/2008/01/truecrypt-explained.html" rel="nofollow noreferrer">TrueCrypt explained</a> by Björn Edström. It contains easy to understand explanation of how truecrypt works and a simple Python implementation of some of truecrypt's functionality <strong>including pas... | 42,744 |
<p>In Google Reader, you can use a bookmarklet to "note" a page you're visiting. When you press the bookmarklet, a little Google form is displayed on top of the current page. In the form you can enter a description, etc. When you press Submit, the form submits itself without leaving the page, and then the form disappea... | <p>Aupajo has it right. I will, however, point you towards a bookmarklet framework I worked up for our site (<a href="http://www.iminta.com" rel="nofollow noreferrer">www.iminta.com</a>).</p>
<p>The bookmarklet itself reads as follows:</p>
<pre><code>javascript:void((function(){
var e=document.createElement('script... | <p>At it's very basic level it will be using <code>createElement</code> to create the elements to insert into the page and <code>appendChild</code> or <code>insertBefore</code> to insert them into the page.</p>
| 9,327 |
<p>The solution we developed uses a database (sqlserver 2005) for persistence purposes, and thus, all updated data is saved to the database, instead of sent to the program.</p>
<p>I have a front-end (desktop) that currently keeps polling the database for updates that may happen anytime on some critical data, and I am ... | <p>Since you're on SQL2005, you can use a <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldependency.aspx" rel="nofollow noreferrer">SqlDependency</a> to be notified of changes. Note that you can use it pretty effortlessly with <a href="http://msdn.microsoft.com/en-us/library/system.web.cachin... | <p>In ASP.NET, <a href="http://msdn.microsoft.com/en-us/library/ms178604(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms178604(VS.80).aspx</a>. </p>
| 18,528 |
<p>Theoretically, the end user should never see internal errors. But in practice, theory and practice differ. So the question is what to show the end user. Now, for the totally non-technical user, you want to show as little as possible ("<em>click here to submit a bug report</em>" kind of things), but for more advanced... | <p>Interesting question. A solution I have used several times is this: If it's a fatal error (non-fatal errors should give the user a chance to correct the input, for example), we generate a file with a lot of relevant information: The request variables, headers, internal configuration information and a full backtrace ... | <p>I know nothing about your target language, but this is an interesting question that I have given some thought to and I wanted to add my two cents.</p>
<p>My feeling has always been that messages for hard errors and internal errors should be as useful as possible for the developer to identify the problem & fix i... | 41,182 |
<p>Our application is interfacing with a lot of web services these days. We have our own package that someone wrote a few years back using UTL_HTTP and it generally works, but needs some hard-coding of the SOAP envelope to work with certain systems. I would like to make it more generic, but lack experience to know how ... | <p>I have used <code>UTL_HTTP</code> which is simple and works. If you face a challenge with your own package, you can probably find a solution in one of the many wrapper packages around UTL_HTTP on the net (Google "consuming web services from pl/sql", leading you to e.g.
<a href="http://www.oracle-base.com/articles/9... | <p>Check out this <a href="https://stackoverflow.com/questions/33449/can-you-call-a-webservice-from-tsql-code">older post</a>. I have to agree with that post's #1 answer; it's hard to imagine a scenario where this could be a good design.</p>
<p>Can't you write a service, or standalone application, which would talk to... | 5,835 |
<p>I am planning a PHP application that needs to store date/times in an MSSQL database. (For the curious, it is a calendar application.) What is the preferred format to store this information?</p>
<p>MSSQL has its own datetime data type, which works well in the database itself and is very readable. However, there aren... | <p>I would store the dates in the MS-SQL format to assist in using the date manipulation functions in T-SQL to their fullest. It's easier to write and read</p>
<pre><code>SELECT * FROM Foo
WHERE DateDiff(d,field1,now()) < 1
</code></pre>
<p>Than to try and perform the equivalent operation by manipulating integers... | <p>Hello and good day for everyone</p>
<p>Yes , might be thats the best way , store dates in db, they will take db format and you can format when you need as you wich</p>
<p>But there is another one solution in the ISO-developed international date format, i mean ISO 8601.</p>
<p>The international format defined by I... | 28,138 |
<p>Can we have the database and transaction logs on the same drive? What will be its consequences if it is not recommended?</p>
| <p>The only downside is that it causes more thrashing on the disk, so worse performance.</p>
<p>A single write will require 2 seeks (between: write transaction log, write data, commit log). Having the transaction log on a separate disk means as few as zero seeks, because the drive heads can remain on the transaction l... | <p>In some scenarios you don't need transaction log at all. In that case you can switch database to <a href="http://msdn.microsoft.com/en-us/library/aa173563(SQL.80).aspx" rel="nofollow noreferrer">Simple Recovery Mode</a> and you gain performance and simpler administration benefits.</p>
| 6,486 |
<p>The IT department where I work is trying to move to 100% virtualized servers, with all the data stored on a SAN. They haven't done it yet, but the plan eventually calls for moving the existing physical SQL Server machines to virtual servers as well.</p>
<p>A few months ago I attended the Heroes Happen Here launch ... | <p>I can say this from personal experience because I am dealing with this very problem as we speak. The place I am currently working as a contractor has this type of environment for their SQL Server development systems. I am trying to develop a fairly modest B.I. system on this environment and really struggling with ... | <p>The biggest concern to me when virtualising software is normally licensing. </p>
<p>Here's an article on it for MS SQL. Not sure about your situation so can't pick out any salient points.</p>
<p><a href="http://www.microsoft.com/sql/howtobuy/virtualization.mspx" rel="nofollow noreferrer">http://www.microsoft.com/s... | 17,996 |
<p>I'm looking for books and resource to teach <em>myself</em> linear algebra to be used in 3D graphics programming. I prefer practical approaches to teaching over theoretical (even though math is what, 99.99% theory?) ones, so the dream resource for me would be a book that tackles linear algebra as it's used with 3D g... | <p><a href="http://ocw.mit.edu/OcwWeb/Mathematics/18-06Spring-2005/CourseHome/" rel="noreferrer">MIT OpenCourseWare</a> offers a free course in Linear Algebra. May be too general for your very specific interests, but it's free. :)</p>
| <p>Hmm - for 3D programming you don't need all the fancy linear algebra stuff like abstract vector spaces, bases, eigenvectors, etc.</p>
<p>All you need is basic stuff like matrixmultiplication, the definition of the inner product (and some basic facts about it), definition of lines and plans with respect to normal ve... | 24,183 |
<p>More and more applications need different representations of similar objects, e.g., when crossing the wire with web services or when mapping to the database. When you are working with a domain model you probably need one kind of objects in your business layer/domain model (small, lots of behaviour) and another when ... | <p>I ended up finding java code from IBM that solved it: <a href="http://www.ibm.com/developerworks/java/library/j-coordconvert/index.html" rel="noreferrer">http://www.ibm.com/developerworks/java/library/j-coordconvert/index.html</a></p>
<p>Just for reference, here is my python implementation of the method I needed:</... | <p>There is a perl module via CPAN called Geography::NationalGrid which can convert easting/northing to lat/longs. That may help.</p>
<p>Alternatively there are lots of scripts on the <a href="http://www.movable-type.co.uk/scripts/latlong-gridref.html" rel="nofollow noreferrer">movable-type site</a> that let you conve... | 44,721 |
<p>I am writing an application in Java for the desktop using the Eclipse SWT library for GUI rendering. I think SWT helps Java get over the biggest hurdle for acceptance on the desktop: namely providing a Java application with a consistent, responsive interface that looks like that belonging to any other app on your d... | <p>To follow up on pauxu's answer, I'm using launch4j and NSIS on a project of mine and thought it would be helpful to show just how I'm using them. Here's what I'm doing for Windows. BTW, I'm creating .app and .dmg for Mac, but haven't figured out what to do for Linux yet.</p>
<h2>Project Copies of launch4j and NSI... | <p>I went through the same and found that all of the free options weren't very good. Looks like you'll be writing your own. I'd be interested to see if someone has a free/cheap option that works</p>
| 2,933 |
<p>Using ICU 4.0 regex library, I find that the following regex is exhibiting exponential time:</p>
<pre><code>actual: "[^<]*<\?"
C code: "[^<]*<\\?"
</code></pre>
<p>Aim: find "<?" where there is no other "<" before it</p>
<p>When running this regex on plain text with no "<" characters at all i... | <p>You will find an explanation at <a href="http://swtch.com/~rsc/regexp/regexp1.html" rel="nofollow noreferrer" title="Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)">Regular Expression Matching Can Be Simple And Fast</a>.<br>
As MizardX said, if the match fails... | <h1><a href="http://search.cpan.org/perldoc?re" rel="nofollow noreferrer">Perl re dump</a></h1>
<p><em>Sorry for such a long post. The sample outputs have been edited for clarity.</em><br/></p>
<h2>The Perl regex engine takes shortcuts. So my first run didn't output anything all that helpful.</h2>
<pre><code>perl -M... | 40,481 |
<p>Here is my question,</p>
<p>Would it be possible, knowing that classic asp support server-side javascript, to be able to generate "server side HTML" to send to the client like
Response.write $(page).html()</p>
<p>Of course it would be great to use jQuery to do it because it's easy to parse complicated structure... | <p>I such situations I use an XML DOM as surrogate for the HTML DOM I would have in a browser.</p>
<p>jQuery can manipulating an XML DOM however jQuery expects window to be present in its context. It may be possible to fool jQuery (or tweak it) so that it would work server-side but it could be quite fragile.</p>
<p>... | <p>Yes it is possible. No, it wouldn't be fast at all and I don't see any reason for doing it as jQuery is often used for doing things that are only relevant on the client.</p>
| 19,237 |
<p>I have a UIWebView in my iPhone app, which merrily shows web content, but it does not render visited links any differently to unvisited links. Ordinarily I'd expect it to use a different colour for visited links, but alas no.</p>
<p>Safari on the other hand deals with its links correctly. I assume that UIWebView is... | <p>I came to the conclusion that the only way to get this functionality is to fake it.</p>
<p>I got this working successfully by adding a JavaScript function to all the pages to apply a "visited" class to all links whose target is on a list that I pass in from Objective-C (with UIWebView's stringByEvaluatingJavaScript... | <p>Aside from changing CSS properties in javascript by call stringByEvaluatingJavaScriptFromString: there is probably no supported way to do it in the official SDK. UIWebView is very limited compared to WebView on the desktop.</p>
| 35,296 |
<p>I'm getting confused with the include/exclude jargon, and my actual SVN client doesn't seem to have (or I've been unable to find it easily) a simple option to add or remove a certain type of files for version control.</p>
<p>Let's say for example I've added the entire Visual Studio folder, with its solutions, proje... | <p>You're probably safest excluding particular filetypes, rather than picking those you want to include, as you could then add a new type and not realize it wasn't versioned.</p>
<p>On a per-directory basis, you can edit the <a href="http://svnbook.red-bean.com/en/1.1/ch07s02.html#svn-ch-7-sect-2.3.3" rel="noreferrer"... | <p>If you use Eclipse (I use Spring Tool Suite):</p>
<pre><code>Preferences > Team > Ignored Resources
</code></pre>
<p>click on <code>Add Pattern</code>, write <strong>.DS_Store</strong> (or whatever) and Save.
This acts globally in your workspace.</p>
| 14,878 |
<p>I have a third-party editor that basically comprises a textbox and a button (the DevExpress ButtonEdit control). I want to make a particular keystroke (<kbd>Alt</kbd> + <kbd>Down</kbd>) emulate clicking the button. In order to avoid writing this over and over, I want to make a generic KeyUp event handler that will r... | <p>Here's a demo using generics (error checks omitted):</p>
<pre><code>using System;
using System.Reflection;
static class Program {
private class Sub {
public event EventHandler<EventArgs> SomethingHappening;
}
internal static void Raise<TEventArgs>(this object source, string eventName, TEventAr... | <p>From <em><a href="http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/44b0d573-5c53-47b0-8e85-6056cbae95b0/" rel="nofollow noreferrer">Raising an event via reflection</a></em>, although I think the answer in <a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET" rel="nofollow noreferrer">VB.NET</a>, that... | 24,189 |
<p>Using SSRS 2008 <strong>Express</strong> Edition, is it possible to create a datasource that connects to an external SQL server, or is it artificially limited to same SQL Server and instance of that Reporting Services engine?</p>
| <p>I figured out myself. You can not define an external datasource.</p>
<p>See: <a href="http://msdn.microsoft.com/en-us/library/ms365166.aspx" rel="nofollow noreferrer">MSDN</a></p>
| <p>You could try using a linked server, where you would just call the procedures in the remote (linked) data source.</p>
| 46,391 |
<p>I'm trying to make some types in Django that map to standard Django types. The <a href="http://docs.djangoproject.com/en/dev/howto/custom-model-fields/#howto-custom-model-fields" rel="nofollow noreferrer">custom model field documentation</a> goes into complicated cases; I just want to store a basic Django type from... | <p>I'd do this with a subclass of Django's PositiveIntegerField:</p>
<pre><code>from django.db import models
class Card(object):
"""The ``Card`` class you described."""
...
class CardField(models.PositiveIntegerField):
__metaclass__ = models.SubfieldBase
def get_db_prep_value(self, value):
"... | <p>Don't be afraid to adapt the model classes in Django to your own needs. There's nothing magical about them. And I guess this is the Right Place for this code: In the model.</p>
| 43,448 |
<p>currently, I am looking deeper into testing techniques, even though I am not sure if I still reside in the unittest-land or left it into the land of integration tests already. </p>
<p>Let me elaborate a bit, Given two components A and B and A uses B, then we have a certain "upwards-contract" for B and a certain "do... | <p>You just have to remember that the scale is 00 (no color effect) through FF (full color effect) and the three parts of the triplet are red, green and blue.</p>
<p>000000 is black (i.e., no color) and FFFFFF is white (mixing all three primary colors).</p>
<p>The hard bit is remembering the mixtures, which I use the ... | <p>Well, monitors use an 'RGB' colorscheme. The order of the colors in the hexadecimal number is RRGGBB. So just remembering the name of the colorscheme tells you what goes where. Then you can parse the #RRGGBB as three numbers RR, GG and BB.</p>
<p>The higher the number the brighter that particular component.</p>
<p... | 34,593 |
<p>I've found many Youtube videos of makers upgrading to BLTouch sensor. </p>
<p>I have a Creality CR-10S Pro, so far bed leveling hasn't been an issue (after some days of trial and error). </p>
<p>My question is what are the problems/issues users need to face in order to need (or justify) an upgrade?</p>
| <p>A touch or an inductive/capacitive sensor is useful when you cannot get prints to stick to the build surface because of a skew bed platform/heated plate or if the plate has a bend, large concave or convex area.</p>
<p>Even with such a sensor, you need to provide a bed that is as level (trammed) as you can get. Auto... | <p>I don't know your printer but I don't have BLtouch, and I have to set the height every time because the bed expands with heat.</p>
<p>If you print at variable bed temperature (PLA, ABS, PETg, nylon require different values) then that sensor helps a lot.</p>
<p>BL touch can also speed up bed calibration: you scan t... | 1,639 |
<p>I have the following snippet where I would like to extract code between the <code>{foreach}</code> and <code>{/foreach}</code> using a regular expression:</p>
<pre><code>{foreach (...)}
Some random HTML content <div class="">aklakdls</div> and some {$/r/template} markup inside.
{/foreach}
</code></pre>
... | <p>I came up with this</p>
<pre><code>/(?:{foreach .*?})(.*?)(?:{\/foreach})/gis
</code></pre>
<p>Tested with <a href="http://gskinner.com/RegExr/" rel="nofollow noreferrer">RegExr</a></p>
| <p>If your regex flavor did not support non-greedy matching, the following would do it, but since it does I recommend <a href="https://stackoverflow.com/questions/341531/regular-expression-match-anything-but-full-token#341603">@BaileyP's answer</a>.</p>
<pre><code>\{foreach [^}]*\}((?:.(?!\{/foreach\}))*[^{]?)
</code>... | 44,395 |
<p>Currently, I'm attempting to make multiple beziers have equidistant points. I'm currently using cubic interpolation to find the points, but because the way beziers work some areas are more dense than others and proving gross for texture mapping because of the variable distance. <strong>Is there a way to find point... | <p>distance between P_0 and P_3 (in cubic form), yes, but I think you knew that, is straight forward.</p>
<p>Distance on a curve is just arc length:</p>
<p><a href="http://www.codecogs.com/eq.latex?%5Cint_%7Bt_0%7D%5E%7Bt_1%7D%20%7B%20|P'(t)|%20dt" rel="nofollow noreferrer">fig 1 http://www.codecogs.com/eq.latex?... | <p>I know this is an old question but I recently ran into this problem and created a <code>UIBezierPath</code> extention to solve for an <code>X</code> coordinate given a <code>Y</code> coordinate and vise versa. Written in swift. </p>
<p><a href="https://github.com/rkotzy/RKBezierMath" rel="nofollow">https://github.c... | 3,166 |
<p>The db I am querying from is returning some null values.
How do I safeguard against this and make sure the caller gets some data back.</p>
<p>The code I have is:</p>
<p>Using DataReader</p>
<pre><code> while (dr.Read())
{
vo = new PlacementVO();
vo.PlacementID = dr.GetString... | <p>There is <code>IsDBNull(int ordinal)</code> if you are using ordinals (which you are).</p>
<p>So:</p>
<pre><code>string email = reader.IsDBNull(0) ? null : reader.GetString(0);
</code></pre>
<p>If you are working with string column names, then to use this you'll have to call <code>GetOrdinal</code> first, for exa... | <p>Use a wrapper class to perform this functionality. An example <a href="http://www.codeproject.com/KB/database/NullableReaders.aspx" rel="nofollow noreferrer">can be found here</a>. The <a href="http://www.lhotka.net/cslanet/" rel="nofollow noreferrer">CSLA framework</a> I believe also has this functionality</p>
| 49,388 |
<p>Is it possible to create a parameterized SQL statement that will taken an arbitrary number of parameters? I'm trying to allow users to filter a list based on multiple keywords, each separated by a semicolon. So the input would be something like "Oakland;City;Planning" and the WHERE clause would come out something ... | <p>A basic proof-of-concept... Actual code would be less, but since I don't know your table/field names, this is the full code, so anyone can verify it works, tweak it, etc.</p>
<pre><code>--Search Parameters
DECLARE @SearchString VARCHAR(MAX)
SET @SearchString='Oakland;City;Planning' --Using your example search
DEC... | <p>using a tool like NHibernate will allow you to dynamically construct your queries safely without the need for stored procedures.</p>
<p>Frans Bouma has an <a href="http://weblogs.asp.net/fbouma/archive/2003/11/18/38178.aspx" rel="nofollow noreferrer">excellent article</a> about stored procs vs dynamic sql and what ... | 38,510 |
<p>I'm trying to replace some bespoke message queues with ActiveMQ, and I need to talk to them (a lot) from Perl. ActiveMQ provides a Stomp interface and Perl has Net::Stomp, so this seems like it should be fine, but it's not.</p>
<p>Even if I send a BEGIN command over Stomp, messages sent with SEND are immediately p... | <p>BTW the best place to ask Perl/ActiveMQ/Stomp questions is the <a href="http://activemq.apache.org/discussion-forums.html" rel="nofollow noreferrer">ActiveMQ user forum</a> as lots of Perl-Stomp folks hang out there.</p>
<p>The trick with STOMP transactions is to make sure each message you send or each acknowledgem... | <p>Have a look at <a href="http://search.cpan.org/~huguei/Net-Stomp-Receipt-0.34/lib/Net/Stomp/Receipt.pm" rel="nofollow noreferrer">Net::Stomp::Receipt</a>. It's a subclass of Net::Stomp that implements "return receipts" from the Stomp protocol, and allow you to make sure the correct reception of your message, and abo... | 10,487 |
<p>I'm trying to display a picture in an openGL environment. The picture's origninal dimensions are 3648x2432, and I want to display it with a 256x384 image. The problem is, 384 is not a power of 2, and when I try to display it, it looks stretched. How can I fix that?</p>
| <p>There's three ways of doing this that I know of -</p>
<ul>
<li>The one Albert suggested (resize it until it fits).</li>
<li>Subdivide the texture into 2**n-sized rectangles, and piece them together in some way.</li>
<li>See if you can use <code>GL_ARB_texture_non_power_of_two</code>. It's probably best to avoid it ... | <p><code>ARB_texture_rectangle</code> is probably what you're looking for. It lets you bind to <code>GL_TEXTURE_RECTANGLE_ARB</code> instead of <code>GL_TEXTURE_2D</code>, and you can load an image with non power-of-2 dimensions. Be aware that your texture coordinates will range from [0..w]x[0..h] instead of [0..1]x[0.... | 47,438 |
<p>I'm reading lines of input on a TCP socket, similar to this:</p>
<pre><code>class Bla
def getcmd
@sock.gets unless @sock.closed?
end
def start
srv = TCPServer.new(5000)
@sock = srv.accept
while ! @sock.closed?
ans = getcmd
end
end
end
</code></pre>
<p>If the endpoint termi... | <p>You can use select to see whether you can safely gets from the socket, see following implementation of a TCPServer using this technique.</p>
<pre><code>require 'socket'
host, port = 'localhost', 7000
TCPServer.open(host, port) do |server|
while client = server.accept
readfds = true
got = nil
begin
... | <p>If you believe the <a href="http://www.ruby-doc.org/stdlib/libdoc/socket/rdoc/index.html" rel="nofollow noreferrer">rdoc</a> for ruby sockets, they don't implement <code>gets</code>. This leads me to believe gets is being provided by a higher level of abstraction (maybe the IO libraries?) and probably isn't aware of... | 8,690 |
<p>I am trying to print an existing file to PDF programmatically in Visual Basic 2008.</p>
<p>Our current relevant assets are:
Visual Studio 2008 Professional
Adobe Acrobat Professional 8.0</p>
<p>I thought about getting a sdk like ITextSharp, but it seem like overkill for what I am trying to do especially since we h... | <p>The big takeaway point here is that PDF IS HARD. If there is anything you can do to avoid creating or editing PDF documents directly, I strongly advise that you do so. It sounds like what you actually want is a batch SNP to PDF converter. You can probably do this with an off-the-shelf product, without even openin... | <pre><code>Imports System.Drawing.Printing
Imports System.Reflection
Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim pkInstalledPrinters As String
' Find all printers installed
For Each pkInstalledPrinters In _
... | 19,755 |
<p>I have a solution that is deployed using ClickOnce.</p>
<p>It consists of an application, several referenced assemblies
and a SQL Server Compact database.</p>
<p>There is also an assembly which is not referenced by the main application,
but simply loaded at runtime. This assembly needs to be deployed along with
th... | <p>Alright, I had the SAME problem. Here is how I solve it (might not be the ideal but it works.</p>
<p>1) If your dll or file is inside the solution, I would take it off and re-add it.
2) Go inside the property of your project and select Publish and Application Files. You need to have your file there and to select AG... | <p>Let me get this right: you're using Visual Studio's publish feature to create and deploy the ClickOnce package?</p>
<p>Good luck with that.</p>
<p>You might be better off <a href="http://msdn.microsoft.com/en-us/library/xc3tc5xx.aspx" rel="nofollow noreferrer">building your own ClickOnce packages using Mage</a>.</... | 32,745 |
<p>I have a whole bunch of POV-RAY files from a molecular dynamics simulation with the general name "frameXX.pov" where "XX" is the number of the frame. I want to render them all but I have like 500 so I really don't wanna do it by hand. I'm sure there is a way to do this from the command line or a batch file...what w... | <p>Since your question is 2 months old, I presume your problem will be solved by now. But I want to explain for other SOers interested in the matter.</p>
<p>You can run a POV-Ray script a number of times in a parameterized loop. A typical way to describe the loop parameters is by writing a .ini-file.</p>
<pre><code>I... | <p>Its directly supported apparently:</p>
<p><a href="http://news.povray.org/povray.animations/message/%3C47324428%40news.povray.org%3E/#%3C47324428%40news.povray.org%3E" rel="nofollow noreferrer">http://news.povray.org/povray.animations/message/%3C47324428%40news.povray.org%3E/#%3C47324428%40news.povray.org%3E</a></p... | 48,369 |
<p>I have been looking at the new database server we are setting up for a client and note the database files are set to grow by 1 meg everytime the file is full and the initial size is 100 MB.</p>
<p>I have been considering this breifly and it doesn't sound right. I've checked a few sites on DB considerations and the... | <p>What you've suggested is pretty much spot on. You want the autogrowth to be based on what you expect to see. </p>
<p>A database that has autogrowth of 1Mb everytime it is full will experience huge performance issues, as every time the database is full, whatever transaction is in progress will have to pause until it... | <p>You're generally correct about trying to minimize the number of times when your database has to grow. </p>
<p>I could not give you any exact values but it's always better to have the database file size so big you would only need to grow it occasionally and then it has to grow considerably so you would not have freq... | 24,646 |
<pre><code>$doba = explode("/", $dob);
$date = date("Y-m-d", mktime(0,0,0, $doba[0], $doba[1], $doba[2]));
</code></pre>
<p>The above code turns any date i pass through into 1999-11-30 and i know it was working yesterday. Date is correct when I echo $doba. Anyone have any ideas?</p>
<p>Cheers</p>
| <p>What is the format of <code>$doba</code>? Remember <code>mktime</code>'s syntax goes hour, minute, second, <strong>month, day year</strong> which can be confusing.</p>
<p>Here's some examples:</p>
<pre><code>$doba = explode('/', '1991/08/03');
echo(date('Y-m-d', mktime(0,0,0, $doba[1], $doba[2], $doba[0]);
$doba ... | <p>If you have issues with what jcoby said above, the <a href="http://www.php.net/strptime" rel="nofollow noreferrer">strptime</a>() command gives you more control by allowing you to specify the format as well.</p>
| 30,650 |
<p>This is mostly a theoretical question I'm just very curious about. (I'm not trying to do this by coding it myself or anything, I'm not reinventing wheels.)</p>
<p>My question is how the uppercase/lowercase table of equivalence works for Unicode.</p>
<p>For example, if I had to do this in ASCII, I'd take a characte... | <p>There is a mapping file that contains all the case mappings that have a 1:1 mapping ratio. Usually operating systems/frameworks/libraries support a specific version of Unicode, and since this case mappings file is versioned, you would get the mappings for whichever version of Unicode your particular OS/framework/lib... | <p>The correct answer is a little more complicated, depending on what you are trying to do.</p>
<p>When comparing character strings, for sorting or searching applications, the correct algorithm to use is specified in <a href="http://unicode.org/reports/tr10/" rel="nofollow noreferrer">UTS #10: "Unicode Collation Algor... | 38,102 |
<p>I'm not overly familiar with Tomcat, but my team has inherited a complex project that revolves around a Java Servlet being hosted in Tomcat across many servers. Custom configuration management software is used to write out the server.xml, and various resources (connection pools, beans, server variables, etc) written... | <p>I've had some luck with <a href="http://wrapper.tanukisoftware.org/doc/english/introduction.html" rel="noreferrer">the Java Service Wrapper</a></p>
| <p>It's possible to implement a Windows service in 100% Java code by combining the use of <a href="https://jdk.java.net/panama/" rel="nofollow noreferrer">Foreign Memory and Linker API</a> (previewing from JDK16 upwards) with <a href="https://github.com/openjdk/jextract" rel="nofollow noreferrer">OpenJDK jextract proje... | 9,363 |
<p>I want <code>boost::any_cast<T></code> to only throw an exception when the type of the <code>any</code> doesn't have an implicit conversion to <code>T</code>. The normal behaviour seems to be to throw an exception if the type of the <code>any</code> is not <code>T</code>, regardless of implicit conversions.</p... | <p>Well you can't do it. The <code>any</code> mechanism works like this:</p>
<pre><code>struct base {
virtual ~base() { }
};
template<typename T>
struct concrete_base : base {
T t;
concrete_base(T t):t(t) { }
};
struct my_any {
base * b;
template<typename T>
my_any(T t):b(new con... | <p>any_cast can't do it but if the base and derived types are complete (which they usually are for types that are in a hierarchy) you could implement your own system which converts by means of throw and catch, since throwing a pointer to a derived type can be caught as a base pointer type.</p>
| 41,257 |
<p>When should you use generator expressions and when should you use list comprehensions in Python?</p>
<pre><code># Generator expression
(x*2 for x in range(256))
# List comprehension
[x*2 for x in range(256)]
</code></pre>
| <p><a href="https://stackoverflow.com/a/47792/4518341">John's answer</a> is good (that list comprehensions are better when you want to iterate over something multiple times). However, it's also worth noting that you should use a list if you want to use any of the list methods. For example, the following code won't wo... | <p>For functional programming, we want to use as little indexing as possible. For this reason, If we want to continue using the elements after we take the first slice of elements, islice() is a better choice since the iterator state is saved.</p>
<pre><code>from itertools import islice
def slice_and_continue(sequence... | 7,005 |
<p>Sometimes while developing in Visual Studio IDE, when you use "Find in Files" dialog to find something, the search fails and you will see the following message in the "Find Results" window. </p>
<blockquote>
<p>No files were found to look in. Find stopped progress</p>
</blockquote>
<p>Once this message shows up... | <p>According to <a href="http://connect.microsoft.com/VisualStudio/feedback/details/105511/find-in-files-says-no-files-were-found-to-look-in-find-was-stopped" rel="noreferrer"><strike>this thread</strike></a>:</p>
<blockquote>
<p>Posted by Microsoft on 10/13/2009 at
4:33 PM </p>
<p>Hi all,</p>
<p>Thank y... | <p>To be clear, Press <kbd>Ctrl</kbd> + <kbd>ScrlLck</kbd>, with the Search Window open. That resolved it for me too.</p>
| 32,406 |
<p>I am attempting to write a component in C# to be consumed by classic ASP that allows me to access the indexer of the component (aka default property).</p>
<p>For example:<br>
C# component:</p>
<pre><code>public class MyCollection {
public string this[string key] {
get { /* return the value associated w... | <p>Try setting the DispId attribute of the property to be 0, as described here in the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dispidattribute(VS.71).aspx" rel="nofollow noreferrer">MSDN documentation</a>.</p>
| <p>Thanks to Rob Walker's tip, I got it working by adding the following method and attribute to MyCollection:</p>
<pre><code>[DispId(0)]
public string Item(string key) {
return this[key];
}
</code></pre>
<p>Edit: See <a href="https://stackoverflow.com/a/311946/3195477">this better solution</a> which uses an index... | 38,328 |
<p>How do I discover classes at runtime in the classpath which implements a defined interface?</p>
<p>ServiceLoader suits well (I think, I haven't used it), but I need do it in Java 1.5.</p>
| <p>There's nothing built into Java 1.5 for this. I implemented it myself; it's not too complicated. However, when we upgrade to Java 6, I will have to replace calls to my implementation with calls to <code>ServiceLoader</code>. I could have defined a little bridge between the app and the loader, but I only use it in a ... | <p>There is no reliable way to know what classes are in the classpath. According to its <a href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html" rel="nofollow noreferrer">documentation</a>, ServiceLoader relies on external files to tell it what classes to load; you might want to do the same. The bas... | 31,292 |
<p>I have a couple of header files, which boil down to:</p>
<p>tree.h:</p>
<pre><code>#include "element.h"
typedef struct tree_
{
struct *tree_ first_child;
struct *tree_ next_sibling;
int tag;
element *obj;
....
} tree;
</code></pre>
<p>and element.h:</p>
<pre><code>#include "tree.h"
typedef ... | <p>I think the problem here is not the missing include guard but the fact that the two structures need each other in their definition. So it's a type define hann and egg problem.</p>
<p>The way to solve these in C or C++ is to do forward declarations on the type. If you tell the compiler that element is a structure of... | <p>These are known as "once-only headers." See <a href="http://developer.apple.com/DOCUMENTATION/DeveloperTools/gcc-4.0.1/cpp/Once_002dOnly-Headers.html#Once_002dOnly-Headers" rel="nofollow noreferrer">http://developer.apple.com/DOCUMENTATION/DeveloperTools/gcc-4.0.1/cpp/Once_002dOnly-Headers.html#Once_002dOnly-Headers... | 17,655 |
<p>I'm a C/Python programmer in C++ land working with the STL for the first time.</p>
<p>In Python, extending a list with another list uses the <code>.extend</code> method:</p>
<pre><code>>>> v = [1, 2, 3]
>>> v_prime = [4, 5, 6]
>>> v.extend(v_prime)
>>> print(v)
[1, 2, 3, 4, 5, 6... | <p>From <a href="https://cplusplus.com/reference/vector/vector/insert/" rel="nofollow noreferrer">here</a></p>
<pre><code>// reserve() is optional - just to improve performance
v.reserve(v.size() + distance(v_prime.begin(),v_prime.end()));
v.insert(v.end(),v_prime.begin(),v_prime.end());
</code></pre>
| <p>Simple is better IMHO.</p>
<pre><code>for (auto &val: v_prime)
v.push_back(val);
</code></pre>
<p>When you need to extend the vector <strong>v</strong> multiple times, the simple code above is much faster than repeatedly reserving the space and inserting the other vector. This is because the process of reservi... | 40,408 |
<p>Is there any easy to install/use (on unix) database migration tools like Rails Migrations? I really like the idea, but installing ruby/rails purely to manage my database migrations seems overkill.</p>
| <p>Just use ActiveRecord and a simple Rakefile. For example, if you put your migrations in a <code>db/migrate</code> directory and have a <code>database.yml</code> file that has your db config, this simple Rakefile should work:</p>
<p><strong>Rakefile:</strong></p>
<pre><code>require 'active_record'
require 'yaml'
... | <p>Here is a tool to do this written in Haskell:</p>
<p><a href="http://hackage.haskell.org/package/dbmigrations" rel="nofollow">http://hackage.haskell.org/package/dbmigrations</a></p>
| 12,737 |
<p>Is there some elegant way to add an empty option to a DropDownList bound with a LinqDataSource?</p>
| <p>Here's how to add a value at the top of the list. It can be an empty string, or some text.</p>
<pre><code><asp:DropDownList ID="categories" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="categoriesDataSource" DataTextField="CategoryName" DataValueField="CategoryID" EnableViewState="... | <p>I'd provide an extension method on <code>IEnumerable<string></code> that prepended an item to the beginning of the list:</p>
<pre><code> public static IEnumerable<string> Prepend(this IEnumerable<string> data, string item)
{
return new string[] { item == null ? string.Empty : item }... | 35,138 |
<p>G'day everyone</p>
<p>I'm a newbie to C++ and even more so to Borland Turbo C++ Explorer. I've just encountered this compile error. Any clues as to how to fix it? </p>
<pre><code>[C++ Error] comsvcs.h(3209): E2015 Ambiguity between 'ITransaction' and 'Oledb::ITransaction'
[C++ Error] comsvcs.h(3275): E2015 Ambigui... | <p>It depends, with eclipse 3.4, SWT 3.4 is quite supported with <a href="http://www.eclipse.org/swt/macosx/" rel="nofollow noreferrer">MacOs</a>.</p>
<p><img src="https://www.eclipse.org/swt/macosx/downloaded.png" alt="alt text"></p>
<p>Now, SWT is OS specific, and you may not have the same flexibility than Swing, s... | <p>You might consider <a href="http://javafx.com/" rel="nofollow">JavaFX 2.0</a>. </p>
<p>Still early days but it looks quite promising for the kind of interactive / graphical applications that you might otherwise use Flash for.</p>
| 36,373 |
<p>What does this mean exactly? I'm doing something like this:</p>
<pre><code>File.Copy(@"\\foo\bar\baz.txt", @"c:\test\baz.txt");
</code></pre>
<p>MSDN doesn't describe this exception except in general terms, and googling around just yields tables of error codes.</p>
<p>I've confirmed the source file exists, and I... | <p>Check this article for some information about using symlinks in .Net: "<a href="http://www.codeproject.com/KB/files/JunctionPointsNet.aspx" rel="nofollow noreferrer">Manipulating NTFS Junction Points in .NET</a>".</p>
<p>According to this article:</p>
<blockquote>
<p>"In particular the .NET libraries does
not ... | <p>You will get this error if the destination file already exists. I would also confirm that the account you're running the code under has access to the UNC \foo\bar\baz.txt</p>
| 30,828 |
<p>I have multiple ordered lists. Unfortunately, the order of the items isn't a simple alpha or numeric comparison, otherwise this is trivial. So what I have is something like:</p>
<pre><code>List #1 List #2 List #3
groundhog groundhog easter
mothersday mayday mothersday
midsummer ... | <p>You may want to have a look at <a href="http://en.wikipedia.org/wiki/Topological_sort" rel="nofollow noreferrer">topological sorting</a>. I think it applies quite well to your case.</p>
| <p>I would use the Array.Sort method, with a Comparison method that takes the two strings to be compared, and then checks their presence in any list; any list which has them both, find their relative positions, and return based upon that; if no list has them both, return equality.</p>
<p>The MSN documentation states t... | 35,742 |
<p>What are <strong>real-world</strong> problems where a recursive approach is the natural solution besides depth-first search (DFS)? </p>
<p>(I don't consider <a href="http://en.wikipedia.org/wiki/Tower_of_Hanoi" rel="noreferrer">Tower of Hanoi</a>, <a href="http://en.wikipedia.org/wiki/Fibonacci_number" rel="norefer... | <h2>A real world example of recursion</h2>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/4/44/Helianthus_whorl.jpg" alt="A sunflower"></p>
| <p>A real world example of indirect recursion would be asking your parents if you can have that video game for christmas. Dad: "Ask mom."... Mom: "Ask Dad." [In short, "No, but we dont want to tell you that lest you throw a tantrum."]</p>
| 13,138 |
<p>I'm trying to code opposite action to this:</p>
<pre><code>std::ostream outs; // properly initialized of course
std::set<int> my_set; // ditto
outs << my_set.size();
std::copy( my_set.begin(), my_set.end(), std::ostream_iterator<int>( outs ) );
</code></pre>
<p>it should be something like this:<... | <p>You could derive from the istream_iterator<T>.<br>
Though using <a href="https://stackoverflow.com/questions/250096/how-to-read-arbitrary-number-of-bytes-using-stdcopy#250380">Daemin generator method</a> is another option, though I would generate directly into the set rather than use an intermediate vector.</p... | <p>(Edited: I should have read the question closer...)</p>
<p>While somewhat suspect, you can get approximately the right behavior by having an entry in the file that will "fail" the first loop, then clear the fail bit on the stream and start reading more.</p>
<p>Data, without an explicit size, but like this</p>
<pr... | 31,112 |
<p>I've been playing around with PETG for the first time, and everything seemingly worked right just from the start - clean prints, no stringing, no bed adhesion problems, no warping or dimensional accuracy problems, etc. As expected it prints a lot like PLA, and as expected, it's less brittle/stands up much better to ... | <p>What you describe is usually the result of using a too high of a part cooling fan rotational speed. Like ABS, PETG doesn't require much cooling (if needed at all that is). If you do cool too much, layers and perimeters do not bond optimally (you can get string cheese like printed parts on failure). </p>
<p><strong>... | <p>PETG doesn't bond well if the layers aren't both at a fairly high temperature, as noted by the other answers. As mentioned, try reducing or simply turning off layer cooling. Additionally, try printing at a smaller layer height, or increased line width, to force the layers to bond more effectively. A final solution w... | 1,325 |
<p>I wish to calculate the time it took for an API to return a value.
The time taken for such an action is in the space of nanoseconds. As the API is a C++ class/function, I am using the timer.h to calculate the same:</p>
<pre><code> #include <ctime>
#include <iostream>
using namespace std;
int mai... | <p>What others have posted about running the function repeatedly in a loop is correct.</p>
<p>For Linux (and BSD) you want to use <A href="http://opengroup.org/onlinepubs/007908799/xsh/clock_gettime.html" rel="noreferrer">clock_gettime()</A>.</p>
<pre><code>#include <sys/time.h>
int main()
{
timespec ts;
... | <p><a href="https://plflib.org/nanotimer.htm" rel="nofollow noreferrer">plf::nanotimer</a> is a lightweight option for this, works in Windows, Linux, Mac and BSD etc. Has ~microsecond accuracy depending on OS:</p>
<pre><code> #include "plf_nanotimer.h"
#include <iostream>
int main(int argc, char**... | 34,652 |
<p>how do I pass additional information to the service method returning the collection of items? I'll attempt to explain what I mean, I have 2 text boxes on a form, I need to fill out names, based of a specific account id in a database. so, I need to pass an integer to the getNamesForDropDown method. I couldn't figu... | <p>azam has the right idea- but the signature of the autocomplete method can also have a third parameter:</p>
<p>public string[] yourmethod(string prefixText, int count, string <strong>contextKey</strong>)</p>
<p>you can Split up the results of the contextKey string using Azam's method- but this way you do not have t... | <p>Refer here
<a href="http://www.aspsnippets.com/Articles/ASPNet-AJAX-AutoCompleteExtender-Pass-Additional-Parameter-to-WebMethod-using-ContextKey.aspx" rel="nofollow">http://www.aspsnippets.com/Articles/ASPNet-AJAX-AutoCompleteExtender-Pass-Additional-Parameter-to-WebMethod-using-ContextKey.aspx</a></p>
| 22,910 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.