instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm looking for a way to implement a referral system for my web site.</p>
<p>Initially I went with <a href="http://mysite.com/?affid=0001" rel="nofollow noreferrer">http://mysite.com/?affid=0001</a> and used the affid in the query string affid value to record referrals. The problem with this is that from some commo... | <p>What you should do is detect when there is an affiliate id in the URL, then redirect to the same URL without the affiliate ID (after storing the ID in the session, cookie, etc first of course).</p>
<p>This will fix both the my-affiliates-are-replacing-me-in-google problem and the duplicate content problem.</p>
| <p>yup the both ideas above mentioning redirecting affiliate links 301 {permanent} is the handiest and best way for search engines to attribute the content and links to the correct url only
it only adds a split second to the user experience</p>
<p>thus complete code to add to start of all affilate landing pages is mor... | 33,237 |
<p>C++ was the first programming language I really got into, but the majority of my work on it was academic or for game programming. Most of the programming jobs where I live require Java or .NET programmers and I have a fairly good idea of what technologies they require aside from the basic language. For example, a Ja... | <p>As for every language, I believe there are three interconnected levels of knowledge :</p>
<ol>
<li>Master your language. Every programmer should (do what it takes to) master the syntax. Good references to achieve this are :
<ul>
<li><a href="http://www.research.att.com/~bs/3rd.html" rel="noreferrer">The C++ Progra... | <p>In no specific order</p>
<ul>
<li>COM/ATL</li>
<li>DirectX</li>
<li>MFC & Win32</li>
<li>STL</li>
<li>GDI</li>
<li>BOOST</li>
</ul>
| 18,387 |
<p>In Oracle 8 doing an online backup with BLOBs in the database is extremely slow. By slow, I mean over an hour to backup a database with 100MB of BLOB data. Oracle acknowledged it was slow, but wouldn't fix the problem (so much for paying for support.) Does anyone know if Oracle has fixed this problem with subsequent... | <p>I've had this issue in the past, and the only decent workarounds we found were to make sure that the LOBs were in their own tablespace, and use a different backup strategy with them, or to switch to using the BFILE type. Whether or not you can get by with BFILE will depend on how you're using the LOBs.</p>
<p>Some... | <p>I use SQL Backup from Redgate for SQL Server -- it is ridiculously fast, even with my BLOB data. </p>
<p>I keep a copy of every file that I do EDI with, so while they aren't huge, they are numerous and BLOBs. I'm well over 100Megs of just these text files.</p>
<p>It's important to note that Redgate's SQL Backup ... | 14,210 |
<p>any idea how if the following is possible in PHP as a single line ?:</p>
<pre><code><?php
$firstElement = functionThatReturnsAnArray()[0];
</code></pre>
<p>... It doesn't seem to 'take'. I need to do this as a 2-stepper:</p>
<pre><code><?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allE... | <p>Try:</p>
<pre><code><?php
$firstElement = reset(functionThatReturnsAnArray());
</code></pre>
<p>If you're just looking for the first element of the array.</p>
| <p>As far as I know this is not possible, I have wanted to do this myself several times.</p>
| 9,427 |
<p>I've just had to write a string reverse function in C# 2.0 (i.e. LINQ not available) and came up with this:</p>
<pre><code>public string Reverse(string text)
{
char[] cArray = text.ToCharArray();
string reverse = String.Empty;
for (int i = cArray.Length - 1; i > -1; i--)
{
reverse += cArr... | <pre><code>public static string Reverse( string s )
{
char[] charArray = s.ToCharArray();
Array.Reverse(charArray);
return new string(charArray);
}
</code></pre>
| <pre><code>public string rev(string str)
{
if (str.Length <= 0)
return string.Empty;
else
return str[str.Length-1]+ rev(str.Substring(0,str.Length-1));
}
</code></pre>
| 28,224 |
<p>I'm trying to write a query that will pull back the two most recent rows from the Bill table where the Estimated flag is true. The catch is that these need to be consecutive bills. </p>
<p>To put it shortly, I need to enter a row in another table if a Bill has been estimated for the last two bill cycles.</p>
<p>I'... | <p>Assuming the rows have sequential IDs, something like this may be what you're looking for:</p>
<pre><code>select top 1 *
from
Bills b1
inner join Bills b2 on b1.id = b2.id - 1
where
b1.IsEstimate = 1 and b2.IsEstimate = 1
order by
b1.BillDate desc
</code></pre>
| <p>You should be able to do a descensing sorted query on estimated = true and select top 2. I am not the best at SQL so i cant give exact language structure</p>
| 15,425 |
<p>In most programming languages, dictionaries are preferred over hashtables.
What are the reasons behind that?</p>
| <p>For what it's worth, a Dictionary <strong>is</strong> (conceptually) a hash table.</p>
<p>If you meant "why do we use the <code>Dictionary<TKey, TValue></code> class instead of the <code>Hashtable</code> class?", then it's an easy answer: <code>Dictionary<TKey, TValue></code> is a generic type, <code>Ha... | <p>According to what I see by using <a href="http://en.wikipedia.org/wiki/.NET_Reflector" rel="nofollow noreferrer">.NET Reflector</a>:</p>
<pre><code>[Serializable, ComVisible(true)]
public abstract class DictionaryBase : IDictionary, ICollection, IEnumerable
{
// Fields
private Hashtable hashtable;
// M... | 38,658 |
<p>How can I rotate a layer using Core Animation around an arbitrary point? ( In my case a point that is not inside the layer I want to rotate )</p>
<p>I prefer doing this without changing the anchor point, because unless I get something wrong every time I change the anchor point it also changes the position of the la... | <p>You can do this by appending multiple transformations:</p>
<ol>
<li>translate the layer by (-rotCenterX, rotCenterY)</li>
<li>rotate the layer</li>
<li>translate the layer by (rotCenterX, rotCenterY)</li>
</ol>
| <p>I finaly did it by creating a new bigger layer with it's center at my rotation axis and setting the layer i want to rotate as it's sub layer.</p>
<p>Then I rotate the bigger layer instead of the sub layer</p>
| 24,333 |
<p>How do you run an update query in a data source control from a button? I have the data source control with the update query configured in it. I just don't know what to put in the button_click event to make it run.</p>
| <p>In the event handler just call the Update method for your Datasource control.</p>
| <p>I get an error when I call the Update method of the Datasource</p>
<p>sdsUpdateName.Update;</p>
<p>Only assignment, call, increment, decrement, and new object expressions can be used as a statement </p>
| 35,713 |
<p>Currently I have subversion set up so that when I make changes in Eclipse PDT, I can commit the changes and they will be saved in /home/administrator/<em>Project File</em>. This file has the /branches /tags and /trunk directories recommended by subversion. I have no problem properly uploading files to the reposito... | <p>You can do an <code>svn export</code> into your www directory. That will give you a "clean" version of your repo, without the .svn directories.</p>
<pre><code>cd /var/www
svn export /home/administrator/MyProject/trunk MyProject
</code></pre>
<hr>
<p>Edit: adding in some good ideas from the comments...</p>
<p>Som... | <p>You'll probably want to remember what files you have on production at any given time - so keep a "release" tag (e.g. in /project/tags/release). When you want to make a release, copy your trunk into there. Then svn export that release tag.</p>
<p>Or something.</p>
| 33,030 |
<p>In Windows Mobile, when you open Internet Explorer and type in a URL that your device can't connect to, you are notified of this and prompted to (manually) navigate to the screen where you can actually do something about this as a user (Network Management), like so:</p>
<p><a href="http://www.freeimagehosting.net/u... | <p>In answer to your question 2, this code will show the connections control panel:</p>
<pre><code>Process.Start(@"\windows\ctlpnl.exe", "cplmain.cpl,19");
</code></pre>
<p>A lot of the built in settings applets are shown through ctlpnl.exe. I got the magic number from the list <a href="http://knowledgepointer.wordpr... | <p>You need to use the <a href="http://msdn.microsoft.com/en-us/library/ms879581.aspx" rel="nofollow noreferrer">Connection Manager</a> API to establish a connection. In fact, there is a flag you can set to stop the error notification!</p>
<p><a href="http://blogs.msdn.com/windowsmobile/archive/2005/09/14/466579.aspx... | 38,541 |
<p>Is there an easier way to achieve the following?</p>
<pre><code>var obj = from row in table.AsEnumerable()
select row["DOUBLEVALUE"];
double[] a = Array.ConvertAll<object, double>(obj.ToArray(), o => (double)o);
</code></pre>
<p>I'm extracting a column from a <code>DataTable</code> and storing ... | <p>I don't know about Artifactory but here are my reasons for using Nexus:</p>
<ul>
<li>Dead simple install (and since 1.2, dead simple upgrade, too)</li>
<li>Very good web UI</li>
<li>Easy to maintain, almost no administrative overhead</li>
<li>Provides you with RSS feeds of recently installed, broken artifacts and e... | <p>Both Artifactory and Nexus have more or less similar feature set but Artifactory's LDAP support makes it more attractive over Nexus. Though Nexus also have LDAP support but in paid version :-(</p>
| 47,617 |
<p>Surely there is a way to store a date value prior than 1-1-1900 in a column other than varchar? Or do I really have to break this out, and perform my own datetime library for date differences, sorting, and such?</p>
<p>Yes, I understand how datetime's are actually stored (an integer value from a specific date), but... | <p>smalldatetime vs. datetime!</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms187819.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms187819.aspx</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms182418.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms182418.aspx... | <p>SQL Server 2008 has the DATE data type which can range from 0001-01-01 through 9999-12-31.</p>
<p>With previous versions, your SOL if you need a date prior to 1753-01-01 (Minimum value for DATETIME).</p>
| 22,813 |
<p>I have a simple function that sends out emails, how would I go about using threads to speed email delivery?</p>
<p>Sample code would be ideal.</p>
| <p>Use SendAsync isntead.</p>
| <p>You know what would be nicer and easier is to create an application back end and send emails every 30 minutes. Throw the information into a database that you need to send to and from there, create an application pool that launches every 30 minutes. When it launches, you can send an email. No need to wait for your... | 16,135 |
<p>Is there a way in Delphi 7 to find out if a pop-up menu is visible (shown on the screen) or not, since it lacks a Visible property.</p>
| <p>You could make your own flag by setting it in the OnPopup event. The problem is knowing when the popupmenu is closed. <a href="http://groups.google.com/group/borland.public.delphi.winapi/browse_thread/thread/d4be3b47ebbf30e0/bcb981c67486cb5c?lnk=st" rel="nofollow noreferrer">Peter Below</a> has a solution for that.<... | <p>This seems to be a bit simpler (I used Delphi 2007):</p>
<p>In your WM_CONTEXTMENU message handler, before calling the inherited handler, the popup menu is about to be shown, you can set your flag. After calling inherited, the popup menu has been closed, reset your flag.</p>
<pre><code>procedure TForm1.WMContextMe... | 16,709 |
<p>I need to query existing rules, as well as being able to easily add and delete rules. I haven't found any API's for doing this. Is there something that I'm missing?</p>
<p>The closest I've come to a solution is using <code>iptables-save | iptables-xml</code> for querying and manually calling the iptables command it... | <p>From the <a href="http://www.netfilter.org/documentation/FAQ/netfilter-faq-4.html#ss4.5" rel="noreferrer">netfilter FAQ</a>:</p>
<blockquote>
<p>The answer unfortunately is: No.</p>
<p>Now you might think 'but what about libiptc?'. As has been pointed out numerous times on the mailinglist(s), libiptc was <em>NEVER</... | <p>MarkR's right, you're not supposed to do this. The easiest way is to call iptables from the script or to write the iptables config and 'restore' it.</p>
<p>Still, if you want to, read the source of iptables. iptables uses matches and tables as shared objects. You can use the source or them.</p>
<p>The Linux netfil... | 13,480 |
<p>I'm looking for a tool (or a set of tools) for Windows that will perform the following:</p>
<ol>
<li>Capture UDP packets from a specific network interface to a file.</li>
<li>Play a stream of packets from a file through a network interface.</li>
<li>In addition to 2: replay the original packets to a different host ... | <p>The <strong>BitTwist</strong> (<a href="http://bittwist.sourceforge.net" rel="nofollow noreferrer">http://bittwist.sourceforge.net</a>) editor commandline program (<code>bittwiste</code>) allows you to change the destination IP address (and port number) amongst other things.</p>
<p>See a similar question (and worke... | <p>for visual inspection you can use wire shark tool but you need advanced tool then use wpdpack libraries. It is available in this site. </p>
<p><a href="https://www.winpcap.org/devel.htm" rel="nofollow noreferrer">https://www.winpcap.org/devel.htm</a></p>
<p>Similar like wire shark you can capture using TestPacketC... | 47,099 |
<p>I need help writing the following method:</p>
<pre><code>def get_new_location(current_location, target_location, distance_travelled):
...
...
return new_location
</code></pre>
<p>where all locations are (lat,long)</p>
<p>I realize that there are different models for the earth (WGS-84, GRS-80, ...) whi... | <p>As BenjiSmith said, there are potentially several paths that connect any A & B on the globe, but the two most popular (by far!) are the "great circle" and "rhumb line" paths. </p>
<p>A great circle gives the shortest distance (by constructing a plane from the two points & the center of the earth & foll... | <p>Your updated sample code would not always follow the correct path.</p>
<p>For a quick example, consider the following two points on the equator in the middle of the pacific ocean:</p>
<ul>
<li>current_location: lat = 0, lon = -179</li>
<li>target_location: lat = 0, lon = 179</li>
</ul>
<p>These two points are ver... | 35,865 |
<p>I have to copy quite a lot of files from one folder to another. Currently I am doing it in this way:</p>
<pre><code>string[] files = Directory.GetFiles(rootFolder, "*.xml");
foreach (string file in files)
{
string otherFile = Path.Combine(otherFolder, Path.GetFileName(file));
File.Copy(file, otherFile);
}
<... | <p>I can't think of a more efficient way than File.Copy, it goes directly to the OS. </p>
<p>On the other hand if it takes that long, I would strongly suggest to show a progress dialog - like <a href="http://msdn.microsoft.com/en-us/library/bb762164(VS.85).aspx" rel="noreferrer">SHFileOperation</a> does it for you. At... | <p>You could use the operating system to move the files. This is what tools like WinMerge do. You click the "copy" button in your app and it pops up the Windows progress box as if you had used Explorer to arrange the copy. <a href="http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.d... | 27,449 |
<p>My ASP.NET application needs a number of supporting services to run periodically in the background. For example:</p>
<ul>
<li>I need to query the database (or cache) every 1-5 minutes, identify overdue work items and notify users by email</li>
<li>I need to generate nightly reports that are then emailed to subscrib... | <p>This year I needed to implement a single task to cache some data from a database, It had to verify a changing code every n minutes, I found this very nice article;</p>
<p><a href="http://www.codeproject.com/KB/aspnet/ASPNETService.aspx" rel="nofollow noreferrer">Simulate a Windows Service using ASP.NET to run sched... | <p>Honestly I've never been a fan of trying to simulate a windows service inside an ASP.net process, especially when you consider how easy it is to create a Windows service. Most of the attempts that I've seen at doing so have been full of problems.</p>
| 36,708 |
<p>I would like to display some memory statistics (working set, GCs etc.) on a web page using the .NET/Process performance counters. Unfortunately, if there are multiple application pools on that server, they are differentiated using an index (#1, #2 etc.) but I don't know how to match a process ID (which I have) to th... | <p>The first hit on Google:</p>
<p><a href="http://openrent.blogspot.com/2008/01/multiple-clr-performance-counters.html" rel="noreferrer">Multiple CLR performance counters appear that have names that resemble "W3wp#1"</a></p>
<blockquote>
<p>When multiple ASP.NET worker processes
are running, Common Language Runt... | <p>I know it has been answered before, but just for the sake of complete working code I'm posting this solution. Please note this code based on the method submitted by M4N in this chain:</p>
<pre><code>public static long GetProcessPrivateWorkingSet64Size(int process_id)
{
long process_size = 0;
Process process = P... | 13,915 |
<p>I want to generate a thumbnail preview of videos in Java. I'm mostly JMF and video manipulation alienated. </p>
<ul>
<li>Is there an easy way to do it?</li>
<li>What about codecs? Will I have to deal with it?</li>
<li>Any video type is suported? (including Quicktime)</li>
</ul>
| <p>There seems to be a few examples out there that are far better than <a href="http://code.google.com/p/vitalopensource/source/browse/trunk/src/com/vtls/opensource/image/VideoImageSource.java" rel="noreferrer">what I was going to send you.</a></p>
<p>See <a href="http://krishnabhargav.blogspot.com/2008/02/processing-... | <p>There is a relatively newer option called JThumbnailer that you find here: <a href="https://github.com/makbn/JThumbnail" rel="nofollow noreferrer">https://github.com/makbn/JThumbnail</a></p>
<blockquote>
<p>JThumbnail is a Java library for creating Thumbnails of common types
of file including .doc, .docx, .pdf , .mp... | 7,055 |
<p>first question here. I'm developing a program in C# (.NET 3.5) that displays files in a listview. I'd like to have the "large icon" view display the icon that Windows Explorer uses for that filetype, otherwise I'll have to use some existing code like this:</p>
<pre><code> private int getFileTypeIconIndex(str... | <p>You might find the use of <a href="http://msdn.microsoft.com/en-us/library/system.drawing.icon.extractassociatedicon.aspx" rel="noreferrer">Icon.ExtractAssociatedIcon</a> a much simpler (an managed) approach than using SHGetFileInfo. But watch out: two files with the same extension may have different icons.</p>
| <p>Edit: <a href="https://stackoverflow.com/questions/462270/get-file-icon-used-by-shell">Here</a> is a version without PInvoke.</p>
<pre><code>[StructLayout(LayoutKind.Sequential)]
public struct SHFILEINFO
{
public IntPtr hIcon;
public IntPtr iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.B... | 13,338 |
<p>I'm trying to get the zoom controls to show up in a <code>mapview</code>, the following code almost works, but the zoom controls appear in the top left of the <code>mapview</code>, not the bottom center like I'm specifying via <code>setGravity()</code>. Can someone enlighten me as to what I'm missing?</p>
<pre><co... | <p>Add the following line to the <code>OnCreate()</code> method of your <code>MapView</code> Class:</p>
<p><code>view.setBuiltInZoomControls(true);</code></p>
| <p>Reto - the problem with using FILL_PARENT is that the zoom control then "steals" all of the touch events; so that you can't pan the map while the zoom controls are visible. Do you know how to prevent this?</p>
| 32,992 |
<p>I'm trying to 3D print a lattice work or truss, basically some beams forming a rectangle and additional beams forming the diagonals and where those beams cross, they should be fused. So, something like this:</p>
<p><a href="https://i.stack.imgur.com/gdKj1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.img... | <h2>Yes you can!</h2>
<p>To have stronger prints you would have to choose the correct direction of filament deposition paths/traces. This answer demonstrates changing the direction of the filament path in Ultimaker Cura slicer.</p>
<p>To do this, it requires some tinkering of your model and choosing the correct slicer ... | <p>Have a look at <a href="https://www.reddit.com/r/3Dprinting/comments/pt80ap/new_3d_printing_slicer_geared_towards_highspeed/" rel="nofollow noreferrer">Chisel</a> infills there are very strength optimised, limitation is currently that they must be single line width, but multiple-lines thick infill will be supported ... | 2,025 |
<p>How can I call a custom action dll written in managed code (.net) from an installer without using an unmanaged intermediary?</p>
| <p>The answer to your question depends on how your are authoring your installer.</p>
<p>For Visual Studio setup projects, create an installer class in one of your deployed assemblies. This is covered in the MSDN documentation, eg <a href="http://msdn.microsoft.com/en-us/library/d9k65z2d(VS.80).aspx" rel="nofollow nor... | <p>There is support for exactly this in .NET/Windows Installer</p>
<p>Create an assembly using VS.NET.
Add an installer class to the project - select 'Add - New Item'. Select intaller class.
This class derives from System.Configuration.Install.Installer. It has a number of virtual methods such as Install(). This will ... | 5,549 |
<p>I have a web project where I must import text and images from a user-supplied document, and one of the possible formats is Microsoft Office 2007. There's also a need to generate documents in this format.</p>
<p>The server runs CentOS 5.2 and has PHP/Perl/Python installed. I can execute local binaries and shell scri... | <p>The Office 2007 file formats are open and <a href="http://msdn.microsoft.com/en-us/library/aa338205.aspx" rel="noreferrer">well documented</a>. Roughly speaking, all of the new file formats ending in "x" are zip compressed XML documents. For example:</p>
<blockquote>
<p>To open a Word 2007 XML file Create a
tem... | <p>You can probably check the code for <a href="http://www.sphider.eu/" rel="nofollow noreferrer">Sphider</a>. They docs and pdfs, so I'm sure they can read them. Might also lead you in the right direction for other Office formats.</p>
| 20,870 |
<p>As stated in the title, i'm looking for an XML schema (XSD-file) for the Glade markup language?</p>
<p>Wikipedia states that <strong>Glade</strong> is a schema based markup language (<a href="http://en.wikipedia.org/wiki/List_of_XML_Schemas#Graphical_User_Interfaces" rel="nofollow noreferrer">list of schemas at wik... | <p>There's nothing that will explicitly tie down the glade to an particular schema since it's all run-time based.</p>
<p>You may find the .defs files generated by PyGTK useful. If you really need an XSD file, you should be able to create one from these files.</p>
<p><a href="http://svn.gnome.org/viewvc/pygtk/trunk/g... | <p>Thx, this is a first start. I assume there is no document that is more explicit that this DTD? This DTD only specyfies what (global) tags can be used. Especially for the tag <widget> i would like a have constraints on the attribute "class" (as supported by XSD). The XSD should cover that there are only certain... | 9,061 |
<p>I have a c# object with a property called Gender which is declared as a char.</p>
<pre><code>private char _Gender;
public char Gender
{
get{ return _Gender; }
set{ _Gender = value; }
}
</code></pre>
<p>What string is returned/created when I call MyObject.Gender.ToString()?</p>
<p>I ask because I am calli... | <p>The default value of char is unicode 0, so I'd expect "\u0000" to be returned.</p>
| <p>A char has a length of 1, so it never should return an empty string.</p>
<p>If you want to distinguish between 0 and uninitialised, you would need to use the nullable form char?.</p>
| 22,154 |
<p>I have a large codebase, and I'd like to refactor the package structure so that classes which interact heavily go in the same package.</p>
<p>It seems that it should be possible to create a tool that could look at the interactions between classes, and then group together those classes that interact heavily. These ... | <p>Structure101 is another product that can analyze the structure of your code and do dependency and what-if analysis.</p>
<p><a href="http://www.headwaysoftware.com/products/structure101/index.php" rel="noreferrer">http://www.headwaysoftware.com/products/structure101/index.php</a></p>
| <p>Try some Pasta (see <a href="http://freshmeat.net/projects/pastatool/" rel="nofollow noreferrer">http://freshmeat.net/projects/pastatool/</a>)</p>
| 17,415 |
<p>Say I have 3 frames in a frameset arranged in 3 rows. Frames 1 and 3 are from my site and frame 2 (the central one) is from an external website. Is there a cunning way to force the browser to centre align the data in frame 2?</p>
<p>I've found a small work-around which uses a frameset within a frameset which has 2 ... | <p>I think what you are looking for is a way to inject some CSS into the other frame, even though it comes from another site.</p>
<p>I think this will not be possible without a server side script to request the page and modify it.</p>
<p>Javascript has ways to modify other frames using window.frames[] and using DOM t... | <p>If you use an absolute value rather than a percentile to define the size of a frame in conjunction with other frames using percentiles the frame with an absolute value will not resize with the browser window and the other frames/divs will.</p>
<pre><code><frameset rows="10%,65,25%" border=0 frameborder=... | 21,617 |
<p>After I level my Ender 3, the distance between the nozzle and the bed seems fine on both ends, but moving the bed on the Y axis shows that it's increasing and decreasing for three times, which I just cant fix.</p>
<p>This only occurs on the left side - the right side is constant from beginning to end.
Also I've bee... | <p>Your video shows that your bed seems warped somewhat.</p>
<h2>Ammount of error</h2>
<p>As I assume you did level the bed with a sheet of paper to be 0.1 mm thick, we can estimate the change of thickness. The thickest point seems to be 0.2 mm, the thinnest 0.05. that's in average an error of 0.075 mm for the first la... | <p>Blue Painters tape on the left side starting at the center and leaving a band on the far left side and the rear Perfetto side. I checked the before and after and the thickness of the tape shimmed out the deflection on the plate. It sounds like whatever the use to stamp the steel out is creating the bend we are only ... | 1,202 |
<p>I have an ASP.net application that works fine in the development environment but in the production environment throws the following exception when clicking a link that performs a postback. Any ideas?</p>
<blockquote>
<p>Invalid postback or callback argument.
Event validation is enabled using
in configurat... | <p>Problem description:
This is one the common issues that a lot of ASP.NET beginners face, post, and ask about. Typically, they post the error message as below and seek for resolution without sharing much about what they were trying to do.</p>
<p>[ArgumentException: Invalid postback or callback argument. Event valid... | <p>It seems that the data/controls on the page are changed when the postback occurs. What happens if you turn off the event validation in the page directive. </p>
<pre><code><%@ Page ... EnableEventValidation = "false" />
</code></pre>
| 12,917 |
<p>I am busy writing my thesis (so, I guess this could count as a homework question). Now, one of the things that came up was the Unix <code>select</code> system call. I would like to add a reference to the appropriate man page, but all I can find that seems the slight bit official is the Single Unix Specification site... | <p>You need to ask your graduate college how you should reference this in your thesis. They will have strict rules about how to do it. If it makes it easier, see if your library has a copy of the The Linux Programmer's Reference -- assuming that it describes the select(2) call -- and reference it as a book</p>
| <p>Try Googling <code>man <command></code>. I find them frequently available here: <a href="http://linux.die.net/man/2/select" rel="nofollow noreferrer">http://linux.die.net/man/2/select</a>.</p>
| 26,473 |
<p>Is it possible to import csv data into mysql and automatically create the column names, as in can I create just the table, or must I create the table names as well?</p>
<p>Is it possible to check for duplicate entries upon importing? I have an identifier field, but dont know how to make it so it will not be importe... | <p>As tante said you'll have to handle the table creation yourself, but as far as importing csv is concerned you should have a look at <a href="http://dev.mysql.com/doc/refman/5.0/en/load-data.html" rel="nofollow noreferrer">LOAD DATA INFILE</a></p>
<pre><code>LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file... | <p>Sure, but you'll probably have to write a few lines of code yourself, it can be done with very little code. Checking for duplicates is quite easy then, you can do that before inserting in your little script.</p>
<p>You could store the file as a combination of two fields, one Varchar for the name and a blob for the ... | 30,622 |
<p>One of my columns is called <code>from</code>. I can't change the name because I didn't make it.
Am I allowed to do something like <code>SELECT from FROM TableName</code> or is there a special syntax to avoid the SQL Server being confused?</p>
| <p>Wrap the column name in brackets like so, <code>from</code> becomes [from].</p>
<pre><code>select [from] from table;
</code></pre>
<p>It is also possible to use the following (useful when querying multiple tables):</p>
<pre><code>select table.[from] from table;
</code></pre>
| <p>In Oracle SQL Developer, pl/sql you can do this with double quotes but if you use double quotes you must type the column names in upper case. For example, SELECT "FROM" FROM MY_TABLE</p>
| 36,299 |
<p>I have Expression Blend 2, Service Pack 1, and cannot create a Silverlight 2 project. When I attempt to create a Silverlight 2 project, I get the following error:</p>
<blockquote>
<p>Blend cannot continue because a compatible Silverlight version could not be found.</p>
</blockquote>
<p>I installed Blend a few we... | <p>What version of Blend do you have installed (version number, not service pack)?</p>
<p>According to <a href="http://silverlight.net/forums/t/36181.aspx" rel="nofollow noreferrer">this form posting</a> the issue gets resolved from:</p>
<blockquote>
<p>The old version of the file also named BlendV2SP1_en.exe has a... | <p>Bryant got it, but I want to explain a bit more fully in case anyone else ever gets caught in this trap. Yes, I installed the wrong SP1. (This shouldn't even be possible, but ... whatever.)</p>
<p>I went to the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EB9B5C48-BA2B-4C39-A1C3-135C60BBBE66&am... | 33,265 |
<p>Is there a way of mapping data collected on a stream or array to a data structure or vice-versa?
In C++ this would simply be a matter of casting a pointer to the stream as a data type I want to use (or vice-versa for the reverse)
eg: in C++</p>
<pre><code>Mystruct * pMyStrct = (Mystruct*)&SomeDataStream;
pMyStr... | <p>Most people use .NET serialization (there is faster binary and slower XML formatter, they both depend on reflection and are version tolerant to certain degree)</p>
<p>However, if you want the fastest (unsafe) way - why not:</p>
<p>Writing:</p>
<pre><code>YourStruct o = new YourStruct();
byte[] buffer = new byte[M... | <p>if its .net on both sides:</p>
<p>think you should use binary serialization and send the byte[] result.</p>
<p>trusting your struct to be fully blittable can be trouble.</p>
<p>you will pay in some overhead (both cpu and network) but will be safe.</p>
| 2,443 |
<p>I am creating an integration server for the first time, and although I have two projects in my cruisecontrol config file, only the first one seems to be executing. My config file is pasted below.</p>
<pre><code><cruisecontrol>
<project name="cc-config">
<triggers>
<int... | <ol>
<li><p>Have you checked your CCNet build logs for any anomalies? (<em>Edit Answer: Yes, and there weren't any.</em>)</p></li>
<li><p>Logging into the CCNet web server, does the second project show up as a valid project?
(<em>Edit Answer: No, it does not.</em>)</p></li>
<li><p>If so, can you do a force build on it?... | <p><a href="http://confluence.public.thoughtworks.org/display/CCNET/Interval+Trigger" rel="nofollow noreferrer">Interval triggers</a> have a default <strong>buildCondition</strong> of <strong>IfModificationExists</strong>, which means that a build will only be kicked off if a modication has been detected within your <a... | 31,795 |
<p>What would be the best version control system to learn as a beginner to source control?</p>
| <p>Anything but Visual Source Safe; preferably one which supports the concepts of branching and merging. As others have said, Subversion is a great choice, especially with the TortoiseSVN client.</p>
<p>Be sure to check out (pardon the pun) <a href="http://www.ericsink.com/scm/source_control.html" rel="noreferrer">Eri... | <p>Anything, but I would learn a modern system like git or subversion myself. My first VCS was RCS, but I got the basics down.</p>
| 4,330 |
<p>I tried playing a .wav file using pyaudio. It works great on windows, but doesn't work in Ubuntu when another device is using sound.</p>
<blockquote>
<p>The error is "IOError: [Errorno
Invalid output device (no default
output device)] -9996</p>
</blockquote>
<p>Is there another library I could try to use? An... | <p>You can use <a href="http://wxpython.org/" rel="noreferrer">wxPython</a></p>
<pre><code>sound = wx.Sound('sound.wav')
sound.Play(wx.SOUND_SYNC)
</code></pre>
<p>or</p>
<pre><code>sound.Play(wx.SOUND_ASYNC)
</code></pre>
<p><a href="http://svn.wxwidgets.org/viewvc/wx/wxPython/tags/wxPy-2.8.9.1/wxPython/demo/Sound... | <p>I'm not absolutely sure if that fulfills your requirements, but I immediately thought PyGame</p>
<p><a href="http://www.pygame.org/docs/ref/mixer.html#pygame.mixer.Sound" rel="nofollow noreferrer" title="PyGame Sound Module">http://www.pygame.org/docs/ref/mixer.html#pygame.mixer.Sound</a></p>
<pre><code>from pygam... | 34,835 |
<p>does anyone have any resources for learning assembly language on x86? I'm trying to debug a program in MSVC++6 and frequently come across assembly (like stepping into memcpy).. Previously I just ignored these but memcpy keeps throwing exceptions and I need to find out why..</p>
<p>Any help would be appreciated :)</... | <p>If you just need to understand what each instruction does, the reference manual for the IA-32 (x86) & IA64 instruction sets are located <a href="http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html" rel="nofollow noreferrer">here</a>.</p>
| <p><a href="https://rads.stackoverflow.com/amzn/click/com/0471375233" rel="nofollow noreferrer" rel="nofollow noreferrer">Dunteman's "Assembly Language Step by Step"</a> is a pretty good starting point for x86 assembly.</p>
<p>I'm sure there are good tutorial sites on the Net, but I'm not familiar with them.</p>
| 49,791 |
<p>Essentially my question is, does anyone know of a utility for inspecting the <strong>buffer cache</strong> in linux?</p>
| <p>Take a look at <a href="http://code.google.com/p/linux-ftools/" rel="nofollow">linux-ftools</a>. This suite of tools is specifically designed to analyze the buffers and cache. It includes the following tools:</p>
<ul>
<li>fincore</li>
<li>fadvise</li>
<li>fallocate</li>
</ul>
<p>Of these 3 tools the one that will ... | <p>I'm not entirely sure if you're asking what I think you're asking, but <a href="http://hoytech.com/vmtouch/" rel="nofollow">vmtouch</a> could be helpful to you. Just type <code>vmtouch [file or folder you want to check for presence in cache]</code></p>
| 25,884 |
<p>Say you have a string, but you don't know what it contains. And you want to replace all occurences of a particular word or part of a word with a formatted version of the same word.
For example, I have a string that contains "lorem ipsum" and i want to replace the entire word that contains "lo" with "lorem can" so th... | <pre><code>$str = preg_replace('/(\blo[a-z]+\b)/', '$1 can', $str);
</code></pre>
<p>The problem with RoBorg's answer are:</p>
<ol>
<li><code>\w</code> matches digits and underscores, which aren't <em>really</em> word characters in human language, so it would match 'lo_fi' or '__lo__'.</li>
<li>it would also match wo... | <p><code>$str = preg_replace('/lo(\w*)/', 'lo$1 can', $str);</code></p>
<p>This replaces "lo" plus any word characters with "lo" + the other characters + " can"</p>
<p>It will also replace "lo" with "lo can" - if you don't want this, change <code>\w*</code> to <code>\w+</code></p>
| 32,072 |
<p>I would like to remove two files from a folder at the conclusion of my script. Do I need to create a function responsible for removing these two specific files? I would like to know in some detail how to use os.remove (if that is what I should use) properly. These two files will always be discarded at the conclusion... | <p>It sounds like what you really want is a temp file:
<a href="http://docs.python.org/library/tempfile.html" rel="nofollow noreferrer">http://docs.python.org/library/tempfile.html</a></p>
| <p>Just call <code>os.remove("path/to/file")</code>. For example, to remove the file <code>.emacs</code>, call</p>
<pre><code>os.remove(".emacs")
</code></pre>
<p>The path should be a <code>str</code> that's the pathname of the file. It may be relative or absolute.</p>
| 37,906 |
<p>I have a .NET assembly which I am accessing from VBScript (classic ASP) via COM interop. One class has an indexer (a.k.a. default property) which I got working from VBScript by adding the following attribute to the indexer: <code>[DispId(0)]</code>. It works in most cases, but not when accessing the class as a membe... | <p>I stumbled upon this exact problem a few days ago. I couldn't find a reasonable explanation as to why it doesn't work.</p>
<p>After spending long hours trying different workarounds, I think I finally found something that seems to work, and is not so dirty. What I did is implement the accessor to the collection in t... | <p>WAG here... Have you examined your assembly with <a href="http://www.microsoft.com/downloads/details.aspx?familyid=5233b70d-d9b2-4cb5-aeb6-45664be858b6&displaylang=en" rel="nofollow noreferrer">oleview</a> to make sure your public interface has an indexer visible to com consumers? Second WAG is to use the get_I... | 41,050 |
<p>In C++ when can a virtual function use static binding? If it is being accessed through a pointer, accessed directly, or never?</p>
| <p>If you want to call the base class version of a function, you can do that by explicitly naming the base class:</p>
<pre><code>class Base
{
public:
virtual ~Base() {}
virtual void DoIt() { printf("In Base::DoIt()\n"); }
};
class Derived : public Base
{
public:
virtual void DoIt() { printf("In Derived::DoIt()\... | <p>Static binding can only be done when the object's type is totally unambiguous at compile time. I can only think of four places where an abstract object's type is unambiguous: in the constructor, in the destructor, when declared locally and within the same scope as a dynamic allocation. I don't know the standard that... | 33,507 |
<p>I'm using Flex 3 in the UI of a Windows app (Flash player as an embedded ActiveX control), and passing data between them with ExternalInterface (primarily into the Flex app, as opposed to out). I'm finding, though, that the performance is pretty awful, particularly with larger (i.e., custom) objects; the more EI cal... | <p>Multiple expectations are not a problem at all. What you're running into are ordering problems, given your specific args on unordered expectations. Check <a href="http://rspec.info/documentation/3.3/rspec-mocks/#Ordering" rel="noreferrer">this page</a> for details on ordering expectations.</p>
<p>The short story ... | <p><a href="http://rspec.rubyforge.org/rspec/1.1.9/classes/Spec/Mocks.html" rel="nofollow noreferrer">Mock Receive Counts</a></p>
<p>my_mock.should_receive(:sym).once<br>
my_mock.should_receive(:sym).twice<br>
my_mock.should_receive(:sym).exactly(n).times<br>
my_mock.should_receive(:sym).at_least(:once)<br>
my... | 30,247 |
<p>I know the standard answer is No. However hear out the reasons for wanting it, and then we'll go for whether it is possible to achieve the same effect as ReadyBoost via either enabling (and installing) ReadyBoost or using third party software.</p>
<p>Reasons for using Widows Server 2008 as a development environment... | <p>With Virtual machines, the answer to "do you really need so much memory" is a resounding YES. Trying to run 4-6 virtual machines eacch configured with 512MB or more really stresses out the system. </p>
<p>The ability to use ANYTHING as additonal virtual memory is key.</p>
| <ul>
<li>Is everything that's installed
64bit?</li>
<li>Do you have hardware virtualization
capabilities and is it turned on in
the bios?</li>
<li><a href="http://www.ditii.com/2008/03/04/windows-server-2008-enable-superfetch/" rel="nofollow noreferrer">Have you enabled superfetch?</a></li>
<li><a href="http://www.tech... | 10,658 |
<p>This question is related to another question which I asked yesterday! </p>
<p><a href="https://stackoverflow.com/questions/220796/list-all-links-in-web-site">List all links in web site</a></p>
<p>I think renaming all the .html files to .asp and changing the links is not good for SEP purposes. Some one told me that... | <p>We've been using the <a href="http://www.codeplex.com/IIRF" rel="nofollow noreferrer">Ionic rewriter</a>. It seems to work very well. Your application doesn't need any knowledge of the rewriter. You just configure it in IIS, and it redirects your links. It's also free/donationware.</p>
<p><a href="http://www.ii... | <p>Another option is not to rename the files at all. You could setup an application mapping for HTML files which will pass them through the asp processor. This will give you dynamic content, etc without any SEO side effects.</p>
<p>As ever, there is a downside. Passing an HTML file which is intended to be static throu... | 28,361 |
<p>How do you get the current directory where your app is running? </p>
| <p>You could try this:</p>
<pre><code>using System.IO;
using System.Reflection;
namespace Utilities
{
static public class DirectoryHelper
{
static public string GetCurrentDirectory ()
{
return Path.GetDirectoryName (Assembly.GetExecutingAssembly ().GetName ().CodeBase);
}
... | <p>Public Shared Sub WriteDBStatus(ByVal strString As String)</p>
<pre><code> Try
Dim FILE_NAME As String = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + "\DBStatus"
Dim sr As IO.StreamWriter = Nothing
If Not IO.File.Exists(FILE_NAME) Then
sr = IO.... | 36,030 |
<p>I am looking for a custom control which could enable me to call message of following type.</p>
<p><a href="http://extjs.com/deploy/dev/examples/message-box/msg-box.html" rel="nofollow noreferrer">http://extjs.com/deploy/dev/examples/message-box/msg-box.html</a></p>
<p>Is there a control which function like a .NET ... | <p>There is a <strong>good tutorial</strong> which could help:</p>
<p><a href="http://www.jankoatwarpspeed.com/post/2008/05/28/Create-MessageBox-user-control-using-ASPNET-and-CSS.aspx" rel="nofollow noreferrer">Create MessageBox user control using ASP.NET and CSS</a></p>
<p>And here combining it with the <strong>Ajax... | <p>use the namespace "System.Windows.Forms" by adding the reference to the solution explorer</p>
| 37,485 |
<p>Assuming a class called <code>Bar</code> in a namespace called <code>foo</code>, which syntax do you prefer for your source (.cpp/.cc) file?</p>
<pre><code>namespace foo {
...
void Bar::SomeMethod()
{
...
}
} // foo
</code></pre>
<p>or</p>
<pre><code>void foo::Bar::SomeMethod()
{
...
}
</code></pre>
<p>... | <p>I would decline the first (<em>edit</em> : question changed, the first is what i prefer too now). Since it is not clear where Bar refers to from only looking at the function definition. Also, with your <strike>first</strike> method, slippy errors could show up:</p>
<pre><code>namespace bar {
struct foo { void... | <p>I think it depends on each case. If it's a 3rd party library that's similar to your own code, and you want to avoid confusion in the code, then specifying the full namespace at each occurance may be beneficial. But other than that, less code is generally better (unless it becomes unclear).</p>
| 38,460 |
<p>Hey, I'm using <a href="http://en.wikipedia.org/wiki/Levenshtein_distance" rel="nofollow noreferrer">Levenshteins</a> algorithm to get distance between source and target string.</p>
<p>also I have method which returns value from 0 to 1:</p>
<pre><code>/// <summary>
/// Gets the similarity between two strings... | <p>Your problem here may be distinguishing between noise words and useful data:</p>
<ul>
<li>Rolling_Stones.Best_of_2003.Wild_Horses.mp3</li>
<li>Super.Quality.Wild_Horses.mp3</li>
<li>Tori_Amos.Wild_Horses.mp3</li>
</ul>
<p>You may need to produce a dictionary of noise words to ignore. That seems clunky, but I'm not... | <p>There is a <a href="https://github.com/kdjones/fuzzystring" rel="nofollow noreferrer">GitHub repo</a> implementing several methods.</p>
| 7,695 |
<p>I have a page something.aspx, with associated codebehind something.aspx.cs. In that codebehind, I want to know the filesystem location of something.aspx. Is there any convenient way to get it?</p>
<p>Update: I got several excellent answers, which unfortunately didn't work because of something else crazy I'm doing... | <p><a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest.physicalpath.aspx" rel="noreferrer">Request.PhysicalPath</a></p>
| <p><code>Server.MapPath( Request.AppRelativeCurrentExecutionFilePath )</code></p>
| 22,812 |
<p>I've searched on the Internet for comparisons between <a href="http://en.wikipedia.org/wiki/F_Sharp_%28programming_language%29" rel="noreferrer">F#</a> and <a href="http://en.wikipedia.org/wiki/Haskell_%28programming_language%29" rel="noreferrer">Haskell</a> but haven't found anything really definitive. What are the... | <p>Haskell is a "pure" functional language, where as F# has aspects of both imperative/OO and functional languages. Haskell also has lazy evaluation, which is fairly rare amongst functional languages.</p>
<p>What do these things mean? A pure functional language, means there are no side effects (or changes in shared st... | <p>Well, for one I'd say a main advantage is that F# compiles against the .NET platform which makes it easy to deploy on windows. I've seen examples which explained using F# combined with ASP.NET to build web applications ;-)</p>
<p>On the other hand, Haskell has been around for waaaaay longer, so I think the group of... | 6,674 |
<p>We are in the process of moving our SVN repositories from one machine to another one, and with it will come a new domain name for the new repo. The problem is, that within the repository, there are lots of svn:externals references to other projects within the repository. So for example, we have projectA, which has... | <p>As you indicated that you still want to be able to check out older revisions, the only solution is really to "rewrite" the entire history (solution D mentioned earlier).</p>
<p>To do this, you should:</p>
<p>1) Dump the contents of the <em>entire</em> repository using <a href="http://svnbook.red-bean.com/en/1.1/re... | <p>You could:</p>
<p>a) check out the old revision, and change your hosts-file to point the old name to the new address, then svn update. In case the URL-path also changed... well then you might as well:</p>
<p>b) take the time to write a script that find the properties in the current (old revision-) working copy and... | 25,053 |
<p>I am trying to run a SeleniumTestCase with phpunit but I cannot get it to run with the phpunit.bat script. </p>
<p>My goal is to use phpunit with Selenium RC in CruiseControl & phpUnderControl. This is what the test looks like:</p>
<pre><code>require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
class WebTe... | <p>hopefully this is a more definitive answer then the ones given here (which did not solve me problem). If you are getting this error, check your PEAR folder and see if the "SeleniumTestCase.php" file is actually there:</p>
<pre><code>/PEAR/PHPUnit/Extensions/SeleniumTestCase.php
</code></pre>
<p>If it is NOT, the e... | <p>Well when I use inline command : if lauching test from PhPunit dir i have the error while whent launching it from test dir I havne't the error ...</p>
<p>but I still haven't any acces to selenium server ... shall I have to launch it before or not.</p>
<p>If Yes it's strange that we havne't to specify any handle to... | 10,327 |
<p>Did you know that :</p>
<pre><code>Map<Object,Object> m1 = new HashMap<Object, Object>();
Map<Object,Object> m2 = new HashMap<Object, Object>();
System.out.println("m1.equals(m2) = "+m1.equals(m2));
System.out.println("m1.keySet().equals(m2.keySet()) = "
+m1.keySet().equals(m2.ke... | <p>Per the contract of <a href="http://java.sun.com/javase/6/docs/api/java/util/Collection.html#equals(java.lang.Object)" rel="nofollow noreferrer"><code>Collection#equals()</code></a>, there is no general-purpose equals() methods for <code>Collection</code>s, and thus <code>AbstractCollection</code> cannot provide one... | <p>I am not sure if thatt's the official reason, but AbstractCollection avoids adding semantic constraints on potential subclasses. The semantics of equality are determined by the nature of the concrete inheriting data structure, and in particular based on whether your structure is ordered and whether it allows duplica... | 44,369 |
<p>Referenced <a href="https://stackoverflow.com/questions/21265/comparing-ieee-floats-and-doubles-for-equality">here</a> and <a href="https://stackoverflow.com/questions/17333/most-effective-way-for-float-and-double-comparison">here</a>...Why would I use two's complement over an epsilon method? It seems like the epsi... | <p>the second link you reference mentions an article that has quite a long description of the issue:</p>
<p><a href="http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm" rel="nofollow noreferrer">http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm</a></p>
<p>but unless you ... | <p>When it comes to speed, follow these rules:</p>
<ol>
<li>If you're not a very experienced developer, don't optimize.</li>
<li>If you are an experienced developer, don't optimize yet.</li>
</ol>
<p>Do the easiest method.</p>
<p>Alex</p>
| 12,181 |
<p>I have a form with some radio buttons that are disabled by default. </p>
<p>When a value gets entered into a text box, the radio buttons are enabled via javascript. The user then selects one of the radio buttons and clicks on a submit button which posts back to the server.</p>
<p>When I get back to the server, the... | <p>This has to do with how ASP.NET postback data. If a control is disabled <code>control.enabled = false</code> when the page is rendered than the values will not be posted back to the server. How I have solved it in the past is to set the disabled flag using attributes tags instead of using the Enabled property. So... | <p>This isn't working for me.</p>
<p>I added:</p>
<pre><code>Me.rbSolid.Style.Add("background-color", "red")
Me.rbSolid.Style.Add("disabled", "true")
</code></pre>
<p>and the background style works but the <code>disabled</code> did not. It's still editable when the form renders.... | 15,805 |
<p>I'd like to know which method is recommended on Windows C programming: using malloc or the Win32 HeapAlloc (maybe VirtualAlloc?) function.</p>
<p>I've read the MSDN <a href="http://msdn.microsoft.com/en-us/library/aa366781(VS.85).aspx" rel="nofollow noreferrer">Memory Management Functions</a> article and the MSDN a... | <p>Stick with malloc unless you have a compelling reason to use something different. It will be implemented underneath in terms of the OS memory allocation primitives, but there is no real advantage in diving down to that layer yourself.</p>
<p>A few API calls I believe need a memory block allocated from a Windows he... | <p>Unlike Rob, I go the other way... Since I chose to code against the WinAPI, I use the native functions instead of C run-time ones, which are just a thin wrapper around them anyway.</p>
| 30,208 |
<p>I can print a reasonably high quality print, but then there will be a millimetre or two of rubbish.</p>
<p><a href="https://i.stack.imgur.com/9ppdc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9ppdc.jpg" alt="Bad layer"></a>
<a href="https://i.stack.imgur.com/9kreD.jpg" rel="nofollow noreferre... | <p>This can be caused by various problems, of which an <a href="/a/7901/5740">aforementioned</a> filament diameter is only one of multiple possible causes.</p>
<p>The observed phenomenon is called <strong><em>under-extrusion</em></strong>. Temporary under-extrusion can also be caused by filament friction on the spool,... | <p>One of the reasons for such a defect may be a local decrease in the diameter of the filament. Carefully check your filament.</p>
| 1,168 |
<p>My code needs to determine how long a particular process has been running. But it continues to fail with an access denied error message on the <code>Process.StartTime</code> request. This is a process running with a User's credentials (ie, not a high-privilege process). There's clearly a security setting or a policy... | <p>I've read something similar to what you said in the past, Lars. Unfortunately, I'm somewhat restricted with what I can do with the machine in question (in other words, I can't go creating user groups willy-nilly: it's a server, not just some random PC).</p>
<p>Thanks for the answers, Will and Lars. Unfortunately, t... | <p>OK, sorry that didn't work... I am no expert on ASP.NET impersonation, I tend to use app pools which I don't think you can do on W2K Have you tried writing a tiny little test app which does the same query, and then running that as various users? </p>
<p>I am reluctant to post a chunk of MS framework code here,... | 4,831 |
<p>How do I get the value of a <code>MemberInfo</code> object? <code>.Name</code> returns the name of the variable, but I need the value. </p>
<p>I think you can do this with <code>FieldInfo</code> but I don't have a snippet, if you know how to do this can you provide a snippet??</p>
<p>Thanks!</p>
| <p>Although I generally agree with Marc's point about not reflecting fields, there are times when it is needed. If you want to reflect a member and you don't care whether it is a field or a property, you can use this extension method to get the value (if you want the type instead of the value, see nawful's answer to <... | <p>Jon's answer is ideal - just one observation: as part of general design, I would:</p>
<ol>
<li><em>generally</em> avoid reflecting against
non-public members</li>
<li>avoid having public fields (almost always)</li>
</ol>
<p>The upshot of these two is that <em>generally</em> you only need to reflect against public ... | 29,508 |
<p>I understand that creating too many threads in an application isn't being what you might call a "good neighbour" to other running processes, since cpu and memory resources are consumed even if these threads are in an efficient sleeping state.</p>
<p>What I'm interested in is this: <strong>How much memory (win32 pla... | <p>I have a server application which is heavy in thread usage, it uses a configurable thread pool which is set up by the customer, and in at least one site it has 1000+ threads, and when started up it uses only 50 MB. The reason is that Windows <em>reserves</em> 1MB for the stack (it maps its address space), but it is ... | <p>I guess this can be measured quite easily.</p>
<ol>
<li>Get the amount of resources used by the system before creating a thread</li>
<li>Create a thread with default system values (default heap size and others)</li>
<li>Get the amount of resources after creating a thread and make the difference (with step 1).</li>
... | 31,966 |
<p>What is meant by <code>nvarchar</code>?</p>
<p>What is the difference between <code>char</code>, <code>nchar</code>, <code>varchar</code>, and <code>nvarchar</code> in SQL Server?</p>
| <p>Just to clear up... or sum up...</p>
<ul>
<li><strong><code>nchar</code></strong> and <strong><code>nvarchar</code></strong> can store <strong>Unicode</strong> characters.</li>
<li><strong><code>char</code></strong> and <strong><code>varchar</code></strong> <strong>cannot store Unicode</strong> characters.</li>
<li... | <p><strong>NVARCHAR</strong> can store Unicode characters and takes 2 bytes per character.</p>
| 21,265 |
<p>I'm designing a small SQL database to be used by a web application.</p>
<p>Let's say a particular table has a Name field for which no two rows will be allowed to have the same value. However, users will be able to change the Name field at any time.</p>
<p>The primary key from this table will be used as a foreign ... | <p>I would use a generated PK myself, just for the reasons you mentioned. Also, indexing and comparing by integer is faster than comparing by strings. You can put a unique index on the name field too without making it a primary key.</p>
| <p>The primary key must be <em>unique</em> for every row. The auto_increment Integer is very good idea, and if you don't have other ideas about populating the primary key then this is the best way.</p>
| 20,141 |
<p>As an electrician newbie I have a question..</p>
<h2>Short question</h2>
<p>My power plug is attached to the wall outlet and three wires are at the end of it.. the blue, the brown and the green/yellow oen.</p>
<p>How to determine which is the live, zero and ground wire WITHOUT depending on the colouring?
I want to k... | <p>As it is alternating current, why are you interested to know which is which? (I'm referring to the blue and the brown wire, the green/yellow has an obvious purpose) </p>
<p>E.g. a <a href="https://en.wikipedia.org/wiki/AC_power_plugs_and_sockets" rel="nofollow noreferrer">CEE 7/4 plug</a> can be flipped around in t... | <p>As it is alternating current, why are you interested to know which is which? (I'm referring to the blue and the brown wire, the green/yellow has an obvious purpose) </p>
<p>E.g. a <a href="https://en.wikipedia.org/wiki/AC_power_plugs_and_sockets" rel="nofollow noreferrer">CEE 7/4 plug</a> can be flipped around in t... | 1,243 |
<p>Rails introduced some core extensions to Ruby like <code>3.days.from_now</code> which returns, as you'd expect a date three days in the future. With extension methods in C# we can now do something similar:</p>
<pre><code>static class Extensions
{
public static TimeSpan Days(this int i)
{
return new ... | <p>I like extension methods a lot but I do feel that when they are used outside of LINQ that they improve readability at the expense of maintainability.</p>
<p>Take <code>3.Days().FromNow()</code> as an example. This is wonderfully expressive and anyone could read this code and tell you exactly what it does. That is... | <p>I'm on the conservative side of the spectrum, at least for the time being, and am against extension methods. It is just syntactic sugar that, to me, is not that important. I think it can also be a nightmare for junior developers if they are new to C#. I'd rather encapsulate the extensions in my own objects or static... | 48,518 |
<p>I have been banging my head against a brick wall trying to deploy my MVC app on IIS6 (<a href="https://stackoverflow.com/questions/275920/aspnet-mvc-on-iis-6-wildcard-mapping-the-incoming-request-does-not-match-any-ro">linked question</a>)</p>
<p>I have scrapped wildcard mapping for the time being and am trying to ... | <p>My <a href="https://stackoverflow.com/questions/275920/aspnet-mvc-on-iis-6-wildcard-mapping-the-incoming-request-does-not-match-any-ro">original problem</a> has been solved by <a href="https://stackoverflow.com/users/36849/oli">Oli</a> who pointed out that the Global.asax file is needed with the website. I was using... | <blockquote>
<p>I have not made any changes to the
default Web.config and all my routes
are configured with extenionless and
extension based equivalents.</p>
</blockquote>
<p>Whats the order of the extension and extensionless routes?</p>
<p>I would either remove extensionless (since you are using extensions),... | 35,928 |
<p>How do you handle passwords for services when the user enters something that is best represented in Unicode or some other non-Latin character encoding?</p>
<p>Specifically, can you use a Cyrillic password as a password to Oracle? What do you do to verify a user's password against a Windows authentication mechanism ... | <p><strong>XPath expressions cannot be evaluated agaist a non-wellformed XML document</strong>, which is exactly the described case.</p>
<p>It is possible to do this in two chained steps, the first of which is to convert the HTML to wellformed XML and then the second -- to apply the XPath expression.</p>
<p>Therefore... | <p>XPath does not work directly with HTML. The interaction of XPath with your HTML is dictacted by whatever software/library is parsing the HTML into a rendering tree. This may help direct your search appropriately.</p>
| 46,157 |
<p>I'm having trouble with something that I thought would be easy...
I can't get my NotifyIcon to show a balloon tip. The basic code is:</p>
<pre><code>public void ShowSystrayBubble(string msg, int ms)
{
sysTrayIcon.Visible = true;
sysTrayIcon.ShowBalloonTip(20, "Title", "Text", ToolTipIcon.None);
}
</code></pre>... | <p>I had foiled myself... This turned out to be an issue at the OS level. I had previously disabled all balloons via the registry a few weeks ago.</p>
<p>You can read the information here on how to disable balloon tips in WinXP:
<a href="http://support.microsoft.com/kb/307729" rel="nofollow noreferrer">http://support... | <p>Please see this it covers all combinations of mouse clicks with NotifyIcon as well as much more. The code is located in a template and is project setting driven so that you can implement NotifyIcon logic in all your projects with no coding effort at all.</p>
<p>More Here</p>
<p><a href="http://code.msdn.microsoft.... | 23,561 |
<p>Is there a way to send an email from an iSeries terminal, adding an attachment from the IFS? I know how to send a normal email using the SNDDST utility.</p>
| <p>There is two main methods of doing this. </p>
<ol>
<li>The Do-It-Yourselfer will use QtmmSendMail API</li>
<li>Otherwise there are several other free and purchased products that you could use. The ones I would recommend are:
<ul>
<li><a href="http://www.bvstools.com/mailtool.html" rel="noreferrer">MAILTOOL</a> - ... | <p>You could code your own program with Java and the <a href="http://java.sun.com/products/javamail/" rel="nofollow noreferrer">JavaMail API</a>.</p>
| 41,566 |
<p>I want to do this:</p>
<pre><code>e.className = t;
</code></pre>
<p>Where t is the name of a style I have defined in a stylesheet.</p>
| <p>If <code>e</code> is a reference to a DOM element and you have a class like this: <code>.t {color:green;}</code> then you want reference the class name as a string:</p>
<pre><code>e.className = 't';
</code></pre>
| <pre><code>document.getElementById('id').className = 't'
</code></pre>
| 13,561 |
<p>This is a little convoluted, but lets try:</p>
<p>I'm integrating LUA scripting into my game engine, and I've done this in the past on win32 in an elegant way. On win32 all I did was to mark all of the functions I wanted to expose to LUA as export functions. Then, to integrate them into LUA, I'd parse the PE header... | <p>iPhone does not support dynamic linking after the initital application launch. While what you want to do does not actually require linking in any new application TEXT, it would not shock me to find out that some of the dl* functions do not behave as expected.</p>
<p>You may be able to write some platform specific c... | <p>You need to pass <code>--export-dynamic</code> to the linker (via <code>-Wl,--export-dynamic</code>).</p>
<p>Note: This is for Linux, but could be a starting point for your search.</p>
<p>References:</p>
<ul>
<li><a href="http://sourceware.org/binutils/docs/ld/Options.html" rel="nofollow noreferrer">http://source... | 32,897 |
<p>Most people, articles, videos, etc. refer to printing speed by linear speed (mm/s), but a lot of YouTubers prefer to talk about volumetric flow (mm<sup>3</sup>/s) (mm cubed per second). I suspect that at some point in the past year or three, some of the more engineer-y types switched to this new measurement standar... | <p>Linear print speed is widely written in marketing material and in filament manufacturers' official print setting recommendations, and is the value talked about by naive users, including a number of popular YouTube personalities. <strong>However, in most contexts it's at best the wrong number, and more often, meaingl... | <p>Flow rate adds a dimension to the regularly used printing speed. Note that maximum volumetric flow is determined by the hotend (unless your extruder is under dimensioned or highly geared) as it cannot supply more molten filament than it can melt in a certain time.</p>
<p>So, instead of specifying the print speed, yo... | 2,070 |
<p>I have a TDbGrid, and I can easily tell how many columns are in it at runtime with the FieldCount property, but there doesn't seem to be a corresponding RowCount property to display how many records are being displayed. How can I find this out?</p>
| <p>You could try:</p>
<pre><code>DBGrid1.DataSource.DataSet.RecordCount
</code></pre>
<p>Maybe there are better solutions. But this worked for me.</p>
| <p>I would use</p>
<pre><code>TDbGrid.ApproxCount
</code></pre>
| 37,572 |
<p>I'm hitting this error and I'm not really sure why. I have a minified version of excanvas.js and something is breaking in IE, specifically on:</p>
<p><code>
var b=a.createStyleSheet();
</code></p>
<p>I'm not sure why. Does anyone have any insight? I can provide more information, I'm just not sure what informati... | <p>This is a slightly old thread, but I thought it would be useful to post. There seems to be a limitation on how much style information a page can contain, which causes this error in IE6. I am able to produce an invalid argument error using this simple test page:</p>
<pre><code><html>
<head>
<title>... | <p>First thing I'd do is use the un-minified version. Looks like this coming from an init function called from onreadystatechange, trying to style canvas elements, although that isn't as enlightening as one might hope.</p>
| 29,740 |
<p>I'm looking to stream lots of data (up to ~1 Gbit) from Java to a C++ application (both on the same machine). I'm currently using a FIFO on Linux but need a Windows solution too.</p>
<p>The most cross-platform method seems to be a local socket, but:
a) won't I get huge overhead from TCP checksumming and copying to ... | <p>Named pipes would be more efficient than TCP, but how about just using <strong>shared memory</strong> blocks? </p>
<p>I don't know what primitives exist on the Java side for interfacing with shared memory, but from the C++ side it would be more efficient to access data in shared memory than read it out of either a... | <p>I would advise against JNI, because it is very difficult to debug. If the C++ code segfaults or throws an uncaught exception, your JVM will crash, and you will have no idea why.</p>
| 33,467 |
<p>I have a byte stream I need parsed into a struct, and I also need to be able to parse the struct back to a byte stream.</p>
<p>Below is an example of what I want where I've used BitConverter to parse the values. I hope there is a more efficient way of doing this, because my structs are HUGE!</p>
<pre><code>ref str... | <p>For stuff like this, you usually use a code generator. Let's assume the source looks like this:</p>
<pre><code>struct a {
int i;
}
struct b {
string name;
struct a a;
}
</code></pre>
<p>What you do is you write a simple parser which searches the source (probably some header file) for "struct", then yo... | <p>You mention both C++ and .net. For C++ only, you should be able to do something along the lines of</p>
<pre><code>char buffer[sizeof(MYSTRUCT)];
memcopy((char*) &mystruct, buffer, sizeof(MYSTRUCT));
</code></pre>
<p><a href="http://www.parashift.com/c++-faq-lite/serialization.html" rel="nofollow noreferrer">Fo... | 40,895 |
<p>I've begun to use TDD. As mentioned in <a href="https://stackoverflow.com/questions/64333/what-is-the-downside-to-test-driven-development#64402">an earlier question</a> the biggest difficulty is handling interface changes. How do you reduce the impact on your test cases as requirements change?</p>
| <p>Changing an interface requires updating code that uses that interface. Test code isn't any different from non-test code in this respect. It's unavoidable that tests for that interface will need to change.</p>
<p>Often when an interface changes you find that "too many" tests break, i.e. tests for largely unrelated... | <p>You write the tests before you write the code for the new interface.</p>
| 16,859 |
<p>I'm trying to upload an image to my site through a form, however it's much more efficient to (rather than bog down the database) just store the location of the image in the database.</p>
<p>I'm having trouble with my form and really don't know where to go:</p>
<pre><code><?=form_open('bro/submit_new');?>
//... | <p>CodeIgniter's file uploading class will do this for you. The <a href="http://codeigniter.com/user_guide/libraries/file_uploading.html" rel="noreferrer">entry in their user guide</a> explains as well as I could, so I'm going to point you there. </p>
<p>Essentially you'd just need to modify the controller that they h... | <p>use the model pages to upload data to database</p>
| 36,662 |
<p>I have heard several podcasters (most recently the guys on <a href="http://www.dotnetrocks.com/" rel="nofollow noreferrer">DotNetRocks</a>) say that the look and feel of Visual Studio 2010 has been completely redesigned and Visual Studio rewritten in WPF.</p>
<p>I have been watching some <a href="http://channel9.ms... | <p>I'm guessing 3D with a space theme. You'll be able to "fly through" your code, "orbiting" classes, "shooting down" bugs and "launching" your code.</p>
| <p>Highlights from the PDC Keynote #1 on Day 2 (see: <a href="http://www.microsoftpdc.com" rel="nofollow noreferrer">PDC website</a>)</p>
<ul>
<li>Multi-monitor support for the IDE via
WPF.</li>
<li>Building classes from test classes.</li>
<li>Toggle TFS bugs over a code segment
in Debug mode.</li>
<li>Partial config ... | 49,769 |
<p>There are a number of commercial offerings that I've come across but nothing open-source.</p>
<p>I realise that you could do something simiilar with JUnit / JMeter but I'm looking for something a bit more specific.</p>
| <p>What about clif
<a href="http://clif.ow2.org/" rel="nofollow">http://clif.ow2.org/</a></p>
<p>or jmeter
<a href="http://jmeter.apache.org/" rel="nofollow">http://jmeter.apache.org/</a></p>
<p>I think there are others, but these two spring to mind.</p>
| <p>Load testing is a very complex activity. You'll need to be able to simulate many contexts (e.g., IP, port) and divide the load generators on many machines. While doing that you'll need to monitor the server (Application under test).</p>
<p>As of today, there are several very good commercial tools that needs certain... | 10,291 |
<p>I have a Java file <code>TestThis.java</code> like the following:</p>
<pre><code>class A
{
public void foo()
{
System.out.println("Executing foo");
}
}
class B
{
public void bar()
{
System.out.println("Executing bar");
}
}
</code></pre>
<p>The above code file is compiling ... | <p>As usual (for example, accessing from the Test.java):</p>
<pre><code>public class Test {
public static void main(String... args) {
A a = new A();
a.foo();
B b = new B();
b.bar();
}
}
</code></pre>
<p>The rule here is that you could not have more than one public class in the ... | <p>Any other class in the same package can access A and B; in this case the null package is being used since no package statement is present for the source file.</p>
| 42,094 |
<p>It's been awhile since my algorithms class in school, so forgive me if my terminology is not exact. </p>
<p>I have a series of actions that, when run, produces some desired state (it's basically a set of steps to reproduce a bug, but that doesn't matter for the sake of this question). </p>
<p>My goal is to find th... | <p>Your naive n^2 approach is not exactly correct; in the worst case you might have to look at all subsets (well actually the more accurate thing to say is that this problem might be NP-hard, which doesn't mean "might have to look at all subsets", but anyway...)</p>
<p>For example, suppose you are currently running st... | <p>You problem domain can be mapped to directional graph where you have states as nodes and steps as links , you want to find the shortest path in a graph , to do this a number of well known algorithms exists for example <a href="http://en.wikipedia.org/wiki/Dijkstra's_algorithm/" rel="nofollow noreferrer">Dijkstra... | 40,421 |
<p>What is a good way to render data produced by a Java process in the browser? </p>
<p>I've made extensive use of JSP and the various associated frameworks (<a href="http://java.sun.com/products/jsp/jstl/" rel="nofollow noreferrer">JSTL</a>, <a href="http://struts.apache.org/" rel="nofollow noreferrer">Struts</a>, <a... | <p>I personally use <a href="http://tapestry.apache.org/tapestry5/" rel="nofollow noreferrer">Tapestry 5</a> for creating webpages with Java, but I agree that it can sometimes be a bit overkill. I would look into using JAX-RS (<a href="https://jsr311.dev.java.net/" rel="nofollow noreferrer">java.net project</a>, <a hre... | <p>Perhaps you could generate the data as XML and render it using XSLT?</p>
<p>I'm not sure PHP or Ruby are the answer if Java isn't fast enough for you!</p>
| 10,967 |
<p>I want to style the last TD in a table without using a CSS class on the particular TD.</p>
<pre><code><table>
<tbody>
<tr>
<td>One</td>
<td>Two</td>
<td>Three</td>
<td>Four</td>
<td>Five</td>
</t... | <p>The <code>:last-child</code> selector should do it, but it's <a href="http://www.quirksmode.org/css/contents.html" rel="noreferrer">not supported in any version of IE</a>.</p>
<p>I'm afraid you have no choice but to use a class.</p>
| <p>This is the code that will add border for all the nodes and will remove the border for the last node(TD).</p>
<pre><code><style type="text/css">
body {
font-family:arial;font-size: 8pt;
}
table td{
border-right: #666 1px solid
}
table td {
h: expression(t... | 46,945 |
<p>I have a collection of objects to which I'd like to just add a new property. How do I do that with LINQ?</p>
| <pre><code>var a = from i in ObjectCollection select new {i.prop1, i.prop2, i.prop3, ..., newprop = newProperty}
</code></pre>
| <p>I don't think that you can using pure LINQ. However, if you're doing this sort of thing a lot in your code you may be able to make this work with reflection.</p>
| 6,825 |
<p>Why would I want to use PHP's <a href="http://www.php.net/filter" rel="nofollow noreferrer">filter</a> library? Why wouldn't I?</p>
<p>It seems to try and do a bit of clean-up (it's awful when you have to work with regular expressions), but on the other hand function naming and parameter constants seem to be a disa... | <p>Probably the best resource for this is the tutorial linked to from the PHP manual page: <a href="http://devolio.com/blog/archives/413-Data-Filtering-Using-PHPs-Filter-Functions-Part-one.html" rel="nofollow noreferrer">http://devolio.com/blog/archives/413-Data-Filtering-Using-PHPs-Filter-Functions-Part-one.html</a></... | <p>It's about using a well-tested data filtering framework to prevent XSS and SQL Injection attacks.</p>
<p>If you look at all the possibilities, that is the kind of filtering you don't want to implement yourself.</p>
<p><a href="http://www.php.net/manual/en/intro.filter.php" rel="nofollow noreferrer">http://www.php.... | 48,081 |
<p>The situation is somewhat like-</p>
<pre><code>var someVar = some_other_function();
someObj.addEventListener("click", function(){
some_function(someVar);
}, false);
</code></pre>
<p>The problem is that the value of <code>someVar</code> is not visible inside the listener function of the <code>addEventListener</... | <p>There is absolutely nothing wrong with the code you've written. Both <code>some_function</code> and <code>someVar</code> should be accessible, in case they were available in the context where anonymous </p>
<pre><code>function() { some_function(someVar); }
</code></pre>
<p>was created. </p>
<p>Check if the ale... | <p>Other alternative, perhaps not as elegant as the use of bind, but it is valid for events in a loop </p>
<pre><code>for (var key in catalog){
document.getElementById(key).my_id = key
document.getElementById(key).addEventListener('click', function(e) {
editorContent.loadCatalogEntry(e.srcElement.my_id... | 32,036 |
<p>I'm working on a project that has a rich object model with various sets of aggregate roots. </p>
<p>We're using the <strong>Castle</strong> stack (Monorail through to nHibernate with ActiveRecord).</p>
<p>We have marked the aggregate roots as lazy <code>[ActiveRecord(Lazy = true)]</code> and have customized 'eager... | <p>Do an "inner join fetch" on the Account.Order.Product entity. So instead of something like this (which is what you probably already have):</p>
<pre><code>"from Account a inner join fetch a.Order where a.ID = ?"
</code></pre>
<p>Tell it to fetch the Order.Product as well:</p>
<pre><code>"from Account a inner join... | <p>From "NHibernate in Action", page 225: </p>
<blockquote>
<p>NHibernate currently limits you to fetching just one collection eagerly.</p>
</blockquote>
<p>That might explain the second query for fetching the addresses.</p>
| 49,869 |
<p>I have a file with fields separated by pipe characters and I want to print only the second field. This attempt fails:</p>
<pre><code>$ cat file | awk -F| '{print $2}'
awk: syntax error near line 1
awk: bailing out near line 1
bash: {print $2}: command not found
</code></pre>
<p>Is there a way to do this?</p>
| <p>Or just use one command:</p>
<pre><code>cut -d '|' -f FIELDNUMBER
</code></pre>
| <p>And 'file' contains no pipe symbols, so it prints nothing. You should either use 'cat file' or simply list the file after the awk program.</p>
| 26,289 |
<p>I've been doing quite a bit of debugging of managed applications lately using both Visual Studio and WinDbg, and as such I'm often ask to assist colleagues in debugging situations. On several occasions I have found people aho just insert break points here and there and hope for the best. In my experience that is rar... | <p>One very best practice is not diving into debugger immediately but look at the code and <em>think hard</em> for some time.</p>
| <p>I just replayed in <a href="https://stackoverflow.com/questions/365424/how-to-learn-c-debugging-and-best-practices#365575">another post</a>, the question was C debugging but as i stated in my replay i think that debugging techniques are language independent. </p>
| 47,833 |
<p>What's the best way to go about creating a vertical and horizontal ruler bars in an SDI app? Would you make it part of the frame or the view? Derive it from CControlBar, or is there a better method?</p>
<p>The vertical ruler must also be docked to a pane and not the frame.</p>
<p>To make it a little clearer as t... | <p>I would <strong><em>not</em></strong> use control bars. I have no good reason other then (IMOHO) are difficult to get to do what you want - if what you want if something other than a docking toolbar.</p>
<p>I would just draw them directly on the View window using GDI calls.</p>
<p>I guess I <em>might</em> think ab... | <p>I ended up deriving the ruler from CWnd as you suggested and skipping the control bar route. This code works in either case:</p>
<pre><code>m_wndSplitter.CreateStatic(this, 1, 3);
m_wndLeftPane.Create(&m_wndSplitter,WS_CHILD|WS_VISIBLE,m_wndSplitter.IdFromRowCol(0, 0));
m_ruler.Create(&m_wndSplitter,WS_CH... | 20,221 |
<p>Setting up an integration server, I’m in doubt about the best approach regarding using multiple tasks to complete the build. Is the best way to set all in just one big-job or make small dependent ones?</p>
| <p>You definitely want to break up the tasks. Here is a nice example of CruiseControl.NET configuration that has different targets (tasks) for each step. It also uses a common.build file which can be shared among projects with little customization.</p>
<p><a href="http://code.google.com/p/dot-net-reference-app/sourc... | <p>I would definitely break down the jobs. Chances are you're likely to make changes in the builds, and it'll be easier to track down issues if you have smaller tasks instead of searching through one monolithic build.</p>
<p>You should be able to create one big job from the smaller pieces, anyways.</p>
| 4,978 |
<p>I want to create a custom control in C#. But every time I have to fully redraw my control, it flickers, even if I use double buffering (drawing to an Image first, and blitting that).</p>
<p>How do I eliminate flicker when I have to fully redraw?</p>
| <p>You could try putting the following in your constructor after the InitiliseComponent call. </p>
<pre><code>SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint, true);
</code></pre>
<p>EDIT:</p>
<p>If you're giving this a go, if you can, re... | <p>You say you've tried double buffering, but then you say drawing to an Image first and blitting that. Have you tried setting DoubleBuffered = true in the constructor rather than doing it yourself with an Image?</p>
| 8,978 |
<p>I'm designing a database for an events management site - there is a table of venues and a table of events. Each event is in a venue (stores the venue's id) and each venue is in a city. It must be possible to search for event by city, should city be a field in the venues table (which could possibly result in duplicat... | <p>Use a separate table -- that way you have a master list of cities to populate dropdowns and/or autosuggest fields, <em>and</em> you save space by storing ids instead of strings redundantly. If you have a million venues, and only a thousand cities, that's significant savings, both in terms of storage, and in terms o... | <p>It might be worth considering having an address table, with a city column.</p>
<p>The solution really depends on what the other functionality is, and whether the database will ever be used for other functions in the future.</p>
<p>It's also a subjective choice, in my opinion having a seperate city table is probabl... | 26,456 |
<p>I am building a graphic board like project where i am facing a design issue.</p>
<p>Main Class is Board which is a canvas responsible for handling mouse events when drawing shapes. It also has context variables such as currentShape or snapFlag to activate grid magnetism.</p>
<p>To handle the moving / resizing / ro... | <p>I would approach this from a slightly different angle. I assume that the <code>Board</code> object traps mouse events first, so that it can decide which shape has been clicked on. I would have the board trap mouse movements as well, passing the correct (snapped or unsnapped) coordinates "down" to the selected <code>... | <p>Just trying to think together with you..
I see no big deal in Shapes having IBoard interface.
Though, I don't like the idea that they have to check the flag on the board...</p>
<p>How would you pass the flag as parameter? In OnMove() method? didn't understood this quite well...could you expand?</p>
<p>Though..
If ... | 40,744 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.