instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I have a vertical menu in my system which is basically made of HTML <code>ul</code>/<code>li</code> with CSS styling (see image below). However I don't want the <code>li</code> items which are wider than the menu to wrap, I would prefer them to overflow with a horizontal scroll bar at the bottom of the menu. How can...
<pre><code>ul { overflow: auto; // allow li's to overflow w/ scroll bar // at the bottom of the menu } li { white-space: nowrap; // stop the wrapping in the first place } </code></pre>
<p>You would also need to give the style the ul:</p> <pre><code>ul{ width:250px; overflow:auto; } </code></pre>
38,028
<p>I have a stored procedure that needs to convert hexadecimal numbers to their decimal equivalent. I've read the documentation for the UNHEX() function, but it is returning a binary value. What I'm wanting to do is something like this:</p> <pre><code>CREATE PROCEDURE foo( hex_val VARCHAR(10) ) BEGIN DECLARE dec...
<p>You can use the <a href="http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_conv" rel="noreferrer"><code>CONV()</code></a> function to convert between bases.</p> <pre><code>SET dec_val = CONV(hex_val, 16, 10); </code></pre>
<pre><code>conv(hex_val, 16, 10) </code></pre> <p>Will convert a number of base 16 to base 10. The UNHEX function does something completely different, it converts pairs of hex digits to characters.</p>
45,661
<p>Does Java have a built-in way to escape arbitrary text so that it can be included in a regular expression? For example, if my users enter "$5", I'd like to match that exactly rather than a "5" after the end of input.</p>
<p>Since <a href="http://download.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#quote(java.lang.String)" rel="noreferrer">Java 1.5, yes</a>:</p> <pre><code>Pattern.quote("$5"); </code></pre>
<p>^(Negation) symbol is used to match something that is not in the character group.</p> <p>This is the link to <a href="https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference" rel="nofollow noreferrer">Regular Expressions</a></p> <p>Here is the image info about negat...
8,499
<p>For my C# app, I don't want to always prompt for elevation on application start, but if they choose an output path that is UAC protected then I need to request elevation.</p> <p>So, how do I check if a path is UAC protected and then how do I request elevation mid-execution?</p>
<p>The best way to detect if they are unable to perform an action is to attempt it and catch the <code>UnauthorizedAccessException</code>.</p> <p>However as @<a href="https://stackoverflow.com/users/941/dannysmurf">DannySmurf</a> <a href="https://stackoverflow.com/questions/17533/request-vista-uac-elevation-if-path-is...
<p>If your secondary drive has it's own file permissions, like say you have an other copy of windows installed on it. It will prompt.</p> <p>It will also prompt if files are in use, which sometimes occurs if you have windows explorer open to the same directory and the file selected with a file previewer displaying the...
3,816
<p>Our project is held in a SourceSafe database. We have an automated build, which runs every evening on a dedicated build machine. As part of our build process, we get the source and associated data for the installation from SourceSafe. This can take quite some time and makes up the bulk of the build process (which is...
<p>I should imagine the command line is implemented internally with the same code as you'd find in the object model, so unless there's a large amount of startup required, it shouldn't make much of a difference.</p> <p>The cost of rewriting to use the object model is probably more than would be saved in just leaving it...
<p>I betting running the Object Model will be slower by at least 2 hours.... ;-)</p>
49,512
<p>If I need to implement sending and receiving of business documents from system to system (invoices, POs, remittance advice, etc) what standard would you recommend for best interop and why? It could be XML or otherwise.</p>
<p>I would look at (in this order):</p> <ul> <li>Industry-specific formats. Always your best choice if you have a homogeneous trading group.</li> <li>cXML or XCBL if you want an XML solution with an established standard.</li> <li>X12 if you have unlimited time, money, and willing partners.</li> <li>custom XML only if...
<p>PDF - everyone has it, its cross platform and it can handle any document type. No good if you want to edit it though.</p>
20,132
<p>Does anyone know of a way to find out how much memory an instance of an object is taking?</p> <p>For example, if I have an instance of the following object:</p> <pre><code>TestClass tc = new TestClass(); </code></pre> <p>Is there a way to find out how much memory the instance <code>tc</code> is taking?</p> <p>Th...
<p>If you are not trying to do it in code itself, which I'm assuming based on your ANTS reference, try taking a look at CLRProfiler (currently v2.0). It's free and if you don't mind the rather simplistic UI, it can provide valuable information. It will give you a in-depth overview of all kinds of stats. I used it a whi...
<p>I have good experiences with <a href="http://memprofiler.com/" rel="nofollow noreferrer">MemProfiler</a>. It gives you stack traces of when the object was created and all the graphs of why the object is still not garbage collected.</p>
8,584
<p>I have a working excel workbook that has VBA code and macros to help in data input.</p> <p>I use a calendar to capture dates and read data out of cells. The application works 100% on my machine (application developed in <code>2007</code> but saved as a <code>.XLS – 97/2000</code> for compatibility in the office). W...
<p>The calendar control has many different versions, you need to build it out of the version they have on their machine.</p>
<p>VBA will automatically update references to the newest version. Example: If I reference Office 10.0 and you have Office 12.0 on your machine the reference will automatically be updated from ten to twelve. But it does <em>not</em> downgrade them. So if you have a reference to Office 12.0 and deploy it on a machine th...
31,168
<p>If you have a class member that is <code>static</code> and <code>public</code>. Would you write <code>static public</code> or <code>public static</code>? I know they are the same. But is there some recommendation / best practice for writing this?</p>
<p>see <a href="https://stackoverflow.com/questions/191929/is-there-a-convention-to-the-order-of-modifiers-in-c#191944">this question</a></p> <p>If you download the Microsoft <a href="http://code.msdn.microsoft.com/sourceanalysis" rel="noreferrer">StyleCop</a> Visual Studio addin, it can validate your source code agai...
<p>I personally would go with public static because it's more important that it's public than that it's static.</p> <p>And check this: <a href="http://checkstyle.sourceforge.net/config_modifier.html" rel="nofollow noreferrer">http://checkstyle.sourceforge.net/config_modifier.html</a></p> <p>As well as this: <a href="...
29,701
<p>I get this error when I do a <strong>bulk insert</strong> with <code>select * from [table_name]</code>, and another table name:</p> <pre><code>the locale id '0' of the source column 'PAT_NUM_ADT' and the locale id '1033' of the destination column 'PAT_ID_OLD' do not match </code></pre> <p>I tried resetting my db ...
<p>If you are copying less than a full set of fields from one table to another, whether that table is on another domain across the world, or is collocated in the same database, you just have to select them in order. SqlBulkCopyColumnMappings do not work. Yes, I tried. I used all four possible constructors, and I use...
<p>I would check what your default locale settings are. Also, you'll need to check the locale of both tables using sp_help to verify they are the same. If they aren't you'll need to convert it to the correct locale</p>
12,825
<p>I've installed Oracle XE with APEX, but forgot to write down the URL to access it. How may I determine the URL?</p>
<p>The default is <a href="http://127.0.0.1:8080/apex" rel="noreferrer">http://127.0.0.1:8080/apex</a></p> <p>If you happen to be on Windows, there will also be an entry in the Start menu (Programs > Oracle XE > Database homepage )</p>
<p>For future reference, to get to the Apex Administration Services:</p> <p><a href="http://127.0.0.1:8080/apex/apex_admin" rel="nofollow noreferrer">http://127.0.0.1:8080/apex/apex_admin</a></p>
21,883
<p>In the middle of a Perl script, there is a system command I want to execute. I have a string that contains the data that needs to be fed into stdin (the command only accepts input from stdin), and I need to capture the output written to stdout. I've looked at the various methods of executing system commands in Perl,...
<p>IPC::Open2/3 are fine, but I've found that usually all I really need is <a href="http://metacpan.org/pod/IPC::Run3" rel="nofollow noreferrer">IPC::Run3</a>, which handles the simple cases really well with minimal complexity:</p> <pre><code>use IPC::Run3; # Exports run3() by default run3( \@cmd, \$in, \$out, \$e...
<p>I always do it this way if I'm only expecting a single line of output or want to split the result on something other than a newline:</p> <pre><code>my $result = qx( command args 2&gt;&amp;1 ); my $rc=$?; # $rc &gt;&gt; 8 is the exit code of the called program. if ($rc != 0 ) { error(); } </code></pre...
10,355
<p>I am looking for a generic, bidirectional 1 to 1 Dictionary class in C# (2), ie. a <code>BiDictionaryOneToOne&lt;T, S&gt;</code> which is guaranteed to only contain one of each value and key (up to RefEquals anyway), and which can be searched using either key or value. Anyone know of one, or should I just implement ...
<p>OK, here is my attempt (building on Jon's - thanks), archived here and open for improvement :</p> <pre><code>/// &lt;summary&gt; /// This is a dictionary guaranteed to have only one of each value and key. /// It may be searched either by TFirst or by TSecond, giving a unique answer because it is 1 to 1. /// &lt;/s...
<p>A bit late, but here's an implementation I wrote a while back. It handles a few interesting edge cases, such as when the key overrides the equality check to perform partial equality. This results in the main dictionary storing <code>A =&gt; 1</code> but the inverse storing <code>1 =&gt; A'</code>.</p> <p>You access...
33,670
<p>I have a couple variants of a program that I want to compare on performance. Both perform essentially the same task.</p> <p>One does it all in C and memory. The other calls an external utility and does file IO.</p> <p>How do I reliably compare them? </p> <p>1) Getting "time on CPU" using "time" favors the second ...
<p>If I've understood, typing "time myapplication" on a bash command line is not what you are looking for.</p> <p>If you want accuracy, you must use a profiler... You have the source, yes?</p> <p>Try something like <a href="http://oprofile.sourceforge.net/news/" rel="nofollow noreferrer">Oprofile</a> or <a href="http...
<p>I'd probably lean towards adding "time -o somefile" to the front of the system command, and then adding it to the time given by time'ing your main program to get a total. Unless I had to do this lots of times, then I'd find a way to take two time outputs and add them up to the screen (using awk or shell or perl or ...
18,058
<p>How does one lock the focus of a .net application to a specific control? For example, if I have a form with 5 text boxes, and I want them filled out in a specific order, how can I stop someone who is in box 1 from tabbing/clicking to box 2, or hitting OK or Cancel or anything else? Is there an easy way, or do I ha...
<p>Handle the Leave event of your textBox1. Inside the event handler, if your conditions are not met, for e.g. if the user has not entered some input, reset the focus back to the control.</p> <pre><code>private void textBox1_Leave(object sender, EventArgs e) { if string.isNullOrEmpty(textBox1.Text) { t...
<p>Handle the Leave event of your textBox1. Inside the event handler, if your conditions are not met, for e.g. if the user has not entered some input, reset the focus back to the control.</p> <pre><code>private void textBox1_Leave(object sender, EventArgs e) { if string.isNullOrEmpty(textBox1.Text) { t...
35,707
<p>Does anyone have some good information on the usage of the .SaveChanges() method?</p> <p>I am experiencing a variety of issues when attempting to use the .SaveChanges() method on my data context object. I am taking data from an existing data source, creating the appropriate EntityFramework/DataService objects, pop...
<p>I have no big experience in using EntityFramework (just some random experiment), have you tried calling .SaveChanges() every n iterations?</p> <p>I mean something like this:</p> <pre><code>int i = 0; foreach (var item in collection) { // do something with your data if ((i++ % 10) == 0) context.Save...
<p>I am using EntityFramework on a small project also so I am very interested in the question also. Two quick questions: Have you tried to turn of the caching og the data objects in the datacontext? Have you tried to close the datacontext and created a new one during the loop to free up memory?</p> <p>Regards<...
23,062
<p>I'm trying to use System.Transaction.TransactionScope to create a transaction to call a few stored procedures but it doesn't seem to clean up after itself. Once the transaction is finished (commited or not and the transaction scope object is disposed) subsequent connections to the database open up with the read comm...
<p>Use <a href="http://msdn.microsoft.com/en-us/library/system.transactions.transactionoptions.isolationlevel.aspx" rel="nofollow noreferrer">TransactionOptions.IsolationLevel</a></p> <p>By <a href="http://msdn.microsoft.com/en-us/library/system.transactions.isolationlevel.aspx" rel="nofollow noreferrer">default, it's...
<p>You should also see a reset (<code>sp_reset_connection</code>) between uses of the same connection in the pool; will that not reset the isolation level? Have you tried reproducing a serializable issue (for example, lock escalation deadlocks)</p>
44,158
<p>I'm having a bit of trouble trying to get class variables to work in javascript. </p> <p>I thought that I understood the prototype inheritance model, but obviously not. I assumed that since prototypes will be shared between objects then so will their variables.</p> <p>This is why this bit of code confuses me.</...
<p><strong>Static (class level) variables can be done like this</strong>:</p> <pre><code>function classA(){ //initialize } classA.prototype.method1 = function(){ //accessible from anywhere classA.static_var = 1; //accessible only from THIS object this.instance_var = 2; } classA.static_var = 1; /...
<p>What you are defining is not a class variable, it is a default value for an instance variable.</p> <p>Class variables should be defined directly in the class, which means directly in the constrctor function.</p> <pre><code>function ClassA() { ClassA.countInstances = (ClassA.countInstances || 0) + 1; } var a1 =...
32,655
<p>Looking into System.Data.DbType there is no SqlVariant type there. SqlDataReader, for example, provides the GetString method for reading into string variable. What is the appropriate way to retrieve data from the database field of type sql_variant, presumably into object? </p> <p>The aim is to read data stored as <...
<p>If you want to put the data into a variable of type object then (simplified):</p> <pre><code>object result = null; result = reader["columnNameGoesHere"]; </code></pre> <p>Should do the trick.</p> <p>There's also a good explanation of the various different methods of retrieving the contents of a given columns curr...
<p>Sql_Variant is of type object.</p> <p><a href="https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings" rel="nofollow noreferrer">Microsoft Docs</a></p>
22,119
<p>I have a very strange problem. Under some elusive circumstances I fail to apply any jQuery selector on my pages under IE. It's OK under Firefox though. The jQuery function simply returns empty array. </p> <p>Any suggestions?</p> <p>Page is too complex to post it here. Practically any selector, except <code>"#id"</...
<p>Try upgrading to jQuery 1.2.6, you should be on the latest release of jQuery if you are having problems first ensure you are on the latest and greatest.</p>
<p>What version(s) of IE is it failing under? Is it failing for a specific complex selector? I think we need an example.</p> <p>Edit: Does the problem go away if you upgrade to 1.2.6? 1.2.6 is primarily a bug-fix release according to <a href="http://docs.jquery.com/Release:jQuery_1.2.6" rel="nofollow noreferrer">this ...
6,137
<p>How do I prevent Visual Studio 2008 from automatically creating the "Mixed Platforms" and "Any CPU" solution configurations? We have "Win32" and "x64" configurations and a developer needs to choose between them. However, as soon as anyone makes any changes to the solution VS automatically creates "Mixed Platforms" a...
<p>We see a similar issue with Visual Studio 2005 projects that we want to build both for a Win32 configuration and for a number of distinct smart device platform/configuration combinations.</p> <p>At arbitrary times, every configuration gets auto-generated for every platform, whether it's valid or not, exploding the ...
<p>You could filter your .sln files in a commit hook of your source control. So that if you check it in the .sln file and possibly the project files get fixed. The open source Chromium project has such a filter implemented.</p>
25,435
<p>I've inherited a piece of code with a snippet which empties the database as follows:</p> <pre><code>dbmopen (%db,"file.db",0666); foreach $key (keys %db) { delete $db{$key}; } dbmclose (%db); </code></pre> <p>This is usually okay but sometimes the database grows very large before this cleanup code is called and ...
<p>You can just delete the file:</p> <pre><code>unlink $file; </code></pre> <p>Since your third argument to <a href="http://perldoc.perl.org/functions/dbmopen.html" rel="nofollow noreferrer">dbmopen</a> is a file mode and not <code>undef</code>, <code>dbmopen</code> will recreate the file the next time it's called:</...
<p>Actually, a workmate has pointed me to a solution. You can apparently do:</p> <pre><code>dbmopen (%db,"file.db",0666); %db = (); dbmclose (%db); </code></pre> <p>which clears out the hash before closing the database.</p>
23,903
<p>I'm looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant classes inherit dependency properties which have become vestigial and can be a little confusing when using <em>IntelliSense</em> or using the classes...
<p>Override them like Michael Suggests <a href="https://stackoverflow.com/questions/1528/#1533">above</a> and to prevent folks from using the overridden (sp?) methods, mark them as obsolete:</p> <pre><code>[Obsolete("These are not supported in this class.", true)] public override void dontcallmeanymore() { } </code><...
<p>You can use an interface</p> <pre><code> public static void Main() { NoRemoveList&lt;string&gt; testList = ListFactory&lt;string&gt;.NewList(); testList.Add(" this is ok "); // not ok //testList.RemoveAt(0); } public interface NoRemoveList&lt;T&gt; { T t...
2,388
<p>We are developing a .NET 2.0 winform application. The application needs to access <a href="http://ws.lokad.com/" rel="nofollow noreferrer">Web Services</a>. Yet, we are encountering issues with users behind proxies.</p> <p>Popular windows backup applications (think <a href="http://mozy.com/" rel="nofollow noreferre...
<p>Put this in your application's config file:</p> <pre><code>&lt;configuration&gt; &lt;system.net&gt; &lt;defaultProxy&gt; &lt;proxy autoDetect="true" /&gt; &lt;/defaultProxy&gt; &lt;/system.net&gt; &lt;/configuration&gt; </code></pre> <p>and your application will use the proxy settings from IE. I...
<p>The easiest way is to use the proxy settings from IE Explorer.</p>
15,483
<p>We've got a multiproject we're trying to run Cobertura test coverage reports on as part of our mvn site build. I can get Cobertura to run on the child projects, but it erroneously reports 0% coverage, even though the reports still highlight the lines of code that were hit by the unit tests. </p> <p>We are using mvn...
<p>From the <a href="http://static.springframework.org/spring/docs/2.5.5/reference/beans.html#beans-definition" rel="noreferrer">Spring Docs (v 2.5.5 Section 3.2.2.1.)</a>:</p> <blockquote> <p>It can often be useful to split up container definitions into multiple XML files. One way to then load an application ...
<p>Another thing to note is that although you can do this, if you aren't a big fan of XML you can do a lot of stuff in Spring 2.5 with annotations. </p>
12,014
<p>What should i use to code Classic ASP under Linux. I have really tried to use Emacs and Vim but I don't have the time to learn them.</p> <p>What i'm looking for is:</p> <ul> <li>Syntax highlighting</li> <li>Code Browser (Ctags)</li> <li>Preferably som sort of code insight</li> </ul> <p>Something like Ultra Edit o...
<p>I'm not sure what you're asking here, but if you are simply looking for a text-editor, my recommendations would be:</p> <p>Console-based:</p> <ul> <li>jed (simple, with a DOS Edit-like menubar, supports syntax-highlighing)</li> <li>nano / pico (even simpler)</li> </ul> <p>X-based:</p> <ul> <li>Kate (KDE, syntax-...
<p>I played with BlueFish for a while when I was contemplating switching over completely and I liked it better than Kate. But, you will have to add the code to enable ASP highlighting. Its floating around numerous places - I found it in short order with a quick trip to the trusty ole Google. ;)</p> <p>But that is just...
4,422
<p>Like it says.</p>
<p>Using semantic markup means that the (X)HTML code you use in a page contains metadata describing its purpose -- for example, an <code>&lt;h2&gt;</code> that contains an employee's name might be marked <code>class="employee-name"</code>. Originally there were some people that hoped search engines would use this infor...
<p>Besides the already mentioned goal of allowing software to 'understand' the data, there are more practical applications in using it to translate between ontologies, or for mapping between dis-similar representations of data - without having to translate or standardize the data (which can result in a loss of informat...
14,440
<p>I have a asp.net web application which has a number of versions deployed on different customer servers inside their networks. One practice that we have is to have clients email screenshots when they have issues.</p> <p>In the old asp.net 1.1 days, we could grab details of the build DLL, using reflection, and show ...
<p>We are using .Net 2.0 and pull the version information out of the assembly. Perhaps not ideal, but we use the description to store the build date.</p> <pre><code>Assembly assembly = Assembly.GetExecutingAssembly(); string version = assembly.GetName().Version.ToString(); string buildDate = ((AssemblyDescriptionAttri...
<p>You can get the Assembly Build date through reflection, check this examples:</p> <ul> <li><a href="http://blog.codinghorror.com/determining-build-date-the-hard-way/" rel="nofollow noreferrer">Determining Build Date the hard way</a></li> <li><a href="http://dotnetfreak.co.uk/blog/archive/2004/07/08/determining-the-b...
41,990
<p>Say I have a site on <a href="http://example.com" rel="noreferrer">http://example.com</a>. I would really like allowing bots to see the home page, but any other page need to blocked as it is pointless to spider. In other words</p> <p><a href="http://example.com" rel="noreferrer">http://example.com</a> &amp; <a href...
<p>So after some research, here is what I found - a solution acceptable by the major search providers: <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=40367" rel="noreferrer">google</a> , <a href="http://help.yahoo.com/l/us/yahoo/search/webcrawler/slurp-02.html" rel="noreferrer">yahoo</a> &amp; ...
<p>Basic robots.txt:</p> <pre><code>Disallow: /subdir/ </code></pre> <p>I don't think that you can create an expression saying 'everything but the root', you have to fill in all sub directories.</p> <p>The query string limitation is also not possible from robots.txt. You have to do it in the background code (the pro...
6,503
<p>Are you aware of any tool that creates diagrams showing the branch/merge activity in a SVN repository?</p> <p>We've all seen these diagrams in various tutorials. Some good, some not so good. Can they be created automatically (or maybe with a little prodding -- you might have to tell it what if your branching philos...
<p>Check this out <a href="http://svnmapper.tigris.org/" rel="noreferrer">SvnMapper from Tigris.org</a></p> <p><img src="https://i.stack.imgur.com/tlCvQ.png" alt="enter image description here"></p>
<p>prior to SVN 1.5 (which has been out all of a month or so), it didn't track merges at all, so the bits where branches 'reconnect' to the trunk are impossible for it to do anyway</p>
3,152
<p>So here's my current code:</p> <pre><code>List&lt;string&gt; rowGroups = GetFileGroups((int)row.Cells["document_security_type"].Value); bool found = false; System.Security.Principal.WindowsPrincipal p = new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent()); foreach ...
<p>Multiple threads would share an instance. For this reason a static class can be convenient for passing state between threads, but you need to be very careful not to introduce race conditions (<code>Monitor</code> or <code>lock</code> your properties).</p> <p>However, multiple <em>processes</em> should be in separa...
<p>The scope of a static class is limited to the application domain. Each app domain will have its own copy of any static variables you might have. If your "processes" are threads within the same app domain, then they will share the static values. But if they are actual separate Windows processes, then they will have d...
36,098
<p>I've seen many website designs with frequent inclusions of 'back to top' links and am just wondering when, if ever, they can really be justified? What use cases demand a 'back top top' link, and what are their effects on usability?</p>
<p>I think they can be useful when there is a table of contents at the top of the page, and the content is not sequential - like a FAQ.</p>
<p>I think it's useful when on first thing on the page is a table of contents, each link of which takes the user to some bottom part of this rather long page. Common example is a FAQ page with all Qs on the same page.</p>
45,157
<p>I'm running <a href="http://en.wikipedia.org/wiki/Mac_OS_X_Leopard" rel="nofollow noreferrer">Mac&nbsp;OS&nbsp;X Leopard</a> and wanted to know what the easy way to setup a web development environment to use Python, MySQL, Apache on my machine which would allow me to develop on my Mac and then easily move it to a ho...
<p>Most Python applications are moving away from mod_python. It can vary by framework or provider, but most development effort is going into mod_wsgi.</p> <p>Using the <a href="https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface" rel="nofollow noreferrer">WSGI</a> standard will make your Python application serv...
<p>What you're looking for is Mod_Python. It's an Apache-based interpreter for Python. Check it out here:</p> <p><a href="http://www.modpython.org/" rel="nofollow noreferrer">http://www.modpython.org/</a></p>
33,365
<p>I am trying to set the margin of an object from JavaScript. I am able to do it in Opera &amp; Firefox, but the code doesn't work in Internet Explorer.</p> <p>Here is the JavaScript I have:</p> <pre class="lang-js prettyprint-override"><code>function SetTopMargin (ObjectID, Value) { document.getElementById(Ob...
<p>[Updated in 2016] On all current browsers (including IE8+), your code</p> <pre><code>document.getElementById(ObjectId).style.marginTop = Value.ToString() + 'px'; </code></pre> <p>works fine.</p> <p>On <em>very old</em> IE (&lt; 8) versions, you must use this non-standard contraption instead:</p> <pre><code>docum...
<p>First of all, you should really use a javascript library like jQuery or Dojo. I also recommend www.debugbar.com for inspecting IE's DOM.</p> <p>About your problem, <code>elem.style = "margin: 10px"</code> should work in IE.</p> <p>Hope this helps!</p>
41,109
<p>I just ran a "PROCEDURE ANALYSE ( )" on one of my tables. And I have this column that is of type INT and it only ever contains values from 0 to 12 (category IDs). And MySQL said that I would be better of with a ENUM('0','1','2',...,'12'). This category's are basically static and won't change in the future, but if th...
<p>Put simply, it's because it's indexed in a different way.</p> <p>In this case, <code>ENUM</code> says "It's one of these 13 values" whereas <code>INT</code> is saying "It could be any integer."</p> <p>This means that indexing is easier, as it doesn't have to take into account indexing for those integers you don't ...
<p>On Oracle I would have a BITMAP index which is much faster than a hash-based lookup for such a small number of values. (So I presume a similar benefit in query optomisation or indexing is available for MySQL.) </p> <p>Interestingly The MySQL docs suggest that using 'things that look like numbers' are a bad choice f...
13,872
<p>I just came onto a project with a pretty huge code base. </p> <p>I'm mostly dealing with C++ and a lot of the code they write uses double negation for their boolean logic. </p> <pre><code> if (!!variable &amp;&amp; (!!api.lookup("some-string"))) { do_some_stuff(); } </cod...
<p>It's a trick to convert to bool.</p>
<p>It's correct but, in C, pointless here -- 'if' and '&amp;&amp;' would treat the expression the same way without the '!!'.</p> <p>The reason to do this in C++, I suppose, is that '&amp;&amp;' could be overloaded. But then, so could '!', so it doesn't <em>really</em> guarantee you get a bool, without looking at the c...
30,908
<p>I have a Mini Kossel and I am going through calibration.</p> <p>I can home carriages and find the bed with paper-test getting some Z value with <code>M114</code>. Then I run the effector almost full height <strong>up and then down</strong> - and now <strong>Z value for the bed is greater</strong>!</p> <p>If I repe...
<p>After some more testing I checked that the problem shows up only on Z tower and is not related with current. Examining the tower I found very dumb mistake. Pulley on the motor didn't have a setscrew! Don't know how could I missed that. The fact that it could somehow run is even more amazing. Thanks @tom-van-der-zand...
<p>According to discussions in comments, I'm pretty sure the problem lies in too low current. </p> <p>Please review <a href="https://3dprinting.stackexchange.com/questions/1480/how-do-you-make-sure-you-have-the-right-voltage-on-the-timpots-on-a-a4988-steppe/1483#1483">this answer</a> to <a href="https://3dprinting.sta...
371
<p>My question is in regards to MySQL, but I also wonder how this affects other databases. I have several fields that are <code>varchar(255)</code> but my coworker insists if they were <code>varchar(30)</code> -- or any smaller size -- then queries would run faster. I'm not so sure, but if it's so I'll admit to it.</...
<p>It depends on the query and the data, but you're probably optimizing too soon to even be worried.</p> <p>For SELECT queries, the statement itself will run just as fast within MySQL, and as long as the data doesn't get larger than it would be at the smaller sized field then it will transmit as fast. If the smaller ...
<p>If you're only ever using the first 30 characters, then there won't be a difference between a varchar(30) and a varchar(255) (although there would be a difference with varchar(1000), which would take an extra byte).</p> <p>Of course, if you end up using more than 30 characters, it will be slower as you have more d...
25,063
<p>This certainly presupposes that unit testing is a good thing. Our projects have some level of unit testing, but it's inconsistent at best.</p> <p>What are the most convincing ways that you have used or have had used with you to convince everyone that formalized unit testing is a good thing and that making it requir...
<p>The event which convinced me was when we managed to regress a bug three times, in three consecutive releases. Once I realised how much more productive I was as a programmer when I wasn't constantly fixing trivial mistakes after they had gone to the client, and I could have a warm fuzzy feeling that colleagues code w...
<p>Remind your team or the other developers that they're professionals, not amateurs. Worked for me!</p> <p>Also, it's an industry standard these days. Without unit testing experience, they are less desirable and less valuable as employees to potential future employers.</p>
14,646
<p>I need to run a JavaScript function onLoad(), but only do it if the page loaded the first time (i.e. is not the result of a postback).</p> <p>Basically, I need to check for IsPostBack in JavaScript.</p> <p>Thank you.</p>
<p>Server-side, write:</p> <pre><code>if(IsPostBack) { // NOTE: the following uses an overload of RegisterClientScriptBlock() // that will surround our string with the needed script tags ClientScript.RegisterClientScriptBlock(GetType(), "IsPostBack", "var isPostBack = true;", true); } </code></pre> <p>Then...
<p>You can create a hidden textbox with a value of 0. Put the onLoad() code in a if block that checks to make sure the hidden text box value is 0. if it is execute the code and set the textbox value to 1.</p>
8,439
<p>I have populated a Datatable, from 2 different servers. I am able to make adjustments where my length>0, what I want to do is remove the rows that does not hit. Here is a summary of what I have</p> <pre><code>DataRow[] dr = payments.dtPayments.Select(myselect); if (dr.Length &gt; 0) { for (int a = 0; a &lt; d...
<p>I'm not sure I completely understand your question but it seems that you try to remove an entry from the collection while you are still looping over it. (which will cause an array index error)</p> <p>You should save a reference to each entry you want to delete in a new collection and then remove all the new entries...
<p>Have you tryed this?</p> <p>payments.dtPayments.Rows.Remove(dr)</p>
40,649
<p>I have a variable of type Hashmap<code>&lt;String,Integer</code>>.</p> <p>In this, the Integer value might have to go some manipulation depending upon the value of a flag variable. I did it like this...</p> <pre><code>Hashmapvariable.put( somestring, if (flag_variable) { //manipulation code goes here ...
<p>You cannot place a statement in the method call.</p> <p>However, one option could be to make an method that returns a <code>Integer</code> such as:</p> <pre><code>private Integer getIntegerDependingOnFlag(boolean flag) { if (flag) return new Integer(MANIPULATED_VALUE); else return new Integ...
<p>This isn't scheme, so if statements don't evaluate to a value. You'll have to use a tri-if-thing (the name escapes me for some reason right now) or create a function, as someone else said.</p>
40,255
<p>I'd like to show an image in an iPhone app, but the image I'm using is too big. I'd like to scale it to fit the iPhone screen, I can't find any class to handle it.</p>
<pre><code>UIImageView* view = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"your_image.png"]]; view.frame = CGRectMake(0, 0, width, height); </code></pre> <p>To get the frame of the iPhone screen you can use</p> <pre><code>CGRect frame = [[UIScreen mainScreen] bounds]; </code></pre>
<p>My ImageView was set in IB, and I would need to show multiple images, so set the image of imageView, instead of creating ImageView for individual image. </p> <p>After I set the image view frame size, I am still see the same result, the image was too big, so that only part of the image was displayed on the screen.</...
30,436
<p>I use XML serialization for the reading of my Config-POCOs. </p> <p>To get intellisense support in Visual Studio for XML files I need a schema file. I can create the schema with xsd.exe mylibrary.dll and this works fine.</p> <p>But I want that the schema is always created if I serialize an object to the file syste...
<p>thank you, this was the right way for me. solution:</p> <pre><code>XmlReflectionImporter importer = new XmlReflectionImporter(); XmlSchemas schemas = new XmlSchemas(); XmlSchemaExporter exporter = new XmlSchemaExporter(schemas); Type type = toSerialize.GetType(); XmlTypeMapping map = importer.ImportTypeMapping(type...
<p>Improvement to Matt Murrell version: to apply XmlAttributes recursively for nested property user type (for example CustomerClass property).</p> <pre><code>private static void AttachXmlAttributes(XmlAttributeOverrides xao, List&lt;Type&gt; all, Type t) { if (all.Contains(t)) { return; } else ...
43,721
<p>I want a checkbox on a web page. When I click it, it sends an ajax request to the server. When the server replies, I want the checkbox to change. I can fix everything except the fact that the checkbox immediately changes state when clicked. </p>
<p>Are you sure you really want this? An Ajax-Request can take its time. When the user gets no feedback, they may be inclined to click again and again, until something happens. When this deactivates the button (again after some time) the user gets even more puzzled.</p> <p>Rather think about providing immediate feedba...
<p>You could start your onchange method with <code>checkbox.checked=NOT checkbox.checked</code> (you may have to modify this for your language of choice), you'll probably get a flicker but it should put it back quickly enough.</p>
23,197
<p>I received the following exception when I was using the Regex class with the regular expression: (?'named a'asdf)</p> <pre><code>System.ArgumentException: parsing \"(?'named a'asdf)\" - Invalid group name: Group names must begin with a word character. </code></pre> <p>What is the problem with my regular expression...
<p>The problem is the space in the name of the capture. Remove the space and it works fine.</p> <p>From the MSDN documentation: "The string used for name must not contain any punctuation and cannot begin with a number. You can use single quotes instead of angle brackets; for example, (?'name')."</p> <p>It does not ma...
<p>The problem is your quotes around the name of the named capture group. Try the string: (?&lt;Named&gt;asdf)</p>
14,965
<p>The auto-collapse feature for <em>code</em> properties is neat AFTER you've got your properties all worked out, but while you're still editing them I find the feature to be REALLY annoying.</p> <p><strong>How can you disable it?</strong></p> <p>(I'm in VS2008 if it makes a difference)</p> <p>Edit: I'm not talking...
<p>From the EDIT menu, choose OUTLINING, STOP OUTLINING. You can also use the keyboard shortcut CTRL+M, CTRL+P.</p>
<p>When the window is open, click on the pin in the upper right hand corner (the middle icon between the X and the down arrow). When you're done, click it again to enable auto hide again.</p>
28,019
<p>I need to do a number of network-related things in C++ that I would normally do with <code>ifconfig</code> in Linux, but I'd like to do it without parsing the output of a group of system calls. Which C or C++ libraries can I use to tell if a network adapter is up or down, read or change an adapter's IP address and ...
<p>Basically you need to make a bunch of ioctl calls using a socket handle (SIOCGIFADDR, SIOCADDRT). You can find sample programs that use it in the Linux kernel source under Documentation/networking. Some other links that might be helpful:</p> <ul> <li><a href="http://www.ibm.com/developerworks/aix/library/au-ioctl-s...
<p>The <a href="http://projects.gnome.org/NetworkManager/" rel="nofollow noreferrer">NetworkManager</a> service exposes an API over <a href="http://www.freedesktop.org/wiki/Software/dbus" rel="nofollow noreferrer">dbus</a> for querying/manipulating the networking on many distributions these days. This may be too high-l...
49,622
<p>Change Data Capture is a new feature in SQL Server 2008. From MSDN:</p> <blockquote> <p>Change data capture provides historical change information for a user table by capturing both the fact that DML changes were made and the actual data that was changed. Changes are captured by using an asynchronous ...
<p>Sure. Oracle actually has a number of technologies for this sort of thing depending on the business requirements.</p> <ul> <li>Oracle has had something called <a href="http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14253/long_intro.htm#ADWSM010" rel="noreferrer">Workspace Manager</a> for a long time (8i ...
<p>I believe Oracle has provided auditing features since 8i, however the tables used to capture the data are rather complex and there is a significant performance impact when this is turned on.</p> <p>In Oracle 8i you could only enable this for an entire database and not a table at a time, however 9i introduced Fine G...
18,788
<p>Inside a visual studio project I have the following folders (for example)</p> <ul> <li>foo/ </li> <li>bar/</li> <li>LongFolderName/</li> </ul> <p>When I open up a file in LongFolderName/ the tab gets labeled with <code>LongFolderName/L...me.ascx</code> when I'd prefer <code>LongFileName.ascx</code> (omitting the n...
<p><a href="http://www.tabsstudio.com" rel="nofollow noreferrer">Tabs Studio add-in</a> for Visual Studio that replaces built-in Visual Studio tabs doesn't shorten tab names and has option to remove path from tab name.</p>
<p>If you click on the <strong>Window | Windows...</strong> menuitem, what do the Name and Path fields look like for your open documents?</p> <p>On my install, the Name fields are just the filenames, exactly what appears in the tabs.</p> <p>Do the full paths appear in the window titles if you set the Window layout to...
27,968
<p>I'm writing a tool to report information about .NET applications deployed across environments and regions within my client's systems.</p> <p>I'd like to read the values of assembly attributes in these assemblies.</p> <p>This can be achieved using <code>Assembly.ReflectionOnlyLoad</code>, however even this approach...
<p>From the <a href="http://msdn.microsoft.com/en-us/library/0et80c7k.aspx" rel="noreferrer">MSDN documentation of System.Reflection.Assembly.ReflectionOnlyLoad (String)</a> :</p> <blockquote> <p>The reflection-only context is no different from other contexts. Assemblies that are loaded into the context can be...
<p>You can try to use <a href="http://msdn.microsoft.com/en-us/library/ms404434.aspx" rel="nofollow noreferrer">Unmanaged Metadata API</a>, which is COM and can easily be used from .NET application with some kind of wrapper. </p>
27,850
<p>I found a bug in Delphi 2009's implementation of TFields and wrote a quick patch. I copied DB.pas to my projects folder and added it to the project's file list, but now I can't get it to compile. The first two error messages don't even make any sense when I go to the indicated places in the code.</p> <p>Surely if...
<p>Does it help if you add the following line at the top of the DB.pas unit.</p> <p>{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N-,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}</p> <p>If it works after using this line, then your project options are not compatible with the settings that CodeGear used to compile the RTL/VCL.</p> ...
<p>I ran into the same problem with DB.pas but did never modify any VCL units. So the cause clearly had to be my project. Switching <strong>Emit runtime type information</strong> to <strong>false</strong> did the trick and solved the problem.</p> <p>(Project Options: Delphi Compiler -> Compiling -> Code generation -> ...
45,268
<p>Say I have the following web.config:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;system.web&gt; &lt;authentication mode="Windows"&gt;&lt;/authentication&gt; &lt;/system.web&gt; &lt;/configuration&gt; </code></pre> <p>Using ASP.NET C#, how can I detect the M...
<p>The mode property from the authenticationsection: <a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.authenticationsection.mode(VS.80).aspx" rel="noreferrer">AuthenticationSection.Mode Property (System.Web.Configuration)</a>. And you can even modify it.</p> <pre><code>// Get the current Mode ...
<p>use an xpath query //configuration/system.web/authentication[mode] ?</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { XmlDocument config = new XmlDocument(); config.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); XmlNode node = config.SelectSingleNode("//configuration/syst...
11,729
<p>How do I make all occurrences of a phrase (search term) in a file to be highlighted in the VS code editor?</p>
<p>When you run a "find" you can click "bookmark all" which will identify on the left which lines the search terms occur on, but you can't "highlight" the elements using visual studio, out of the box.</p>
<p>I copied and pasted the source code into Word 2007. This has highlight all option called 'Reading Highlight'. This keeps the highlighting on even when you search for another term.</p>
32,056
<p>We all know what virtual functions are in C++, but how are they implemented at a deep level?</p> <p>Can the vtable be modified or even directly accessed at runtime?</p> <p>Does the vtable exist for all classes, or only those that have at least one virtual function? </p> <p>Do abstract classes simply have a NULL f...
<h2>How are virtual functions implemented at a deep level?</h2> <p>From <a href="http://wayback.archive.org/web/20100209040010/http://www.codersource.net/published/view/325/virtual_functions_in.aspx" rel="noreferrer">"Virtual Functions in C++"</a>:</p> <blockquote> <p>Whenever a program has a virtual function decla...
<p>Burly's answers are correct here except for the question:</p> <p><em>Do abstract classes simply have a NULL for the function pointer of at least one entry?</em></p> <p>The answer is that no virtual table is created at all for abstract classes. There is no need since no objects of these classes can be created!</p> ...
12,451
<p>Is there a way to prompt the user for input during a NAnt build? I want to execute a command that takes a password, but I don't want to put the password into the build script.</p>
<p>I'm using a script for now, but I'd love to hear if there's a prebuilt method already available. Many thanks to sundar for the ForegroundColor trick.</p> <p>I'm not sure if it matters whether you use Project.Log or go direct to Console.WriteLine(), any NAnt ninjas want to educate me?</p> <p>Here's the script and a...
<p>Try this :</p> <pre><code>&lt;script language="C#" prefix="test" &gt; &lt;code&gt; &lt;![CDATA[ [Function("get-password")] public static string GetPassword( ) { Console.WriteLine("Please enter the password"); ConsoleColor oldFore...
38,011
<p>I have a Nant build file which executes NUnit after compiling the dll's. I am executing the NAnt build file with a task in CruiseControl. So NAnt is running the tests not CruiseControl.</p> <p>How do I configure it so that the CruiseControl web dashboard can be used to view the NUnit output ?</p> <hr> <p>This fi...
<p>You want to use the merge capabilities of CruiseControl to grab your NUnit XML output. This is the situation my company has going, and it seems to work fairly well. Here is a config snippet (This goes in the &lt;publishers&gt; element in CCNet.config):</p> <pre><code> &lt;merge&gt; &lt;files&gt; &lt;...
<p>Make sure that in the the dashboard.config file you have a valid xsl file in the section we run nunit with ncover and use this xsl\NCoverExplorer.xsl I think that the xsl file we took from the ncover install somewhere.</p> <p>also make sure that this line is correct: </p> <p>Then make sure in the ccnet.config f...
19,593
<p>How do I do <code>mv original.filename new.original.filename</code> without retyping the original filename?</p> <p>I would imagine being able to do something like <code>mv -p=new. original.filename</code> or perhaps <code>mv original.filename new.~</code> or whatever - but I can't see anything like this after looki...
<p>You could use the <code>rename(1)</code> command:</p> <pre><code>rename 's/(.*)$/new.$1/' original.filename </code></pre> <p><strong>Edit:</strong> If <code>rename</code> isn't available and you have to rename more than one file, shell scripting can really be short and simple for this. For example, to rename all <co...
<p>In my case I have a group of files which needs to be renamed before I can work with them. Each file has its own role in group and has its own pattern. <br></p> <p>As result I have a list of rename commands like this:</p> <pre><code>f=`ls *canctn[0-9]*` ; mv $f CNLC.$f f=`ls *acu...
25,536
<p>I have a SQL Server database and I want to know what columns and types it has. I'd prefer to do this through a query rather than using a GUI like Enterprise Manager. Is there a way to do this?</p>
<p>You can use the <a href="http://msdn.microsoft.com/en-us/library/ms176077.aspx" rel="noreferrer">sp_columns</a> stored procedure:</p> <pre><code>exec sp_columns MyTable </code></pre>
<pre><code>CREATE PROCEDURE [dbo].[describe] ( @SearchStr nvarchar(max) ) AS BEGIN SELECT CONCAT([COLUMN_NAME],' ',[DATA_TYPE],' ',[CHARACTER_MAXIMUM_LENGTH],' ', (SELECT CASE [IS_NULLABLE] WHEN 'NO' THEN 'NOT NULL' ELSE 'NULL' END), (SELECT CASE WHEN [COLUMN_DEFAULT] IS NULL THEN '' ELSE CONCAT(' ...
41,289
<p>I have a custom control that I need to use in another custom control. I have written all code at server side (no HTML). Can anyone tell me how to write below line of code in code behind using <code>htmlTextWriter</code> and how to register this control or how to write custom control within another where html is writ...
<p>First, build a simple custom web control:</p> <pre><code>namespace My.Controls { public class InnerControl : Control { protected override void Render(HtmlTextWriter writer) { writer.WriteLine("&lt;h1&gt;Inner Control&lt;/h1&gt;"); } } } </code></pre> <p>Then build yo...
<p>Thankx it works.. i was missing only one line--</p> <p>innerControl.RenderControl(writer);</p>
38,144
<p>While I've seen rare cases where <em>private</em> inheritance was needed, I've never encountered a case where <em>protected</em> inheritance is needed. Does someone have an example?</p>
<p>People here seem to mistake Protected class inheritance and Protected methods.</p> <p>FWIW, I've never seen anyone use protected class inheritance, and if I remember correctly I think Stroustrup even considered the "protected" level to be a mistake in c++. There's precious little you cannot do if you remove that pr...
<p><a href="http://www.parashift.com/c++-faq-lite/" rel="nofollow noreferrer">C++ FAQ Lite</a> mentions of a case where using private inheritance is a legitimate solution (See <a href="http://www.parashift.com/c++-faq-lite/private-inheritance.html#faq-24.3" rel="nofollow noreferrer">[24.3.] Which should I prefer: compo...
5,178
<p>The "ATL simple object" wizard doesn't provide a way to specify that a new class is derived from an existing coclass and its interface. In Visual Studio 2008, how do I make a new ATL COM class derived from an existing one (i.e. <code>Base</code> implements <code>IBase</code>, and I want to make a new <code>Derived</...
<p>Just a suggestion - if your COM object does not need to do anything special with COM related stuff then you can implement code such that the real logic that your base COM class does is encapsulated in another plain old C++ class say CBaseLogic. </p> <pre><code>CBaseLogic : IBase class ATL_NO_VTABLE CBase : pub...
<p>Edit the code that the wizards generate. If you want an object to derive from additional interfaces, add these base classes to the resulting class declaration.</p>
37,889
<p>I've had an app doing prefix searches for a while. Recently the index size was increased and it turned out that some prefixes were too darned numerous for lucene to handle. It kept throwing me a <a href="http://web.archive.org/web/20080901205009/http://lucene.apache.org:80/java/2_3_2/api/core/org/apache/lucene/sear...
<p>I've hit this before. It has to do with the fact that lucene, under the covers, turns many (all?) things into boolean queries when you call Query.rewrite()</p> <p>From: <a href="http://web.archive.org/web/20110915061619/http://lucene.apache.org:80/java/2_2_0/api/org/apache/lucene/search/Query.html" rel="nofollow no...
<p>When running a prefix query, Lucene searches for all terms in its "dictionary" that match the query. If more than 1024 (by default) match, the TooManyClauses-Exception is thrown.</p> <p>You can call BooleanQuery.setMaxClauseCount to increase the maximum number of clauses permitted per BooleanQuery.</p>
2,997
<p>I'm trying to write some PHP to upload a file to a folder on my webserver. Here's what I have:</p> <pre><code>&lt;?php if ( !empty($_FILES['file']['tmp_name']) ) { move_uploaded_file($_FILES['file']['tmp_name'], './' . $_FILES['file']['name']); header('Location: http://www.mywebsite.com/dump/');...
<p>As it's Windows, there is no real 777. If you're using <a href="http://fr2.php.net/manual/en/function.chmod.php" rel="noreferrer">chmod</a>, check the Windows-related comments.</p> <p>Check that the IIS Account can access (read, write, modify) these two folders:</p> <pre><code>E:\inetpub\vhosts\mywebsite.com\httpd...
<p>Create a folder named "image" with folder permission <code>777</code></p> <pre><code>&lt;?php move_uploaded_file($_FILES['file']['tmp_name'],"image/".$_FILES['file']['name']); ?&gt; </code></pre>
2,569
<p>What can be a practical solution to center vertically and horizontally content in HTML that works in Firefox, IE6 and IE7?</p> <p>Some details:</p> <ul> <li><p>I am looking for solution for the entire page.</p></li> <li><p>You need to specify only width of the element to be centered. Height of the element is not k...
<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;Centering&lt;/title&gt; &lt;style type="text/css" media="screen"&gt; body, html {height: 100%; padding: 0px; marg...
<p>Is this what you are trying to accomplish? If not, please explain what is different than the image below?</p> <p><img src="https://content.screencast.com/users/jessegavin/folders/Jing/media/a7adbb3d-dfc9-4f57-9cca-c47e9d399dd0/2008-09-11_1259.png" alt="alt text"></p>
7,187
<p>In my .NET/Forms app I have a DataGridView which is bound to a DataTable. The user selects a row of the DataGridView by double-clicking and does some interaction with the app. After that the content of the row is updated programmatically.</p> <p>When the user selects a new row the changes on the previous one are au...
<p>I just had the same issue, and found the answer <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.iscurrentrowdirty.aspx" rel="nofollow noreferrer">here</a>:</p> <blockquote> <p>When the user navigates away from the row, the control commits all row changes. The user can also p...
<p>I guess it depends on what triggers the update to take place, if it is in a validation routine you could simply call that after the user clicks OK on editing the data. Your question is vague it would be easier to answer with more information. What is this interaction? Is it a dialog? What actually updates the da...
9,840
<p>I did a lot of PHP programming in the last years and one thing that keeps annoying me is the weak support for Unicode and multibyte strings (to be sure, natively there is none). For example, &quot;htmlentities&quot; seems to be a much used function in the PHP world and I found it to be absolutely annoying when you'v...
<p>Named entities in "real" XHTML (i.e. with <code>application/xhtml+xml</code>, rather than the more frequently-used <code>text/html</code> compatibility mode) are discouraged. Aside from the five defined in XML itself (<code>&amp;lt;</code>, <code>&amp;gt;</code>, <code>&amp;amp;</code>, <code>&amp;quot;</code>, <cod...
<p>Safari seems to have issues with some glyphs but not others, it may not be <strong>needed</strong> but it's probably best to do so, of course, this is my opinion and not backed up by anything but my own observations.</p>
4,474
<p>I'd like to be able to read the mac address from the first active network adapter using VB.net or C# (using .NET 3.5 SP1) for a winform application</p>
<p>Since .Net 2.0 there's been a NetworkInterface class in the System.Net.NetworkInformation namespace that will give you this information. Try this:</p> <pre><code> foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { if (nic.OperationalStatus == OperationalStatus....
<p>You need to DllImport GetAdaptersInfo -- here's some C# code</p> <p><a href="http://www.codeguru.com/cpp/i-n/network/networkinformation/comments.php/c5451/?thread=60212" rel="nofollow noreferrer">http://www.codeguru.com/cpp/i-n/network/networkinformation/comments.php/c5451/?thread=60212</a></p>
26,857
<p>I have a view using a master page that contains some javascript that needs to be executed using the OnLoad of the Body. What is the best way to set the OnLoad on my MasterPage only for certain views?</p> <p>On idea I tried was to pass the name of the javascript function as ViewData. But I dont really want my Contro...
<p>I have been using the following pattern with my current MVC project and it seems to be working pretty good for my .js work thus far...</p> <p>Within my Master Page I load up my standard script files that I want to be used in all of my content pages (things like jquery.js, global.js, jquery-plugins, .css files, etc....
<p>You should definitely be using jQuery or another JavaScript framework anyway.</p> <p>Have your controllers pass some kind of status indicator to your views, but not views-specific things like the names of JavaScript functions. It is up to your views to map status indicators to JavaScript function names.</p>
25,382
<p>I recently came across the data structure known as a <a href="http://en.wikipedia.org/wiki/Skip_list" rel="noreferrer"><em>skip list</em></a>. It seems to have very similar behavior to a binary search tree. </p> <p>Why would you ever want to use a skip list over a binary search tree? </p>
<p>Skip lists are more amenable to concurrent access/modification. Herb Sutter wrote an <a href="http://www.ddj.com/hpc-high-performance-computing/208801371" rel="noreferrer">article</a> about data structure in concurrent environments. It has more indepth information.</p> <h2>The most frequently used implementation o...
<p>Skip Lists do have the advantage of lock stripping. But, the runt time depends on how the level of a new node is decided. Usually this is done using Random(). On a dictionary of 56000 words, skip list took more time than a splay tree and the tree took more time than a hash table. The first two could not match hash t...
32,009
<p>This question intends to provide a list of solutions to common pitfalls, "gotcha's", or design issues when developing WPF applications. This can also include proper design-patterns as long as there is an explanation as to why it works best. Responses should be voted up or down based on how common the type of issue i...
<p><strong>Problem</strong> : The major issue I have seen so far is that people start coding in WPF with the winform UI model in mind.</p> <p><strong>Solution</strong>: <strong>WPF is not WinForms/MFC/Win32</strong> So Forget all the UI side assumptions and norms you have used and learned while developing Windows base...
<p>Ivan Towlson did a really good presentation on this topic. Most of the information is in his slides, which you can get from here: <a href="http://hestia.typepad.com/flatlander/2008/08/codecamp-2008-.html" rel="nofollow noreferrer">http://hestia.typepad.com/flatlander/2008/08/codecamp-2008-.html</a></p>
41,756
<p>I'm using TinyMCE in an ASP.Net project, and I need a spell check. The only TinyMCE plugins I've found use PHP on the server side, and I guess I could just break down and install PHP on my server and do that, but quite frankly, what a pain. I don't want to do that.</p> <p>As it turns out, Firefox's built-in spell c...
<p>TinyMCE only goes out of its way to disable spell-checking when you don't specify the <code>gecko_spellcheck</code> option (i verified this with their example code). Might want to double-check your <code>tinyMCE.init()</code> call - it should look something like this:</p> <pre><code>tinyMCE.init({ mode : "texta...
<p>I know at least <a href="http://developer.yahoo.com/yui/editor/" rel="nofollow noreferrer">yahoo!'s Rich Text Editor</a> will let you use the included spell checker in FireFox.</p> <p>I also tested FCKeditor, but that requires the users to install additional plugins on their computer.</p>
4,353
<p>Is there any centralized repository of useful Objective-C / Cocoa libraries as there is for Perl, Ruby, Python, etc.?</p> <p>In building my first iPhone app, I'm finding myself implementing some very basic functions that would be just a quick "gem install" away in Ruby.</p>
<p>Unfortunately not :( There are some very useful sites however. I find one of the best is <a href="http://www.cocoadev.com/" rel="nofollow noreferrer">cocoadev.com</a> as it contains lots of useful information about many of the more obscure classes usually including snippets of code to do some really cool things :) ...
<p>I might be confused or missing something here... But doesn't apple provide all the Foundation / Cocoa / AppKit / CoreAudio / Qtkit / etc libraries that should provide all of the very basic functions you are looking for?</p> <p>Other than what xcode comes with or is on the apple dev site, there are no centralized re...
11,439
<p>I'm looking for a library that can deal with RDF and OWL data.</p> <p>So far I have found:</p> <ul> <li><a href="http://razor.occams.info/code/semweb/" rel="nofollow noreferrer">semweb</a> (no owl support for all I know)</li> <li><a href="http://rowlex.nc3a.nato.int/HowToUse.aspx" rel="nofollow noreferrer">rowlex<...
<p><a href="http://rowlex.nc3a.nato.int" rel="noreferrer">ROWLEX</a> is actually very cool (uses <a href="http://razor.occams.info/code/semweb/" rel="noreferrer">SemWeb</a> internally). It is not just a browser app but rather an SDK written in C#. If you use ROWLEX, you do not directly interact with the tripples of RDF...
<p>I researched this just a bit several months ago. One of the more interesting projects I could find is: <a href="http://www.hookedonlinq.com/linqtordf.ashx" rel="nofollow noreferrer">http://www.hookedonlinq.com/linqtordf.ashx</a></p>
29,813
<p>What would be the best way of inserting functionality into a binary application (3d party, closed source).</p> <p>The target application is on OSX and seems to have been compiled using gcc 3+. I can see the listing of functions implemented in the binary and have debugged and isolated one particular function which I...
<p>For those interested in what I've ended up doing, here's a summary:</p> <p>I've looked at several possibilities. They fall into runtime patching, and static binary file patching.</p> <p>As far as file patching is concerned, I essentially tried two approaches:</p> <ol> <li><p>modifying the assembly in the code seg...
<p>Interesting problem. If I understand you correctly, you'd like to add the ability to remotely call functions in a running executable. </p> <p>If you don't really need the whole application, you might be able to strip out the main function and turn it into a library file that you can link against. It'll be up to ...
32,859
<p>I've read and followed <a href="http://developer.yahoo.com/yui/menu/" rel="nofollow noreferrer">YUI's tutorial</a> for subscribing to Menu events. I also looked through the API and bits of the code for Menu, MenuBar, and Custom Events, but the following <em>refuses</em> to work</p> <pre><code>// oMenuBar is a Menu...
<p>Todd Kloots here, author of the YUI Menu widget. When you are subscribing to DOM-based events, the event name is all lower case. So, for the "mouseover" event, subscribe as follows:</p> <p>buyMenu.subscribe('mouseover', onMouseOver, {foo: 'bar'}, false);</p> <p>Regarding your keypress event handler: you are subs...
<p>Based on my testing, the following will work:</p> <pre><code>oMenu.subscribe('keypress', function () { alert("I'm your friendly neighborhood keypress listener.")}); </code></pre> <p>but that only fires when the <code>Menu</code> is receiving the <code>keypress</code> event, so it would need to already have focus.<...
19,220
<p>In an application I'm working on, we have a bunch of custom controls with their ControlTemplates defined in Generic.xaml.</p> <p>For instance, our custom textbox would look similar to this:</p> <pre><code>&lt;Style TargetType="{x:Type controls:FieldTextBox}"&gt; &lt;Setter Property="Template"&gt; &lt;S...
<p>Within your control template you can add a Trigger that sets the FocusedElement of the StackPanel's <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.focusmanager.focusedelement.aspx" rel="nofollow noreferrer">FocusManager</a> to the textbox you want focused. You set the Trigger's property to {T...
<p>You can get rid of the hard coding of control name in the code by providing some DependancyProperty and have the same code in controlLoaded or OnApplyTemplate function based on the DependancyProperty. This DependancyProperty's sender will the candidate for .Focus() call.</p>
19,176
<p>Do any editors honer C #line directives with regards to goto line features?</p> <p><em>Context:</em> I'm working on a code generator and need to jump to a line of the output but the line is specified relative to the the #line directives I'm adding. I can drop them but then finding the input line is even a worse pai...
<p>If the editor is scriptable it should be possible to write a script to do the navigation. There might even be a Vim or Emacs script that already does something similar.</p> <p>FWIW when I writing a lot of Bison/Flexx I wrote a <a href="http://www.zeusedit.com" rel="nofollow noreferrer">Zeus</a> Lua macro script tha...
<p><code>#line</code> directives are normally inserted by the precompiler, not into source code, so editors won't usually honor that if the file extension is <code>.c</code>.</p> <p>However, the normal file extension for post-compiled files is <code>.i</code> or <code>.gch</code>, so you might try using that and see w...
7,362
<p>The object I’m working on is instantiated in JavaScript, but used in VBScript. In one code path, the variable <code>M.DOM.IPt</code> is defined and has a value, in the other however it is not. I need to detect if it has been defined or not. I checked that <code>M.DOM</code> is defined and accessable in both code pat...
<pre> Function SupportsMember(object, memberName) On Error Resume Next Dim x Eval("x = object."+memberName) If Err = 438 Then SupportsMember = False Else SupportsMember = True End If On Error Goto 0 'clears error End Function </pre>
<p>Have you tried On Error Goto label?</p>
31,242
<p>I get the following error message in SQL Server 2005:</p> <pre><code>User '&lt;username&gt;' does not have permission to run DBCC DBREINDEX for object '&lt;table&gt;'. </code></pre> <p>Which minimum role do I have to give to user in order to run the command?</p>
<p>You will need to be a member of the <strong>db_ddladmin</strong> or the <strong>db_owner</strong> role AFAIK</p>
<blockquote> <p>Caller must own the table, or be a member of the sysadmin fixed server role, the db_owner fixed database role, or the db_ddladmin fixed database role.</p> </blockquote> <p><a href="http://msdn.microsoft.com/en-us/library/ms181671(SQL.90).aspx" rel="nofollow noreferrer">DBCC DBREINDEX (Transact-SQL) @...
8,077
<p>By &quot;better&quot; I mean &quot;more precise&quot;...</p> <p>With respect to a RepRap P3Steel or Wilson II, I am getting some 330 mm T8 leadscrews for the Z-axis movement.</p> <p>There seems to be a choice between a <em>lead</em> of 1, 2 or 8 mm - the <em>pitch</em> is 1 mm in the first case and 2 mm in the last ...
<p>Based on what I've learned over 8 months of printing:</p> <p>What matters the most is getting a very accurate zero relative to the bed surface. An offset of 30 or 40 microns can strongly affect first-layer adhesion. Now, unless you put in some of the advanced auto-levelling sensors, the repeatability of the Z-axi...
<p><strong>Longer lead</strong></p> <p>Pros:</p> <ol> <li>Faster movement (mostly benefits homing)</li> <li>More standard</li> <li>Weak motor friendly</li> <li>Might be slightly more stable (sideways) than shorter leads because of more starts creating more contact with nut (?)</li> </ol> <p>Cons</p> <ol> <li>Backla...
594
<p>Nant seems very compiler-centric - which is guess is because it's considered a .NET development system. But I know it can be done! I've seen it. The platform we're building on has its own compiler and doesn't use 'cl.exe' for c++. We're building a C++ app on a different platform and would like to override with our ...
<p>Here is one I did for Delphi. Each 'arg' is a separate param with a value defined elsewhere. The target is called with the params set up before calling it.</p> <pre><code>&lt;target name="build.application"&gt; &lt;exec program="dcc32" basedir="${Delphi.Bin}" workingdir="${Application.Folder}" verbose="true"&gt...
<p>You could also use the <code>&lt;exec&gt;</code> task.</p>
11,344
<p>Before I begin, I want to clarify that this is not a command-line tool, but an application that accepts commands through it's own command-line interface.</p> <p><strong>Edit:</strong> I must apologize about my explanation from before, apparently I didn't do a very good job at explaining it. One more time...</p> <p...
<p>On *nix, you can use the <code>signal</code> function to register a signal handler:</p> <pre><code> #include &lt;signal.h&gt; void signal_handler(int sig) { // Handle the signal } int main(void) { // Register the signal handler for the SIGINT signal (Ctrl+C) signal(SIGINT, signal_handler); ... } </code></p...
<p>A better *nix solution that is thread safe is to use <a href="http://linux.die.net/man/3/pthread_sigmask" rel="nofollow">pthread_sigmask()</a> instead of signal().<br> For example, this is how you signore SIGINT, SIGTERM, and SIGPIPE in the current thread and future spawned threads:</p> <pre><code>sigset_t waitset;...
21,897
<p>Should the model just be data structures? Where do the services (data access, business logic) sit in MVC?</p> <p>Lets assume I have a view that shows a list of customer orders. I have a controller class that handles the clicks on the view controls (buttons, etc).</p> <p>Should the controller kick off the data ac...
<p>Generally I implement MVC as follows:</p> <p>View - Receives data from the controller and generates output. Generally only display logic should appear here. For example, if you wanted to take an existing site and produce a mobile/iPhone version of it, you should be able to do that just by replacing the views (ass...
<p>The View would relay what should happen on a click in the UI to the Control layer, which would contain ALL business logic, and would in turn call the Model layer which would only make database calls. Only the model layer should be making database calls, or you will defeat the purpose of the MVC design pattern. </p> ...
42,735
<p>Here's my situation: I'm trying to understand how msbuild works by looking at the build files located in the .NET framework install path:</p> <pre><code>C:\Windows\Microsoft.NET\Framework\v3.5&gt;dir /s/b microsoft* Microsoft.Build.Tasks.v3.5.xml Microsoft.Build.xsd Microsoft.Common.targets Microsoft.Common.Tasks ...
<p>It "starts" with your .vbproj file. Take a look at that file, it will &lt;Import> the Microsoft.VisualBasic.targets, which in turn will &lt;Import> Microsoft.Common.targets.</p>
<p>In 4.0, which is currently available in Beta, there is a /preprocess switch which will make this all clear.</p>
37,295
<p>I have been hearing a lot of good things about DVCS systems, in particular about bazaar. Apart from the concept of distributed repository, I see two main advantages being touted: the merge is better automated, and the rename is handled right.</p> <p>Could someone please point me at some text explaining how exactly ...
<p>Merge is not intrinsically better in DVCS, it is just that they would be practically very difficult to use if the branch/merge did not work correctly (svn arguably does not implement branching/merging correctly), because instead of making a checkout, you are making a new branch everytime you start working on a proje...
<p>I'm not familiar with bazaar, but git doesn't track file renames. To git, this looks like a delete and an add. However, git is smart enough to see that the contents of the file already exist in its repository and will track their position in the system. If you split files up or merge them it's smart enough to keep t...
6,834
<p>I have an ASP.NET GridView which has columns that look like this:</p> <pre><code>| Foo | Bar | Total1 | Total2 | Total3 | </code></pre> <p>Is it possible to create a header on two rows that looks like this?</p> <pre><code>| | Totals | | Foo | Bar | 1 | 2 | 3 | </code></pre> <p>The data in each r...
<p><a href="https://web.archive.org/web/20100201202857/http://blogs.msdn.com/mattdotson/articles/541795.aspx" rel="nofollow noreferrer">This article</a> should point you in the right direction. You can programmatically create the row and add it to the collection at position 0.</p>
<p>Please refer to <a href="https://stackoverflow.com/a/9333714/1060656">https://stackoverflow.com/a/9333714/1060656</a></p> <p>i created this solution example </p> <p>To run in your local system will will need to create 2 files ( one for the control and one aspx) you can either do it one project or 2 projects.</p> ...
40,623
<p>Given two image buffers (assume it's an array of ints of size width * height, with each element a color value), how can I map an area defined by a quadrilateral from one image buffer into the other (always square) image buffer? I'm led to understand this is called "projective transformation".</p> <p>I'm also lookin...
<p><strong>EDIT</strong></p> <p>The assumption below of the invariance of angle ratios is incorrect. Projective transformations instead preserve cross-ratios and incidence. A solution then is:</p> <ol> <li>Find the point C' at the intersection of the lines defined by the segments AD and CP.</li> <li>Find the point B'...
<p>Here's how would do it in principle:</p> <ul> <li>map the origin of A to the origin of B via a traslation vector <code>t</code>.</li> <li>take unit vectors of A (1,0) and (0,1) and calculate how they would be mapped onto the unit vectors of B.</li> <li>this gives you a transformation matrix <strong>M</strong> so th...
20,506
<p>I've never learnt JavaScript, but I imagine this is quite a simple problem. Just wanted to know which method is most advised these days.</p>
<pre><code>// use this to avoid redirects when a user clicks "back" in their browser window.location.replace('http://somewhereelse.com'); // use this to redirect, a back button call will trigger the redirection again window.location.href = "http://somewhereelse.com"; // given for completeness, essentially an alias to...
<p>One important thing to remember when redirecting a page using JavaScript is, always provide a non-JavaScript redirect as well! A link would do, or better a <code>&lt;META&gt;</code> tag, for example: <code>&lt;meta http-equiv="refresh" content="2;url=http://example.com"&gt;</code></p>
24,434
<p>My development shop has put together a fairly useful Python-based test suite, and we'd like to test some Linux-based C++ code with it. We've gotten the test project they ship with Boost to compile (type 'bjam' in the directory and it works), but we're having issues with our actual project.</p> <p>Building the boost...
<p>"Google Maps Hacks" has a hack, <a href="http://safari.oreilly.com/0596101619/googlemapshks-CHP-4-SECT-3" rel="nofollow noreferrer">"Hack 30. Stay Out of Traffic Jams"</a>, on that.</p> <p>You can also find out how to get U.S. traffic info from John Resig's <a href="http://ejohn.org/blog/traffic-conditions-data/" r...
<p>Google is mum on what source they use for their traffic data. You might contact them directly to see if they want to implement something for you, but my guess is that they'd simply refer you to their provider if they really wanted your data.</p> <p>Keep in mind that traffic data is available for more than just the...
9,259
<p>I had developed an application in visual Studio 2005. whenever i run that application active directory locks domain my account. I really cant understand what am i doing wrong.</p>
<p>I can't tell you exactly what's causing it, but here are some tips for troubleshooting. Install the <strong><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7af2e69c-91f3-4e63-8629-b999adde0b9e&amp;DisplayLang=en" rel="nofollow noreferrer">Account Lockout and Management Tools</a></strong> from Micr...
<p>Are you using authentication to a database, SSAS cube or other item that uses user/password authentication against an AD account?</p> <p>If this is the case and your application tries three logins with the wrong password, AD may lock out your account (depending on its settings). Analysis Services is quite bad for ...
15,136
<p>Say, I have a script that gets called with this line:</p> <pre><code>./myscript -vfd ./foo/bar/someFile -o /fizz/someOtherFile </code></pre> <p>or this one:</p> <pre><code>./myscript -v -f -d -o /fizz/someOtherFile ./foo/bar/someFile </code></pre> <p>What's the accepted way of parsing this such that in each case (o...
<h4>Bash Space-Separated (e.g., <code>--option argument</code>)</h4> <pre class="lang-sh prettyprint-override"><code>cat &gt;/tmp/demo-space-separated.sh &lt;&lt;'EOF' #!/bin/bash POSITIONAL_ARGS=() while [[ $# -gt 0 ]]; do case $1 in -e|--extension) EXTENSION=&quot;$2&quot; shift # past argument ...
<p>This also might be useful to know: you can set a value and if someone provides input, override the default with that value.</p> <p><code>myscript.sh -f ./serverlist.txt</code> or just <code>./myscript.sh</code> (and it takes defaults)</p> <pre><code> #!/bin/bash # --- set the value, if there is inputs, ove...
23,365
<p>Does anybody have any pointers to what SWD files are in Flash 9, why Flash Player wants to download them sometimes, how to make ones, how to make use of them? Didn't manage to dig anything useful myself yet.</p> <p><em>Update</em></p> <p>I know roughly what are swd files used in Flash8, and <a href="http://livedoc...
<p>SWD files are needed to debug content with Adobe's debugging tools. You can see this in action by publishing from Flash authoring with shift-control-enter. </p> <p>The SWD itself is only needed for the debugging tool to see inside the SWF. You can throw it away once you're done debugging, and you never need to uplo...
<blockquote> <p>SWD files are similar to SWF files, except that they contain debugging-specific information that the debugger and Flash Debug Player watch for.</p> </blockquote> <p>From: About SWD files</p> <p>The citation above is from the Flex documentation but applies to 'normal' Flash too.</p>
15,387
<p>Is there a way to compile multiple java source directories in a single maven project? </p>
<p>You can add a new source directory with build-helper:</p> <pre class="lang-xml prettyprint-override"><code>&lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt; &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt; &lt;v...
<p>This can be done in two steps:</p> <ul> <li>For each source directory you should create own module.</li> <li>In all modules you should specify the same build directory: <code>${build.directory}</code></li> </ul> <p>If you work with started Jetty (<code>jetty:run</code>), then recompilation of any class in any modu...
33,989
<p>Here's the idea, I'd like to make a service? that will look for a certain program starting up and dissallow it unless certain conditions are met. </p> <p>Let's say I have a game I want to stop myself from playing during the week. So if I start it up on any day other than Friday/Saturday/Sunday, it will intercept a...
<p>Well, you can definitely determine which programs are running by looking for the process names you want (GetProcessesByName()) and killing them.</p> <pre><code>Process[] processes = Process.GetProcessesByName(processName); foreach(Process process in processes) { process.Kill(); } </code></pre> <p>You could just...
<p>I'm not sure if you can catch it starting up, but you could try to look for the program in the list of windows (was it ENUM_WINDOWS? I can never remember) and shut it down as soon as it shows up.</p> <p>You could probably even do this in AutoIt!</p> <p>Drag out the Petzold and have some fun with windows...</p> <p...
17,636
<p>I have the following command which will loop over all the subdirectories in a specific location and output the full path:</p> <pre><code>for /d %i in ("E:\Test\*") do echo %i </code></pre> <p>Will give me:</p> <pre><code>E:\Test\One E:\Test\Two </code></pre> <p>But how do I get both the full path, and just the d...
<p>The following command syntax can be used to return the full path or directory name only:</p> <pre><code>%~fI - expands %I to a fully qualified path name %~nI - expands %I to a file name only </code></pre> <p>Using your example, the following command will list directories in the format that you specif...
<p>You can use "%~ni". This is an enhanced substitution that will return the file name of a path (or, more accurately, the last part, which is the directory name in your case):</p> <pre><code>for /d %i in ("E:\Test\*") do echo %i - %~ni </code></pre> <p>See also this question: <a href="https://stackoverflow.com/quest...
39,424
<p>When I enable common control visual style support (InitCommonControls()) and I am using any theme other then Windows Classic Theme, buttons inside a group box appear with a black border with square corners. </p> <p>Windows Classic Theme appears normal, as well as when I turn off visual styling.</p> <p>I am using t...
<p>The problem is having the groupbox as the controls' parent. Groupboxes are not supposed to have any children and using them as parents will cause all kinds of errors (including painting, keyboard navigation and message propagation). Just change the parent in the buttons' CreateWindow call from <strong>group_box</str...
<p>Ahh yes the black background with radio buttons and group boxes. Although I'm not sure if this will work for VC++ 2008, but back-in-the-day the solution for VB6 themed apps was to put the radio controls on a PictureBox (a generic container really) first and then add that to the group box.</p> <p>Its worth a shot!</...
26,371
<p>I am getting a DC for a window handle of an object in another program using win32gui.GetDC which returns an int/long. I need to blit this DC into a memory DC in python. The only thing I can't figure out how to do is get a wxDC derived object from the int/long that win32gui returns. None of the wxDC objects allow ...
<p>I downloaded the wxWidgets source and dug around, and I think this will work.</p> <p>You need the handle (HWND) for the external window, not the DC.</p> <pre><code>window = wx.Frame(None, -1, '') window.AssociateHandle(hwnd) dc = wx.WindowDC(window) </code></pre>
<p>From what I can tell, DCs in python are abstracted due to platform variation. So a device context in python doesn't directly map to a device context in Windows even though many of the methods are direct Windows method calls. To make this happen it appears you would need to make your own DelegateDC class or somethi...
30,297
<p>I'm working my way into MVC at the moment, but on my "To learn at some point" list, I also have WCF.</p> <p>I just wonder if WCF is something that should/could be used in an MVC Application or not? The Background is that I want a Desktop Application (.NET 3.5, WPF) interact with my MVC Web Site, and I wonder what t...
<p>WCF services might make sense in this situation, but don't create services that align with your UI, create services that align with the business processes. ie. you won't have a service that returns the view data for each page, you will have a service that exposes logical operations. Then, your site can call the same...
<p>You could use <a href="http://www.odata.org/" rel="nofollow noreferrer">OData</a> for your MVC application to handle Xml/Json type stuff. I know other people have suggested roll your own - and this is what I'm currently doing .. via the use of my own custom ActionFilter or custom ViewResult.</p> <p>Sample OData cod...
26,685
<p>I'm having some minor problems with some animations I'm trying to set up. I have a couple divs stacked on top of each other kind of like this.</p> <pre><code>&lt;div id="div1"&gt; Stuff... &lt;/div&gt; &lt;div id="div2"&gt; More Stuff... &lt;/div&gt; </code></pre> <p>Each of these divs has a drop shadow app...
<p>I would suggest using <strong>CSS</strong> for your drop shadows, and <strong>not JS</strong>.</p> <p>I have dealt with this exact problem in the past and I have completely stopped using JS for drop shadows. I have never seen animations with JS shadows look as smooth as pure CSS. Also, using too much JS to alter ...
<p>Ok, I still don't know how you animate, but I give you another example:</p> <pre><code>$('#foo').slideToggle().ready(function(){ $('#foo').dropShadow(options); }); </code></pre> <p>So, instead of <code>slideToggle</code>, just use whatever animation <em>thingy</em> you got.</p> <p>Hope that helps.</p>
22,930