instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I’ve been reading a few questions and answers regarding exceptions and their use. Seems to be a strong opinion that exceptions should be raised only for exception, unhandled cases. So that lead me to wondering how validation works with business objects.</p>
<p>Lets say I have a business object with getters/setters ... | <p>You want to delve a bit in the remarkable work of <a href="http://www.paulstovell.com/" rel="noreferrer">Paul Stovell</a> concerning data validation. He summed up his ideas at one time in <a href="http://www.codeproject.com/KB/cs/DelegateBusinessObjects.aspx" rel="noreferrer">this article</a>. I happen to share his ... | <p>I my opinion this is an example where throwing an exception is okay. Your property probably does not have any context by which to correct the problem, as such an exception is in order and the calling code should handle the situation, if possible.</p>
| 11,418 |
<p>I'm working with LINQ for the first time and wanted to get the Mapping to work when I have a money type in SQL, but my domain object property is of type double. How can I express this in the XML file, or in code so that the mapping does not throw the usual "invalid cast" exception?</p>
| <p>In the DBML XML file, you can set the Expression attribute of a Column element to something like this:</p>
<pre><code> <Column Name="Table1.Amount" DbType="smallint" Type="System.Int32"
Expression="CAST(Table1.Amount as int)" />
</code></pre>
| <p>pretty sure Money maps to System.Decimal</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb386947.aspx" rel="nofollow noreferrer">Check here</a></p>
| 3,698 |
<p>How do you organize DB layer, business logic and cross-platform API of your information management system, if uploading and processing 500000 data records in one session is a normal operation (C# .NET 3.5 + MS SQL 2005)?</p>
<p>I’m specifically interested in production-proven paging patterns that behave well with t... | <p>This is a good book to start with:</p>
<p><a href="http://www.amazon.co.uk/Enterprise-Application-Architecture-Addison-Wesley-signature/dp/0321127420" rel="nofollow noreferrer">Patterns of Enterprise Application Architecture</a> by Martin Fowler</p>
| <blockquote>
<p>Same with the SQL paging - it does not work in the scenario of numerous
concurrent edits (as detected by the stress-testing)</p>
</blockquote>
<p>As I mentioned, there is no magic in implementing paging – you either use ROW_NUMBER or a temporary table. The magic here is in evaluating what is your m... | 18,300 |
<p>This is on the Mac:</p>
<p>If I have two filenames /foo/foo and /foo/FOO they may refer to the same file or the may be different files depending on the file system. How do I figure out if they are both pointing to the same file? And if they are, how do I get the correct representation of the filename?</p>
<p>My pr... | <p>There's really a couple of different parts to your question. By my reading, you want:</p>
<blockquote>
<p><strong>1</strong> a way to tell if two different paths are the same on-disk file</p>
<p><strong>2</strong> a canonical name for the file on disk, with the proper casing</p>
</blockquote>
<p>There's a third issu... | <p>AFAIK, by default the filesystem in Mac OS X is Case Insensitive, thus the case of the link or filename shouldn't matter.</p>
| 48,353 |
<p>With <a href="/questions/tagged/fdm" class="post-tag" title="show questions tagged 'fdm'" rel="tag">fdm</a> printers, the 3D object that should be printed can be positioned anywhere in the build volume. But it's only practical to place it on the bottom, because otherwise support material would be necessary.<... | <p>There are several things you could try without spending much but even PLA will warp on an unheated bed. I had a Legacy Kossel that I switched to an acrylic bed and had many issues with warping and prints pulling off the bed. </p>
<p>Some cheap things to try would be...</p>
<ol>
<li>Adding a brim to the print.</l... | <p>Try a dilute solution of PVA glue (approx. 5:1 water:PVA) applied to the bed or the BuildTak like sheet and allowed to dry.
Keep the ambient temperature as high as possible (but not so high as to soften any plastic on the printer obviously).
Big brims help - consider adding them to the model rather than just apply... | 147 |
<p>What guidelines can you give for rich HTML formatting in emails while maintaining good visual stability across many clients and web based email interfaces?</p>
<p>An unrelated answer on a question on Stack Overflow suggested:</p>
<p><a href="http://www.campaignmonitor.com/blog/archives/2008/05/2008_email_design_gu... | <p>It's actually <em>really</em> hard to make a decent HTML email, if you approach it from a 'modern HTML and CSS' perspective.</p>
<p>For best results, imagine it's 1999. </p>
<ul>
<li>Go back to tables for layout (or preferably - don't attempt any complex layout)</li>
<li>Be afraid of background images (they break ... | <p>If you're including a style block don't begin any new line with ".classname" or "." anything. Put a brace or something before the period. If you don't do this some web mail systems will not properly display your style sheets.</p>
<p>Many people have incorrectly assumed they cannot use CSS blocks in emails because... | 15,515 |
<p>I'm thinking of recycling some filament from a couple of recently failed prints. I can reuse them in the future for basic prototypes, so I'm not concerned with whatever weird mixture of colors come out (they are of a few different colors).</p>
<p>The thing is, I have both PLA and ABS, in small quantities. I origina... | <p>This is not a good idea. Both filaments have different melting points, that of ABS being much higher than that of PLA. To melt the ABS you have to heat the plastic to the point where the PLA starts to degrade.</p>
| <p>yes but you would have to experiment with the settings to see were it afectivly melts.</p>
| 140 |
<p>For an image hosting web application:</p>
<p>For my stored images, is it feasible to create thumbnails on the fly using PHP (or whatever), or should I save 1 or more different sized thumbnails to disk and just load those?</p>
<p>Any help is appreciated.</p>
| <p>Save thumbnails to disk. Image processing takes a lot of resources and, depending on the size of the image, might exceed the default allowed memory limit for php. It is less of a concern if you have your own server with only your application running but it still takes a lot of cpu power and memory to resize images. ... | <p>check out the <a href="http://us2.php.net/gd" rel="nofollow noreferrer">gd library</a> and <a href="http://us2.php.net/manual/en/book.imagick.php" rel="nofollow noreferrer">imagemagick</a></p>
| 12,936 |
<p>I would like to provide my users the ability to send an image/picture (displayed through a UIImageView in the app) to their friends via email using the built-in Mail app.</p>
<p>In a way, I want a very similar user experience to the way the Photos app does this. User clicks on a button, the image/picture is copied ... | <p>If you plan on putting the app in the App Store, you're limited to the standard mailto links as specified in the iPhone URL Scheme Reference:<br>
<a href="https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MailLinks/MailLinks.html" rel="nofollow noreferrer">https://developer.apple... | <p>send the image to a web application that will inturn do the sending. using the mailto scheme will launch iphone's email application but your application will quit meaning the user will have to relaunch it later.. </p>
| 26,506 |
<p>I posted an answer to <a href="https://stackoverflow.com/questions/154706">this question</a>, including a very short rant at the end about how String.Split() should accept IEnumerable<string> rather than string[]. </p>
<p>That got me thinking. What if the base Object class from which everything else inherits pr... | <pre><code>public static IEnumerable<object> ToEnumerable(this object someObject)
{
return System.Linq.Enumerable.Repeat(someObject, 1);
}
</code></pre>
| <p><strong>the index operator ([]) isn't part of the contract of IEnumerable<T></strong>
After looking at the code in reflector, the code uses the index operator heavily, which is always part of Array.</p>
<p>Well, simply put, Array will always have an enumerator.</p>
<blockquote>
<p>The idea is that then if ... | 18,728 |
<p>What are the proper uses of:</p>
<ul>
<li><a href="https://en.cppreference.com/w/cpp/language/static_cast" rel="noreferrer"><code>static_cast</code></a></li>
<li><a href="https://en.cppreference.com/w/cpp/language/dynamic_cast" rel="noreferrer"><code>dynamic_cast</code></a></li>
<li><a href="https://en.cppreference.... | <p><strong><code>static_cast</code></strong> is the first cast you should attempt to use. It does things like implicit conversions between types (such as <code>int</code> to <code>float</code>, or pointer to <code>void*</code>), and it can also call explicit conversion functions (or implicit ones). In many cases, expli... | <p>Nice feature of <code>reinterpret_cast</code>, not mentioned in the other answers, is that it allows us to create a sort of <code>void*</code> pointer for function types. Normally, for object types one uses <code>static_cast</code> to retrieve the original type of a pointer stored in <code>void*</code>:</p>
<pre><co... | 43,012 |
<p>I am trying to get this program to give me an out put that when I do an addition, subtraction, multiplication, or division problem it will give me the answer. However, it is not working can anyone help.</p>
<pre><code>int main ()
{
int choice;
float a, b;
float sum;
float difference;
float product... | <p>What are you trying to accomplish with this line?</p>
<pre><code>scanf("%f %f %f %f", &sum, &difference, &product, &quotiont);
</code></pre>
<p>What this does is takes four numbers from the user and loads them into the four variables, respectively. Right after this line you assign new values to t... | <pre><code>#include<stdio.h>
#include<conio.h>
int main ()
{
int choice;
float a, b;
float sum;
float difference;
float product;
float quotiont;
printf("This program adds, subtracts, multiplies, and divides.\n");
printf("**************\n");
printf("* Calcu... | 34,088 |
<p>Originally I am looking for a solution in Actionscript. The point of this question is the algorithm, which detects the exact Minute, when a clock has to switch the Daylight Saving Time. </p>
<p>So for example between the 25th and the 31th of October we have to check, if the actual date is a sunday, it is before or ... | <p>There is no real algorithm for dealing with Daylight Saving Time. Basically every country can decide for themselves when -and if- DST starts and ends. The only thing we can do as developers is using some sort of table to look it up. Most computer languages integrate such a table in the language.</p>
<p>In Java you ... | <p>The <a href="https://stackoverflow.com/a/154765/642706">Answer by Richters</a> is correct and should be accepted.</p>
<p>As Richters noted, there is no logic to <a href="https://en.wikipedia.org/wiki/Daylight_saving_time" rel="nofollow noreferrer">Daylight Saving Time (DST)</a> or other anomalies. Politicians arbit... | 9,640 |
<p>I've written a screen saver that displays a web page. It works exactly as I want it to on my main display, but in the preview and secondary displays, the web view is hanging off the top of the screen.</p>
<p>Example (from preview):</p>
<a href="http://skitch.com/dlsspy/6mds/screen-saver-bug" rel="nofollow norefer... | <p>PowerShell will actually treat any comma-separated list as an array:</p>
<pre><code>"server1","server2"
</code></pre>
<p>So the @ is optional in those cases. However, for associative arrays, the @ is required:</p>
<pre><code>@{"Key"="Value";"Key2"="Value2"}
</code></pre>
<p>Officially, @ is the "array operator."... | <p>I hope this helps to understand it a bit better.
You can store "values" within a key and return that value to do something.
In this case I have just provided @{a="";b="";c="";} and if not in the options i.e "keys" (a, b or c) then don't return a value</p>
<pre><code>... | 47,503 |
<p>I am currently initializing a Hashtable in the following way:</p>
<pre><code>Hashtable filter = new Hashtable();
filter.Add("building", "A-51");
filter.Add("apartment", "210");
</code></pre>
<p>I am looking for a nicer way to do this.</p>
<p>I tried something like </p>
<pre><code>Hashtable filter2 = new Hashtabl... | <p>The exact code you posted:</p>
<pre><code> Hashtable filter2 = new Hashtable()
{
{"building", "A-51"},
{"apartment", "210"}
};
</code></pre>
<p>Compiles perfectly in C# 3. Given you reported compilation problems, I'm guessing you are using C# 2? In this case you can a... | <p>I think the real question being asked may be about imaginable constructors such as:</p>
<p>HashTable ht = new HashTable(MyArray) ; // fill from array</p>
<p>HashTable ht = new HashTable(MyDataTable) ; // fill from datatable</p>
<p>AFAIK, the answer is "no", but you could write it yourself. I assume the reason tha... | 15,613 |
<p>I am VERY new to ASP.NET. I come from a VB6 / ASP (classic) / SQL Server 2000 background. I am reading a lot about Visual Studio 2008 (have installed it and am poking around). I have read about "reflection" and would like someone to explain, as best as you can to an older developer of the technologies I've writte... | <p>Reflection is how you can explore the internals of different Types, without normally having access (ie. private, protected, etc members).</p>
<p>It's also used to dynamically load DLL's and get access to types and methods defined in them without statically compiling them into your project.</p>
<p>In a nutshell: Re... | <p>When you build <em>any</em> assembly in .NET (ASP.NET, Windows Forms, Command line, class library etc), a number of meta-data "definition tables" are also created within the assembly storing information about methods, fields and types corresponding to the types, fields and methods you wrote in your code. </p>
<p>T... | 20,663 |
<p>I need to copy data values from one element to another, but jQuery's clone() method doesn't clone the data. And I can't iterate over the data either:</p>
<pre><code>element.data().each
</code></pre>
<p>because <code>data()</code> is a function and not a jQuery object. It seems I have to keep a separate list of att... | <p>To really only copy the data-*, this is quite straightforward:</p>
<pre><code>$(destination).data( $(source).data() );
</code></pre>
<p>This is because using .data() no arguments will return a key-value object of all pieces of data and vice versa you can also update multiple pieces data at once using a key-value o... | <p>To give another alternative, i.e. instead of cloning the whole object you can copy the data object to a new array containing name/value pairs followingly:</p>
<pre><code>
function getOriginalElementData(domElementJQueryObject){
var originalElementData = new Array();
$.each(domElementJQueryObject.data(),func... | 21,435 |
<p>I would like to find all the rows in a table and match on an exact case sensitive string. Unfortunately, my table has the case insensitive collation. </p>
<p>What is the most efficient way to perform this.</p>
<p>Eg.</p>
<p>I would like the following to return no rows:</p>
<pre><code>select * from sysobject wher... | <p>Here is a snippet of code that works, its really tricky to do this in a safe and efficient way. The double match is to avoid a table scan (look at the execution plan). The varbinary casting forces a length and case match. So trailing spaces are treated properly and casing is treated properly. </p>
<p><strong>Note</... | <p>Actually I don't see why you have to do the escaping first, this is built into SQL server through the COLLATE statment. </p>
<pre><code>select * from sysobjects
WHERE name = @match and --Get all relevant hits from the index before doing the final case sensitive test
name COLLATE Latin1_General_CS_AS = @match COLLAT... | 39,483 |
<p>Is there any example code of a <a href="http://www.python.org/" rel="noreferrer">cpython</a> (not IronPython) client which can call Windows Communication Foundation (WCF) service?</p>
| <p>WCF needs to expose functionality through a communication protocol. I think the most commonly used protocol is probably SOAP over HTTP. Let's assume that's
what you're using then.</p>
<p>Take a look at <a href="https://linux.die.net/diveintopython/html/soap_web_services/index.html" rel="nofollow noreferrer">this... | <p>Even if there is not a specific example of calling WCF from Python, you should be able to make a fully SOAP compliant service with WCF. Then all you have to do is find some examples of how to call a normal SOAP service from Python.</p>
<p>The simplest thing will be to use the BasicHttpBinding in WCF and then you ca... | 34,824 |
<p>I have created a custom UserControl in Managed C++ that wraps some native code controls. I have confirmed the control works at runtime, and have been trying to make the control work with the Visual Studio designer by allowing drag and drop of the control from the designer toolbox.</p>
<p>While I have successfully a... | <p>Visual studio is unaware of any unmanaged dependency. You will have to copy the dll's your self or copy them into your windows\system32 directory.</p>
<p>Two other strategies for dealing with this.</p>
<ol>
<li><p>Wrap this assembly with another assembly and manually load your mixed dll with assembly.loadfrom. th... | <p>Try not to put anything in the constructor of the control that will access files.
If you have to, sometimes the DesignTime property helps in skipping the offending lines.</p>
| 38,106 |
<p>I am wondering if there is any way to list all the calls to a function in source code, so that I could see the dependencies if I modify that function.</p>
<p>One method I use is to search the function name in the "Entire Solution" but I am looking for a better way.</p>
| <p>Right-click on the call and select "Find All References".</p>
| <p>Use <a href="http://www.ndepend.com/" rel="nofollow noreferrer">NDepend</a>. It comes with a VS add-in that allows you to do CQL queries on the fly. See <a href="http://www.ndepend.com/Res/NDependBig09.PNG" rel="nofollow noreferrer">this screenshot</a>.</p>
| 43,602 |
<p>I am looking to create an ASP.net page that will have a control like GridView or Repeater and the data to be displayed in this page can be either unicode or Utf-8 . I am really struggling to display languages like Hebrew and some asian languages. </p>
<p>How do I show any type of language on the ASP.net page?? I ha... | <p>Ideally, this should all be handled transparently by your environment. Unfortunately, "the environment" also hands you several tools with which to mess things up.</p>
<p>Two things need to happen. Your server needs to know what encoding it is supposed to send to the client and the browser needs to know what that en... | <p>Make sure that Response.Charset = UTF-8.</p>
| 45,650 |
<p>I can successfully connect to MySQL from a DOS prompt, but when I try to connect from cygwin, it just hangs.</p>
<pre><code>$/cygdrive/c/Program\ Files/MySQL/MySQL\ Server\ 5.1/bin/mysql -u root -p
</code></pre>
<p>What's wrong?</p>
| <p>I just came across this, and when I read someone's mention of it being a windows/DOS command that you run in cygwin I did a <code>which mysql</code> and that gave me:</p>
<pre><code>$ which mysql
/cygdrive/c/Program Files/MySQL/MySQL Server 5.5/bin/mysql
</code></pre>
<p>So I ran the cygwin <code>Setup.exe</code> ... | <p>I have created a semi-fix for this that satisfies me.
I ran cygwin.bat in cmd.exe, then typing mysql in- everything worked fine.</p>
<p>I realized right there that the problem was mintty.</p>
<p>Easy solution? Download <a href="http://sourceforge.net/projects/console/" rel="nofollow">Console2</a>, and under settin... | 42,732 |
<p>I have just come across a Visual C++ option that allows you to force file(s) to be included - this came about when I was looking at some code that was missing a <code>#include "StdAfx.h"</code> on each .cpp file, but was actually doing so via this option.</p>
<p>The option can be found on the <strong>Advanced C/C++... | <p>I would discourage from /FI (<a href="http://msdn.microsoft.com/en-us/library/8c5ztk84.aspx" rel="noreferrer">MSDN</a> says it's called /FI . Not sure whether i looked at the right page though), simply because people or yourself reading the files don't notice a header is magically included anyway. </p>
<p>You can ... | <p>Save this function for when something weird comes up - like if you want to include a header in a generated source file. Even then there are likely better ways.</p>
| 41,494 |
<p>I am using the following code:</p>
<pre><code><?php
$stock = $_GET[s]; //returns stock ticker symbol eg GOOG or YHOO
$first = $stock[0];
$url = "http://biz.yahoo.com/research/earncal/".$first."/".$stock.".html";
$data = file_get_contents($url);
$r_header = '/Prev. Week(.+?)Next Week/';
$r_date = '/\<b\>(... | <p>Problem is that the HTML has newlines in it, which you need to incorporate with the s regex modifier, as below</p>
<pre><code><?php
$stock = "goog";//$_GET[s]; //returns stock ticker symbol eg GOOG or YHOO
$first = $stock[0];
$url = "http://biz.yahoo.com/research/earncal/".$first."/".$stock.".html";
$data = fil... | <p>I think this is because you're applying the values to the regex as if it's plain text. However, it's HTML. For example, your regex should be modified to parse: </p>
<p><code><a href="...">Prev. Week</a> ...</code> </p>
<p>Not to parse regular plain text like: "Prev. Week ...."</p>
| 27,563 |
<p>In an ASP.NET web application with a lot of HTML pages, a lot of inline JavaScript functions are accumulating. What is a good plan for organizing them into external files? Most of the functions are particular to the page for which they are written, but a few are relevant to the entire application.</p>
<p>A single... | <p>You probably want each page to have its page-specific JavaScript in one place, and then all the shared JavaScript in a large file. If you SRC the large file, then your users' browsers will cache the JavaScript code on the first load, and the file size won't be an issue. If you're particularly worried about it, you... | <p>I would recommend that if you split your JS into seperate files, that you do not use lots of tags to include them , that will kill page-load performance. Instead, use server-side includes to inline them before they leave the server.</p>
| 16,839 |
<p>I read some of the answers on here re: testing views and controllers, and mocking, but I still can't figure out how to test an ASP.NET MVC controller that reads and sets Session values (or any other context based variables.)
How do I provide a (Session) context for my test methods? Is mocking the answer? Anybody hav... | <p>Check out Stephen Walther's post on Faking the Controller Context:</p>
<p><a href="http://stephenwalther.com/blog/archive/2008/07/01/asp-net-mvc-tip-12-faking-the-controller-context.aspx" rel="noreferrer">ASP.NET MVC Tip #12 – Faking the Controller Context</a></p>
<pre><code>[TestMethod]
public void TestSessionSta... | <p>Because HttpContext is static, I use Typemock Isolator to mock it, Typemock also has an Add-in custom built for <a href="http://www.typemock.com/ASP.NET_unit_testing_page.php" rel="nofollow noreferrer">ASP.NET unit testing</a> called <a href="http://sm-art.biz/Ivonna.aspx" rel="nofollow noreferrer">Ivonna</a> .</p>
| 21,246 |
<p>I am doing laboratory experiments and need to print some components.</p>
<p>I am working with different aqueous (water) solutions containing sulphuric acid (H<sub>2</sub>SO<sub>4</sub>), hydrochloric acid (HCl), and hydrogen peroxide (H<sub>2</sub>O<sub>2</sub>), separately and in combination. The pH of the solutio... | <p>There are two issues you have here, one is temperature stability and the other is chemical reactivity of plastics. I can't help you with the chemistry side, but I can help with the temperature.</p>
<h1>Application 1 (Temp < 40 °C)</h1>
<p>Any FDM plastic will perform reasonably well under these temperatures. I wo... | <p>There are two issues you have here, one is temperature stability and the other is chemical reactivity of plastics. I can't help you with the chemistry side, but I can help with the temperature.</p>
<h1>Application 1 (Temp < 40 °C)</h1>
<p>Any FDM plastic will perform reasonably well under these temperatures. I wo... | 567 |
<p>I recently had to rename a table (and a column and FK/PK contraints) in SQL Server 2000 without losing an data. There did not seem to be an obvious DDL T-SQL statements for performing this action, so I used sp_rename to directly fiddle with object names.</p>
<p>Was this the only solution to the problem? (other, tha... | <p>sp_rename is the correct way to do it.</p>
<pre><code>EXEC sp_rename 'Old_TableName', 'New_TableName'
</code></pre>
| <p>Maybe not the only: I guess you could always toy with the master database and update the table name there - but this is highly unrecommendable.</p>
| 19,533 |
<p>Title says most of it. </p>
<p>I have inherited a Joomla site and the client wants part of the main template (a feature-type box) to be editable via the Joomla backend.</p>
<p>I guess really it is a content item that never gets displayed as its own page, but as a part of all pages.</p>
<p>Is that possible?</p>
<... | <p>The Custom HTML Module allows you to create, edit, and display your own free-form HTML on a Joomla site using a WYSIWYG editor.</p>
<p>In your administration control panel you can find the "Module Manager" under "Extensions" in the drop down navigation menu. There you can create this module, choose a position in yo... | <p>Joomla templates are always editable via the backend. Just got to Extensions->Template Manager->Select the template you're using to edit it->and then up in the toolbar there will options for editing the html or the css as well as many design (look) options over on the right. That is in Joomla 1.5.</p>
| 25,407 |
<p>I want to access the call stack at runtime in a Native C++ application. I am not using the IDE. How do I display the call stack?</p>
<p>Update: I have a function which is called from many points all over the application. It crashes on rare occasions. I was looking for a way to get name of the caller and log it.</p>... | <p>Have a look at <a href="http://msdn.microsoft.com/en-us/library/ms680650(VS.85).aspx" rel="nofollow noreferrer">StackWalk64</a>.</p>
<p>If you're used to doing this on .NET, then you're in for a nasty surprise.</p>
| <p>If you're not actively debugging, you can "crash" the app to produce a minidump (this can be done non-invasively and lets the app continue running). IIRC DrWatson will let you do this, if not userdump from MS support will.</p>
<p>You can then load the dump into windbg and see the callstack + variables etc there. Yo... | 15,383 |
<p>Is it possible for UDP data to come to you corrupted? I know it is possible for it to be lost.</p>
| <p>UDP packets use a 16 bit checksum. It is not impossible for UDP packets to have corruption, but it's pretty unlikely. In any case it is not more susceptible to corruption than TCP.</p>
| <p>Short answer: YES.</p>
<p>Detailed answer:</p>
<p>About 7 years ago(maybe 2011?) We found that UDP datagrams are unintentionally changed when a UDP datagram is exchanged between a computer in China and another one in Korea. Of course, Checksum in UDP packet header is also reculculated regarding to the payload chan... | 7,023 |
<p>Is <code>yield return</code> a shortcut for implementing <code>IEnumerable</code> and <code>IEnumerator</code>?</p>
| <p>Yes, it is.</p>
<p>You can find out a lot more about it in chapter 6 of my book, C# in Depth. Fortunately chapter 6 is <a href="http://www.manning-source.com/books/skeet/Chapter6sample.pdf" rel="noreferrer">available for free</a> from <a href="http://manning.com/skeet/" rel="noreferrer">Manning's web site</a>.</p>
... | <p>Yes. See the following for a starter </p>
<p><a href="http://msdn.microsoft.com/en-us/library/dscyy5s0.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/dscyy5s0.aspx</a></p>
| 36,769 |
<p>I found some code in a project which looks like that : </p>
<pre><code>int main(int argc, char *argv[])
{
// some stuff
try {
theApp.Run();
} catch (std::exception& exc) {
cerr << exc.what() << std::endl;
exit(EXIT_FAILURE);
}
return (EXIT_SUCCESS);
}
</code></pre>
<p>I don't understan... | <p>If an exception is uncaught, then the standard does not define whether the stack is unwound. So on some platforms destructors will be called, and on others the program will terminate immediately. Catching at the top level ensures that destructors are always called.</p>
<p>So, if you aren't running under the debugge... | <p>Have a look at the C++ bible i.e. Stroustrup, he has an example which is also repeated in Applied C++ programming. The reasoning is:</p>
<pre><code>int main(void)
{
try
{
// your code
}
catch ( /* YourPossibleExceptions i.e. barfs you expect may occur */ )
{
}
catch ( .... | 48,066 |
<p>On several occasions I've wanted lettering/numbering printed as part of a design, but with the ability to make it stand out more effectively in the printed object without having to do detailed manual finishing. Is there a good material which can catch in and fill sunken (depth 0.4 mm, width 0.6-1.0 mm) lin... | <p>The great pics really help with the answerability of this question. From how catastrophic the failure is, and how it's clearly independent of any specialty needs for the particular print such as tiny bed-adhesion contacts, sharp overhangs, bridges, etc. this is definitely not a problem with temperature. Different pe... | <p>I found the solution to be the exact opposite. My bed was too low (as in too far from the hotend). All the above mentioned aside, I did also drop the flow rate on the brim and initial layer by roughly 2-3 %. Now it prints perfectly again. (your mileage may vary)</p>
| 1,448 |
<p>I'm trying to learn about catamorphisms and I've read <a href="http://en.wikipedia.org/wiki/Catamorphism" rel="noreferrer">the Wikipedia article</a> and the first couple posts in <a href="http://lorgonblog.spaces.live.com/Blog/cns!701679AD17B6D310!256.entry" rel="noreferrer">the series of the topic for F#</a> on the... | <p>LINQ's <code>Aggregate()</code> is just for <code>IEnumerables</code>. Catamorphisms in general refer to the pattern of folding for an arbitrary data type. So <code>Aggregate()</code> is to <code>IEnumerables</code> what <code>FoldTree</code> (below) is to <code>Trees</code> (below); both are catamorphisms for the... | <blockquote>
<p>I understand that it's a
generalization of folds (i.e., mapping
a structure of many values to one
value, including a list of values to
another list).</p>
</blockquote>
<p>I wouldn't say one value.It maps it into another structure.</p>
<p>Maybe an example would clarify.let's say summation ove... | 23,849 |
<p>I'm new to .NET and I would like to participate with .NET community to grow my skills (selfish, I know), contribute something (not so selfish) and I thought its just nice to be part of a community.</p>
<p>I can start a blog but considering I'm a beginner I can't possibly post anything worthwhile. How about opensour... | <p>Just because you're a beginner doesn't mean you can't post anything worthwhile to a blog. You could your blog as a notebook of "I didn't understand X, now I do - here's an explanation." That will help other beginners to learn, <em>and</em> potentially help old hands to understand which areas cause problems for begin... | <p>Do you make use of any open source projects at work? This can help give you direction, you can try to add features you've found yourself wanting or rewrite documentation that you found to be confusing. You could also simply do as Jon suggested, and start participating in the newsgroups or forums for these projects.<... | 41,833 |
<p>I heard Microsoft allows use of commercially available Office UI controls, with the exception of competing products, such as a word processor or spreadsheet app, etc.</p>
<p>How true is that?</p>
<p>Also, if it is not true, do you know of any <em>free</em> Ribbon controls?</p>
| <p>You should look at <a href="http://blogs.msdn.com/jensenh/archive/2006/11/21/licensing-the-2007-microsoft-office-user-interface.aspx" rel="nofollow noreferrer">Jensen Harris' blog entry about licensing the Office user interface</a> which explains it in great detail. However I believe the relevant point here is:</p>
... | <p>You can still build a word processor with a ribbon. You just can't use <em>Microsoft's</em> ribbon. There have been ribbon-like interfaces around for a lot longer than Office 2007 (the one that sticks in my mind most is the pallet in C++ Builder: very similar to a ribbon), so they definitely don't <em>own</em> the... | 21,797 |
<p>The name of a temporary table such as #t1 can be determined using </p>
<pre><code>select @TableName = [Name]
from tempdb.sys.tables
where [Object_ID] = object_id('tempDB.dbo.#t1')
</code></pre>
<p>How can I find the name of a table valued variable, i.e. one declared by</p>
<pre><code>declare @t2 as table (a int)... | <p>Table variable metadata is viewable in <code>tempdb.sys.tables</code> too. This is easily verifiable from the below</p>
<pre><code>declare @t2 as table ( [38F055D8-25D9-4AA6-9571-F436FE] int)
SELECT t.name, t.object_id
FROM tempdb.sys.tables t
JOIN tempdb.sys.columns c
ON t.object_id = c.object_id
WHERE c.name = ... | <p>I don't believe you can, as table variables are created in memory not in tempdb.</p>
| 12,136 |
<p>Although elements like <code><div></code>s normally grow to fit their contents, using the <code>float</code> property can cause a startling problem for CSS newbies: <strong>If floated elements have non-floated parent elements, the parent will collapse.</strong></p>
<p>For example:</p>
<p><div class="snippet" d... | <h2>Solution 1:</h2>
<p>The most reliable and unobtrusive method appears to be this:</p>
<p>Demo: <a href="http://jsfiddle.net/SO_AMK/wXaEH/" rel="noreferrer">http://jsfiddle.net/SO_AMK/wXaEH/</a></p>
<p><strong>HTML</strong>: </p>
<pre><code><div class="clearfix">
<div style="float: left;">Div 1<... | <p>I believe that best way is to set <code>clear:both</code> to the upcoming element.</p>
<p>Here's why:</p>
<p>1) <code>:after</code> selector is not supported in IE6/7 and buggy in FF3, however,
<br> if you care only about IE8+ and FF3.5+ clearing with :after is probably best for you... | 26,918 |
<p>I'm looking for the class name of the popup/message windows on the iPhone (it's a blueish window that comes up when you have a missed call, or a message comes in for example.)</p>
| <p>The class is called <code>UIAlertView</code>. From the documentation:</p>
<blockquote>
<p>Use the UIAlertView class to display an alert message to the user. An alert view functions similar to but differs in appearance from an action sheet (an instance of UIActionSheet).</p>
<p>Use the properties and methods defined ... | <p>The examples you gave (missed call or incoming text message) are system level alerts that pop up over any application. That functionality is not available through the SDK. lajos's answer does provide the correct way to display an alert, but it is worth remembering you can only do this within your application. You... | 21,167 |
<p>For this xml (in a SQL 2005 XML column): </p>
<pre><code><doc>
<a>1</a>
<b ba="1" bb="2" bc="3" />
<c bd="3"/>
<doc>
</code></pre>
<p>I'd like to be able to retrieve the names of the attributes (ba, bb, bc, bd) rather than the values <em>inside SQL Server 2005</em>. Well, X... | <pre><code>DECLARE @xml as xml
DECLARE @path as varchar(max)
DECLARE @index int, @count int
SET @xml =
'<doc>
<a>1</a>
<b ba="1" bb="2" bc="3" />
<c bd="3"/>
</doc>'
SELECT @index = 1
SET @count = @xml.query('count(/doc/b/@*)').value('.','int')
WHILE @index <= @count
BE... | <pre><code>Declare @xml Xml = '<doc><a>1</a><b ba="1" bb="2" bc="3" /><c bd="3"/></doc>'
Select n.value('local-name(.)', 'varchar(max)') from @xml.nodes('/doc/*/@*') a(n)
</code></pre>
<p>Returns
ba
bb
bc
bd</p>
| 29,884 |
<p>I want to create tag in subversion. On the command line I have tried the following:</p>
<p><strong>svn copy <a href="http://myserver.mycompany.com:8080/svn/SVN_Main/trunk" rel="nofollow noreferrer">http://myserver.mycompany.com:8080/svn/SVN_Main/trunk</a> <a href="http://myserver.mycompany.com:8080/svn/SVN_Main/tag... | <p>What happens if you just do the copy from within the repository browser (right click on the folder, then copy)</p>
<p>Could it also be a case-sensitivity issue? We run our svn server under Apache on Windows and find that reads are general case-insensitive, but write operations are case sensitive.</p>
<p>This is ... | <p>Either that isn't the right path, or you've put a <code>-r</code> option in there that you didn't show. Try a <code>svn ls</code> on that path to confirm it is correct. If you passed <code>-r</code>, make sure you've used the right revision.</p>
| 44,777 |
<p>I am using some nested layouts in Ruby on Rails, and in one of the layouts i have a need to read in a string from a div and set that as the title of the document. What is correct way (if any) to set the title of the document?</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
/... | <p>The following should work but it wouldn't be SEO compatible. It's best to put the title in the title tag.</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
document.title = 'blah';
});
</script>
</code></pre>
| <p>If you have got a serverside script get_title.php that echoes the current title session this works fine in jQuery:</p>
<pre><code>$.get('get_title.php',function(*respons*){
title=*respons* + 'whatever you want'
$(document).attr('title',title)
})
</code></pre>
| 21,729 |
<p>I bought an Ender 3, and after assembling it following the description and some YouTube videos and after correct leveling, I printed the test dog gcode on the micro SD card that comes with the printer. PLA 1.75 mm. Attached the image of the printing result. What went wrong? I didn't change or modify any setting... | <p>This is an extreme case of repeated layer shifting in the Y-carriage, which can come from some pieces related to the carriage. Luckily for you, they are easily fixable.</p>
<ul>
<li>The Ender3 Y-carriage has an eccentric nut to adjust the force the wheels press down on the V-slot. Adjust it (most likely loosen them... | <p>Ender 3's have a reputation to be not quite square on the base. Make sure that your X, Y, and X axis' are all perfectly squared.</p>
| 1,238 |
<p>Does using delegates slow down my programs? </p>
<p>I've been avoiding them because I really have no clue if they make my programs any slower. I know if I cause a (catch) exception, that uses quite a bit of CPU power but I don't know about Delegates and Events and what .NET does to them. </p>
| <p>Delegates are very, very fast. Not quite as fast as direct method calls, but not far off. The chances of them becoming a bottleneck are miniscule.</p>
<p>(Likewise exceptions, when used properly, <a href="https://stackoverflow.com/questions/161942/how-slow-are-net-exceptions">rarely actually cause a performance iss... | <p>Just a small addition to Jon's post: when used in the normal C# way (i.e. via lambdas / anonymous methods / event handlers / etc), then they are definitely very quick - but note that another important use of delegates can be to execute dynamic code (either methods built at runtime, or existing methods via reflection... | 39,174 |
<p>G'day,</p>
<p>I am working with a group of offshore developers who have been using the term unit testing quite loosely.</p>
<p>Their QA document talks about writing unit tests and then performing unit testing of the system.</p>
<p>This doesn't line up with my interpretation of what unit testing is at all.</p>
<p... | <p>Unit tests are generally used by developers to test isolated sections of code. They cover border cases, error cases, and normal cases. They are intended to demonstrate the correctness of a limited segment of code. If all of your unit tests pass, then you have demonstrated that your isolated segments of code do what ... | <p>What does it matter what we think? The issue here is your unhappiness with the terms they use in the document. Why don't you discuss it with them?</p>
| 32,487 |
<p>I enabled PHP5 on my website and my webhost needs me to add the following to .htaccess files for PHP5 to work:</p>
<blockquote>
<p>AddHandler application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml<br>
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml </p>
</blockquote>
<p>Locally, I am... | <p>Apache has <a href="http://httpd.apache.org/docs/2.0/mod/core.html#ifdefine" rel="nofollow noreferrer"><code><IfDefine></code></a> directive. You can use it to hide <code>AddType</code> from your own server:</p>
<pre><code><IfDefine !MyServer>
AddType application/x-httpd-php5 .php5 …
…
</IfDefine>... | <p>So, you're in kind of a tough place; ideally speaking your webhost should not need you to put extra gunk in your htaccess files. Not knowing XAMPP too well, I can't offer a specific solution, but I can give you some pointers:</p>
<ol>
<li><p>Your webhost is running a custom compiled version of PHP that uses applica... | 23,538 |
<p>I am looking for a hash-algorithm, to create as close to a unique hash of a string (max len = 255) as possible, that produces a long integer (DWORD).</p>
<p>I realize that 26^255 >> 2^32, but also know that the number of words in the English language is far less than 2^32.</p>
<p>The strings I need to 'hash' would... | <p>See <a href="https://stackoverflow.com/questions/114085/what-is-a-performant-string-hashing-function-that-results-in-a-32-bit-integer-w#114102">here</a> for a previous iteration of this question (and the answer).</p>
| <p>H(key) = [GetHash(key) + 1 + (((GetHash(key) >> 5) + 1) % (hashsize – 1))] % hashsize</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms379571.aspx" rel="nofollow noreferrer">MSDN article on HashCodes</a></p>
| 15,374 |
<p>Is it possible in Actionscript 3 to create a weak reference to an object, so that it can be garbage collected.</p>
<p>I'm creating some classes to make debugging easier, so I don't want the objects to hang around in memory if they are only referenced here (and of course I don't want to fill the code with callbacks ... | <p>Grant Skinner has written an excellent series of articles on <a href="http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html" rel="noreferrer">resource management in ActionScript 3</a>, and in the third part of that series he introduces <a href="http://www.gskinner.com/blog/archives/2006/08/as3_resource_... | <p>Right now I've made a simple class to take advantage of the Dictionary weakKeys parameter:</p>
<pre><code>public class WeakReference
{
private var dic
public function WeakReference(object)
{
this.dic = new Dictionary(true)
this.dic[object] = true
}
public function get Value()
... | 32,274 |
<p>I have the following table and data in SQL Server 2005:</p>
<pre><code>create table LogEntries (
ID int identity,
LogEntry varchar(100)
)
insert into LogEntries values ('beans')
insert into LogEntries values ('beans')
insert into LogEntries values ('beans')
insert into LogEntries values ('cabbage')
insert into... | <p>This is a set-based solution for the problem. The performance will probably suck, but it works :)</p>
<pre><code>CREATE TABLE #LogEntries (
ID INT IDENTITY,
LogEntry VARCHAR(100)
)
INSERT INTO #LogEntries VALUES ('beans')
INSERT INTO #LogEntries VALUES ('beans')
INSERT INTO #LogEntries VALUES ('beans')
INSERT ... | <p>Now I have looked at the eactual question closely enough :-)</p>
<p>Hmm, on reconsidering, why not just use a cursor? The performance isn't always worse than straight SQL - and it'd certianly be easy for other people to follow the code when they come to look at it. Wrap it in a stored proc or function and you'd be ... | 48,917 |
<p>Do you know any easy or simple way to make a map object (from the STL library) persistent (i.e. write it to a file) so that you can recover its state later when the program in run later ??</p>
<p>Thanks for your help</p>
| <p>I believe the <a href="http://www.boost.org/doc/libs/1_36_0/libs/serialization/doc/index.html" rel="noreferrer">Boost Serialization</a> library is capable of serializing std::map, but the standard library itself provides no means. Serialization is a great library with a lot of features and is easy to use and to exte... | <p>The answer is serialization. Specifics depend on your needs and your environment. For starters, check out Boost Serialization library: <a href="http://www.boost.org/doc/libs/1_36_0/libs/serialization/doc/index.html" rel="nofollow noreferrer">http://www.boost.org/doc/libs/1_36_0/libs/serialization/doc/index.html</a><... | 16,648 |
<p>I have an asp:checkbox control, and I want to change the visibility of a Label when it is checked or unchecked. To do this I'm attempting to use the OnCheckChanged event, which apparently only fires after a post to the server. This means that my Label's visibility isn't changing immediately. How do I post to the ser... | <p>I've used Sax CommStudio in the past, but now I just use System.IO.Ports.SerialPort.</p>
<p>By any chance are you using a USB serial port? I've had problems with those going BSOD and whatnot. If that's the case, you have a driver problem, not a software problem.</p>
<p>If you want to do some troubleshooting outsid... | <p>You mention you are running on Windows XP and .NET 2.0, .NET may well be your problem since there are bugs affecting serial ports in most versions of .NET. The minimum version that I'd recommend for using serial ports is .NET 3.5 SP1.</p>
<p>See also:
<a href="http://blog.zachsaw.com/2010/07/net-serialport-woes.htm... | 43,484 |
<p>What is the best way for me to determine a controller variable's value during execution?</p>
<p>For example, is there a way I can insert a break in the code, and cause the value of the variable to be output to the screen (or the log)?</p>
| <p>Yes. The easiest way is to raise the value as a string. Like so: <code>raise @foo.to_s</code></p>
<p>Or, you can install the debugger (<code>gem install ruby-debug</code>), and then start the development server with the <code>--debugger</code> flag. Then, in your code, call the <code>debugger</code> instruction.</p... | <p>Raising an exception is the fastest way if you just need to look at a value, but it's worth the time to learn how to use the debugger properly. It's rare that you would only need to just see the value of a variable, you are likely trying to find a bug in your code, and that's what a debugger is for.</p>
<p>Sending ... | 8,570 |
<p>I'm working on a large, aging code base for an MFC app. The code has been worked on by many developers over time, and as a result, we have three different ways throughout the code of dealing with the possibility of an allocation failure with new.</p>
<p>The first way is to test for NULL on the result of new. We d... | <p>It will depend on the compile options for the static libraries to be linked to the application.</p>
<p>If the libraries are compiled with a configuration to use the <strong>static</strong> Standard C++ run-time then I would expect the <code>operator new</code> from the Standard C++ run-time to be called.</p>
<p>If... | <p>You can change the MFC throwing behavior with <code>AfxSetNewHandler(_PNH pfnNewHandler)</code> and provide a pointer to your own <code>NewHandler</code> function. This function should then throw a <code>std::bad_alloc</code> exception.
But now the MFC-program-parts have the problem to catch a <code>std::bad_alloc</... | 26,301 |
<p>We are building a framework that will be used by other developers and for now we have been using a lot of TDD practices. We have interfaces everywhere and have well-written unit tests that mock the interfaces.</p>
<p>However, we are now reaching the point where some of the properties/methods of the input classes n... | <p>You need to be able to replicate those internal methods in your mock up objects. And call them in the same way the real object would call them. Then you focus your unit test on the public method that relies on that private method you need to test. If these internal methods are calling other objects or doing a lot of... | <p>Sounds like you want your class to have a <a href="http://www.javaranch.com/journal/200709/dependency-injection-unit-testing.htm" rel="nofollow noreferrer">dependency injection</a>. Search stackoverflow too. Then you can set this Id by your choice of either within constructor or through a setter.</p>
<p>[1l</p>
| 30,547 |
<p>What I'm talking about here are nested classes. Essentially, I have two classes that I'm modeling. A DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn't necessarily mean nesting, right?</p>
<p>I have code that looks something like this:</p>
<p... | <p>You might want to do this when the "inner" class is a one-off, which will never be used outside the <em>definition</em> of the outer class. For example to use a metaclass, it's sometimes handy to do</p>
<pre><code>class Foo(object):
class __metaclass__(type):
....
</code></pre>
<p>instead of defining ... | <p>Either way, defined inside or outside of a class, would work. Here is an employee pay schedule program where the helper class EmpInit is embedded inside the class Employee:</p>
<pre><code>class Employee:
def level(self, j):
return j * 5E3
def __init__(self, name, deg, yrs):
self.name = na... | 10,418 |
<p>I have been using TortoiseSVN, svn, and subclipse and I think I understand the basics, but there's one thing that's been bugging me for a while: Merging introduces unwanted code. Here's the steps.</p>
<p><code>trunk/test.txt@r2</code>. A test file was created with 'A' and a return:</p>
<pre><code>A
[EOF]
</code></... | <p>Merging only revisions 4,7, and 11-15 with <a href="http://www.orcaware.com/svn/wiki/Svnmerge.py" rel="noreferrer">svnmerge</a>:</p>
<pre><code>svnmerge.py merge -r4,7,11-15
</code></pre>
<p>And with regular svn:</p>
<pre><code>svn merge -c4,7 -r10:15 http://.../branches/TRY-XX-Foo
</code></pre>
| <p>If you don't want the unwanted change, do not merge revision 4:5, but just revision 5. It means you merge the change committed in revision 5.</p>
| 42,357 |
<p>I was wondering whether the object to test should be a field and thus set up during a <code>SetUp</code> method (ie. JUnit, nUnit, MS Test, …).</p>
<p>Consider the following examples (this is C♯ with MsTest, but the idea should be similar for any other language and testing framework):</p>
<pre><code>public class S... | <p>It's a slippery slope once you start initializing fields & generally setting up the context of your test <em>within</em> the test method itself. This leads to large test methods and really really unmanageable fixtures that don't explain themselves very well.</p>
<p>Instead, you should look at the BDD style nam... | <p>Personally, I use Setup and Teardown methods for two distinct reasons, although I assume that others will have different reasons.</p>
<ol>
<li>Use Setup and Teardown methods when there is common initiation logic that is used by all tests and a single instance of the object(s) created in the Setup are designed to be... | 38,810 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/176775/big-integers-in-c-sharp">Big integers in C#</a> </p>
</blockquote>
<p>I want to be able to process arbitrarily large numbers in C#.<br>
I can live with just integers. </p>
<p>Are there established algo... | <p>You might want to check the <a href="http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic" rel="nofollow noreferrer">Big Num</a> kind of libraries. In C# the most popular ones are: <a href="http://www.codeplex.com/IntX/" rel="nofollow noreferrer">IntX</a> and <a href="http://www.codeplex.com/sine" rel="nofoll... | <p>If you just need very large numbers, you could use <code>long</code> (64-bit), or even <code>decimal</code> (128-bit floating point). </p>
<p>If you need values larger than 9223372036854775807 (<code>long</code>) or 79228162514264337593543950335 (<code>decimal</code>), then you need to ignore this answer.</p>
| 32,778 |
<p>I'm developing a 3-column website using a layout like this:</p>
<pre><code> <div id='left' style='left: 0; width: 150px; '> ... </div>
<div id='middle' style='left: 150px; right: 200px' > ... </div>
<div id='right' style='right: 0; width: 200px; '> ... </div... | <p>If you haven't already checked out <a href="http://www.alistapart.com/" rel="noreferrer">A List Apart</a> you should, as it contains some excellent tutorials and guidelines for website design.</p>
<p><a href="http://alistapart.com/articles/holygrail" rel="noreferrer">This article</a> in particular should help you o... | <p>Firstly, relative positioning does what you've described: it reserves space in the original location but displays the DIV offset by some amount.</p>
<p>If you float the DIVs then they will stack left-to-right, but this can cause problems.</p>
<p>A three-column layout using CSS is quite hard. Have a look at [<a hre... | 10,896 |
<p>Okay, I develop web applications in PHP and JavaScript and a lot of times here on Stack Overflow I have seen the word <em>unit test</em> passing by, but nowhere on the website have I been able to found a satisfactory answer to what exactly a unit test is. </p>
<p>So what are unit tests and should I, as a PHP and Ja... | <p>Unit tests are for any code you wish to maintain.</p>
<p>In a nutshell, the idea is to write many small tests, each of which can be run in isolation, and test the smallest possible part of your codebase (often individual classes or individual functions). If I give this function the input it expects, does it return ... | <p>A <a href="http://www.google.com/search?q=php+unit+testing" rel="nofollow noreferrer">google search for "php unit testing"</a> yields a treasure trove of information on this subject. The <a href="http://www.phpunit.de/" rel="nofollow noreferrer">PHPUnit</a> project looks interesting.</p>
| 45,099 |
<p>What are the best conventions of naming testing-assemblies in .NET (or any other language or platform)?</p>
<p>What I'm mainly split between are these options (please provide others!):</p>
<ul>
<li><strong>Company.Website</strong> - <em>the project</em></li>
<li><strong>Company.Website.Tests</strong></li>
</ul>
<... | <p>I will go with </p>
<pre><code>* Company.Website - the project
* Company.Website.Tests
</code></pre>
<p>The short reason and answer is simple, testing and project are linked in code, therefore it should share namespace.</p>
<p>If you want splitting of code and testing in a solution you have that option anyway. e.... | <p>I usually name test projects <em>Project-Tests</em> for brevity in Solution Explorer, and I use <em>Company.Namespace.Tests</em> for namespaces.</p>
| 11,021 |
<p>Hi*,<br><br>I am using the .NET Compact framework Remote Performance Monitor from the .net 3.5 compact framework powertoys.<br><br>It is able to run an applications and get statistics from it, but after a while it fails to vieuw the GC heap on the platform with this exception:<br><br><a href="http://files.stormenet.... | <p>If it's any consolation, I checked with the CF team and they've finally gotten back to me on this. They've got it as an open bug and are looking at it. I take that to mean that it's not you and that there are some circumstances that can cause this (I've never seen it on any device so far).</p>
| <p>Have you tried running the 2.00 one against it?</p>
<p>I also wouldn't be so swift to point the finger at MS. The issue might be to do with customisations to the OS performed by the OEM.</p>
| 46,448 |
<p>How do I view the SQL that is generated by nHibernate? version 1.2</p>
| <p>You can put something like this in your app.config/web.config file :</p>
<p>in the configSections node :</p>
<pre><code><section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</code></pre>
<p>in the configuration node :</p>
<pre><code><log4net>
<appender name=... | <p>Or, if you want to show the SQL of a specific query, use the following method (slightly altered version of what suggested <a href="https://weblogs.asp.net/ricardoperes/getting-the-sql-from-a-linq-query-in-nhibernate" rel="nofollow noreferrer">here</a> by <a href="https://about.me/rjperes" rel="nofollow noreferrer">R... | 15,701 |
<p>So I know there have been several clicking Extruder threads but have not found any solutions to the one I am having.</p>
<p>Background:
I have a custom Prusa like 3d printer fitted with an MKS board (v1.5) and an MK3 Extruder.</p>
<p>The issue:
<strong>While i can extrude fine when ordering some extrusion, as soon... | <p>It took some digging, but I was able to start scripting a wrapper in C# for the RPC commands.</p>
<ul>
<li><a href="https://github.com/TrueAnalyticsSolutions/MakerBotAgentAdapterCore#api" rel="nofollow noreferrer">C# Wrapper</a> (MTConnect Implementation)</li>
<li>Unofficial <a href="https://github.com/TrueAnalytic... | <h2>The Mystery of Makerbot-Wiki</h2>
<p>According to the Wayback machine, the wiki.makerbot.com went offline on <a href="https://web.archive.org/web/20121126084944/http://wiki.makerbot.com:80/" rel="nofollow noreferrer">31st December 2012</a>:</p>
<blockquote>
<p>Over the past three amazing years, MakerBot owners ... | 1,233 |
<p>How can I list all the types that are declared by a module in Ruby?</p>
| <p>Use the <em>constants</em> method defined in the <em>Module</em> module. From the Ruby documentation:</p>
<blockquote>
<p>Module.constants => array</p>
<p>Returns an array of the names of all
constants defined in the system. This
list includes the names of all modules
and classes.</p>
<p>p Module.... | <p>Not sure if this is what you mean, but you can grab an array of the names of all constants and classes defined in a module by doing</p>
<blockquote>
<blockquote>
<blockquote>
<p>ModuleName.constants</p>
</blockquote>
</blockquote>
</blockquote>
| 16,598 |
<p>Given a list of sets:</p>
<ul>
<li>S_1 : [ 1, 2, 3, 4 ]</li>
<li>S_2 : [ 3, 4, 5, 6, 7 ]</li>
<li>S_3 : [ 8, 9, 10, 11 ]</li>
<li>S_4 : [ 1, 8, 12, 13 ]</li>
<li>S_5 : [ 6, 7, 14, 15, 16, 17 ]</li>
</ul>
<p>What the most efficient way to merge all sets that share at least 2 elements? I suppose this is similar to ... | <pre><code>Let there be a list of many Sets named (S)
Perform a pass through all elements of S, to determine the range (LOW .. HIGH).
Create an array of pointer to Set, of dimensions (LOW, HIGH), named (M).
do
Init all elements of M to NULL.
Iterate though S, processing them one Set at a time, named (Si)... | <p>One side note: It depends on how often this occurs. If most pairs of sets <em>do</em> share at least two elements, it might be most efficient to build the new set at the same time as you are stepping through the comparison, and throw it away if they don't match the condition. If most pairs <em>do not</em> share a... | 40,329 |
<p>I have the requirement to support different Master pages on my application (ASP.NET MVC).
What is the recommended way to:</p>
<ol>
<li>Pass the master page name to the view from.</li>
<li>Store the master page (in session, or something) so it sticks during a user's visit.</li>
</ol>
| <p>Use a custom base controller and inherit from it instead:</p>
<pre><code>Public Class CustomBaseController
Inherits System.Web.Mvc.Controller
Protected Overrides Function View(ByVal viewName As String, ByVal masterName As String, ByVal model As Object) As System.Web.Mvc.ViewResult
Return MyBase.Vie... | <p>Why not keep the Master Page on the user profile?
Then just change it on the PreLoad event.</p>
<p><a href="http://www.odetocode.com/articles/440.aspx" rel="nofollow noreferrer">http://www.odetocode.com/articles/440.aspx</a></p>
| 34,269 |
<p>I write financial applications where I constantly battle the decision to use a double vs using a decimal.</p>
<p>All of my math works on numbers with no more than 5 decimal places and are not larger than ~100,000. I have a feeling that all of these can be represented as doubles anyways without rounding error, but h... | <ol>
<li>Floating point arithmetic will almost always be significantly faster because it is supported directly by the hardware. So far almost no widely used hardware supports decimal arithmetic (although this is changing, see comments).</li>
<li>Financial applications should <strong>always</strong> use decimal numbers... | <p>I refer you to my answer given to <a href="https://stackoverflow.com/questions/366852#366919">this question</a>.</p>
<p>Use a long, store the smallest amount you need to track, and display the values accordingly.</p>
| 42,705 |
<p>I'm trying to watch the execution of a VB6 app and I'm running into an issue because once I enter the debugger and then hit <code>Continue</code>, it no longer lets me step through the code until I hit another break point. I want to be able to execute a program without stepping through something until I hit a poin... | <p>While the code is running, press ctrl+break (or the 'VCR pause' button in the IDE) then press F8 (or choose 'Step Into'from the Debug menu in the IDE) to continue running the app. The next action will cause execution to break. </p>
<p>Note that the which causes the break will not always be the one you hoped it wou... | <p>You can press the F8 key to step through the code line by line. Alternatively, you can press SHIFT-F8 to step through line by line.</p>
<p>F8 will step you in to a function, where SHIFT-F8 will step you over the function. If you click on the DEBUG menu in the VB IDE, you will see other options too.</p>
<p>EDIT:<... | 36,672 |
<p>In one of our application im getting an exception that i can not seem to find or trap. </p>
<pre><code>...
Application.CreateForm(TFrmMain, FrmMain);
outputdebugstring(pansichar('Application Run')); //this is printed
Application.Run;
outputdebugstring(pansichar('Application Run After')); //this is print... | <p>Try installing <a href="http://www.madshi.net/" rel="noreferrer">MadExcept</a> - it should catch the exception and give you a stack-trace.</p>
<p>It helped me when I had a similar issue.</p>
| <p>Here's two things you can try:</p>
<p>1) Quick and easy is to to hit 'F7' on the final 'end.'. This will step you into the other finalization blocks.</p>
<p>2) Try overriding the Application.OnException Event.</p>
| 15,934 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/83073/why-not-use-tables-for-layout-in-html">Why not use tables for layout in HTML?</a> </p>
</blockquote>
<p>Under what conditions should you choose tables instead of DIVs in HTML coding?</p>
| <p>The whole "Tables vs Divs" thing just barely misses the mark. It's not "table" or "div". It's about using semantic html.</p>
<p>Even the div tag plays only a small part in a well laid out page. Don't overuse it. You shouldn't need that many if you put your html together correctly. Things like lists, field sets... | <blockquote>
<p>One other use I would have for it
would be forms, particularly label :
textbox pairs. This could technically
be done in div boxes, but it's much,
much easier to do this in tables, and
one can argue that label:textbox pairs
are in fact tabular in nature.</p>
</blockquote>
<p>I see that a ... | 5,013 |
<p>I have a <code>crontab</code> that looks like</p>
<pre><code>0 0 * * * pg_dump DB_NAME > /path/to/dumps/`date +%Y%m%d`.dmp
</code></pre>
<p>which works fine when I run it manually, but not when <code>cron</code> runs it. After digging through the logs, I see</p>
<pre><code>Dec 12 00:00:01 localhost crond[17638... | <p>You have to escape percent signs with a backslash:</p>
<pre><code>0 0 * * * pg_dump DB_NAME > /path/to/dumps/`date +\%Y\%m\%d`.dmp
</code></pre>
<p>From <code>man 5 crontab</code>:</p>
<blockquote>
<p>The ‘‘sixth’’ field (the rest of the line) specifies the command to
be
run. The entire command ... | <p>There's another characteristic problem that can affect programs run by <code>cron</code> as compared with the command line (other than the interpretation of '<code>%</code>' signs described by Robert Gamble).</p>
<p>That difference is in the environment. If the program run relies on special environment variables, ... | 47,393 |
<p>By default C# compares DateTime objects to the 100ns tick. However, my database returns DateTime values to the nearest millisecond. What's the best way to compare two DateTime objects in C# using a specified tolerance?</p>
<p>Edit: I'm dealing with a truncation issue, not a rounding issue. As Joe points out below, ... | <p>I usally use the TimeSpan.FromXXX methods to do something like this:</p>
<pre><code>if((myDate - myOtherDate) > TimeSpan.FromSeconds(10))
{
//Do something here
}
</code></pre>
| <p>I’ve created extension methods IsSimilar</p>
<pre><code>public static bool IsSimilar(this DateTime? lhs, DateTime? rhs, TimeSpan tolerance)
{
if (!lhs.HasValue && !lhs.HasValue) return true;//both are null
if (!lhs.HasValue || !lhs.HasValue) return false;//one of 2 is null
return IsSimilar(lhs.... | 49,995 |
<p>The following code does not compile:</p>
<pre><code>public class GenericsTest {
public static void main(String[] args) {
MyList<?> list = new MyList<Object>();
Class<?> clazz = list.get(0);
// Does not compile with reason
// "Type mismatch: cannot convert ... | <p>I think you are not understanding quite how generics work.</p>
<pre><code>MyList<?> list = new MyList<Object>();
Class<String> clazz= list.get(0);
</code></pre>
<p>This code snippet does not compile because you are telling the compiler that <code>list</code> is going to hold <code>Class<Object... | <p>Have you tried:</p>
<pre><code>Class clazz2 = list2.get(0).getClass();
</code></pre>
<p>Read about it at:
<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#getClass()" rel="nofollow noreferrer">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#getClass()</a></p>
| 36,559 |
<p>I have created my own Tree implementation for <a href="https://stackoverflow.com/questions/144642/tree-directed-acyclic-graph-implementation">various reasons</a> and have come up with two classes, a 'base' class that is a generic tree node that is chock full of logic and another class that extends that one which is ... | <p>So, after getting my copy of <a href="https://rads.stackoverflow.com/amzn/click/com/0201633612" rel="nofollow noreferrer" rel="nofollow noreferrer">Design Patterns</a> and opening it for what I'm fairly sure is the first time ever I discovered what I want.</p>
<p>It's called the <a href="http://en.wikipedia.org/wik... | <p>I don't think there's a better approach. Just be careful not to call these hooks from the constructor.</p>
| 17,835 |
<p>I use codes below to see a result like picture 1, but a result like picture 2 is coming. What should be done to solve it?</p>
<p>aspx code:</p>
<pre><code><asp:datalist id="dtlUrun" runat="server" RepeatDirection="Horizontal">
<ItemTemplate>
<table class="dtlTable">
... | <p>From what I can tell in the code the first datalist is bound with the two header items, then inside that you have the individual elements. Your template creates a table for each section, but by default tables are going to be block level elements. My guess is that you could fix that with CSS, but I'd have to check.... | <p> tag within headertemplate is can't see his closing tag within footertemplate. Are you sure your code is true?</p>
<p>You said:</p>
<blockquote>
<p>My guess is that you could fix that with CSS</p>
</blockquote>
<p>Please let's fix it with Css :)</p>
| 42,450 |
<p>After my web form is submitted, a regex will be applied to user input on the server side (via PHP). I'd like to have the identical regex running in real-time on the client side to show the user what the real input will be. This will be pretty much the same as the Preview section on the Ask Question pages on Stack Ov... | <p>Hehe this was sort of asked moments ago and Jeff pointed out:<br>
<a href="http://www.regular-expressions.info/refflavors.html" rel="noreferrer">http://www.regular-expressions.info/refflavors.html</a>.</p>
<p>There is a comparison of regular expression capabilities across tools and languages.</p>
| <p>Both JavaScript's regex and PHP's preg_match are based on Perl, so there shouldn't be any porting problems. Do note, however, that Javascript only supports a subset of modifiers that Perl supports.</p>
<p>For more info for comparing the two:</p>
<ul>
<li><a href="http://www.regular-expressions.info/javascript.html" ... | 4,999 |
<p>As part of a larger web-app (using CakePHP), I'm putting together a simple blog system. The relationships are exceedingly simple: each User has a Blog, which has many Entries, which have many Comments.</p>
<p>An element I'd like to incorporate is a list of "Popular Entries." Popular Entries have been defined as tho... | <p>Heh, I was just about to come back with essentially the same answer (using Cake's Model::find):</p>
<pre><code>$this->loadModel('Comment');
$this->Comment->find( 'all', array(
'fields' => array('COUNT(Comment.id) AS popularCount'),
'conditions' => array(
'Comment.created >' => ... | <p>You probably want a <strong>WHERE</strong> clause to get just last 30 days comments:</p>
<pre><code>SELECT entry-id, count(id) AS c
FROM comment
WHERE comment_date + 30 >= sysdate
GROUP BY entry-id
ORDER BY c DESC
</code></pre>
| 7,612 |
<p>I have a table which consists of 200 Companies Stock prices for 5 years. This is one large table which consists of Company Name, Stock Open, High, Low, Close, Date</p>
<p>I am now required to do some processing on the same and also let users [up to 10] access this database to fetch reports on different sets of para... | <p>Pull out the name and use an integer ID. It should be faster and will tolerate name changes. The stock symbol can also be extracted to the parent table.</p>
| <p>i'd have a table for the company, and a table for the stock prices on a given day (the open/high/low/close bits), to save duplicating the company info everywhere.</p>
| 40,954 |
<p>I would like to create a cache for my php pages on my site. I did find too many solutions but what I want is a script which can generate an HTML page from my database ex:</p>
<p>I have a page for categories which grabs all the categories from the DB, so the script should be able to generate an HTML page of the sort... | <p>check ob_start() function</p>
<pre><code>ob_start();
echo 'some_output';
$content = ob_get_contents();
ob_end_clean();
echo 'Content generated :'.$content;
</code></pre>
| <p>If you're not opposed to frameworks, try using the Zend Frameworks's <a href="http://framework.zend.com/manual/en/zend.cache.html#zend.cache.introduction" rel="nofollow noreferrer">Zend_Cache</a>. It's pretty flexible, and (unlike some of the framework modules) easy to implement.</p>
| 46,384 |
<p>I have a master page, with a help link in the top menu. This link should contain the a dynamic bookmark from the current page, so that the user scrolls to the help for the page he is currently seeing.</p>
<pre><code><a href="help.aspx#[NameOfCurentPage]">Help</a>
</code></pre>
<p>How would you implemen... | <p>Another thing you could do is reference the master page through the content page itself.</p>
<p>To make it easier on myself, I create a publicly accessible method in the master page itself:</p>
<pre><code>Public Sub SetNavigationPage(ByVal LinkName As String)
DirectCast(Me.FindControl(MenuName), HyperLink).Navi... | <p>i haven't written a line of c# in over three months but you could hook up an event in the masterpage (OnLoad) and set the link from there. See what's in the ContentPlaceholder that's your main page and get it's type or name, then apply it to the link.</p>
| 28,132 |
<p>I would like to know how to infer coercions (a.k.a. implicit conversions) during type inference. I am using the type inference scheme described in <a href="http://people.cs.uu.nl/bastiaan/phdthesis/index.html" rel="noreferrer">Top Quality Type Error Messages</a> by Bastiaan Heeren, but I'd assume that the general id... | <p>I hope you get some good answers to this.</p>
<p>I haven't yet read the paper you link to but it sounds interesting. Have you looked at all how ad-hoc polymorphism (basically overloading) works in Haskell? Haskell's type system is H-M plus some other goodies. One of those goodies is type classes. Type classes p... | <p>Could you give a little more clarification as to what exactly it is you're asking?</p>
<p>I have a slight idea, and if my idea is right then this answer should suffice as my answer. I believe you're talking about this from the perspective of someone who's creating a language, in which case you can look at a languag... | 9,507 |
<p>Looking at tooltip support in Flex, I've seen you can apply colors and styles to modify the appearance.
Is it possible to do cooler stuff like make tool tips appear with a simple animation like how menus work on modern Windows apps?</p>
| <p>Take a look at the ToolTipManager class (<a href="http://livedocs.adobe.com/flex/3/langref/mx/managers/ToolTipManager.html" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/3/langref/mx/managers/ToolTipManager.html</a>). It has a "showEffect" property which is what you are looking for I suppose.</p>
| <p>Take a look here: <a href="http://blog.flexmonkeypatches.com/the-monkey-index/tooltips/" rel="nofollow noreferrer">http://blog.flexmonkeypatches.com/the-monkey-index/tooltips/</a><br />
You'll find A TON of useful tutorials/docs about Flex tooltips !</p>
| 27,558 |
<p>In my c# app, I've got a list that I navigate with an Enumerator. It works great for moving forward through the list, but the Enumerator class doesn't have a MoveBack method. </p>
<p>Is there different class that has a MoveBack method, or do I need to write my own?</p>
| <p>Any enumerators using the IEnumerator interface by definition must start before the first element and iterate forwards through the collection. In short: they don't support backwards traversal. </p>
<p>If you want backwards traversal you'll need to write your own enumeration functions that allow you start anywhere... | <p>You could reverse the list and interate over that. Or, with some classes, you could do a for loop from end to beginning and use ElementAt().</p>
| 23,291 |
<p>I'm having an issue with a query that currently uses </p>
<pre><code>LEFT JOIN weblog_data AS pwd
ON (pwd.field_id_41 != ''
AND pwd.field_id_41 LIKE CONCAT('%', ewd.field_id_32, '%'))
</code></pre>
<p>However I'm discovering that I need it to only use that if there is no exact match first. What's happening i... | <p>It sounds like you want to join the tables aliased as pwd and ewd in your snippet based first on an exact match, and if that fails, then on the like comparison you have now.</p>
<p>Try this:</p>
<pre><code>LEFT JOIN weblog_data AS pwd1 ON (pwd.field_id_41 != '' AND pwd.field_id_41 = ewd.field_id_32)
LEFT JOIN webl... | <p>I can only think of doing it in code. Look for an exact match, if the result is empty, look for a LIKE.
One other option is a WHERE within this query such that WHERE ({count from exact match}=0), in which case, it wont go through the comparison with LIKE if the exact match returns more than 0 results. But its terri... | 10,149 |
<p>In ruby the library path is provided in <code>$:</code>, in perl it's in <code>@INC</code> - how do you get the list of paths that Python searches for modules when you do an import?</p>
| <p>I think you're looking for <a href="https://docs.python.org/3/library/sys.html#sys.path" rel="noreferrer">sys.path</a></p>
<pre><code>import sys
print (sys.path)
</code></pre>
| <pre><code>python -c "import sys; print('\n'.join(sys.path))"
/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python39.zip
/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9
/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framewo... | 16,356 |
<p>I have a Monoprice Select v2 that I just bought less than 2 months ago. I've manually leveled it on several prints prior.</p>
<p>I noticed a couple of holes in my print bed after my last print, like the extruder pushed into the sheet really hard. They're both on the same side.</p>
<p>I then noticed that the extrud... | <p>You decide which layer height you want based on the quality you desire, but never go over about 75 % of your nozzle diameter, so with your 0.4 mm nozzle never choose layer heights larger than 0.3 mm. The rationale of this rule of thumb is that the filament leaves the nozzle as a tube and needs to be f... | <p>You decide which layer height you want based on the quality you desire, but never go over about 75 % of your nozzle diameter, so with your 0.4 mm nozzle never choose layer heights larger than 0.3 mm. The rationale of this rule of thumb is that the filament leaves the nozzle as a tube and needs to be f... | 1,166 |
<p>Unit testing and ASP.NET web applications are an ambiguous point in my group. More often than not, good testing practices fall through the cracks and web applications end up going live for several years with no tests. </p>
<p>The cause of this pain point generally revolves around the hassle of writing UI automation... | <p>Unit testing will be achievable if you <strong>separate your layers</strong> appropriately. As Rob Cooper implied, <em>don't put any logic in your WebForm other than logic to manage your presentation</em>. All other stuff logic and persistence layers should be kept in separate classes and then you can test those ind... | <p>There have been tries on getting Microsoft's free UI Automation (included in .NET Framework 3.0) to work with web applications (ASP.NET). A german company called Artiso happens to have written a blog entry that explains how to achieve that (<a href="http://www.artiso.com/ProBlog/PermaLink,guid,1a01608b-e5fa-4ad9-8c4... | 3,913 |
<p>Being relatively new to the .net game, I was wondering, has anyone had any experience of the pros / cons between the use of LINQ and what could be considered more traditional methods working with lists / collections? </p>
<p>For a specific example of a project I'm working on : a list of unique id / name pairs are ... | <p>i dont think the linq you wrote would compile, it'd have to be</p>
<pre><code>public string branchName (string branchId)
{
//branchList populated in the constructor
branch_summary bs = (from b in branchList where b.id == branchId select b).FirstOrDefault();
return branch_summary == null ? null : branch... | <p>I'm not sure a singleton class is absolutely necessary, do you absolutely need global access at all times? Is the list large? </p>
<p>I assume you will have a refresh method on the singleton class for when the properties need to change and also that you have some way of notifying the singleton to update when the li... | 7,085 |
<p>We have CC.NET setup on our ASP.NET app. When we build the project, the ASP.NET app is pre-compiled and copied to a network share, from which a server runs the application.</p>
<p>The server is a bit different from development box'es, and the next server in our staging environment differs even more. The difference ... | <p>I use a <a href="http://nant.sourceforge.net/" rel="nofollow noreferrer">NAnt</a> <a href="http://www.cruisecontrolnet.org/projects/ccnet/wiki/NAnt_Task" rel="nofollow noreferrer">task</a> for all publishing, deploying, cleaning and so on.</p>
| <p>Of course CruiseControl.NET can run a batch file, simply use the exec task. However, an easier answer might just be to have MSBuild do the task for you. It should be simple to add a few steps in the postcompile target.</p>
| 13,886 |
<p>What is the best way to tokenize/split a NSString in Objective-C?</p>
| <p>Found answer <a href="http://borkware.com/quickies/one?topic=NSString" rel="nofollow noreferrer">here</a>:</p>
<pre><code>NSString *string = @"oop:ack:bork:greeble:ponies";
NSArray *chunks = [string componentsSeparatedByString: @":"];
</code></pre>
| <p>I had a case where I had to split the console output after an LDAP query with ldapsearch. First set up and execute the NSTask (I found a good code sample here: <a href="https://stackoverflow.com/questions/412562/execute-a-terminal-command-from-a-cocoa-app">Execute a terminal command from a Cocoa app</a>). But then I... | 32,486 |
<p>Is there any HTML5 support in IE8? Is it on the IE8 roadmap?</p>
| <p>IE8 beta 2 supports two APIs from HTML5: <a href="http://www.whatwg.org/specs/web-apps/current-work/#crossDocumentMessages" rel="noreferrer">cross-document messaging</a> and <a href="http://www.whatwg.org/specs/web-apps/current-work/#storage" rel="noreferrer">non-SQL storage</a>.</p>
<p>IE8 beta 2 doesn’t implement... | <p>According to <a href="http://msdn.microsoft.com/en-us/library/cc288472(VS.85).aspx#html" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc288472(VS.85).aspx#html</a>, IE8 will have "strong" HTML 5 support. I haven't seen anything discussing exactly what "strong support" entails, but I can say that... | 36,826 |
<p>When you have code like the following: </p>
<pre><code>static T GenericConstruct<T>() where T : new()
{
return new T();
}
</code></pre>
<p>The C# compiler insists on emitting a call to Activator.CreateInstance, which is considerably slower than a native constructor. </p>
<p>I have the following workarou... | <p>I <em>suspect</em> it's a JITting problem. Currently, the JIT reuses the same generated code for all reference type arguments - so a <code>List<string></code>'s vtable points to the same machine code as that of <code>List<Stream></code>. That wouldn't work if each <code>new T()</code> call had to be reso... | <p>Interesting observation :)</p>
<p>Here is a simpler variation on your solution:</p>
<pre><code>static T Create<T>() where T : new()
{
Expression<Func<T>> e = () => new T();
return e.Compile()();
}
</code></pre>
<p>Obviously naive (and possible slow) :)</p>
| 47,977 |
<p>A few times already, I got into situations where one of my SVN repository got corrupt and we could do anything with some versions or branches of the project without really knowing what we did. So I'm asking what can cause a repository to become corrupt?</p>
<hr>
<p>It seems that incompatibilities between clients m... | <p>There are basically three distinct cases:</p>
<ol>
<li>Faulty hardware (memory, fs corruption, etc.)</li>
<li>User's with login access to the server can corrupt repository files.</li>
<li>Bugs in Subversion.</li>
</ol>
<p>Faulty hardware is usually the most difficult to spot, except in the most obvious cases. Case... | <p>I've had it happen a few times. SVN doesn't seem to cope well if the client goes away while the server is taking a long time to do certain things. I don't know the exact details, but I have done a few <code>kill -9</code>s on what I thought were read-only processes and ended up having to run a <code>svnadmin cleanup... | 43,594 |
<p>I have three Java <code>JCheckboxes</code> in a column, arranged by setting the layout of the container <code>JPanel</code> to <code>GridLayout(3, 1, 1, 1)</code>. When I run the program, there is too much vertical space between the JCheckBoxes; it looks like more than 1 pixel. Since I've already set the vertical ... | <p>I explored using <code>GridLayout</code>, <code>BorderLayout</code>, and <code>GridBagLayout</code> and I believe that any extra vertical space that is present in your application is due to the sizing of the JCheckBox component, not related to the layout manager. All of the examples below have no space between compo... | <p>Thank you Steve and Alex. Both your responses were correct. By setting the border to an empty border, I was able to move the checkboxes closer. </p>
| 26,929 |
<p>My company has recently became a Microsoft Certified Partner and from a business perspective it helps us greatly as it provides the software licenses needed to continue development in a much more cost effective manner, and the added benefit of marketing abilities.</p>
<p>Now, I know that Microsoft Certified Partner... | <p>Yes. As a partner, you not only get access to the software, but the company gets vouchers for certification testing, making it more likely that your employer would not only support, but encourage you to get certified. I work for a MS Gold Partner and every single developer here is MCPD certified.</p>
| <p>I am starting to work at a software company that is a Microsoft certified gold partner very soon, in terms of how that looks on your CV does it help that you have worked for a company that is certified ?</p>
| 21,131 |
<p>I've seen these words a lot around Subversion (and I guess general repository) discussions.<br>
I have been using <strong>SVN</strong> for my projects for the last few years, but I've never grasped the complete concept of these directories.</p>
<p>What do they mean?</p>
| <p>Hmm, not sure I agree with Nick re tag being similar to a branch. A tag is just a marker</p>
<ul>
<li><p><a href="http://svnbook.red-bean.com/en/1.8/svn.tour.importing.html#svn.tour.importing.layout" rel="noreferrer"><strong>Trunk</strong></a> would be the main body of development, originating from the start of the... | <p><strong>Trunk</strong> : After the completion of every sprint in agile we come out with a partially shippable product. These releases are kept in trunk.</p>
<p><strong>Branches</strong> : All parallel developments codes for each ongoing sprint are kept in branches.</p>
<p><strong>Tags</strong> : Every time we rele... | 3,687 |
<p>Disclaimer: Near zero with marshalling concepts..</p>
<p>I have a struct B that contains a string + an array of structs C. I need to send this across the giant interop chasm to a COM - C++ consumer.<br>
<strong>What are the right set of attributes I need to decorate my struct definition ?</strong> </p>
<pre><code... | <p><a href="http://msdn.microsoft.com/en-us/library/ms379617%28VS.80%29.aspx#vs05cplus_topic12" rel="nofollow noreferrer">C++: The Most Powerful Language for .NET Framework Programming</a></p>
<p>I was about to approach a project that needed to marshal structured data across the C++/C# boundary, but I found what could... | <p>The answer depends on what the native definitions are that you are trying to marshal too. You haven't provided enough information for anyone to be able to really help.</p>
<p>A common thing that trips people up when marshalling strings in native arrays is that native arrays often use a fixed-size buffer for the st... | 5,176 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.