instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>What is best practice when creating your exception classes in a .NET solution: To derive from <code>System.Exception</code> or from <code>System.ApplicationException</code>?</p>
| <p>According to Jeffery Richter in the Framework Design Guidelines book:</p>
<blockquote>
<p><code>System.ApplicationException</code> is a class that should not be part of the .NET framework.</p>
</blockquote>
<p>It was intended to have some meaning in that you could potentially catch "all" the application exceptio... | <p>I'm used to do:</p>
<pre><code>private void buttonFoo_Click()
{
try
{
foo();
}
catch(ApplicationException ex)
{
Log.UserWarning(ex);
MessageVox.Show(ex.Message);
}
catch(Exception ex)
{
Log.CodeError(ex);
MessageBox.Show("Internal error.");
}
}
<... | 7,605 |
<p>Considering you have an MVVM Architecture in WPF like <a href="http://joshsmithonwpf.wordpress.com/2008/11/14/using-a-viewmodel-to-provide-meaningful-validation-error-messages/" rel="nofollow noreferrer">Josh Smith's examples</a></p>
<p>How would you implement two properties 'synced' that update eachother? I have a... | <p>One way:</p>
<pre><code> public class Sample : INotifyPropertyChanged
{
private const double Multiplier = 1.21;
#region Fields
private double price;
private double vat;
#endregion
#region Properties
public double Price
{
get { retur... | <p>Have a look at <a href="http://polymod.codeplex.com/" rel="nofollow">Polymod.NET</a>.
If you have a 'Price' property on a domain object, you can create a model for that domain class, define a formula 'PriceVat' = Price * 0.1. The model will know that PriceVat changes when Price changes, and tell the UI about it.</p>... | 48,712 |
<p>I am trying to compile my apps (which uses 3rd party libraries) for the x64 platform. However selecting x64 from Build Configuration Manager from my VS2008 Pro doesn't seem to work. The binary does get created but my client wasn't able to get it to run on x64. </p>
<p>I wonder if the 3rd party DLLs could be the cau... | <p>Do you have x64 versions of the third party libraries? If not you are out of luck. A process must either be fully x86 or x64, you can't mix and match libraries. If the libraries are DLLs then you still need the export libraries from an x64 build.</p>
<p>In what way does selecting the x64 configuration in VS not ... | <p>"selecting x64 from Build Configuration Manager from my VS2008 Pro doesn't seem to work"<br>
I'm not sure why you would be getting binaries at all but remember that the x64 tools are not installed by default. Go back and re-run your VC2008 installer, do a custom install, and, under the VC++ bit of the tree, make su... | 20,583 |
<p>I am living on the other side of the world from my home (GMT+1 now, GMT+13 is home), and I miss my old terrestrial radio station. It has a Shoutcast stream, and I would like to simply delay it by 12 hours so that it is always available when I want to listen to it, in a way that would make its timezone be synchronise... | <p>A stream ripper would be the Easy way, and probably the Right way, but if you want to do it the Programmer way....</p>
<ul>
<li>Most development machines have quite a bit of RAM. Are you SURE you can't spare 675 MB?</li>
<li>Rather than store the output in a buffer can't you store it in a file or files(s), say an ... | <p>to answer my own question, here's a script that starts up as a cron job every 30 minutes. it dumps the incoming stream in 5-minute chunks (or set by FILE _ SECONDS ) to a particular directory. block borders are synchronised to the clock, and it doesn't start writing until the <em>end</em> of the current time chunk, ... | 43,943 |
<p>Of course I'm referring to side by side and not stacking or overlapping. 200 x 200 mm PEI and Kapton sheets are more readily available than 400 x 400 sheets. I'm wondering if anyone has tried this and if the edges of the sheets cause a problem.</p>
| <p>Aligning build surfaces isn't the main issue with 1 mm thick surfaces when aligning four 200 x 200 mm surfaces to make one 400 x 400 surface. The main issue is slight bucking at the seams from thermal mismatch. Using this with PETG tends to tear up the build surface at the seams. The image shows aligned surfaces.... | <p>I haven't tried such a thing, but a speculative answer covering the constraints and expected failure modes may suffice here.</p>
<p>Unless the sheets have squared (rather than rounded) corners, the corners will almost certainly be a problem. In particular you'd end up with a hole right at the middle of the bed.</p>
... | 1,755 |
<p>What's the best way to delete all rows from a table in sql but to keep n number of rows on the top? </p>
| <pre><code>DELETE FROM Table WHERE ID NOT IN (SELECT TOP 10 ID FROM Table)
</code></pre>
<p><strong>Edit:</strong> </p>
<p>Chris brings up a good performance hit since the TOP 10 query would be run for each row. If this is a one time thing, then it may not be as big of a deal, but if it is a common thing, then I did ... | <p>I would solve it using the technique below. The example expect an <em>article</em> table with an <em>id</em> on each row.</p>
<pre><code>Delete article where id not in (select top 1000 id from article)
</code></pre>
<p>Edit: Too slow to answer my own question ...</p>
| 6,851 |
<p>I want to have a look at how Java implements LinkedList. Where should I go to look at the source code?</p>
| <p>Install the Java SE Development Kit from <a href="http://java.sun.com/javase/downloads/index.jsp" rel="noreferrer">http://java.sun.com/javase/downloads/index.jsp</a>. </p>
<p>Once installed, you should find an archive called <code>src.zip</code> in the top of the JDK installation directory. The Java source code i... | <p>The best way to view java source code is to install Intelli-J community edition. Create a new Java project and inside your project create a new class.
Inside class if you want to see the source code of LinkedList, create a new LinkedList object as follows:</p>
<pre><code>public class LinkedListWatch{
public stat... | 32,630 |
<p>Actionscript 3.0 has decent native XML support so I'm not surprised to see a lot of people loading an external XML and then passing the object around to various modules/sections of code.</p>
<p>However my instinct is to create a class (i.e. with statically named/typed fields), populate it from the XML and pass THAT... | <p>I would say due to the XML object having no static structure it opens up a lot of possibility for errors to creep into systems and also makes the code a lot less readable and understandable.</p>
<p>So I would say yes a class is the way to go, it's extra effort but your system is a lot more structured because of it.... | <p>i tend to create "reader" classes which load the data and store it in its own XML object. I then pass whatever data is needed from the XML to other objects as native types.</p>
| 36,629 |
<p>I wish to search a database table on a nullable column. Sometimes the value I'm search for is itself NULL. Since Null is equal to nothing, even NULL, saying</p>
<pre><code>where MYCOLUMN=SEARCHVALUE
</code></pre>
<p>will fail. Right now I have to resort to</p>
<pre><code>where ((MYCOLUMN=SEARCHVALUE) OR (MYCO... | <p>You can do the IsNull or NVL stuff, but it's just going to make the engine do more work. You'll be calling functions to do column conversions which then have to have the results compared.</p>
<p>Use what you have</p>
<pre><code>where ((MYCOLUMN=SEARCHVALUE) OR (MYCOLUMN is NULL and SEARCHVALUE is NULL))
</code></... | <p>I would think that what you have is OK. You could maybe use:</p>
<pre><code>where NVL(MYCOLUMN, '') = NVL(SEARCHVALUE, '')
</code></pre>
| 23,271 |
<p>I want to write a windows service which the user can schedule. i.e, the user can choose to run the service from 9:00 AM to 6 PM daily, or he could run it every night, starting from night 12 o clock at night to next day morning 6, etc. Is there any out of the box .NET API that will help me do this? I know I can do th... | <p>My first response is to question why a service? But more importantly, the question would be why not use the powerful scheduler that is provided by the operating system?</p>
<p>That said, a windows service is pretty much just a thread that your application runs in. You could ship it in two parts, the first is the ... | <p>If you're going to schedule it, just build a console program and add some code to the installer that helps the user setup a scheduled task in windows.</p>
| 19,854 |
<p>I save stuff in an <a href="http://msdn.microsoft.com/en-us/library/3ak841sy.aspx" rel="nofollow noreferrer">Isolated Storage</a> file (using class IsolatedStorageFile). It works well, and I can retrieve the saved values when calling the saving and retrieving methods in my <a href="http://en.wikipedia.org/wiki/Data_... | <p>When you instantiated the IsolatedStorageFile, did you scope it to IsolatedStorageScope.Machine?</p>
<p>Ok now that you have illustrated your code style and I have gone back to retesting the behaviour of the methods, here is the explanation:</p>
<ul>
<li>GetMachineStoreForAssembly() - scoped to the machine and the... | <p>When you are saving, you are calling GetMachineStoreForDomain, but when you are retrieving, you are calling GetMachineStoreForAssembly.</p>
<p>GetMachineStoreForAssembly is scoped to the assembly that the code is executing in, while the GetMachineStoreForDomain is scoped to the currently running AppDomain and the a... | 9,825 |
<p>I'm writing a routine that validates data before inserting it into a database, and one of the steps is to see if numeric values fit the precision and scale of a Numeric(x,y) SQL-Server type. </p>
<p>I have the precision and scale from SQL-Server already, but what's the most efficient way in C# to get the precision ... | <pre><code>System.Data.SqlTypes.SqlDecimal.ConvertToPrecScale( new SqlDecimal (1234.56789), 8, 2)
</code></pre>
<p>gives 1234.57. it will truncate extra digits after the decimal place, and will throw an error rather than try to truncate digits before the decimal place (i.e. ConvertToPrecScale(12344234, 5,2)</p>
| <p>You can use decimal.Truncate(val) to get the integral part of the value and decimal.Remainder(val, 1) to get the part after the decimal point and then check that each part meets your constraints (I'm guessing this can be a simple > or < check)</p>
| 23,413 |
<p>I'm starting to get familiar with 3D printers. I wish to know if printing details the size of 10<sup>-7</sup> m (3.9*10<sup>-6</sup> in) is possible these days with metals or any other material.</p>
<p>If anyone has information or articles as leads, I would really appreciate it.</p>
| <p>There are no 3D printers (that I'm aware of) that can do 0.0001 millimeters, hobbyist or industrial, plastic or metal. For that matter I think you'll be hard pressed to find a CNC mill with that type of tolerances. </p>
<p>Sorry!</p>
| <p>Today, only SLA/DLP will give features of that size (if even these technologies do), and I am unaware of anyone using these technologies to print with metals today.</p>
| 535 |
<p>I want to write a <a href="http://getsongbird.com/" rel="noreferrer">Songbird</a> extension binds the multimedia keys available on all Apple Mac OS X platforms. Unfortunately this isn't an easy google search and I can't find any docs.</p>
<p>Can anyone point me resources on accessing these keys or tell me how to d... | <p>This blog post has a solution:</p>
<p><a href="http://www.rogueamoeba.com/utm/posts/Article/mediaKeys-2007-09-29-17-00.html" rel="nofollow noreferrer">http://www.rogueamoeba.com/utm/posts/Article/mediaKeys-2007-09-29-17-00.html</a></p>
<p>You basically need to subclass <code>NSApplication</code> and override <code... | <p><a href="http://www.manpagez.com/man/1/xev/" rel="nofollow noreferrer"><code>xev</code></a> might help you if you want to find out which codes are being sent by multimedia keys.</p>
| 13,985 |
<p>Flsun 3D Cube; Marlin 1.1.1; main board: Makerbase MKS Gen_L V1.0; running from either Repetier or OctoPrint.</p>
<p>I was recently obliged to replace the main board when it stopped powering the heated bed. I got the new main board - same make, version, etc - got everything setup just as it was before, but the bed ... | <p>Considering:</p>
<blockquote>
<p>Multimeter shows zero across the board's heat bed contacts</p>
</blockquote>
<p>this implies that </p>
<ul>
<li>If you measured <strong>resistance</strong>, the heated bed has no resistance. Basically this implies that the bed has a short. This might be the reason why it is not ... | <p>Since the bed was warm when you connected to 12 V that means the bed and the wiring are good. It sounds like your multimeter is not too accurate, with a reading of 0.5 Ω (or you measured accidentally some other circuit), but no worries. </p>
<p>Since both boards do not power the bed, it seems like it could be a fir... | 1,223 |
<p>Is it possible to detect when the user clicks on the browser's back button?</p>
<p>I have an Ajax application and if I can detect when the user clicks on the back button I can display the appropriate data back</p>
<p>Any solution using PHP, JavaScript is preferable. Hell a solution in any language is fine, just need... | <p>There are multiple ways of doing it, though some will only work in certain browsers. One that I know off the top of my head is to embed a tiny near-invisible iframe on the page. When the user hits the back button the iframe is navigated back which you can detect and then update your page. <a href="http://www.ajax... | <p>The dojo toolkit has functionality to deal with this in javascript. I don't think there is any good way to handle it in pure PHP.</p>
<p>Here is the docs page they have: <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/back-button-undo" rel="nofollow noreferrer">http://dojotoolk... | 7,973 |
<p>Can I run a 64-bit VMware image on a 32-bit machine?</p>
<p>I've googled this, but there doesn't seem to be a conclusive answer.</p>
<p>I know that it would have to be completely emulated and would run like a dog - but slow performance isn't necessarily an issue as I'm just interested in testing some of my backgro... | <p>The easiest way to check your workstation is to download the <a href="http://downloads.vmware.com/d/details/processor_check_5_5_dt/dCpiQGhkYmRAZQ==" rel="noreferrer">VMware Processor Check for 64-Bit Compatibility</a> tool from the VMware website.</p>
<p>You can't run a 64-bit VM session on a 32-bit processor. How... | <p>You can if your processor is 64-bit and Virtualization Technology (VT) extension is enabled (it can be switched off in BIOS). You can't do it on 32-bit processor.</p>
<p>To check this under Linux you just need to look into <em>/proc/cpuinfo</em> file. Just look for the appropriate flag (<strong>vmx</strong> for Int... | 8,004 |
<p>How can I have SQL repeat some set-based operation an arbitrary number of times without looping? How can I have SQL perform an operation against a range of numbers? I'm basically looking for a way to do a set-based for loop.<p>
I know I can just create a small table with integers in it, say from 1 to 1000 and then u... | <p>I think the very short answer to your question is to use WITH clauses to generate your own.</p>
<p>Unfortunately, the big names in databases don't have built-in queryable number-range pseudo-tables. Or, more generally, easy pure-SQL data generation features. Personally, I think this is a <strong>huge</strong> fai... | <p>If using SQL Server 2000 or greater, you could use the <strong>table datatype</strong> to avoid creating a normal or temporary table. Then use the normal table operations on it.</p>
<p>With this solution you have essentially a table structure in memory that you can use almost like a real table, but much more perfor... | 8,277 |
<p>Besides "no connection", what other failure modes should I test for? How do I simulate a high-latency link, an unreliable link, or all the other sorts of crazy stuff that will undoubtedly happen "in the wild"? </p>
<p>How about wireless applications? How do I test the performance in a less-than-ideal WL environme... | <blockquote>
<p>To add to TimK's answer, if you have a router, test pulling the upstream link on the router, this will test a bad connection without your system knowing that you lost the physical link.</p>
</blockquote>
<p>Also if you plug it back in after a few seconds it's possible that the connection won't be los... | <p>You definitely want to test physically pulling the cable out. Lots of networking code will throw different exceptions in that scenario vs when the connection has just been lost.</p>
| 4,320 |
<p>How does one go about creating a virtual CD driver on Mac OS X programatically? </p>
<p>I can't find any relevant Cocoa APIs or any pure C BSD solutions. </p>
<p>Any help or information is appreciated.</p>
| <p>You would need to use the I/O Kit framework to develop your own device driver that would emulate a virtual CD drive. Here are some links to the relevant APIs to get you started.</p>
<p><a href="http://developer.apple.com/documentation/DeviceDrivers/Conceptual/IOKitFundamentals/Introduction/chapter_1_section_1.html... | <p>The simplest way to mount a custom volume is <a href="http://macfuse.googlecode.com/" rel="nofollow noreferrer">MacFUSE</a>. It handles the IOKit details for you and lets you write the implementation in user space. However, I don’t think you can make a MacFUSE “look like” a CD; you’d have to modify FUSE to achieve t... | 28,775 |
<p>I'm VERY new to WPF, and still trying to wrap my head around binding in XAML.</p>
<p>I'd like to populate a combobox with the values of a string collection in my.settings. I can do it in code like this:</p>
<p>Me.ComboBox1.ItemsSource = My.Settings.MyCollectionOfStrings</p>
<p>...and it works.</p>
<p>How can I d... | <p><strong>Yes</strong>, you can (and should for the most part) declare bindings in XAML, since that's one of the most powerful features in WPF.</p>
<p>In your case, to bind the ComboBox to one of your custom settings you would use the following XAML:</p>
<pre><code><Window x:Class="WpfApplication1.Window1"
xm... | <p>You could also store the list as a delimited string in settings then use a converter.</p>
<pre><code><ComboBox ItemsSource="{Binding Default.ImportHistory,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay,Converter={StaticResource StringToListConverter},ConverterParameter=|}" IsEditable="True">
/// <summary&... | 25,074 |
<p>I would like to be able to refactor out the <strong>OrderBy</strong> clause in a linq expression. </p>
<p>Here is an example of a refactor of the <strong>where</strong> clause </p>
<p>before:</p>
<pre><code>results = ctx.ActiveUsers
.Where(u => u.CompanyID != 1 &&
(u.LastName.ToLower().... | <p>Assuming you want to actually take a string such as "LastName", "FirstName" etc, I'd do something like:</p>
<pre><code>var unordered = ctx.ActiveUsers
.Where(Employee.GetExpression(searchString))
.OrderBy(ordering)
.Select(u => new Employee {
... | <p>I'd agree with Jon on using lambdas where possible to avoid typos etc. However, if you genuinely can't do this (for whatever reason), I've looked at fully-dynamic <code>OrderBy</code> in the past. See <a href="http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/9ca28e3f0205bb... | 49,064 |
<p>Is there a way to auto discover a specific WCF service in the network? I don't want to config my client with the address if this is possible.</p>
| <p>What you want to look at is the WS-Discovery protocol. I found a sample on <a href="http://wcf.netfx3.com/files/folders/protocol_channels/entry7909.aspx" rel="nofollow noreferrer">netfx3's</a> website of using the <a href="http://en.wikipedia.org/wiki/WS-Discovery" rel="nofollow noreferrer">specification</a>. I wo... | <p>What you want to look at is the WS-Discovery protocol. I found a sample on <a href="http://wcf.netfx3.com/files/folders/protocol_channels/entry7909.aspx" rel="nofollow noreferrer">netfx3's</a> website of using the <a href="http://en.wikipedia.org/wiki/WS-Discovery" rel="nofollow noreferrer">specification</a>. I wo... | 8,949 |
<p>What are your opinions and experiences regarding using TDD when developing an user interface?</p>
<p>I have been pondering about this question for some time now and just can't reach a final decision. We are about to start a Silverlight project, and I checked out the <a href="http://code.msdn.microsoft.com/silverlig... | <p>Trying to test the exact placement of UI components is pointless. First because layout is subjective and should be "tested" by humans. Second, because as the UI changes you'll be constantly rewriting your tests.</p>
<p>Similarly, don't test the GUI components themselves, unless you're writing new components. Trust ... | <p>Test-Driven Development lends itself more to developing code than for developing user-interfaces. There are a few different ways in which TDD is performed, but the preferred way of true TDD is to write your tests first, then write the code to pass the tests. This is done iteratively throughout development.</p>
<p>P... | 47,337 |
<p>We have some COBOL programs running on our mainframe and we need one of those to communicate with our back end vault through a Java API. Is there any way a Cobol program can invoke the Java program?</p>
<p>Would it be possible to use a Web Service from Cobol? How would I integrate a Cobol program with anything else... | <p>Found this:</p>
<blockquote>
<p>A COBOL program can interoperate with
JAVA.</p>
<p>To achieve inter-language
interoperability with Java™, you must
follow certain rules and guidelines
for: Using services in the Java Native
Interface (JNI) Coding data types
Compiling your COBOL programs You can
i... | <p>I'm guessing that any Java integration would be a vendor extension. What compiler are you using?</p>
<p>If your Cobol program is running as a batch job, you might be able to split it into two batch jobs, one that writes all of the queries for Java land into a file, and one that uses the answers from Java land. Ru... | 19,656 |
<p>I want to implement Scrum, but I can't decide on a Sprint length. Ken Schwaber seems to relate that 30 days it the defacto... but I can't imagine waiting 30 days without the possibility of changing direction or reprioritizing. </p>
<p>Our projects usually only last 1-3 months using the waterfall method and moving t... | <p>I've worked on teams doing 1, 2 and 4 week sprints. It really is dependent on your organization. I prefer 1 or 2 week sprints. The current team I'm running is at 4 week sprints because we are coordinating efforts of 12 different products. I'm looking to move them to 2 week iterations soon.</p>
<p>The key thing to d... | <p>2 weeks (10 standard working days, if you are a M-F outfit or 12 if you are a M-S outfit) is half a month (a month typically has roughly 20 working days in it, give or take). Also, week is more vague than day but less vague than month, so it makes the unit of measurement in weeks better for more agile (more give/tak... | 33,251 |
<p>I print on a glass bed covered with BuildTak. Prints stick well, release is difficult. They sell a mod, self adhesive magnetic sheet that holds a steel plate which in turn you put the BuildTak on making it easier to get your prints off by twisting the flexible steel as opposed to chiseling your print off a glass pla... | <p>Follow up:</p>
<p>I used the 6mil magnet, cut a sheet of thin steel, (about .5mm) to fit, added a layer of Buildtak and now it's much easier to remove prints, build surface is very flat. I assume you could deform the metal beyond the magnet's ability to flatten it but it works quite well. The metal was cut with she... | <p>Try using buildtak flex. <a href="https://www.buildtak.com/product/flexplate/" rel="nofollow noreferrer">https://www.buildtak.com/product/flexplate/</a></p>
<p>or cheaper alternatives:
<a href="http://www.printinz.com/printinz-plate-3d-printer-bed-upgrade/" rel="nofollow noreferrer">http://www.printinz.com/printinz... | 504 |
<p>Is there a way to "stream" a set of results (eg. a DataTable) from a BackgroundWorker to a DataGridView. What I want to do is to query data, and fill the results in a DataGridView <strong>as they come</strong> (like query grid results in SQL Server Management Studio). My first thought was to use a BackgroundWorker (... | <p>You could:</p>
<p>Bind the DataGridView to an initially empty DataTable. </p>
<p>Then, in your worker thread, use a thread-safe collection (a synchronized queue for example) and calls to Control.BeginInvoke to pass record info over to the UI thread. </p>
<p>In the UI thread, you'd pull items out of the queue and ... | <p>If the process is taking 2 seconds or less, then I would show a "busy" cursor and do the update inline. There are 2 reasons for this:</p>
<ul>
<li><p>Somebody who starts an operation that is only going to take just a couple of seconds will still be in a "focused" mode of thinking by the time the operation has compl... | 31,520 |
<p>We are looking at hiring a software development project manager. His job is going to be concerned with running multiple dedicated project teams focused on delivery of software for external customers. He will also need to provide support to our business development unit and oversee post-implementations support of the... | <p>As with any position, you need to assess first and foremost what skills and experience you need on the team for you to be successful. Then hire to fill the gap for the skills that you do not already have on your team.</p>
<p>If you already have a team with strong technical and technical leadership skills then you d... | <p>Most has been answered already, but I'll add this:</p>
<p>Keep the same mindset that you would have when hiring an office manager. While the technology knowledge is important, you'll find that ambition, a will to learn, coupled with a team leader attitude will get you a better manager than looking at mostly technol... | 22,730 |
<p>Here's the purpose of my console program: Make a web request > Save results from web request > Use QueryString to get next page from web request > Save those results > Use QueryString to get next page from web request, etc.</p>
<p>So here's some pseudocode for how I set the code up.</p>
<pre><code> for (int i = 0;... | <p>Have you tried creating a new WebRequest object for each time during the loop, it could be the Create() method isn't adequately flushing out all of its old data.</p>
<p>Another thing to check is that the ResponseStream is adequately flushed out before the next loop iteration. </p>
| <p>Here's my terrible, hack-ish, workaround solution:</p>
<p>Make another console app that calls THIS one, in which the first console app passes an argument at the end of strURL. It works, but I feel so dirty.</p>
| 41,205 |
<p>In HTML, you can send data from one page to another using a GET request in a couple of ways:</p>
<pre><code>http://www.example.com/somepage.php?data=1
</code></pre>
<p>...or...</p>
<pre><code><form action="somepage.php" method="get">
<input type="hidden" name="data" value="1" />
<input type="su... | <p>There are only two ways to POST from a browser - a form, or an <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">Ajax</a> request.</p>
| <p>You can of course always do a GET to a page which contains server-side (or AJAX) logic which will create a POST request (e.g. GET /pageWhichCreatesAPost.py). Very messy of course, but there can be cases where such a work-around could maybe be useful.</p>
| 42,223 |
<p>The project I'm on is using a 3rd party component to build dynamic PDFs in a VB.Net web system called ABCpdf.Net. (not a terrible tool, but not a great one either.)</p>
<p>Every now and then, for reasons I can't fathom, the document object throws a SEHException. Digging futher, it turns out this is caused by a cu... | <p>Update, three months later:</p>
<p>As near as I can tell, the memory issues were all resolved when we upgraded from ABCpdf 6 to 7. It would seem that version 7 is no longer a COM object with a .NET wrapper, but all managed code from the bottom up. It's still not the greatest PDF generator out there, but the resou... | <p>I haven't specifically seen this error before, but we've had memory issues with ABC PDF before. </p>
<p>Long story short is that it is NOT a completely managed code base, but simply a .NET wrapper around their COM version. That being said, we traced our memory usage problem to not disposing of their objects prope... | 21,216 |
<p>I'm looking for some good references for learning how to model 2d physics in games. I am <strong>not</strong> looking for a library to do it for me - I want to think and learn, not blindly use someone else's work.</p>
<p>I've done a good bit of Googling, and while I've found a few tutorials on GameDev, etc., I find... | <p>Here are some resources I assembled a few years ago. Of note is the Verlet Integration.
I am also including links to some open source and commercial physics engines I found at that time. There is a stackoverflow article on this subject here: <a href="https://stackoverflow.com/questions/98628/2d-game-physics">2d ga... | <p><a href="http://www.ffconsultancy.com/products/fsharp_journal/?so" rel="nofollow noreferrer">The F#.NET Journal</a> has published two articles about this:</p>
<ul>
<li><p><a href="http://fsharpnews.blogspot.com/2009/05/downloadable-demos-from-fnet-journal.html" rel="nofollow noreferrer">Real-time Finite Element Mat... | 19,982 |
<p>Suppose we have the following code:</p>
<pre><code>ExpressionHelper.GetRouteValuesFromExpression<AccountController>(ax => ax.MyAction("a", "b"));
</code></pre>
<p>(from ASP.NET MVC Futures assembly). Method is reasonably fast - it executes 10k iterations in 150ms.</p>
<p>Now, we change code to this:</p>
... | <p>Why don't you just cache the value of the expression and its compiled value locally if this is such a bottleneck? I imagine a simply Dictionary could do the trick:</p>
<pre><code>Dictionary<Expression<Action<T>>, Action<T>> m_Cache =
new Dictionary<Expression<Action<T>>, A... | <p>Does it have to be a <code>Func<object></code>? You could probably manually craft a "capture" - i.e. have a type that declares a & b; have a <code>Func<Whatever, object></code>, and compile this to a delegate. Then all you do at runtime is:</p>
<pre><code>Foo foo = new Foo {A = a, B = b};
return cac... | 26,871 |
<p>I have a work laptop that was purchased new, but it came without the CD. It has XP Pro, but it did not come with IIS installed. This looked to be a good approach:</p>
<p><a href="http://ezinearticles.com/?Guide---How-To-Install-IIS-on-Windows-XP-SP2-Without-CD&id=416853" rel="nofollow noreferrer">http://ezinear... | <p>If you don't have your install disk - check to see if there's a directory called C:\Windows\Options\i386. The IIS components are located in IIS6.CAB.</p>
<p>You can also download the full Windows XP SP2 download which should have the IIS6.CAB file in it: <a href="http://www.microsoft.com/downloads/details.aspx?Fam... | <p>As much as I understand concerns over a question being "not programming related", please tell me how many .NET Web application developers are programming without IIS? I would argue that this would make it programming related, wouldn't you? There is nothing wrong with the question -- I mean seriously, I want to know ... | 32,126 |
<p>On my machine (XP, 64) the ASP.net worker process (w3wp.exe) always launches with 5.5GB of Virtual Memory reserved. This happens regardless of the web application it's hosting (it can be anything, even an empty web page in aspx). </p>
<p>This big old chunk of virtual memory is reserved at the moment the process sta... | <p>David Wang <a href="http://blogs.msdn.com/david.wang/archive/2006/02/14/More-on-Virtual-Memory-Memory-Fragmentation-and-Leaks-and-WOW64.aspx#541133" rel="noreferrer">answers this to a similar question</a>:</p>
<blockquote>
<p>[...] the ASP.Net performance developer tells me that: </p>
<ul>
<li>The Reserved... | <p><em>Reserved</em> memory is very different from <em>allocated</em> memory. Reserving memory just allocates address space. It doesn't commit any physical pages.</p>
<p>This address space is likely allocated by IIS for its heap. It will only commit pages when needed.</p>
<p>If you really want to launch w3wp.exe f... | 46,401 |
<p>Assume that I set up an <a href="https://stackoverflow.com/questions/204603/nightly-builds-why-should-i-do-it">automatic nightly build</a>. What artifacts of the build should I save?</p>
<p>For example:</p>
<ul>
<li>Input source code</li>
<li>output binaries</li>
</ul>
<p>Also, how long should I save them, and w... | <p>You shouldn't save anything for the sake of saving it. you should save it because you need it (i.e., QA uses nightly builds to test). At which point, "how long to save it" becomes however long QA wants them.</p>
<p>i wouldn't "save" source code so much as tag/label it. I don't know what source control you're using,... | <p>Save as in check in to source code control or just on disk? Save nothing to source code control. All derived files should be visible in the file system and available to developers. Don't checkin binaries, code generated from XML files, message digests etc. A separate packaging step will make these end products avail... | 28,546 |
<p>What is the way to avoid phpunit having to call the constructor for a mock object? Otherwise I would need a mock object as constructor argument, another one for that etc. The api seems to be like this:</p>
<pre><code>getMock($className, $methods = array(), array $arguments = array(),
$mockClassName = '', $c... | <p>You can use <code>getMockBuilder</code> instead of just <code>getMock</code>:</p>
<pre><code>$mock = $this->getMockBuilder('class_name')
->disableOriginalConstructor()
->getMock();
</code></pre>
<p>See the section on <a href="http://phpunit.de/manual/current/en/test-doubles.html">"Test Doubles"</a... | <p>PHPUnit is designed to call the constructor on mocked objects; to prevent this you should either:</p>
<ol>
<li>Inject a mock object as a dependency into the object you're having trouble mocking</li>
<li>Create a test class that extends the class you're trying to call that doesn't call the parent constructor</li>
</... | 35,323 |
<p>What the difference between <code>LPCSTR</code>, <code>LPCTSTR</code> and <code>LPTSTR</code>?</p>
<p>Why do we need to do this to convert a string into a <code>LV</code> / <code>_ITEM</code> structure variable <code>pszText</code>: </p>
<pre><code>LV_DISPINFO dispinfo;
dispinfo.item.pszText = LPTSTR((LPCTSTR)s... | <p>To answer the first part of your question:</p>
<p><code>LPCSTR</code> is a pointer to a const string (LP means <a href="https://stackoverflow.com/questions/2315311/what-is-a-long-pointer">Long Pointer</a>)</p>
<p><code>LPCTSTR</code> is a pointer to a <code>const TCHAR</code> string, (<code>TCHAR</code> being eith... | <p>The short answer to 2nd part of the question is simply that <code>CString</code> class doesn't provide a direct typecast conversion by design and what you are doing is kind of cheat.</p>
<p>A longer answer is the following:</p>
<p>The reason you can typcast <code>CString</code> to <code>LPCTSTR</code> is because CSt... | 41,601 |
<p>I am using C# to process a message in my Outlook inbox that contains attachments. One of the attachments is of type olEmbeddeditem. I need to be able to process the contents of that attachment. From what I can tell I need to save the attachment to disk and use CreateItemFromTemplate which would return an object. ... | <p>I found the following code on Google Groups for determining the type of an Outlook object:</p>
<pre><code>Type t = SomeOutlookObject.GetType();
string messageClass = t.InvokeMember("MessageClass",
BindingFlags.Public |
BindingFlags.GetField |
BindingFlags.GetProperty,
null,
SomeOutlookObject,
new obje... | <p>Working with email attachments that are also emails which in turn contains user defined properties that I want to access, then I perform the following steps:</p>
<pre><code>Outlook.Application mailApplication = new Outlook.Application();
Outlook.NameSpace mailNameSpace = mailApplication.GetNamespace(“mapi”);
// mak... | 10,801 |
<p>I am trying to implement in windows scripting host the same function as windows Send To/Mail Recipient does. Did not find anything usefull on google except steps to instantiate <code>Outlook.Application</code> and directly calling its methods.</p>
<p>I need to go the same path as windows do, as there is a mix of Ou... | <p>Use <a href="http://www.codeplex.com/stsdev" rel="nofollow noreferrer">STSDev</a> to create the solution package.
That should help with creating the WSP. The custom form, CQWP webpart and the .xls file should also be deployable within the project.</p>
<p>To deploy the xslt, your feature will have an</p>
<p><code>... | <p>But where in the folder structure do you deploy the form and the .xsl to?</p>
| 16,010 |
<p>Why are 'out' parameters in .NET a bad idea?</p>
<p>I was recently asked this, but I had no real answer besides it's simply unnecessarily complicating an application. What other reasons are there?</p>
| <p>Well, they aren't a bad idea I think. <code>Dictionary<K, V></code> has a <code>TryGetValue</code> method which is a very good example why out parameters are sometimes a very nice thing to have.</p>
<p>You should not overuse this feature of course, but it's not a bad idea per definition. Especially not in C... | <p>The out variable is not bad anyway, its really a cool stuff to use out if we need to return multiple (2 specifically) variables from a function. Sometimes its really tedious work to create a custom object just for the purpose of returning 2 variables, out is the ultimate solution. </p>
| 16,228 |
<p>We just started running in to an odd problem with a FileSystemWatcher where the call to Dispose() appears to be hanging. This is code that has been working without any problems for a while but we just upgraded to .NET3.5 SP1 so I'm trying to find out if anyone else has seen this behavior. Here is the code that creat... | <p>Just a thought... Any chance there's a deadlock issue here?</p>
<p>You're calling TreeView.Invoke, which is a blocking call. If a filesystem change happens just as you're clicking whatever button causes the FileSystemWatcher.Dispose() call, your FileWatcherFileChanged method will get called on a background thread ... | <p>We are also having this issue. Our application runs on .Net 2.0 but is compiled by VS 2008 SP1. I have .NET 3.5 SP1 installed as well. I've got no idea why this happens either, it doesn't look like a deadlock issue on our end as no other threads are running at this point (it is during application shutdown).</p>
| 9,882 |
<p>The following ListCellRenderer does not receive click events on the nested ComboBoxes. Do I need to enable something?</p>
<pre><code>class FilterCellRenderer implements ListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocu... | <p>Renderer components in swing work like "rubber stamps" -they are just used to render/paint a value and are not added to the parent container in the usual way (just think how a single component could be added in multiple places!).</p>
<p>It sounds like you may want an editor rather than a renderer (an editor is a fu... | <p>It's a little bit tricky this. I believe you need to replace the JList with a single column JTable. Then set a table cell editor as well as renderer. IIRC, there might be a problem losing the first click (which gets used to select that cell edited).</p>
<p>Also it's a very good idea to reuse the components between ... | 22,742 |
<p>Does anyone know how many options a drop down list can have? Is it unlimited? How many before performance degrades?</p>
| <blockquote>
<p>Does anyone know how many options a drop down list can have? Is it unlimited? </p>
</blockquote>
<p>I imagine it is unlimited in theory, obviously not in practice as a computer's RAM and the specific browser's limitations come into play.</p>
<blockquote>
<p>How many before performance degrades?</p... | <p>In theory, there is no limit, but some browsers will implement limits. (Similar to using <code>document.write</code> in an infinite loop.)</p>
<p>But, at the end of the day, the most I would ever recommend in a drop-down-list, is about 50, just because no-one wants to do that much scrolling. That said, if organized... | 6,433 |
<p>I am trying to write a replacement regular expression to surround all words in quotes except the words AND, OR and NOT. </p>
<p>I have tried the following for the match part of the expression:</p>
<pre><code>(?i)(?<word>[a-z0-9]+)(?<!and|not|or)
</code></pre>
<p>and </p>
<pre><code>(?i)(?<word>[a-... | <p>This is a little dirty, but it works:</p>
<pre><code>(?<!\b(?:and| or|not))\b(?!(?:and|or|not)\b)
</code></pre>
<p>In plain English, this matches any word boundary not preceded by and not followed by "and", "or", or "not". It matches whole words only, e.g. the position after the word "sand" would not be a match... | <pre><code>(?!\bnot\b|\band\b|\bor\b|\b\"[^"]+\"\b)((?<=\s|\-|\(|^)[^\"\s\()]+(?=\s|\*|\)|$))
</code></pre>
<p>I use this regex to find all words that are not within double quotes or are the words "not" "and" or "or."</p>
| 30,053 |
<p>We have to accept large file uploads (video content) and want to do that in a way that works well across all standards-compliant browsers and plug-ins. Our current setup looks like this:</p>
<ul>
<li><a href="http://swfupload.org" rel="nofollow noreferrer">SWFUpload</a></li>
<li>input type="file" for graceful degra... | <p>File uploading is always a pain.</p>
<p>I tried a few flash uploaders a while ago and it seems all of them had the limitation of not being to display a progress bar on Macs. Not to mention the upgrade to flash 10 broke most flash uploaders so users of our company app went from multiselecting a whole folder with 50 ... | <p>New versions (v2.2.0+) of SWFUpload deal with the Flash 10 issue.</p>
| 41,113 |
<p>Question: Is there any reason Autocomplete=off on a ASP:Textbox would not be working in IE 7?</p>
<p>In case this is the best term for it, the IE Autocomplete feature is that drop down list like thing that drops down from textboxes and shows you past things you have typed in.</p>
<p>I need the IE Autocomplete feat... | <p>Trying to clear out my unanswered questions that I've answered in the original post.</p>
<pre><code>test.AutoCompleteType = AutoCompleteType.None;
</code></pre>
| <p>Try this one:</p>
<pre><code>someTextbox.Attributes.Add("autocomplete", "off");
</code></pre>
| 29,849 |
<p>Has anyone been able to successfully unit test methods that are, by necessity, coupled to the System.Windows.Forms.Form class?</p>
<p>I've recently been working on a C# winforms application, trying to build it with an MVC structure. This is difficult enough, given that the framework isn't really built with this in... | <p>The best method I've heard of/used for unit testing with GUI elements is the <a href="http://www.objectmentor.com/resources/articles/TheHumbleDialogBox.pdf" rel="nofollow noreferrer">Humble Dialog</a> pattern/method. In essence, the Forms are just the interface, and all the real work is done in other classes. You un... | <p>My current thought is that I may have to use composition rather than inheritance with the Form class, to decouple the controllers from it.</p>
<p>This has the disadvantage that every time I need to use an member of the Form class that I didn't plan for, I need to add it explicitly to my view interface.</p>
| 15,591 |
<p>I'm writing code to do Xml serialization. With below function.</p>
<pre><code>public static string SerializeToXml(object obj)
{
XmlSerializer serializer = new XmlSerializer(obj.GetType());
using (StringWriter writer = new StringWriter())
{
serializer.Serialize(writer, obj);
return writer... | <p>During an object's de-serialization, the class responsible for de-serializing an object creates an instance of the serialized class and then proceeds to populate the serialized fields and properties only after acquiring an instance to populate.</p>
<p>You can make your constructor <code>private</code> or <code>inte... | <p>First of all, this what is written in <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.aspx" rel="nofollow noreferrer">documentation</a>. I think it is one of your class fields, not the main one - and how you want deserialiser to construct it back w/o parameterless construct... | 33,582 |
<p>I'm looking for a good way to represent organic growth - especially trees and flowers - using code.</p>
<p>I've found Lindenmayer Systems as a reasonable way to portray this, but need a good place to start programming this.</p>
<p>Any good suggestions?</p>
| <p>Start by looking at Laurens Lapre's LParser system page at home.wanadoo.nl/laurens.lapre/. </p>
<p>He's made the source code available and it's a great place to kick off from. The code is highly useful as it is - I once wrapped it up in a dll with minimal changes to employ in a landscape generation program and it... | <p>I am not sure how much you already know on the topic, but I believe Wikipedia's article on <a href="http://en.wikipedia.org/wiki/L-system" rel="nofollow noreferrer" title="L-system">L-system</a> should be a good start.</p>
<p>"using code" is a bit fuzzy, so I can hardly answer. You might find some freeware to exper... | 12,603 |
<p>The only thing I can get python omnicomplete to work with are system modules. I get nothing for help with modules in my site-packages or modules that I'm currently working on.</p>
| <p>I get completion for my own modules in my PYTHONPATH or site-packages. I'm not sure what version of the pythoncomplete.vim script you're using, but you may want to make sure it's the latest.</p>
<p>EDIT: Here's some examples of what I'm seeing on my system...</p>
<p>This file (mymodule.py), I puth in a directory i... | <p>I think your after the <a href="http://www.vim.org/scripts/script.php?script_id=850" rel="nofollow noreferrer">pydiction</a> script. It lets you add your own stuff and site-packages to omni complete. </p>
<p>While your at it, add the following to your python.vim file...</p>
<pre><code> set iskeyword+=.
</code></pr... | 24,282 |
<p>In an earlier question about <a href="https://stackoverflow.com/questions/280579/c-beginner-help-how-do-i-pass-a-value-from-a-child-back-to-the-parent-form">how to return a string from a dialog window</a>, <strong>yapiskan</strong> suggested <a href="https://stackoverflow.com/questions/280579/c-beginner-help-how-do-... | <p>Better to have a Public property/method and get the information. </p>
<p>What would you do if you would need 3..4..5 informations, having 5 parameters out? More clean to have accessors to get your information from the Dialog.</p>
| <p>I prefer this one because I don't like the approach of getting result from a property or a method after you have done with the class. After dialog form was shown and closed I think the object should not be used any more because logically you have done with the dialog then why should I use its property or method to g... | 35,580 |
<p>This is probably not possible, but I have this class:</p>
<pre><code>public class Metadata<DataType> where DataType : struct
{
private DataType mDataType;
}
</code></pre>
<p>There's more to it, but let's keep it simple. The generic type (DataType) is limited to value types by the where statement. What ... | <pre><code>public abstract class Metadata
{
}
// extend abstract Metadata class
public class Metadata<DataType> : Metadata where DataType : struct
{
private DataType mDataType;
}
</code></pre>
| <p>I have also used a non-generic version, using the <code>new</code> keyword:</p>
<pre><code>public interface IMetadata
{
Type DataType { get; }
object Data { get; }
}
public interface IMetadata<TData> : IMetadata
{
new TData Data { get; }
}
</code></pre>
<p>Explicit interface implementation is u... | 45,988 |
<p><strong>Intro</strong>: I'm trying to migrate our Trac SQLite to a PostgreSQL backend, to do that I need psycopg2. After clicking past the embarrassing rant on www.initd.org I downloaded the latest version and tried running <code>setup.py install</code>. This didn't work, telling me I needed mingw. So I downloaded a... | <p>Have you tried the <a href="http://www.stickpeople.com/projects/python/win-psycopg/" rel="nofollow noreferrer">binary build</a> of psycopg2 for windows? If that works with your python then it mitigates the need to build by hand.</p>
<p>I've seen random people ask this question on various lists and it seems one reco... | <p>Compiling extensions on windows can be tricky. There are precompiled libraries available however: <a href="http://www.stickpeople.com/projects/python/win-psycopg/" rel="nofollow noreferrer">http://www.stickpeople.com/projects/python/win-psycopg/</a></p>
| 15,370 |
<p>I am just getting started creating an AJAX application using server side push. I am using Grizzly Comet on Glassfish V2. Almost all the sample applications use IFrames for updating content on the client side. I want to stick to using <strong>JavaScript only</strong>. Are there any such sample applications (preferabl... | <p>The point about the push is that the HTTP request never ends. Not all client implementations handle that correctly. As I see it, it's possible to do it with pure javascript in Firefox with its extensive API, but the XMLHTTPRequest object would timeout and would not be able to stream you the content.</p>
<p>IFrame i... | <p>This is how I figured out how to do a push with just javascript and php.</p>
<p>Have javascript do an initial call and load content into a div.
Then have the javascript call back to the php and have the php sleep until it see there is a new update.
Then send out the data to everyone and call back to php and sleep a... | 39,333 |
<p>We are using <a href="http://en.wikipedia.org/wiki/JetBrains" rel="nofollow noreferrer">JetBrains</a>' <a href="http://en.wikipedia.org/wiki/DotTrace" rel="nofollow noreferrer">dotTrace</a>. What other profiling tools can be recommended that are better for profiling C# <a href="http://en.wikipedia.org/wiki/Windows_F... | <p>No. I have tried pretty much every .NET profiler on the market (ANTS, vTune, OptimizeIt, DevPartner, YourKit), and in my opinion dotTrace is the best of the lot. It is one of only two profilers I have used (the other being YourKit) that has low enough overhead to handle a highly CPU-intensive application.</p>
<p>If... | <p><a href="http://nprof.sourceforge.net/Site/Description.html" rel="nofollow noreferrer">nProf</a> is a good tool if you're looking for something free. It's kind of finicky at points, and a little buggy, but if you're on a tight budget, it'll do the job.</p>
| 7,251 |
<p>I'm working with an existing XML document which has a structure (in part) like so:</p>
<pre><code><Group>
<Entry>
<Name> Bob </Name>
<ID> 1 </ID>
</Entry>
<Entry>
<Name> Larry </Name>
</Entry>
</Group>
</... | <p><a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xelement.aspx" rel="noreferrer">XElement</a> actually has <a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xelement.op_explicit.aspx" rel="noreferrer">interesting explicit conversion operators</a> that do the right thing in this case.</... | <p>How about:</p>
<pre><code>var items = from g in xDocument.Root.Descendants("Group").Elements("Entry")
let idEl = g.Element("ID")
select new
{
name = (string)g.element("Name").Value,
id = idEl == null ? "none" : idEl.Value;
};
</code></p... | 35,128 |
<p>Whenever I try to write graphical programs (whether a game or really any GUI app) I always wind up with one or two god classes with way too many methods (and long methods, too), and each class having far too many responsibilities. I have graphics being done at the same time as calculations and logic, and I feel like... | <p>Here is a simple (but effective) OO design to get you started:</p>
<p>First create a Game object that is pure Java/C# code. With no UI or anything else platform specific. The Game object handles a Board object and a Player object. The Board object manages a number of Tile objects (where the mines are). The Player o... | <p>Sorry to say it, but it seems you have mess in your head trying to improve your coding too much in one step.</p>
<p>There is no way to answer your question as such, but here we go.</p>
<p>First start with OOP, think about what objects are required for your game/GUI and start implementing them a little at a time, s... | 49,801 |
<p>I have a problem where a Web Application needs to (after interaction from the user via Javascript)<br>
1) open a Windows Forms Application<br>
2) send a parameter to the app (e.g. an ID)</p>
<p>Correspondingly, the Windows Forms Application should be able to<br>
1) send parame... | <p>What you're asking for is possible but seems awkward.</p>
<p>Trying to call an application from a web page is not something you could do due to security considerations. You could however make a desktop application which would be associated with a certain type of files and then use content-type on the web page to ma... | <p>No I don't think it's possible.<br>
Think of viruses/trojans/spyware. If it were possible to launch an application from a mere HTML page, it would be very easy to install malware.<br>
Browsers are designed to prevent you from doing that.</p>
| 15,326 |
<p>I am just starting to fiddle with Excel via C# to be able to automate the creation, and addition to an Excel file.</p>
<p>I can open the file and update its data and move through the existing worksheets. My problem is how can I add new sheets?</p>
<p>I tried:</p>
<pre><code>Excel.Worksheet newWorksheet;
newWorksh... | <p>You need to add a COM reference in your project to the <strong>"<code>Microsoft Excel 11.0 Object Library</code>"</strong> - or whatever version is appropriate.</p>
<p>This code works for me:</p>
<pre><code>private void AddWorksheetToExcelWorkbook(string fullFilename,string worksheetName)
{
Microsoft.Office.In... | <p>You can use OLEDB to create and manipulate Excel files. See <a href="https://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c#151048">this question</a> for links and samples.</p>
| 23,468 |
<p>I'm doing some Android development, and I much prefer Visual Studio, but I'll have to use <em>Eclipse</em> for this.</p>
<p>Has anyone made a tool which can make <em>Eclipse</em> look and behave more like visual studio? I mainly can't stand its <strong>clippyesqe</strong> suggestions on how I should program (Yes, I... | <p>There are also other choices for Java IDEs. You've obviously found Eclipse, but you also may want to check out <a href="http://www.jetbrains.com/idea/index.html" rel="noreferrer">IntelliJ</a> and <a href="http://www.netbeans.org/" rel="noreferrer">NetBeans</a>. IntelliJ is not free, but has a 30 day evaluation per... | <p>I'm gonna play devils advocate here and say that forcing you to use <code>this.myString</code> is actually much safer than just <code>myString</code>. <code>myString</code> could be defined locally (in the method) or in the class as a private member. I sometimes think Visual Studio is a bit cavalier about this. In t... | 17,594 |
<p>I am using REPLACE in an SQL view to remove the spaces from a property number. The function is setup like this REPLACE(pin, ' ', ''). On the green-screen the query looked fine. In anything else we get the hex values of the characters in the field. I am sure it is an encoding thing, but how do I fix it?</p>
<p>Here ... | <p>We ended up using concat and substring to get the results we wanted.</p>
<pre><code>CREATE VIEW RLIC2GIS AS
SELECT CONCAT(SUBSTR(RCAPIN,1,3),CONCAT(SUBSTR(RCAPIN,5,2),
CONCAT(SUBSTR(RCAPIN,8,2), CONCAT(SUBSTR(RCAPIN,11,3),
SUBSTR(RCAPIN, 15,3))))) AS CAPIN13, RLICN... | <p>Try using NULL rather than an empty string. i.e. REPLACE(RCAPIN, ' ', NULL)</p>
| 15,021 |
<p>Can you have a multicolumn listview control where one of the columns is a checkbox? Example code or links would be greatly appreciated.</p>
<p>I am using visual studio 2005</p>
| <p>Better use grid view control, but if you want <strong>only</strong> one column with checkboxes and that column is the <strong>first</strong> one you can just write: </p>
<pre><code>this.listView1.CheckBoxes = true;
</code></pre>
| <p>You can try <a href="http://www.codeproject.com/KB/tree/treeviewadv.aspx" rel="nofollow noreferrer">TreeViewAdv</a>. It is open source and hosted on sourceforge.</p>
| 8,567 |
<p>How can I constrain a vertical WPF <code>StackPanel</code>'s width to the most narrow item it contains. The <code>StackPanel</code>'s width must not be greater than the width of any other child element.</p>
| <p>Unfortunately the <em>IValueConverter</em> approach will not always work; if the children are added to <em>StackPanel</em> statically, for example, the child collection will be empty at the time of binding (so I discovered). The simplest solution is to create a custom panel:</p>
<pre><code>public class ConstrainedS... | <p>You can't. A vertically oriented <code>StackPanel</code> will always allocate as much width as its children request.</p>
<p>You'd be best off writing a custom panel to achieve your desired behavior.</p>
| 49,436 |
<p>What is the correct syntax for this:</p>
<pre><code>IList<string> names = "Tom,Scott,Bob".Split(',').ToList<string>().Reverse();
</code></pre>
<p>What am I messing up?
What does TSource mean?</p>
| <p>The problem is that you're calling <code>List<T>.Reverse()</code> which returns <code>void</code>.</p>
<p>You could either do:</p>
<pre><code>List<string> names = "Tom,Scott,Bob".Split(',').ToList<string>();
names.Reverse();
</code></pre>
<p>or:</p>
<pre><code>IList<string> names = "Tom,S... | <p>What your missing here is that .Reverse() is a void method. It's not possible to assign the result of .Reverse() to a variable. You can however alter the order to use Enumerable.Reverse() and get your result</p>
<pre><code>var x = "Tom,Scott,Bob".Split(',').Reverse().ToList<string>()
</code></pre>
<p>The d... | 40,709 |
<p>Make a <strong>new AS3 Document</strong> in Flash, <strong>paste</strong> in the following code and <strong>run it:</strong></p>
<pre><code>var a:Number=0;
trace(a) // 0
a+=0.3;
trace(a) // 0.3
a+=0.3;
trace(a) // 0.6
a+=0.3;
trace(a) // 0.8999999999999999
a+=0.3;
trace(a) // 1.2
a+=0.3;
trace(a) // 1.... | <p>This is a standard floating point problem. Binary floating point numbers do not represent the full range of decimal numbers with perfect accuracy, you need to do something along the lines of</p>
<pre><code>trace (round (a, 1))
</code></pre>
<p>or, better yet, turn it into a string and strip off everything past the... | <p>One workaround is to use a scaled integer type. For this example, you could increment by 3, and then divide by 10 just before output. That avoids all the rounding errors inherent in floating point arithmetic.</p>
| 47,788 |
<p>I have let's say two pc's.PC-a and PC-b which both have the same application installed with java db support.I want from time to time to copy the data from the database on PC-a to database to PC-b and vice-versa so the two PC's to have the same data all the time.
Is there an already implemented API in the database la... | <p>As you mention in the comments that you want to "merge" the databases, this sounds like you need to write custom code to do this, as presumably there could be conficts - the same key in both, but with different details against it, for example.</p>
| <p>I guess you are using <a href="http://developers.sun.com/javadb/" rel="nofollow noreferrer">Java DB (aka Derby)</a> - in which case, assuming you just can't use a single instance, you can do a <a href="http://db.apache.org/derby/docs/10.3/adminguide/" rel="nofollow noreferrer">backup/restore</a>.</p>
| 35,495 |
<p>I am unable to load any existing projects after starting VS2008. When I try to open an existing project VS2008 will crash. It looks like it is crashing when trying to load a floating window in VS but I cant tell which one.</p>
<p>When I launch the debugger on the crashed instance I get the following message which i... | <p>You can also try running devenv.exe with the /ResetSettings argument (which will reset any custom settings you have) or with the /SafeMode flag.
/SafeMode won't help you fix your problem but it will at least narrow down the issue to the things that are different between safe and regular mode.</p>
| <p>Try renaming the:<br>
projectName.csproj.user file<br>
solutionName.suo file<br>
solutionName.ncb file<br>
... and see if the project opens. </p>
| 11,446 |
<p>Since content of web applications is dynamically generated it would appear that AdSense is not going to produce relevant ads.</p>
<p>Is there a way to increase relevancy of the AdSense ads for the web application?</p>
<p>Is it possible to achieve Gmail-like ad functionality at all for third-party applications?</p>... | <p>Sure it is possible to get relevant AdSense ads on dynamic pages. Only because we call some site "dynamic" (= we generate content on-the-fly), it doesn't mean it is not crawlable by AdSense. It all depends on how URLs on your site are constructed, and how you access pages. </p>
<p>Here's simpified sequence of how A... | <p>No, it's not really suitable. As you know, AdSense is based on page content and that's rarely going to target the correct ads unless your site is very focused on one advertising niche.</p>
<p>If you run a huge web-app that gets many millions of pageviews, then you might be able to get something worked out with Goog... | 20,089 |
<p>How does one handle a <code>DateTime</code> with a <code>NOT NULL</code>?</p>
<p>I want to do something like this:</p>
<pre><code>SELECT * FROM someTable WHERE thisDateTime IS NOT NULL
</code></pre>
<p>But how?</p>
| <p>erm it does work? I've just tested it?</p>
<pre><code>/****** Object: Table [dbo].[DateTest] Script Date: 09/26/2008 10:44:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DateTest](
[Date1] [datetime] NULL,
[Date2] [datetime] NOT NULL
) ON [PRIMARY]
GO
Insert into DateTe... | <p>SELECT * FROM Table where codtable not in (Select codtable from Table where fecha is null) </p>
| 16,766 |
<p>I'm looking for a way to sequentially number rows in a <em>result set</em> (not a table). In essence, I'm starting with a query like the following:</p>
<pre><code>SELECT id, name FROM people WHERE name = 'Spiewak'
</code></pre>
<p>The <code>id</code>s are obviously not a true sequence (e.g. <code>1, 2, 3, 4</code... | <p>To have a meaningful row number you need to order your results. Then you can do something like this:</p>
<pre><code>SELECT id, name
, (SELECT COUNT(*) FROM people p2 WHERE name='Spiewak' AND p2.id <= p1.id) AS RowNumber
FROM people p1
WHERE name = 'Spiewak'
ORDER BY id
</code></pre>
<p>Note that the WHERE ... | <p>I know this is an old thread, but I was just now looking for this answer. I tried Dan Goldstein's query in MySQL, but it didn't work as written because 'outer' is a reserved word. Then, I noticed that it is still using a sub-query, anyways.</p>
<p>So, I figured out a version using JOIN, but NO sub-query:</p>
<pr... | 24,722 |
<p>I'm quite new to NHibernate and starting to find my way around.</p>
<p>I have a domain model that is somewhat like a tree.</p>
<p>Funds have Periods have Selections have Audits<br>
Now I would like to get all Audits for a specific Fund</p>
<p>Would look like this if I made it in SQL</p>
<p>SELECT A.*<br>
FROM Au... | <p>Try this </p>
<pre><code>select elements(s.Audits)
from Fund as f inner join Period as p inner join Selection as s
where f = myFundInstance
</code></pre>
| <p>using LINQ ....</p>
<p>(from var p in Fund.Periods
let fundPeriodSelections = p.Selections
from var selection in fundPeriodSelections
select selection.Audit).ToList()</p>
<p>... but it does depend on those many-to-many / one-to-many relations being 2-way. Also, I was thinking you may need a mapping table / class ... | 19,692 |
<p>I having to downgrade my Oracle instance from 10g (10.1.0.2.0) to 9i (9.2.x.x.x).
Not having planned on ever doing this, I didn't document 10g dependencies.</p>
<p>What are some of the dependencies on 10g that I will have to address?</p>
<p>Is there any type of query that I could perform to detect dependencies?</p... | <p>Every correct algorithm has to compare adjacent cells, unless they are equal. Proof: Assume otherwise. A[i] and A[i+1] in the final array have not been compared (A[i] < A[i+1). What happens if their positions are swapped in the original array? All the comparisons made by the algorithm give the same results as in... | <p>Quicksort and Mergesort will always compare neighboring elements. Only time two elements are not compared, is when the algorithm knows there is an element in between. I think the same holds for most other <em>O</em>(<em>n</em>log <em>n</em>) sorting algorithms.</p>
| 31,253 |
<p>While I was investigating a problem I had with lexical closures in Javascript code, I came along this problem in Python:</p>
<pre><code>flist = []
for i in xrange(3):
def func(x): return x * i
flist.append(func)
for f in flist:
print f(2)
</code></pre>
<p>Note that this example mindfully avoids <code... | <p>Python is actually behaving as defined. <b>Three separate functions</b> are created, but they each have the <b>closure of the environment they're defined in</b> - in this case, the global environment (or the outer function's environment if the loop is placed inside another function). This is exactly the problem, th... | <p>The reasoning behind the behavior has already been explained, and multiple solutions have been posted, but I think this is the most pythonic (remember, everything in Python is an object!):</p>
<pre><code>flist = []
for i in xrange(3):
def func(x): return x * func.i
func.i=i
flist.append(func)
for f in... | 28,922 |
<p>We've got a PHP web service which we need to send a file from a .NET 3.5 web app.</p>
<p>The PHP team has stated that we need to provide the file in the form of a SOAP attachment, but we can't find a way from which we can do that in .NET.</p>
<p>All reference examples that we've been able to come across refer to u... | <p>From <a href="http://en.wikipedia.org/wiki/Direct_Internet_Message_Encapsulation" rel="nofollow noreferrer">Wikipedia</a>: </p>
<blockquote>
<p>Direct Internet Message Encapsulation (DIME) is a Microsoft-proposed internet
standard for the transfer of binary and other encapsulated data over SOAP."</p>
</blockqu... | <p><a href="http://msdn.microsoft.com/en-us/library/ms824597.aspx" rel="nofollow noreferrer">How to: Add Attachments to a SOAP Message by Using DIME</a></p>
| 43,547 |
<p>My <code>master</code> and <code>development</code> branches are tracked remotely on <a href="http://en.wikipedia.org/wiki/GitHub" rel="noreferrer">GitHub</a>. How do I clone both these branches?</p>
| <p>First, clone a remote <a href="http://en.wikipedia.org/wiki/Git_%28software%29" rel="noreferrer">Git</a> repository and <a href="http://en.wikipedia.org/wiki/Cd_%28command%29" rel="noreferrer"><code>cd</code></a> into it:</p>
<pre><code>$ git clone git://example.com/myproject
$ cd myproject
</code></pre>
<p>Next, lo... | <p>If you use Bitbucket, you can use <strong>import Repository</strong>. This will import all Git history (all the branches and commits).</p>
| 9,325 |
<p>This <a href="http://themechanicalbride.blogspot.com/2008/04/using-operators-with-generics.html" rel="nofollow noreferrer">article</a> describes a way, in C#, to allow the addition of arbitrary value types which have a + operator defined for them. In essence it allows the following code:</p>
<pre><code>public T Add... | <p>Due to the way templates are compiled in C++, simply doing:</p>
<pre><code>template < class T >
T add(T const & val1, T const & val2)
{
return val1 + val2;
}
</code></pre>
<p>will work, you'll get a compile error for every type where an operator+ is not defined.</p>
<p>C++ templates generate cod... | <p>Templates in C++.
In C, not without massive hassle and overhead.</p>
<pre><code>template<typename T>
T add(T x, T y)
{
return x + y;
}
</code></pre>
| 27,368 |
<p>I need a Java way to find a running Win process from which I know to name of the executable. I want to look whether it is running right now and I need a way to kill the process if I found it.</p>
| <pre><code>private static final String TASKLIST = "tasklist";
private static final String KILL = "taskkill /F /IM ";
public static boolean isProcessRunning(String serviceName) throws Exception {
Process p = Runtime.getRuntime().exec(TASKLIST);
BufferedReader reader = new BufferedReader(new InputStreamReader(
p.g... | <p>You will have to call some native code, since IMHO there is no library that does it. Since JNI is cumbersome and hard you might try to use JNA (Java Native Access). <a href="https://jna.dev.java.net/" rel="nofollow noreferrer">https://jna.dev.java.net/</a></p>
| 10,760 |
<p>When do you think we can expect the full release version of ASP.NET MVC?</p>
| <p><strong><em>EDIT (16/Jul/2009)</em></strong></p>
<p>Updating to ensure this page contains the most recent details.</p>
<p>ASP.NET MVC is now fully released <strong><em><a href="http://www.asp.net/mvc/" rel="nofollow noreferrer">http://www.asp.net/mvc/</a></em></strong>.</p>
<hr>
<p><strong><em>EDIT (28/Jan/2009)... | <p>There can be only speculations right now. I will then speculate that we will have a Beta in December (they said the next preview will be the Beta) and a full Release in February-March 2009.</p>
| 17,102 |
<p>I am writing an application using labview and need to use external code. I have read that using CINs are old fashioned and 'wrong' to use. Is this correct? Should I use shared dlls instead?</p>
<p>What are the advantages/disadvantages of both methods?</p>
| <p>I don't have personal experience of writing external code to be called by LabVIEW, but from the <a href="http://digital.ni.com/public.nsf/allkb/292A50C1FEAB6B4D86256FB9001AE6D6" rel="nofollow noreferrer">NI knowledge base</a>: "When given the choice, a DLL is the choice to make."</p>
<p>The advantages they list inc... | <p>Thanks nekomatic for your answer. If anyone else is interested in this I found an <a href="http://expressionflow.com/2007/05/19/external-code-in-labview-part2-comparison-between-shared-libraries-and-cins/" rel="nofollow noreferrer">article</a> from the depths of the internet that explains advantages and disadvantage... | 32,836 |
<p>How do I connect to a remote Oracle database instance from PHP?</p>
<p>I need to query (read only) the remote Oracle database for some information; do I need to have an Oracle Instant Client installed?</p>
<p>Is the OCI extension for PHP enough?</p>
| <p>From <a href="http://php.net/manual/en/oci8.setup.php" rel="nofollow noreferrer">PHP Manual</a></p>
<ul>
<li><p>You will need the Oracle client libraries to use this extension.</p></li>
<li><p>The most convenient way to install all the required files is to use Oracle Instant Client, which is available from <a href=... | <p>I saw this in the "Notes" section of the <a href="http://php.net/manual/en/function.oci-connect.php" rel="nofollow noreferrer">PHP documentation</a>: </p>
<blockquote>
<p><strong>If</strong> you're using PHP with Oracle Instant Client, you can use easy connect naming method (...)</p>
</blockquote>
<p>So I think ... | 10,870 |
<p>We're in the process of developing a measurement device that will be running
CE 6.0 with CF 3.5 on x86 embedded hardware, a PC is used to control the
device and is connected with it using ethernet.</p>
<p>We would like to communicate using interfaces (using DCOM (we know it is not
supported by default on CE6), .... | <p>If you're using CE 6 and .NET Compact Framework 3.5, have you considered using the Windows Communication Foundation (WCF)? You'd have to write your own transport, but when that is done, you will be able to consume your service interfaces with relative ease. </p>
| <p>As with Scott, we went down the road of using socket based communications, for performance and stability reasons. The code works well across all devices from Windows CE 2.1 up to mobile 6.0. I found the Windows CE developers handbook, ISBN 0-7821-2414-3, to be very useful in developing this functionality, albeit i... | 18,983 |
<p>I'm trying to create an Extension Method for MVC's htmlHelper.
The purpose is to enable or disable an ActionLink based on the AuthorizeAttribute set on the controller/action.
Borrowing from the <a href="http://blog.maartenballiauw.be/post/2008/08/29/Building-an-ASPNET-MVC-sitemap-provider-with-security-trimming.aspx... | <p>Here is the working code:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Principal;
using System.Web.Routing;
using System.Web.Mvc;
using System.Collections;
using System.Reflection;
namespace System.Web.Mvc.Html
{
public static class Ht... | <p>Your ViewPage has a reference to the view context, so you could make it an extension method on that instead.</p>
<p>Then you can just say if Request.IsAuthenticated or Request.User.IsInRole(...)</p>
<p>usage would be like <code><%= this.SecurityLink(text, demandRole, controller, action, values) %></code></p>... | 14,720 |
<p>I'm wondering if it's possible to embed Ruby as a scripting language in Microsoft XNA, and what's the best way to do that. I'm looking for something like <a href="http://www.xnua.com/xna_lua_xnua" rel="nofollow noreferrer">Xnua</a>, except for Ruby. </p>
<p>I've stumbled upon Ruby.NET and IronRuby and both seem to ... | <p>IronRuby and IronPython do not work on the Xbox 360 because they are based on the <a href="http://en.wikipedia.org/wiki/Dynamic_Language_Runtime" rel="nofollow noreferrer">DLR</a> (Dynamic Language Runtime) and the DLR makes heavy use of <a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.aspx" r... | <p>Why not use Ruby for PC development and Lua for 360?</p>
<p>EDIT: maybe <a href="http://rubyluabridge.rubyforge.org/" rel="nofollow noreferrer">this</a> will be useful.</p>
| 27,784 |
<p>I want to clear a element from a vector using the erase method. But the problem here is that the element is not guaranteed to occur only once in the vector. It may be present multiple times and I need to clear all of them. My code is something like this:</p>
<pre><code>void erase(std::vector<int>& myNumbe... | <p>Use the <a href="http://www.codeguru.com/forum/archive/index.php/t-231045.html" rel="noreferrer">remove/erase idiom</a>:</p>
<pre><code>std::vector<int>& vec = myNumbers; // use shorter name
vec.erase(std::remove(vec.begin(), vec.end(), number_in), vec.end());
</code></pre>
<p>What happens is that <code>... | <p>Depending on why you are doing this, using a <a href="http://www.sgi.com/tech/stl/set.html" rel="nofollow noreferrer">std::set</a> might be a better idea than std::vector.</p>
<p>It allows each element to occur only once. If you add it multiple times, there will only be one instance to erase anyway. This will make ... | 45,205 |
<p>For a small project I have to parse pdf files and take a specific part of them (a simple chain of characters). I'd like to use python to do this and I've found several libraries that are capable of doing what I want in some ways.</p>
<p>But now after a few researches, I'm wondering what is the real structure of a p... | <p>Here is a link to Adobe's reference material</p>
<p><a href="http://www.adobe.com/devnet/pdf/pdf_reference.html" rel="noreferrer">http://www.adobe.com/devnet/pdf/pdf_reference.html</a></p>
<p>You should know though that PDF is only about presentation, not structure. Parsing will not come easy.</p>
| <p>To extract text from a PDF, try this on Linux, BSD, etc. machine or use Cygwin if on Windows:</p>
<pre><code>pdfinfo -layout some_pdf_file.pdf
</code></pre>
<p>A plain text file named <code>some_pdf_file.txt</code> is created. The simpler the PDF file layout, the more straightforward the .txt file output will be.... | 11,426 |
<p>Just started doing some design. First project was a replacement handle for my angle grinder, so basically a hollow cylinder. I want to reduce the amount of material used in the print. I could sit here and punch holes through the handle with a smaller cylinder, or some other shape etc., but is there an easier way to ... | <p>Updated to match the improved question format.</p>
<p>There are a few ways to reduce material usage. First is what you have touched on. Which is to reduce the design by punching out holes, and removing all material that does not add anything to the structure. Even better is what you touched on, reducing it to the p... | <p>"<em>Just like the movies</em>"-type tech typically means <strong><em>$$$</em></strong>. </p>
<p>For those who do not own (legally or otherwise) expensive CAD software, it may be difficult to find an out-of-the-box solution. That's not to say that it can't be done.</p>
<p>A close, readily available, solution would... | 454 |
<p>Basically I want to get the number of lines-of-code in the repository after each commit.</p>
<p>The only (really crappy) ways I have found is to use <code>git filter-branch</code> to run <code>wc -l *</code>, and a script that runs <code>git reset --hard</code> on each commit, then runs <code>wc -l</code></p>
<p>T... | <p>You might also consider <a href="http://gitstats.sourceforge.net/" rel="noreferrer">gitstats</a>, which generates this graph as an html file. </p>
| <p>The first thing that jumps to mind is the possibility of your git history having a nonlinear history. You might have difficulty determining a sensible sequence of commits.</p>
<p>Having said that, it seems like you could keep a log of commit ids and the corresponding lines of code in that commit. In a post-commit h... | 4,370 |
<p>I have just started to study computer sciences at my university where they teach us programming in Scheme.</p>
<p>Since I have learned C++ for the last 6 years, Scheme appears a little odd to me. My instructors tell me you can write any program you can write in C or Java with it. </p>
<p>Is anybody really using t... | <p>Not a lot of people use it that I know, but it is definitely worth a peek (if even just to try programming in another paradigm, so that you learn to think differently). You're lucky to be able to take a class that uses Scheme, as most universities these days now teach Java. Here's a good link if you want to see some... | <p>I'm learning about it in my Program Language Design class, it has some neat uses. I would only use it for a problem that lends itself easily to tail recursion.</p>
| 37,117 |
<p>I have a problem when an unhandeld exception occurs while debugging a WinForm VB.NET project.</p>
<p>The problem is that my application terminates and I have to start the application again, instead of retrying the action as was the case in VS2003</p>
<p>The unhandeld exception is implemented in the new My.MyApplic... | <p>Ok I found the answer to this issue in this blog post: <a href="http://www.julmar.com/blog/mark/PermaLink,guid,f733e261-5d39-4ca1-be1a-c422f3cf1f1b.aspx" rel="nofollow noreferrer">Handling "Unhandled Exceptions" in .NET 2.0</a></p>
<p>Thank you Mark!</p>
<p>The short answer is: </p>
<pre><code>Application.SetUnha... | <p>I'm not sure about VS2008, but I had the same issue for awhile in VS2005. It turns out I just had to go to Debug->Exceptions (or Crtl + Alt + E) and make sure that all the Thrown boxes are unchecked, but all the User-unhandled boxes are checked.</p>
<p>You may have something different and funky going on with the c... | 22,794 |
<p>What is the easiest way to set up an SMS alerting system so that I will receive notification if my server doesn't respond or a GET query doesn't return correct content?</p>
| <p>You can completely outsource the monitoring and alerting, for example by subscribing to <a href="http://pingdom.com/" rel="nofollow noreferrer">Pingdom</a>. The most basic Pingdom plan will monitor up to 5 services (including using HTTP GETs with optional content pattern matching) and send an SMS after a configurabl... | <p>You can get a service like <a href="http://www.serviceuptime.com/" rel="nofollow noreferrer">http://www.serviceuptime.com/</a> and the send an email to your-number@a-domain-your-provider-gives They usually have the exact domains for the providers on their respective websites but you could just try @t-mobile.com if y... | 20,887 |
<p>I am running JVM 1.5.0 (Mac OS X Default), and I am monitoring my Java program in the Activity Monitor. I have the following:</p>
<pre><code>import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
public class MemoryTest {
pu... | <p>Many JVMs never return memory to the operating system. Whether it does so or not is implementation-specific. For those that don't, the memory limits specified at startup, usually through the -Xmx flag, are the primary means to reserve memory for other applications.</p>
<p>I am having a hard time finding documentati... | <p>Is the OS perhaps showing the memory which is currently allocated to the program - Even though 150~ MB is allocated it does not mean 150~ MB is in use.</p>
| 42,026 |
<p>A lot of files will be stored in the DB and I need file hashes to unique identify that the file was not changed.
(In general, will be used as the Windows Personal Firewall part)</p>
| <p>If I understand the "used as the Windows Personal Firewall" part right, MD5 is not a good choice as an algorithm.</p>
<p>There exists a successful attack on the MD5 algorithm which lets you find a different message that produces the same hash with relatively little work (as compared to brute force). That attack <em... | <p>This is, of course, not possible in general. Many people still use hashing for this purpose, and <a href="http://en.wikipedia.org/wiki/MD5" rel="nofollow noreferrer">MD5</a> is a popular algorithm, that gives you a 128-bit "signature" for the file with a high probability of changing when the contents of the file cha... | 38,675 |
<p>I'm a big subversion fan and am just about to take over a big site (200mb approx.) I've trimmed down the main site from an original size of 500MB!!</p>
<p>I'm about to check this site into a new subversion repository. The problem is, my subversion repository is remotely hosted so that another colleague can also wor... | <p>Unless I'm mistaken after the first check in/out you only handle .diff files so you only have to download/upload the changes (not the whole file just the lines that have been changed as long as the file is ASCII) that exists between the files on the client/server.</p>
<p>The first comit/update will be horrendous th... | <p>If lots of changes are being made frequently, why not have a cron entry that does a subversion update to keep your local copy up to date, say every 6 hours?</p>
<p>That way you're getting recent diffs (or none if it hasn't updated in a few hours) rather than the whole shebang.</p>
<p><strong>EDIT</strong>: for cla... | 21,076 |
<p>I have a model that's placed on the bed exactly like on this picture:</p>
<p><a href="https://i.stack.imgur.com/hDTcF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hDTcF.png" alt="sample model placement" /></a></p>
<p>I have constant quality degradation as the bed moves down to print in the uppe... | <p>I think this is resolved. After looking at every conceivable source of over-extrusion and coming up negative, <code>R.. GitHub STOP HELPING ICE</code> suggested that it might be a mechanical problem in Z axis movement, like in <a href="https://3dprinting.stackexchange.com/questions/8022/first-3-mm-prints-poorly-then... | <p>I had the same problem with my Ender-3 V2.</p>
<p>You need to check if the feeder bracket is square like explained in <a href="https://www.youtube.com/watch?v=xnzNd_FIMKY" rel="nofollow noreferrer">this YouTube</a></p>
<p>If that is not the problem maybe you need a custom bracket to change the spacing between the Z-... | 1,695 |
<p>I have imported the <code>kernel32</code> library. So, I have the <code>createMutex</code> function available but I am not quite sure of the various parameters and return values.</p>
<p>This is classic Visual Basic, not Visual Basic.NET but I can probably work with either language in the form of an answer.</p>
| <p>The VB code looks something like this:</p>
<pre><code>hMutex = CreateMutex(ByVal 0&, 1, ByVal 0&)
</code></pre>
<p>The first parameter is a pointer to an <code>SECURITY_ATTRIBUTES</code> structure. If you don't know what it is, you don't need it. Pass NULL (0).</p>
<p>The second parameter is <code>TRUE</c... | <p>Well, based on the <a href="http://msdn.microsoft.com/en-us/library/ms682411(VS.85).aspx" rel="nofollow noreferrer">documentation</a> it looks like:</p>
<ol>
<li>Security attributes (can pass null)</li>
<li>Whether it's initially owned (can pass false)</li>
<li>The name of it</li>
</ol>
<p>HTH</p>
| 2,338 |
<p>I typically use the .markdown or .md extension for markdown documents. Unfortunately spotlight refuses to index them unless they have the .txt file extension.</p>
<p>I've seen a possible solution involving <a href="http://blog.macromates.com/2007/leopard-issues/" rel="noreferrer">editing Info.plist files</a> on the... | <p>You can do this without disabling SIP by creating a copy of the system RichText.mdimporter, modifying its Info.plist and saving it in /Library/Spotlight.</p>
<pre><code>cp -r /System/Library/Spotlight/RichText.mdimporter .
patch -p2 RichText.mdimporter/Contents/Info.plist < Markdown.patch
mv RichText.mdimporter ... | <p>You <em>could</em> write a Importer, but there's an easier way. Markdown is just text, which Spotlight handles. If you give your markdown files the extension ".txt", Spotlight will pick them up.</p>
<p>In my case, I just named mine all to end with ".mdwn.txt" and taught emacs' markdown-mode to activate for files ma... | 47,742 |
<p>I am trying to access the Cache in the Application_Start method of Global.asax. I am trying to accdess Context.Cache. When I run the code from visual studio it works just fine but when I run it on the server from IIS I get: Session state is not available in this context. I want to seed some values in the cache when ... | <p>Wow. I found the answer to this. Use the variable HttpRuntime.Cache instead of Context.Cache.</p>
| <p>Yes, this changed in IIS7 with the switch to integrated mode. Application_Start executes earlier so the HttpContext is not available. </p>
<p>Visual Studio uses Cassini which differs from full IIS in several ways. Check out the newly released <a href="http://learn.iis.net/page.aspx/868/iis-express-overview/" rel="n... | 33,803 |
<p>I want to be able to introduce new 'tag lines' into a database that are shown 'randomly' to users. (These tag lines are shown as an introduction as animated text.)</p>
<p>Based upon the number of sales that result from those taglines I'd like the good ones to trickle to the top, but still show the others less frequ... | <p>Looking at your problem, I would modify the requirements a bit -</p>
<p>1) The most popular one should be shown most often.
2) Taglines should "age", so one that got a lot of votes (purchase) in the past, but none recently should be shown less often
3) Brand new taglines should be shown more often during their firs... | <p>I would suggest randomly choosing with a weighting factor based on previous sales. So let's say you had this:</p>
<ul>
<li>tag1 = 1 sale </li>
<li>tag2 = 0 sales </li>
<li>tag3 = 1 sale</li>
<li>tag4 = 2 sales</li>
<li>tag5 = 3 sales</li>
</ul>
<p>A simple weighting formula would be 1 + number of sales, so this wo... | 25,758 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.