instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Does anyone have an example (code or a link) that will allow me to export a gridview template field to excel? Here is an example of what I mean. Assume I have the following GridView Declaration:</p>
<pre><code><asp:GridView Id="gvResults" runat="server">
<Columns>
<asp:TemplateField Hea... | <p>Sure, although it's easier in the fluent syntax:</p>
<pre><code>var query_foo = db.Foo.Where(f=>f.Bar > 5);
// :
var foo =query_foo.Select(f=>SomeMethodThatReturnsEtc(f));
</code></pre>
| <blockquote>
<p>I guess my real question is, what's
the syntax of the SomeMethod()? –
Jonas (an hour ago)</p>
</blockquote>
<p>The way you want to do it, you can only return "object" from the method.</p>
| 49,192 |
<p>I've got a collection (List<Rectangle>) which I need to sort left-right. That part's easy. Then I want to iterate through the Rectangles in their <em>original</em> order, but easily find their index in the sorted collection. indexOf() won't work, since I may have a number of equal objects. I can't help feeling... | <p>I've found a solution - but perhaps there is a neater/more optimal one out there.</p>
<pre><code>List<Rectangle> originalRects = ...;
/* record index of each rectangle object.
* Using a hash map makes lookups efficient,
* and using an IdentityHashMap means we lookup by object identity
* not value.
*/
Ide... | <p>Clone the lists and sort one of them. Having two references of the same object is will not matter too much with indexOf() since the pointers to the same object are the same and you can't tell between them.
If you have two objects that are equal but not identical and you do want to distinguish between them then you ... | 25,360 |
<p>I'll get straight to the point!</p>
<p>My javascript sends about 20 AJAX requests to my PHP file to respond to (via an external web API) when the user submits their search. The results are stored in an array in the session array.</p>
<p>I've read that browsers will only allow 2 simultaneous requests to a server.</... | <p>I think you should start refactoring your solution:</p>
<ol>
<li>All the performance guidelines states that you should minimize the number of HTTP requests. 20 is too much</li>
<li>If you have a shared resource you need to lock an unlock the parts you manipulate it to prevent that two or more requests update it at ... | <p>Sorry it's not really the answer you're after but 20 requests sounds like far too much for a single search. Having implemented something similar ie. a brief search history stored in the session we opted not to use AJAX at all. There's a time and a place for it but not if it's going to kill your server with requests ... | 45,461 |
<p>This should be a really really simple thing, but for some reason it is just eluding me.</p>
<p>I want a Sharepoint page which will have a drop down list that is tied to a database lookup table. </p>
<p>When an item is selected and they click a GO button, I want it to update a gridview that is also on the page.</p... | <p>I currently use a drop down tied to one sharepoint list to filter a dataview of another sharepoint List.</p>
<p>The instructions are here:
<a href="http://blogs.msdn.com/sharepointdesigner/archive/2007/03/05/asp-net-controls-filter-the-data-view.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/sharepointdesign... | <p>I'm not exactly sure of the specific needs here, but it seems that you are trying to stretch a bit beyond what Sharepoint Designer is well suited to. To look up data, you do have access via the dataview web part, which is here:</p>
<p><a href="http://office.microsoft.com/en-us/sharepointdesigner/HA100948041033.asp... | 21,327 |
<p>As part of a wide ranging job for a cystic fibrosis support organization, they'd also like a web site set up and I've decided on Apache running on Linux (due to its security and low cost mostly). Other than (fairly) static content, they also want a forum where people can discuss issues with the condition - it'll be ... | <p><strong>Advantages</strong> to rolling your own:</p>
<ul>
<li>a non-standard custom-built system means you'll be less prone to "standard" attacks (e.g.: a vulnerability in PunBB) since bad guys tend to bother with exploit-hunting only on widely-deployed systems (more return on their investment)</li>
<li>absolute co... | <p>My answer would be: don't reinvent the wheel, there are plenty of fora software out there. My preference would go for <a href="http://rforum.andreas-s.net/" rel="nofollow noreferrer">RForum</a> if you need only that.</p>
| 48,936 |
<p>In the past, when I've worked on long-running C++ daemons I've had to deal with heap fragmentation issues. Tricks like keeping a pool of my large allocations were necessary to keep from running out of contiguous heap space. </p>
<p>Is this still an issue with a 64 bit address space? Perf is not a concern for me,... | <blockquote>
<p>Is this still an issue with a 64 bit address space?</p>
</blockquote>
<p>No, it is not still an issue.</p>
<p>You are correct that it was an issue on 32-bit systems, but it no longer is an issue on 64-bit systems.</p>
<p>The virtual address space is so large on 64-bit systems (2^48 bytes at the mom... | <p>If your process genuinely needs gigabytes of virtual address space, then upgrading to 64-bit really does instantly remove the need for workarounds.</p>
<p>But it's worth working out how much memory you expect your process to be using. If it's only in the region of a gigabyte or less, there's no way even crazy fragm... | 40,648 |
<p>I'm trying to design a form which contains a dropdown box containing a list of grocery item choices. </p>
<p>What criteria should I look at when trying to decide on whether to use a java enum or a lookup table? Also, I will need to plan ahead for i18n support for the dropdown strings.</p>
| <p>There is a line, somewhere... sharing library code is positively encouraged - but you need to be a <em>little</em> bit careful when apps consume each-other, simply to prevent spaghetti code and circular references.</p>
<p>If the code you mention is really library code (i.e. neither project is the "master" for this ... | <p>You should share everything (within the limits of common sense of course.) You are a team of developers, not a set of individual developers. Sharing code has numerous benefits: reusability means quicker development, simpler maintenance (you only need to fix a bug once), a new feature or improvement is potentially ab... | 27,273 |
<p>Today somebody told me that interface implementation in C# is just "Can-Do" relationship, not "Is-A" relationship. This conflicts with my long-time believing in LSP(Liskov Substitution Principle). I always think that all inheritance should means "Is-A" relationship. </p>
<p>So, If interface implementation is just a... | <p>In my experience it doesn't really help that much to think of "is-a" and "can-do" relationships. You rapidly get into problems. It's an impedance mismatch between the real world and OO, basically. However much people actually talk about modeling the real world, you fundamentally need to understand what the relations... | <p>The designers of the .NET framework use interfaces to designate a "has a" (or "can do") relationship, whereas "is a" is implemented using inheritance.</p>
<p>The rationale for this can be found in the <a href="http://msdn.microsoft.com/en-us/library/ms229013.aspx" rel="nofollow noreferrer">Choosing Between Classes ... | 31,901 |
<p>I'm creating some videos from a collection of images, I subsequently wish to play this video back with java. I found JMF but I haven't been able to find an encoding which is actually playable by it. Does anybody have an ffmpeg or mencoder formulation which produces JMF playable output? I would also take alternati... | <p>According to the <a href="http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/formats.html" rel="nofollow noreferrer">JMF 2.1.1 - Supported Formats</a> page, Quicktime and various codecs are supported for decoding directly.</p>
| <p>If you're not stuck with JMF, you could try <a href="http://www.xuggle.com/xuggler" rel="nofollow noreferrer">Xuggler</a>. It will encode almost all formats for you (one of the areas JMF just falls down on).</p>
<p>Here's a <a href="http://wiki.xuggle.com/MediaTool_Introduction#How_To_Take_Snapshots_Of_Your_Deskto... | 45,359 |
<p>Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd) that is only sized at 8.2 GB. I would like to double the size to something like 16-20GB. I see options for compacting the VHD but nothing to expand it. It's set to "dynamically expand" but I'm installing some software and it doesn't seem... | <p><a href="http://vmtoolkit.com/files/folders/converters/entry87.aspx" rel="nofollow noreferrer">VHD Resizer</a></p>
| <p>Never worked with Virtual PC but from other virtualization software I know I guess that dynamically expand means that initially the .vhd file will take less space in the HD than the specified and will dynamically grow as you keep installing programs or adding files into the virtual drive UP TO the specified size.</p... | 4,859 |
<p>I am sure to become a scrum master could really add value to the process I am following, however I believe that the background of the area of the application I am working on help more to get better planning and scheduling done for the project</p>
| <p>I just have an issue with the wording used here - in the question and responses. As a scrum master you would <strong>not</strong> be <strong>managing</strong> the project, or <strong>running</strong> it. The team runs the project in a self-directed way. The scrum master's role is to <strong>facilitate and coach</str... | <p>You probably would benefit from becomming a certified scrum master (i recently became one myself).</p>
<p>The scrum master shouldn't 'manage the scrums' but instead be there to facilitate the team - help it remove impediments. The team is self organizing and pretty much manages itself.</p>
| 21,655 |
<p>Under VS's external tools settings there is a "Use Output Window" check box that captures the tools command line output and dumps it to a VS tab.</p>
<p>The question is: <em>can I get the same processing for my program when I hit F5?</em></p>
<p><strong>Edit:</strong> FWIW I'm in C# but if that makes a difference ... | <p>I'm going to make a few assumptions here. First, I presume that you are talking about printf output from an application (whether it be from a console app or from a windows GUI app). My second assumption is the C language.</p>
<p><em>To my knowledge, you cannot direct printf output to the output window in dev stud... | <p>System.Diagnostics.Debug.Writeline() or Trace.Writeline()</p>
| 14,938 |
<p>My website is XHTML Transitional compliant <strong>except for one thing</strong>: the & (ampersand) in the URL are written as it is, instead of <code>&amp;</code></p>
<p>That is, all the URLs in my pages are usually like this:</p>
<pre><code><a href="http://www.example.org/page.aspx?x=1&y=2"... | <p>I have just tried this. What you attempted to do is correct. In HTML if you are writing a link the <code>&</code> characters should be encoded as <code>&amp;</code> You would only encode the <code>&</code> as <code>%26</code> if you wanted a parameter value to contain an ampersand. I just wrote a simp... | <p>The problem is worse than you think - try it in <a href="https://en.wikipedia.org/wiki/Safari_%28web_browser%29" rel="nofollow noreferrer">Safari</a>. <code>&amp;amp;</code> gets converted to <code>&amp;#38;</code> and the hash ends the URL.</p>
<p>The correct answer is to not output XHTML - there's no reas... | 34,676 |
<p>Can someone illustrate what really is the difference between the two?</p>
| <p>Even though they are two very different things, one can argue they <strong>both solve a software architecture problem</strong></p>
<ul>
<li><p>a design pattern solves many software architecture issues (about creation, behavior, concurrency, ...) with different pre-defined <em>design</em>. (design being an <a href="... | <p>Frameworks are more specific to a problem definition. In order to write one design patterns can be devised or used where ever applicable.</p>
| 41,405 |
<p>I've asked a few <a href="https://stackoverflow.com/questions/150513/html-input-style-to-hide-the-box-but-show-the-contents">other questions</a> here about this system, so I'll try to avoid repeating a lot of detail.</p>
<p>The short version is that I have many html pages, each with a form that accepts input, but n... | <p>The nearest equivalent is probably the <a href="http://labix.org/python-dateutil" rel="noreferrer">dateutil</a> module. Usage is:</p>
<pre><code>>>> from dateutil.parser import parse
>>> parse("Wed, Nov 12")
datetime.datetime(2008, 11, 12, 0, 0)
</code></pre>
<p>Using the fuzzy parameter should ... | <p>Why no give <a href="http://code.google.com/p/parsedatetime/" rel="nofollow noreferrer">parsedatetime</a> a try?</p>
| 36,228 |
<p>I'm trying to access the command line and execute a command, and then return the output to my aspx page. A good example would be running dir on page load of an aspx page and returning the output via Response.Write(). I have tried using the code below. When I try debugging this it runs but never finishes loading and ... | <p>You have a problem with the syntax of commandline arguments to cmd.exe. This is why cmd never exits.<br>
In order to have cmd.exe run a program and then quit, you need to send it the syntax "/c [command]". Try running the same code with the line</p>
<pre><code> si.StartInfo.Arguments = "dir";
</code></pre>
... | <p>This is madness! Use the System.IO namepace to create your file list from inside your C# program! It's very easy to do; although this technique also has authorization issues. </p>
| 30,765 |
<p>I am making a Python gui project that needs to duplicate the look of a Windows gui environment (ie Explorer). I have my own custom icons to draw but they should be selectable by the same methods as usual; click, ctrl-click, drag box etc. Are any of the gui toolkits going to help with this or will I have to impleme... | <p>Python has extensions for accessing the Win32 API, but good luck trying to re-write explorer in <em>that</em> by yourself. Your best bet is to use a toolkit like <a href="http://doc.trolltech.com/4.4/gallery-windowsxp.html" rel="nofollow noreferrer">Qt</a>, but you'll still have to write the vast majority of the app... | <p>I'll assume you're serious and suggest that you check out the many wonderful <a href="http://wiki.python.org/moin/GuiProgramming" rel="nofollow noreferrer">GUI libraries</a> available for Python.</p>
| 17,500 |
<p>Can/Should I use a LIKE criteria as part of an INNER JOIN when building a stored procedure/query? I'm not sure I'm asking the right thing, so let me explain.</p>
<p>I'm creating a procedure that is going to take a list of keywords to be searched for in a column that contains text. If I was sitting at the console, I... | <p>Your first query will work but will require a full table scan because any index on that column will be ignored. You will also have to do some dynamic SQL to generate all your LIKE clauses.</p>
<p>Try a full text search if your using SQL Server or check out one of the <a href="http://lucene.apache.org/java/docs/in... | <p>Performance will be depend on the actual server than you use, and on the schema of the data, and the amount of data. With current versions of MS SQL Server, that query should run just fine (MS SQL Server 7.0 had issues with that syntax, but <a href="http://support.microsoft.com/kb/225093" rel="nofollow noreferrer">... | 4,085 |
<p>I'm currently writing a C# application that does a lot of digital signal processing, which involves a lot of small fine-tuned memory xfer operations. I wrote these routines using unsafe pointers and they seem to perform much better than I first thought. However, I want the app to be as fast as possible.</p>
<p>Woul... | <p>I've actually done pretty much exactly what you're asking, only in an image processing area. I started off with C# unsafe pointers, then moved into C++/CLI and now I code everything in C++. And in fact, from there I changed from pointers in C++ to SSE processor instructions, so I've gone all the way. Haven't reached... | <p>I would suggest that if you have any algorithms in your DSP code that <strong>need</strong> to be optimised then you should really be writing them in assembly, not C or C++.</p>
<p>In general, with modern processors and hardware, there aren't that many scenarios that require or warrant the effort involved in optimi... | 32,719 |
<p>Is there any way to format a string by name rather than position in C#?</p>
<p>In python, I can do something like this example (shamelessly stolen from <a href="http://docs.python.org/lib/typesseq-strings.html" rel="noreferrer">here</a>):</p>
<pre><code>>>> print '%(language)s has %(#)03d quote types.' % ... | <p>There is no built-in method for handling this.</p>
<p><a href="http://mo.notono.us/2008/07/c-stringinject-format-strings-by-key.html" rel="noreferrer">Here's one method</a></p>
<pre><code>string myString = "{foo} is {bar} and {yadi} is {yada}".Inject(o);
</code></pre>
<p><a href="http://james.newtonking.com/archi... | <pre><code>string language = "Python";
int numquotes = 2;
string output = language + " has "+ numquotes + " language types.";
</code></pre>
<p>Edit:
What I should have said was, "No, I don't believe what you want to do is supported by C#. This is as close as you are going to get."</p>
| 19,239 |
<p>Whenever I run any jython program in Eclipse, I got the following error in the beginning of the output: </p>
<blockquote>
<p>" Failed to
get environment, environ will be
empty: (0, 'Failed to execute command
([\'sh\', \'-c\', \'env\']):
java.io.IOException: Cannot run
program "sh": Crea teProcess error=... | <p>Try to uncomment and change the os setting in the 'registry' file </p>
<p>(it is in the same directory as your jython.jar / i hope)</p>
<pre><code># python.os determines operating-specific features, similar to and overriding the
# Java property "os.name".
# Some generic values are also supported: 'nt', 'ce' and 'p... | <p>I ran into the same error, using Windows Vista, and Jython 2.5.1, under Eclipse/PyDev By editing javaos.py, to include "Windows Vista" in the OR statement in getOsType,;
I fixed the error. (I've filed a bug with the fix under the PyDev Tracker at SourceForge.)</p>
<p>Details:</p>
<p>I installed the full version ... | 30,492 |
<p>We are logging any exceptions that happen in our system by writing the Exception.Message to a file. However, they are written in the culture of the client. And Turkish errors don't mean a lot to me.</p>
<p>So how can we log any error messages in English without changing the users culture?</p>
| <p>This issue can be partially worked around. The Framework exception code loads the error messages from its resources, based on the current thread locale. In the case of some exceptions, this happens at the time the Message property is accessed.</p>
<p>For those exceptions, you can obtain the full US English version ... | <p>You should log the call stack instead of just error message (IIRC, simple exception.ToString() should do that for you). From there, you can determine exactly where the exception originated from, and usually deduce which exception it is.</p>
| 25,658 |
<p><strong>Problem:</strong> a table of coordinate lat/lngs. Two rows can potentially have the same coordinate. We want a query that returns a set of rows with unique coordinates (within the returned set). Note that <code>distinct</code> is not usable because I need to return the id column which is, by definition, dist... | <p>You might be able to use a CTE for this with the ROW_NUMBER function across lat and long and then use rand() against that. Something like:</p>
<pre><code>WITH cte AS
(
SELECT
intID,
ROW_NUMBER() OVER
(
PARTITION BY geoLat, geoLng
ORDER BY NEWID()
... | <p>Where did you get the idea that DISTINCT only works on one column? Anyway, you could also use a GROUP BY clause.</p>
| 46,215 |
<p>Just wondering if any of you guys know of any web-based/browser-based employee scheduling software/tools? </p>
<p>Currently doing it all in Excel, but it just isnt intelligent enough... any product suggestions?</p>
<p>Needs to handle multiple employees time over weeks and months... to schedule in work short-term a... | <p>My girlfriend's employer uses: <a href="http://www.hotschedules.com/" rel="nofollow noreferrer">http://www.hotschedules.com/</a> from what I have seen it seems to be pretty feature-complete...</p>
| <p>I love WSS (Windows Sharepoint Services). It's free and installs on W2K3 or W2K8 Server. Very easy to use out of the box. And easily customizable. With Intelligantt you can publish your MS Project files there as well. Then by plugging in Microsoft Office Sharepoint Designer you can built some custom workflows. ... | 38,402 |
<p>ASP.NET ASMX service occasionally throws exceptions. However, global.asax Application_Error method do not seem to catch them. The question is, how to configure global error handler to catch and log these exceptions?</p>
| <p>Basic problem (well it is not a problem) with ASMX web service is that any exception behind the service layer is thrown as SOAP exception to client. You need to catch SOAP exception and then look for inner exception there.</p>
<p>A better and clean approach is you implement SOAP handler in your application. Seriali... | <p>Is it the ASMX or the AJAX JavaScript which is throwing the exception? </p>
<p>If it's the Javascript, you'll need to write exception handling into your JS, and then push that back to the server to be tracked in your error datastore--possibly via another call to your webservice.</p>
<p>If it's the ASMX then it's ... | 24,551 |
<p>Is it recommended that I use an <a href="http://en.wikipedia.org/wiki/Initialization_vector" rel="noreferrer">initialization vector</a> to encrypt/decrypt my data? Will it make things more secure? Is it one of those things that need to be evaluated on a case by case basis?</p>
<p>To put this into actual context, th... | <p>An IV is essential when the same key might ever be used to encrypt more than one message.</p>
<p>The reason is because, under most encryption modes, two messages encrypted with the same key can be analyzed together. In a simple stream cipher, for instance, XORing two ciphertexts encrypted with the same key results... | <p>The IV allows for plaintext to be encrypted such that the encrypted text is harder to decrypt for an attacker. Each bit of IV you use will double the possibilities of encrypted text from a given plain text.</p>
<p>For example, let's encrypt 'hello world' using an IV one character long. The IV is randomly selected t... | 9,153 |
<p>I am trying to figure out how a library works and I would like to be able to visualize which methods and lines of code are executed in response to user input (e.g. a keypress or mouse click). Is there a way to do this in .NET?</p>
| <p>There's a wonderful, free tool from Microsoft called <a href="http://research.microsoft.com/Pex/" rel="nofollow noreferrer">Pex</a>. Once installed, you can right-click a method and select "Run Pex Exploration". It will analyze the code and show you inputs to touch every part of the method.</p>
<p>For more informat... | <p>If you are able to execute the action you want to analyze from within an NUnit test, you can use the NCover utility to visualize which parts of the code were executed and which weren't.</p>
<p><a href="http://www.ncover.com/" rel="nofollow noreferrer">http://www.ncover.com/</a></p>
<p>Hope this helps!</p>
<p>Adam... | 33,759 |
<p>Say you've got a credit card number with an expiration date of 05/08 - i.e. May 2008.</p>
<p>Does that mean the card expires on the morning of the 1st of May 2008, or the night of the 31st of May 2008?</p>
| <p>It took me a couple of minutes to find a site that I could source for this.</p>
<blockquote>
<p>The card is valid until the last day of the month indicated, after the last [sic]<sup>1</sup>
day of the next month; the card cannot be used to make a purchase if the
merchant attempts to obtain an authorization.
... | <p>In your example a credit card is expired on 6/2008.</p>
<p>Without knowing what you are doing I cannot say definitively you should not be validating ahead of time but be aware that sometimes business rules defy all logic.</p>
<p>For example, where I used to work they often did not process a card at all or would co... | 7,761 |
<p>Are there any replacements for NUnitAsp that anyone knows of for testing ASP.NET pages?</p>
| <p>You can use <a href="http://watin.sourceforge.net/" rel="nofollow noreferrer">WatiN</a> or <a href="http://code.google.com/p/ieunit/" rel="nofollow noreferrer">IEUnit</a>.</p>
| <p>Please note that both IeUnit and WatiN are discontinued.</p>
<p>Using Selenium directly in tests is not a good idea, as you may probably need to <a href="http://toolsqa.com/selenium-webdriver/c-sharp/encapsulation-oops-principle/" rel="nofollow noreferrer">encapsulate page objects</a>.</p>
<p>I'd recommend to use th... | 32,511 |
<p>I'm looking for some useful books for a beginner who wants to better understand the Sun JVM</p>
| <p>Not specific to the Sun Java Virtual Machine implementation, but <a href="http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html" rel="nofollow noreferrer">The Java Virtual Machine Specifications</a> from Sun may be an interesting read.</p>
| <p><a href="http://en.wikipedia.org/wiki/Java_Virtual_Machine" rel="nofollow noreferrer">wikipedia - JVM</a></p>
<blockquote>
<p>A Java Virtual Machine (JVM) is a set of computer software programs and data structures which use a virtual machine model for the execution of other computer programs and scripts. The model u... | 45,798 |
<p>First off, this question is ripped out from <a href="https://stackoverflow.com/questions/56215/interesting-interview-questions#56291">this</a> question. I did it because I think this part is bigger than a sub-part of a longer question. If it offends, please pardon me.</p>
<p>Assume that you have a algorithm that ge... | <p>Statistics. The de facto standard for testing RNGs is the <a href="https://web.archive.org/web/20150103230339/http://stat.fsu.edu/pub/diehard/" rel="nofollow noreferrer">Diehard suite</a> (originally available at <a href="http://stat.fsu.edu/pub/diehard" rel="nofollow noreferrer">http://stat.fsu.edu/pub/diehard</a>... | <p>Pondering it myself, what I would do is something like:</p>
<p>Setup (Pseudo code)</p>
<pre><code>// A card has a Number 0-51 and a position 0-51
int[][] StatMatrix = new int[52][52]; // Assume all are set to 0 as starting values
ShuffleCards();
ForEach (card in Cards) {
StatMatrix[Card.Position][Card.Number]++... | 8,033 |
<p>In a few large projects i have been working on lately it seems to become increasingly important to choose one or the other (XML or Annotation). As projects grow, consistency is very important for maintainability. </p>
<p>My questions are: what are the advantages of XML-based configuration over Annotation-based conf... | <p>Annotations have their use, but they are not the one silver bullet to kill XML configuration. I recommend mixing the two!</p>
<p>For instance, if using Spring, it is entirely intuitive to use XML for the dependency injection portion of your application. This gets the code's dependencies away from the code which w... | <p>This is the classic 'Configuration versus Convention' question. Personal taste dictates the answer in most cases. However, personally I prefer Configuration (i.e. XML based) over Convention. IMO IDE's are sufficiently robust enough to overcome some of the XML hell people often associate w/ the building and mainta... | 22,042 |
<p>Is there a way to execute SQL custom functions with Enterpise Library? I've tried Database.ExecuteScalar() but for some reason it returns null.</p>
<p>This is my function:</p>
<pre><code>Database db = DatabaseFactory.CreateDatabase("ConnectionString");
DbCommand cmd = db.GetStoredProcCommand("FunctionName");
db.Ad... | <p>You have to create a select statement which selects the result from the function and execute that.</p>
<p>"SELECT * FROM FunctionName(@Value1, @Value2)"</p>
<p>Or you can wrap your function call in a procedure and call the procedure, I prefer this.</p>
| <p>For scalar functions it would be</p>
<pre><code>SELECT FuncName(@Param1)
</code></pre>
<p>whereas a Table-Valued Function would be</p>
<pre><code>SELECT * FROM FuncName(@Param1)
</code></pre>
| 32,040 |
<p>I have an ASP.NET web page that displays a variety of fields that need to be updated best on certain conditions, button clicks and so on. We've implemented AJAX, using the ASP.NET Update Panel to avoid visible postbacks.</p>
<p>Originally there was only <em>one</em> area that needed this ability ... that soon expan... | <p>Multiple panels are much better. One of the main reasons for using UpdatePanels at all is to reduce the traffic and to only send the pieces that you need back and forth across the wire. By only using one update panel, you're pretty much doing a full post back every time, you're just using a little Javascript to up... | <p>Not sure about the best practices, but in my experience multiple panels work well, and reduce the amount of data being sent at one time - resulting in an increase in response time overall. Multiple panels also reduce the complexity of each server call.</p>
| 9,814 |
<p>What's the easiest way to use a linked list in python? In scheme, a linked list is defined simply by <code>'(1 2 3 4 5)</code>. Python's lists, <code>[1, 2, 3, 4, 5]</code>, and tuples, <code>(1, 2, 3, 4, 5)</code>, are not, in fact, linked lists, and linked lists have some nice properties such as constant-time conc... | <p>For some needs, a <a href="https://docs.python.org/library/collections.html#collections.deque" rel="noreferrer">deque</a> may also be useful. You can add and remove items on both ends of a deque at O(1) cost.</p>
<pre><code>from collections import deque
d = deque([1,2,3,4])
print d
for x in d:
print x
print d.... | <p>My 2 cents </p>
<pre><code>class Node:
def __init__(self, value=None, next=None):
self.value = value
self.next = next
def __str__(self):
return str(self.value)
class LinkedList:
def __init__(self):
self.first = None
self.last = None
def add(self, x):
... | 35,431 |
<p>I am pretty sure that the settings that I am using are correct, so all possible things can be wrong which I should check out so that I can make authentication with our Active Directory work.</p>
| <p>Try test if PHP can connect to active directory</p>
<pre><code><?php
$ds = ldap_connect('host.ad.lan', 389);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
ldap_bind($ds, 'admin@ad.lan', 'xxx');
$sr = ldap_search($ds, 'CN=Cameron Zemek,OU=Users,OU=BRC,DC=ad,DC=la... | <p>@grom... thanks but, yes PHP is working just fine. I have a WordPress and a MediaWiki installation on the same server, and they are both authenticating against the same active directory just fine.</p>
| 6,254 |
<p>How can I check whether a variable is defined in Ruby? Is there an <code>isset</code>-type method available?</p>
| <p>Use the <code>defined?</code> keyword (<a href="http://ruby-doc.org/docs/keywords/1.9/Object.html#method-i-defined-3F" rel="noreferrer">documentation</a>). It will return a String with the kind of the item, or <code>nil</code> if it doesn’t exist.</p>
<pre><code>>> a = 1
=> 1
>> defined? a
=> "l... | <p>Also, you can check if it's defined while in a string via interpolation, if you code: </p>
<pre><code>puts "Is array1 defined and what type is it? #{defined?(@array1)}"
</code></pre>
<p>The system will tell you the type if it is defined.
If it is not defined it will just return a warning saying the variable is not... | 36,757 |
<p>What are some good resources to learn best practices for Javascript? I'm mainly concerned about when something should be an object vs. when it should just be tracked in the DOM. Also I would like to better learn how to organize my code so it's easy to unit test.</p>
| <p>Seconding <a href="http://oreilly.com/catalog/9780596517748/" rel="noreferrer">Javascript: The Good Parts</a> and Resig's book <a href="http://jsninja.com/" rel="noreferrer">Secrets of the Javascript Ninja</a>.</p>
<p>Here are some tips for Javascript:</p>
<ul>
<li>Don't pollute the global namespace (put all funct... | <p>You can pick up a lot from <a href="https://rads.stackoverflow.com/amzn/click/com/1590597273" rel="nofollow noreferrer" rel="nofollow noreferrer">Pro JavaScript Techniques</a>, and I'm looking forward to Resig's forthcoming <a href="http://jsninja.com/" rel="nofollow noreferrer">Secrets of the JavaScript Ninja</a>.<... | 6,080 |
<p>I need to get a count of the number of files in a directory. I could get the names of all the files in the directory using <code>System.IO.Directory.GetFiles()</code> and take the length of that array but that takes too long on large directories. Is there a way to get just the count without having to get the names... | <p>I don't believe so, no - at least not in vanilla .NET. I suspect it's not the actual fetching of the names that takes the time - it's the OS walking through the directory internals. There <em>may</em> be a Win32 call you could make via P/Invoke.</p>
<p>How large is the directory you're looking at? In general it's a... | <p>So far, in most languages I came across, you get this information only by walking the folder and counting the files. I doubt there is a Windows API call to get only the count (but I can be surprised!).<br>
Advantage of the method: flexibility - you can filter out some file types, walk down recursively or ignore fold... | 45,444 |
<p>I am new to the world of ASP.NET and SQL server, so please pardon my ignorance ...</p>
<p>If I have a data structure in C# (for e.g. let's just say, a vector that stores some strings), is it possible to store the contents of the vector as is in SQL table? I want to do this so that it fast to convert that data back ... | <p>First, there is the obvious route of simply creating a relational structure and mapping the object to fields in the database.</p>
<p>Second, if you have an object that is serializable, you can store it in SQL server. I have done this on occasion, and have used the Text data type in SQL Server to store the XML. </... | <p>I have more experience with relational databases than c#, but binary serialization is an acceptable way to go, as it allows the entire object's state to be saved into the database. XML serialization is pretty much the same, although generic types are not allowed.</p>
| 26,694 |
<p>I have a control that is modelled on a <strong>ComboBox</strong>. I want to render the control so that the control <strong>border</strong> looks like that of a standard <strong>Windows ComboBox</strong>. Specifically, I have followed the MSDN documentation and all the rendering of the control is correct except for r... | <p>I'm not 100% sure if this is what you are looking for but you should check out the <strong>VisualStyleRenderer</strong> in the System.Windows.Forms.VisualStyles-namespace.</p>
<ol>
<li><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstylerenderer.aspx" rel="noreferrer">Visua... | <p>Are any of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.controlpaint_members.aspx" rel="nofollow noreferrer">ControlPaint</a> methods useful for this? That's what I usually use for custom-rendered controls.</p>
| 2,503 |
<p>ShellExecute() allows me to perform simple shell tasks, allowing the system to take care of opening or printing files. I want to take a similar approach to sending an email attachment programmatically.</p>
<p>I don't want to manipulate Outlook directly, since I don't want to assume which email client the user uses ... | <p>This is my MAPI solution:</p>
<pre><code>#include <tchar.h>
#include <windows.h>
#include <mapi.h>
#include <mapix.h>
int _tmain( int argc, wchar_t *argv[] )
{
HMODULE hMapiModule = LoadLibrary( _T( "mapi32.dll" ) );
if ( hMapiModule != NULL )
{
LPMAPIINITIALIZE lpfnMAP... | <p>You'll need to implement a <a href="http://msdn.microsoft.com/en-us/library/ms527046.aspx" rel="nofollow noreferrer">MAPI client.</a> This will let you prefill the document, add attachments, etc.. before presenting the message to the user to send off. You can use the default message store to use their default mail... | 32,854 |
<p>I'm working on a web app that needs an ActiveX control to function. It installs just fine when the user has admin privileges, but fails to load otherwise. Is this by design and if so, is this documented somewhere? (preferably MSDN)</p>
| <p>Actually, none of these answers are completely correct; if you install an ActiveX control in a per-user basis it will work just fine without Administrative privileges, regardless of the group that the user is in. Bascially this involves installing it to HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE.</p>
<p>Depend... | <p><strong>Complex answer: Yes.</strong> The user's account needs to be part of a group that affords the privelege of registering libraries (dll) or controls (ocx) or needs to be directly assigned the privelege.</p>
<p><strong>Simple answer: No.</strong> Only accounts with the administrative privelege to install OCXs... | 43,965 |
<p>I would like to create a link between a winMo device and a server, so that they can pass information back and forth to each other. I actually don't really know where to start, I've had SOAP, RPC and creating a TCP link suggested to me. If someone could provide a link to an example that would be great.</p>
<p>Thanks... | <p>Your best bet is to set up an ASP.NET web service on the server, and then have your PDA application talk to it.</p>
<p>You can also use the web service to talk back to the PDA. Essentially, the PDA has to initially call the web service and pass in a delegate method that the server then calls when it needs to talk ... | <p>I'm setting up a project doing exactly this, and I'm using a web service to do the talking. </p>
<p>You can also access SQL Server directly using <i>sqlClient</i>, synchronize data with the SQL Server 2005 Compact Edition "Remote Data Access" or use SQL Server Merge Replication. </p>
<p>I'm not sure what the diffe... | 28,940 |
<p>I know that jQuery and prototype have a $.each() function for iterating over each element in an array. Does YUI offer any help with this?</p>
| <p>What keeps you from simply <em>iterating</em> the array?</p>
<pre><code>for(var i=0; i<ary.length; i++)
// assuming that ary[] contains objects with a DoSometing() method
ary[i].doSomething();
</code></pre>
| <p>In YUI3:</p>
<pre><code>Y.Array.each(myArray, function(element) {
Y.log(element);
});
</code></pre>
<p>or even:</p>
<pre><code>Y.Array.each(myArray, function(element, index, array) {
...
});
</code></pre>
| 36,640 |
<p>I need to replace the standard Overflow function in a ToolStrip to a "More..." button which would then pop up a menu with the overflowed items. Does anyone have any ideas about how to accomplish this?</p>
| <p>I wrote something very similar to this awhile ago. The code I used is pasted below, and you are free to modify it to suit your needs. </p>
<p>The ToolStripCustomiseMenuItem is basically your "More" button that populates a DropDown Context Menu when clicked. Hope this helps you, at the very least this should be ... | <p>You can trap the paint event on the button by calling</p>
<pre><code>toolStrip1.OverflowButton.Paint += new PaintEventHandler(OverflowButton_Paint);
</code></pre>
<p>Which in theory should allow you to make it say "More...", but I was unable to set the width of the Overflow Button to be anything but the (narrow) d... | 29,101 |
<p>Does anyone have a method to understand complex SQL statements? When reading structural / OO code there are usually layers of abstraction that help you break it down into manageable chunks. Often in SQL, though, it seems that you have to keep track of what's going on in multiple parts of a query all at the same ti... | <p>When I look at a complex bit of SQL Code, this is what I do.</p>
<p>First, if it is an update or delete, I add code (if it isn't there and commented out) to make it a select. Never try an update or delete for the first time without seeing the results in a select first. If it is an update, I make sure the select sho... | <p>Query optimizers can handle a lot, including implementing your sub-query as a join. These days, they can even handle non-correlated sub-queries.</p>
<p>Clarity is more important than performance in most cases, and sub-queries are easier to debug.</p>
<p>BTW: why do you use confusing table aliases?</p>
| 49,657 |
<p>Is it possible to configure <a href="http://www.apachefriends.org/en/xampp.html" rel="noreferrer">xampp</a> to serve up a file outside of the <code>htdocs</code> directory?</p>
<p>For instance, say I have a file located as follows:</p>
<p><code>C:\projects\transitCalculator\trunk\TransitCalculator.php</code></p>
... | <p>Ok, per <a href="https://stackoverflow.com/questions/1408/#2471">pix0r</a>'s, <a href="https://stackoverflow.com/questions/1408/#1413">Sparks</a>' and <a href="https://stackoverflow.com/questions/1408/#1414">Dave</a>'s answers it looks like there are three ways to do this:</p>
<hr>
<h2><a href="https://stackoverfl... | <p>Solution to allow Apache 2 to host websites outside of htdocs:</p>
<p>Underneath the "DocumentRoot" directive in httpd.conf, you should see a directory block. Replace this directory block with:</p>
<pre><code><Directory />
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>... | 2,381 |
<p>If I query a table with a condition on the key field as in:</p>
<pre><code> var user = from u in dc.Users
where u.UserName == usn
select u;
</code></pre>
<p>I know that I will either get zero results or one result. Should I still go ahead and retrieve the results using ... | <p>Try something like this:</p>
<pre><code>var user = (from u in dc.Users
where u.UserName == usn
select u).FirstOrDefault();
</code></pre>
<p>The <a href="http://msdn.microsoft.com/en-us/library/bb549141.aspx" rel="noreferrer">FirstOrDefault</a> method returns the first element ... | <p>Another option is to use Contains(username) as opposed to "=="</p>
<pre><code>var user = (from u in dc.UserInfo
where u.Users.Contains(username)
select u).SingleOrDefault();
</code></pre>
| 25,058 |
<p>I'm planning to install Drupal. Is there any reason not to install the latest 6.x version as opposed to the 5.x branch? Are there any really good modules that are 5.x only?</p>
| <p>I've found enough modules to happily run my site on Drupal 6.x I think the only 5.x module I miss is one that did very easy Google ad integration, and that may have been updated I just haven't checked recently. I don't get enough traffic to make the ads worth the time in setting them up, so I just use the search p... | <p>The one significant CCK-related module that's not D6 production ready is <a href="http://www.drupal.org/project/filefield" rel="nofollow noreferrer">filefield</a>. This may not be an issue if you're not doing anything substantial with images and media, but might be worth considering if you're going to do any serious... | 13,530 |
<p>this c# code is probably not the most efficient but gets what I want done. </p>
<p>How do I accomplish the same thing in F# code?</p>
<pre><code> string xml = " <EmailList> " +
" <Email>test@email.com</Email> " +
" <Email>test2@email.com</Email... | <pre><code>let doc = new XmlDocument() in
doc.LoadXml xml;
doc.SelectNodes "/EmailList/Email/text()"
|> Seq.cast<XmlNode>
|> Seq.map (fun node -> node.Value)
|> String.concat Environment.NewLine
</code></pre>
<p>If you actually want the final trailing newline you can a... | <p>If you look at your code, you have a couple of things going on. The first is loading the collection for the Email nodes, and the second is actually doing something meaningful with them.</p>
<p>First, you'd want to have your function return a collection. Something like (and I'm on my Mac, so this may not work):</p>
... | 43,143 |
<p>I'm really new to .NET, and I still didn't get the hang about how configuration files work.</p>
<p>Every time I search on Google about it I get results about web.config, but I'm writing a Windows Forms application.</p>
<p>I figured out that I need to use the System.Configuration namespace, but the documentation is... | <p>You want to use an App.Config.</p>
<p>When you add a new item to a project there is something called Applications Configuration file. Add that.</p>
<p>Then you add keys in the configuration/appsettings section</p>
<p>Like:</p>
<pre><code><configuration>
<appSettings>
<add key="MyKey" value="fal... | <p>What version of .NET and Visual Studio are you using?</p>
<p>When you created the new project, you should have a file in your solution called <em>app.config</em>. That is the default configuration file.</p>
| 13,983 |
<p>I'm discovering a simple solution for singular-plural keywords searches. I heard about stemming but I don't want to use all its features, only plural/singular transformation. The language is Dutch. Have looked at <a href="http://www.snowball.tartarus.org" rel="nofollow noreferrer">http://www.snowball.tartarus.org</a... | <p>Use a dictionary, a list of stopwords (those you don't want to singularize) plus the rules for the language. If you don't know Dutch then I cannot help you, but show you how it'd be done in Spanish, for instance:</p>
<ul>
<li>Plurals end with s, if it doesn't then it's done
<ul>
<li>If it ends with s,
<ul>
<li>c... | <p>Stemmers caused much user annoyance, so if I use one of them, all functionality except singular/plural should be disabled. So the requirement is to use only plural/singular transformations.</p>
| 19,053 |
<p>I like <a href="http://code.msdn.microsoft.com/sourceanalysis" rel="noreferrer">StyleCop</a>'s static code analysis and rules enforcement. However, it is severely lacking in several key departments. </p>
<ul>
<li>Adding new rules isn't officially supported and from what I hear pretty difficult.</li>
<li>Automatic... | <p>Adding rules is, or is going to be, <a href="http://blogs.msdn.com/sourceanalysis/archive/2008/08/19/stylecop-4-3-is-released.aspx" rel="noreferrer">officially supported</a>:</p>
<blockquote>
<p>As promised, we will also be releasing
SDK documentation for StyleCop
explaining how to author custom rules
and h... | <p>I often write unit tests to reflect over my types and check for violations of my custom rules.</p>
<p>Here's an example for verifying that certain types are immutable: <a href="http://blogs.msdn.com/kevinpilchbisson/archive/2007/11/20/enforcing-immutability-in-code.aspx" rel="nofollow noreferrer">http://blogs.msdn.... | 36,360 |
<p>I'm using Apache.</p>
<p>I'm auto gzipping my HTML & CSS files on the fly using the following directive in my .htaccess file.</p>
<pre><code># Enable ETag
FileETag MTime Size
# Set expiration header
ExpiresActive on
ExpiresDefault "access plus 1 year"
ExpiresByType image/gif A2592000
ExpiresByType image/png ... | <p>I figured it out, looks like I need it to be:</p>
<pre><code>AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript text/javascript application/javascript
</code></pre>
<p>To get javascript to compress/gzip</p>
| <p>Have you declared the text/javascript MIME type in Apache? If your server configuration points to, say, a <code>mime.types</code> file with one of these:</p>
<pre><code>TypesConfig /private/etc/apache2/mime.types
</code></pre>
<p>then said file should include this line:</p>
<pre><code>application/javascript ... | 48,870 |
<p>I have a dataset that contains 2 datatables they link together using a DataRelation.</p>
<p>it it possible to select from those tables into into one result set? </p>
<p>thanks,
Ofer</p>
| <p>Microsoft's suggestion is to create a helper class. See:</p>
<p><a href="http://support.microsoft.com/kb/326080/en-us" rel="nofollow noreferrer">http://support.microsoft.com/kb/326080/en-us</a></p>
<p>This is a general purpose tool that can be used no matter what the source.</p>
| <p>You can create JOIN tables with the VS DataSet editor, whcih combine your results - you can then write Select queries against that and call them from within your app.</p>
<p>To do it, simply create a new TableAdapter, then add BOTH tables into the editor (use the visual one), and select the fields you want to use f... | 33,333 |
<p>What is a good challenge to improve your skills in object oriented programming?</p>
<p>The idea behind this poll is to provide an idea of which exercises are useful for learning OOP.</p>
<p>The challenge should be as language agnostic as possible, requiring either little or no use of specific libraries, or only th... | <p><a href="https://www.itmaybeahack.com/homepage/books" rel="nofollow noreferrer">Building Skills in Object-Oriented Design</a> is a free book that might be of use.</p>
<p>The description is as follows:</p>
<p>"The intent of this book is to help the beginning designer by giving them a sequence of interesting and ... | <p>A given task has very little to do with being "OOP", it's more in how you grade it.</p>
<p>I would look at the Refactoring book, chapter 3, and make sure none of the bad code smells exist in the solution. Or, more importantly, go over ones that do apply.</p>
<p>Most importantly, watch for the existence of setters... | 8,492 |
<p>My application runs under CF 2.0 locally and i would like to know how to connect and send something to print in the embedded printer of a http://www.milliontech.com/home/content/view/195/95/'>Bluebird BIP-1300 device.</p>
<p>Ideally i would like an example in C#.</p>
<p>Thank you in advance.</p>
| <p>I'm not familiar with this particular device, but in general, printers in this class require you to send RAW data, as they don't have Windows drivers.</p>
<p><a href="http://support.microsoft.com/kb/322091" rel="nofollow noreferrer">This KB article</a> outlines how to send data to the device using C#: whether this ... | <p>Use bbpdaapi.dll (search by google)
and in c#</p>
<pre><code>using Bluebird.BIP.Printer;
...
this.prn1 = new Bluebird.BIP.Printer.Printer();
if (!this.prn1.Open(0))
{
MessageBox.Show("Can not open Printer", "Printer problem");
}
this.prn1.PrintText("sdfgidfui", 0);
this.prn1.... | 22,032 |
<p>I need to include a copyright statement at the top of every Python source file I produce:</p>
<pre><code># Copyright: © 2008 etc.
</code></pre>
<p>However, when I then run such a file I get this message:</p>
<p>SyntaxError: Non-ASCII character '\xa9' in file MyFile.py on line 3, but no encoding declared; see <a... | <p>The copyright symbol in ASCII is spelled <code>(c)</code> or "<code>Copyright</code>".</p>
<p>See circular 61, <a href="http://www.copyright.gov/circs/circ61.pdf" rel="noreferrer">Copyright Registration for Computer Programs</a>. </p>
<p>While it's true that the legal formalism (see Circular 1, <a href="http://ww... | <p>You can always revert to good old (c)</p>
| 27,280 |
<p>Let's say:</p>
<pre><code><div>
pre text
<div class="remove-just-this">
<p>child foo</p>
<p>child bar</p>
nested text
</div>
post text
</div>
</code></pre>
<p>to this:</p>
<pre><code><div>
pre text
<p>child foo</p>
<p&g... | <p>Using <a href="http://jquery.com/" rel="noreferrer">jQuery</a> you can do this:</p>
<pre><code>var cnt = $(".remove-just-this").contents();
$(".remove-just-this").replaceWith(cnt);
</code></pre>
<p>Quick links to the documentation:</p>
<ul>
<li><a href="http://docs.jquery.com/Traversing/contents" rel="noreferrer"... | <p>if you'd like to do this same thing in pyjamas, here's how it's done. it works great (thank you to eyelidness). i've been able to make a proper rich text editor which properly does styles without messing up, thanks to this.</p>
<pre><code>def remove_node(doc, element):
""" removes a specific node, adding its ... | 20,518 |
<p>This is a follow-up question to <a href="https://stackoverflow.com/questions/369220/why-should-you-not-use-number-as-a-constructor">this one</a>.</p>
<p>Take a look at these two examples: </p>
<pre><code>var number1 = new Number(3.123);
number1 = number1.toFixed(2);
alert(number1);
var number2 = 3.123;
number2 =... | <p>Technically, no. You can treat it like it is a method of the primative value, because number2 is will be converted to a <code>Number</code> object, then <code>toFixed</code> is gets called on that object.</p>
<p>The same thing happens when you call methods on strings.</p>
<p>To illustrate what's happening, you can... | <p>Calling a method on a literal value or variable initialized with a primitive value has the same effect as first coercing the value to an Object of appropriate type and then calling the method on it. The following experiment is better than trying to explain this in words:</p>
<pre><code>Object.prototype.getPrototype... | 48,249 |
<p>how can access the binary data file(.DAT). i am using geonames API. can anyone help me? </p>
| <p>If you are referring to the binary flat file format used by MaxMinds GeoLocation database, they offer some handy utility classes in C# and Java to access it.</p>
<p><a href="http://www.maxmind.com/app/api" rel="nofollow noreferrer">http://www.maxmind.com/app/api</a></p>
| <p>Assuming you are using C# (from the tag), you can use <a href="http://msdn.microsoft.com/en-us/library/system.io.binaryreader.aspx" rel="nofollow noreferrer"><code>BinaryReader</code> class</a> to read binary data. See <a href="http://www.tanguay.info/web/codeExample.php?id=817" rel="nofollow noreferrer">How to read... | 42,188 |
<p>I've been trying to refactor a "bit" of code that I'd previously developed. Basically, the project was my response to not knowing how to use XSLT effectively, so I developed an XML transformation system in PHP. The program reads through the tags of an XML file and does something along these lines to convert it to HT... | <p>caveat: i don't know PHP, but I can <a href="http://us3.php.net/manual/en/functions.variable-functions.php" rel="nofollow noreferrer">google</a> and i like function pointers better than huge switch statements, so if you can't just use XSLT...</p>
<p>...one option would be to adopt a naming convention for your 'work... | <p>Try something like this:</p>
<pre>
//utils.php
function handle_box($node)
{
//...
}
function handle_link($node)
{
//....
}
?\>
</pre>
<p>then:</p>
<pre>
require_once 'templates/utils.php';
function getTemplate()
{
switch($node)
{
case "a" :
handle_link($node,$otherParams);
break;
}
... | 44,575 |
<p>I really feel that I should learn <a href="http://en.wikipedia.org/wiki/Lisp_(programming_language)" rel="noreferrer">Lisp</a> and there are plenty of good resources out there to help me do it.</p>
<p>I'm not put off by the complicated syntax, but where in "traditional commercial programming" would I find places it... | <p>One of the main uses for Lisp is in Artificial Intelligence. A friend of mine at college took a graduate AI course and for his main project he wrote a "<a href="http://en.wikipedia.org/wiki/Lights_Out_(video_game)" rel="noreferrer">Lights Out</a>" solver in Lisp. Multiple versions of his program utilized slightly d... | <p>Syntax is irrelevant, readability is not!</p>
| 2,673 |
<p>How do I tell if my application (compiled in Visual Studio 2008 as <em>Any CPU</em>) is running as a 32-bit or 64-bit application?</p>
| <pre><code>if (IntPtr.Size == 8)
{
// 64 bit machine
}
else if (IntPtr.Size == 4)
{
// 32 bit machine
}
</code></pre>
| <p>In .Net Standard you can use <code>System.Runtime.InteropServices.RuntimeInformation.OSArchitecture</code></p>
| 33,363 |
<p>From the reading I've done I'm under the impression the DataContractSerializer handles versionong issues by, if members in the request are not there it will set the default value, and if addional members are in the request but not in the definition the serializer will simply ignores these fields and not process them... | <p>I ended up solving this in a thoroughly Rails fashion -- patching :attribute_fu to meet my needs. Hopefully I'll be able to release my patches to the community fairly soon.</p>
| <p>The behavior you describe above seems like it must be a bug in attribute_fu, since the local isn't getting properly passed along, which it definitely should. I'd be interested to know what you did to patch it.</p>
| 33,187 |
<p>I'm used to coding Java Swing UIs, and in those if you have some properties that change, and you want your UI to update, you would implement the observer/observable pattern. In Java you do this normally by having your class maintain a list of listeners that it notifies of different events.</p>
<p>I've played with O... | <p>There are two built-in ways of doing observation in Cocoa: Key-Value Observing and notifications. In neither system do you need to maintain or notify a collection of observers yourself; the framework will handle that for you.</p>
<p>Key-Value Observing (KVO) lets you observe a property of an object — including ev... | <p>That's not generally the way that it's done. Take a look at the discussion <a href="https://stackoverflow.com/questions/95567/is-there-any-benefit-to-using-cocoas-version-of-mvc-with-net">here</a>, in particular the link to the Apple documentation.</p>
<p>If you still want to do it the way you say you do, it's not p... | 20,023 |
<p>I user sun jdk 1.5 ThreadPoolExecutor( 24, 24,60,TimeUnit.SECONDS, new LinkedBlockingQueue()). soemtime I use jdb tool to find the status of all threads in thread pool are " waiting in a monitor", the code is : </p>
<pre><code> String key = getKey(dt.getPrefix(), id);
synchronized (key.intern()) { ----... | <p>I posted a related question to this once that you might want to take a look at: <a href="https://stackoverflow.com/questions/133988/problem-with-synchronizing-on-string-objects">Problem with synchronizing on String objects?</a></p>
<p>What I learned was: using intern'ed Strings for synchronization is a <strong>bad<... | <p>key.intern() guarantee uniqueness because key.intern() returns a string from String constants pool.</p>
<p><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#intern()" rel="nofollow noreferrer">http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#intern()</a>
intern</p>
<p>public St... | 45,408 |
<p>It is slow to load anything other than a small project. It is slow to quit; it can sometimes take minutes. It can be slow to open new files. The record macro feature used to be useful. It is now so slow to start up it's almost always quicker to do it manually!</p>
<hr>
<blockquote>
<p>More info would be helpful.... | <p>it might be that you have a plugin that is misbehaving. Try the <a href="http://msdn.microsoft.com/en-us/library/xee0c8y7(VS.80).aspx" rel="nofollow noreferrer">safemode</a> switch to see if this improves performance </p>
| <p>here's ya problem:</p>
<blockquote>
<p>3.2GHz P4 Hyperthreaded, 2GB RAM</p>
</blockquote>
<p>Hypertheaded means "doesn't actually have two CPU's, but it fakes it". If you have a process with just one thread running, then you get bad performance. It was a good short-term measure, but compared to having two REAL C... | 6,513 |
<p>Or more generally, how do I remove an item from a colon-separated list in a Bash environment variable?</p>
<p>I thought I had seen a simple way to do this years ago, using the more advanced forms of Bash variable expansion, but if so I've lost track of it. A quick search of Google turned up surprisingly few releva... | <p>A minute with awk:</p>
<pre><code># Strip all paths with SDE in them.
#
export PATH=`echo ${PATH} | awk -v RS=: -v ORS=: '/SDE/ {next} {print}'`
</code></pre>
<h3>Edit: It response to comments below:</h3>
<pre><code>$ export a="/a/b/c/d/e:/a/b/c/d/g/k/i:/a/b/c/d/f:/a/b/c/g:/a/b/c/d/g/i"
$ echo ${a}
/a/b/c/d/e:/a/... | <p>Let's "remove" references to /path/to/something from the PATH:</p>
<p>Bash:</p>
<pre><code>PATH=${PATH/something/nope/}
</code></pre>
<p>Bonus answer for Windows Batch:</p>
<pre><code>set PATH=%PATH:something=nope%
</code></pre>
<p>Anyone has a simpler solution? :)</p>
| 48,335 |
<p>I've got a siluation where i need to access a SOAP web service with WSE 2.0 security. I've got all the generated c# proxies (which are derived from Microsoft.Web.Services2.WebServicesClientProtocol), i'm applying the certificate but when i call a method i get an error:</p>
<pre><code>System.Net.WebException : The r... | <p>Ok, found what the problem was. I was trying to call a .wsdl url instead of .asmx url.
Doh!</p>
| <p>hmm are those other clients also using C#/.NET?</p>
<p>Method not allowed --> could this be a REST service, instead of a SOAP web service?</p>
| 18,250 |
<p>We develop Java Web-aps (Websphere, DB2) which display graphical and databased information. We would also like to offer the same application offline (distribution via CD/DVD) with online data-update. We have tried a number of alternatives in the past, but nothing has been really stable. What are the new best practic... | <p>I don't know how well it works with the CD/DVD distribution front, but the first thing that comes to mind is <a href="http://code.google.com/p/gears/" rel="nofollow noreferrer">Gears</a>. On the .NET side of the fence there's <a href="http://www.microsoft.com/silverlight/" rel="nofollow noreferrer">Silverlight 2</a>... | <p>You could create an image of your server as a VMware instance and distribute it with a copy of VMware player (licensing allowing of course). Personally I'd build it on top of a Linux distribution like CentOS5.</p>
| 42,901 |
<p>I've recently been exposed to the fluent interface in nUnit and I love it; however, I am using msTest. </p>
<p>Does anyone know if there is a fluent interface that is either testing framework agnostic or for msTest? </p>
| <p>See <a href="http://www.fluentassertions.com/" rel="nofollow noreferrer">Fluent Assertions</a>. You can do stuff like</p>
<pre><code>"ABCDEFGHI".Should().StartWith("AB").And.EndWith("HI").And.Contain("EF").And.HaveLength(9);
new[] { 1, 2, 3 }.Should().HaveCount(4, "because we thought we put three items in the
col... | <p>Based on my research there isn't one, but if your willing to sacrifice the better reportability as far as why an assert failed and willing to add a new dll you can reference nunit and use theirs....</p>
| 38,793 |
<p>I see many user interface control libraries for .NET, but where can I get similar stuff for win32 using simply C/C++?</p>
<p>Things like prettier buttons, dials, listviews, graphs, etc.</p>
<p>Seems every Win32 programmers' right of passage is to end up writing his own collection. :/</p>
<hr>
<p>No MFC controls... | <p>I've used <a href="http://trolltech.com/products/qt/" rel="noreferrer">Trolltech's Qt framework</a> in the past and had great success with it:
In addition, it's also cross-platform, so in theory you can target Win, Mac, & Linux (provided you don't do anything platform-specific in the rest of your code, of course... | <p>The MFC feature pack is derived from <a href="http://www.bcgsoft.com/" rel="nofollow noreferrer">BCGSoft components</a>.</p>
| 8,871 |
<p>I need generate <a href="https://stackoverflow.com/questions/27921/what-is-the-best-way-to-create-a-thumbnail-using-aspnet">thumbnails</a> for a bunch of jpegs (200,000+) but I want to make sure all of my thumbs have a equal height and width. However, I don't want to change the proportions of the image so I need to ... | <p>How about this. Maybe you should draw a black (or whichever color) rectangle on the Bitmap first.</p>
<p>And then when you are placing the resized image, just calculate the placement of the image based on whichever dimension is shorter, and then move that dimension by half the difference (and keep the other on 0... | <p>Like <strong>Vaibhav</strong> said, first paint the entire thumbnail area with black. This will be simpler than first fitting the image into the thumbnail and then determining which rectangles to paint black to achieve <a href="http://en.wikipedia.org/wiki/Pillarbox" rel="nofollow noreferrer">pillarboxing</a> or <a ... | 26,150 |
<p>I'm in the middle of building a D-Bot printer, and have run into a bit of an issue when it comes to the heat bed wires. The heated bed is an aluminum plate with a silicon heater attached to it, and the heater wires are not long enough to make it through the drag chain when the Z-axis is fully extended.</p>
<p>The ... | <p>750 W at 120 V is 6.3 A. 22-24 AWG is on the thin side for this. I would recommend 18 AWG or thicker. You don't need a specific style of insulation for this (other than something that is rated for the voltage and temperature the wire will need to withstand, but most commonly found wire should be good).</p>
<p>A goo... | <p>750 W at 120 V is around 6.3 A.</p>
<p>You can use a <a href="https://www.calculator.net/voltage-drop-calculator.html" rel="nofollow noreferrer">voltage drop calculator</a> to find out how much power is lost in the wires, and therefore their temperature increase.</p>
<p>I did it for you. With 10 feet (2x5 feet) 20A... | 1,685 |
<p>Hey right now I'm using jQuery and I have some global variables to hold a bit of preloaded ajax stuff (preloaded to make pages come up nice and fast):</p>
<pre><code>
$.get("content.py?pageName=viewer", function(data)
{viewer = data;});
$.get("content.py?pageName=artists", function(data)
{artists = data;});... | <p>You don't need <code>eval()</code> or <code>Function()</code> for this. An array, as you suspected, will do the job nicely:</p>
<pre><code>(function() // keep outer scope clean
{
// pages to load. Each name is used both for the request and the name
// of the property to store the result in (so keep them valid... | <p>You can call only one time that page, and returning a json object instead of text</p>
<pre><code>{
viewer:'me',
artists:'you',
instores:'instores',
specs:'specs',
about:'about'
}
</code></pre>
<p>and eval that
Since now you're calling N times your server, this slow down all, you should reconsider your logic!</p>
... | 24,657 |
<p>I'm trying to make an XML questions editor in flash.
Basically I load in the XML into a Tree component - XML like so:</p>
<pre><code><questions>
<question id="1" type="radio" text="This is question 1" isBranch="true">
<option id="1.1" correct="false" text="This is option 1" />
<option id="1... | <p>Take a look at ksh93, it supports associative arrays and is a much more complete/correct implementation of ksh.</p>
<p>See: <a href="http://kornshell.com/" rel="nofollow noreferrer">kornshell.com</a></p>
| <p>Why not just use bash? It might not have explicit associative arrays, but you can <a href="http://linuxshellaccount.blogspot.com/2008/05/how-to-fake-associative-arrays-in-bash.html" rel="nofollow noreferrer">fake them</a>.</p>
<p>Alternatively, zsh has <a href="http://zsh.dotsrc.org/Doc/Release/zsh_14.html#SEC72" r... | 44,477 |
<p>A customer sometimes sends POST requests with <code>Content-Length: 0</code> when submitting a form (10 to over 40 fields).</p>
<p>We tested it with different browsers and from different locations but couldn't reproduce the error. The customer is using Internet Explorer 7 and a proxy.</p>
<p>We asked them to let t... | <p>Internet Explorer does not send form fields if they are posted from an authenticated site (NTLM) to a non-authenticated site (anonymous).</p>
<p>This is feature for challange-response situations (NTLM- or Kerberos- secured web sites) where IE can expect that the first POST request immediately leads to an <em>HTTP 40... | <p>Google also shows this as an IE (some versions, anyway) bug after an https connection hits the keepalive timeout and reconnects to the server. The solution seems to be configuring the server to not use keepalive for IE under https.</p>
| 42,541 |
<p>I am using the WMD markdown editor in a project for a large number of fields that correspond to a large number of properties in a large number of Entity classes. Some classes may have multiple properties that require the markdown.</p>
<p>I am storing the markdown itself since this makes it easier to edit the fields... | <blockquote>
<p>The classes that require this are not part of a single inheritance hierarchy.</p>
</blockquote>
<p>They should at least implement a common interface, otherwise coming up with a clean generic solution is going to be cumbersome.</p>
<blockquote>
<p>The other option I am considering is doing this in ... | <p>You do have one option for doing this if you can't use inheritance or an interface. I know, I know refactor but this is reality and *hit happens.</p>
<p>You can use reflection to iterate over your properties and apply the formatting to them. You could either tag them with an attribute or you could adopt a naming sc... | 31,677 |
<p>I recently upgraded to Delphi 2009 and was disappointed to find out that I couldn't easily replace one VCL component with another. The best answer back was that <a href="http://www.gexperts.org" rel="nofollow noreferrer">GExperts</a> could be used to do this. </p>
<p>Is it worthwhile to petition Embarcadero to inco... | <p>What features in GExperts would you most like to be included in Delphi itself? I would suggest that you come up with prioritized list of your, say, top 10 features. Then pop on over to Quality Central (<a href="http://qc.codegear.com" rel="nofollow noreferrer">http://qc.codegear.com</a>) and see if they've already b... | <p>Most used features for me are: Grep Search and Replace Components.</p>
<p>But, i think it's not a good idea to include gExperts functionality in IDE at all. Because:</p>
<ol>
<li>gExperts are independent product
which can be easily installed in
less then minute</li>
<li>There are too much unfixed bugs in
QC, to sp... | 38,997 |
<p>As I learn more about Computer Science, AI, and Neural Networks, I am continually amazed by the cool things a computer can do and learn. I've been fascinated by projects new and old, and I'm curios of the interesting projects/applications other SO users have run into.</p>
| <p><a href="http://www.numenta.com/" rel="noreferrer">The Numenta Platform for Intelligent Computing</a>. They are implementing the type of neuron described in "On Intelligence" by Jeff Hawkins. For an idea of the significance, they are working on software neurons that can visually recognize objects in about 200 step... | <p><a href="http://alice.pandorabots.com/" rel="nofollow noreferrer">http://alice.pandorabots.com/</a>
- This bot is able to have pretty intelligent conversation with us.</p>
| 40,851 |
<p>I'm working on a project where we're doing a lot of remote object transfer between a Java service and clients written in other various languages. Given our current constraints I've decided to see what it would take to generate code based on an existing Java class. Basically I need to take a <code>.class</code> file ... | <p>I've used BCEL and find it really quite awkward. <a href="http://asm.objectweb.org/" rel="noreferrer">ASM</a> is much better. It very extensively uses visitors (which can be a little confusing) and does not create an object model. Not creating an object model turns out to be a bonus, as any model you do want to crea... | <p>I think javassist might help you too. </p>
<p><a href="http://www.jboss.org/javassist/" rel="nofollow noreferrer">http://www.jboss.org/javassist/</a></p>
<p>I have never had the need of using it, but if you give it a try, would you let us know your comments about it?</p>
<p>Although I think it is more for bytecod... | 19,873 |
<p>Tomcat fails to start even if i remove all my applications from the WEBAPPS directory leaving everything just like after the OS installation.</p>
<p>The log (catalina.out) says:</p>
<pre><code>Using CATALINA_BASE: /usr/share/tomcat5
Using CATALINA_HOME: /usr/share/tomcat5
Using CATALINA_TMPDIR: /usr/share/tomc... | <p>Seems like you've implemented a JMX service and tried to install it on your server.xml file but forgot to add the apache commons modeler jar to the server/lib directory (therefore the <code>ClassNotFoundException</code> for <code>org.apache.commons.modeler.Registry</code>). Check your server.xml file for anything yo... | <p>This screams class path issue, to me. Where exactly is your tomcat installed? (Give us command line printouts of where the home directory is.) Also, how are you starting it?</p>
| 8,788 |
<p>Considering there are so many draconian firewalls in the world, is there any reason I shouldn't run server software on port 80 to guarantee greatest possible accessibility? It seems that the most common firewall exception is to allow outbound connections on port 80. I understand that any sort of packet inspection wo... | <p>If you need to do this, why not just wrap your network comms code with a SOAP interface or an HTTPHandler?</p>
<p>Then your packets will conform to HTTP, you'll get through firewalls and everyone's happy?</p>
<p>It will be much easier than resolving all the installation and operations issues you'll get from multi-... | <p>I will confess to having worked around a Draconian firewall by having an ssh server listen on port 80 back home and using <strong>ssh tunnelling to provide access to other servers and services</strong>. I hasten to add that I did this with the blessing of the people administering the firewall---we all agreed that i... | 49,316 |
<p>I'm using the following query, but I currently have to enter a value in every parameter for the query to work. Is there a way of making the parameters optional, so that 1 or more values will return a result?</p>
<pre><code>SELECT * FROM film
WHERE day LIKE '%day%'
AND month LIKE '%month%'
AND year LIKE '%year%'
</c... | <p>Why don't you create your query dynamically?
Depending on the parameters you have, append the filters dynamically. </p>
<p>e.g.:</p>
<pre><code>string query = "SELECT * FROM film";
string paramenters = string.empty;
if(day!= string.empty)
parameters = " Where day LIKE '%day%'";
if(month != string.empty)
{
i... | <pre><code>SELECT * FROM film
WHERE day LIKE '%day%'
OR month LIKE '%month%'
OR year LIKE '%year%'
</code></pre>
<p>You will still be providing all three parameters, but it won't matter if they are blank or NULL, matches will still return from the ones that aren't blank.</p>
| 42,840 |
<p>I'm a huge fan of bzr and I'm glad they're working on tortoise for it, but currently it's WAY too slow to be useful. The icons are almost always incorrect and when I load a directory in explorer with a lot of branches it locks up my entire system for anywhere from 10 seconds to 2 minutes. I look forward to trying ... | <p>I think you can do:</p>
<pre><code>regsvr32 /u tbzrshellext_x86.dll
</code></pre>
<p>I also killed tbzrcachew.exe in memory, but since, like enobrev, I couldn't find it with AutoRuns, I will suppose it is the shell extension that runs this cache.</p>
<p>Will know for sure when I will reboot my computer...</p>
<p... | <p><a href="https://stackoverflow.com/questions/151587/how-do-i-disable-tortoise-bzr#151911">Jason's answer</a> seemed valid, so I spent some time looking for the py file. It's nowhere to be found. It seems when installing bzr via the setup it also installs tbzr binaries. I've looked through as many panels as I can ... | 18,266 |
<p>I know MSDE is no longer supported on Vista, is this also the case for Windows Server 2008?</p>
| <p>The status is the same for Vista and all OS after Vista, which includes both Windows 2008 and Windows 7.</p>
<p>I do not know if you can somehow "make it work", but you will not get any Support from Microsoft.</p>
<p>Edit: Source is <a href="http://blogs.msdn.com/sqlexpress/archive/2006/08/09/693650.aspx" rel="nof... | <p>The status is the same for Vista and all OS after Vista, which includes both Windows 2008 and Windows 7.</p>
<p>I do not know if you can somehow "make it work", but you will not get any Support from Microsoft.</p>
<p>Edit: Source is <a href="http://blogs.msdn.com/sqlexpress/archive/2006/08/09/693650.aspx" rel="nof... | 35,255 |
<p>I think there must be something subtle going on here that I don't know about. Consider the following:</p>
<pre><code>public class Foo<T> {
private T[] a = (T[]) new Object[5];
public Foo() {
// Add some elements to a
}
public T[] getA() {
return a;
}
}
</code></pre>
<p>Suppose that your m... | <pre><code>Foo<Double> f = new Foo<Double>();
</code></pre>
<p>When you use this version of the generic class Foo, then for the member variable <code>a</code>, the compiler is essentially taking this line:</p>
<pre><code>private T[] a = (T[]) new Object[5];
</code></pre>
<p>and replacing <code>T</code> w... | <p>@matt b: Thanks for the answer! Very helpful.</p>
<p>I have found a workaround for those interested: give the getA method an initialized array to populate. That way the type info is available.</p>
<pre><code>public class Foo<T> {
private T[] a = (T[]) new Object[5];
public Foo() {
// Add some elemen... | 48,659 |
<p>I have a custom control that implements IPostBackEventHandler. Some client-side events invoke __doPostBack(controlID, eventArgs).</p>
<p>The control is implemented in two different user controls. In one control, RaisePostBackEvent is fired on the server-side when <code>__doPostBack</code> is invoked. In the other c... | <p>There's a lot of ways this can fall apart. Are you adding the control to the page dynamically in code behind? If so alot of times your UniqueID can be off - even though the client id's are equal. Do you have a code sample that might demonstrate what you're doing?</p>
| <p>Double check that it is indeed a derivation of the UserControl class, not the WebControl one.<br>
This one has had me by surprise many times. If you need to use WebControl for the styling, you need to let your control implement INamingContainer. (Don't worry, its a marker interface)</p>
<p>So..</p>
<pre><code>publ... | 3,089 |
<pre><code>$("#dvMyDIV").bind("resize", function(){
alert("Resized");
});
</code></pre>
<p>or</p>
<pre><code>$("#dvMyDIV").resize(function(){
alert("Resized");
});
</code></pre>
<p>The questions</p>
<ol>
<li>Why is this not working at FireFox, Chrome and Safari?</li>
<li>Can this be considered a jQuery bug ... | <p>I believe the JavaScript resize event only applies to frames or windows, not to DIVs.</p>
<p>e.g. see <a href="http://devguru.com/technologies/javascript/10929.asp" rel="noreferrer">this page</a>:</p>
<blockquote>
<p>The onResize even handler is use to execute specified code whenever a user or script resizes a w... | <p>Why do you expect #dvMyDIV to be resized? Is maybe resizing of that element a result of something else, maybe the window being resized? If so, try</p>
<pre><code>$(window).resize(function(){alert("Resized");});
</code></pre>
| 28,345 |
<p>(If anything here needs clarification/ more detail please let me know.)</p>
<p>I have an application (C#, 2.* framework) that interfaces with a third-party webservice using SOAP. I used thinktecture's WSCF add-in against a supplied WSDL to create the client-side implementation. For reasons beyond my control the SO... | <p>You can utilize SoapExtension from existing WSE2.0 framework to intercept the responses from the server.</p>
<pre><code>public class MyClientSOAPExtension : SoapExtension
{
Stream oldStream;
Stream newStream;
// Save the Stream representing the SOAP request or SOAP response into
// a local mem... | <p>The <a href="http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension(VS.85).aspx" rel="nofollow noreferrer">MSDN Library</a> includes example code for obtaining the XML of both the request and the response that you can use to archive it. Obviously you'll have to make some changes since t... | 31,975 |
<p>Which language for quick GUI app + sqlite database CRUD (2-4 tables). Java, Python? (Please no jokes like VBasic), some reference, source code to look on?</p>
<p>added:</p>
<p>First idea:
1 database SQLite (Win) + client GUI app (Win)
clients table + orders table + others
import, export database
add, del, edit, et... | <p>Ruby on Rails will do simple CRUD operations <strong>very</strong> easily - although doing more than that can be a little more complex (would require some reading about RoR's way of doing things). The latest version of Rails automatically uses sqlite databases, and in fact the whole database, and CRUD GUI code can b... | <p>C# and WPF, it;s preatty easy and good to know (I've been playing with it for 1 week and fully wrote a twitter client in a few hours.</p>
<p>now Cocoa, and the interface Builder, that is a cool approach even for a simple app.</p>
| 31,184 |
<p>Python has several ways to parse XML...</p>
<p>I understand the very basics of parsing with <strong>SAX</strong>. It functions as a stream parser, with an event-driven API.</p>
<p>I understand the <strong>DOM</strong> parser also. It reads the XML into memory and converts it to objects that can be accessed with ... | <p>ElementTree is much easier to use, because it represents an XML tree (basically) as a structure of lists, and attributes are represented as dictionaries.</p>
<p>ElementTree needs much less memory for XML trees than DOM (and thus is faster), and the parsing overhead via <code>iterparse</code> is comparable to SAX. A... | <p>ElementTree's parse() is like DOM, whereas iterparse() is like SAX. In my opinion, ElementTree is better than DOM and SAX in that it provides API easier to work with.</p>
| 23,442 |
<p>I have a workstation with Windows 2008 x64, MS Access 2007 and Oracle 11g x64
I use Access to connect to Oracle via ODBC.
I am the administrator (in the administrator group) on the workstation. I run Access as administrator but when I want to make an ODBC call to Oracle it does not work.</p>
<p>How do I do it:
I st... | <p>Solved! Create a Virtual PC (Hyper-V) and install the 32 bit version of OS and client - it works!</p>
| <p>If you want to use the Oracle supplied ODBC driver, you need to install the oracle client. The default client install does not include the driver, so you either need to add it when you do the install or re-run the universal installer to add it later.</p>
| 25,617 |
<p>I have a program that I need to run under *nix and windows. because the program takes file paths from files the issue is what to do about the <code>\</code> vs <code>/</code> issue. </p>
<p>My current thought is to put in a regex that converts the wrong one to the right one depending on what system I'm on. This wil... | <p>The / is fully supported in win32 too.</p>
<p>Also see this <a href="https://stackoverflow.com/questions/122455/handling-file-paths-cross-platform">related question</a></p>
| <p>Create a parser for your input to create a tree structure of nodes representing directories. Then you can 'save' by walking the tree and writing whatever delimiters you want or optionally doing different things, like checking if the directory exists or writing meta files. This is actually something that I am just ... | 35,325 |
<p>If our organisation were to switch from a central-server VCS like subversion to a distributed VCS like git, how do I make sure that all my code is safe from hardware failure?</p>
<p>With a central-server VCS I just need to backup the repository every day. If we were using a DVCS then there'd be loads of code branch... | <p>I think that you will find that in practice developers will prefer to use a central repository than pushing and pulling between each other's local repositories. Once you've cloned a central repository, while working on any tracking branches, fetching and pushing are trivial commands. Adding half a dozen remotes to a... | <p>You could have developer home directories mount remote devices over the local network. Then you only have to worry about making the network storage safe. Or maybe you could use something like <a href="http://www.getdropbox.com/" rel="nofollow noreferrer">DropBox</a> to copy your local repo elsewhere seamlessly.</p... | 13,553 |
<p>I just installed an application on a win2003 server and I'm getting this error:</p>
<pre><code>Line 149: <roleManager>
Line 150: <providers>
Line 151: <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, ... | <p>A dynamic language rules for this. Why? The mappings are easy to code and change. You don't have to recompile and rebuild.</p>
<p>Indeed, with a little cleverness, you can have your "XML XPATH to a Tag -> DB table-field" mappings as disjoint blocks of Python code that your main application imports.</p>
<p>The b... | <p>If you are well versed in Java, you can try out <a href="https://vtd-xml.sourceforge.io/" rel="nofollow noreferrer">VTD</a> XML Parser for parsing large volumes of XML data.</p>
| 38,685 |
<p>Are DES Encryption called "One Way Encryption" or "two way Encryption" ?
Are there a PHP class or method to decrypt the DES Encryption ?</p>
| <p>The php <a href="http://us2.php.net/crypt" rel="nofollow noreferrer">crypt</a> function is a one-way hashing function, if you want to be able to decrypt, take a look at the <a href="http://us2.php.net/manual/en/book.mcrypt.php" rel="nofollow noreferrer">mcrypt</a> extension which supports <a href="http://us2.php.net... | <p>I am not familiar with the "one way encryption" or "two way encryption" terms. There is a term "one time password" (totally irrelevant for DES), and there are "symmetric" and "assymetric" encryption algorithms, meaning whether the same key is used for encryption and decryption (symmetric) or a set of two different k... | 32,066 |
<p>I have a JavaScript resource that has the possibility of being edited at any time. Once it is edited I would want it to be propagated to the user's browser relatively quickly (like maybe 15 minutes or so), however, the frequency of this resource being editing is few and far between (maybe 2 a month).</p>
<p>I'd rat... | <p>You may pass a version string as a get parameter to the URL of your script tag. The parameter won't be evaluated by the static JavaScript file but force the browser to get the new version. </p>
<p>If you do not want to assign the version string every time you edited the source you may compute it based on the file s... | <p>Put a version on your javascript code like this that is updated when you make a change</p>
<pre><code><script src="/code.js?ver=123" type="text/javascript"></script>
</code></pre>
<p>They will then always get new version.</p>
| 25,336 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.