instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Suppose I have some code:</p>
<pre><code>let listB = [ 1; 2; 3 ]
</code></pre>
<p>Using Lisp notation, how do I do a <code>car</code> and <code>cadr</code> against this list? I know cons is <code>::</code>.</p>
<p>Or in Scheme, <code>first</code> and <code>rest</code>?</p>
| <p><em>List.head</em>: Returns the first element of a nonempty list <em>(The head of the list)</em>.</p>
<p><em>List.tail</em>: Returns all the elements of a
nonempty list except the first <em>(The tail or rest of the list)</em>.</p>
<p>Example (<em>using F# Interactive Console</em>):</p>
<pre><code>> let sample ... | <p>I'm going to have to agree with simonuk. Although, like CMS has mentioned, <code>hd</code> and <code>tl</code> are the correct functions, there is more to the argument then that.</p>
<p>When using pattern matching you can exploit the compilers ability to catch (base) cases you may have missed (such as when the lis... | 35,883 |
<p>Should I catch exceptions for logging purposes?</p>
<pre>
public foo(..)
{
try
{
...
} catch (Exception ex) {
Logger.Error(ex);
throw;
}
}
</pre>
<p>If I have this in place in each of my layers (DataAccess, Business and WebService) it means the exception is logged several times.</p>
<p>... | <p>Definitely not. You should find the correct place to <strong>handle</strong> the exception (actually do something, like catch-and-not-rethrow), and then log it. You can and should include the entire stack trace of course, but following your suggestion would litter the code with try-catch blocks.</p>
| <p>If you're required to log all exceptions, then it's a fantastic idea. That said, logging all exceptions without another reason isn't such a good idea.</p>
| 12,110 |
<p>I was writing a database handler class in PHP using the mysqli class and prepared statements. I was attempting to print out the result. It didn't work right off the bat so I decided to do some debugging. I tried to use the <code>num_rows()</code> method from the <code>mysqli_statement</code> class, but it kept re... | <p>I wonder if num_rows() is reporting relative to the current resultset. Try capturing num_rows() prior to fetching the data. e.g.</p>
<pre><code>if($statement->prepare($query))
{
$statement->execute();
$statement->store_result();
echo $statement->num_rows();
$statement->bind_result($na... | <p>It doesn't look like you've declared $name.</p>
<p>Also, try removing bind_result() and fetch() so it reads something like this:</p>
<pre><code>$statement->execute();
$statement->store_result();
printf("Number of rows: %d.\n", $statement->num_rows);
</code></pre>
| 10,574 |
<p>I am trying to convert an <code>int</code> into three <code>bytes</code> representing that <code>int</code> (big endian).</p>
<p>I'm sure it has something to do with bit-wise and and bit shifting. But I have no idea how to go about doing it.</p>
<p>For example:</p>
<pre><code>int myInt;
// some code
byte b1, b... | <p>To get the least significant byte:</p>
<pre><code>b3 = myInt & 0xFF;
</code></pre>
<p>The 2nd least significant byte:</p>
<pre><code>b2 = (myInt >> 8) & 0xFF;
</code></pre>
<p>And the 3rd least significant byte:</p>
<pre><code>b1 = (myInt >> 16) & 0xFF;
</code></pre>
<p><strong>Explanat... | <p>The answer of Jeremy is correct in case of positive integer value. If the conversion should be correct for negative values, it is little more complicated due to two's-complement format (<a href="https://en.wikipedia.org/wiki/Two%27s_complement" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Two%27s_compleme... | 22,472 |
<p>I am wanting to find the distance between two different points. This I know can be accomplished with the great circle distance.
<a href="http://www.meridianworlddata.com/Distance-calculation.asp" rel="noreferrer">http://www.meridianworlddata.com/Distance-calculation.asp</a></p>
<p>Once done, with a point and distan... | <p>Here is a Java implementation of <a href="http://en.wikipedia.org/wiki/Haversine_formula" rel="noreferrer">Haversine</a> formula. I use this in a project to calculate distance in miles between lat/longs.</p>
<pre><code>public static double distFrom(double lat1, double lng1, double lat2, double lng2) {
double e... | <p>I typically use MATLAB with the <a href="http://www.mathworks.com/products/mapping/" rel="nofollow">Mapping Toolbox</a>, and then use the code in my Java using <a href="http://www.mathworks.com/discovery/java-math.html" rel="nofollow">MATLAB Builder JA.</a> It makes my life a lot simpler. Given most schools have it ... | 14,630 |
<p>I'm having trouble with a web application that will deadlock occasionally</p>
<p>There are 3 queries involved. 2 are trying to update a table</p>
<pre><code>UPDATE AttendanceRoll
SET ErrorFlag = 0
WHERE ContractID = @ContractID
AND DATEPART(month,AttendanceDate) = DATEPART(month,@Month_Beginning)
AND DATEPART(year... | <p>Is the Update query taking a significant time to execute (say, more than second)? If so, try optimizing the query (i.e. by putting indexes on the contractid column etc)</p>
<p>The first thing I always like to do when fixing deadlocks is tune the queries involved. If you can get a good performance improvement then y... | <p>I usually wrap all my calls to SQL server inside something like (exactly this won't compile, but you'll get the idea):</p>
<pre><code>for (;;) {
try {
using (var t = BeginTransaction()) {
DoTheCall();
t.Commit();
return;
}
}
catch (SqlException ex) {
... | 42,722 |
<p>What's the best way to extend the User model (bundled with Django's authentication app) with custom fields? I would also possibly like to use the email as the username (for authentication purposes).</p>
<p>I've already seen a <a href="http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inhe... | <p>The least painful and indeed Django-recommended way of doing this is through a <code>OneToOneField(User)</code> property.</p>
<blockquote>
<h2><a href="https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model" rel="noreferrer">Extending the existing User model</a></h2>
<p>…</p... | <p>Currently as of Django 2.2, the recommended way when starting a new project is to create a custom user model that inherits from AbstractUser, then point AUTH_USER_MODEL to the model.</p>
<p>Source: <a href="https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-proj... | 6,577 |
<p>I still have a large number of floppies. On some of them there probably is source code I don't want to lose. I also don't want to take look at each one individually, as that's going to take a lot of time. What software would be best for copying all data to a hard disk, preferably while creating an index at the same ... | <p>Here is a script I used on my Linux box to perform the same type of task. Basically I just a raw image of each disk to a folder. I had another script I ran later that mounted each and dumped a directory listing into a file.</p>
<pre><code>#!/bin/bash
floppydev='/dev/sdb'
savepath='/srv/floppy_imgs'
while true
do... | <p>I am not too sure of your goal. Somehow, what you need is a robot, inserting the floppies, copying, etc. :-)</p>
<p>I would just make a bunch of empty folders, insert disk, do select all and drag to nth folder. Or use something like xcopy or xxcopy to transfer recursively data from floppy to folder. Etc.</p>
| 42,520 |
<p>I want to set a style on the first and last TabItems in a TabControl, and have them updated as the visibility of the TabItems is changed. I can't see a way to do so with triggers.</p>
<p>What we're after looks like this:</p>
<pre>| > > > |</pre>
<p>And the visibility of TabItems are determined by binding.</p>
<... | <p>Sorry can you explain this a little better so far i have interpreted your question as so:</p>
<p>Apply a specific style when the visibility changes on the tab items at the beginning and end of the tab control - ie if it scrolls out of view then change the style?</p>
<p>If this is so then, as you add your TabItems ... | <p>I have taken the silverlight tabcontrol and made the tabitems scrollable. here is a link to the post. I think this is what you are looking for.</p>
<p><a href="http://www.dansoltesz.com/post/2010/07/20/Silverlight-tabcontrol-with-scrollable-tabItems.aspx" rel="nofollow noreferrer">http://www.dansoltesz.com/post/2... | 24,880 |
<p>I have something like this:</p>
<pre><code><node TEXT=" txt A "/>
<node TEXT="
txt X
"/>
<node>
<html>
<p>
txt Y
</p>
</html>
</node>
<node TEXT="txt B"/>
</code></pre>
<p>and i want to use XSLT to get this:</p>
<pre><cod... | <p>The following transformation:</p>
<pre><code><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="*">
<xsl:apply-templates select="@TEXT | node()"/>
</xsl:template>
<xsl:template match="node/@TEXT | text... | <p>You probably want</p>
<pre><code> <xsl:strip-space elements="node"/>
</code></pre>
<p>explained <a href="http://www.w3schools.com/XSL/el_preserve-space.asp" rel="nofollow noreferrer">here</a>. And this <a href="http://www.ibm.com/developerworks/xml/library/x-tipwhitesp.html" rel="nofollow noreferrer">article... | 42,062 |
<p>From what I understand, due to the "same origin policy" enforcement in current browsers, it's impossible to obtain data from an XmlHttpRequest sent to a different domain than the Javascript's original domain.</p>
<p>I have close to zero experience regarding this matter, so I'm confused about web services being unus... | <p>In your question your mentioned the <script> trick. JSONP is based on that. <a href="http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/" rel="noreferrer">It was formally proposed almost 3 years ago by Bob Ippolito</a>. It doesn't give you the right to talk to the origin of the script — the o... | <p>Have a look at JSONP, which works around the same origin policy using pretty much the approach you are describing, just make sure you trust where you get it from...</p>
| 42,056 |
<p>I swear I've seen someone do this, but I can't find it in the various lists of shortcuts.</p>
<p>Given:</p>
<pre><code>String s = "A very long ............................ String";
</code></pre>
<p>Is there an Eclipse shortcut to turn it into:</p>
<pre><code>String s = "A very long ............................ "... | <p>Yup - just hit return when your cursor is in the middle of the string.</p>
<p>Admittedly that puts the + at the end of the first line instead of the start of the second, which is irritating if your style guide demands the latter, but if you're not fussy it's great :)</p>
| <p>There may be a Quick Fix (<kbd>Ctrl</kbd> + <kbd>1</kbd>) for this as well.</p>
<p>I was amazed in 3.4 to discover that there are Quick Fixes to transform +-based string concats into uses of <code>StringBuilder</code> or <code>MessageFormat</code>. Brilliant!</p>
| 32,098 |
<p>What is the difference between using a new thread and using a thread from the thread pool? What performance benefits are there and why should I consider using a thread from the pool rather than one I've explicitly created? I'm thinking specifically of .NET here, but general examples are fine.</p>
| <p>Thread pool will provide benefits for frequent and relatively short operations by</p>
<ul>
<li>Reusing threads that have already been created instead of creating new ones (an expensive process)</li>
<li>Throttling the rate of thread creation when there is a burst of requests for new work items (I believe this is onl... | <p>Using a pool is a good idea, if you don't know or can't control how many thread will be created.</p>
<p>Just have an issue with a form using thread to update some field from a database on a <code>positionchanged</code> event of a list control (avoid freeze). It took 5 minutes for my user to have an error from the da... | 28,469 |
<p>This may seem like a programming 101 question and I had thought I knew the answer but now find myself needing to double check. In this piece of code below, will the exception thrown in the first catch block then be caught by the general Exception catch block below?</p>
<pre><code>try {
// Do something
} catch(IOE... | <p>No, since the new <code>throw</code> is not in the <code>try</code> block directly.</p>
| <p>Old post but "e" variable must be unique:</p>
<pre><code>try {
// Do something
} catch(IOException ioE) {
throw new ApplicationException("Problem connecting to server");
} catch(Exception e) {
// Will the ApplicationException be caught here?
}
</code></pre>
| 17,332 |
<p>I would like to embed a light weight web server in a Windows application developed in .NET. The web server has to support PHP.</p>
<p>I have looked at Cassini, but it seems it is ASP.NET only.</p>
| <p>The .net class HttpListener exposes the underlying http.sys upon which IIS is built. All machines since Windows XP2 have http.sys installed by default.
Here are some links to get you started.</p>
<p><a href="http://www.cookcomputing.com/blog/archives/000572.html" rel="noreferrer">XML-RPC SERVER USING HTTPLISTENER<... | <p>Mongoose embedded webserver
<a href="https://code.google.com/p/mongoose/" rel="nofollow">https://code.google.com/p/mongoose/</a></p>
<p>You can build it with VS2012/10/08 as EXE and you can use PHP and also websockets to push data to the client app. Also you can build a DLL you can do this with make or bring the co... | 18,760 |
<p>Assuming the following directory structure,</p>
<pre><code>htdocs/
images/
css/
.htaccess
system/
index.php
...
</code></pre>
<p>I would like to route all incoming requests through that php script. I have been trying some rewrite rules within the htaccess, but I can't seem to be able to route to files th... | <p>What a lot of frameworks do is use rewrite to route all requests to one file where you can do more complex routing of your own. An example .htaccess file might be:</p>
<pre><code># ignore anything that's an actual file (eg CSS, js, images)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
# redirect all other traffic... | <p>No, you cannot route outside the docroot without potentially enormous risk.</p>
<p>You should place the <code>index.php</code> within the <code>htdocs</code> folder and rewrite it there, not outside. If you were to rewrite to handle the index, accessing outside the docroot, and you made one little mistake it's pot... | 42,654 |
<p>Is there a simple way to detect mouse or keyboard activity in Linux or Xorg or Qt4 or Kde4 environment? Obviously not only on a particular window but in the entire Xorg desktop.</p>
| <p>You can use the XScreenSaver extension (<code>man Xss</code>). It can provide you with values into this struct using the function <code>XScreenSaverQueryInfo</code>:</p>
<pre><code> typedef struct {
Window window; /∗ screen saver window */
int state; /∗ ScreenSaver{... | <p>I'm not familiar with the guts of the Qt4 or KDE API's.</p>
<p>However in general terms, on any X11 system keyboard or mouse input is only delivered to the <em>active</em> window, unless you call the underlying <code>XGrabMouse</code>, <code>XGrabKeyboard</code>, etc functions.</p>
<p>Of course, once you've done t... | 45,715 |
<p>The <a href="https://stackoverflow.com/questions/19235/agile-architectures">Agile architecture question</a> makes me wonder this. </p>
<p>Does it depends of what is being build ? Do applications (I mean single
computing program here) have an architecture ? </p>
<p>UPDATE: to try to clarify the question, I'... | <p>It's really fairly simple: architecture is about the design decision you make to meet the "non-functional" requirements: requirements like cost, maintainability, performance, reliability, availability, and security. This about a web application: you can build it in a zillion ways, from a big C program that runs as ... | <p>It is purely subjective. Whatever the dev lead or architect says is the truth.</p>
| 33,699 |
<p>For a newcomer to .NET Web Development and programming in general, who chooses C# as there preferred language?</p>
<p>Is it better to learn C# first, without trying to apply it to web development? It seems most literature for C# uses Console or Windows Forms as a learning platform. So would that be the best directi... | <p>You need to understand the fundamentals of C# in order to develop anything useful, be it an ASP.NET website, windows client or web service. </p>
<p>I would start with some good tutorials around the basics of types, classes, methods, events and so on to get to grips with C#. C# Station has some good introductory tut... | <p>My suggestion would be to do both as if you are doing only web development, then console or Windows applications may not be meaningful to complete. Another point is that there may be parts of C# that are specific to Webforms such as AJAX functionality to name one example though the ASP.Net MVC may be another worth ... | 37,544 |
<p>I need to implement a 4-to-1 function in Veriog. The input is 4 bits, a number from 0-15. The output is a single bit, 0 or 1. Each input gives a different output and the mapping from inputs to outputs is known, but the inputs and outputs themselves are not. I want vcs to successfully optimizing the code and also... | <p>What you have is fine. A case statement would also work equally well. It's just a matter of how expressive you wish to be. </p>
<p>Your solution, indexing, works fine if the select encodings don't have any special meaning (a memory address selector for example). If the select encodings do have some special sema... | <p>Apparently I am using a lousy synthesis tool. :-) I just synthesized both versions (just the module using a model based on fan-outs for wire delays) and the indexing version from the question gave better timing and area results than the case statements. Using Synopsys DC Z-2007.03-SP.</p>
| 6,427 |
<p>I'm trying to launch another process from a service (it's a console app that collects some data and writes it to the registry) but for some reason I can't get it to launch properly.</p>
<p>I basics of what I'm am trying to do is as follows:</p>
<ol>
<li>Launch the process</li>
<li>Wait for the process to finish</l... | <p><code>WaitForSingleObject</code> and <code>GetExitCodeProcess</code> expect the process handle itself, not a pointer to the process handle. Remove the ampersands.</p>
<p>Also, check the return values and call <code>GetLastError</code> when they fail. That will help you diagnose future problems. Never assume an API ... | <p>Following the update and edit, this sounds like one of many possible gotchas when launching a process from a service. Is there any possibility - any whatsoever - that your external process is waiting for user interaction? There are three major examples I can think of, one for instance would be a command-line applica... | 41,132 |
<p>Just as an example, if I have a <code>Book</code> model and a <code>BooksController</code>, autotest, part of the ZenTest suite will pick up the association between the two and load <code>test/unit/book_test.rb</code> and <code>test/functional/books_controller_test.rb</code> into the test suite. On the other hand, i... | <p>Check this article <a href="http://www.codeproject.com/KB/recipes/MoneyTypeForCLR.aspx" rel="noreferrer">A Money type for the CLR</a></p>
<blockquote>
<p>A convenient, high-performance money
structure for the CLR which handles
arithmetic operations, currency types,
formatting, and careful distribution
and... | <p>i would use integer/long, and use a very low denomination like cents (or pence) - then there would be no decimal to work with, and all calculations can be rounded to the nearest cent. </p>
<p>or, take a look at Martin Fowler's book "Patterns of Enterprise Application Architecture". In that book, he talked about how... | 34,552 |
<p>I am using Powershell PSeventing plugin but have had no luck so far finding an event that triggers when an event log is full. I am looking everywhere MSDN .net events I know it has to do with maximum event log size but I can't find that trigger and I'm not sure how to get PSeventing to make thing happen. Can anyon... | <p>My first thought would be to use a FileSystemWatcher and monitor the file size. I'm not finding any other option, other than monitoring the System event log (I think an event gets written there when a log is full and an attempt to write fails), but that won't work if the log you are concerned about is the system ev... | <p>I wonder if there is an associated WMI event that you could register a sink for. If I get time I'll look for one.</p>
<p>Ok, so here is what I have found so far. There is a __EventQueueOverflowEvent event sink available. I suspect that this <em>might</em> work for you. There is also the __SystemEvent that also <em>... | 38,064 |
<p>I am using <code>pyexcelerator</code> Python module to generate Excel files.
I want to apply bold style to part of cell text, but not to the whole cell.
How to do it?</p>
| <p>This is an example from Excel documentation:</p>
<pre><code>With Worksheets("Sheet1").Range("B1")
.Value = "New Title"
.Characters(5, 5).Font.Bold = True
End With
</code></pre>
<p>So the Characters property of the cell you want to manipulate is the answer to your question. It's used as Characters(<em>start... | <p>Here is one solution which i had used for the same problem.</p>
<pre><code> import xlsxwriter
workbook = xlsxwriter.Workbook(r'C:\workspace\NMSAutomation_001\FMGGUIAutomation\Libraries\Frontend\new_STICKERS_Final.xlsx')
####### two different formats
bold = workbook.add_format({'font_name':'Tahoma', 'bol... | 13,353 |
<p>What alternatives are there to GAE, given that I already have a good bit of code working that I would like to keep. In other words, I'm digging python. However, my use case is more of a low number of requests, higher CPU usage type use case, and I'm worried that I may not be able to stay with App Engine forever. ... | <p>I don't think there is another alternative (with regards to code portability) to GAE right now since GAE is in a class of its own. Sure GAE is cloud computing, but I see GAE as a subset of cloud computing. Amazon's EC2 is also cloud computing (as well as Joyent Accelerators, Slicehost Slices), but obviously they are... | <p>The shift to cloud computing is happening so rapidly that you have no time to waste for testing different platforms.
I suggest you trying out <a href="http://jelastic.com/" rel="nofollow">Jelastic</a> if you are interested in Java as well.</p>
<p>One of the greatest things about Jelastic is that you do not need to... | 18,562 |
<p>I have a flash player that has a set of songs loaded via an xml file.</p>
<p>The files dont start getting stream until you pick one.</p>
<p>If I quickly cycle through each of the 8 files, then flash starts trying to download each of the 8 files at the same time.</p>
<p>I'm wondering if there is a way to clear the... | <p>Check out <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/Sound.html#close()" rel="nofollow noreferrer">Sound.Close()</a>.</p>
<p>From the docs: "<em>Closes the stream, causing any download of data to cease. No data may be read from the stream after the close() method is called.</em>... | <p>If you do something like:</p>
<p>MySoundObject = undefined;</p>
<p>That should do it.</p>
| 10,065 |
<p>Does <a href="http://elmah.github.io/" rel="nofollow noreferrer">ELMAH</a> logged exceptions even when they do not bubble up to the application? I'd like to pop up a message when an exception occurs and still log the exception. Currently I've been putting everything in try catch blocks and spitting out messages, b... | <p>ELMAH has been updated to support a new feature called <a href="https://code.google.com/p/elmah/wiki/DotNetSlackersArticle#Error_Signaling" rel="noreferrer">Signaling</a>.</p>
<p>This allows you to handle exceptions how you want, while still logging them to ELMAH.</p>
<pre><code>try
{
int i = 5;
int j = 0;... | <p>A filter is the cleanest way to handle this problem. Check this solution here <a href="https://stackoverflow.com/a/5936867/965935">https://stackoverflow.com/a/5936867/965935</a></p>
| 11,393 |
<p>I am creating a small modal form that is used in Winforms application. It is basically a progress bar of sorts. But I would like the user to be able to click anywhere in the form and drag it to move it around on the desktop while it is still being displayed.</p>
<p>How can I implement this behavior?</p>
| <p><a href="http://support.microsoft.com/kb/320687" rel="nofollow noreferrer" title="KB Article 320687">Microsoft KB Article 320687</a> has a detailed answer to this question.</p>
<p>Basically, you override the WndProc method to return HTCAPTION to the WM_NCHITTEST message when the point being tested is in the client ... | <p>VC++ 2010 Version (of FlySwat's):</p>
<pre><code>#include <Windows.h>
namespace DragWithoutTitleBar {
using namespace System;
using namespace System::Windows::Forms;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Data;
using names... | 5,007 |
<p>I want to display a thumbnail image in a <code>cell</code> of <code>tableViewController</code>, this thumbnail image is located at some remote place (URL of address is in XML file) so which format of image is cost effective?</p>
| <p>It's mostly the same as on the Web, really. For graphics, PNG is generally more efficient; for photos, you'll want to pick JPEG.</p>
<p>I'm not sure whether the iPhone supports JPEG 2000 (OS X does), so that may be a more efficient options for photos.</p>
<p>Also consider tools such as <code>optipng</code> and <co... | <p>The recommendation for images in a <code>UITableView</code> is <strong><em>PNG</em></strong>, this has the best rendering performance.</p>
| 17,586 |
<p>I have a nightly batch job that can tell if it has failed. I want it to send me an email, possibly with an attachment when it does. </p>
<p>How can I send an email from a Windows Batch (.bat) file?</p>
| <p>If the SMTP-server that is a part of IIS is installed, you could use the Echo command to write a file to the pickup folder, and it'll get sent.</p>
<pre><code>echo From: test@example.com>tmp.txt
echo To: test@example.com>>tmp.txt
echo Subject: hello>>tmp.txt
echo.>>tmp.txt
echo Hello world>&... | <p><a href="http://www.blat.net/" rel="nofollow noreferrer">Blat</a>. Nothing more needs to be said. ;)</p>
| 43,857 |
<p>I'll preface this question by saying this is for a Microsoft only shop. </p>
<p>If you were to write a console app to manage a data warehouse what would you use:<br>
1) Writing a custom environment for PowerShell (ala the latest flavors of Exchange / SQL Server)<br>
2) Write it as a C# Console App </p>
<p>If #2 ... | <p>If you write your management functionality as PowerShell cmdlets, then you can surface that functionality either by letting people run cmdlets directly, or by wrapping them in a GUI. Going with PowerShell probably gives you the most long-term flexibility, and as MS implements more PowerShell cmdlets, it means that m... | <p>When you are saying manage a data warehouse, what kind of tasks are you talking about?</p>
<p>Much of the management I would do in T-SQL (purging, archiving, transforming) - the interface to that can be very thin (even non-existent).</p>
<p>OK, based on your comment I would have the code which does all the work in... | 44,819 |
<p>I'm trying to do an image capture on a high end Nokia phone (N95). The phone's internal camera is very good (4 megapixels) but in j2me I only seem to be able to get a maximum of 1360x1020 image out. I drew largely from this example <a href="http://developers.sun.com/mobility/midp/articles/picture/" rel="nofollow n... | <p>This <a href="http://www.forum.nokia.com/document/Java_ME_Developers_Library/?content=GUID-00C29EFF-1A32-49D6-9AF4-0E5D8F1EE772.html" rel="nofollow noreferrer">explanation</a> on Nokia forum may help you. </p>
<p>It says that "The maximum image size that can be captured depends on selected image format, encoding op... | <p>The 'quality' of a JPEG (As interpreted by the code) is nothing to do with the resolution. Rather it is to do with how compressed the image is. A 640x480 image at 100 quality will be noticably better looking than a 640x480 image at 50, but will use more storage space.</p>
<p>Try this instead:</p>
<pre><code>jpg = ... | 29,942 |
<p>What GUI should use to run my JUnit tests, and how exactly do I do that? My entire background is in .NET, so I'm used to just firing up my NUnit gui and running my unit tests. If the lights are green, I'm clean. </p>
<p>Now, I have to write some Java code and want to run something similar using JUnit. The JUnit doc... | <p>Eclipse is by-far the best I've used. Couple JUnit with a <a href="http://www.eclemma.org/" rel="nofollow noreferrer">code coverage</a> plug-in and Eclipse will probably be the best unit-tester.</p>
| <p>Why you need a GUI runner? Can't you just run the tests from the IDE itself?</p>
<p>In .Net we have <a href="http://testdriven.net/" rel="nofollow noreferrer">TestDriven.net</a>, in Java there must be something equivalent. You can check out <a href="http://en.wikipedia.org/wiki/IntelliJ_IDEA" rel="nofollow noreferr... | 8,360 |
<p>Why does the following method hang?</p>
<pre>
public void pipe(Reader in, Writer out) {
CharBuffer buf = CharBuffer.allocate(DEFAULT_BUFFER_SIZE);
while( in.read(buf) >= 0 ) {
out.append(buf.flip());
}
}
</pre>
| <p>Answering my own question: you have to call <code>buf.clear()</code> between <code>read</code>s. Presumably, <code>read</code> is hanging because the buffer is full. The correct code is</p>
<pre>
public void pipe(Reader in, Writer out) {
CharBuffer buf = CharBuffer.allocate(DEFAULT_BUFFER_SIZE);
while( in.r... | <p>I would assume that it is a deadlock. The in.read(buf) locks the CharBuffer and prevents the out.append(buf) call.</p>
<p>That is assuming that CharBuffer uses locks (of some kind)in the implementation. What does the API say about the class CharBuffer?</p>
<p>Edit: Sorry, some kind of short circuit in my brain... ... | 15,546 |
<p>I'm a web-guy stuck in "application world" in VS 2005. I created my windows forms program and want to give my end users the ability to install it (and some of it's resources) into a standard Program Files/App Directory location along with a start menu/desktop launcher. </p>
<p>The help files don't give any instru... | <p>You're looking for a "Setup Project" which should be under the "Other Project Types" -> "Setup and Deployment" category in the "New Project" dialog.</p>
| <p>The Setup Project is the way to go. If you're going to be deploying the installer from a web site, I recommend creating an MSI file as the project output (as opposed to a Setup.exe output). Most of my clients block the download of EXE files.</p>
| 13,801 |
<p>I'm running my site through the W3C's validator trying to get it to validate as XHTML 1.0 Strict and I've gotten down to a particularly sticky (at least in my experience) validation error. I'm including certain badges from various services in the site that provide their own API and code for inclusion on an external... | <p>The following fragment is valid XHTML and does the job:</p>
<pre><code><div id="twitter_div">
<h2 class="twitter-title"><a href="http://twitter.com/stopsineman" title="Tim's Twitter Page.">Twitter Updates</a></h2>
<div id="myDiv" />
</div>
<script type="text/ja... | <p>At some point the page becomes valid, right? That's the only time it can really be validated.</p>
<p>I'm not sure a non-trivial page will remain valid at every point during its construction if it's constructed with a lot of DOM scripting.</p>
| 18,055 |
<p>I've been sharing image lists across multiple forms in Delphi for years now. I have a TImageList on the main form of my app and then I have other forms that have components where I set the Images property to the image list from the main form (e.g. MyMainForm.MyImageList) at design time.</p>
<p>The problem I'm havin... | <p>I ran into the same problem many years ago. Ever since, I've had the habit of putting image lists that are shared by several forms onto a TDataModule. Then Delphi doesn't lose the link. Putting non-visual components on data modules also reduces design time clutter on your forms. At runtime, the TDataModule is in... | <p>Do you have mainform.pas included in project? Not only as "uses mainform.pas" somewhere in .pas, but as </p>
<pre><code> fMainForm in 'fMainForm.pas' {MainForm},
</code></pre>
<p>in your Application**.dpr**. That comment <em>{MainForm}</em> is necessary for Delphi - for resolving inherited forms and links between... | 49,336 |
<p>I dropped a database from SQL Server, however it turns out that <strong>my login</strong> was set to use the dropped database as its default. I can connect to SQL Server Management Studio by using the 'options' button in the connection dialog and selecting 'master' as the database to connect to. However, whenever I ... | <p>What you can do is set your default database using the sp_defaultdb system stored procedure. Log in as you have done and then click the New Query button. After that simply run the sp_defaultdb command as follows:</p>
<pre><code>Exec sp_defaultdb @loginame='login', @defdb='master'
</code></pre>
| <p>If you use windows authentication, and you don't know a password to login as a user via username and password, you can do this: on the login-screen on SSMS click options at the bottom right, then go to the connection properties tab. Then you can type in manually the name of another database you have access to, over ... | 47,302 |
<p>When merging topic branch "B" into "A" using <code>git merge</code>, I get some conflicts. I know all the conflicts can be solved using the version in "B".</p>
<p>I am aware of <code>git merge -s ours</code>. But what I want is something like <code>git merge -s theirs</code>.</p>
<p>Why... | <p>A similar alternative is the <code>--strategy-option</code> (short form <code>-X</code>) option, which accepts <code>theirs</code>. For example:</p>
<pre><code>git checkout branchA
git merge -X theirs branchB
</code></pre>
<p>However, this is more equivalent to <code>-X ours</code> than <code>-s ours</code>. The key... | <p>I just recently needed to do this for two separate repositories that share a common history. I started with:</p>
<ul>
<li><code>Org/repository1 master</code></li>
<li><code>Org/repository2 master</code></li>
</ul>
<p>I wanted all the changes from <code>repository2 master</code> to be applied to <code>repository1 ... | 20,960 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/200574/linq-equivalent-of-foreach-for-ienumerablet">LINQ equivalent of foreach for IEnumerable<T></a> </p>
</blockquote>
<p>The linq extension methods for ienumerable are very handy ... but not that usefu... | <p>Shedding a little more light on why:</p>
<p>LINQ is functional in nature. It is used to query data and return results. A LINQ query shouldn't be altering the state of the application (with some exceptions like caching). Because foreach doesn't return any results, it doesn't have many uses that don't involve alterin... | <p>Already discussed <a href="https://stackoverflow.com/questions/101265/why-is-there-not-a-foreach-extension-method-on-the-ienumerable-interface">here</a> and <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2386791&SiteID=1" rel="nofollow noreferrer">there</a>.</p>
<p>Im too drowsy to remember but,... | 41,068 |
<p>I would like to extract the date a jpg file was created. Java has the lastModified method for the File object, but appears to provide no support for extracting the created date from the file. I believe the information is stored within the file as the date I see when I hover the mouse pointer over the file in Win X... | <p>The information is stored within the image in a format called <a href="http://en.wikipedia.org/wiki/Exchangeable_image_file_format" rel="noreferrer">EXIF</a> or <a href="http://www.exif.org" rel="noreferrer">link text</a>. There several libraries out there capable of reading this format, like <a href="http://www.dr... | <p>You probably need something to access the <a href="http://en.wikipedia.org/wiki/Exchangeable_image_file_format" rel="nofollow noreferrer">exif</a> data. Google suggests <a href="http://www.drewnoakes.com/code/exif/" rel="nofollow noreferrer">this library</a>.</p>
| 10,937 |
<p>I'm just wondering how other developers tackle this issue of getting 2 or 3 answers from a method.</p>
<p>1) return a object[]<br>
2) return a custom class<br>
3) use an out or ref keyword on multiple variables<br>
4) write or borrow (F#) a simple Tuple<> generic class<br>
<a href="http://slideguitarist.blogspot... | <p>It entirely depends on what the results are. If they are related to one another, I'd usually create a custom class.</p>
<p>If they're not really related, I'd either use an out parameter or split the method up. If a method wants to return three unrelated items, it's probably doing too much. The exception to this is ... | <p>If 2, a Pair.</p>
<p>If more than 2 a class.</p>
| 43,858 |
<p>Can I with ASP.NET Resources/Localization translate strings to depend on one or other (the English grammar) in a easy way, like I pass number 1 in my translate, it return "You have one car" or with 0, 2 and higher, "You have %n cars"?</p>
<p>Or I'm forced to have logic in my view to see if it's singular or plural?<... | <p>JasonTrue wrote:</p>
<blockquote>
<p>To the best of my knowledge, there isn't a language that requires something more complicated than singular/plural</p>
</blockquote>
<p>Such languages do exist. In my native Polish, for example, there are three forms: for 1, for 2-4 and for zero and numbers greater than 4. The... | <p>The logic needn't be in your view, but it's certainly not in the resource model the DotNet framework. Yours is a simple enough case that you can probably get away with creating a simple format string for singular, and one for plural. "You have 1 car."/"You have {0} cars." You then need to write a method that discrim... | 49,265 |
<p>I want my php script to create an output file in a folder based on the date. The way I'm doing this is that its supposed to get the foldername/filename from a text file outputted by another program which I am unable to edit.</p>
<p>So the file its grabbing the data from looks like this:</p>
<pre><code>data/newfol... | <pre><code>if(!file_exists(dirname($file)))
mkdir(dirname($file), 0777, true);
//do stuff with $file.
</code></pre>
<p>Use the third parameter to <a href="http://php.net/mkdir" rel="noreferrer">mkdir()</a>, which makes it create directories recursively.</p>
| <p>Can't you just do this by creating the dir with mkdir (<a href="http://nl.php.net/manual/en/function.mkdir.php" rel="nofollow noreferrer">http://nl.php.net/manual/en/function.mkdir.php</a>) then chmod it 777 (<a href="http://nl.php.net/manual/en/function.chmod.php" rel="nofollow noreferrer">http://nl.php.net/manual/... | 35,715 |
<p>I am working on an ASP.NET MVC application that contains a header and menu on each page. The menu and header are dynamic. In other words, the menu items and header information are determined at runtime.</p>
<p>My initial thought is to build a base Controller from which all other controllers derive. In the base c... | <p>Depends on where your information is coming from. We have standard view data that we use to generate some of the information we have on screen that we create in just this fashion. It works well and is easily maintained. <a href="http://oddiandeveloper.blogspot.com/2008/11/strongly-typed-view-names.html" rel="nofo... | <p>I'll answer your question with another question. Will the base controller have to determine what type it really is in order to generate the proper menu data? If so, then you're defeating the purpose of polymorphism and the code to generate the data should go in each controller, perhaps in OnActionExecuting if the ... | 43,583 |
<p>I have a perl variable <code>$results</code> that gets returned from a service. The value is supposed to be an array, and <code>$results</code> should be an array reference. However, when the array has only one item in it, <code>$results</code> will be set to that value, and not a referenced array that contains th... | <p>im not sure there's any other way than:</p>
<blockquote>
<pre><code>$result = [ $result ] if ref($result) ne 'ARRAY';
foreach .....
</code></pre>
</blockquote>
| <p>I've just tested this with:</p>
<blockquote>
<pre><code>#!/usr/bin/perl -w
use strict;
sub testit {
my @ret = ();
if (shift){
push @ret,1;
push @ret,2;
push @ret,3;
}else{
push @ret,"oneonly";
}
return \@ret;
}
foreach my $r (@{testit(1)}){
print $r." test1\n";
}
foreach my $r (@{testit()}){
p... | 2,527 |
<p>I'm wondering the <em>best</em> way to start a pthread that is a member of a C++ class? My own approach follows as an answer...</p>
| <p>I usually use a static member function of the class, and use a pointer to the class as the void * parameter. That function can then either perform thread processing, or call another non-static member function with the class reference. That function can then reference all class members without awkward syntax.</p>
| <p>The boost library provides a copy mechanism, which helps to transfer object information
to the new thread. In the other boost example boost::bind will be copied with a pointer, which is also just copied. So you'll have to take care for the validity of your object to prevent a dangling pointer. If you implement the o... | 11,155 |
<p>Having a set of (2D) points from a GIS file (a city map), I need to generate the polygon that defines the 'contour' for that map (its boundary). Its input parameters would be the points set and a 'maximum edge length'. It would then output the corresponding (probably non-convex) polygon.</p>
<p>The best solution I ... | <p>One of the former students in our lab used some applicable techniques for his PhD thesis. I believe one of them is called "alpha shapes" and is referenced in the following paper:</p>
<p><a href="http://www.cis.rit.edu/people/faculty/kerekes/pdfs/AIPR_2007_Gurram.pdf" rel="noreferrer">http://www.cis.rit.edu/people/... | <p>A quick approximate solution (also useful for convex hulls) is to find the north and south bounds for each small element east-west.</p>
<p>Based on how much detail you want, create a fixed sized array of upper/lower bounds.
For each point calculate which E-W column it is in and then update the upper/lower bounds fo... | 10,918 |
<p>We're starting a large web project, mostly green field. I like the Tapestry framework for java/web solutions. I have concerns about starting a Tapestry 5 project since T5 is still in beta. However, if I understand the documentation correctly, T4 development will not be supported by T5 and up. My question: Should I b... | <p>This question is moot now; Tapestry 5.0.18 was released on Dec.12 and it's the stable production-ready release, so nobody has to worry about using Tap5 before production anymore... just upgrade from whatever 5.0.x you're using to 5.0.18.</p>
<p><b>WARNING:</b> If you're still using 5.0.15 then maybe you will have t... | <p>As zappan said, you should consider T5 if your project delivery (LIVE/RELEASE) date is several months ahead. Especially since T5 is not released yet -- which leads to the expectation that there will NOT be too many people who will have experience with it.</p>
<p>Then again, if your project is NOT mission critical a... | 20,756 |
<p>I've struggled for the last couple of months to come up with some clean code to report progress to a user. Everything always seems to boil down to:</p>
<pre><code>ReportProgress("Starting Task 1");
doTask1();
ReportProgress("Task 1 is done");
ReportProgress("Starting Task 2");
doTask2();
ReportProgress("Task 2 is... | <p>set up your tasks as an event stream, and have the event-processing 'engine' report progress. Each event instance can have its own name, progress-reporting blurb/template, etc. if you want to go that far</p>
<p>if this is a pattern that occurs often, it is worth the effort for the infrastructure. When you're done, ... | <p>You could call ReportProgress from inside the doTask methods, that might make it look a little cleaner, instead you would just have:</p>
<pre><code>doTask1();
doTask2();
</code></pre>
<p>The reporting would be handled inside those methods. </p>
<p>You could use AOP, but my brain screams KISS!!(Keep It Simple Stu... | 38,006 |
<p>Is there anyway to disable the rather annoying feature that Visual Studio (2008 in my case) has of copying the line (with text on it) the cursor is on when <kbd>CTRL</kbd>-<kbd>C</kbd> is pressed and no selection is made?</p>
<p>I know of the option to disable copying blank lines. But this is driving me crazy as we... | <p>The real problem you probably experience is that you go to paste, with <kbd>CTRL</kbd>+<kbd>V</kbd>. And you accidentally type<kbd> CTRL</kbd>+<kbd>C</kbd>, and end up overwriting the stuff that's on your clipboard. You can't disable this as far as I know, however, the work around for this, is that you can press <... | <p>I have the same problem, but I found a workaround of it.
When I click one time on word in text editor, all occurrences of it are highlighted.</p>
<p>Then I think I will copy this word. But double-click will select text to copy only.</p>
<p>I copy then whole line instead wanted text.</p>
<p>Problem Is: Color of highl... | 13,350 |
<p>I'm still working on groking the F# thing - trying to work out how to 'think' in F# rather than just translating from other languages I know.</p>
<p>I've recently been thinking about the cases where you don't have a 1:1 map between before and after. Cases where List.map falls down.</p>
<p>One example of this is mo... | <p>If you don't care too much about performance, here is a very simple solution:</p>
<pre><code>#light
let MovingAverage n s =
Seq.windowed n s
|> Seq.map Array.average
let avgs = MovingAverage 5000 (Seq.map float [|1..999999|])
for avg in avgs do
printfn "%f" avg
System.Console.ReadKey() |> ign... | <p>As far as I can see, your code is full of <code>let</code> statements. I'm not familiar with F# but did do some Haskell. The functional paradigm means not thinking about "how" but about "what": you think Fifo, but you should actually just specify the semantics of the moving average.</p>
<pre><code>-- the limited ... | 37,740 |
<p>I am attempting to deploy an ASP.NET 2.0 Web service application on an IIS server that currently serves a large .NET 1.0 web application. </p>
<p>I have set up an appropriate virtual directory and have set the ASP.NET version for the virtual directory to 2.0, when I attempt to browse the site in a web-browser, I am... | <p>First of all, be sure that you are running two application pools, one for any .Net 1.1 web apps, and another for any .Net 2.0 web apps.</p>
| <p>Be sure to run </p>
<pre><code>c:\windows\microsoft.net\framework\v2.0.50727\aspnet_regiis.exe -i
</code></pre>
<p>This will ensure that ASP.Net 2.0 is setup correctly with the IIS server.</p>
<p>Secondly, be sure that the Temp ASP.Net folder has read/write permissions for the user that is accessing the site (IUS... | 30,217 |
<p>Suppose I have two applications written in C#. The first is a third party application that raises an event called "OnEmailSent".</p>
<p>The second is a custom app that I've written that I would like to somehow subscribe to the "OnEmailSent" even of the first application.</p>
<p>Is there any way that I could someho... | <p>In order for two applications (separate processes) to exchange events, they must agree on how these events are communicated. There are many different ways of doing this, and exactly which method to use may depend on architecture and context. The general term for this kind of information exchange between processes is... | <p>What's the nature of that OnEmailSent event from that third party application? I mean, how do you know the application is triggering such an event?</p>
<p>If <em>you</em> are planning on doing interprocess communication, the first question you should ask yourself is: Is it really necessary?</p>
<p>Without question... | 3,847 |
<p>I need help getting my head around the difference between my current OOP notion of state, and the way it would be done in a functional language like Haskell or Clojure. </p>
<p>To use a hackneyed example, let's say we're dealing with simplified bank account objects/structs/whatever. In an OOP language, I'd have so... | <p>In a pure functional style, you'll never overwrite any variable.</p>
<p>An analogy would be to spacetime in physics. If you consider the world as 3d, then objects don't have fixed positions - they move over time. To bring math to bear on the physical world, we therefore add a time dimension and consider the value... | <p>Look at Haskell, which is a pure functional language—it has no re-assignment whatsoever, as well as no other side-effects: in order to do IO, in the <em><a href="http://www.haskell.org/haskellwiki/IO_inside#Welcome_to_the_RealWorld.2C_baby_:.29" rel="nofollow noreferrer">IO monad</a></em> construct it actually repla... | 46,099 |
<p>I have written a ruby script which opens up dlink admin page in firefox and does a ADSL connection or disconnection.</p>
<p>I could run this script in the terminal without any problem. But if I put it as cron job, it doesn't fire up firefox.</p>
<p>This is the entry I have in <em>crontab</em></p>
<pre><code># con... | <p>You need to have a DISPLAY environment pointing at a valid X-server. This could either involve setting it to the value ":0.0" (without quotes), such that it refers to your local standard DISPLAY. </p>
<p>There's a few things to keep in mind though:
You could run an X virtual frame buffer (xvfb), so that Firefox s... | <p>the crontab entry is wrong</p>
<p>it is like</p>
<pre><code>#min hour day month dow user command
55 17 * * * ur_user_is_missing ruby /home/raguanu/Dropbox/nettie.rb >> /tmp/cron_test
</code></pre>
| 17,329 |
<p>When we use getstring to get data from a recordset (ADO) then it returns all the columns.</p>
<p>If only certain columns are required, how do we modify the getstring statement?</p>
| <p>You can take a step back and build the recordset with only the fields (columns) that you want, for example:</p>
<pre><code>strSQL="SELECT ID, FName, SName FROM Members"
rs.Open strSQL, cn
a=rs.GetString
</code></pre>
| <p>You can also use a combination of join and getrows</p>
<pre><code>myString = join(rs.getrows( , , myColumn),";")
</code></pre>
<ul>
<li>rsGetrows returns an array containing only the myColumn's values</li>
<li>Join will transfer the array in a
string like "value1;value2; ..."</li>
</ul>
<p>Check the exact syntax ... | 38,186 |
<p>The title basically spells it out. What interfaces have you written that makes you proud and you use a lot. I guess the guys that wrote <code>IEnumerable<T></code> and not least <code>IQueryable<T></code> had a good feeling after creating those.</p>
| <p>I'm pleased with the design of the interface at the heart of <a href="http://msmvps.com/blogs/jon_skeet/archive/2008/01/04/quot-push-quot-linq-revisited-next-attempt-at-an-explanation.aspx" rel="nofollow noreferrer">Push LINQ</a>. It's a very simple interface, but with it you can do all kinds of interesting things. ... | <p>I am working on a validation system I plan on releasing to the community soon. It is essentially an implementation of the <a href="http://en.wikipedia.org/wiki/Specification_pattern" rel="nofollow noreferrer">Specification</a> pattern.</p>
<p>The core interface is designed to be functional in nature:</p>
<pre><cod... | 42,632 |
<p>I've got an ASP.NET page that has a bunch of controls that need to be populated (e.g. dropdown lists).</p>
<p>I'd like to make a single trip to the db and bring back multiple recordsets instead of making a round-trip for each control.</p>
<p>I could bring back multiple tables in a DataSet, or I could bring back a ... | <ol>
<li><strong>If you have more than 1000</strong> record to bring from your DataBase.</li>
<li>If you are not very interested with
custom storing and custom paging
"<em>For GridView</em>"</li>
<li>If your server have a memory stress.</li>
<li>If there is no problem to connect to
your DataBase every time that page
ca... | <p>Take a look into the TableAdapters that are available with .NET 2.0 and up. What they do is give you the strength of a strongly-typed DataTable and allow you to map a Fill method to it that will use a DataReader to load it up. Your fill method can be existing stored procedures, your own AdHoc SQL, or even let the wi... | 21,744 |
<p>I would like to create a view similar to the "Now Playing" page on the iPhone and have 3 lines of text in the Navigation bar.</p>
<p>The only way I could find to do this was:</p>
<pre><code>UINavigationBar *bar = [self.navigationController navigationBar];
label = [[UILabel alloc] initWithFrame:CGRectMake(60, 2,... | <p>You could try creating a UIViewController with your labels positioned correctly, and then instantiate it, like UIViewControllerSubclass *sub = [[UIViewControllerSubclass alloc] init];</p>
<p>Within the UIViewController subclass, you would have to build up your view in the loadView delegate method and attach each la... | <p>I tried adding an entire view.. however, the application kept crashing whenever I added a subview (like a label) to it in the loadView delegate. I'm not all that great at debugging complete crashes, so I found using a button was much more simple. I haven't found any side affects yet...</p>
<pre><code>UIButton *bt... | 46,165 |
<p>How can I dynamically invoke a class method in PHP? The class method is not static. It appears that </p>
<pre><code>call_user_func(...)
</code></pre>
<p>only works with static functions?</p>
<p>Thanks.</p>
| <p>It works both ways - you need to use the right syntax</p>
<pre><code>// Non static call
call_user_func( array( $obj, 'method' ) );
// Static calls
call_user_func( array( 'ClassName', 'method' ) );
call_user_func( 'ClassName::method' ); // (As of PHP 5.2.3)
</code></pre>
| <p>This may be useful as a substitute</p>
<pre><code>class ReferenceContainer {
function __construct(CallbackContainer $callbackContainer) {
//Alternatively you can have no parameters in this constructor and create a new instance of CallbackContainer and invoke the callback in the same manner
... | 34,405 |
<p>Given two different image files (in whatever format I choose), I need to write a program to predict the chance if one being the illegal copy of another. The author of the copy may do stuff like rotating, making negative, or adding trivial details (as well as changing the dimension of the image).</p>
<p>Do you know ... | <p>These are simply ideas I've had thinking about the problem, never tried it but I like thinking about problems like this!</p>
<p><strong>Before you begin</strong></p>
<p>Consider normalising the pictures, if one is a higher resolution than the other, consider the option that one of them is a compressed version of t... | <p>If you're willing to consider a different approach altogether to detecting illegal copies of your images, you could consider <a href="http://www.watermarkingworld.org/faq.html" rel="nofollow noreferrer">watermarking</a>. (from 1.4)</p>
<blockquote>
<p>...inserts copyright information into the digital object witho... | 4,373 |
<p>At the moment we are checking out our php producation code straight into www. With this we get all the Netbeans meta data and project files that are needed for the site, we have to constantly rm the metadata files from www so they are not accessible from the browser, same goes for all the svn metadata and files too.... | <p>Instead of checking out the project, <em>svn export</em> it. That gets rid of any svn metadata. Beyond that, I've gotta agree with acrosman's suggestion: build a script or purge files by hand.</p>
<p>I don't know about NetBeans and how much it auto-generates stuff that you may have included in svn, but in our proje... | <p>For large projects I generally write a script that checks out the project, removes any extra files (I generally remove any file from the production copy that is unneeded, like sql, setup scripts, etc.), and creates a tarball. </p>
<p>I then deploy the tarball to the staging server. Once we're happy with the condi... | 44,091 |
<p>What's the best way for a running C or C++ program that's been launched from the command line to put itself into the background, equivalent to if the user had launched from the unix shell with '&' at the end of the command? (But the user didn't.) It's a GUI app and doesn't need any shell I/O, so there's no rea... | <p>My advice: <strong>don't do this</strong>, at least not under Linux/UNIX.</p>
<p>GUI programs under Linux/UNIX traditionally do <em>not</em> auto-background themselves. While this may occasionally be annoying to newbies, it has a number of advantages:</p>
<ul>
<li><p>Makes it easy to capture standard error in cas... | <p>The most common way of doing this under Linux is via <a href="http://en.wikipedia.org/wiki/Fork_(operating_system)" rel="nofollow noreferrer">forking</a>. The same should work on Mac, as for Windows I'm not 100% sure but I believe they have something similar. </p>
<p>Basically what happens is the process splits its... | 14,221 |
<p>I have some XSD-s that define my objects hierarchy. for example math.xsd, base.xsd
while math.xsd is depends on base.xsd. I need to generate classes from those xsd-s.</p>
<p>I've already read about those two tools:
<a href="http://www.bware.biz/CodeXS/CodeXS.asmx" rel="nofollow noreferrer">CodeXS</a> tool and <a ... | <p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=89e6b1e5-f66c-4a4d-933b-46222bb01eb0&displaylang=en" rel="nofollow noreferrer">Microsoft: XSDObjectGen - Sample Code Generator 1.4.2.1</a><br />
<a href="https://stackoverflow.com/questions/289335/xsdobjectgenexe-vs-xsdexe">Stackoverflow: XSDObjec... | <p>Have you tried the <a href="http://linqtoxsd.codeplex.com/" rel="nofollow noreferrer">LINQ to XSD</a>? The project name is not really describes it's goal, so I should tell that it is useful replacement to xsd.exe.</p>
| 40,281 |
<p>I'm working in Visual Studio 2005 and have added a text file that needs to be parsed by right-clicking the project in the solution explorer and add --> new item. This places the .txt file to the project folder. The debug .exe file is in the /bin/debug folder. </p>
<p>How do I properly point to the txt file from cod... | <p>Check out the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application_members.aspx" rel="nofollow noreferrer">Application Class</a>. It has several members that can be used to locate files, etc. relative to the application once it's been installed.</p>
<p>For example, Application.Executabl... | <p>You can add a post-build event to copy the .txt file to the build output folder. Then your code can assume that the file is in the same folder as the executable.</p>
| 19,974 |
<p>I have a query where I am searching against a string:</p>
<pre><code>SELECT county FROM city WHERE UPPER(name) = 'SAN FRANCISCO';
</code></pre>
<p>Now, this works fine, but it doesn't scale well, and I need to optimize it. I have <a href="http://www.ibm.com/developerworks/db2/library/techarticle/0203adamache/0203... | <p>You could add an indexed column holding a numerical hash key of the city name. (With duplicates allowed).</p>
<p>Then you could do a multi-clause where :</p>
<pre><code>hash = [compute hash key for 'SAN FRANCISCO']
SELECT county
FROM city
WHERE cityHash = hash
AND UPPER(name) = 'SAN FRANCISCO' ;
</code></pr... | <p>Oracle supports function-based indexes. Their canonical example:</p>
<pre><code> create index emp_upper_idx on emp(upper(ename));
</code></pre>
| 3,392 |
<p>By and large, modal interfaces suck big rocks. On the other hand, I can't think of a better way to handle <em>File Open...</em>, or <em>Print...</em> and this, I think, is because </p>
<ul>
<li>they are occasional actions, infrequent and momentous, and</li>
<li>they are atomic in nature; you either finish specifyin... | <p>IMO, modal interfaces should only be used when you <strong><em>HAVE</em></strong> to deal with whatever the dialog is doing or asking before the application can continue. Any other time, if you're using a dialog, it should be non-modal. </p>
| <p>How about a user login window, you cannot (or should not) use the rest of an application until you've logged in, assuming security is necessary.</p>
| 18,452 |
<p>If I was, for example, going to <em>count</em> "activities" across many computers and show a rollup of that activity, what would the database look like to store the data? </p>
<p>Simply this? Seems too simple. I'm overthinking this.</p>
<pre><code>ACTIVITYID COUNT
---------- -----
</code></pre>
| <p>If the volume is not going to be ridiculously large, I'd probably create a table that logs each event individually, with a DateTime as @Turnkey suggests, and possibly the machine that logged it, etc.</p>
<pre><code>LOGID (PK) ACTIVITYID SOURCE DATELOGGED
---------- ---------- ------ ----------
</code></pre>
... | <p>Yes, I'm afraid it's that simple, assuming you are only interested in the number of times each activity occurs. Once you have that table populated, you could easily create, for example, a <a href="http://en.wikipedia.org/wiki/Histogram" rel="nofollow noreferrer">histogram</a> of the results by sorting on count and ... | 14,423 |
<p>I was checking Microsoft's Visual Studio page just now and in the advertisements sidebar I suddenly saw an incredible advertisement:</p>
<blockquote>
<p>"Net Express is a <a href="http://en.wikipedia.org/wiki/COBOL" rel="noreferrer">COBOL</a> development environment for extending core business processes to the .N... | <p><a href="http://www.microfocus.com" rel="noreferrer">Micro Focus</a> make a COBOL development suite that is substantially aimed at maintaining legacy mainframe applications. It speaks something like 20 dialects of COBOL from various platforms and has a <a href="http://en.wikipedia.org/wiki/CICS" rel="noreferrer">CI... | <p>I know of Raincode, Fujitsu, and Microfocus.</p>
<ul>
<li><p>Microfocus attempts ASP.NET using COBOL Codebehind.</p></li>
<li><p>Fujitsu I'm not sure if they are still offering their own web solution or attempting to fit into ASP.NET.</p></li>
<li><p>Raincode offers a standard COBOL compiler targetting .NET without... | 42,102 |
<p>I'm using a whole bunch of CALayers, creating a tile-based image not unlike GoogleMaps (different versions of the same image with more/less detail).</p>
<p>The code I'm using to do this is:</p>
<pre><code>UIImage* image = [self loadImage:obj.fileName zoomLevel:obj.zoomLevel];
[CATransaction setValue:(id)kCFBoolean... | <p>There's not a big performance boost - if anything it's the other way around. By going throuh UIImage to load up your images, you'll get all the benefits of caching that it does for you and it'll be a very speedy critter to use with your various CALayers.</p>
| <p>I don't have a definite answer but I'd guess that you'd see a slower load time when using UIImage than you'd see when using CGImage. With CGImage, you specify the image type (jpg or png) during creation, but with UIImage, the object type needs to be determined dynamically. Admittedly, this is probably as simple as l... | 24,804 |
<p>Is there a way to have TortoiseSVN (or any other tool) auto-add any new .cs files I create within a directory to my working copy so I don't have to remember which files I created at the end of the day?</p>
| <p>If you just commit your working copy, you'll get a file list showing you your unversioned files, which you can tick to add as you commit. You don't have to add them explicitly before you commit.</p>
| <p>Yes, you can add a bat file to svn (on the installed server) so that anytime you update a particular branch, that change get mimicked.. I believe its called hooks... </p>
<p>I hope this is what you meant. </p>
| 7,349 |
<p>Internet Explorer (from versions 4 to 7, at least) limits the number of files uploaded using a single 'input type="file"' form field to one. What is the best approach to take if I want to upload more than one file in a single HTTP POST request?</p>
| <p>You have to include multiple <code>input</code> controls, one per file to be uploaded.</p>
<p>If you don't know how many you want ahead of time, you can use jQuery (or plain javascript) to create them on-the-fly.</p>
| <p>There is also a great resource '<a href="http://www.cs.tut.fi/~jkorpela/forms/file.html" rel="nofollow noreferrer">File input (or "upload") in HTML forms</a>' which discusses cross-browser issues with file upload.</p>
| 22,047 |
<p>I've spent the past few hours searching, but can't seem to find the answer. Hopefully somebody here knows.</p>
<p>I want to use Virtual PC 2007 to create a virtual machine, but I'd like the hard disk for the VM to be on a USB hard drive. I'm not worried about the performance of the VM, I'd just like the VM to be ... | <p>"Versions prior to Microsoft Virtual Server 2005 supported splitting of disk images, if the disk image grew larger than the maximum supported file size on the host file system.</p>
<p>Some file systems, such as the FAT32 file system, have a 4-GB limit on file size. If the hard disk image expands more than 4 GB, Mic... | <p>Here is explaned, how to split vhd file(if link in above answer is not working):
<a href="http://leonzandman.com/2007/10/26/splitting-a-virtual-pc-vhd/" rel="nofollow">http://leonzandman.com/2007/10/26/splitting-a-virtual-pc-vhd/</a></p>
| 46,992 |
<p>I have a cheap cartesian printer with the usual arrangement - X axis with three linear bearings, build plate moving as Y axis on three linear bearings as well, Z axis with lead screws. After about 2 kg of filament printed, I can see that one of the linear bearings (the single bearing on one side of the Y axis) is le... | <p>After completion of the print job, I was able to perform a closer inspection. The black goo contains metallic particles, and the rail the bearings are riding on has a visible groove - which means replacing both the bearings and the rail.</p>
| <p>Your new oil butted out the old graphite lubricant. </p>
<p>Don't know about the metal particles though, might be dust, or your new oil caused damage to the bearings and/or rails.</p>
| 520 |
<p>Our web services are distributed across different servers for various reasons (such as decreasing latency to the client), and they're not always all up-to-date. Rather than throwing an exception when a method <em>doesn't</em> exist because the particular web service is too old, it would be nicer if we could have the... | <p>Get the WSDL (append ?wsdl to the URL) - you can parse that any way you like.</p>
| <p>When you are making a SOAP request you are just sending an HTTP request to a server. If the server understands it, it will respond with an HTTP 200 and some XML back, if it doesn't it will send you some error HTTP code (404, 500, ...)</p>
<p>There is no general way to ask for the existance of a "method" exposed by ... | 13,389 |
<p>I'm looking for a very specific eclipse plugin that will tell me if a class in my project is not implementing hashCode or/and equals methods.</p>
<p>Does anyone know of such a plugin?</p>
<p>Thanks</p>
| <p>Can you not use the <a href="http://eclipse-cs.sourceforge.net/" rel="nofollow noreferrer">Checkstyle plugin</a> and write your own Checkstyle rule? (There's a Checkstyle rule for overriding equals but not hashCode, but nothing to make sure that both are implemented for all classes, AFAIK.)</p>
| <p>Or you can use <a href="http://findbugs.sourceforge.net/" rel="nofollow noreferrer">findbugs</a></p>
<p>The rule <a href="http://findbugs.sourceforge.net/downloads.html" rel="nofollow noreferrer">HE_EQUALS_NO_HASHCODE</a> does what you want, and there is a <a href="http://findbugs.sourceforge.net/downloads.html" re... | 23,981 |
<p>Following up this question: "<a href="https://stackoverflow.com/questions/336846/database-enums-pros-and-cons">Database enums - pros and cons</a>", I'd like to know which database systems support enumeration data types, and a bit of detail on how they do it (e.g. what is stored internally, what are the limits, query... | <p>I know that MySQL does support ENUM:</p>
<ul>
<li>the data type is implemented as integer value with associated strings</li>
<li>you can have a maximum of 65.535 elements for a single enumeration</li>
<li>each string has a numerical equivalent, counting from 1, in the order of definition</li>
<li>the numerical valu... | <p>MSSQL doesn't support ENUM.</p>
<p>When you use Entity Framework 5, you can use enums (look at: <a href="http://blogs.msdn.com/b/efdesign/archive/2011/06/29/enumeration-support-in-entity-framework.aspx" rel="nofollow" title="Enumeration Support in Entity Framework ">Enumeration Support in Entity Framework </a> and ... | 43,723 |
<p>What are some things I can do to improve query performance of an oracle query without creating indexes?</p>
<p>Here is the query I'm trying to run faster:</p>
<pre><code>SELECT c.ClaimNumber, a.ItemDate, c.DTN, b.FilePath
FROM items a,
itempages b,
keygroupdata c
WHERE a.ItemType IN (112,115,189,241)
AND a.ItemNum... | <p>First I'd rewrite the query to be ANSI standard:</p>
<pre><code>SELECT c.ClaimNumber, a.ItemDate, c.DTN, b.FilePath
FROM items a
INNER JOIN itempages b ON b.ItemNum = a.ItemNum
INNER JOIN keygroupdata c ON c.ItemNum = b.ItemNum
WHERE a.ItemType IN (112,115,189,241)
ORDER BY a.DateStored DESC
</code></pre>
<p>This ... | <p>Remove the ORDER BY</p>
<p>perform the sort, after you pull the rows back to your application.</p>
| 30,254 |
<p>I would like to set the MSMQ message label using the NetMsmqBinding. I understand <a href="http://blogs.msdn.com/skaufman/archive/2007/12/17/msmq-label-property-and-wcf.aspx" rel="nofollow noreferrer">it’s easy when using the MsmqIntegrationBinding</a>, but I would like to continue to use the NetMsmqBinding (<strong... | <p>I thought this was an interesting question. Unfortunately, from everything I've seen, it looks like you can't access the Label property on an outgoing MSMQ message using NetMsmqBinding.</p>
<p>Here are some of the links I came across:</p>
<ul>
<li><p><a href="http://social.msdn.microsoft.com/Forums/en-US/wcf/thre... | <p>George: No answer, but I'm curious to know how you plan to use the MSMQ label together with NetMsmqBinding.</p>
<p>The reason I ask is that NetMsmqBinding was really created to support the scenario in which both the sending and receiving endpoints are both WCF applications, so at that point you might as well just s... | 19,855 |
<p>What's the best way to add the coordinates of a circle to an array in JavaScript? So far I've only been able to do a half circle, but I need a formula that returns the whole circle to two different arrays: <code>xValues</code> and <code>yValues</code>. (I'm trying to get the coordinates so I can animate an object al... | <p>Your loop should be set up like this instead:</p>
<pre><code>for (var i = 0; i < steps; i++) {
xValues[i] = (centerX + radius * Math.cos(2 * Math.PI * i / steps));
yValues[i] = (centerY + radius * Math.sin(2 * Math.PI * i / steps));
}
</code></pre>
<ul>
<li>Start your loop at 0</li>
<li>Step through the... | <p>I was able to solve it on my own by multiplying the number of steps by 2:</p>
<pre><code>circle: function(radius, steps, centerX, centerY){
var xValues = [centerX];
var yValues = [centerY];
for (var i = 1; i < steps; i++) {
xValues[i] = (centerX + radius * Math.cos(Math.PI * i / steps*2-Math.... | 18,828 |
<p>I recently added JQuery's date-picker control to a project. In Internet Exploder, I get the following error message:</p>
<blockquote>
<p>Internet Explorer cannot open the
Internet site</p>
<p><a href="http://localhost/" rel="nofollow noreferrer">http://localhost/</a></p>
<p>Operation aborted</p>
</blo... | <p><strong>There was a related question earlier today</strong>:</p>
<p><a href="https://stackoverflow.com/questions/266585/operation-aborted-error-in-ie7"><strong>Operation Aborted Error in IE</strong></a></p>
<p>This is a common problem.</p>
<p>It occurs in IE when a script tries to modify the DOM before the page i... | <p>This comes up a lot with Google Maps (used to drive me bonkers because it's hard to debug). One simple solution is to add the <code>defer</code> attribute to your script tags. They don't validate that way, but hey, this is real life we're talking about.</p>
| 33,503 |
<p>Is it possible to have an anonymous type implement an interface?</p>
<p>I've got a piece of code that I would like to work, but don't know how to do this.</p>
<p>I've had a couple of answers that either say no, or create a class that implements the interface construct new instances of that. This isn't really ideal... | <p>No, anonymous types cannot implement an interface. From the <a href="http://msdn.microsoft.com/en-us/library/bb397696.aspx" rel="noreferrer">C# programming guide</a>:</p>
<blockquote>
<p>Anonymous types are class types that consist of one or more public read-only properties. No other kinds of class members such a... | <p>Using Roslyn, you can dynamically create a class which inherits from an interface (or abstract class).</p>
<p>I use the following to create concrete classes from abstract classes.</p>
<p>In this example, AAnimal is an abstract class.</p>
<pre><code>var personClass = typeof(AAnimal).CreateSubclass("Person")... | 23,191 |
<p>I have to work on an old 1.3 JVM and I'm asked to create a secure connection to another server. Unfortunately the HttpsURLConnection only appears sinc JVM 1.4. </p>
<p>Is there another way to create a secure connection? Is there a library that I could you to add this fonctionnality?</p>
| <p>You need to install the Java Secure Socket Extension (JSSE), which used to be required because Sun wouldn't ship it with the JDK because of comedy export restrictions. I had a look on Sun's web site, but the JDK 1.3 instructions are preving elusive. Bear in mind that JDK 1.3 is now end-of-lifed by Sun, so they may ... | <p>You might be able to use <a href="http://java.sun.com/products/archive/jsse/" rel="nofollow noreferrer">JSSE</a>.</p>
| 19,049 |
<p>I am having a strange DB2 issue when I run DBUnit tests. My DBUnit tests are highly customized, but I don't think it is the issue. When I run the tests, I get a failure: </p>
<blockquote>
<p>SQLCODE: -1084, SQLSTATE: 57019</p>
</blockquote>
<p><a href="https://www1.columbia.edu/sec/acis/db2/db2m0/sql1000.htm" ... | <p>Oracle provides a utility called <code>tnsping</code>:</p>
<pre><code>R:\>tnsping someconnection
TNS Ping Utility for 32-bit Windows: Version 9.0.1.3.1 - Production on 27-AUG-20
08 10:38:07
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
C:\Oracle92\network\ADMIN\sqlnet.ora
... | <p>The easiest way is probably to check the <strong>PATH</strong> environment variable of the process that is connecting to the database. Most likely the tnsnames.ora file is in <em>first Oracle bin directory in path</em>..\network\admin. TNS_ADMIN environment variable or value in registry (for the current Oracle home)... | 3,170 |
<p>Is it possible for me to see the amount of processor usage (% of maximum) that the current, python, app is using?</p>
<p>Scenario:
My host will allow me to run my app as long as it does not consume more then X% of the CPU power, so I would like it to 'keep an eye on itself' and slowdown. So how can I know how muc... | <pre><code>>>> import os
>>> os.times()
(1.296875, 0.765625, 0.0, 0.0, 0.0)
>>> print os.times.__doc__
times() -> (utime, stime, cutime, cstime, elapsed_time)
Return a tuple of floating point numbers indicating process times.
</code></pre>
<p>From the (2.5) manual:</p>
<blockquote>
<p>tim... | <p>Use <code>time.clock()</code> to get the CPU time.
To get the percentage of CPU usage do CPU time elapsed/time elapsed</p>
<p>For example, if CPU time elapsed is 0.2 and time elapsed is 1 then the cpu usage is 20%.</p>
<p>Note:You have to divide by by number of processers you have. If you have 2 i.e. a dual core:<... | 34,837 |
<p>When exchanging the mainboard of my Ultimaker Original, I found the new (unoriginal) mainboard to have a condensator that is quite a little higher than on the original, which means the fan duct doesn't fit any more.</p>
<p>I read somewhere that those A4988 stepper motor drivers don't have to be actively cooled, but... | <p>This may not be your cuppa tea, but if you're willing to learn to use <a href="http://www.openscad.org/" rel="nofollow noreferrer">OpenSCAD</a> or already know how, there's a <a href="https://www.thingiverse.com/thing:1668883/" rel="nofollow noreferrer">Thingiverse</a> post that appears to directly address your obje... | <p>This is the best and simplest way I've found to transform a flat design into a 3D object that you can then save as an STL file: <a href="https://www.youtube.com/watch?v=ows2QTiMRPg" rel="nofollow noreferrer">Blender-Converting 2D Image to 3D Object</a></p>
<p>This solution requires you to use <a href="https://www.b... | 1,032 |
<p>Back in the days of Unix, you couldn't even <a href="http://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Exiting" rel="noreferrer">close a software</a> without reading the man page first. Then came Mac and Windows with consistent menu layout and keyboard shortcuts, but you still saw paper user manuals ship... | <h3>Three notes on help:</h3>
<ol>
<li>F1 / stand-alone context-sensitive help was always doomed. It was hidden by default, and so the people who most needed it were least likely to read it. There was hope at one time that we would be able to train users to always hit F1 when they ran into trouble, but too many applica... | <p>The Idiot/Dummy books must be doing quite well. Imagine if the standard application help was as good as those books. The standard F1 help for a lot of apps is just awful.</p>
<p>Is help dead? No, but some of it should be taken out and shot.</p>
| 8,578 |
<p>I have deployed ASP.NET web site and ASP.NET web service on the same web server. Both of them require access to shared file. </p>
<p>How to implement/share lock that supports single writers and multiple readers? If somebody reads, nobody can write, but all still can read. If somebody writes, nobody can read/write.<... | <p>to open file for writing with allowing other threads to read it use System.IO.File.Open method with System.IO.FileShare.Read. Ie.:</p>
<pre><code>System.IO.File.Open("path.txt",System.IO.FileMode.OpenOrCreate,System.IO.FileAccess.ReadWrite,System.IO.FileShare.Read)
</code></pre>
<p>Other (reading) threads should u... | <p>Well, you can do something like this:</p>
<pre><code>public class yourPage {
static object writeLock = new object();
void WriteFile(...) {
lock(writeLock) {
var sw = new StreamWriter(...);
... write to file ...
}
}
</code></pre>
<p>Basically, this solution is o... | 24,545 |
<p>I have developed about 300 Applications which I would like to provide with multi-language capabilities independent from the Operating System. I have written a just-in-time translator, but that is too slow in applications with many components. What would you suggest I do?</p>
| <p>We are using <a href="http://www.sicomponents.com/tsilang1.html" rel="nofollow noreferrer">TsiLang</a> and are very happy with it.</p>
<p>One of the best points is that you can pretranslate the project with a dictionary (which you filled from existing translations).</p>
| <p>Get <a href="http://www.multilizer.com/" rel="nofollow noreferrer">Multilizer</a>. It is made in Delphi and it can handle Delphi programs like no other with special support for VCL. You can even redo your screens easy for every language. With Multilizer you can use different techniques to translate and run your prog... | 28,910 |
<p>I'm using Subversive plugin in Ganymede, but after today's update it stopped working - it just doesn't see any valid svn connectors (I've already been using 1.2.0 dev version of SVNKit, instead of a stable one, because Subversive / Ganymede could not handle it; now it can't handle even the dev one). Any ideas how to... | <p>I had a similar problem right after the update. It turned out that I had been getting the connectors (the base connector and both the SVNKit and JavaHL connectors) from the Polarion site that had "ganymede" in the URL. Instead, I should have been using the general URL.</p>
<p>Checking my current configuration, you ... | <p>I'm using <a href="http://subclipse.tigris.org/" rel="nofollow noreferrer">Subclipse</a> in Ganymede successfully, maybe could you switch? I do recall having problems with SvnKit also, I'm using the JavaHL client.</p>
| 16,832 |
<p>In an asp.net application, I would like to combine the use of the Webclient Software Factory (WCSF), and its associated Model View Presenter pattern (MVP), with Page Method, that is static methods on the .aspx Views marked with the [WebMethod] attribute. </p>
<p>However, static methods on the aspx page would seem t... | <p>I had a similar problem recently when doing a MVP patterened project and wanting a lot of AJAX integration. You're best off having web services which conform to the MVP pattern that you call.</p>
<p>Keep in mind that a PageMethod is little more than a web service, just in the current page. It doesn't have access to... | <p>I think you could come close to what you are looking for by using an ASP.Net AJAX Web Service instead of static page methods. The web service has the advantage of not being static, and depending on how your views are implemented, (I'm not familiar with the specifics of the WCSF MVP pattern) you could potentially ma... | 17,041 |
<p>I have a need to work with Windows executables which are made for x86, x64, and IA64. I'd like to programmatically figure out the platform by examining the files themselves.</p>
<p>My target language is PowerShell but a C# example will do. Failing either of those, if you know the logic required that would be great... | <p>(from another Q, since removed)</p>
<p>Machine type: This is a quick little bit of code I based on some that gets the linker timestamp. This is in the same header, and it seems to work - it returns I386 when compiled -any cpu-, and x64 when compiled with that as the target platform.</p>
<p>The Exploring PE Headers... | <p>Unix OS have a utility called "file" which identifies files. The rules for identifying are kept in a description file called "magic". You could try file to see if it is able to identify your files correctly and grab the appropriate rules out of the magic file.</p>
| 24,098 |
<p>What is code coverage and how do YOU measure it?</p>
<p>I was asked this question regarding our automating testing code coverage. It seems to be that, outside of automated tools, it is more art than science. Are there any real-world examples of how to use code coverage?</p>
| <p>Code coverage is a measurement of how many lines/blocks/arcs of your code are executed while the automated tests are running.</p>
<p>Code coverage is collected by using a specialized tool to instrument the binaries to add tracing calls and run a full set of automated tests against the instrumented product. A good t... | <p><strong>For PHP you should take a look at the Github from Sebastian Bergmann</strong> </p>
<blockquote>
<p>Provides collection, processing, and rendering functionality for PHP code coverage information.</p>
</blockquote>
<p><a href="https://github.com/sebastianbergmann/php-code-coverage" rel="nofollow noreferrer... | 23,690 |
<p>My first and only 3D printer is a Printrbot Simple Metal, which has a hotend that doesn't expose any of its internal parts. Easy for beginners, I suppose: "The hotend is that tube that heats up the plastic and deposits it on the print bed."</p>
<p><a href="https://i.stack.imgur.com/7y1yy.jpg" rel="noreferrer"><img ... | <p>This varies by hotend design. The following is a list of components which you might find in a typical hotend, but note that different designs may integrate these components to some extent. For instance, on the J-head the heat block, nozzle and heatbreak are all one and the same component whereas on the E3D hotends t... | <p><strong>picture on the left</strong></p>
<p>This hotend is made out of <a href="https://en.wikipedia.org/wiki/PEEK" rel="nofollow">PEEK plastics</a> (beige). It can work in temperature upto 250C. As it is also good heat insulator then it doesn't need to have cooling fan. Red part on this picture is just a cover (in... | 345 |
<p>I have seen several postings in forums about the power connector on some ender 3's being bad and causing issues or just burning out, potentially causing a fire.</p>
<p>How can I tell if I have the bad power connector?</p>
| <p>If you can measure the voltage at the main board where the bed power line is attached, or at the last point in the wiring prior to the connector, then measure the voltage at the bed, you can compare the difference to determine if there is loss related to a failing connector.</p>
<p>One certain indication of a faili... | <p>Unless the connector has already started failing - by getting warm, creating a voltage drop, eventually melting away -, you will have to remove the shrink tubing near it.
Earlier batches had the connection crimped by the supplier of the cables, which is <strong>wrong</strong>. XT60 connectors should always be solder... | 1,540 |
<p>I'm using the Excel interop in C# (<code>ApplicationClass</code>) and have placed the following code in my finally clause:</p>
<pre><code>while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { }
excelSheet = null;
GC.Collect();
GC.WaitForPendingFinalizers();
</code></pre>
<p>Although th... | <p>Excel does not quit because your application is still holding references to COM objects.</p>
<p><strong>I guess you're invoking at least one member of a COM object without assigning it to a variable.</strong></p>
<p>For me it was the <em>excelApp.Worksheets</em> object which I directly used without assigning it to... | <p>Excel is not designed to be programmed via C++ or C#. The COM API is specifically designed to work with Visual Basic, VB.NET, and VBA. </p>
<p>Also all the code samples on this page are not optimal for the simple reason that each call must cross a managed/unmanaged boundary and further ignore the fact that the Exce... | 19,197 |
<p>I was wondering what people thought about the decision to support Entity Framework over LINQ-to-SQL? I have an application I'm developing originally in LINQ-to-SQL. I found it the perfect solution for our application. </p>
<p>While attempting to port to Entity Framework I was surprised how rough it was. IMHO, no... | <p>That is pretty much my view. See my previous reply <a href="https://stackoverflow.com/questions/276433/do-you-think-its-advantageous-to-switch-to-entity-framework#276439">here</a>. This other question wasn't specifically about the problems in EF, but yes: it has a fair few glitches. For example (in addition to your ... | <p>L2S is more mature for what it is made for.</p>
<p>And I will still consider EF as a BETA realease. </p>
<p>there is lot of discussion around EF, you can find alot more in related questions.</p>
| 45,348 |
<p>How can I debug a MinGW EXE with the Microsoft Visual C++ debugger?</p>
| <p>You can attach the Visual C++ debugger to any process running on the system (from the Visual C++ menu). But for being able to step through your source code Visual C++ would have to load the symbol file (.pdb if I remember correctly) and I don't think GCC generates those files.</p>
| <p>Exists many Visual studio extensions such us: WinGDB, VisualGDB you can find it on the web. It allows you to debug as regular Visual Studio project. These projects are not free but it has full functional 30 days trial. It has some restrictions but it's good enough.</p>
| 34,589 |
<p>I'm working on an application where users have to make a call and type a verification number with the keypad of their phone.</p>
<p>I would like to be able to detect if the number they type is correct or not. The phone system does not have access to a list of valid numbers, but instead, it will validate the number ... | <p>After some research, I think I'll go with the <strong>ISO 7064 Mod 97,10</strong> formula. It seems pretty solid as it is used to validate IBAN (International Bank Account Number).</p>
<p>The formula is very simple:</p>
<ol>
<li>Take a number : <code>123456</code></li>
<li>Apply the following formula to obtain the... | <blockquote>
<ul>
<li>I must have a reasonnable number of possible combinations (let's say 1M)</li>
<li>The code must be as short as possible, to avoid errors from the user</li>
</ul>
</blockquote>
<p>Well, if you want it to have at least one million combinations, then you need at least six digits. Is that sh... | 6,829 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.