instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have a collection of non-overlapping rectangles that cover an enclosing rectangle. What is the best way to find the containing rectangle for a mouse click?</p>
<p>The obvious answer is to have an array of rectangles and to search them in sequence, making the search O(n). Is there some way to order them by positio... | <p>You can organize your rectangles in a quad or kd-tree. That gives you O(log n). That's the mainstream method.</p>
<p>Another interesting data-structure for this problem are R-trees. These can be very efficient if you have to deal with lots of rectangles.</p>
<p><a href="http://en.wikipedia.org/wiki/R-tree" rel="no... | <p>Shove them in a <a href="http://en.wikipedia.org/wiki/Quadtree" rel="nofollow noreferrer">quadtree</a>.</p>
| 12,325 |
<p>If I have a Resource bundle property file:</p>
<p>A.properties:</p>
<pre><code>thekey={0} This is a test
</code></pre>
<p>And then I have java code that loads the resource bundle:</p>
<pre><code>ResourceBundle labels = ResourceBundle.getBundle("A", currentLocale);
labels.getString("thekey");
</code></pre>
<p>Ho... | <p>The class you're looking for is java.text.MessageFormat; specifically, calling</p>
<pre><code>MessageFormat.format("{0} This {1} a test", new Object[] {"Yes!!!", "is"});
</code></pre>
<p>or</p>
<pre><code>MessageFormat.format("{0} This {1} a test", "Yes!!!", "is");
</code></pre>
<p>will return</p>
<pre><code>"Y... | <p>There is the class <a href="http://struts.apache.org/1.2.7/api/org/apache/struts/util/MessageResources.html" rel="nofollow noreferrer">org.apache.struts.util.MessageResources</a> with various methods getMessage, some of them take arguments to insert to the actual message.</p>
<p>Eg.:</p>
<pre><code>messageResource... | 9,354 |
<p>My form receives asynchronous callbacks from another object on random worker threads. I have been passing the data to the main thread (where it can be used to update onscreen controls) using delegates as shown below. Performance is dreadful -- once I reach 500 updates per second, the program completely locks up. ... | <p>You probably don't need to update UI on every event, but rather "not as often as X times per second". You may utilize StopWatch or other timing system to collect events during a period of time, and then update UI when appropriate. </p>
<p>If you need to capture all events, collect them in the Queue and fire event e... | <p>It is difficult to tell the exact problem, but some possibilities...</p>
<p>Is your <code>MyStatus</code> object that you are passing to OnStatus derived from <code>MarshalByRefObject</code> (and every object in it)? If not it will be serailized on every call that is marshaled and that can cause a huge performance... | 15,803 |
<p>What I want to do is take a certain stock pattern (defined as a series of x and y coordinates) and compare it against historical stock prices. If I find anything in the historical prices similar to that pattern I defined, I would like to return it as a match.</p>
<p>I'm not sure how to determine how similar two cu... | <p>Compute the total least squares of the residuals (y differences) on each point. This should give you a measure of the geometric fit (how similar they look). You should then be able to set some tolerance for 'similar enough'.</p>
<p>See <a href="http://en.wikipedia.org/wiki/Curve_fitting" rel="nofollow noreferrer">h... | <p>One thought might be to take moving averages of varying time ranges (daily for weeks, months, years; weekly for months, years; etc) and compare them to moving averages now.</p>
<p>The individual averages would also give you an easier comparison.. if consecutive items in the averages are in some normalized form (say... | 49,287 |
<p><em>With the popularity of the Apple iPhone, the potential of the Microsoft <a href="http://www.microsoft.com/surface/index.html" rel="noreferrer">Surface</a>, and the sheer fluidity and innovation of the interfaces pioneered by Jeff Han of <a href="http://link.brightcove.com/services/link/bcpid713271701/bclid713073... | <p>Are you only interested in GUIs? A lot of research has been done and continues to be done on <a href="http://en.wikipedia.org/wiki/Tangible_User_Interface" rel="noreferrer">tangible interfaces</a> for example, which fall outside of that category (although they can include computer graphics). The <a href="http://en... | <p>People are used to WIMP, the other main issue is that most of the other "Cool" interfaces require specialized hardware.</p>
| 23,590 |
<p>If I have a <code>Linq</code> to <code>SQL</code> expression like this:</p>
<pre><code> from subscription in dbContext.Subscriptions
where subscription.Expires > DateTime.Now
select subscription
</code></pre>
<p>I want this to to use the SQL Servers <code>GETDATE()</code> function instead of the time of the m... | <p>Try <a href="http://peteohanlon.wordpress.com/2008/01/11/sql-server-getdate-and-linq-to-sql/" rel="noreferrer">this</a>:</p>
<pre><code>[Function(Name="GetDate", IsComposable=true)]
public DateTime GetSystemDate()
{
MethodInfo mi = MethodBase.GetCurrentMethod() as MethodInfo;
return (DateTime)this... | <p>You could use the ExecuteQuery to gain full control of the sql <a href="http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-expressions.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-expressions.aspx</a> ... | 24,480 |
<p>I've got two PostgreSQL databases that have been created using the same sql file. One of them is 2GB larger. Can someone help me figure out why? I'm sure the databases have the same row counts, tables, indexes, etc.. The databases are on different servers, there are small differences in the postgresql.conf and the P... | <p>You mentioned they are on two different servers and two different versions. Is it possible you have a 32-bit OS and a 64-bit OS differences, or major version changes (because we don't know all the changes that the Postgresql team has made to the underlying data structures on disk). You may find it has something t... | <p>Try using the VACUUM command on PostgreSQL to free formerly used space.</p>
| 27,980 |
<p>When you add a raft in Slic3r, the first layer of the raft prints at the first layer speed. After the raft is finished, the first layer of the print prints at the standard speed. How can I make the first layer of the actual print slow down to the first layer speed?</p>
| <p>This is still work in progress, and here is what I have so far, but first:</p>
<p><strong>A useful alternative for similar problems:</strong></p>
<p>A problem very similar to this would be to use different settings for different parts of a model in Slic3r. For most settings, this can be achieved through <a href="h... | <p>You shouldn't need to. The purpose of a slower first layer is to help with need adhesion. With a raft the first layer of the model is printing on the raft so it can go at regular speeds.</p>
| 111 |
<p>I have a .net 3.5 application running on windows mobile professional that uses sql server ce 3.5 and merge replication with sql server 2005 sp2, it not yet a 1.0 product. Every couple of minutes or so it starts a merge replication using a timer control. I suppose down the line I'll have to have some kind of push s... | <p>I recommend that you don't disable the sleep mode, but instead register events to wake up your device and run your task. Have a look at the Smart Device Framework at <a href="http://www.opennetcf.com" rel="nofollow noreferrer">OpenNetCf</a>. Among others there you will find:</p>
<ul>
<li>Methods for registering wak... | <p>Maybe the answer to this SO question is of help: <a href="https://stackoverflow.com/questions/336771/how-can-i-run-code-on-windows-mobile-while-being-suspended">How can I run code on Windows Mobile while being suspended?</a> It uses the "unattended" mode to keep the application running with screen switched off.</p>
| 35,570 |
<p>I wonder what the best approach is for a situation where I want to have the user type in</p>
<p><a href="http://myserver/something/20" rel="nofollow noreferrer">http://myserver/something/20</a></p>
<p>and get redirected (301 or 302) to </p>
<p><a href="http://someotherserver/applications/something/modules/default... | <p>The only way I have seen to do it without putting the 301 redirects directly into IIS Manager is to use Wildcard mapping</p>
<p><a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5c5ae5e0-f4f9-44b0-a743-f4c3a5ff68ec.mspx?mfr=true" rel="nofollow noreferrer">Link</a></p>
| <p>You might enlist the assistance of ASP.</p>
<p>Create a 404.asp file in your something folder with the content:-</p>
<pre><code><%
Dim id : id = CLng(Mid(Request.QueryString, InStrRev(Request.QueryString, "/")+1))
Response.Redirect "http://someotherserver/applications/something/modules/default.aspx? id=" &am... | 49,054 |
<p>I think most of the SharePoint developers and administrators know that with the change form Firefox 2 to Firefox 3 some functionality of SharePoint have became unavailable. </p>
<p>Especially adding Webparts to a site and using the PeoplePicker don't work anymore with Firefox 3. So I want to know how you deal with ... | <p>I am using IE Tab: <a href="https://addons.mozilla.org/en-US/firefox/addon/1419" rel="nofollow noreferrer">https://addons.mozilla.org/en-US/firefox/addon/1419</a></p>
| <p>What underlying code is it trying to run that Firefox 3 won't support?</p>
<p>Is it just using a bad agent sniffer? that can't handle v3?</p>
<p>The only thing I've encountered in v3 that isn't handled as nice as v2, is the ability to call .focus() on non-form elements. It worked better in v2, v3 seems to have so... | 26,608 |
<p>How compatible is code written under Solaris with Open Solaris ? I would be interested specifically in some kernel modules .</p>
| <p>I think it is hard to quantify software compatibility, but I'd say code written for Solaris is quite forward compatible with OpenSolaris kernel. OpenSolaris source code evolves into what will be Solaris 11, and Sun's commitment to backwards compatibility is quite a fact.</p>
| <p>This is with regard to core OS daemons only and <strong>not</strong> kernel modules, but I've had success compiling OpenSolaris components from source and using the resulting binaries on commercial Solaris just fine. It's obviously easier with a Makefile but I did one manually.</p>
<p>I tried this with a small hand... | 14,172 |
<p>we need reports in our web application and there is the free ReportViewer Control from microsoft (normally used, to display reports from the reporting services). I like the fact, that the Report Format (.RDL-Format) from the ReportViewer is a documented XML-Format. But the functionality is somewhat limited, when the... | <p>This depend on your requirements. I am not clear what your requirements are.</p>
<p>Is your application a web application or a desktop application? </p>
<p>If your application is a <strong>web application</strong> then you can use any other reporting service. I like <strong><a href="http://www.inetsoftware.de/prod... | <p>Sorry, I have forgotten to write, that the application is a asp.net web application</p>
| 17,541 |
<p>Sorry for the Windows developers out there, this solution is for Macs only.</p>
<p>This set of applications accounts for: Usability Testing, Screen Capture (Video and Still), Version Control, Task Lists, Bug Tracking, a Developer IDE, a Web Server, A Blog, Shared Doc Editing on the Web, Team and individual Chat, Em... | <p>You've got most of it covered.</p>
<p>I always add space, time and money for 2 more things you might consider strange.</p>
<ol>
<li><p>A machine set up just like the average user. No development or debugging tools installed. Make it look like someone just bought it from the Apple store. I do image switching but I'... | <p>Change CruiseControl for JetBrains' TeamCity. It's free for up to 20 users, and is more powerful and usable than CruiseControl.</p>
<p>It's easy to set up, and has some amazing features. Such as automatically sending off a build to be performed on any spare computer you may have sitting around in the office.</p>
| 9,805 |
<p>Can I export multiple calendar events into a single iCalendar file? </p>
| <p>You simply make an iCalendar file with multiple VEVENT sections. For example:</p>
<pre><code>BEGIN:VCALENDAR
BEGIN:VEVENT
DESCRIPTION:
DTEND:20071202T220000Z
DTSTAMP:20081124T220920Z
DTSTART:20071202T200000Z
LOCATION:Wherever
STATUS:CONFIRMED
SUMMARY:An event
UID:event-the-first
END:VEVENT
BEGIN:VEVENT
DESCRIPTION:... | <p>Just a note, you need to escape the "," and ";" on strings. Also strlength should be < 75 chars. \r\n should be followed by a white space.</p>
| 40,636 |
<p>My goals are focused on software application development, and maybe web application development, but most likely desktop applications. I'm embarking on a path to becoming more familiar with C/C++, but should I go much lower than that, into assembly? Or would I not have a benefit for my long-term goals?</p>
| <p>I am really surprised to see so many "no" answers to this question. I think you <em>should</em> learn assembly.</p>
<p>I do not expect that you would ever <em>use</em> assembly directly as part of your job. But it does not follow from that that you should not learn it.</p>
<p>Learning assembly will teach you about... | <p>I would not suggest to learn a "modern assembler language". </p>
<p>However knowing a little about <a href="http://en.wikipedia.org/wiki/MOS_Technology_6510" rel="nofollow noreferrer">MOS 6510</a> Assembler and browsing through the disassembled <a href="http://en.wikipedia.org/wiki/C64" rel="nofollow noreferrer">C6... | 4,761 |
<p>We've got some code that uses LoadLibrary and GetProcAddress to implement a plugin architecture for one of our products. We ensure that the DLL about to be loaded is signed with our code-signing key.</p>
<p>We're changing the plugin architecture to use COM instead. Is there a way to enforce code-signing (preferably... | <p>You need to do this at the DLL level using the Authenticode API. The standard API is called <a href="http://msdn.microsoft.com/en-us/library/aa388208.aspx" rel="nofollow noreferrer">WinVerifyTrust()</a> and there are samples documented there. There's another <a href="http://support.microsoft.com/kb/323809" rel="no... | <p>I don't think you can do this directly, but you could look up the DLL that the CLSID uses in the registry and check its signature before issuing the CoCreateInstance call.</p>
| 21,554 |
<p>I have a query that works on Postgresql 7.4 but not on Postgresql 8.3 with same database.</p>
<p>Query:</p>
<pre><code>SELECT * FROM login_session WHERE (now()-modified) > timeout;
</code></pre>
<p>Gets the following error:</p>
<pre><code>ERROR: operator does not exist: interval > integer
LINE 1: ...ELECT... | <p>There are a lot of changes between 7.4 and 8.3. Some of the most drastic were the removal of some automatic casts.</p>
<p>I suppose the "timeout" is in seconds? If so you could change the query to:</p>
<pre><code>SELECT
*
FROM
login_session
WHERE
(CURRENT_TIMESTAMP - modified) > (timeout * '1 sec'::... | <pre><code>CREATE OR REPLACE FUNCTION intToInterval(arg integer)
RETURNS interval AS
$BODY$
BEGIN
return CAST( arg || ' seconds' AS interval );
END;
$BODY$
LANGUAGE 'plpgsql';
CREATE CAST (integer AS interval)
WITH FUNCTION intToInterval ( integer )
AS IMPLICIT;
</code></pre>
<p>(Assuming timeo... | 36,987 |
<p>Is there any good way to unit test destructors? Like say I have a class like this (contrived) example:</p>
<pre><code>class X
{
private:
int *x;
public:
X()
{
x = new int;
}
~X()
{
delete x;
}
int *getX() {return x;}
const int *getX() const {return x;}
};
</... | <p>There may be something to be said for dependency injection. Instead of creating an object (in this case an int, but in a non-contrived case more likely a user-defined type) in its constructor, the object is passed as a parameter to the constructor. If the object is created later, then a factory is passed to the cons... | <p>Some compilers will overwrite deleted memory with a known pattern in debug mode to help detect access to dangling pointers. I know Visual C++ used to use 0xDD, but I haven't used it in a while.</p>
<p>In your test case, you can store a copy of x, let it go out of scope and make sure that *x == 0xDDDDDDDD:</p>
<pre... | 40,200 |
<p>I'm interested in how java organizes memory and executes code (like what gets put in the stack or the heap), from the start of main, to assigning variables, calling functions, passing parameters, returning values, instantiating objects, etc. Has anyone found a good, beginner-friendly article/reference on it?</p>
| <p>The canonical reference is the <a href="http://java.sun.com/docs/books/jvms/" rel="nofollow noreferrer">JVM spec</a>. However, different JVMs can implement the spec in different ways. You can also check out the open source Java platform implementation, <a href="http://openjdk.java.net/" rel="nofollow noreferrer">O... | <p>I don't know exactly how they execute their bytecode, but I found this <a href="http://www.ibm.com/developerworks/ibm/library/it-haggar_bytecode/" rel="nofollow noreferrer">link</a> describing java's bytecode. I am not sure if it helps, but at least it's something to start on.</p>
<p>Quote:</p>
<blockquote>
<p>T... | 12,460 |
<p>I'm looking to find records in a table that match a specific number that the user enters. So, the user may enter 12345, but this could be 123zz4-5 in the database.</p>
<p>I imagine something like this would work, if PHP functions worked in MySQL.</p>
<pre><code>SELECT * FROM foo WHERE preg_replace("/[^0-9]/&qu... | <p>I realise that this is an ancient topic but upon googling this problem I couldn't find a simple solution (I saw the venerable agents but think this is a simpler solution) so here's a function I wrote, seems to work quite well.</p>
<pre><code>DROP FUNCTION IF EXISTS STRIP_NON_DIGIT;
DELIMITER $$
CREATE FUNCTION STRI... | <p>How big is table with foo? If it is small, and speed really doesn't matter, you might pull the row ID and foo, loop over it using the PHP replace functions to compare, and then pull the info you want by row number.</p>
<p>Of course, if the table is too big, this won't work well.</p>
| 36,518 |
<p>One of the problems I have come across having complex tasks on the browser is with automatic timeouts.</p>
<p>Currently our site has a sliding expiration of 30 minutes. Normally, this isn't a problem because we use asp.net and most of the time the users update one or two fields and then submit the form. This obviou... | <p>We recently went through this in my organization. Although it is not the best solution, and hitting the right session across multiple browser windows is rough, we put a countdown timer on our page, included a button that just went back and hit the server to restart the session, and also provided the user with a Jav... | <p>Ah, the age old problem of not wanting to increase the session time because of higher memory usage. </p>
<p>One answer is to also set a cookie that expires after more like a day that will tell the system to still remember the user. That's what eBay does, among others.</p>
| 6,854 |
<p>i am using the apache commons httpclient in a lotus notes java agent and it works fine. BUT when establishing a proxy connection the log will be spamed with the following line :</p>
<pre><code>[INFO] AuthChallengeProcessor - basic authentication scheme selected
</code></pre>
<p>Do you know how to disable the integ... | <p>you should be able to set the logging level to something less spammy. there are a few default <a href="http://hc.apache.org/httpclient-3.x/logging.html" rel="nofollow noreferrer">logging options</a>, so it depends on the logging method you chose.</p>
<p>it sounds like your logging level is set to "debug" or "info" ... | <p>It is possible to set a AuthPolicy Priority :</p>
<p>... snipp....</p>
<pre><code>client.getState().setProxyCredentials(
new AuthScope(conParm.getProxyServer(), conParm.getProxyPort()),
new UsernamePasswordCredentials(conParm.getProxyUser(), conParm.getProxyP... | 24,406 |
<p>Looking at what's running and nothing jumps out. </p>
<p>Thanks!</p>
| <p>It should be w3wp.exe</p>
<p>EDIT: In line with Darren's comment, you should also check the "Show processes from all users" in Task Manager if that is where you are looking for the process.</p>
| <p>Furthermore if you need to look at the .NET/unmanaged stack just donwload <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer">Process Explorer</a> and look at your w3wp.exe processes to examine memory and other stats without having to do a remote/local debugging (just lo... | 6,873 |
<p>Pretty much every other editor that isn't a vi descendant (vim, cream, vi-emu) seems to use the emacs shortcuts (<kbd>ctrl</kbd>+<kbd>w</kbd> to delete back a word and so on)</p>
| <p>Early software was often modal, but usability took a turn at some point, away from this style. </p>
<p>VI-based editors are total enigmas -- they're the only real surviving members of that order of software. </p>
<p>Modes are a no-no in usability and interaction design because we humans are fickle mammals who cann... | <p>Though not really answering your question, there used to be a "modal like" way to write Japanese on cell phones before :
The first letter you hit was a conson let's say K, and then, and then the next key you would hit would have the role of a conson. (Having two conson in a row is impossible in Japanese)</p>
<p>Tho... | 3,522 |
<p>I have a javascript function that manipulates the DOM when it is called (adds CSS classes, etc). This is invoked when the user changes some values in a form. When the document is first loading, I want to invoke this function to prepare the initial state (which is simpler in this case than setting up the DOM from t... | <p>Definitely use <code>onload</code>. Keep your scripts separate from your page, or you'll go mad trying to disentangle them later.</p>
| <p>My take is the former becauase you can only have 1 window.onload function, while inline script blocks you have an <em>n</em> number.</p>
| 6,224 |
<p>Ok, one for the SO hive mind...</p>
<p>I have code which has - until today - run just fine on many systems and is deployed at many sites. It involves threads reading and writing data from a serial port. </p>
<p>Trying to check out a new device, my code was swamped with 995 ERROR_OPERATION_ABORTED errors calling G... | <p>How are you setting over the OVERLAPPED structure before the ReadFile? - I always zero them (other than the hEvent, obviously), which is perhaps part superstition, but I have a feeling that it's caused me a problem in the past.</p>
<p>I'm afraid blaming the driver (if it's non-MS and not just a tiny tweak from the ... | <p>in addition to zeroing the OVERLAPPED, you might also check how you're setting olap.hEvent, that is, what are your arguments to CreateEvent? If you're creating an event that's pre-signalled (i.e. the third argument to CreateEvent is TRUE) I would expect an immediate return. Also, don't forget that if you specify m... | 39,534 |
<p>I know I can programatically make the taskbar item for a particular window start flashing when something changes, but is there any way I can stop it from flashing either programatically after a certain period of time or at least is there a keyboard shortcur I can give to my users to somehow stop the flashing?</p>
| <p>The <a href="http://msdn.microsoft.com/en-us/library/ms679347%28VS.85%29.aspx" rel="noreferrer">FlashWindowEx</a> function which controls the flashing takes a <a href="http://msdn.microsoft.com/en-us/library/ms679348%28VS.85%29.aspx" rel="noreferrer">FLASHWINFO</a> struct which has a uCount field to control how many... | <p>@thomas -- Amazingly Microsoft's own <a href="http://msdn.microsoft.com/en-us/library/aa511446.aspx" rel="nofollow noreferrer">Windows Vista User Experience Guidelines</a> agree with you ...</p>
<blockquote>
<p>While having a background window flash its taskbar button is better than having it automatically come t... | 4,910 |
<p>I was wondering if there's a way to see the output of any command,
straight inside vim, rather than first redirecting it into a file and
then opening that file.</p>
<p>E.x. I need something like
$ gvim < <code>diff -r dir1/ dir2/</code></p>
<p>This gives ambiguous redirect error message</p>
<p>I just want to... | <pre><code>diff file1 file2 | vim -R -
</code></pre>
<p>The <code>-R</code> makes it read-only so you don't accidentally modify the input (which may or may not be your desired behavior). The single dash tells <code>vim</code> to reads its input over standard input. Works for other commands, too.</p>
| <p>One of the most simple and convenient ways is to do it like this:</p>
<pre><code>vimdiff -R <file1> <file2>
</code></pre>
<p>Again the '-R' flag is to open it for read-only mode to avoid any accidental changes.</p>
| 28,561 |
<p>I'm tryint to post to a ADO.NET Data Service but the parameters seems to get lost along the way.</p>
<p>I got something like:</p>
<pre><code>[WebInvoke(Method="POST")]
public int MyMethod(int foo, string bar) {...}
</code></pre>
<p>and I make an ajax-call using prototype.js as:</p>
<pre><code>var args = {foo: 4,... | <p>WCF and ASMX webservices tend to be a bit choosey about the request body, when you specify args the request is usually encoded as a form post i.e. foo=4&bar=test instead you need to specify the javascript literal:-</p>
<pre><code> new Ajax.Request(baseurl + 'MyMethod', {
method: 'POST',
postBo... | <p>If you want to use POST, you need to specify the parameters to be wrapped in the request in WebInvoke attribute unless the parameters contains on object (e.g. message contract). This makes sense since there is no way to serialize the parameters without wrapped in either json or xml.</p>
<p>Unwrapped which is not XM... | 27,829 |
<p>Is it just that <code>nvarchar</code> supports multibyte characters? If that is the case, is there really any point, other than storage concerns, to using <code>varchars</code>?</p>
| <p>An <code>nvarchar</code> column can store any Unicode data. A <code>varchar</code> column is restricted to an 8-bit codepage. Some people think that <code>varchar</code> should be used because it takes up less space. I believe this is not the correct answer. Codepage incompatabilities are a pain, and Unicode is the ... | <p>varchar is suitable to store non-unicode which means limited characters. Whereas nvarchar is superset of varchar so along with what characters we can store by using varchar, we can store even more without losing sight of functions.</p>
<p>Someone commented that storage/space is not an issue nowadays. Even if space i... | 17,404 |
<p>I have been playing around with the bed for a while and I still can't get the first layer to stick properly. I think I am getting the bed leveled good, I use the paper method. But yet I find myself with the filament lifting off and getting pulled away with the nozzle or some balling in rare situations. </p>
<p>I us... | <p>Masking tape (and blue painter's tape) is coated with a wax-based release agent in order to prevent the tape sticking to itself on the roll. This release agent must be removed with an organic solvent in order to obtain good adhesion. Isopropyl (rubbing) alcohol is good for this. Acetone will also work, but it is a m... | <p>I'll go out on a limb and suggest that, while your bed may be well-levelled, the Z-axis zero might be off. A difference of 10-20 microns can be the difference between strong adhesion to the bed/tape and having your print float away. If your first layer doesn't get "squashed flat" a bit by the nozzle, your extruder... | 800 |
<p>What is the right place to store program data files which are the same for every user but have to be writeable for the program? What would be the equivalent location on MS Windows XP? I have read that C:\ProgramData is not writeable after installation by normal users. Is that true? How can I retrieve that directory ... | <p><code>SHGetFolderPath()</code> with CSIDL of <code>CSIDL_COMMON_APPDATA</code>.</p>
<p>Read more at <a href="http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx</a></p>
<p>If you need the path in a batch file, you can al... | <p>You can use:</p>
<pre><code>CString strPath;
::SHGetSpecialFolderPath(NULL, strPath.GetBuffer(1024), CSIDL_COMMON_APPDATA, FALSE);
</code></pre>
| 15,975 |
<p>What is the best method for including a CSS or Javascript file for a specific node in Drupal 6.</p>
<p>I want to create a page on my site that has a little javascript application running, so the CSS and javascript is specific to that page and would not want to be included in other page loads at all.</p>
| <p>I'd advise against using <code>hook_nodeapi</code> for that. Adding CSS and Javascript is related to layout so <code>hook_nodeapi</code> is not the place for it: use themeing. This way, you <em>can</em> override those files when you're going to develop a new theme. Doing that with the nodeapi approach would be a bit... | <p>You can have a custom template for that node (node-needsjs.tpl.php) which calls the javascript. That's a little cleaner than using PHP right in the node body, and makes changes to content easier in the future.</p>
<p><strong>EDIT:</strong> I don't think I was very clear above. You want to name the template file n... | 8,702 |
<p>We have had issues with Mootools not being very backward compatible specifically in the area of drag and drop functionality. I was wondering if anyone has had any similar problems with jQuery not being backward compatible. We are starting to use it quite heavily and are thinking about upgrading to a newer version to... | <p>jQuery seems to be nicely backward compatible. I have been using it for more than a couple of years now through several versions of the core and have not had issues when upgrading except a few minor ones with some plugins. I would say that the core seems to be fine but if you're using a lot of plugins you might ru... | <p>In my experience, jQuery 1.x has been very backwards-compatible until version 1.9.</p>
<blockquote>
<p>The jQuery 1.x line had major changes as of jQuery 1.9.0. We strongly recommend that you also use the jQuery Migrate plugin if you are upgrading from pre-1.9 versions of jQuery or need to use plugins that haven'... | 35,609 |
<p>I have a model that looks like this:</p>
<pre><code>class Category(models.Model):
name = models.CharField(max_length=60)
class Item(models.Model):
name = models.CharField(max_length=60)
category = models.ForeignKey(Category)
</code></pre>
<p>I want select count (just the count) of items for each categ... | <p>Here, as I just discovered, is how to do this with the Django 1.1 aggregation API:</p>
<pre><code>from django.db.models import Count
theanswer = Item.objects.values('category').annotate(Count('category'))
</code></pre>
| <p>How's this? (Other than slow.)</p>
<pre><code>counts= [ (c, Item.filter( category=c.id ).count()) for c in Category.objects.all() ]
</code></pre>
<p>It has the advantage of being short, even if it does fetch a lot of rows.</p>
<hr>
<p>Edit.</p>
<p>The one query version. BTW, this is often <em>faster</em> than... | 42,491 |
<p>This is pretty weird.</p>
<p>I have my Profiler open and it obviously shows that a stored procedure is called. I open the database and the SP list, but the SP doesn't exist. However, there's another SP whose name is the same except it has a prefix 'x'</p>
<p>Is SQL Server 2005 mapping the SP name to a different on... | <p>In general, when you know an object exists because it's been used in a query, and you can't find it in the object tree in Management Studio, you can do this to find it. </p>
<pre><code>select *
from sys.objects
where name = 'THE_NAME_YOU_WANT'
</code></pre>
<p>I just checked, and it works with Synonyms.</p>
| <p>Possibly silly questions, but just in case... have you refreshed the SP list? Have you checked for a stored procedure of that name under a different owner? If you created the stored procedure without specifying the owner then it could be in the list under your ownership (or not at all if the list is filtered to only... | 11,075 |
<p>Solution<br/>
-- WorkflowProject<br/>
-- Workflow1<br/>
-- Workflow2<br/>
-- WebProject (WAP)<br/>
-- App_Data<br/>
-- MyDatabase.vdb3<br/>
-- MyWebService.asmx<br/>
-- Web.Config<br/></p>
<p>Ok, so.. that's the basic "outline" of t... | <p><a href="http://linux.die.net/man/7/sem_overview" rel="noreferrer">POSIX semaphore</a> is the way to go. Since you want to share the same semaphore across processes, you need to use a named semaphore.:</p>
<blockquote>
<p>A named semaphore is identified by a
name of the form /somename. Two
processes can opera... | <p>I assume that </p>
<blockquote>
<p>...that is shared between two applications?</p>
</blockquote>
<p>means that you want these two things to be running as separate processes? If that's not true, and they are running as a single process (with multiple threads), then the suggestions of semaphores and mutexes are th... | 30,935 |
<p>How do I get a list of all files (and directories) in a given directory in Python?</p>
| <p>This is a way to traverse every file and directory in a directory tree:</p>
<pre><code>import os
for dirname, dirnames, filenames in os.walk('.'):
# print path to all subdirectories first.
for subdirname in dirnames:
print(os.path.join(dirname, subdirname))
# print path to all filenames.
f... | <pre><code>#import modules
import os
_CURRENT_DIR = '.'
def rec_tree_traverse(curr_dir, indent):
"recurcive function to traverse the directory"
#print "[traverse_tree]"
try :
dfList = [os.path.join(curr_dir, f_or_d) for f_or_d in os.listdir(curr_dir)]
except:
print "wrong path name/d... | 14,673 |
<p>I have two BufferedImages I loaded in from pngs. The first contains an image, the second an alpha mask for the image.</p>
<p>I want to create a combined image from the two, by applying the alpha mask. My google-fu fails me.</p>
<p>I know how to load/save the images, I just need the bit where I go from two Buffered... | <p>I'm too late with this answer, but maybe it is of use for someone anyway. This is a simpler and more efficient version of Michael Myers' method:</p>
<pre><code>public void applyGrayscaleMaskToAlpha(BufferedImage image, BufferedImage mask)
{
int width = image.getWidth();
int height = image.getHeight();
... | <p>Actually, I've figured it out. This is probably not a <em>fast</em> way of doing it, but it works:</p>
<pre><code>for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
Color c = new Color(image.getRGB(x, y));
Color maskC = new Color(mask.getRGB(x, y));
... | 27,352 |
<p>This code:</p>
<pre><code>#include <iostream>
int main( int, char **argv )
{
std::cout << 1.23e45 << std::endl;
}
</code></pre>
<p>prints </p>
<blockquote>
<p>1.23e+045</p>
</blockquote>
<p>when compiled with MS Visual Studio 2003, and</p>
<blockquote>
<p>1.23e+45</p>
</blockquote>
<p>on ... | <p>I don't think this is possible with standard manipulators. (if it is, I'd love to be corrected and learn how)</p>
<p>Your only remaining option is creating a streambuf yourself, and intercepting all exponent numbers that go to the stream, reformat them by hand, and pass them on to the underlying stream.</p>
<p>See... | <p>Look into the iomanip header. It has a lot of width-precision etc... functionality.</p>
| 33,715 |
<p>A few questions on MS Access databases -</p>
<p>Size: Are there limits to the size of an access database? The reason i ask is that we have an access database that has a few simple tables. The size of the db is about 1GB. When I do a query on it, i see it taking over 10 minutes to run. </p>
<p>With proper indexi... | <p>You will get many varied answers here, but in MY OPINION access is just not there as a scalable solution. It doesn't handle multi-user situations very well, as you start to approach 1Gb in size, stability starts to become a MAJOR concern, and in reality it just doesn't have the performance.</p>
<p>In regards to tr... | <p>Personally, I've found the 'usable' limit to be in the couple hundred megabyte range.</p>
<p>Access is designed and meant for small databases. For large ones, ie ones beyond just something you and a couple-few people are using, you should be looking at a "real" RDBMS like SQL Server, ORacle, DB2, MySQL, etc.</p>
<... | 21,691 |
<p>How to configure JAXB unmarshaller so it will trim leading and trailing whitespaces from strings?</p>
<p>For instance let's consider a simple binding between a Java bean and XML using JAXB annotations:</p>
<pre><code>@XmlRootElement(name="bean")
class Bean {
@XmlElement(required=true)
String name;
@XmlEle... | <p>Use a custom <em>Adapter</em> class. I was thinking that <a href="http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/adapters/NormalizedStringAdapter.html" rel="noreferrer">NormalizedStringAdapter</a> would do the work but it's only for unmarshaling and it doesn't do what you want anyway.</p>
<pre><cod... | <p>To remove leading and trailing whitespaces during unmarshalling you can use an adapter <a href="https://docs.oracle.com/javase/8/docs/api/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.html" rel="nofollow noreferrer">CollapsedStringAdapter</a> (since Java 1.6).</p>
<blockquote>
<p>Built-in XmlAdapter to h... | 46,863 |
<p>My team is currently trying to automate the deployment of our .Net and PHP web applications. We want to streamline deployments, and to avoid the hassle and many of the headaches caused by doing it manually.</p>
<p>We require a solution that will enable us to:</p>
<pre><code>- Compile the application
- Version ... | <p>Thank you all for your kind suggestions. We checked them all out, but after careful consideration we decided to roll our own with a combination of CruiseControl, NAnt, MSBuild and MSDeploy.</p>
<p>This article has some great information:
<a href="http://dougrohm.com/blog/post/2006/01/29/Integrating-MSBuild-with-Cru... | <p><a href="http://www.nongnu.org/fab/" rel="nofollow noreferrer">Fabric</a>. Seems small, simple, procedural. Written in Python, since Ruby is a no-no (why?).</p>
| 6,778 |
<p>I'm currently installing and configuring an open source project on a test server. I've been well trained to use source control, and I want to make sure everything I do is managed properly (both for me, the sole dev/admin, and for future maintaners). The open source project is available as a source download or by svn... | <p>Ok, first of all, if one of the installer/updater products out on the market fits your need, you should probably use those.
That being said, I've had the pleasure of building a system like this myself not long ago.
Yes, our installer/updater included two parts on the client side so that:</p>
<p>~ Part A would conne... | <p>Ten years ago I wrote an auto updater (not in .NET), but the gist of it was that the application had a version id that was checked on startup. In this case the app queried a database table that had the current version and if the running version was less than the current version, the user was prompted to download the... | 31,120 |
<p>In my code, I am using JavaScript to fire off an <code>window.open()</code> event on an ASPX page. I´m outputting a file in the <code>Page_Load()</code> event of this page:</p>
<pre><code>Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "";
Response.ContentType = "application/o... | <p>Make the polling thread call back to the main form using <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.invoke.aspx" rel="nofollow noreferrer">Control.Invoke</a> or <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.begininvoke.aspx" rel="nofollow noreferrer"... | <p>You should invoke the function from your main window:</p>
<pre><code> void MyWorkerThread() {
while (Connected) {
Thread.Sleep(1000);
if (NewMessage) {
ShowNewForm();
}
}
}
void ShowNewForm() {
if (this.InvokeRequired) { // this... | 48,985 |
<p>I have form that displays several keywords (standard set of choice lists that changes rarely). There are about 4 such fields and each have about 20 choices or so.</p>
<p>I'm thinking if caching the keywords will be helpful for performance / best practice? Is there a strategy for determining when to cache?</p>
| <p>To start, you ought to look at the cost for those keywords. </p>
<ul>
<li>Are you querying them from the database, each one individually?
<li>Are you querying them as a group?
<li>Are they constants that you're simply writing out?
</ul>
<p>In general when optimizing (IE caching) look for items that are going ... | <p>Use a lazy initialized singeton with appropriate field to store your data. eg of this singleton at
<a href="http://www.yoda.arachsys.com/csharp/singleton.html" rel="nofollow noreferrer">http://www.yoda.arachsys.com/csharp/singleton.html</a></p>
<p>You can have the property to be of type</p>
<pre><code>"IDictionar... | 44,290 |
<p>I need to parse Visual Studio automatically generated XML documentation to create a report. I decided to use XSLT but I'm very new to it and need help.
Common template is:</p>
<pre><code><doc>
<members>
<member name="F:MyNamespace">
<summary>Some text</summary>
</mem... | <p><strong>In case you're performing the transformation with Visual Studio X</strong>, where X is not greater than 2008, this would be processed by an <a href="http://www.w3.org/TR/xslt" rel="noreferrer"><strong>XSLT 1.0</strong></a> processor (.NET's <a href="http://msdn.microsoft.com/en-us/library/system.xml.xsl.xslc... | <p>These functions are from XPath 2.0 in XSLT 2.0. .NET XSLT is at 1.0 and your xsl namespace reflects that.</p>
| 44,263 |
<p>I have a test project using MbUnit and TestDriven.Net. </p>
<p>If I right-click on an individual test method and say "Run Tests" the test runs successfully. Same thing if I click on a file name in the solution explorer. </p>
<p>However, if I right click and say run tests on the project or the solution, TestDriv... | <p>I had once similar problem. The problem was that I forgot to declare my test class with <em>public</em> modifier.</p>
| <p>You need to add testing attributes for your favorite testing framework. TestDriven picks up these attributes by reflection in order to know what tests to run.</p>
<p>For example, using NUnit.Framework - each test class needs [TextFixture] and each test method needs [Test]</p>
<p>Here's an <a href="http://www.nuni... | 11,287 |
<p>On my <strong>Windows XP</strong> machine Visual Studio 2003 2005 and 2008 all complain that I cannot start debugging my <strong>web application</strong> because I must either be a member of the Debug Users group or of the Administrators group. So, I am an Administrator and I added Debug Users just in case, and it s... | <p>Which users and/or groups are in your "Debug programs" right (under User Rights Assignment)? Maybe that setting got overridden by group policy (Daniel's answer), or just got out of whack for some reason. It should, obviously, include the "Debug Users" group.</p>
| <p>You could try running "<code>VsJITDebugger.exe -p <PID></code>" on the command line. I've had a simalar situation and been able to debug the application using the above.</p>
<p>"<code>VsJITDebugger.exe /?</code>" will show you all the options.</p>
<p>The PID can be found either in the task manager (view->Sel... | 3,281 |
<p>Let's say I want to run a .NET application on a machine where the .NET framework is not available; Is there any way to compile the application to native code?</p>
| <p>Microsoft has an article describing how you can <a href="http://msdn.microsoft.com/en-us/library/ht8ecch6(VS.71).aspx" rel="noreferrer">Compile MSIL to Native Code</a></p>
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx" rel="noreferrer">Ngen</a>.</p>
<blockquote>
<p>The Native Imag... | <p>I think it's not possible. You will need to distribute .NET FW as well. If you want to compile .NET app to native code, use NGen <a href="http://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx" rel="nofollow noreferrer">tool</a></p>
| 6,769 |
<p>in a DB2 trigger, I need to compare the value of a CLOB field.
Something like:</p>
<pre><code>IF OLD_ROW.CLOB_FIELD != UPDATED_ROW.CLOB_FIELD
</code></pre>
<p>but "!=" does not work for comparing CLOBs.</p>
<p>What is the way to compare it?</p>
<p><strong>Edited to add:</strong></p>
<p>My trigger needs to do s... | <p>Calculate the md5 (or other) hash of the clobs and then compare these. Initial calculation will be slow but comparison is fast and easy. This could be a good method if the bulk of your data doesn't change very often.</p>
<p>One way to calculate md5 is through a java statement in your trigger. Save these in the same... | <p>Does DB2 use <code>!=</code> for not equals? The ANSI SQL Standard uses <code><></code> for not equals.</p>
| 13,585 |
<p>I'm developing a little project plan and I came to a point when I need to decide what local databse system to use.</p>
<p>The input data is going to be stored on webserver (hosting - MySQL DB). The idea is to build a process to download all necessary data (for example at midnight) and process them. However, there a... | <p>I want to say Microsoft Sql 2005 Express, as it (almost) comes as the obvious choice when developing in .NET. </p>
<p>But it all depends on what previous db skills you have. If you already know MySql and as you already said, the data should be exported back to MySql. Why not use MySql all the way?</p>
| <p>For what you described, definitely MS SQL Server. Good performance, good tools. Free.</p>
| 20,973 |
<p>I'm doing a addin system where the main app loads assemblies Addin1.dll and Addin2.dll on runtime in new AppDomain's.</p>
<p>However, in case that Addin1.dll is signed (strong name) with my key and Addin2.dll is not, I want to be able to only load Addin1.dll and reject Addin2.dll.</p>
<p>I'm suspecting that it nee... | <p>Look into the <a href="http://msdn.microsoft.com/en-us/library/ms145229.aspx" rel="nofollow noreferrer" title="Assembly.Load Method (AssemblyName, Evidence)">Assembly.Load</a> method that takes an Evidence parameter. You can find an example of how to create an evidence from your public key <a href="http://msdn.micr... | <p>You can implment a DomainManager and base your load/block decision's on whatever you like. I answered a somewhat related question <a href="https://stackoverflow.com/questions/439173/message-pumps-and-appdomains/924653#924653">here.</a></p>
| 48,384 |
<p>I want to loop over the elements of an HTML form, and store the values of the <input> fields in an object. The following code doesn't work, though:</p>
<pre><code>function config() {
$("#frmMain").children().map(function() {
var child = $("this");
if (child.is(":checkbox"))
thi... | <p>don't think you need quotations on this:</p>
<pre><code>var child = $("this");
</code></pre>
<p>try:</p>
<pre><code>var child = $(this);
</code></pre>
| <p>This is the simplest way to loop through a form accessing only the form elements. Inside the each function you can check and build whatever you want. When building objects note that you will want to declare it outside of the each function.</p>
<p>EDIT
<a href="http://jsfiddle.net/UDD7E/6/" rel="nofollow">JSFIDDLE<... | 20,538 |
<p>This is a multiple question for the same pre-processing instruction.</p>
<h2>1 - <> or "" ?</h2>
<p>Apart from the info found in the MSDN:</p>
<p><a href="https://msdn.microsoft.com/en-us/library/36k2cdd4.aspx" rel="noreferrer" title="#include Directive (C-C++)">#include Directive (C-C++)</a></p>
<p>... | <p>After reading all answers, as well as compiler documentation, I decided I would follow the following standard.</p>
<p>For all files, be them project headers or external headers, always use the pattern:</p>
<pre><code>#include <namespace/header.hpp>
</code></pre>
<p>The namespace being at least one directory de... | <p>I use <...> from system header file (stdio, iostreams, string etc), and "..." for headers specific to that project. </p>
| 21,609 |
<p>Suppose you create a generic Object variable and assign it to a specific instance. If you do GetType(), will it get type Object or the type of the original class?</p>
| <p>Yes.</p>
<p>You can also do:</p>
<pre><code>object c = new FooBar();
if(c is FooBar)
Console.WriteLine("FOOBAR!!!");
</code></pre>
| <p>Calling GetType() will call the ACTUAL type. If you want to know the base type, you can call GetType().BaseType</p>
| 40,780 |
<p>Where is the best tutorial for getting Ruby On Rails working on a windows box with Mongrel? I'm a complete novice at server management, so the more detailed the better!</p>
| <p>You can follow this tutorial, it will get you setup you can actually manage your Mongrel server as a Windows service (start/stop/restart, start on boot, manage programatically etc etc):</p>
<p><a href="http://noobonrails.blogspot.com/2006/06/how-to-setup-mongrel-as-native-windows.html" rel="nofollow noreferrer">How... | <p><a href="http://bitnami.org/stack/rubystack" rel="nofollow">Rubystack</a> is a free Windows Rails installer that we keep up to date and includes Mongrel support out of the box </p>
| 5,613 |
<p>I'm just getting started with Custom User Controls in C# and I'm wondering if there are any examples out there of how to write one which accepts nested tags?</p>
<p>For example, when you create an <code>asp:repeater</code> you can add a nested tag for <code>itemtemplate</code>.</p>
| <p>I wrote a <a href="https://robertwray.co.uk/blog/describing-asp-net-control-properties-declaratively" rel="nofollow noreferrer">blog post</a> about this some time ago. In brief, if you had a control with the following markup:</p>
<pre><code><Abc:CustomControlUno runat="server" ID="Control1">
<Children&... | <p>My guess is you're looking for something like this? <a href="http://msdn.microsoft.com/en-us/library/aa478964.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa478964.aspx</a></p>
<p>Your tags were removed or are invisible, so can't really help you there.</p>
| 14,719 |
<p>What are the Win32 APIs to use to programically delete files and folders? </p>
<p><strong>Edit</strong></p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa363915(VS.85).aspx" rel="noreferrer">DeleteFile</a> and <a href="http://msdn.microsoft.com/en-us/library/aa365488(VS.85).aspx" rel="noreferrer">RemoveDir... | <p>I think you want <a href="http://msdn.microsoft.com/en-us/library/aa363915(VS.85).aspx" rel="noreferrer">DeleteFile</a> and <a href="http://msdn.microsoft.com/en-us/library/aa365488(VS.85).aspx" rel="noreferrer">RemoveDirectory</a></p>
| <p>For C++ programming, if you're willing to work with third-party libraries,
<a href="http://www.boost.org/doc/libs/1_48_0/libs/filesystem/v3/doc/reference.html#remove_all" rel="nofollow">boost::filesystem::remove_all(yourPath)</a>
is much simpler than SHFileOperation.</p>
| 26,231 |
<p>How can I create a Delphi TSpeedButton or SpeedButton in C# 2.0?</p>
| <p>Using a Button and setting the TabStop property to false only works when tapping through the form...</p>
<p>If you need (as I did) a button that does not get selected when clicking on it, there is only one way I have found to do it.</p>
<p>The way I did it, was to subclass the Button class and in the constructor c... | <p>Does <a href="https://stackoverflow.com/questions/148729/how-to-setchangeremove-focus-style-on-a-button-in-c">this</a> help? Looks like you would have to handle the OnPaint event, and not take focus...</p>
| 27,550 |
<p>This PHP code...</p>
<pre><code>207 if (getenv(HTTP_X_FORWARDED_FOR)) {
208 $ip = getenv('HTTP_X_FORWARD_FOR');
209 $host = gethostbyaddr($ip);
210 } else {
211 $ip = getenv('REMOTE_ADDR');
212 $host = gethostbyaddr($ip);
213 }
</code></pre>
<p>Throws this warning...</p>
<... | <p>on php.net it says the following:</p>
<blockquote>
<p>The function <code>getenv</code> does not work if your Server API is ASAPI (IIS).
So, try to don't use <code>getenv('REMOTE_ADDR')</code>, but <code>$_SERVER["REMOTE_ADDR"]</code>.</p>
</blockquote>
<p>Did you maybe try to do it with <code>$_SERVER</code>?<... | <p>First of all, getenv() takes a string as parameter. On line 207, you should use:</p>
<pre><code>getenv('HTTP_X_FORWARDED_FOR')
</code></pre>
<p>...instead of:</p>
<pre><code>getenv(HTTP_X_FORWARDED_FOR)
</code></pre>
<p>Secondly, accessing these variables through $_SERVER is a more reliable solution, as getenv()... | 21,018 |
<p>I'm getting a strange error from <code>g++</code> 3.3 in the following code:</p>
<pre><code>#include <bitset>
#include <string>
using namespace std;
template <int N, int M>
bitset<N> slice_bitset(const bitset<M> &original, size_t start) {
string str = original.to_string<ch... | <p>The selected answer from <a href="https://stackoverflow.com/questions/231868/c-two-or-more-data-types-in-declaration#231904">CAdaker</a> solves the problem, but does not explain <strong>why</strong> it solves the problem.</p>
<p>When a function template is being parsed, lookup does not take place in dependent types.... | <p>The following compiled for me (using gcc 3.4.4):</p>
<pre><code>#include <bitset>
#include <string>
using namespace std;
template <int N, int M>
bitset<N> slice_bitset(const bitset<M> &original, size_t start)
{
string str = original.to_string();
string newstr = str.subst... | 28,701 |
<p>In a discussion about motors with a friend who used to work in the robotics industry, he told me that he despised stepper motor systems, as every stepper based system he had worked on required a bunch of hacky software fixes to make the system perform to the required level.</p>
<p>He said that servo motor based sys... | <p>You can get "stepper replacement" servo drives that supposedly put all the needed control in the drive, and accept ordinary stepper inputs. Those should make the servo-drive a "drop-in" option on anything that uses stepper drives.</p>
<p>That said, I've seen an affordable CNC router system based on steppers turned ... | <p>I think using these technologies is possible, and may be better than stepper motors, but by using these you loose the main advantages of the steppers : the simplicity and the cost.</p>
<p>When you use steppers, you assume your motors are strong enough to don't loose any step, and you "just" command them. Steppers a... | 564 |
<p>I am looking for a template engine to use client side. I have been trying a few like jsRepeater and jQuery Templates. While they seem to work OK in FireFox they all seem to break down in IE7 when it comes down to rendering HTML tables.</p>
<p>I also took a look at MicrosoftAjaxTemplates.js (from <a href="http://www... | <p>Check out Rick Strahl's post <a href="http://www.west-wind.com/weblog/posts/509108.aspx" rel="noreferrer">Client Templating with jQuery</a>. He explores jTemplates, but then makes a better case for John Resig's <a href="http://ejohn.org/blog/javascript-micro-templating/" rel="noreferrer">micro-templating solution</... | <p>There is also an rewrite of PURE by beebole - jquery pure html templates - <a href="https://github.com/mpapis/jquery-pure-templates" rel="nofollow">https://github.com/mpapis/jquery-pure-templates</a></p>
<p>It should allow a lot more automatic rendering mostly using jquery selectors, whats more important it does no... | 20,537 |
<p>I'm trying to integrate running Fitnesse tests from MSBuild im my nightly build on TFS.</p>
<p>In an attempt to make it self contained I would like to start the seleniumRC server only when it's needed from fitness.</p>
<p>I've seen that there is a "Command Line Fixture" but it's written in java can I use that?</p>... | <p>I think you might be able to. You can call any process easily in MSBuild using the <a href="http://msdn.microsoft.com/en-us/library/x8zx72cd.aspx" rel="nofollow noreferrer"></a> task. However, the problem with doing this is that the exec task will wait for the Selinium process to finish before continuing, which is ... | <p>What about writing a simple .NET app that does a Process.Start("selenumRC commandline") which gets run by your build script?</p>
<p>If you aren't too far down the Selenium route; might I suggest that you look at similar .NET browser automation tools; specifically WatiN or ArtOfTest. The "stacks" in these are compl... | 12,544 |
<p>There's one thing I haven't found in <a href="https://www.rfc-editor.org/rfc/rfc2616" rel="nofollow noreferrer">RFC 2616</a> ("Hypertext Transfer Protocol -- HTTP/1.1") and that's a "canonical" name for a request/response pair. Is there such thing?</p>
<p><a href="https://www.rfc-editor.org/rfc/r... | <p>The spec calls them "exchanges" (or "request/response exchanges").</p>
<p>Per <a href="https://www.rfc-editor.org/rfc/rfc2616#section-1.4" rel="nofollow noreferrer">section 1.4, "Overall Operation"</a>:</p>
<blockquote>
<p>In HTTP/1.0, most implementations used a new connection for each... | <p>Transaction, yes, or "A singe HTTP Request consists of one HTTP Request message and one HTTP Response message."</p>
| 42,127 |
<p>How do I run a batch file each time windows boots up also I need to run it in the back ground(without that command window getting displayed)? I use Windows Xp.
My actuall requirement is I want to start the Tracd server using the command line commands whenever Windows boots up.</p>
| <p>Add your program in the <a href="http://www.bleepingcomputer.com/tutorials/tutorial44.html" rel="noreferrer">registry</a>:</p>
<p>Run - These are the most common startup locations for programs to install auto start from. By default these keys are not executed in Safe mode. If you prefix the value of these keys with... | <p>There's also <a href="http://www.ntwind.com/software/utilities/hstart.html" rel="nofollow noreferrer">hstart</a>, a third party program that's worked well for my needs. It's maintained too. The last version was released on July 7, 2010.</p>
| 36,870 |
<p>SQL Server 2000 doesn't seem to support the xml based .xlsx file types. Besides converting the file to a 97-2003 file type, how else can I achieve this? </p>
| <p>If you have Excel 2007, you might also have Access 2007.</p>
<p>You can create an Access 2007 Access Data Project (.adp) file. Connect this to your SQL 2000 database. Then use the Access 2007 import table function to get the Excel 2007 data.</p>
| <p>If you have Excel 2007, you might also have Access 2007.</p>
<p>You can create an Access 2007 Access Data Project (.adp) file. Connect this to your SQL 2000 database. Then use the Access 2007 import table function to get the Excel 2007 data.</p>
| 22,860 |
<p>At run time I want to dynamically build grid columns (or another display layout) in a WPF ListView. I do not know the number and names of the columns before hand.</p>
<p>I want to be able to do:<br/>
MyListView.ItemSource = MyDataset;<br/>
MyListView.CreateColumns();</p>
| <p>i'd try following approach:</p>
<p>A) you need to have the list box display grid view - i believe this you've done already <br>
B) define a style for GridViewColumnHeader:</p>
<pre><code> <Style TargetType="{x:Type GridViewColumnHeader}" x:Key="gridViewColumnStyle">
<EventSetter Event="... | <p>Have a <strong>DataTemplateselector</strong> to select one of the predefined templates(Of same DataType) and apply the selector on to the ListView. You can have as many DataTemplates with different columns.</p>
| 15,277 |
<p>I need to learn ADO.NET to build applications based on MS Office. I have read a good deal about ADO.NET in the MSDN Library, but everything seems rather messy to me.</p>
<p>What are the basics one must figure out when using ADO.NET? I think a few key words will suffice to let me organize my learning.</p>
| <p>There are three key components (assuming ur using SQL server):</p>
<ul>
<li><code>SQLConnection</code></li>
<li><code>SqlCommand</code></li>
<li><code>SqlDataReader</code></li>
</ul>
<p>(if you're using something else, replace <code>Sql</code> with "Something", like <code>MySqlConnection</code>, <code>OracleComman... | <p>Another way of getting a command object is to call <code>connection.CreateCommand()</code>. </p>
<p>That way you shouldn't have to set the <code>Connection</code> property on the command object. </p>
| 2,618 |
<p>After making some changes in my models (eg. new field in a model and a new model) what is the best way of reflecting these changes to my populated database? </p>
<hr>
<p>PS: I wanted to see many solutions in one place rated. Apparently more solutions are already listed <a href="https://stackoverflow.com/questions/... | <p>I've asked a similar question <a href="https://stackoverflow.com/questions/35991/altering-database-tables-in-django">here</a> and got quite a few answers.</p>
<p>There are quite a lot of ways of doing it, like manually doing the dumping and reloading with SQL, using fixtures or using one of the "emerging" schema-ev... | <p><code>Perform these steps in order may help you</code>:</p>
<p><code>For more details,</code></p>
<p>clickhere: <a href="http://south.readthedocs.org/en/latest/" rel="nofollow">http://south.readthedocs.org/en/latest/</a></p>
<p>1) <code>python manage.py schemamigration apps.appname --initial</code></p>
<p>Above ... | 21,201 |
<p>At the company I work for we have a "Utility" project that is referenced by pretty much ever application we build. It's got lots of things like NullHelpers, ConfigSettingHelpers, Common ExtensionMethods etc.</p>
<p>The way we work is that when we want to make a new project, we get the latest version of the project ... | <p>That's exactly what we're doing. We have a Utility project which has some non project specific useful functions. We increase the version manually (minor), build the project in Release version, sign it and put it to a shared location.</p>
<p>People then use the specific version of the <em>library</em>.</p>
<p>If so... | <p>I've had the <em>EXACT</em> same issue!</p>
<p>I used to use project references, but it all seems to go bad, when as you say, you have many projects referencing it.</p>
<p>I now compile to a DLL, and set the CopyLocal property for the DLL reference to false after the first build (otherwise I find it can override s... | 6,268 |
<p>I would like to see the specific style elements that are used in the default stylesheet for the various browsers. Do the browsers have an actual file based stylesheetss that I locate on my system and read? If so, what are the default locations of those files? If not, where I can find this information?</p>
| <ul>
<li><a href="http://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css" rel="noreferrer">From the WebKit source respository</a> </li>
<li><a href="http://css-class.com/test/css/defaults/UA-style-sheet-defaults.htm" rel="noreferrer">Unofficial Grid of several major browsers</a></li>
</ul>
| <p>This may be tangential to the heart of your question, but if I'm right in guessing why you want this information, you may want to check out <a href="http://browsershots.org/" rel="nofollow noreferrer">browsershots.org</a>.</p>
<blockquote>
<p>Browsershots makes screenshots of your Web design in different browsers... | 26,352 |
<p>I asked <a href="https://stackoverflow.com/questions/188043/security-crytography-stupid-challege-response-protocol">here</a> about a protocol that I was asked to implement, and how secure it was. Since it seemed clear from the very beginning that it was shit. Being so I ask:</p>
<p>Can you guys point me to some ver... | <p>Check out <a href="http://en.wikipedia.org/wiki/Challenge-response_authentication" rel="nofollow noreferrer">Challenge Response Authentication</a></p>
<ul>
<li>Server includes a random challenge string in the login form</li>
<li>When you login, javascript hashes the password, and then hashes that with the challenge... | <p>If your protocol runs on TCP you can just write the authentication in clear and then wrap the communication with SSL. For example, if you are using port 1234 for your protocol, you can then close that port on the server and let clients tunnel it with SSH. This can be done programmatically and it is a very very commo... | 23,112 |
<p>I'm trying to check, using an automated discovery tool, when JAR files in remote J2EE application servers have changed content. Currently, the system downloads the whole JAR using WMI to checksum it locally, which is slow for large JARs.</p>
<p>For UNIXy servers (and Windows servers with Cygwin), I can just log in ... | <p>I'd imagine its one of:</p>
<ul>
<li><p>Eclipse doesn't want to display non-C++ resources in the tree (I've had problems with this)</p></li>
<li><p>You don't have "Preferences > C/C++ > Indexer > Index All Files" enabled.</p></li>
<li><p>You want to use the "Full C/C++ Indexer" rather than the "Fast C/C++ Indexer"<... | <p>The CDT parser/indexer won't recognize weird extensions like that. The only thing you can do is to define macros on the Paths and Symbols property page to trick the parser. Try creating macros for <code>$hdr</code>, <code>$end</code> and <code>$src</code> that have empty bodies. That way the preprocessor will remove... | 8,295 |
<p>I am interested in mastering prefetch-related functions such as</p>
<p>_mm_prefetch(...)</p>
<p>so when I perform operations that loop over arrays, the memory bandwidth is fully utilized. What are the best resources for learning about this?</p>
<p>I am doing this work in C using GCC 4 series on an intel linux pl... | <p>There is also an excellent paper by Ulrich Drepper, <a href="http://people.redhat.com/drepper/cpumemory.pdf" rel="noreferrer">What Every Programmer Should Know About Memory</a>. He covers prefetching, plus many other topics dealing with memory performance optimization. It was released in Nov 2007, and is extremely r... | <p>This <a href="http://gcc.gnu.org/projects/prefetch.html" rel="nofollow noreferrer">site</a> contains details on gcc prefetch support including prefetch options and functions and includes details on several architectures including Intel. The gcc <a href="http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/" rel="nofollow no... | 30,455 |
<p>No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.</p>
<pre><code>IDLE 1.2.2 ==== No Subprocess ====
>>> import unittest
>>>
>>> class Test(unittest.TestCase):
def testA(self):
... | <p>Your example is exiting on my install too. I can make it execute the tests and stay within Python by changing</p>
<pre><code>unittest.main()
</code></pre>
<p>to</p>
<pre><code>unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromTestCase(Test))
</code></pre>
<p>More information is available <a href=... | <pre><code>try:
sys.exit()
except SystemExit:
print('Simple as that, but you should really use a TestRunner instead')
</code></pre>
| 10,516 |
<p>Assuming String a and b:</p>
<pre><code>a += b
a = a.concat(b)
</code></pre>
<p>Under the hood, are they the same thing?</p>
<p>Here is concat decompiled as reference. I'd like to be able to decompile the <code>+</code> operator as well to see what that does.</p>
<pre><code>public String concat(String s) {
... | <p>No, not quite.</p>
<p>Firstly, there's a slight difference in semantics. If <code>a</code> is <code>null</code>, then <code>a.concat(b)</code> throws a <code>NullPointerException</code> but <code>a+=b</code> will treat the original value of <code>a</code> as if it were <code>null</code>. Furthermore, the <code>conc... | <p>Note that <code>s.concat("hello");</code> would result in a <code>NullPointereException</code> when s is null. In Java, the behavior of the + operator is usually determined by the left operand:</p>
<p><code>System.out.println(3 + 'a'); //100</code></p>
<p>However, Strings are an exception. If either operan... | 6,987 |
<p>When writing my own auto updater, is there a general framework that I should be following?</p>
<p>A while ago I was reading up on how one should create a 'boot strapper' that will load first before the main application (since a running appilation can't be updated due to file locks etc.)</p>
<p>So any tips/best pra... | <p>Ok, first of all, if one of the installer/updater products out on the market fits your need, you should probably use those.
That being said, I've had the pleasure of building a system like this myself not long ago.
Yes, our installer/updater included two parts on the client side so that:</p>
<p>~ Part A would conne... | <p>Ten years ago I wrote an auto updater (not in .NET), but the gist of it was that the application had a version id that was checked on startup. In this case the app queried a database table that had the current version and if the running version was less than the current version, the user was prompted to download the... | 31,119 |
<p>In javascript, is there an equivalent of String.indexOf() that takes a regular expression instead of a string for the first first parameter while still allowing a second parameter ?</p>
<p>I need to do something like </p>
<pre><code>str.indexOf(/[abc]/ , i);
</code></pre>
<p>and</p>
<pre><code>str.lastIndexOf(/[... | <p>Instances of the <code>String</code> constructor have a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search" rel="noreferrer"><code>.search()</code> method</a> which accepts a RegExp and returns the index of the first match.</p>
<p>To start the search from a parti... | <p>Well, as you are just looking to match the position of a <em>character</em> , regex is possibly overkill. </p>
<p>I presume all you want is, instead of "find first of these this character" , just find first of these characters. </p>
<p>This of course is the simple answer, but does what your question sets out to do... | 34,494 |
<p>We're working now on the design of a new API for our product, which will be exposed via web services. We have a dispute whether we should use strict parameters with well defined types (my opinion) or strings that will contain XML in whatever structure needed. It is quite obvious that ideally using a strict signature... | <p>That code will work fine, you just don't have ServiceFactory in your classpath. Ie, Java can't load that class. Try including a dependency on cfusion.jar from C:\CFusionMX7\lib.</p>
| <p>That code will work fine, you just don't have ServiceFactory in your classpath. Ie, Java can't load that class. Try including a dependency on cfusion.jar from C:\CFusionMX7\lib.</p>
| 33,744 |
<p>I have a concept that's roughly 18"x30" (about 457x762 mm), and I just realized that the Makerbot and similar printers only allow dimensions around the size of a piece of paper. What are other options? Are there large 3D printers I just don't know about? I looked up TMC injection mold, but couldn't find anything on ... | <p>As Trish states, a print service would appear to be your best bet. Building a printer large enough may work out costing more than the print service, especially if it is only for one print of a proof of concept.</p>
<p>Anecdotally, I visited a 3D Printing shop in Bangkok, <a href="http://jwh3dprinting.com/english/ou... | <h1>Yes<sup>If you have the money</sup></h1>
<p>Either read <a href="https://all3dp.com/1/best-large-3d-printer-large-format-scale-3d-printers/#section-best-large-3d-printers-under-1000" rel="nofollow noreferrer">here</a> or look at the ones I plucked out of that list to show you:</p>
<p>First of all, 3D printers on FD... | 1,054 |
<p>I want to discover all xml files that my ClassLoader is aware of using a wildcard pattern. Is there any way to do this?</p>
| <p>It requires a little trickery, but here's an relevant <a href="http://bill.burkecentral.com/2008/01/14/scanning-java-annotations-at-runtime/" rel="noreferrer">blog entry</a>. You first figure out the URLs of the jars, then open the jar and scan its contents. I think you would discover the URLs of all jars by looking... | <p>Well, it is not from within Java, but</p>
<p><code>jar -tvf jarname | grep xml$</code></p>
<p>will show you all the XMLs in the jar.</p>
| 16,128 |
<p>I'm having trouble figuring out how to get the testing framework set up and usable in <strong>Visual Studio 2008</strong> for <code>C++</code> presumably with the built-in unit testing suite.</p>
<p>Any links or tutorials would be appreciated.</p>
| <p><a href="http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle" rel="nofollow noreferrer">This page</a> may help, it reviews quite a few C++ unit test frameworks:</p>
<ul>
<li>CppUnit </li>
<li>Boost.Test</li>
<li>CppUnitLite </li>
<li>NanoCppUnit</li>
<li>Unit++</li>
<li>CxxTest</li>
</ul>
<p>... | <p>I've used <a href="http://cppunit.sourceforge.net/cppunit-wiki" rel="nofollow noreferrer">CppUnit</a> with VS2005 and Eclipse. The wiki is very thorough (especially if you are familiar with JUnit).</p>
| 2,532 |
<p>Has anyone started making Unicode Apps or converting Existing Apps into Unicode?</p>
<p>How are you tweaking Firebird to have the least problems, especially the CHARSET attribute?</p>
<p>Is there any problem encountered? Any thing else that I should be aware of?</p>
<p>I'm just preparing myself so that I get less... | <p>it's the "edges" of the app where you'll see the issues (file reading/writing, DLLs, storage, etc).</p>
<p>ini files: i migrated from TIniFile (ansi only) to TMemIniFile (don't forget to call UpdateFile).</p>
<p>as for the Firebird part of your question, i don't have any experience with that.</p>
| <p>As far as I know the only part of Delphi 2009 that is not unicode enabled are the console functions like readln and writeln. The rest should be fully unicode.</p>
| 30,781 |
<p>I've been trying to create a Windows Media Player plugin in Visual Studio 2008, and am having great difficulty finding the correct template. MSDN provides advice <a href="http://msdn.microsoft.com/en-us/library/bb262076(VS.85).aspx" rel="nofollow noreferrer">here</a>, but it does not appear to be relevant to VS2008.... | <p>Generics doesn't natively support arithmetic. However, it can be done with .NET 3.5, <a href="http://www.pobox.com/~skeet/csharp/miscutil/usage/genericoperators.html" rel="nofollow noreferrer">like so</a>. The Operator class is part of <a href="http://www.yoda.arachsys.com/csharp/miscutil/" rel="nofollow noreferrer"... | <p>Marc Gravell has done a lot of work on making generic maths viable. See the <a href="http://www.yoda.arachsys.com/csharp/miscutil/usage/genericoperators.html" rel="nofollow noreferrer">MiscUtil</a>
and <a href="http://www.yoda.arachsys.com/csharp/genericoperators.html" rel="nofollow noreferrer">general article abou... | 20,699 |
<p>Besides the fact that <code>$_REQUEST</code> reads from cookies, are there any reasons why I should use <code>$_GET</code> and <code>$_POST</code> instead of <code>$_REQUEST</code>? What are theoretical and practical reasons for doing so?</p>
| <p>I use $_REQUEST when I just want certain data from the user to return certain data.</p>
<p>Never use $_REQUEST when the request will have side effects. Requests that produce side effects should be POST (for semantic reasons, and also because of basic CSRF stuff, a false img tag can hit any GET endpoint without a u... | <p>Here's one I've just found: <a href="https://stackoverflow.com/questions/107683/when-and-why-should-request-be-used-instead-of-get-post-cookie"><a href="https://stackoverflow.com/questions/107683/when-and-why-should-request-be-used-instead-of-get-post-cookie">When and why should $_REQUEST be used instead of $_GET / ... | 48,084 |
<p>I'm just wondering if the same thread is used for each session, or if its dangerous to count on a particular thread between requests. What I'm getting at, is can I use thread static storage?</p>
| <p>The short answer is yes. The thread used for a request is returned to the thread pool and can be used to service other requests. They are NOT session specific, and to answer your second question, you should never count on a particular thread being available for subsequent requests on a particular session. Because of... | <blockquote>
<p>What I'm getting at, is can I use thread static storage?</p>
</blockquote>
<p>Or if you only want the data to stay around for the lifetime of a single request, you can store it in HttpContext.Current.Items</p>
| 25,090 |
<p>I have a two dimensional array that I need to load data into. I know the width of the data (22 values) but I do not know the height (estimated around 4000 records, but variable).</p>
<p>I have it declared as follows: </p>
<pre><code>float[,] _calibrationSet;
....
int calibrationRow = 0;
While (recordsToRead)... | <p>You can't use an array.
Or rather, you would need to pick a size, and if you ended up needing more then you would have to allocate a new, larger, array, copy the data from the old one into the new one, and continue on as before (until you exceed the size of the new one...)</p>
<p>Generally, you would go with one of... | <p>I generally use the nicer collections for this sort of work (List, ArrayList etc.) and then (if really necessary) cast to T[,] when I'm done.</p>
| 7,334 |
<p>Here's my setup: a Mac, running OS X Tiger. Windows XP running in a virtual machine (Parallels). Windows XP has my Mac home directory mapped as a network drive.</p>
<p>I have two files in a directory of my Mac home directory:</p>
<h3>foo.py</h3>
<pre><code>pass
</code></pre>
<h3>test.py</h3>
<pre><code>import... | <p>Add import sys; print sys.path to the start of test.py. See what it prints out in the failing case. If "." isn't on the list, that may be your problem.</p>
| <p>As a random guess: are the permissions on foo.py accessable from the windows client? (eg try opening with notepad from the virtual machine).</p>
<p>If that's OK, try running:</p>
<pre><code>python -v -v test.py
</code></pre>
<p>and looking at the output (alternatively, set PYTHONVERBOSE=2). This should list all ... | 31,439 |
<p>Is it better to have all the private members, then all the protected ones, then all the public ones? Or the reverse? Or should there be multiple private, protected and public labels so that the operations can be kept separate from the constructors and so on? What issues should I take into account when making this... | <p>I put the public interface first, but I didn't always do this. I used to do things backwards to this, with private, then protected, then public. Looking back, it didn't make a lot of sense.</p>
<p>As a developer of a class, you'll likely be well acquainted with its "innards" but users of the class don't much care... | <p>Depends entirely on your preference. There is no "the right way".</p>
<p>When doing C++ in my own pet projects I personally keep convention that I put access modifier before each member or method declaration.</p>
| 39,752 |
<p>What is the C# version of VB.net's InputBox?</p>
| <p>Add a reference to <code>Microsoft.VisualBasic</code>, <code>InputBox</code> is in the <code>Microsoft.VisualBasic.Interaction</code> namespace:</p>
<pre><code>using Microsoft.VisualBasic;
string input = Interaction.InputBox("Prompt", "Title", "Default", x_coordinate, y_coordinate);
</code></pre>
<p>Only the first... | <p>There is no such thing: I recommend to write it for yourself and use it whenever you need.</p>
| 12,256 |
<p>I'm planning to create a data structure optimized to hold assembly code. That way I can be totally responsible for the optimization algorithms that will be working on this structure. If I can compile while running. It will be kind of dynamic execution. Is this possible? Have any one seen something like this?</p>
<p... | <p>It is possible. Dynamic code generation is even mainstream in some areas like software rendering and graphics. You find a lot of use in all kinds of script languages, in dynamic compilation of byte-code in machine code (.NET, Java, as far as I know Perl. Recently JavaScript joined the club as well).</p>
<p>You also... | <p>In 99% of the cases, the difference in performance is negligible. The main advantage of classes is that the code produced by OOP is better and easier to understand than procedural code.</p>
<p>I'm not sure in what language you're coding - note that in C# the major difference between classes and structs is that stru... | 13,384 |
<p>What is the series of steps needed to securely verify a ssl certificate? My (very limited) understanding is that when you visit an https site, the server sends a certificate to the client (the browser) and the browser gets the certificate's issuer information from that certificate, then uses that to contact the iss... | <p>Here is a very simplified explanation:</p>
<ol>
<li><p>Your web browser downloads the web server's certificate, which contains the public key of the web server. This certificate is signed with the private key of a trusted certificate authority.</p></li>
<li><p>Your web browser comes installed with the public keys ... | <p>The client has a pre-seeded store of SSL certificate authorities' public keys. There must be a chain of trust from the certificate for the server up through intermediate authorities up to one of the so-called "root" certificates in order for the server to be trusted.</p>
<p>You can examine and/or alter the list of ... | 22,822 |
<p>I have a properties file in java, in which I store all information of my app, like logo image filename, database name, database user and database password.</p>
<p>I can store the password encrypted on the properties file. But, the key or passphrase can be read out of the jar using a decompiler.</p>
<p>Is there a way... | <p>There are multiple ways to manage this. If you can figure out a way to have a user provide a password for a keystore when the application starts up the most appropriate way would be to encrypt all the values using a key, and store this key in the keystore. The command line interface to the keystore is by using keyto... | <p>You could make a separate properties file (outside the jar) for passwords (either direct DB password or or key passphrase) and not include that properties file with the distribution. Or you might be able to make the server only accept that login from a specific machine so that spoofing would be required.</p>
| 12,796 |
<p>I am working on an application and one design approach involves extremely heavy use of the <code>instanceof</code> operator. While I know that OO design generally tries to avoid using <code>instanceof</code>, that is a different story and this question is purely related to performance. I was wondering if there is an... | <p>Modern JVM/JIT compilers have removed the performance hit of most of the traditionally "slow" operations, including instanceof, exception handling, reflection, etc.</p>
<p>As Donald Knuth wrote, "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root o... | <p>You're focusing on the wrong thing. The difference between instanceof and any other method for checking the same thing would probably not even be measurable. If performance is critical then Java is probably the wrong language. The major reason being that you can't control when the VM decides it wants to go collec... | 12,919 |
<p>I was trying the following example, but with external URLs:
<a href="http://android-developers.blogspot.com/2008/09/using-webviews.html" rel="nofollow noreferrer">Using WebViews</a></p>
<p>The example shows how to load an HTML file from assets folder (<code>file:// url</code>) and display it in a WebView. </p>
<p>... | <p>I found out the answer myself.</p>
<p>The permission name is android.permission.INTERNET.</p>
<p>Adding following line to the AndroidManifest.xml (nested directly in tag) did the trick:</p>
<pre><code><uses-permission android:name="android.permission.INTERNET"></uses-permission>
</code></pre>
<p>The... | <p>It's a user permission:</p>
<pre><code><uses-permission android:name="android.permission.INTERNET" />
</code></pre>
| 23,937 |
<p>Actually I try to find a subclass of InputStream which is also Serializable. I think that doesn't exist. Since both Interfaces have many sublclasses it is hard to find one that is a subclass of both.</p>
<p>Until now I haven't found anything to help my search in Eclipse. Anyone ideas?</p>
<p>Edit: I understand now... | <p>Serializing an InputStream is not a very viable solution. To illustrate this, imagine if you have an InputStream from a socket and you serialize that. Before you deserialize it, the socket is closed. Now when you actually do deserialize it, the resource has vanished and you have a nasty exception in your hands. </p>... | <p>I am not sure that you can do that in fact (or at least in an easy way...).</p>
<p>Anyway, I like the "<a href="http://eclipse-tools.sourceforge.net/implementors/index.html" rel="nofollow noreferrer">Open Implementation</a>" plugin that allows you to right-click on a method of a class or an interface (or the class ... | 30,528 |
<p>I'd like to develop a few applications for a device I own which has Windows Mobile 2003 on it, but I don't care to hunt down a copy of Visual Studio 2003 to do so. I'd like to know if the Mobile 6 SDK can be used for this purpose.</p>
<p>There's no upgrade path to newer versions of Windows Mobile for this device, a... | <p>You need to code to the least common denominator. Using the WimNo 6 SDK is not the route to go as there is no guarantee of backward compatability and you may end up using features available only in the later OS/Platform. Studio 08 ships with a PPC 2003 SDK, so use that. The apps developed for PPC 03 should be for... | <p>You can create programs for WM2003. As long as you can install the .net cf you will be able to run programs compiled under the compact framework. The list of requirements are:
From <a href="http://www.microsoft.com/downloads/details.aspx?familyid=9655156b-356b-4a2c-857c-e62f50ae9a55&displaylang=en" rel="nofollow... | 32,133 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.