instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Why is it bad to check in lines with trailing whitespace to your source control? What kinds of problems could that cause? </p>
<p>False differences, basically. It's helpful if diffs only show "real" changes. Some diff programs will ignore whitespace, but it would be better just to avoid the dummy change in the first place.</p> <p>Of course, it also doesn't help if it makes the line wrap on a colleague's machine.</p>
<p>Modern diff utilities don't get hung up on whitespace.</p>
38,518
<p>Okay, I have a FormView with a couple of child controls in an InsertItemTemplate. One of them is a DropDownList, called DdlAssigned. I reference it in the Page's OnLoad method like so:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { ((DropDownList)FrmAdd.FindControl("DdlAssigned")).Selecte...
<p>I figured it out. I'm still missing exactly why it doesn't work just on FormLoad, but performing the change in the FormView's DataBound event does the trick.</p> <pre><code>protected void FrmAdd_DataBound(object sender, EventArgs e) { // This is the same code as before, but done in the FormView's DataBound even...
<p>I had a problem with dropdownlists and making the first value say something like, "Please select a value..." but without making it an actual selectable item, nor show up on the dropdownlist. I was binding the ddl in the page_load and I have to make sure that I set the text of the dropdownlist, AFTER it's been bound...
40,114
<p>I'm new to Wicket and Hibernate and can't get past the "org.hibernate.HibernateException: /hibernate.cfg.xml not found" error. I've put that file in every location imagineable but I'm still stuck. Where exactly does that file go and/or am I missing a wicket file config setting somewhere?</p>
<p>Ensure hibernate.cfg.xml file placed in classpath.</p>
<p>If you're just starting with Wicket and Hibernate, you may be interested in the <a href="http://databinder.net" rel="nofollow noreferrer">Databinder toolkit</a>.</p>
34,746
<pre><code>class A : IFoo { } ... A[] arrayOfA = new A[10]; if(arrayOfA is IFoo[]) { // this is not called } </code></pre> <p>Q1: Why is <code>arrayOfA</code> not an array of <code>IFoos</code>?</p> <p>Q2: Why can't I cast <code>arrayOfA</code> to <code>IFoo[]</code>?</p>
<p><code>arrayOfA</code> <strong>is</strong> <code>IFoo[]</code>. </p> <p>There must be something else wrong with your program.</p> <p>You seem to have mocked up some code to show the problem, but in fact your code (see below) works as you expect. Try updating this question with the real code - or as close to real as...
<p>You could try</p> <pre><code>if (arrayofA[0] is IFoo) {.....} </code></pre> <p>which sort of answers your question. <code>arrayOfA</code> is an array. An array is an object which implements <code>ICloneable</code>, <code>IList</code>, <code>ICollection</code>, &amp; <code>IEnumerable</code>. <code>IFoo</code> isn'...
11,829
<p>I have an application that I'm trying to wrap into a jar for easier deployment. The application compiles and runs fine (in a Windows cmd window) when run as a set of classes reachable from the CLASSPATH. But when I jar up my classes and try to run it with java 1.6 in the same cmd window, I start getting exceptions...
<p>The -jar option is mutually exclusive of -classpath. See an old description <a href="http://download.java.net/jdk8u20/docs/technotes/tools/windows/java.html" rel="noreferrer">here</a></p> <blockquote> <p>-jar</p> <p>Execute a program encapsulated in a JAR file. The first argument is the name of a JAR file instead of...
<p>I have found when I am using a manifest that the listing of jars for the classpath need to have a space after the listing of each jar e.g. "required_lib/sun/pop3.jar required_lib/sun/smtp.jar ". Even if it is the last in the list. </p>
31,118
<p>I'm writing a .NET forms control to edit HTML using MSHTML. I am creating some custom elements and want to make them effectively read-only. I thought I could go about this by focusing on the entire element any time focus entered anywhere in that element but the HtmlElement.Focus() doesn't select the entire element...
<p>I found that setting the attribute:</p> <pre><code>contentEditable=false </code></pre> <p>Resulted in the desired behavior.</p>
<p>In case you are trying to apply readonly behavior to an User Input control, you can try using @readonly attribute of that control. Otherwise you could also add event listeners for appropriate UI events (keydown, mousedown) and prevent their default behavior (return false, or event.returnValue = false). As for custom...
21,285
<p>How can I validate that my ASPNET AJAX installation is correct.</p> <p>I have Visual Studio 2008 and had never previously installed any AJAX version.</p> <p>My UpdatePanel is nto working within IIS6, although it works ok within Visual Studio's web server. The behaviour I get is as if the UpdatePanel doesnt exist a...
<p>You can do <code>sgml-pretty-print</code> and then <code>indent-for-tab</code> on the same region/buffer, provided you are in html-mode or nxml-mode.</p> <p><code>sgml-pretty-print</code> adds new lines to proper places and <code>indent-for-tab</code> adds nice indentation. Together they lead to properly formatted ...
<p>The easiest way to do it is via command line.</p> <ul> <li>Make sure you have tidy installed</li> <li>type <code>tidy -i -m &lt;&lt;file_name&gt;&gt;</code></li> </ul> <p>Note that <code>-m</code> option replaces the newly tidied file with the old one. If you don't want that, you can type <code>tidy -i -o &lt;&lt;...
16,581
<p>The <code>gcc -S</code> option will generate assembly code in AT&amp;T syntax, is there a way to generate files in Intel syntax? Or is there a way to convert between the two?</p>
<h3>Use <code>-masm=intel</code></h3> <pre><code>gcc -S -masm=intel -Og -fverbose-asm test.c </code></pre> <p>That works with GCC, and clang3.5 and later. <a href="https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-masm_003ddialect" rel="noreferrer">GCC manual</a>:</p> <blockquote> <ul> <li><code>-masm=dialect<...
<p>I have this code in CPP file:</p> <pre><code>#include &lt;conio.h&gt; #include &lt;stdio.h&gt; #include &lt;windows.h&gt; int a = 0; int main(int argc, char *argv[]) { asm("mov eax, 0xFF"); asm("mov _a, eax"); printf("Result of a = %d\n", a); getch(); return 0; }; </code></pre> <p>That's code...
24,386
<p>We have been using .Net and Visual Studio for the last six years, and early on developed a number of web based reporting applications using the .Net version of Crystal Reports that was bundled with Visual Studio. I'm unimpressed with that product: It seems incredibly difficult and convoluted to use. We had to make s...
<p>Like you, I've had poor experiences with Crystal Reports, and my gut instinct is to post "avoid it at all costs" in all caps with lots of exclamation points. However, I've had my afternoon nap today, so I'll post like a grownup.</p> <p>If all you're looking to do is pdf-ize (yes, it's a real word, damnit!) then you...
<p>We use Crystal in our shop too. We are currently on 8.5, which is way old and is no longer supported by SAP. We tried to upgrade to CRXI recently, which involved an entirely new API. We had to shelf the effort due to other priorities. While working on the upgrade I found support for CRXI on a number of forums. ...
14,173
<p>I know about the "cooperative" threading of ruby using <a href="http://en.wikipedia.org/wiki/Green_threads" rel="noreferrer">green threads</a>. How can I create real "OS-level" threads in my application in order to make use of multiple cpu cores for processing?</p>
<p><strong>Updated with Jörg's Sept 2011 comment</strong></p> <p>You seem to be confusing two <em>very</em> different things here: the Ruby Programming Language and the specific threading model of one specific implementation of the Ruby Programming Language. There are currently around 11 different implementations o...
<p>If you are using MRI, then you can write the threaded code in C either as an extension or using the ruby-inline gem. </p>
7,996
<p>I've always used a <code>*.h</code> file for my class definitions, but after reading some boost library code, I realised they all use <code>*.hpp</code>. I've always had an aversion to that file extension, I think mainly because I'm not used to it.</p> <p>What are the advantages and disadvantages of using <code>*.h...
<p>Here are a couple of reasons for having different naming of C vs C++ headers:</p> <ul> <li>Automatic code formatting, you might have different guidelines for formatting C and C++ code. If the headers are separated by extension you can set your editor to apply the appropriate formatting automatically</li> <li>Naming...
<p>The extension of the source file may have meaning to your build system, for example, you might have a rule in your makefile for <code>.cpp</code> or <code>.c</code> files, or your compiler (e.g. Microsoft <code>cl.exe</code>) might compile the file as C or C++ depending on the extension. </p> <p>Because you have to...
18,407
<p>Is there any way to detect packet loss with the help of performance counters or am I better of using a 3rd-party tool? What tools would you recommend?</p>
<p>Are you trying to track the total number of TCP retries because of packet losses? If so, then yes, Performance Counters will work fine.</p>
<p>We've always found tools based on the PCAP library to be useful. In particular Wireshark (<a href="http://www.wireshark.org" rel="nofollow noreferrer">www.wireshark.org</a>) is great for getting a network traffic trace and it will highlight problems such as packet loss in its output.</p>
33,656
<p>At work I use mostly the .NET Compact Framework 3.5 for developing applications that run on smart devices. Our devices are not phones or handhelds - they are measurement instruments which you get with a whole punch of features. Our application is pretty advanced - we are even using a N-Layer architecture, a self-mad...
<p>We've done a plant-floor monitoring system that acts as a data server and a web server collecting data from PLCs and creating dynamic web-based reports all in the CF. We've created a peer-to-peer notification and file sharing system. We've done vehicle tracking and dispatching systems. We've done smart-farming ap...
<p>I wrote an app that monitors the statistics on my self-made blog by interfacing with a WebService.</p>
31,985
<p>I want to generate a Makefile from an existing Xcode project on the Mac. Specifically, an existing iPhone, Objective-C program on the Mac.</p> <p>I found <a href="http://members.bellatlantic.net/%7Evze35xda/software.html" rel="noreferrer">PBToMake</a>, but it looks like it is for Xcode 2.1 and when I tried using it...
<p>GNUStep provides '<a href="http://wiki.gnustep.org/index.php/Pbxbuild" rel="nofollow noreferrer">pbxbuild</a>' to convert a .xcodeproj file into a GNUMakefile.</p> <p><strong>UPDATE:</strong> <a href="http://gnustep.8.n7.nabble.com/pbxbuild-is-now-deprecated-td24464.html" rel="nofollow noreferrer">pbxbuild is now d...
<p>You could try <a href="http://freshmeat.net/projects/mfg/?topic_id=46" rel="nofollow noreferrer">mfg</a>. It is template based and I think (I haven't played with it too much) you could get it to generate a suitable makefile.</p>
12,082
<p>I often hear the terms 'statically linked' and 'dynamically linked', often in reference to code written in <a href="http://en.wikipedia.org/wiki/C_%28programming_language%29" rel="noreferrer">C</a>, <a href="https://en.wikipedia.org/wiki/C++" rel="noreferrer">C++</a> or <a href="http://en.wikipedia.org/wiki/C_Sharp_...
<p>There are (in most cases, discounting interpreted code) two stages in getting from source code (what you write) to executable code (what you run).</p> <p>The first is compilation which turns source code into object modules.</p> <p>The second, linking, is what combines object modules together to form an executable.</...
<p>(I don't know C# but it is interesting to have a static linking concept for a VM language)</p> <p>Dynamic linking involves knowing how to find a required functionality which you only have a reference from your program. You language runtime or OS search for a piece of code on the filesystem, network or compiled code...
40,191
<p>I've got a multiline textBox that I would like to have a label on the form displaying the current line and column position of, as Visual Studio does.</p> <p>I know I can get the line # with GetLineFromCharIndex, but how can I get the column # on that line?</p> <p>(I really want the Cursor Position on that line, no...
<pre><code>int line = textbox.GetLineFromCharIndex(textbox.SelectionStart); int column = textbox.SelectionStart - textbox.GetFirstCharIndexFromLine(line); </code></pre>
<p>Off the top of my head, I think you want the SelectionStart property.</p>
9,198
<p>Is there a way of getting the websites absolute URL (<a href="http://www.domain.com/" rel="nofollow noreferrer">http://www.domain.com/</a>) using Java? because I've googled a bit but I only come across with having to make 2 or 3 classes to create that function =/</p> <h3>Update:</h3> <p>The thing is I am trying to c...
<p>I'm assuming you just want the domain from a JSP, however you may find you need the entire URL including the prefix, domain, path and parameters. The easiest way to get this quickly is to use the Request object and build it. Have a look here for more info:</p> <p><a href="http://www.exforsys.com/tutorials/jsp/jsp-r...
<p>Could you be more specific? Your question states:</p> <blockquote> <p>Is there a way of getting the websites absolute URL (<a href="http://www.domain.com/" rel="nofollow noreferrer">http://www.domain.com/</a>) using Java?</p> </blockquote> <p>By "the website" which website are you asking for? I can see multi...
32,057
<p>As a hobby I'm interesting in programming an Ethernet-connected LED sign to scroll messages across a screen. But I'm having trouble making a UDP sender in <a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET" rel="nofollow noreferrer">VB.NET</a> (I am using 2008 currently).</p> <p>Now the sign is nice enough to ...
<p>You could put together a quickie decoder like this one:</p> <pre><code>Function HexCodeToHexChar(ByVal m as System.Text.RegularExpressions.Match) As String Return Chr(Integer.Parse(m.Value.Substring("&lt;0x".Length, 2), _ Globalization.NumberStyles.HexNumber)) End Function </code></pre> <p>then use th...
<p>This might help. At my company we have to communicate with our hardware using sort of a combination of ascii and hex. </p> <p>I use this function to hexify ip addresses before sending them to the hardware</p> <pre><code>Public Function HexFromIP(ByVal sIP As String) Dim aIP As String() Dim sHexCode As Stri...
20,446
<p>I want to use forms authentication in my asp.net mvc site.</p> <p>Can I use an already existing sql db (on a remote server) for it? How do I configure the site to use this db for authentication? Which tables do I need/are used for authentication?</p>
<p>You can. Check <code>aspnet_regsql.exe</code> program parameters in your Windows\Microsoft.NET\Framework\v2.xxx folder, specially <code>sqlexportonly</code>.</p> <p>After creating the needed tables, you can configure: create a connection string in the web.config file and then set up the MemberShipProvider to use th...
<p>The easiest manner is to just use the windows interface for the aspnet_regsql.exe application.</p> <p>You can find it in the c:\windows\microsoft.net\framework\v2.0.50727 folder.</p> <p>Just type in aspnet_regsql.exe, it will then open a wizard, this way you don't need to remember any command line switches.</p>
16,148
<p>I'm using RSACryptoServiceProvider in .NET 2 and it seems that the Private part of a Public/Private key pair always contains the Public part as well.</p> <p>I need to encrypt some info using my Public key, and allow the other party to ONLY DECRYPT what I encrypted. I don't want them to be able to know how I encrypt...
<p>The private key always includes the public key.</p> <p>What you might really want is Signing. Using the same .NET classes, you can sign data with your private key and verify the signature on the other party's side with the public key (which obviously doesn't contain the private key).</p> <pre><code> public stat...
<p>Data encryption using private/public key does not work like that. You must use other <strong>person's public key</strong>, so he/she can decrypt it by means of his/her private key.</p> <p>Nonetheless this is really slow, so in practice what is actually used to encrypt the message is a symmetric key which is generat...
38,645
<p>What would be the best way to draw a simple animation just before showing a modal <a href="https://docs.oracle.com/javase/9/docs/api/javax/swing/JDialog.html" rel="nofollow noreferrer">JDialog</a>? (i.e. expanding borders from the mouse click point to the dialog location). I thought it would be possible to draw on t...
<p>Are you trying to show the JDialog indepentently of the annimation? In order to get the order set properly, you may need to bundle those actions in a runnable that is passed to the EDT at once.</p> <p>eg:</p> <pre><code>SwingUtilities.invokeLater(new Runnable(){ public void run(){ doAnnimation(); sh...
<p>You may be able to take @rcreswick's answer and expand on it a little to make it work.</p> <pre><code>void myShowDialog() { new Thread(new Runnable() {public void run() { SwingUtilities.invokeAndWait(new Runnable() { public void run() { doAnimation(); } } ); // Delay to wait for the animation to...
6,017
<p>So let's say I have two different functions. One is a part of the BST class, one is just a helper function that will call on that Class function. I will list them out here.</p> <pre><code>sieve(BST&lt;T&gt;* t, int n); </code></pre> <p>this function is called like this: sieve(t,n) the object is called BST t; <...
<pre><code>sieve(BST&lt;int&gt;&amp; t, int n) </code></pre> <p>The <code>&amp;</code> specifies passing by <em>reference</em> rather than value. :-)</p>
<blockquote> <p>What happens here is everything compiles just fine, but when t.remove function is called I see no actual results. I'm assuming because it's just creating a copy or a whole other t object instead of passing the one from my main() function.</p> </blockquote> <p>Correct. That is exactly what happens, b...
31,291
<p>What is the best IO strategy for a high traffic web app that logs user behaviour on a website and where ALL of the traffic will result in an IO write? Would it be to write to a file and overnight do batch inserts to the database? Or to simply do an INSERT (or INSERT DELAYED) per request? I understand that to conside...
<p>By writing to the DB, you allow the RDBMS to decide when disk IO should happen - if you have enough RAM, for instance, it may be effectively caching all those inserts in memory, writing them to disk when there's a lighter load, or on some other scheduling mechanism.</p> <p>Writing directly to the filesystem is goin...
<p>Write to a file and then load later. It's safer to be coupled to a filesystem than to a database. And the database is more likely to fail than the your filesystem.</p>
40,596
<p>When performing string concatentation of an existing string in the intern pool, is a new string entered into the intern pool or is a reference returned to the existing string in the intern pool? According to this article, String.Concat and StringBuilder will insert new string instances into the intern pool? </p> <p...
<p>If you create new strings, they will not automatically be put into the intern pool, unless you concatenate constants compile-time, in which case the compiler will create one string result and intern that as part of the JIT process.</p>
<p>You can see whether a string has been interned by calling <code>String.IsInterned</code>. The call will return a new string that is either a reference to an interned string equal to the string that was passed as an argument, or <code>null</code> if the string was not interned.</p>
5,889
<p>My friend and I are having a disagreement over an application development issue. It's a simple production management application. </p> <p>According to my friend, the front-end stores data in XML, and a Java program will read the XML document, store it (at the back-end), and apply some business logic and again store...
<p>You're right and your friend gave a bad idea. In addition, from your question, I see there are several troubled issues, I don't know where to begin so I will just list them but not in any particular oder. But the ground rule for you to read on is you must agree that simpler is better as Einstein said "Things shoul...
<p>What your friend is suggesting is to keep things modular. It doesn't really matter what language you use, but if throw it together in one big project you might make it non modular.</p>
47,491
<p>I need to perform some action when my application receives focus. </p> <p>I've tried hooking both GotFocus- and Enter-events, but they only trigger when focus changes within my application. </p> <p>Scenario is that my application detects some problem that must be resolved elsewhere, and I would like to do the chec...
<p>I would try overriding <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.onactivated(VS.85).aspx" rel="nofollow noreferrer">Form.OnActivated</a> (or handling the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.activated(VS.85).aspx" rel="nofollow noreferrer">Form.A...
<p>Try hooking the Activated event.</p>
24,090
<p>I know you can just use CSS to hide the DIV or Silverlight Plugin, but is there a way to instantiate a Silverlight Component/App using JavaScript that doesn't show any UI element at all?</p> <p>There is alot of great functionality in Silverlight, like MultiThreading and compiled code, that could be utilized by trad...
<p>Yes you can, and some of the reasons you make makes perfect sense. I did a talk on the HTML bridge at CodeCampNZ some weeks back, and have <a href="http://jonas.follesoe.no/2008/09/01/unit-testing-presentation-model-and-the-html-bridge-at-codecamp-nz/" rel="nofollow noreferrer">a good collection of resources</a> up ...
<p>Curt, using Managed JavaScript would still require you to have some Silverlight/XAML display layer being visible on the page, correct? Is there a way to entirely get rid of any Silverlight/UI element from being displayed?</p>
14,366
<p>In IE when I insert text into a <code>&lt;pre&gt;</code> tag the newlines are ignored:</p> <pre><code>&lt;pre id="putItHere"&gt;&lt;/pre&gt; &lt;script&gt; function putText() { document.getElementById("putItHere").innerHTML = "first line\nsecond line"; } &lt;/script&gt; </code></pre> <p>Using <code>\r\n</code>...
<p>These <a href="http://www.quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html" rel="noreferrer">quirksmode.org bug report and comments</a> about innerHTML behaviour of Internet Explorer could help:</p> <p>"<em>IE applies <strong>HTML normalization</strong> to the data that is assigned to the innerHTML p...
<pre><code>if (typeof div2.innerText == 'undefined') div2.innerHTML = value; else div2.innerText = value; </code></pre> <p>that worked for me.</p>
23,733
<p>I have a client-server architecture where client communicates with the server using .NET Remoting. Server handles all business logic and database interaction. I need to add an operation which may take a while to execute and the dataset it returns might be quite large. I'm thinking of employing asynchronous call for ...
<p>You could design your client/server interaction so that the server let a worker thread do the SQL stuff so that it was ready to receive another call from the client. So, the client makes call 1 and says do SQL work. The server gives that work to the worker thread and is ready for new incoming. Then the client ...
<p>What do you do now with call in progress when client closes application? You can do the same thing with asynchronous call.</p> <p>Yes, async is the way to go for long-running requests. If result set is big enough, you can even think about sending chunks of it with several responses from server.</p> <p>Of when user...
35,840
<p>I've got a java server (not web based, more like a big, many-threaded standalone application) that needs to talk to a MS SQL Server database. </p> <p>I just worked on a different project that ported a home-grown O/R layer from oracle to SQL Server, and it ran into significant problems because of too many oracle ass...
<p><strong>Hibernate</strong> is the usual choice. Besides that you can take a look at Oracle TopLink, iBatis, whatever suites you best.</p>
<p>Hibernate is good. But there are different flavors of Hibernate implementation. I suggest Hibernate 3.x (3.2?) with JPA. I also usually use Spring 2.5 as the framework for the business logic. Hibernate and Spring work especially well together, because they can share name resolving scopes to a degree, which lesse...
34,326
<p>The top of my <code>web.xml</code> file looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/w...
<p>Perhaps try:</p> <pre><code>http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd </code></pre> <p>Instead of:</p> <pre><code>http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd </code></pre> <hr> <p>Also, the <code>&lt;!DOCTYPE ...&gt;</code> is missing:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt...
<p>Add this <code>&lt;!DOCTYPE ...&gt;</code> to your xml file. Please put it under <code>&lt;?xml ...&gt;</code>:</p> <pre><code>&lt;!DOCTYPE ??? PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; </code></pre> <p><code>???</code> = Your root element, now i...
41,704
<p>If I have srand(2) declared in my main of my driver file, do I need to declare srand(2) in my code file which is being linked with my driver?</p> <p>Thanks.</p> <p><strong>edit</strong></p> <p>(from user's comment below)</p> <p>If I do,</p> <pre><code>srand(2); srand(2); </code></pre> <p>will I get the seed as...
<p><a href="http://www.cplusplus.com/reference/clibrary/cstdlib/srand.html" rel="nofollow noreferrer">srand</a>(2) sets the seed of the random number generator to 2. Calling it again with the same parameter sets the seed to 2 again, and will cause the random generator to create the same output. </p> <p>FYI, If the dr...
<p>When you call srand() with a particular seed, it begins the sequence for that seed regardless of any previous call to srand(). Every time you call srand(2) for example, subsequent calls to rand() will give you the same numbers in the same order every time. So:</p> <pre><code>srand(2); srand(2); </code></pre> <p>is...
42,313
<p>I am attempting to compose a style sheet that, given an XML input (obviously) and a parameter that specifies a "target", will produce a list of commands that match that target. Here is the style sheet as written:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Tr...
<p>If I have understood the question correctly, I think you need to use 'stringparam' as the option to call xsltproc, assuming you are passing a string value to match, and not an XPath expression.</p> <pre><code>xsltproc --stringparam target cora_cmd gen-commands.xsl commands.xml </code></pre>
<p>In your declaration of the 'target' parameter in the stylesheet, you should quote the <code>@select</code> value if you want it to function as a default value when the parameter is not used on the command line:</p> <pre><code>&lt;xsl:param name="target" select="'cora_cmd'"/&gt; </code></pre>
31,122
<p><strong>UPDATE</strong></p> <p>I'm basically binding the query to a WinForms <code>DataGridView</code>. I want the column headers to be appropriate and have spaces when needed. For example, I would want a column header to be <code>First Name</code> instead of <code>FirstName</code>.</p> <hr> <p>How do you create ...
<p>As CQ states, you can't have a space for the field name, you can return new columns however.</p> <pre><code>var query = from u in db.Users select new { FirstName = u.FirstName, LastName = u.LastName, FullName = u.FirstName + " " + u.LastName ...
<p>My VS2008 is busted right now, so I can't check. In C#, you would use "=" - How about </p> <pre><code>Dim query = From u In db.Users _ Select 'First Name' = u.FirstName </code></pre>
15,605
<p>We are using a PHP scripting for tunnelling file downloads, since we don't want to expose the absolute path of downloadable file:</p> <pre><code>header("Content-Type: $ctype"); header("Content-Length: " . filesize($file)); header("Content-Disposition: attachment; filename=\"$fileName\""); readfile($file); </code></...
<p>The first thing you need to do is to send the <code>Accept-Ranges: bytes</code> header in all responses, to tell the client that you support partial content. Then, if request with a <code>Range: bytes=x-y</code> header is received (with <code>x</code> and <code>y</code> being numbers) you parse the range the client ...
<p>I've created a library for serving files with support for conditional (don't download file again unless it has changed) and ranged (pause and resume download) requests. It even works with virtual file systems, such as <a href="https://flysystem.thephpleague.com" rel="nofollow noreferrer">Flysystem</a>.</p> <p>Check ...
19,037
<p>This is really weird... When I open the following simple HTML document in Internet Explorer 7.0.5730.11 (on Windows Server 2003 Web Edition SP2)</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;p&gt;+&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>it shows me a totally blank page. FWIW, this is just a ...
<p>Does it work if you use the numeric character reference notation?</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;p&gt;&amp;#43;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<p>Does it work if you use a Doctype? IE does get a bit picky if you don't use a doctype (insert no-right-to-be-picky pun here).</p> <p>By intermittent do you mean using the same code it appears and doesn't? That sounds <em>really</em> strange.</p> <p><em>CLOSED - NOT REPRO</em>... er I mean I only get the +, no matt...
30,948
<p>[This code is called from within the <code>Inspector.Activate</code> event handler (first call), i.e. right before the inspector window is actually shown.]</p> <p>For "native" mail inspectors I can simply QI the <code>Inspector</code> interface to <code>IOleWindow</code> and call its <code>GetWindow</code> method. ...
<p>I have now come up with something new that I haven't yet been able to break but it still feels a lot like voodoo. By observation I found that the window I want always appears to be the first one returned by <a href="http://msdn.microsoft.com/en-us/library/ms633497.aspx" rel="nofollow"><code>EnumWindows</code></a> th...
<p>I found that on the Constructor of the custom Inspector, you can use the following method to find the newly constructed inspector.</p> <p>C#</p> <p><code> inspectorWindow = Win32.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "OpusApp", "Microsoft Word"); </code></p> <p>You have to do this on the constructor, afterwards ...
38,209
<p>When a system has N tiers, and when using an ORM, how do you send loaded entities across the tiers ?</p> <p>Do you use DTO ?</p> <p>When DTO are not used and the entities are directly sent, how do you protect againt the uninitialized lazy loaded relationship errors ?</p> <p>Note : this is not a "should N tiers be...
<p>Well I don't know if there is a better way, but when we use Hibernate we just turn lazy loading off so that it loads everything. It obviously costs more to do this, but I wasn't sure how to get away from the lazy loading methods that Hibernate would create.</p> <p>If a Containers has sets of data that are not used...
<p>I'm just trying to find my way with ORMs. </p> <p>It's an appealing concept. Like you I don't want other tiers in the application to know that the ORM exists. </p> <p>What I'm looking at currently is using interfaces that I design and using partial classes (a C#/.net thing, without partial classes I guess I'd w...
11,378
<p>Lets say I have a class that stores user information complete with getters and setters, and it is populated with data from an XML file. How would I iterate over all of the instances of that class like you would do with java beans and tag libraries?</p>
<p>For outputting formatted HTML, you have a few choices. What I would probably do is make a property on the code-behind that accesses the collection of objects you want to iterate over. Then, I'd write the logic for iterating and formatting them on the .aspx page itself. For example, the .aspx page:</p> <pre><code>[s...
<p>This assumes you can acquire all instances of your class and add them to a Generic List.</p> <pre><code>List&lt;YourClass&gt; myObjects = SomeMagicMethodThatGetsAllInstancesOfThatClassAndAddsThemtoTheCollection(); foreach (YourClass instance in myObjects) { Response.Write(instance.PropertyName.ToString(); } </code>...
15,158
<p>I want to print styled html pages with their images from a script. Can anyone suggest an open-source solution?</p> <p>I'm using linux (Ubuntu 8.04) but would be also be interested in solutions for other operating systems.</p>
<p>You could give <a href="http://user.it.uu.se/~jan/html2ps.html" rel="noreferrer">html2ps</a> a try, it is written in Perl, so I guess it wil run on any operating system that runs Perl. It does support CSS and images. It does not render as good as you may perhaps want.</p> <p>To use in Debian/Ubuntu <code>sudo aptit...
<p>I´m not sure if this code works with mono, but it should work with Windows and the "real" .NET Framework at least: <a href="http://pietschsoft.com/post/2008/07/C-Generate-WebPage-Thumbmail-Screenshot-Image.aspx" rel="nofollow noreferrer">http://pietschsoft.com/post/2008/07/C-Generate-WebPage-Thumbmail-Screenshot-Ima...
36,424
<p>I need to cool some liquid (250&nbsp;°C) while it’s flowing through a tube which has to be able to bend and flex. My idea is to make a flexible tube with a second tube spiraling around it through which coolant will flow.</p> <p>I’d like to 3D print this tube if possible so I wonder if there is some printable filame...
<p>Ok, so to answer the primary question: What flexible filament will operate consistently at 250 °C?</p> <p>Man, this is a tough one. Some filaments, like PEEK and ULTEM 1010 can operate up in the 200 °C range, but they're not flexible at all.</p> <p>Silicon might be able to work, but you're still pushing boundaries.<...
<p>3D printing nerd showed a couple of filaments that fits this in his latest video "Printers at RAPID + TCT 2019":</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/obCgJQp5Yj8?start=0"></iframe> </div></div></p> <p>Firstly a...
1,338
<p>What is the C# equivalent of Delphi's <code>FillChar</code>?</p>
<p>If I understand FillChar correctly, it sets all elements of an array to the same value, yes?</p> <p>In which case, unless the value is 0, you probably have to loop:</p> <pre><code>for(int i = 0 ; i &lt; arr.Length ; i++) { arr[i] = value; } </code></pre> <p>For setting the values to the type's 0, there is <co...
<p>Try this in C#:</p> <pre><code>String text = "hello"; text.PadRight(10, 'h').ToCharArray(); </code></pre>
41,429
<p>My development environment is running in JDK1.6, and I need to compile some classes so they are compatible with a client running JDK1.5. How would I do this with the 'javac' ant target?</p>
<p>Command line : javac -target 1.5 sourcefiles </p> <p>Ant: <code>&lt; javac srcdir="${src} destdir="${build}" target="1.5" /&gt;</code></p>
<pre><code>&lt;javac source="1.5"... /&gt; </code></pre>
20,402
<p>For those who like a good WPF binding challenge:</p> <p>I have a nearly functional example of two-way binding a <code>CheckBox</code> to an individual bit of a flags enumeration (thanks Ian Oakes, <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c05b7e7e-25cd-4a41-8bf5-e35d2caff797/" rel="nofollow ...
<p>You could use a value converter. Here's a very specific implementation for the target <code>Enum</code>, but would not be hard to see how to make the converter more generic:</p> <pre><code>[Flags] public enum Department { None = 0, A = 1, B = 2, C = 4, D = 8 } public partial class Window1 : Win...
<p>I do not have enough rep to comment yet, this solution is targeting user99999991:<br> "Cant have multiple checkboxes binding to different values on a page with the same converter I guess."<br> Another advantage, with this solution you can also bind the Flag mask instead of hardcoding a static reference. </p> <p>Us...
42,337
<p>I have just started to look at .NET 3.5 so please forgive me if this type of question have been asked before. I am struggling with a decent usage for extension methods, in that I have just downloaded suteki shop an MVC ecommerce offering. In this project there is a pretty standard Repository pattern that extends IRe...
<p>The point is that if you've implemented all of <code>IRepository&lt;T&gt;</code> appropriately, you (as the data layer implementor) don't have to know about root categories at all. For the scope of this extension method, it is assumed that any <em>repository</em> of categories will have a root category of ID 1. That...
<p>Yes in the example you mentioned it does seem counter-intuitive and the reason is because you are working with a single object at a single level. I find that extension methods are most useful when you are working with IQueryable / IEnumerable collections.</p> <p>For eg. lets consider 2 scenarios:</p> <ul> <li><p>...
36,215
<p>What is the difference between the <a href="https://msdn.microsoft.com/en-us/library/z883w3dc(v=vs.110).aspx" rel="noreferrer">AddRange</a> and <a href="https://msdn.microsoft.com/en-us/library/bb302894(v=vs.110).aspx" rel="noreferrer">Concat</a> functions on a generic List? Is one recommended over the other?</p>
<p>They have totally different semantics.</p> <p>AddRange modifies the list by adding the other items to it.</p> <p>Concat returns a new sequence containing the list and the other items, without modifying the list.</p> <p>Choose whichever one has the semantics you want.</p>
<p>I found this interesting article talking about the difference between these 2 structures and comparing their performance...</p> <p>The main idea is that AddRange is way much faster when its about big size collections.</p> <p>Here is the <a href="https://www.tabsoverspaces.com/232514-collection-type-result-whats-fa...
12,540
<p>What I want to do is basically this: on <strong>ONE</strong> page, my customers can click a <strong>VIEW CART</strong> link and the contents of their cart shows below on that same page. Here is my basic link form:</p> <pre><code> &lt;FORM METHOD=post ACTION="http://www.123websiteservices.com/cgi-bin/cybercart.pl"&g...
<p>This should get you started on how to show the cart when the viewcart.gif has been clicked.</p> <pre><code>&lt; script&gt; function ShowScript() { // Do Your Show cart stuff here return false } &lt; /script&gt; ... &lt; input type="image" src="viewcart.gif" onClick="return ShowScript();" /&gt; </code></pre...
<p>like this?? <p></p> <pre><code>&lt; FORM METHOD=post ACTION="http://www.123websiteservices.com/cgi-bin/cybercart.pl"&gt; &lt; INPUT TYPE=hidden NAME=merchant VALUE="jessicas"&gt; &lt; INPUT TYPE=hidden NAME=action VALUE=order&gt; &lt; INPUT TYPE=hidden NAME=page_name VALUE="viewcart.html"&gt; &lt; script&gt;functio...
46,446
<p>Occasionally I come accross a unit test that doesn't Assert anything. The particular example I came across this morning was testing that a log file got written to when a condition was met. The assumption was that if no error was thrown the test passed.</p> <p>I personally don't have a problem with this, however it ...
<p>It's simply a very minimal test, and should be documented as such. It only verifies that it doesn't explode when run. The worst part about tests like this is that they present a false sense of security. Your code coverage will go up, but it's illusory. Very bad odor.</p>
<p>I have to admit that I have never written a unit test that verified I was logging correctly. But I did think about it and came across this <a href="http://www.mail-archive.com/log4j-user@logging.apache.org/msg08646.html" rel="nofollow noreferrer">discussion</a> of how it could be done with JUnit and Log4J. Its not t...
16,620
<p>If I have a range of say <code>000080-0007FF</code> and I want to see if a char containing hex is within that range, how can I do it?</p> <p>Example</p> <pre><code>char t = 0xd790; if (t is within range of 000080-0007FF) // true </code></pre>
<pre><code>wchar_t t = 0xd790; if (t &gt;= 0x80 &amp;&amp; t &lt;= 0x7ff) ... </code></pre> <p>In C++, characters are interchangeable with integers and you can compare their values directly.</p> <p>Note that I used <code>wchar_t</code>, because the <code>char</code> data type can only hold values up to 0xFF.</p>
<p>Since hex on a computer is nothing more than a way to print a number (like decimal), you can also do your comparison with plain old base 10 integers.</p> <pre><code>if( (t &gt;= 128) &amp;&amp; (t &lt;= 2047) ) { } </code></pre> <p>More readable.</p>
32,111
<p>In a SharePoint list I want an auto number column that as I add to the list gets incremented. How best can I go about this?</p>
<p>Sharepoint Lists automatically have an column with "ID" which auto increments. You simply need to select this column from the "modify view" screen to view it.</p>
<p>Peetha has the best idea, I've done the same with a custom list in our SP site. Using a workflow to auto increment is the best way, and it is not that difficult. Check this website out: <a href="http://splittingshares.wordpress.com/2008/04/11/auto-increment-a-number-in-a-new-list-item/" rel="nofollow noreferrer">htt...
9,812
<p>I've been learning Lisp to expand my horizons because I have heard that it is used in AI programming. After doing some exploring, I have yet to find AI examples or anything in the language that would make it more inclined towards it.</p> <p>Was Lisp used in the past because it was available, or is there something t...
<p>Lisp WAS used in AI until the end of the 1980s. In the 80s, though, Common Lisp was oversold to the business world as the "AI language"; the backlash forced most AI programmers to C++ for a few years. These days, prototypes usually are written in a younger dynamic language (Perl, Python, Ruby, etc) and implementatio...
<p>I think you're right: Lisp was a handy tool for hacking things up. This is because it didn't distinguish much between program and data. This allowed hackers to manipulate functions very easily, just like data. </p> <p>But lisp is quite difficult for humans to read, with its braces and non-distinction between data a...
15,840
<p>How do I create a batch file to delete files older than a specified date?</p> <p>This does not seem to work;</p> <pre><code>:: --------DELOLD.BAT---------- @echo off SET OLDERTHAN=%1 IF NOT DEFINED OLDERTHAN GOTO SYNTAX for /f "tokens=2" %%i in ('date /t') do set thedate=%%i type %1 pause set mm=%thedate:~0,2% se...
<p><b>Edit:</b> I figured it out.</p> <p>To delete all files older than a given date:</p> <pre><code>REM del_old.bat REM usage: del_old MM-DD-YYY for /f "tokens=*" %%a IN ('xcopy *.* /d:%1 /L /I null') do if exist %%~nxa echo %%~nxa >> FILES_TO_KEEP.TXT for /f "tokens=*" %%a IN ('xcopy *.* /L /I /EXCLUDE:FILES_TO_KEE...
<p>I don't know if you can do that with .BAT files and what few tools Windows comes with, but you sure can with .js (JScript) or .vbs (VBScript) files. You are doing this under Windows, right? If so, then Windows can process .js and .vbs files just as well as .bat files by default. They are far more powerful.</p> <p>A...
41,993
<p>what is the best method for inter process communication in a multithreaded java app.</p> <p>It should be performant (so no JMS please) easy to implement and reliable,so that objects &amp; data can be bound to one thread only?</p> <p>Any ideas welcome!</p>
<p>Could you clarify a bit? Do you mean IPC in a single JVM? (Multiple threads, yes, but at an OS-level only one process.) Or do you mean multiple JVMs? (And truly OS-level inter process communications.)</p> <p>If it is the first, then maybe something out of <strong>java.util.concurrent</strong>, like <a href="http...
<p>I recommend looking into the entire <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/package-summary.html" rel="nofollow noreferrer">java.util.concurrent</a> package, which have multiple classes for dealing with concurrency and different communication means between threads. All depends on what y...
7,450
<p>I'm familiar with the LAMP stack and over the years have successfully deployed a handful of web sties based on it. I've used everything from Apache + modPerl, to PHP, to Ruby and Rails. With good use of caching my Rails site can sustain a pretty good load, but I'm not talking massive.</p> <p>I never really liked Ja...
<p>The key differentiator that Java EE offers over the LAMP stack can be boiled down to a single word. Transactions.</p> <p>Most smaller systems simply rely on the transaction system supplied by the database, and for many applications that is (obviously) quite satisfactory.</p> <p>But each Java EE server includes a d...
<p>Java EE and other program languages must be treated just like any other tool. Yes, it's been used in enterprise environment and it takes good craftsmanship to get these tools to work "perfectly" and knowing when to use it. I'm currently working on a Mainframe environment and Java EE is used to some extent. If hig...
20,476
<p>I need recommendations on what to use in Delphi (I use Delphi 2009) to handle very large XML files (e.g. 100 MB) as fast as possible. </p> <p>I need to input the XML, access and update the data in it from my program, and then export the modified XML again.</p> <p>Hopefully the input and output could be done within...
<p>If I understood your question correctly, you have known data structure and you are modifying data - not XML structure of file. </p> <p>Under these condition <em>and if performance is crucial</em>, then you could try with direct text manipulation - skip XML parsing. </p> <p>Read from stream, use some fast text sear...
<p>Another possibility I just discovered, is with the <a href="http://www.lmdinnovative.com/products/lmdelpack/desc/newfeat.php" rel="nofollow noreferrer">LMD ElPack package</a> that I purchased, they include an XML support library which they say "is extremely fast, fully unicode-enabled and adds only a small footprint...
33,067
<p>I'm currently developing an application that is comprised of five separate executables that communicate via ActiveMQ. I have a Visual Studio Solution that contains the five executable projects. One of the projects (the launcher.exe) launches the other four projects from their local folders as separate processes. ...
<p>What you need is in the Tools menu: Attach to Process. This gives you a list of running processes and allows you to attach your debugger to those processes.</p> <p>For local debugging, Transport and Qualifier should keep their default values. The Attach To value just above the list determines which type of debuggin...
<p>You can pick one at a time by running launcher manually (outside of visual studio, or with &lt;ctrl-f5&gt;) and then attaching to the process you want to debug once it's started. If it's one of the projects in your solution, you can set breakpoints and they'll get picked up when you attach the debugger.</p>
28,733
<p>I have a problem with a oneway web method that open a moss site (probably because in a oneway webmethod the context is null)</p> <p>Is possible to rewrite this code to remove the null reference exception? (without the oneway attribute i don't have the exception)</p> <pre><code>[SoapDocumentMethod(OneWay = true)] ...
<p>i have found a workaround to solve my problem.Create new HttpContext. The question now is: is it the right solution or there are implications that i don't consider?</p> <p>the method that i use to change the context is this:</p> <pre><code>//Call this before call new SPSite() private static void ChangeContext(str...
<p>The only implication that I see is that you are actually using a new HttpContext.</p> <p>Well..duh :)</p> <p>Anyway, this will have implications if you also have input- and outputfilters set up. For example if you are using WebServiceExtensions (WSE) with your own input and outputfilters. In that case, you should ...
44,189
<p>Would NTFS allocation blocks of 16KB or 32KB make compile time faster in comparison to the default 4KB?</p>
<p>I can't imagine that would make much of a difference - disk block size is pretty far removed from compile speed. With the amount of caching a modern OS does, it seems unlikely to be significant.</p> <p>The real answer, of course, can be found by measuring it. Getting similar conditions between different machines wi...
<p>My guess would be that disk fragmentation would be the biggest factor in determining compile speeds (that is, for a code base of decent size).</p>
28,151
<p>What are the best practices for checking in BIN directories in a collaborative development environment using SVN? Should project level references be excluded from checkin? Is it easier to just add all bin directories?</p> <p>I develop a lot of DotNetNuke sites and it seems that in a multi-developer environment, i...
<p>Any assemblies that are expected to be in the GAC should stay in the GAC. This includes System.web.dll or any other 3rd party dll that you'll deploy to the GAC in production. This means a new developer would have to install these assemblies.</p> <p>All other 3rd party assemblies should be references through a relat...
<p>We follow the practice of using a vendor directory which contains all vendor specific headers and binaries. The goal is that anybody should be able to build the product just by checking it out and running some top level build script. </p>
2,278
<p>I've never had much need for programming with databases. Since their use is so widespread it seems like a good thing for me to learn. SQL seems like the place to start, possibly <a href="http://www.sqlite.org/" rel="nofollow noreferrer">SQLite</a> and maybe the <a href="http://pysqlite.org/" rel="nofollow noreferr...
<p>Structure Query Language (SQL) is the language used to talk to database management systems (DBMS). While it's a good thing to learn, it's probably best to do it with a project in mind that you'd like to do. It's funny you say you've never had a need, because I'm the opposite, almost every program I've ever written h...
<p>If you program using the .NET framework, then learning LINQ might be a good place to start. The LINQ "engine" will handle the back end communication with the database (or objects, or entities, or XML, etc.) for you. If you want to dig deeper, you can explore the SQL generated by the LINQ that you write.</p>
13,537
<p>Many of the questions asked here are relevant to research I'm doing. These questions and answers are widely dispersed and not always easy to find, doing manual browsing, and sometimes an insightful answer or comment occurs in unrelated topics as well.</p> <p>I want to automate finding these relevant Q's &amp; A's, ...
<p>It is not clear from your question whether you are a programmer or not, so I'm not sure whether you are after tools in the sense of apps or services that to what you want, or a library that makes site-mining easier.</p> <p>If the latter is the case and you use ruby, I can thoroughly recommend <a href="http://mechan...
<p>Human interaction tools might be useful in such case (no development cost, probably a more consistent outcome, and evolving requirements).</p> <p>Couple comes to mind:</p> <ul> <li><a href="https://requester.mturk.com/mturk/welcome" rel="nofollow noreferrer">Mechanical Turk</a>.</li> <li><a href="http://www.timesv...
20,031
<p>I need to store several date values in a database field. These values will be tied to a "User" such that each user will have their own unique set of these several date values.</p> <p>I could use a one-to-many relationship here but each user will have exactly 4 date values tied to them so I feel that a one-to-many t...
<p>If you do it as four separate fields, then you don't have to join. To Save the query syntax from being too horrible, you could write:</p> <pre><code>SELECT * FROM MyTable WHERE 'DateLiteral' IN (MyDate1, MyDate2, MyDate3, MyDate4); </code></pre> <p>As mentioned in comments, the IN operator is pretty specific when...
<p>Create four date fields and store the dates in the fields. The date fields might be part of your user table, or they might be in some other table joined to the user table in a one-to-one relationship. It's your call.</p>
28,681
<p>I need to be able to change the users' password through a web page (in a controlled environment). So, for that, I'm using this code:</p> <pre><code>&lt;?php $output = shell_exec("sudo -u dummy passwd testUser testUserPassword"); $output2 = shell_exec("dummyPassword"); echo $output; echo $output2; echo "done"; ?&gt;...
<p>I'm not familiar enough with PHP to tell you how to fix it, but your problem is that the two <code>shell_exec</code> commands are entirely separate. It appears as though you're trying to use the second command to pipe input to the first one, but that's not possible. The first command shouldn't return until after tha...
<p>You should use the <a href="http://no2.php.net/crypt" rel="nofollow noreferrer">crypt()</a> function to encrypt the password. Then you can call the <code>usermod</code> program like this <code>usermod --password username encryptedpassword</code>.</p> <p>The most common way to encrypt a UNIX login password is like t...
15,510
<p>I will preface this question by saying, I do not think it is solvable. I also have a workaround, I can create a stored procedure with an OUTPUT to accomplish this, it is just easier to code the sections where I need this checksum using a function.</p> <p>This code will not work because of the <code>Exec SP_ExecuteS...
<p>It "ordinarily" can't be done as SQL Server treats functions as deterministic, which means that for a given set of inputs, it should always return the same outputs. A stored procedure or dynamic sql can be non-deterministic because it can change external state, such as a table, which is relied on.</p> <p>Given that...
<p>Because functions have to play nicely with the query optimiser there are quite a few restrictions on them. <a href="http://blog.sqlauthority.com/2007/05/29/sql-server-user-defined-functions-udf-limitations/" rel="nofollow noreferrer">This link</a> refers to an article that discusses the limitations of UDF's in dept...
18,150
<p>I'm using ADO.NET to access SQL Server 2005 and would like to be able to log from inside the T-SQL stored procedures that I'm calling. Is that somehow possible?</p> <p>I'm unable to see output from the 'print'-statement when using ADO.NET and since I want to use logging just for debuging the ideal solution would be...
<p>I solved this by writing a SQLCLR-procedure as Eric Z Beard suggested. The assembly must be signed with a strong name key file.</p> <pre><code>using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; public partial class StoredProcedures { [Mic...
<p>You could use output variables for passing back messages, but that relies on the proc executing without errors.</p> <pre><code>create procedure usp_LoggableProc @log varchar(max) OUTPUT as -- T-SQL statement here ... select @log = @log + 'X is foo' </code></pre> <p>And then in your ADO code somehwere:</p> <...
8,313
<p>In my web app, when a user logs in, I add his Id to a vector of valid Ids in the servlet, when he logs out, I remove his Id from the vector, so I can see how many current users are active, if a user forgets to log out, my servelt generated html has : </p> <pre><code>&lt;meta http-equiv="Refresh" content="30; url=My...
<p>There is no way to know on the server-side (unless you are using some JavaScript to send a message to the server) that the browser has closed. How could there be? Think of how HTTP works - everything is request and response.</p> <p>However, the application server will track when Sessions are active and will even te...
<p>in JavaScript you can use the <code>onbeforeclose</code> event to pass a call back to the server when the user closes the browser.</p> <p>I typically use a synchronous Ajax call to do this.</p>
38,405
<p>I'd like to use my own diff when working in a clearcase snapshot view. </p> <p>As far as I can see, there is no way to specify a diff tool when running "<code>cleartool diff</code>", so I was thinking I could run something like "<code>mydiff &lt;predecessor file&gt; &lt;modified file in my view&gt;</code>", but I ...
<h2>How to change default diff tools</h2> <p>You can specify an external diff tool by <a href="http://www.guiffy.com/help/GuiffyHelp/ClearCase.html" rel="noreferrer">modifying the file <strong>map</strong></a>, in "c:\program files\rational\ClearCase\lib\mgrs"</p> <p>The WinMerge suggested by Paul actually modifies t...
<p>I installed "WinMerge" (a free diff tool) and it installed itself as the clearcase diff tool. I'm not sure how it did that.</p>
49,127
<p>I have an AIR application that takes command-line arguments via onInvoke. All is good, but I cannot figure out how to print some status messages back to the user (to stdout / console, so to speak). Is it possible?</p> <p>Even a default log file for traces would be fine, but I can't find any info about it anywhere. ...
<p>Take a look at <a href="http://www.mikechambers.com/blog/2008/01/17/commandproxy-net-air-integration-proof-of-concept/" rel="nofollow noreferrer">CommandProxy</a>. It is a low level wrapper around your AIR application that lets you send command from AS3 back to the proxy for communicating with the underlying OS. You...
<p>I don't think that is possible, but I'm not completely sure though.</p> <p>There is a flashlog.txt file which you can configure so all trace() statements are logged to it. Check this post <a href="http://www.digitalflipbook.com/archives/2005/07/trace_from_the.php" rel="nofollow noreferrer">http://www.digitalflipboo...
24,516
<p>Assume a table structure of <code>MyTable(KEY, datafield1, datafield2...)</code>.</p> <p>Often I want to either update an existing record, or insert a new record if it doesn't exist.</p> <p>Essentially:</p> <pre><code>IF (key exists) run update command ELSE run insert command </code></pre> <p>What's the best...
<p>don't forget about transactions. Performance is good, but simple (IF EXISTS..) approach is very dangerous.<br> When multiple threads will try to perform Insert-or-update you can easily get primary key violation.</p> <p>Solutions provided by @Beau Crawford &amp; @Esteban show general idea but error-prone.</p> <p>T...
<p>Do a select, if you get a result, update it, if not, create it.</p>
13,377
<p>This might be a bit on the silly side of things but I need to send the contents of a DataTable (unknown columns, unknown contents) via a text e-mail. Basic idea is to loop over rows and columns and output all cell contents into a StringBuilder using .ToString(). </p> <p>Formatting is a big issue though. Any tips/id...
<p>Would converting the datatable to a HTML-table and sending HTML-mail be an alternative? That would make it much nicer on the receiving end if their client supports it.</p>
<p>You can do smth like this (if VB):</p> <pre><code>Dim Str As String = "" 'Create File if doesn't exist Dim FILE_NAME As String = "C:\temp\Custom.txt" If System.IO.File.Exists(FILE_NAME) = False Then System.IO.File.Create(FILE_NAME) End If Dim objWriter As System.IO.S...
7,719
<p>Unit testing sounds great to me, but I'm not sure I should spend any time really learning it unless I can convince others that is has significant value. I have to convince the other programmers and, more importantly, the bean-counters in management, that all the extra time spent learning the testing framework, writ...
<p>Yes. This is a <a href="http://collaboration.csc.ncsu.edu/laurie/Papers/TDDpaperv8.pdf" rel="noreferrer">link</a> to a study by Boby George and Laurie Williams at NCST and a <a href="http://research.microsoft.com/en-us/groups/ese/nagappan_tdd.pdf" rel="noreferrer">another</a> by Nagappan et al. I'm sure there are ...
<p>I do have one set of data points for this - from an experience that sold me on unit tests. </p> <p>Many moons ago I was a fresh graduate working on a large VB6 project and had occasion to write a large body of stored procedure code. Of the subsystem I was writing it made up about 1/4 of the whole code base - arou...
29,320
<p>Is there a way to find the number of files of a specific type without having to loop through all results inn a Directory.GetFiles() or similar method? I am looking for something like this:</p> <pre><code>int ComponentCount = MagicFindFileCount(@"c:\windows\system32", "*.dll"); </code></pre> <p>I know that I can ma...
<p>You should use the <a href="http://msdn.microsoft.com/en-us/library/ms143316.aspx" rel="noreferrer">Directory.GetFiles(path, searchPattern, SearchOption)</a> overload of Directory.GetFiles().</p> <p>Path specifies the path, searchPattern specifies your wildcards (e.g., *, *.format) and SearchOption provides the opt...
<p>Someone has to do the iterating part.</p> <p>AFAIK, there is no such method present in .NET already, so I guess that someone has to be you.</p>
4,718
<p>Do you localize your javascript to the page, or have a master "application.js" or similar?</p> <p>If it's the latter, what is the best practice to make sure your .js isn't executing on the wrong pages?</p> <p>EDIT: by javascript I mean custom javascript you write as a developer, not js libraries. I can't imagine a...
<p>Putting all your js in one file can help performance (only one request versus several). And if you're using a content distribution network like Akamai it improves your cache hit ratio. Also, always throw inline js at the very bottom of the page (just above the body tag) because that is executed synchronously and can...
<p>Personally, I try to include several Javascript files, sorted by module (<a href="http://developer.yahoo.com/yui/" rel="nofollow noreferrer">like YUI does</a>). But once in a while, when I'm writing essentially a one-liner, I'll put it on the page.</p>
38,492
<p>I have been asked to write a testing application that needs to test a new stored procedure on multiple rows in a database, in essence I want to do something like this:</p> <pre><code>[Test] public void TestSelect() { foreach(id in ids) { DataTable old = Database.call(&quot;old_stored_proc&quot;,id); ...
<p>1) If the id's are constant and not looked up at test run time, create a separate unit test fixture for each id. That way you will know which id's are actually failing. See here for a write up on the problems with data driven tests:<br> <a href="http://googletesting.blogspot.com/2008/09/tott-data-driven-traps.html...
<p>Well you could declare a counter and then assert the value of the counter to determine pass/fail</p> <p>Also, you could do the bulk of the work in the test setup, and then just create multiple tests. </p> <p>I'm not clear as to why you need all the assert stmts in the same test.</p>
20,238
<p>Is there a quick and nice way using linq?</p>
<p>How about:</p> <pre><code>var most = list.GroupBy(i=&gt;i).OrderByDescending(grp=&gt;grp.Count()) .Select(grp=&gt;grp.Key).First(); </code></pre> <p>or in query syntax:</p> <pre><code>var most = (from i in list group i by i into grp orderby grp.Count() descending select g...
<p>Someone asked for a solution where there's ties. Here's a stab at that:</p> <pre><code>int indicator = 0 var result = list.GroupBy(i =&gt; i) .Select(g =&gt; new {i = g.Key, count = g.Count()} .OrderByDescending(x =&gt; x.count) .TakeWhile(x =&gt; { if (x.count == indicator || indicator ==...
46,405
<p>Today someone asked me what was wrong with their source code. It was obvious. "Use double equals in place of that single equal in that if statement. Um, I think..." As I remember some languages actually take a single equals for comparison. Since I sometimes forget or mix up the syntax details among the several l...
<p>IDEs that can draw red and yellow squiggles can help, until you develop that mental muscle memory.</p> <p>One of the annoying things with XCode (for Cocoa/ObjectiveC) is that you don't get said squiggles until you compile. (As opposed to Eclipse/Java where you get live squiggles).</p>
<p>Indeed, on SO I advised not to forget avoiding <code>if (a = b)</code> in Java, and someone reminded me that it is legal only if a and b are boolean! Of course, the advice is good for C, C++, JavaScript and a number of other C-like languages.</p> <p>Likewise, I realized only recently that <code>var v</code> in Java...
27,729
<p>If I have a Java source file (*.java) or a class file (*.class), how can I convert it to a .exe file?</p> <p>I also need an installer for my program.</p>
<h3><a href="https://docs.oracle.com/javase/10/tools/javapackager.htm" rel="noreferrer">javapackager</a></h3> <blockquote> <p>The Java Packager tool compiles, packages, and prepares Java and JavaFX applications for distribution. The javapackager command is the command-line version.</p> <p>– Oracle's documentation</p> <...
<p>Java projects are exported as Jar executables. When you wanna do a .exe file of a java project, what you can do is 'convert' the JAR to EXE (i remark that i putted between quotes convert because isn't exactly this).</p> <p>From intelij you gonna be able to generate only the jar</p> <p>Try following the next exampl...
17,720
<p>How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#?</p> <p>I know to do it using plan <code>String.Replace</code>, like:</p> <pre><code>myStr.Replace(&quot;\n&quot;, &quot;\r\n&quot;); myStr.Replace(&quot;\r\r\n&quot;, &quot;\r\n&quot;); </code></pre> <p>However, t...
<p>Will this do?</p> <pre><code>[^\r]\n </code></pre> <p>Basically it matches a '\n' that is preceded with a character that is not '\r'.</p> <p>If you want it to detect lines that start with just a single '\n' as well, then try</p> <pre><code>([^\r]|$)\n </code></pre> <p>Which says that it should match a '\n' but ...
<pre><code>myStr.Replace("([^\r])\n", "$1\r\n"); </code></pre> <p>$ may need to be a \</p>
5,091
<p>I am trying to write a cronjob controller, so I can call one website and have all modules cronjob.php executed. Now my problem is how do I do that?</p> <p>Would curl be an option, so I also can count the errors and successes?</p> <p>[Update]</p> <p>I guess I have not explained it enough. </p> <p>What I want to d...
<p>After some research and a lot procrastination I came to the simple conclusion that a ZF-ized cron script should contain all the functionality of you zend framework app - without all the view stuff. I accomplished this by creating a new cronjobfoo.php file in my application directory. Then I took the bare minimum fr...
<p>Do you have filesystem access to the modules' directories? You could iterate over the directories and determine where a CronjobController.php is available. Then you could either use <code>Zend_Http_Client</code> to access the controller via HTTP or use an approach like <code>Zend_Test_PHPUnit</code>: simulate the ac...
17,309
<p>I need to do an <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods" rel="noreferrer">HTTP GET</a> request in JavaScript. What's the best way to do that?</p> <p>I need to do this in a Mac OS X dashcode widget.</p>
<p>Browsers (and Dashcode) provide an XMLHttpRequest object which can be used to make HTTP requests from JavaScript:</p> <pre><code>function httpGet(theUrl) { var xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", theUrl, false ); // false for synchronous request xmlHttp.send( null ); return xmlHttp....
<p>You can do it with pure JS too:</p> <pre><code>// Create the XHR object. function createCORSRequest(method, url) { var xhr = new XMLHttpRequest(); if ("withCredentials" in xhr) { // XHR for Chrome/Firefox/Opera/Safari. xhr.open(method, url, true); } else if (typeof XDomainRequest != "undefined") { // XDomainReque...
30,743
<p>The primary class in the <code>subprocess</code> module is name <code>Popen</code>, and represents a subprocess. <code>Popen</code> sounds like someone was trying to force the name to follow some function naming format, rather than chosing a name that actually represents what the object is. Does anyone know why it ...
<p>Now, I'm not saying that this is the greatest name in the world, but here was the idea as I understand it.</p> <p>Originally, the popen family was in the os module and was an implementation of the venerable posix popen. The movement to the subprocess module would have been an opportune time to rename them, but I g...
<p>I suppose the name was chosen because the functionality <code>subprocess</code> is replacing was formerly in the <code>os</code> module as the <code>os.popen</code> function. There could be even ways to automate migration between the two.</p>
5,911
<p>I would like to dynamically hide a button in one of my views depending on a certain condition.</p> <p>I tried adding some code to the view controller's <code>-viewWillAppear</code> method, to make the button hidden before displaying the actual view, but I still don't know how to do that.</p> <p>I have a reference ...
<p>If you're trying to hide a UIBarButtonItem, you'll actually have to modify the contents of the parent bar. If it's a UIToolBar, you'll need to set the bar's items array to an array that doesn't include your item.</p> <pre><code>NSMutableArray *items = [[myToolbar.items mutableCopy] autorelease]; [items removeOb...
<p>Just set the button's hidden property to true:</p> <pre><code>myButton.hidden = YES; </code></pre>
34,922
<p>During a recent load test, I've been getting some strange "Index Out of Range Exception" </p> <p>Stack trace: </p> <pre><code> at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]&amp; outputBuffer, Int32 outputOffset, PaddingMode pa...
<p>If someone initiates a post, the application starts sending the post with all 500KBs of viewstate. Half way through postback, the user gets bored and clicks something else. The browser cuts off the postback with just part of the viewstate. The server throws an error that says the viewstate is borked. I would gue...
<p>Just a guess: have you disabled EventValidation on the site? Sounds like something is trying to create a manual postback or otherwise insert data directly into the http request's post data, and isn't calculated the correct value for the viewstate field. This in turn causes the decryption to fail spectacularly. <...
41,096
<p>I have multiple users running attachemate on a Windows 2003 server. I want to kill attachemate.exe started by user_1 without killing attachemate.exe started by user_2.</p> <p>I want to use VBScript.</p>
<p>You could use this to find out who the process owner is, then once you have that you can use Win32_Process to kill the process by the process ID.</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa394372.aspx" rel="noreferrer">MSDN Win32_Process class details</a></p> <p><a href="http://msdn.microsoft.com/e...
<p>Shell out to pskill from <a href="http://sysinternals.com/" rel="nofollow noreferrer">http://sysinternals.com/</a></p> <p>Commandline: pskill -u user_1 attachemate.exe</p>
10,188
<p>I'm using GPS units and mobile computers to track individual pedestrians' travels. I'd like to in real time "clean" the incoming GPS signal to improve its accuracy. Also, after the fact, not necessarily in real time, I would like to "lock" individuals' GPS fixes to positions along a road network. Have any techniques...
<p>I assume you want to "clean" your data to remove erroneous spikes caused by dodgy readings. This is a basic dsp process. There are several approaches you could take to this, it depends how clever you want it to be.</p> <p>At a basic level yes, you can just look for really large figures, but what is a really large f...
<p>In addition to Andrew's comments, you may also want to consider interference factors such as multipath, and how they are affected in your incoming GPS data stream, e.g. HDOPs in the GSA line of NMEA0183. In my own GPS controller software, I allow user specified rejection criteria against a range of QA related param...
42,776
<p>Is there an SSH client that can present a client side GUI interface to the <a href="http://www.cyberciti.biz/tips/how-to-use-screen-command-under-linux.html" rel="nofollow noreferrer">screen</a>* program?</p> <p>I'm thinking of an SSH program that would hook in with screen's session handling and map client side act...
<p>An interesting idea, and quite possible (vim7's tabs show as clicky GUI tabs in gnome-terminal), but I don't see the benefit of doing this..</p> <p>Using the follow <code>~/.screenrc</code> shows "graphical" tabs:</p> <pre><code>startup_message off vbell off hardstatus alwayslastline hardstatus string '%{gk}[ %{G}...
<p>I've never seen one, but the following may help you. Add to your .screenrc</p> <p>To show a row of "tabs" on the bottom caption always "%{.bW}%-Lw%{.rW}%n %t%{-}%+Lw %=%{..G} %{..Y} %m/%d"</p> <p>To show the current program as the screen name [assuming you're using bash and your prompt ends with "$ " by default; ...
44,078
<p>I need to write robust code in .NET to enable a windows service (server 2003) to restart itself. What is the best way to so this? Is there some .NET API to do it?</p>
<p>Set the service to restart after failure (double click the service in the control panel and have a look around on those tabs - I forget the name of it). Then, anytime you want the service to restart, just call <code>Environment.Exit(1)</code> (or any non-zero return) and the OS will restart it for you.</p>
<p>The better approach may be to utilize the NT Service as a wrapper for your application. When the NT Service is started, your application can start in an "idle" mode waiting for the command to start (or be configured to start automatically). </p> <p>Think of a car, when it's started it begins in an idle state, wai...
27,136
<p>Has anyone had any recent requirements for programming automated DOS Batch style tasks on a Windows box?</p> <p>I've got some automation to do and I'd rather not sit and write a pile of .BAT files in Notepad if there is a better way of automating these tasks: mainly moving of files under certain date and time condi...
<p>For simple Windows automation beyond BAT files, <a href="http://msdn.microsoft.com/en-us/library/sx7b3k7y(VS.85).aspx" rel="nofollow noreferrer">VBScript</a> and <a href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx" rel="nofollow noreferrer">Powershell</a> might be worth a look. If you're wondering ...
<p>vbscript/WSH is actually what Microsoft wants you to use - unfortunately, I've written a few of those and it is not pleasant - </p> <p>I totally agree with Mikael - if you know what systems will be running the scripts and you can install interpretters on them, go with a scripting language like Python or Ruby</p> <...
17,651
<p>DataGridView.CellContentClick is not firing if I mouse click a DataGridViewCheckBoxCell very fast. How can I solve this? I need to know when CheckBox's check state changes</p>
<p>Try handling the <code>CellMouseUp</code> event.<br> You can check which colum the <code>MouseUp</code> event occurred in to see if it is your checkbox column.<br> You can also find out if it is in edit mode and end the edit mode programmatically, which in turn will fire the <code>CellValueChanged</code> event. </p>...
<p>It's better to handle the event <code>CellContentClick</code> (if you click accidentally outside the box itself, it won't work properly):</p> <pre><code>grid.CellContentClick += delegate(object obj, DataGridViewCellEventArgs args) { var cell = (settings_grid[args.ColumnIndex,args.RowIndex] as DataGridViewCheckB...
49,944
<p>I have a class that encapsulates tcp socket communications with a server. For each command message sent to the server, the server will send back a response message that invariably contains a response code (OK, Fail). Using my class, each command can be executed either sync or async.</p> <p>There are basically two t...
<p>I think your strategy is basically sound.</p> <p>Keep in mind that the purpose of Exceptions is to deal with exceptional conditions. The closer to the source of the problem, the better. </p> <p>In your case, it appears that your strategy is something like "It didn't work right now. Let's retry". I don't see a rea...
<p>Result codes and exceptions can both work fine. It is a matter of personal taste (and the taste of the others on your team). Exceptions have some advantages, especially in more complex settings, but in your setting it sounds simple enough that return codes should work okay.</p> <p>Some people will foam at the mou...
17,059
<p>I know that to change the index page for rails I need to do three things: delete the index.html, do something with routes.rb, and probably make an action that the route will point to. It's the details that I am a little fuzzy on :-)</p>
<p>Ok, I figured it out. Basically you</p> <ol> <li>Delete public.html</li> <li>Add 'map.root :controller => "foo"' to routes.rb</li> <li>and then of course create the controller foo with the action index.</li> </ol>
<p>Please note from RoR Version 4.0 + this changed - follow the simple steps on the <a href="http://guides.rubyonrails.org/getting_started.html" rel="nofollow">getting started guide</a> !</p> <p>It will become clear within minutes how it works. </p> <p>Just thought it might be worth updating this threat, as those usi...
21,326
<p>I've been perplexed lately working on a SharePoint state machine workflow. I was hoping to add some modification forms to the workflow so that I could reassign a task while in its state. Unfortunately, modification forms don't seem to be documented for use with state machine workflows (pretty straight forward for ...
<p>Why don't you just modify task form and extend it by possibility to reassign task?</p>
<p>First, I know this is a super old thread but since it was high on the search engine results I figured I'd put the solution here.</p> <p>All you need to do is this with your Modification GUID:</p> <ol> <li>Add EnableWorkflowModification activity in the workflow's Initial State</li> <li>Add EventDriven activity to t...
27,381
<p>I am looking for a library that will allow me to look up the status of a windows service to verify that the service is started and running. I looked into the Sigar library, but it is GPL and therefor I cannot use it. A Commercial or BSD(ish) license is required as this will be bundled into commercial software.</p>...
<p>If nothing else helps, try to think of a slightly different approach (if you can, of course), e.g.:</p> <ul> <li>There is a plenty of free/non-free software which does monitoring, including Windows service monitoring (e.g. nagios, Zabbix, etc.). These monitors typically have open API where your Java app could integ...
<p>I don't know of any libraries, but depending on how detailed you need to get you might get by with some shell commands and parsing the output.</p> <p>NET START <em>servicename</em></p> <p>will either start the service, or give you back an error message that tells you its already started. I don't know of any comm...
15,489
<p>What are some useful Oracle optimizations one can use for an Application that mostly writes (updates) to an Oracle database? </p> <p>The general usage pattern here is not web-serving or logging, as is most cases, but instead to persist complex state of a system, so the only times reading is needed is when the syste...
<p>Monitoring of the system health using statspack (9i) or AWR (10g+) would be the best method of identifying bottlenecks.</p> <p>In particular:</p> <ul> <li>lookout for redo waits. The redo log is critical in maintaining a high write rate</li> <li>Use bind variables</li> <li>Use bulk operations wherever possible.</l...
<p>Depending on the characteristics of your application and your data, consider a bulk data load using an Oracle external table. Have the application write the data to a text file, then use an INSERT INTO your target table from a SELECT on the external table = very fast.</p> <p>There are some constraints, and it may ...
22,457
<p>I have implemented some table-per-type inheritance in my data model (basically have a <code>BaseEntity</code> type with all the base information for my items and a <code>Employer</code> type that inherits from the <code>BaseEntity</code> item). Everything appears to be set up correctly and when using the Entities (...
<p>I changed a couple of things and was able to get this to work. I am not particularly sure what was the base issue, but wanted to post what I did do for reference.</p> <p>Rebuilt Tables: I rebuilt the tables starting with just the ID/Key columns and a single data column.</p> <p>Removed extra auto incrementing fiel...
<p>You don't have Employer defined as entity set, just like entity type. That is way you are missing AddToEntity in the context object. There is always one entity set for one class hierarchy, in this case it is BaseClass entity set.</p> <p>If you want to get entity set 'Employer' you can try to manually edit edmx file...
25,958
<p>If you have binary strings (literally String objects that contain only 1's and 0's), how would you output them as bits into a file?</p> <p>This is for a text compressor I was working on; it's still bugging me, and it'd be nice to finally get it working. Thanks!</p>
<p>Easiest is to simply take 8 consecutive characters, turn them into a byte and output that byte. Pad with zeros at the end if you can recognize the end-of-stream, or add a header with length (in bits) at the beginning of the file.</p> <p>The inner loop would look something like:</p> <p><pre><code> byte[] buffer = n...
<p>Assuming the String has a multiple of eight bits, (you can pad it otherwise), take advantage of Java's built in parsing in the Integer.valueOf method to do something like this:</p> <pre><code>String s = "11001010001010101110101001001110"; byte[] data = new byte[s.length() / 8]; for (int i = 0; i &lt; data.length; i...
11,947
<p>First of all, I'm not looking for miracle... I know how PHP works and that there's not really way to hide my code from the clients without using encryption. But that comes with the cost of an extension to be installed on the running server.</p> <p>I'm looking for something different though... I'm not looking to enc...
<p>Obfuscating things can only inconvenience your legitimate, law-abiding customers, while the people who would would rip you off are not your target paying customers anyway. (edited out other thoughts about obfuscation)</p> <p>Another suggestion for protecting your software: create a business model in which the cod...
<p>So let me see, we want to show adam and eve there's some forbidden fruit in a tree, adn we 'd like a way to prevent them from eating... </p> <p>How about having an angel with a flaming sword?</p> <ol> <li><p>Might sound naive, and I dunno what your application does actually, but what about the extensive use of in...
43,603
<p>I know that I can add the SourceSafeTypeLib to a project and can explore it in object browser and find obvious things (GetLatest, etc), but I am looking for some more thorough documentation or specific tutorials on things like "undo another user's checkout" or"determine who has a file checked out. </p> <p>If anyone...
<p>You might check out Microsoft's <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.sourcesafe.interop(VS.80).aspx" rel="nofollow noreferrer">documentation</a> on the Microsoft.VisualStudio.SourceSafe.Interop namespace (I assume that's what you've looked at). I used it to create a VB.NET utility ...
<p>You can also have a look at <a href="http://msdn.microsoft.com/en-us/library/4d44xhsd(VS.80).aspx" rel="nofollow noreferrer">Visual SourceSafe Automation</a> article at MSDN.</p>
15,731
<p>When implementing a needle search of a haystack in an object-oriented way, you essentially have three alternatives:</p> <pre><code>1. needle.find(haystack) 2. haystack.find(needle) 3. searcher.find(needle, haystack)</code></pre> <p>Which do you prefer, and why?</p> <p>I know some people prefer the second altern...
<p>Usually actions should be applied to what you are doing the action on... in this case the haystack, so I think option 2 is the most appropriate.</p> <p>You also have a fourth alternative that I think would be better than alternative 3:</p> <pre><code>haystack.find(needle, searcher) </code></pre> <p>In this case, ...
<p>Definitely the third, IMHO.</p> <p>The question of a needle in a haystack is an example of an attempt to find one object in a large collection of others, which indicates it will need a complex search algorithm (possibly involving magnets or (more likely) child processes) and it doesn't make much sense for a haystac...
4,361
<p>I've been developing web apps for over a decade now, all the way from <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface" rel="nofollow noreferrer">CGI</a> to <a href="http://en.wikipedia.org/wiki/Asp.net" rel="nofollow noreferrer">ASP.Net</a> and <a href="http://en.wikipedia.org/wiki/Apache_Struts" rel=...
<p>I agree, to a point - we are becoming are more client-centric, but I think this is because the clients are actually advancing in a standardized way.</p> <p>We started out with everything on the client - because thats all there was. Then it was client-server, which separated the two, then gradually the client bit wa...
<p>Lets clarify something! </p> <ol> <li>MVC is only a design pattern for the seperation of concerns. There is no really relation to server side frameworks. </li> <li>There is no technical Web 1.0 or Web 2.0 ... JavaScript and Flash were there for years. It's only about social networking, tagging etc.</li> </ol> <p>T...
21,535