instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm coming from Eclipse, working in Visual Studio 2008 Express and just want to highlight code, right-click and comment it out.</p> <ul> <li>nothing in right-click</li> <li>looking in Tools | Options, Toolbars, Commands, can't find a button for it...</li> </ul> <p>How do I activate this the comment/uncomment feature...
<p>Weird it's <kbd>Ctrl</kbd>+<kbd>E</kbd>, <kbd>C</kbd> (Comment) and <kbd>Ctrl</kbd>+<kbd>E</kbd>, <kbd>U</kbd> (Uncomment)</p> <p><a href="http://picasaweb.google.com/lh/photo/jS75c4D1FfUA9kBy92nB5Q?authkey=-b3uGjHkX3g" rel="nofollow noreferrer"><img src="https://lh4.ggpht.com/_nxgDpneh8yk/SSmK9owk_dI/AAAAAAAAAZA/CI...
<p>Mauro is right about the shortcuts, they're in Express as well. You can also get to the Comment/Uncomment block commands in the Edit->Advanced menu. You probably also have a toolbar icon to do this that looks like a couple of lines, with a few indented blue ones.</p>
40,293
<p>Sometimes you don't have the source code and need to reverse engineer a program or a black box. Any fun war stories?</p> <p>Here's one of mine:</p> <p>Some years ago I needed to rewrite a device driver for which I didn't have source code. The device driver ran on an old CP/M microcomputer and drove a dedicated p...
<p>Read the story of FCopy for the C-64 here:</p> <p>Back in the 80s, the Commodore C-64 had an intelligent floppy drive, the 1541, i.e. an external unit that had its own CPU and everything.</p> <p>The C-64 would send commands to the drive which in turn would then execute them on its own, reading files, and such, the...
<p>I've had to reverse engineer a video-processing app, where I only had part of the source code. It took me weeks and weeks to even work out the control-flow, as it kept using CORBA to call itself, or be called from CORBA in some part of the app that I couldn't access. </p> <p>Sheer idiocy.</p>
23,460
<p>There are lots of questions on how to improve communication between teams. One way to start is to identify what one team actually does that the other team really values and do more of that. </p> <p>For example. Our QA team provided a VM for us with:</p> <ul> <li>The latest release of our server-based commercial so...
<p>"It sucks less."</p> <p>That truly made my day.</p>
<p>"It crashed!" - the bug we were hunting for something like several months was reproduced. </p>
15,750
<p>Inside a windows batch file I'd like to figure out what the fully qualified path name of this batch file is.</p> <p>I have tried <code>%0</code> but this does only gave me the typed command (e.g. just the file name without path or extension).</p>
<pre><code>echo %~f0 </code></pre> <p>works for me.</p> <p>see <code>for /?</code> from <code>cmd</code> and read about variable substitution.</p>
<p>Calling script <code>FIRST.BAT</code>:</p> <pre><code>call second.bat %0 parameter-a parameter-b </code></pre> <p>Called script <code>SECOND.BAT</code>:</p> <pre><code>echo The name of this called script should be "SECOND", proof: %~n0 echo The 1st parameter passed should be "FIRST", proof: %1 shift echo The name...
44,672
<p>I have tried to find how to create DLL-s on linux using google, but got very confusing information.</p> <p>Is it possible to write dynamic link libraries on linux? If not, are there other means by which I can call code in another module from several running programs?</p>
<p>That's because DLL is a Windows term. In Linux they are called shared libraries.</p> <p><a href="http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/shared-libraries.html" rel="noreferrer">http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/shared-libraries.html</a></p>
<p>I guess .SO files instead of DLL files, meaning shared object, not StackOverflow :), is what you want.</p>
17,572
<p>Am wondering if anyone might provide some conceptual advice on an efficient way to build a data model to accomplish the simple system described below. Am somewhat new to thinking in a non-relational manner and want to try avoiding any obvious pitfalls. It's my understanding that a basic principal is that "storage ...
<p>Thanks to both of you for your suggestions. I've implemented (first iteration) as follows. Not sure if it's the best approach, but it's working.</p> <p>Class A = Articles. Has a StringListProperty which can be queried on it's list elements</p> <p>Class B = Tags. One entity per tag, also keeps a running count o...
<p>Many-to-many sounds reasonable. Perhaps you should try it first to see if it is actually expensive.</p> <p>Good thing about G.A.E. is that it will tell you when you are using too many cycles. Profiling for free!</p>
39,074
<p>I have received a content export of a MOSS 2007 site which I need to get replicated in my environment but I am having problems importing it using <code>stsadm</code>.</p> <p>The export was done using <code>stsadm</code> though a command similar to:</p> <blockquote> <p>stsadm -o export -url <a href="http://localh...
<p>No, the only option is to remove the roles in the Manifest.xml file of the content export. If you received the export as a single file, just rename it to .CAB and extract the Manifest.xml file for modification. The XML format is pretty extensive and it might take you some studying to figure out where the roles are. ...
<p>No, the only option is to remove the roles in the Manifest.xml file of the content export. If you received the export as a single file, just rename it to .CAB and extract the Manifest.xml file for modification. The XML format is pretty extensive and it might take you some studying to figure out where the roles are. ...
49,365
<p>I'd like to be able to send a Ruby app to some colleagues without requiring them to install a Ruby interpreter. A single exe would be preferable.</p> <p>I googled and found "RubyScript2Exe".</p> <p>What are your experiences with that? Are there other such tools or are there better approaches altogether than buildi...
<p>I've used it about 3 times and I haven't had any problems with it and I ran one of the apps on 10 servers and never had any issues. So, I think RubyScript2Exe is about as good as it gets for ruby.</p>
<p>Sorry to be late to the party, but I found this question in my search for trying to do this myself (starting to use SO more and more as a primary resource).</p> <p>Anyway, I have just had success with <a href="http://exerb.sourceforge.jp/index.en.html" rel="nofollow noreferrer">exerb</a>, although I'd add a couple ...
45,397
<p>I dont know if I should use the httpcontext caching or the Enterprise Library Caching Application Block. Also, what is the best pattern for the caching Strategy when deleting or updating an entity that is part of a cached list?</p> <p>Should I remove all of a list from the cache or only remove the item from the cac...
<p>There are several approaches to implement caching,httpcontext being the easiest one, but it's not necessarily the worst. Take a look at <a href="http://www.danga.com/memcached/" rel="nofollow noreferrer">memcached</a> or <a href="http://blogs.msdn.com/velocity/" rel="nofollow noreferrer">MS Velocity</a>, both of whi...
<p>just use [OutputCache(Duration=10, VaryByParam="none")] on every action or even controller you want to cache.</p> <p>from <a href="http://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/improving-performance-with-output-caching-cs" rel="nofollow">http://www.asp.net/mvc/tutorials/older-versions/cont...
24,274
<p><strong>Has anyone found a way to run Selenium RC / Selenium Grid tests, written in C# in parallel?</strong></p> <p>I've currently got a sizable test suite written using Selenium RC's C# driver. Running the entire test suite takes a little over an hour to complete. I normally don't have to run the entire suite so i...
<p>I am working on this very thing and have found <a href="http://www.gallio.org/" rel="noreferrer">Gallio</a> latest can drive mbUnit tests in parallel. You can drive them against a single <a href="http://selenium-grid.seleniumhq.org/" rel="noreferrer">Selenium Grid</a> hub, which can have several remote control serve...
<p>I don't know if no answer counts as an answer but I'd say you have researched everything and you really came up with the 2 possible solutions... </p> <ul> <li>Test Suite runs tests in parallel</li> <li>Split the test suite up</li> </ul> <p>I am at a loss for any thing else.</p>
11,777
<p>I normally work on single threaded applications and have generally never really bothered with dealing with threads. My understanding of how things work - which certainly, may be wrong - is that as long as we're always dealing with single threaded code (i.e. no forks or anything like that) it will always be executed ...
<p>UI usually has the opposite constraint (sadly): it's single threaded and everything must happen on that thread.</p> <p>The easiest way to check if you are always in the same thread (for, say, a function) is to have an integer variable set at -1, and have a check function like (say you are in C#):</p> <pre><code>vo...
<p>Think about having the model of having a single dataStore class running in your mainThread that all threads can read and write their instance variables to. This will avoid a lot of problems that might arise accessing threads all over the shop.</p> <p>Simple idea, until you reach the fun part of threading. Concurren...
36,428
<p>My huge 32-bit web services LLBLGen-based data access application is running alone on a dedicated 64-bit machine. Its physical memory consumption steadily grows up to approximately 2GB when the process releases almost all of the allocated space (up to 1,5GB) and continues to grow from that point again. There is no o...
<p>It sounds like you have a memory leak, the process keeps leaking memory until it crushes with an out-of-memory condition and is then automatically restarted by the server.</p> <p>1.5GB is about the maximum amount of memory a 32 bit process can allocate before running out of address space.</p> <p>Somethings to look...
<p>The Garbage Collector doesn't automatically free memory when it releases objects, it holds on to that memory to help minimise the expense of future mallocs.</p> <p>When a low memory condition is triggered that memory will be returned to the OS and you will see more available memory when looking through task manager...
35,078
<p>We wish to provide people to be able to add some logic to their accounts(say, given a few arguments, how to compute a particular result). So, essentially, this would be tantamount to writing simple business rules with support for conditionals and expressions. However, the challenge is to provide them a simple online...
<p>As a matter fact, Microsoft is developing <a href="http://www.microsoft.com/soa/products/oslo.aspx" rel="nofollow noreferrer">Oslo</a>, which is right up your alley. <a href="http://www.sellsbrothers.com/" rel="nofollow noreferrer">Chris Sells</a> has been writing a lot about it recently.</p> <p>It is designed to b...
<p>I don't think you'll find anything that isn't too generic, especially regarding the GUI editor. There's no generic tools as far as I know that will be able to automatically interface with your program and be able to query data from it and interpret the script into commands in your software -- if there is I'd like t...
36,935
<p>I'm looking for for a Jabber library for Delphi, I can see some COM based jabber components. But I'm looking for a real VCL library.</p> <p>Somebody knows one?</p>
<p>You could compile the code that underlies Exodus into a VCL. That code is called JOPL, and can be found at <a href="http://code.google.com/p/exodus/source/browse/#svn/trunk/jopl" rel="noreferrer">Google Code</a>.</p>
<p>Bricksoft have VCL component for MSN,YAHOO,AIM,ICQ and Jabber/GTalk.</p> <p>Pls visit our website <a href="http://www.imcomponents.com/" rel="nofollow noreferrer">http://www.imcomponents.com/</a> if you want to get more information.</p>
21,988
<p>Does anyone know a good C++ class to read (and possibly also write) INI files on Windows Mobile? Ideally this class sould work on Windows mobile 2003, 5 and 6 and be public domain but other alternatives may be interesting.</p>
<p>See this question <a href="https://stackoverflow.com/questions/146795/how-to-read-config-file-entries-from-an-ini-file">How to read config file entries from an INI file</a>, and this followup <a href="https://stackoverflow.com/questions/146943/help-improve-this-ini-parsing-code">Help improve this INI parsing code</a...
<p>Try SimpleIni <a href="http://code.jellycan.com/simpleini/" rel="nofollow noreferrer">http://code.jellycan.com/simpleini/</a> as mentioned at CodeProject.</p> <p>It is C++, single header file, template library with an MIT licence (i.e. commercial use is OK). Include it into your source file and use it. It is cross-...
35,417
<p>I have a bunch of records in several tables in a database that have a "process number" field, that's basically a number, but I have to store it as a string both because of some legacy data that has stuff like "89a" as a number and some numbering system that requires that process numbers be represented as number/year...
<p><a href="http://blog.feedmarker.com/2006/02/01/how-to-do-natural-alpha-numeric-sort-in-mysql/" rel="nofollow noreferrer">Maybe this will help.</a></p> <p>Essentially:</p> <pre><code>SELECT process_order FROM your_table ORDER BY process_order + 0 ASC </code></pre>
<p>You need to cast your field as you're selecting. I'm basing this syntax on MySQL - but the idea's the same:</p> <pre><code>select * from table order by cast(field AS UNSIGNED); </code></pre> <p>Of course UNSIGNED could be SIGNED if required.</p>
25,840
<p>How to calculate minute difference between two date-times in PHP?</p>
<p>Here is the answer:</p> <pre><code>$to_time = strtotime("2008-12-13 10:42:00"); $from_time = strtotime("2008-12-13 10:21:00"); echo round(abs($to_time - $from_time) / 60,2). " minute"; </code></pre>
<p>try this</p> <pre><code>$now = \Carbon\Carbon::now()-&gt;toDateString(); // get current time $a = strtotime(&quot;2012-09-21 12:12:22&quot;); $b = strtotime($now); $minutes = ceil(($a - $b) / 3600); it will get ceiling value </code></pre>
47,674
<p>I have two databases with the same structure. The tables have an integer as a primary key as used in Rails.</p> <p>If I have a patients table, I will have one patient using primary key 123 in one database and another patient using the same primary key in the other database.</p> <p>What would you suggest for mergin...
<p>Set both your databases up with entries in config/database.yml, then generate a new migration.</p> <p>Use ActiveRecord::Base.establish_connection to switch between the two databases in the migration like this:</p> <pre><code>def self.up ActiveRecord::Base.establish_connection :development patients = Patient.fi...
<p>BTW it probably makes more sense for this to be a rake or capistrano task rather than a migration.</p>
20,428
<p>I have been looking at the Model-View-ViewModel pattern that is suggested by several people out there (especially John Gossman, take a look at this <a href="http://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx" rel="nofollow noreferrer">post</a> and this <a href="http://pixel8.infragistics.com/#Episode:9...
<p>Another pattern that we have used and loved is the <strong>Attached Behavior pattern</strong> ... using the extensibility mechanism of attached properties in WPF. There are quite a few posts out there on this useful pattern as well.</p> <ul> <li><a href="http://blogs.msdn.com/johngossman/archive/2008/05/16/attached...
<p>I have been using a variation of the Model-View-Presenter pattern. It has served our purposes pretty well developing various UIs. It is not perfect but it gets the job done well. One of the issues I've had is that I am never satisfied with multi-threaded scenarios. We've recently been making many of our presenters m...
22,083
<p>Our web client needs a way to browse the local network and select location for file storage. This will then be returned to the webpage as a UNC name.</p> <p>On a native client this easily accomplished by using Shell32 functions.</p> <p>I've looked at ASP FileUpload, but that returns the file vs. a specific direct...
<p>If by "web client", you mean a web browser - then you really can't. There's an <a href="http://msdn.microsoft.com/en-us/library/ms535263(VS.85).aspx" rel="nofollow noreferrer">HTML file input</a>, but it requires a file (which is no doubt what ASP FileUpload was using). There's <a href="http://msdn.microsoft.com/en-...
<p>You actually <em>can</em> use the Shell32 functions in C#, see <a href="http://www.pinvoke.net/" rel="nofollow noreferrer">P/Invoke</a>.</p>
30,305
<p>I was just wondering if there is any difference between the two different new object initializers or is it just syntactic sugar. </p> <p>So is:</p> <pre><code>Dim _StreamReader as New Streamreader(mystream) </code></pre> <p>and different to:</p> <pre><code>Dim _StreamReader as Streamreader = new streamreader(m...
<p>In VB.NET, they're identical. The <code>As New</code> variant is canonical.</p> <p>In VB6, their semantics actually differed (apart form the obvious fact that VB6 didn't allow assignments in declarations): the <code>As New</code> variant would create an object that could never be <code>Nothing</code>. Rather, the r...
<p>I'm not a VB guy, but as far as I can tell they're equivalent. According to <a href="http://msdn.microsoft.com/en-us/library/7ee5a7s1.aspx" rel="nofollow noreferrer">MSDN's description of the Dim statement</a>:</p> <blockquote> <p>If you do not specify datatype, the variable takes the data type of initializer...
37,600
<p>I'm playing around with the locale and I18N stuff in c++ and have been looking for real world examples. I've read through the Josuttis chapter on I18N in his <a href="http://www.josuttis.com/libbook/" rel="noreferrer">book</a> (2nd Edition for C++11 to be released April 2012), and found it useful but with no real wo...
<p>You've been pointed to <a href="http://www.gnu.org/software/gettext/" rel="nofollow noreferrer">GNU gettext</a>, which allows you to replace literal strings with localized versions at run time - one aspect of localization (which is what happens after you've done the internationalization, when someone actually uses y...
<p>You do not need libraries to accomplish this task. See the MS guide for Satellite DLLs <a href="http://support.microsoft.com/kb/188659" rel="nofollow noreferrer">here</a>.</p> <p>If you specify to use Unicode in the project settings and use Unicode String functions (instead of char) then the standard use of Satelli...
23,750
<p>In any language really, im looking for a simple (very simple) way to control the position of a shortcut on the users desktop. I already make the assumption that Auto Arrange and Align to Grid are unchecked.</p> <p>Ex: The program creates the shortcut to the desktop than places it at position (450,302) on the deskto...
<p>In the end, I think the problem was caused by a step that is missed by the script when you refresh ASP.Net 2.0 with IIS 6.</p> <p>I managed to resolve this using the following steps:</p> <ul> <li><p>Refresh the install using <code>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -s /w3svc/1/root</code><...
<p>When you get the error, it means either:</p> <p>1 The DLL does not need to be registered</p> <p>or</p> <p>2 The DLL is corrupt</p>
12,420
<p>I'm used to passing around string like this in my C++ applications:</p> <pre><code>void foo(const std::string&amp; input) { std::cout &lt;&lt; input.size() &lt;&lt; std::endl; } void bar() { foo("stackoverflow"); } </code></pre> <p>Now I have a case where I want the string to be NULL:</p> <pre><code>void baz...
<p>If you want the type to be null, then make it a pointer. Pass string pointers around instead of references, since this is precisely what pointers can do, and references cant. References always point to the same valid object. Pointers can be set to null, or be reseated to point to another object. Thus, if you need th...
<p>What if you just use:</p> <pre><code>void foo(const char *xinput) { if (xinput == NULL) { // do something exceptional with this return; } std::string input(xinput); // remainder of code as usual } </code></pre> <p>Yes, this does incur an extra allocation and copy, and calling the fu...
44,422
<p>I have built an application in C# that I would like to be optimized for multiple cores. I have some threads, should I do more?</p> <p><strong>Updated for more detail</strong></p> <ul> <li>C# 2.0</li> <li>Run on Windows Vista and Windows Server 2003</li> </ul> <p><strong>Updated again</strong></p> <ul> <li>This c...
<p>I'd generalize that writing a highly optimized multi-threaded process is a lot harder than just throwing some threads in the mix. </p> <p>I recommend starting with the following steps:</p> <ol> <li>Split up your workloads into discrete parallel executable units</li> <li>Measure and characterize workload types - N...
<p>Understanding the parallelism (or potential for parallelism) in the problem(s) you are trying to solve, your application and its algorithms is much more important than any details of thread synchronization, libraries, etc.</p> <p>Start by reading <a href="https://rads.stackoverflow.com/amzn/click/com/0321228111" re...
15,056
<p>I'm investigating an annotation-based approach to validating Spring beans using <a href="https://springmodules.dev.java.net/" rel="nofollow noreferrer">spring modules</a>. In <a href="http://wheelersoftware.com/articles/spring-bean-validation-framework.html" rel="nofollow noreferrer">this tutorial</a>, the following...
<p>I took a quick look at the <a href="https://springmodules.dev.java.net/source/browse/%2Acheckout%2A/springmodules/www/docs/javadocs/0.8/org/springmodules/validation/bean/BeanValidator.html" rel="nofollow noreferrer">BeanValidator API</a>, and it looks like you might want to try the <em>errorCodeConverter</em> proper...
<p>Add the following beans in your <code>applicationContext.xml</code> file.</p> <pre><code>&lt;bean id="configurationLoader" class="org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader" /&gt; &lt;!-- Use the error codes as is. Don't convert them to &lt;Bean class n...
18,017
<p>I've been asked to maintain a large C++ codebase full of memory leaks. While poking around, I found out that we have a lot of buffer overflows that lead to the leaks (how it got this bad, I don't ever want to know).</p> <p>I've decided to removing the buffer overflows first. To make my bug-hunting easier, what tool...
<p>On Linux I'd use Valgrind.</p>
<p>On Windows for memory leaks/buffer overruns and other runtime error detection you can use:</p> <ul> <li>Boundschecker from Compuware (<a href="http://www.compuware.com/products/devpartner/visualc.htm" rel="nofollow noreferrer">http://www.compuware.com/products/devpartner/visualc.htm</a>)</li> <li>IBM Rational Purif...
20,191
<p>I know you can use autoexnt to run a batch file on startup for Windows XP, but that only seems to work for 32-bit machines. I'm running Windows XP x64 on a box, and I need to have a script run on startup (without anyone's logging in). Any ides?</p> <p>Thanks for the help.</p>
<p>Can also use local computer policy to configure startup and shutdown scripts.</p> <p><a href="http://vlaurie.com/computers2/Articles/group_policy_editor.htm" rel="nofollow noreferrer">http://vlaurie.com/computers2/Articles/group_policy_editor.htm</a></p> <p>Has a good walkthrough of how to do it.</p>
<p>On startup meaning Login, or on startup meaning (before anyone logs in)?</p> <p>On login, you could just put a BAT in your Startup folder.</p>
12,946
<p>I can't seem to be able to disable a select box when the select tag is not nested inside a form tag. Some things I tried are (using Firefox 3): (via Jquery)</p> <pre><code>$("#mySelect").attr("disabled", true); $("#mySelect").attr("disabled", "disabled"); </code></pre> <p>(also)</p> <pre><code>document.getElemen...
<p>Short answer: No, you don't need to have the select box within a form. </p> <p>Where is your JavaScript currently included with respect to the <code>body</code> tag in your HTML? Remember that if you have inline JavaScript included in the head if your page, then it will fire as the page is loaded. At this point, th...
<p>When using the jQuery library, make sure the code you write is always enclosed in the <code>$.ready</code> function: </p> <pre><code>$(function () { //Type in your code here }); </code></pre> <p>This makes sure that the <strong>code you write will be executed once the page has finished loading</strong></p>
44,959
<p>Is there a library method to copy all the properties between two (already present) instances of the same class, in Python?</p> <p>I mean, something like Apache Commons' <code>PropertyUtilsBean.copyProperties()</code></p>
<p>If your class does not modify <code>__getitem__</code> or <code>__setitem__</code> for special attribute access all your attributes are stored in <code>__dict__</code> so you can do:</p> <pre><code> nobj.__dict__ = oobj.__dict__.copy() # just a shallow copy </code></pre> <p>If you use python properties you shou...
<p>At the risk of being modded down, is there <strike>a decent</strike> any use-case for this? </p> <p>Unless we know exactly what it's for, we can't sensibly call it as "broken" as it seems.</p> <p>Perhaps try this:</p> <pre><code>firstobject.an_attribute = secondobject.an_attribute firstobject.another_attribute = ...
30,214
<p>When I print large prints close to (but not exceeding) the maximum dimensions of the heated build platform on my Anet A8, the brim or skirt or the print itself is printed outside the heated bed, while there is some space left at the opposite sites. It appears as if the print is not in the center.</p> <ul> <li>Why i...
<p>When centered in the slicer correctly, without offsets defined in the slicer, the printer is most probably incorrectly configured! Luckily you can do something about that! Basically, you will have to calibrate the printer for a new center.</p> <h2>Printer origin?</h2> <p>First of all, the firmware determines where y...
<p>As to <strong>why</strong> this happens, particularly with a budget printer the end-stop mountings may not be particularly precisely located, or the moving part may actuate the endstop slightly differently in each build. In my case, replacing the hot end (and thus the whole carriage) gave me an offset of some cm. Wi...
959
<p>Last time <a href="https://stackoverflow.com/questions/169506/get-form-input-fields-with-jquery">I asked about the reverse process</a>, and got some very efficient answers. I'm aiming for least lines of code here. I have a form of fields and an associative array in the {fieldname:data} format, I want to populate a c...
<p>If your form elements have their ID set to the fieldname:</p> <pre><code>$.each(myAssocArry, function(i,val) { $('#'+i).val(val); }); </code></pre>
<p>I have not seen jQuery handle passing a single (non-array) value into val() for a radio or checkbox input. You have to be sure to wrap the single value into an array.</p> <p>I have also typically not wanted to alter the values of button-ish inputs, so I filter those out.</p> <p>Here's a function that handles the ...
20,788
<p><em>Out of interest and because it infuriates me, I was wondering if SOmebody here might happen to work for a bank or otherwise know the answer to this.</em></p> <p>I've used a few online banking sites (UK and N.America) and they universally enforce a password pattern of <code>/[\w\d]{6,8}/</code> Sometimes, maybe ...
<p>I actually work in a bank right now, and have worked in quite a few in the past.</p> <p>The primary reason that this happens is that in general the people who are ultimately responsible for making these decisions are not the people who end up implementing them. The "Business Unit" of a bank are the non-technical bu...
<p>Here is a "bug" I got logged in Bugzilla regarding a site I'd built for a client recently (not a bank, thankfully!):</p> <blockquote> <p>"It seems that the user is forced to use a ! or _ in their password* which seems a bit odd to me. Can this ben updated so that it is a 6 - 8 digit password that can only use alp...
44,356
<p>I've been reading that Adobe has made crossdomain.xml stricter in flash 9-10 and I'm wondering of someone can paste me a copy of one that they know works. Having some trouble finding a recent sample on Adobe's site.</p>
<p>This is what I've been using for development:</p> <pre><code>&lt;?xml version="1.0" ?&gt; &lt;cross-domain-policy&gt; &lt;allow-access-from domain="*" /&gt; &lt;/cross-domain-policy&gt; </code></pre> <p>This is a very liberal approach, but is fine for my application.</p> <p><strong>As others have pointed out belo...
<p>In production site this seems suitable:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;cross-domain-policy&gt; &lt;allow-access-from domain="www.mysite.com" /&gt; &lt;allow-access-from domain="mysite.com" /&gt; &lt;/cross-domain-policy&gt; </code></pre>
26,209
<p>Let's say I have a class like this:</p> <pre><code>class ApplicationDefs{ public static final String configOption1 = "some option"; public static final String configOption2 = "some other option"; public static final String configOption3 = "yet another option"; } </code></pre> <p>Many of the other classes in my app...
<p>You can use String.intern() to get the desired effect, but should comment your code, because not many people know about this. i.e.</p> <pre><code>public static final String configOption1 = &quot;some option&quot;.intern(); </code></pre> <p>This will prevent the compile time inline. Since it is referring to the exact...
<p>There is nothing here that says these values should be inlined. You are just declaring some <code>public</code>, <code>static</code> members. Those other classes are using the values of these members. No inlining is asked. Even the <code>final</code> keyword </p> <p>But for <strong>performance reasons</strong>, som...
49,480
<p>I need to check programmatically (in .NET) whether a given user (domain account) is a member of the built-in Administrators group on a current computer (the one where the application gets executed).</p> <p>Is it possible?</p>
<p>I don't know about .Net, but in win32, the easy way is to call IsUserAnAdmin(). If you need more control, you can open the process token and check with CheckTokenMembership for each group you need to check</p> <p><strong>Edit:</strong> See <a href="http://www.pinvoke.net/default.aspx/advapi32/CheckTokenMembership.h...
<p>You could loop the groups like i did in this answer:</p> <p><a href="https://stackoverflow.com/questions/45437/determining-members-of-local-groups-via-c#45458">Determining members of local groups via C#</a></p> <p>After reading some more, the easiest thing would be to use the <code>System.DirectoryServices.Account...
7,550
<p>I have 4 <code>&lt;select&gt;&lt;/select&gt;</code> elements in my form. Usually when submitting the form you would get this in the url, e.g.</p> <pre><code>index.html?day=01&amp;month=01&amp;year=1999&amp;reporter=Joe+Blogs </code></pre> <p>However in my interface users are switching between the date picker and t...
<p>Use the .attr("disabled","disabled") in jQuery.</p>
<p>I would rather prefer to pass the control to the server side for any sort of validation. </p>
45,360
<p>I want to play a movie file or any animation file till the time application not loaded completely.<br> Is there any simple way to do it?</p>
<p>Telling other people what they want to do is questionable. My client WANTS a movie to play and it's only a 3 second movie. It's called branding and if his users don't like it, they'll tell him.</p>
<p>The only way to play a movie is to use the MPMoviePlayer. This takes over the UI and is full screen -- none of your app will show through until the movie is closed.</p> <p>While it sounds cool to have a movie play while the app is loading, on the iPhone, it's really not practical. This is not something you want to ...
44,511
<p>Will Subclipse 1.4.4 work safely with Subversion 1.3.2?</p> <p>I am confused because its <a href="http://subclipse.tigris.org/subclipse_1.4.x/changes.html" rel="nofollow noreferrer">changelog</a> says</p> <blockquote> <p>NOTE: As of Subclipse 1.3.0, the minimum Subversion JavaHL requirement is 1.5.0.</p> </block...
<p>Subclipse requires Subversion 1.5.x on the client. A Subversion 1.5.x client can talk to any 1.x server, all the way back to 1.0.0.</p>
<p>Do you mean whether Subclipse 1.4.4 will work with a server that is 1.3.2? If so, probably yes since clients tend to be updated more often than the servers, and thus they try to be backwards compatible. 1.3.2 is starting to get old though, if the client is based on subversion 1.5.</p>
14,676
<p>Despite my most convincing cries to the contrary, I was recently forced to implement a horizontal drop-down navigation system, so I opted for the friendliest one I could find - <a href="http://www.htmldog.com/articles/suckerfish/dropdowns/" rel="nofollow noreferrer">Son of Suckerfish</a>.</p> <p>I tested in various...
<p>This is a problem that occurs in IE7 when another part of the page has focus (ie, you clicked somewhere and then mouse-over the menu). It seems to be an issue with the :hover pseudo-class.</p> <p>Adding a hasLayout trigger to the :hover style should fix the problem. </p> <pre><code>#nav li:hover { position: stat...
<p>For testing why not download the Vista IE7 VPC image from MS themselves?</p> <p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF</a></p> <p>...
16,074
<p>I just installed Glassfish V2 on my local machine just to play around with it.</p> <p>I was wondering if there is a way to retrieve a param passed in by the GET HTTP method.</p> <p>For instance,</p> <pre><code>http://localhost:8080/HelloWorld/resources/helloWorld?name=ABC </code></pre> <p>How do I retrieve the "...
<p>Like this:</p> <pre><code>@Path("/helloWorld") @Consumes({"application/xml", "application/json"}) @Produces({"application/xml", "application/json"}) @Singleton public class MyService { @GET public String getRequest(@QueryParam("name") String name) { return "Name was " + name; } } </code></pr...
<p>By putting:</p> <pre><code>@Context private UriInfo context; </code></pre> <p>in your HelloWorld class, can you access the</p> <pre><code>context.getQueryParameters() ; </code></pre> <p>method to get a map of parameters?</p> <p><a href="http://docs.sun.com/app/docs/doc/820-4867/ggrby?a=view" rel="nofollow noref...
12,543
<p>For years, I've been using named blocks to limit the scope of temporary variables. I've never seen this done anywhere else, which makes me wonder if this is a bad idea. Especially since the Eclipse IDE flags these as warnings by default.</p> <p>I've used this to good effect, I think, in my own code. But since it...
<p>I'd just go straight for refactoring into smaller methods. If a method is big enough that it needs breaking up like this, it really needs breaking up into multiple methods if <em>at all</em> possible.</p> <p>While limiting scope is nice, this isn't really what named blocks are for. It's unidiomatic, which is very r...
<p>I have done this in some of my c#. I didn't know you could name the blocks though, I'll have to try that see if it works in c# too. </p> <p>I think the scope block can be a nice idea, because you can encapsulate code specific to something within a block of code, where you might not want to split it out into its o...
25,173
<p>I need to unzip a compressed file on the fly in my program. It works when I try it on my own linux computer, but for some reason the school computers fail whenever I tell them to do it. To unzip I'm using the following command:</p> <pre><code> zcat /file/address/file.tar.gz </code></pre> <p>and get the error:</p> ...
<p>Your school's system still has the old "compress" style utilities rather than the newer GNU "gzip" based ones.</p> <p>You need to use <code>gzcat</code> rather than <code>zcat</code>, assuming that it's available.</p>
<p>gzip --decompress /file/address/file.tar.gz</p>
37,940
<p>When the following two lines of code are executed in a bash script, "ls" complains that the files don't exist:</p> <pre><code>dirs=/content/{dev01,dev02} ls -l $dirs </code></pre> <p>When I run the script with the -x option, it appears to be passing the variable within single quotes (which would prevent globbing):...
<p>I think it is the order of expansions:</p> <blockquote> <p>The order of expansions is: <code>brace expansion</code>, tilde expansion, parameter, <code>variable</code> and arithmetic expansion and command substitution (done in a left-to-right fashion), word splitting, and <code>pathname expansion</code>....
<pre><code>ls `echo $dirs` </code></pre> <p>works under cygwin. </p>
48,208
<p>Are there any libraries or resources available for parsing/reading an archived eventlogs?</p>
<p>There is this article <a href="http://www.codeproject.com/KB/string/EventLogParser.aspx?fid=334874&amp;df=90&amp;mpp=25&amp;noise=3&amp;sort=Position&amp;view=Quick&amp;select=2018071#xx2018071xx" rel="nofollow noreferrer">Parsing event log(*.evt) file.</a> Then there is the Microsoft <a href="http://msdn.microsof...
<p>Which IIS version do you use ? If you use IIS 6, You can use Microsoft Log Parser to see it. Download from <a href="http://support.microsoft.com/kb/840671" rel="nofollow noreferrer">IIS 6 Resource Kit</a></p>
47,193
<p>I'm looking for a technique (javascript, CSS, whatever ???) that will let me control the amount of a string that is displayed. The string is the result of a search (and therefore not initially known). A simple Character count approach is trivial, but not acceptable, as it needs to handle proportional fonts. In other...
<p>Perhaps the CSS property <code>overflow: hidden;</code> can help you, in conjuntion with <code>width</code>.</p>
<p>Yahoo does this server-side, the truncation and elipsis ('...') is returned in the HTML. Presumably this is done on a character count, and if thats not an option for you then server-side is out.</p> <p>Other than <code>overflow: hidden</code> I'm not sure CSS can help you here. You could measure the width of the co...
23,736
<p>I have a weird problem with my old 3D printer, it is a Prusa/Mendel type. When I print a 20&nbsp;mm cube, X and Y are correct, Z is resulting 16 to 17&nbsp;mm. I have checked the correctness of the movement on Z using the manual controls and there are no issues.</p> <p>I played a bit with the layer thickness, I hav...
<p>You should check that the steps per mm for your Z-axis are set correctly. This depends on the pitch of the leadscrews/threaded rods driving the axis and parameters of your steppers (microstepping and raw steps/revolution). <a href="http://prusaprinters.org/calculator/" rel="nofollow noreferrer">This Calculator</a>.<...
<p>A suitable test part for this problem, to check if the bad scaling is linear or the result of missing steps (as was identified in this case) would be a ramp, or sequence of steps. You can check the linearity using a straight edge, and would be able to perform repeated tests to identify of there was a specific Z loca...
391
<p>Ok, so I've been refactoring my code in my little Rails app in an effort to remove duplication, and in general make my life easier (as I like an easy life). Part of this refactoring, has been to move code that's common to two of my models to a module that I can include where I need it.</p> <p>So far, so good. Look...
<p>You can use this:</p> <pre><code>super if defined?(super) </code></pre> <p>Here is an example:</p> <pre><code>class A end class B &lt; A def t super if defined?(super) puts "Hi from B" end end B.new.t </code></pre>
<p>Rather than checking if the super method exists, you can just define it</p> <pre><code>class ActiveRecord::Base def after_initialize end end </code></pre> <p>This works in my testing, and shouldn't break any of your existing code, because all your other classes which define it will just be silently overrid...
3,196
<p>My ASP.NET application allows users to upload and download large files. Both procedures involve reading and writing filestreams. What should I do to ensure the application doesn't hang or crash when it handles a large file? Should the file operations be handled on a worker thread for example?</p>
<p>Make sure you properly buffer the files so that they don't take inordinate amounts of memory in the system.</p> <p>e.g. excerpt from a download application, inside the while loop that reads the file:</p> <pre><code>// Read the data in buffer. length = iStream.Read(buffer, 0, bufferSize); // Write the data to the ...
<p>Unless this is the primary purpose of your site consider partitioning these operations to a separate application, e.g. a sub-application or sub-domain. Besides reducing risk this would also simplify scaling out as your user base grows.</p>
34,808
<p>I'm using the d programing language to write a program, and I'm trying to use ddbg to debug it. When there is an exception, I want to have the program break whenever there is an exception thrown so that I can inspect the stack.</p> <p>Alternatively, is there another debugger that works with d? Is there another wa...
<p>You want to break when there's any exception thrown or just uncaught exceptions? Because I think the latter is already the default behavior.</p> <p>You probably know this, but you get the stack trace by typing 'us' (unwind stack) at the prompt. Just trying to eliminate the obvious.</p> <p>Anyway, I've never had ...
<p>Haven't used ddbg yet, but according to the documentation at <a href="http://ddbg.mainia.de/doc.html" rel="nofollow noreferrer">http://ddbg.mainia.de/doc.html</a> there is the</p> <blockquote> <p>onex &lt;cmd; cmd; ...&gt; on exception execute list of commands</p> </blockquote> <p>command.</p>
6,965
<p>My company has been working on a Flex dashboard that displays realtime financial information. It will be deployed over a corporate WAN to perhaps a few dozen users. </p> <p>This is our first Flex project, and while development has been very pleasant, we're a little concerned about what production issues might come ...
<p>Your biggest problems are likely to be:</p> <ul> <li>your users not having the correct version of the flash player</li> <li>your users having locked-down desktops and either not being able to download the right version of the player or not being allowed to use the player at all</li> <li>download speeds of the swf i...
<p>our logs showed that flex apps would randomly drop connections to our servers. We ended up adding automatic retry logic to all of our REST calls.</p>
26,088
<p>I am working on a git repository with a master branch and another the topic branch. I have switched to topic branch and modified a file. Now, if I switched to the master branch, that same file is shown as modified.</p> <p>For example:</p> <p>git status in git-build branch:</p> <pre><code># On branch git-build # Chan...
<blockquote> <p>Why is that the file is shown as modified in master branch even though it was modified in git-build branch?</p> </blockquote> <p>The key to remember is that the file was <strong>not</strong> modified in the git-build branch. It was only modified in your working copy.</p> <p>Only when you commit are ...
<p>In my experience this &quot;spillover&quot; problem arises because <code>git</code> does not protect &quot;untracked&quot; files from <code>git checkout</code> (only tracked but uncommitted files would be protected, i.e. user would be forced to <code>git commit</code> them before a <code>git checkout</code> is allow...
30,564
<p>I have an installation program (just a regular C++ MFC program, not Windows Installer based) that needs to set some registry values based on the type of Internet connection: broadband, dialup, and/or wireless. Right now this information is being determined by asking a series of yes or no questions. The problem is ...
<p>Use InternetGetConnectedState API to retrieve internet connection state.</p> <p>I tested it and it works fine.</p> <p>I found this document which can help:</p> <p><a href="http://www.pcausa.com/resources/InetActive.txt" rel="nofollow noreferrer">http://www.pcausa.com/resources/InetActive.txt</a></p>
<p>Best bet would be to grab the default active network connection, ensure it is an internet connection (ping google.com or similar) and then ask it what type of device it is. You should be able to determine from that what connection the user has.</p> <p>I'm fairly confident this is possible, but not sure how to go ab...
11,907
<p>I am looking for a solution or recommendation to a problem I am having. I have a bunch of ASPX pages that will be localized and have a bunch of text that needs to be supported in 6 languages.</p> <p>The people doing the translation will not have access to Visual Studio and the likely easiest tool is Excel. If we ...
<p>I'm not sure how comprehensive an answer you're looking for, but if you're really just using [string, string] pairs for your localization, and you're just looking for a quick way to load resource (.resx) files with the results of your translations, then the following will work as a fairly quick, low-tech solution.</...
<p>If it's in csv here's a quick Ruby script to generate the data elements.</p> <pre><code>require 'csv' require 'builder' file = ARGV[0] builder = Builder::XmlMarkup.new(:indent =&gt; 2) CSV.foreach(file) do |row| builder.data(:name =&gt; row[0], "xml:space" =&gt; :preserve) {|d| d.value(row[1]) } end File.open...
27,601
<p>Is it possible to have a CSS rule which basically "undoes" a prior rule?</p> <p>An example:</p> <pre><code>&lt;blockquote&gt; some text &lt;em&gt;more text&lt;/em&gt; other text &lt;/blockquote&gt; </code></pre> <p>and let's say there's this CSS:</p> <pre><code>blockquote { color: red; } </code></pre> <...
<p>With CSS alone, you can't refer to a parent's parent. </p> <p>The thing you can do is try a mix of specific CSS selectors and markup so that the desired effect appears. </p> <pre><code>&lt;td&gt; This is the enclosing element. &lt;ul&gt; &lt;li&gt;This is the first level UL, direct child of TD &lt;ul...
<p>Ok, the additional text with example clarifies the question a lot. And I'm affraid that what you want is not possible.</p> <p>If you know the "unknown colour" you can of course repeat the color. But I think CSS needs some mechanism to add variables or references. </p> <p>So you have to stick to the cumbersome:</p>...
34,985
<p>Like many others on this site I am considering a move to ASP.NET MVC for future projects. Currently my sites are running the traditional ASP.NET 2.0 Web Forms, and it works OK for us, so my other option is just to stick with what I know and make the move to ASP.NET 3.5 with the integrated AJAX stuff.</p> <p>I'm wo...
<p>To implement a user control you do the following call:</p> <pre><code>&lt;% Html.RenderPartial("~/Views/Shared/MyControl.ascx", {data model object}) %&gt; </code></pre> <p>You may also see the older syntax which as of PR5 is not valid anymore</p> <pre><code>&lt;%= Html.RenderUserControl("~/Views/Shared/MyControl....
<p>As Nick suggested, you will indeed be able to render your user controls, but obviously the page-cycle, pagestate and postback from traditional ASP Webforms won't work anymore, thus making your controls most likely useless.</p> <p>I think you'll have to rewrite most of your complex controls to port your website to M...
6,311
<p>i've got some binary data which i want to save as an image. When i try to save the image, it throws an exception if the memory stream used to create the image, was closed before the save. The reason i do this is because i'm dynamically creating images and as such .. i need to use a memory stream.</p> <p>this is the...
<p>As it's a MemoryStream, you really don't <em>need</em> to close the stream - nothing bad will happen if you don't, although obviously it's good practice to dispose anything that's disposable anyway. (See <a href="https://stackoverflow.com/questions/234059">this question</a> for more on this.)</p> <p>However, you <e...
<p>One strange solution which made my code to work. Open the image in paint and save it as a new file with same format(.jpg). Now try with this new file and it works. It clearly explains you that the file might be corrupted in someway. This can help only if your code has every other bugs fixed</p>
43,633
<p>I have a webpage where I want the user to see a new image when they put thier mouse over a certain part of the image. I used an image map.</p> <pre><code>&lt;img src="pic.jpg" usemap="#picmap" /&gt; &lt;map id="picmap" name="picmap"&gt;&lt;area shape="rect" coords ="10,20,30,40" onMouseOver="mouse_on_write('mouse ...
<p>You don't need to create any page elements, it can all be preloaded using JavaScript:</p> <pre><code>tempImg = new Image() tempImg.src="pic2.jpg" </code></pre> <p>EDIT:</p> <p>If you have a lot of images, you can use the poor-man's multi-preloader:</p> <pre><code>preloads = "red.gif,green.gif,blue.gif".split(","...
<p>Use <code>display: none;</code>, then have the Javascript change it to <code>display: inline</code> when you want to display it. This has the added advantage of being able to put the image exactly where you want in the page's source, rather than having to add it with Javascript later.</p>
36,614
<p><strong>Is there a tool to generate WiX XML given a .reg file?</strong></p> <hr> <p>In 2.0, you were supposed to be able to run tallow to generate registry XML:</p> <pre><code>tallow -r my.reg </code></pre> <p>For what it's worth, the version of tallow I have is producing empty XML.</p> <p>In 3.0, tallow has b...
<p>I couldn't find a tool, so I made one.</p> <p>The source code may not be elegant, but it seems to work:</p> <pre><code>using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Xml; using System.Text.RegularExpressions; namespace Reg2Wix { class Program { sta...
<p>I've tried <strong>tallow.exe (version 2.0.5805)</strong> from the latest stable <strong>Wix 2</strong> release and it worked fine for me.</p> <pre><code>tallow -reg my.reg </code></pre> <p>This will generate the markup using Wix 2 <strong>"Registry"</strong> tag that was <strong>deprecated in Wix 3</strong>. Then...
33,842
<p>According to MSDN </p> <pre><code>form.RightToLeftLayout = True; form.RightToLeft = ifWeWantRTL() ? RightToLeft.True : RightToLeft.False; </code></pre> <p>is enough to mirrow the form content for RTL languages.</p> <p>But controls placement gets mirrowed only for controls immediately on the form,<br> those inside...
<p>It does seen that you have quite a nasty problem on your hands. Have played with it for a while and come up with the following:</p> <p>Making use of a little recursion you can run though all the controls and do the manaul RTL conversion for those controls trapped in Pannels and GroupBoxes.</p> <p>This is a <em>qui...
<p>If you have a class derived from Control that contains child controls (like a <code>ContainerControl</code>), you can add the following code to force all child controls to mirror when the parent form's <code>RightToLeftLayout</code> is set to true and when your control's <code>RightToLeft</code> is set to <code>Righ...
17,777
<p>I am writing a Java utility that helps me to generate loads of data for performance testing. It would be <em>really</em> cool to be able to specify a regex for Strings so that my generator spits out things that match this.</p> <p>Is something out there already baked that I can use to do this? Or is there a library ...
<p><strong>Edit:</strong></p> <p>Complete list of suggested libraries on this question:</p> <ol> <li><a href="https://code.google.com/archive/p/xeger/" rel="noreferrer">Xeger</a>* - Java</li> <li><a href="https://github.com/mifmif/Generex" rel="noreferrer">Generex</a>* - Java</li> <li><a href="https://github.com/curiou...
<p>If you want to generate "critical" strings, you may want to consider:</p> <p>EGRET <a href="http://elarson.pythonanywhere.com/" rel="nofollow noreferrer">http://elarson.pythonanywhere.com/</a> that generates "evil" strings covering your regular expressions</p> <p>MUTREX <a href="http://cs.unibg.it/mutrex/" rel="no...
4,211
<p>I am trying to use native windows API with Qt using mingw toolset. There are link problems with some functions. What happens? Is this a bug with mingw name mangling?</p> <pre><code>#ifdef Q_WS_WIN HWND hwnd = QWidget::winId(); HDC hdcEMF = CreateEnhMetaFile(NULL, NULL, NULL, NULL ) ; Rectangle(hdcEMF,1...
<p>The functions <code>CreateEnhMetaFileW()</code> and <code>CloseEnhMetaFile()</code> are defined in the static library Gdi32.lib, so you have to make sure to link against that. Try adding <code>-lgdi32</code> to the end of your command line you're using to compile. If that doesn't work, you might have to specify th...
<p>It's possible that the functions are included, but getting mangled due to the C++ assumption.</p> <p>Look into the extern C { } declaration. It's intended to declare functions that should not be name mangled to account for polymorphism / overloading. (IE two functions with the same name).</p>
33,571
<p>In an attempt to add some parameter validation and correct usage semantics to our application, we are trying to add correct exception handling to our .NET applications.</p> <p>My question is this: When throwing exceptions in ADO.NET if a particular query returns no data or the data could not be found, what type of ...
<p>The <a href="http://msdn.microsoft.com/en-us/library/ms229021(VS.80).aspx" rel="nofollow noreferrer">MSDN guidelines</a> state:</p> <ul> <li><p>Consider throwing existing exceptions residing in the System namespaces instead of creating custom exception types.</p></li> <li><p>Do create and throw custom exceptions if...
<p>As far as ADO.net is concerned, a query that returns zero rows is not an error. If your application wishes to treat such a query as an error, you should create your own exception class by inheriting from Exception.</p> <pre><code>public class myException : Exception { public myException(string s) : base() { ...
14,796
<p>VMware ESX, ESXi, and VirtualCenter are supposed to be able to support HTTP PUT uploads since version 3.5. I know how to do downloads, that's easy. I've never done PUT before.</p> <p>Background information on the topic is here: <a href="http://communities.vmware.com/thread/117504" rel="nofollow noreferrer">http://c...
<p>In the <a href="http://www.codeplex.com/vitoolkitextensions" rel="nofollow noreferrer">VI Toolkit Extensions</a> use Copy-TkeDatastoreFile. It will work with binaries.</p>
<p>You should have a look at the <code>Send-PoshCode</code> function in the <a href="http://PoshCode.org/" rel="nofollow noreferrer">PoshCode</a> cmdlets script module ... it uses a POST, not a PUT, but the technique is practically identical. I don't have PUT server I can think of to test against, but basically, set y...
9,151
<p>I remember reading that one abstracts the low level calls into a data agnostic framework (eg. ExecuteCommand methods etc), and the other usually contains business specific methods (eg. UpdateCustomer).</p> <p>Is this correct? Which is which?</p>
<p>To me this is a personal design decision on how you want to handle your project design. At times data access and data service are one and the same. For .NET and LINQ that is the case.</p> <p>To me the data service layer is what actually does the call to the database. The data access layer receives the objects an...
<p>The <strong>Data Service Layer</strong> concept done in the <a href="http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/index.jsp?topic=/com.ibm.commerce.developer.soa.doc/concepts/csddsl.htm" rel="nofollow">WebSphere Commerce</a> documentation is straightforward:</p> <blockquote> <p>The data service layer (DSL) pro...
16,143
<p>I'm refactoring a number of classes in an application to use interfaces instead of base classes. Here's the interfaces I created so far:</p> <ul> <li>ICarryable implemented by all Item objects </li> <li>IActable implemented by all Actor objects</li> <li>IUseable implemented by some Item sub-classes</li> <li>IWie...
<p>Sounds like an ILocateable. Something whose location you can discover and track.</p>
<p>IWhereYouAtable - Boost mobile</p> <p>ITwentyable - as in what's your 20 (short for 10-20 - CB slang)</p> <p>seriously though ILocateable is good.</p>
25,417
<p>I want the server to always serve dates in UTC in the HTML, and have JavaScript on the client site convert it to the user's local timezone.</p> <p>Bonus if I can output in the user's locale date format.</p>
<p>Seems the most foolproof way to start with a UTC date is to create a new <code>Date</code> object and use the <code>setUTC…</code> methods to set it to the date/time you want.</p> <p>Then the various <code>toLocale…String</code> methods will provide localized output.</p> <h3>Example:</h3> <p><div class="snippet" ...
<p>Don't know how to do locale, but javascript is a client side technology.</p> <pre><code>usersLocalTime = new Date(); </code></pre> <p>will have the client's time and date in it (as reported by their browser, and by extension the computer they are sitting at). It should be trivial to include the server's time in t...
11,065
<p>I'm writing a photo gallery webapp for a friend's wedding and they want a photo gallery for guests to submit the digital photos they take on the day. </p> <p>After evaluating all the options, I've decided the easiest thing for users would be to let them use a familiar interface (their email) and just have them send...
<p>What MTA are you using? If you use postfix + maildrop you can create a filtering rule that pipes certain messages through a PHP script that then handles the incoming mails. (google for maildrop and <code>xfilter</code>).</p>
<pre><code>&lt;?php //make sure that submit button name is 'Submit' if(isset($_POST['Submit'])){ $name = $_POST['visitorname']; $email = $_POST['visitoremail']; $message = $_POST['visitormessage']; $to="youremail@yourdomain.com"; $subject="From ".$name; $from ...
14,026
<p>I want to add options to a dropdownbox on my aspx page from the c# code behind during load. I don't know how to get a reference to the control. I have some c# code that is triggered when the user changes the dropdownbox. In that I get a reference to the dropdown with:</p> <pre><code>DropDownBox ddb = (DropDownBox...
<p>If you want the selected item of the dropdown to be automatically selected from viewstate on postbacks you will need to have all the items in the dropdown by the time Page_PreLoad fires. To do this you will want to put your code in Page_Init, at this point the controls are created but viewstate has not yet been in...
<p>PreRender is toward the end of the page lifecycle. Are you sure you want to be making changes there? Sounds like you should be changing items in the dropdown when it is initially bound or when its selection is changed. </p> <p><a href="http://codebetter.com/blogs//images/codebetter_com/raymond.lewallen/89/o_aspNet_...
46,205
<p>Is there a quick &amp; dirty way of obtaining a list of all the classes within a Visual Studio 2008 (c#) project? There are quite a lot of them and Im just lazy enough not to want to do it manually.</p>
<p>If you open the "Class View" dialogue (View -> Class View or Ctrl+W, C) you can get a list of all of the classes in your project which you can then select and copy to the clipboard. The copy will send the fully qualified (i.e. with complete namespace) names of all classes that you have selected.</p>
<p>I've had success using <strong><a href="http://www.doxygen.nl/" rel="nofollow noreferrer">doxygen</a></strong> to generate documentation from the XML comments in my projects - a byproduct of this is a nice, hyperlinked list of classes.</p>
11,661
<p>I have a table in the database that I'm retrieving using LINQ to SQL, and as a part of my processing I want to add to this list, then update the database with the new items + any changes I've made.</p> <p>What I thought I could do was this:</p> <pre><code>var list = (from item in db.Table select item)....
<p>The List is meaningless. It's just happens to hold objects that the DataContext knows about. We need to make sure that the DataContext knows about the new ones. The important thing is that they don't have to be complete when we alert the DataContext to them:</p> <pre><code>Item item; if (needNewOne) { item ...
<p>You have to add the new items via InsertOnSubmit.</p>
22,525
<p>I'm getting seemingly random lines scattered across the top surface of my prints:</p> <p><img src="https://i.stack.imgur.com/UdXPx.jpg" alt="lines1"> <img src="https://i.stack.imgur.com/gf0OH.jpg" alt="lines2"></p> <p>Printer: Anycubic i3 mega<br> Slicer: Cura 3.2.1<br> Printer chosen in Cura: Prusa i3, <em>Gcode ...
<p>Our local library has a genuine Prusa i3 Mk2.5 that recently had this problem. Because of the number of fingers engaging such a system, it was not immediately discovered that a different profile had been selected in which the Z-hop was turned off.</p> <p>Z-hop is a feature in which the nozzle lifts slightly (and is...
<p>It seems like the issue may only be that your nozzle has developed a bit of oozing. The g code likes to repeat the same patterns for at least a few layers every time it changes patterns and if it does the same pattern on the top 3-4 layers than by the time it reaches the last layer on the top that pattern will actu...
840
<p>I've never managed to move from unit-testing to integration-testing in any graceful or automated way when it comes to network code.</p> <p><strong>So my question is</strong>: Given a simple single-threaded client/server based network application, how would you go about integrating both client and server into your c...
<p>Another approach is to mock up both ends with a dummy server and dummy client that just send the messages that you want to test and verify the responses are as expected. These mock servers cab be really, really dumb: they only need to read/write sockets and dump pre-set data back. You can spiff them up a bit by temp...
<p>We structure our applications so that the core code is in a library and the executable is generated from a main.c (really main.cxx in our case) that is just a very thin wrapper that starts the server or client. This lets us set up test suites that can instantiate a complete server and client in proc and do tests wh...
43,916
<p>Is there anyway to use unicode strings (most probably in UTF-8, but could be any encoding) in PostScript?</p> <p>So far, i've been using this function to transforms fonts to Latin1 encoding:</p> <pre><code>/latinize { findfont dup length dict begin { 1 index /FID ne {def}{pop pop} ifelse }forall /Encoding ...
<p>Not really or in any simple &quot;out of the box&quot; way. See <a href="https://web.archive.org/web/20120322112530/http://en.wikibooks.org/wiki/PostScript_FAQ#Does_PostScript_support_unicode_for_CJK_fonts.3F" rel="nofollow noreferrer">this FAQ entry for details</a>.</p>
<p>This may or may not fit your bill, but the interpreter that I wrote (<a href="http://code.google.com/p/xpost/" rel="nofollow">xpost</a>) uses Cairo for all its graphics and font functions, including <code>show</code>. So whatever support Cairo has to offer, xpost doesn't get in the way. But before you get too excite...
34,029
<p>I am using the jQuery tableSorter plugin on a page.</p> <p>Unfortunatley, the table that is being sorted is dynamically modified, and when I sort after adding an element, the element disappears, restoring the table to the state that it was in when the tableSorter was created.</p> <p>Is there any way that i can fo...
<p>I believe you can trigger an update using something like:</p> <pre><code>$(table).trigger("update") </code></pre>
<p>The <code>$(table).trigger("update");</code> throws error </p> <pre><code> Uncaught TypeError: Cannot read property 'rows' of undefined </code></pre> <p>So, there is a jquery function <code>.ajaxStop()</code> where <code>tablesorter()</code> is called. Do not call tablesorter in <code>.ready()</code></p> <pre...
30,718
<p>I use screen to persist my work session and connect to the same session from multiple machines. How can I setup SSH and screen such that the XDISPLAY variable <em>inside</em> my persistent screen session is always set to the machine I am currently connecting from?</p> <p>ie. I start the screen session at work and u...
<p>The following is a manual solution, but there's no reason you couldn't use an alias or a script to have it done automagically when you remotely log in.</p> <p>Assuming that your local shell sets the DISPLAY variable appropriately, you could use <code>screen -X</code> to send the following commads to your remote scr...
<p>There is no "trivial" way to change environment variables in foreign processes.</p> <p>A straightforward solution might be to persist your <code>XDISPLAY</code> into a file on login and use a <code>PROMPT_COMMAND</code> to read this file before printing the next prompt.</p> <hr> <p>For moving X applications aroun...
30,494
<p>i'm having a problem to create a text_field without a method association. Maybe i even don't need it :-)</p> <p>I have two radio_buttons associated to the same method:</p> <pre><code>&lt;%= radio_button :comment, :author, "anonymous" %&gt; Anonymous &lt;br&gt; &lt;%= radio_button :comment, :author, "real_name" %&g...
<p>If you want to generate a text_field without an associated object/method, use <a href="http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M001701" rel="noreferrer"><code>text_field_tag</code></a></p>
<p><code>text_field_tag</code> is definitely the easiest way, but if you want to add a field that acts as part of a model, adding an <code>attr_accessor</code> attribute might be worth looking into as well.</p>
24,815
<p>I cannot get a two-way bind in WPF to work. </p> <p>I have a string property in my app's main window that is bound to a TextBox (I set the mode to "TwoWay"). </p> <p>The only time that the value of the TextBox will update is when the window initializes. </p> <p>When I type into the TextBox, the underlying string ...
<p>Most probably you're trying to bind to a .net CLR property instead of a WPF dependencyProperty (which provides Change Notification in addition to some other things).<br> For normal CLR property, you'd need to implement INotifyPropertyChanged and force update on the textbox in the event handler for PropertyChanged. <...
<p>Make sure that the binding specifies two way and when the property has a change, it is immediately transmitted to the holding property.</p> <pre><code> &lt;TextBox Text=&quot;{Binding TextBuffer, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}&quot;/&gt; </code><...
41,389
<p>I'm in the process of designing a PHP-based content management system for personal use and eventually to be distributed. I know there are a lot of CMS's already out there, but I really haven't found one that meets my all of my needs and I also would like to have the learning experience. Security is a large focus, as...
<p>In building a few iterations of CMSs, some of the key things turned out to be:</p> <ul> <li>Having a good rich text editor - end-users really don't want to do HTML. Consensus seems to be that FCKEditor is the best - there have been a couple of questions on this here recently</li> <li>Allowing people to add new page...
<p>Just use Drupal.</p> <p>Out of the box it is very light and fast. You add modules for virtually everything, so that can be daunting but it is fantastic.</p> <p>Its secure (NASA and The White House use it), its modular, its open-source, it is well supported, has a reputation for clean APIs, and has hundreds of modu...
10,231
<p>Spring IoC container gives you <a href="http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-arbitrary-method-replacement" rel="nofollow noreferrer">an option</a> of replacing a method of a bean. Can someone provide a real life example of using this feature to solve real life proble...
<p>As the documentation says, it's not "commonly useful" functionality.</p> <p>A case where it may be useful though is to alter the functionality of a third party method (you don't necessarily have the source) of a final class - i.e. one whose functionality can't be modified or extended through inheritance.</p> <p>I ...
<p>Using spring IoC now I can change my Lucene Analyzers to whatever I want just changing a configuration file.</p> <pre><code>&lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="locations"&gt; &l...
35,451
<p>The following is okay:</p> <pre><code>try { Console.WriteLine(&quot;Before&quot;); yield return 1; Console.WriteLine(&quot;After&quot;); } finally { Console.WriteLine(&quot;Done&quot;); } </code></pre> <p>The <code>finally</code> block runs when the whole thing has finished executing (<code>IEnumer...
<p>I suspect this is a matter of practicality rather than feasibility. I suspect there are very, very few times where this restriction is <em>actually</em> an issue that can't be worked around - but the added complexity in the compiler would be very significant.</p> <p>There are a few things like this that I've alread...
<p>I would speculate that because of the way the call stack gets wound/unwound when you yield return from an enumerator it becomes impossible for a try/catch block to actually "catch" the exception. (because the yield return block is not on the stack, even though he originated the iteration block)</p> <p>To get an ide...
45,071
<p>How does selenium work? Can you explain the internal working of it.</p>
<p>First there's a layer of javascript code that is used to automate the browser and simulate events, run and verify tests. Next, you run a proxy server - which you point your browser to - that injects this javascript code. Then, you can talk to this proxy server through another port using a set of commands which cause...
<p>Basically it works on following principal . It first Searches for element which you specify in your <strong>Locator</strong> by searching it in HTML document shown in driver launched browser . After finding element it gets location of Object.After getting that location ROBOT Class methods like MOUSECLICK MOUSE Move...
13,816
<p>Microsoft Linq to SQL, Entity Framework (EF), and nHibernate, etc are all proposing ORMS as the next generation of Data Mapping technologies, and are claiming to be lightweight, fast and easy. Like for example this article that just got published in VS magazine:</p> <p><a href="http://visualstudiomagazine.com/featu...
<p>I have written data access layers, persistence components, and even my own ORMs in hundreds of applications over the years (one of my "hobbies"); I have even implemented my own business transaction manager (discussed elsewhere on SO).</p> <p>ORM tools have been around for a long time on other platforms, such as Jav...
<p>I have been following Fluent-NHibernate very closely as it has some of the most potential I've ever seen in a project.</p>
47,422
<p>This is probably a really stupid newbie-sounding question to you developer type people, but I'm at a loss :( I've been trying to learn how to use Subversion for keeping the history of my code, but I'm finding it pretty confusing. I read the 'book' that comes with Subversion, but I didn't find it all that helpful. I'...
<p>The recommended directory structure for a subversion repo contains three folders: "branches", "tags" and "trunk". So, create these folders somewhere convenient, in a new folder.</p> <p>Right click in the parent folder of these folders, go to TortoiseSVN and select Import. Enter the url to the repository you created...
<p>I found TortoiseSVN to be terribly confusing, especially in conjunction with the SVN Book. But then again, I'm not a very GUI oriented person.</p> <p>Work through the book using the command line SVN client, until you understand the basic concepts. Don't skip any chapters!</p> <p>Then you can evaluate GUIs, if you ...
15,164
<p>Let's say I have a list of server names stored in a vector, and I would like to contact them one at a time until one has successfully responded. I was thinking about using STL's find_if algorithm in the following way:</p> <pre><code>find_if(serverNames.begin(), serverNames.end(), ContactServer()); </code></pre> <p...
<p>I think I would go for it.</p> <p>The only thing I would worry about is the readability (and therefore maintainability) of it. To me, it reads something like "Find the first server I can contact", which makes perfect sense.</p> <p>You might want to rename <code>ContactServer</code> to indicate that it is a predica...
<p>Isn't that what <code>find_if</code> is for?</p> <p>Note though, that it will find <em>all</em> the servers, if you iterate over the iterator - but you aren't going to do that (according to OP).</p>
4,724
<p>Problem (simplified to make things clearer):</p> <ul> 1. there is one statically-linked static.lib that has a function that increments: <pre><code> extern int CallCount = 0; int TheFunction() { void *p = &CallCount; printf("Function called"); return CallCount++; } </code></p...
<p>My hunch was that, as you suspected, unmanaged DLLs are loaded in the context of the process and not in the context of the AppDomain, so any static data in unmanaged code is shared among AppDomains.</p> <p><a href="http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/98cbabe0-33d6-4775-a3a7-04e71b7498...
<p>In short, maybe. AppDomains are purely a managed concept. When an AppDomain is instantiated it doesn't map in new copies of the underlying DLLs, it can reuse the code already in memory (for example, you wouldn't expect it to load up new copies of all the System.* assemblies, right?)</p> <p>Within the managed wor...
9,837
<p>Code below does not run correctly and throws <code>InvalidOperationExcepiton</code>.</p> <pre><code>public void Foo() { DataContext context = new DataContext(); LinqEntity item = new LinqEntity(){ Id = 1, Name = "John", Surname = "Doe"} ; context.LinqEntities.Attach(item, true); } </code></pre>
<p>By default, the entities will use all fields for checking concurrency when making edits. That's what's throwing the InvalidOperationException.</p> <p>This can be setting the Update Check property for all fields to Never. This must be done on all fields to attach the entity as modified. If this is done, an additi...
<p>When using an ORM you typically select an object before updating it. </p> <p>You can use <code>DataContext.ExecuteCommand(...)</code> to bypass the ORM if you do not want to do a select. </p>
6,126
<p>I have a two years of experience of programming in Visual C# and Visual C++. I would like to know some good online sources to start learning ASP.NET or anything else I should/need to learn before diving into ASP.NET. I found some online videos that are proving to be quite useful. Perhaps I would like to know about s...
<p>Sorry, but I'm going to have to suggest the immediately obvious first:</p> <p><a href="http://www.asp.net" rel="noreferrer">Official Microsoft ASP .Net Site</a></p> <p>There's a link at the top to both "Get Started" and "Learn", and I have found this site incredibly useful over the past year or so.</p>
<p>Just to add, another great resource is <a href="http://www.learnvisualstudio.net" rel="nofollow noreferrer">www.learnvisualstudio.net</a></p> <p>Its not free but it has a plethora of videos covering all aspects of asp.net from 1.1 to 3.5, AJAX, Webservices.</p> <p>Programmer to Programmer style videos with great e...
33,668
<p>Grails scaffolding defaults to 10 rows per page. I would like to increase that number without generating the views and changing the 10 in every file. Where do I change the default?</p>
<p>You have to install scaffold templates with:</p> <p>grails install-templates</p> <p>Now, edit in src/templates/scaffolding Controller.groovy and increase the value params.max as you want</p>
<p>Add to the uri:</p> <pre><code>?max=&lt;num_rows_desired&gt; </code></pre> <p>For instance:</p> <pre><code>http://projecthost:8080/Library/Books/list?max=20 </code></pre>
8,234
<p>What does it mean if a task is declared with the automatic keyword in Verilog?</p> <pre><code>task automatic do_things; input [31:0] number_of_things; reg [31:0] tmp_thing; begin // ... end endtask; </code></pre> <p>Note: This question is mostly because I'm curious if there are any hardware programmers...
<p>It means that the task is re-entrant - items declared within the task are dynamically allocated rather than shared between different invocations of the task.</p> <p>You see - some of us do Verilog... (ugh)</p>
<p>In computing, a computer program or subroutine is called re-entrant if multiple invocations can safely run concurrently (Wikipedia). In simple words, the keyword automatic makes it safe, when multiple instances of a task run at a same time. :D</p>
5,559
<p>Is there a way to quickly list which sites are on which IP address in IIS 7? </p> <p>If I remember correctly you could sort a view of domains by IP in IIS 6 which was a big help to me in seeing which IPs I had available.</p>
<p>Take a look at <a href="http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe/#HowToUse" rel="noreferrer">APPCMD </a>.</p> <p>For example, to list all sites on the machine, use this command-line:</p> <pre><code> %systemroot%\system32\inetsrv\APPCMD list sites </code></pre>
<p>You can try this script:</p> <pre><code>MachineName = "localhost" IIsObjectPath = "IIS://" &amp; MachineName &amp; "/w3svc" WScript.Echo "Checking : " &amp; IISObjectPath Set IIsObject = GetObject(IIsObjectPath) for each obj in IISObject if (Obj.Class = "IIsWebServer") then BindingPath = IIsObjectPath...
30,148
<p>I'm an <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="noreferrer">ASP.NET</a> developer who has used <code>Microsoft SQL Server</code> for all my database needs (both at work and for personal projects). </p> <p>I am considering trying out the <a href="http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29" re...
<p>One thing you have to watch out for is the fairly severe differences in the way SQL&nbsp;Server and MySQL implement the SQL syntax.</p> <p>Here's a nice <a href="http://troels.arvin.dk/db/rdbms/" rel="noreferrer">Comparison of Different SQL Implementations</a>.</p> <p>For example, take a look at the top-n section....
<p>Spending some time working with MySQL from the MSSQL to MySQL syntax POV I kept finding myself limited in what I could do.</p> <p>There are bizzare limits on updating a table while refrencing the same table during an update.</p> <p>Additionally UPDATE FROM does not work and last time I checked they don't support t...
3,182
<p>I want to search for a line in a file, using regex, inside a Perl script.</p> <p>Assuming it is in a system with grep installed, is it better to:</p> <ul> <li>call the external <code>grep</code> through an <code>open()</code> command</li> <li><code>open()</code> the file directly and use a <code>while</code> loop ...
<p>In a modern Perl implementation, the regexp code should be just as fast as in grep, but if you're concerned about performance, why don't you simply try it out? From a code cleanliness and robustness standpoint, calling an external command line tool is definitely not good.</p>
<p>It depends.</p> <ul> <li>working inside Perl saves you the process startup time, and other related resource costs.</li> <li>grep is probably faster than doing the same job in Perl, but not hugely so.</li> </ul> <p>I'd say to do it in Perl unless performance forces you to optimize.</p>
47,683
<p>In the early days of SharePoint 2007 beta, I've come across the ability to customize the template used to emit the RSS feeds from lists. I can't find it again. Anybody know where it is?</p>
<p>OK, I think I have a solution:</p> <ul> <li>Generate the plugin via script/generate plugin</li> <li>change the Rakefile, and add</li> </ul> <p><code> require 'spec/rake/spectask'</p> <pre><code>desc 'Test the PLUGIN_NAME plugin.' Spec::Rake::SpecTask.new(:spec) do |t| t.libs &lt;&lt; 'lib' t.verbose = tru...
<p>For an example of an existing plugin that uses rspec, check out the <a href="http://github.com/technoweenie/restful-authentication/tree/master" rel="nofollow noreferrer">restful_authentication plugin</a>. Maybe it will help.</p>
10,789
<p>Among the data my application sends to a third-party SOA server are complex XMLs. The server owner does provide the XML schemas (<code>.xsd</code>) and, since the server rejects invalid XMLs with a meaningless message, I need to validate them locally before sending.</p> <p>I could use a stand-alone XML schema valid...
<p>It's a perfectly valid thinking to map error situations in the validation process to meaningful HTTP status codes. </p> <p>I suppose you send the XML file to your validation server as a POST content using the URI to determine a specific schema for validation.</p> <p>So here are some suggestions for error mappings:...
<p>That sounds like a neat idea, but the HTTP status codes don't really provide an "operation failed" case. I would return HTTP 200 with an <code>X-Validation-Result: true/false</code> header, using the body for any text or "reason" as necessary. Save the HTTP 4xx for HTTP-level errors, not application-level errors.<...
47,331
<p>When upgrading MySQL, I first create a backup of the database. Then I will uninstall the current version installed, and delete all the files that were left by the installer. Then I install the latest GA version, and restore the created back-up, using the MySQL Administrator.</p> <p>Is there a better way of doing an...
<p>you can dump the <code>mysql.user</code> and <code>mysql.db</code> tables, which contains all the user info, and reimport that as well, to avoid having to recreate all that. i'd also suggest running repairs on the table after you re-import.</p> <p>alternatively, you could create a listing of grants:</p> <pre><code...
<p>Why is the mysql upgrade so braindead? The fact that you need to back up all your data, install MySQL to a different directory, reimport your data -- just to upgrade is ridiculous. There has to be an easier way.</p>
31,462
<p>I am new to programming, and am wondering if there is a correct way to order your control structure logic.</p> <p>It seems more natural to check for the most likely case first, but I have the feeling that some control structures won't work unless they check everything that's false to arrive at something that's true...
<p>There is an excellent discussion of just this topic in McConnell's <em><a href="http://cc2e.com/" rel="nofollow noreferrer">Code Complete</a></em>. It's a book that I highly recommend. Anyway the relevant discussion is on pages 706-708 of the first edition or pg. 749-750 of second edition (thanks plinth). From t...
<p>Either / Or. I generally use the 'negative' approach though.</p> <p>if (!something) {</p> <p>}</p>
28,407
<p>neither</p> <pre><code>&lt;?php system('php file.php'); ?&gt; </code></pre> <p>nor</p> <pre><code>&lt;?php system('/usr/bin/php file.php'); ?&gt; </code></pre> <p>worked. Why?</p> <p>I tried with <code>-q</code>, with <code>!#/usr/bin/php</code> etc.</p>
<p>You are supposed to call it with -f, but it should work without it as well:</p> <pre><code>&lt;?php system('/usr/bin/php -f file.php'); ?&gt; </code></pre> <p>What do you mean by "it doesn't work"? </p> <p>Did you want the contents to be outputted as if they were from your script? Use <a href="http://php.net/incl...
<p>You obviously don't understand how <em>system</em> function works. What you really need is probably <a href="http://www.php.net/popen" rel="nofollow noreferrer">popen</a>. Start the process with <em>popen</em> and then read its output with <em>fgets</em> for example.</p> <p>Alternatively, you can use the backtick o...
23,949
<p>I have these 3 tables + data:</p> <p><strong>items</strong>: itemId, itemName <br />data: 1, my item one</p> <p><strong>categories</strong>: catId, catName <br />data: 1, my cat one. 2, my cat two</p> <p><strong>map</strong>: mapId, itemId, catId</p> <p>When you include item "my item one" in category "my cat one...
<p>Assuming you've already got the category ID for "my cat two" and the item ID for "my item 1":</p> <pre><code>DELETE FROM MAP WHERE ItemID = @MyItem1Id AND CatID &lt;&gt; @MyCat2Id </code></pre> <p>If you have a set of categories you want to keep the item in, you could either:</p> <ol> <li>Delete e...
<p>If you decide that an item should only be in the new category, the following should work:</p> <pre><code>DELETE M FROM Map M WHERE M.itemid = @item_id AND M.catid &lt;&gt; @new_cat_id </code></pre>
33,950
<p>I'm trying to do the following:</p> <ol> <li>User goes to web page, uploads XLS file</li> <li>use ADO .NET to open XLS file using JET engine connection to locally uploaded file on web server</li> </ol> <p>This all works fine locally (my machine as the client and the web server) - and in fact is working on the cust...
<p>Ok, figured it out -</p> <p>turns out that even with IIS using impersonation and the TMP/TEMP environment variables being set to C:\WINDOWS\Temp the ASP.NET process is still running under the ASPNET account and each individual user needed permissions to the Documents and Settings\ASPNET\Local Settings\Temp folder</...
<p>Go to the directory \Documents and Settings\"machineName"\ASPNET\Local Settings\Temp and give the read, write rights to the user "EveryOne" Then it will work fine. Moreover you have to set "" in web.config file</p>
19,145