input
stringlengths
51
42.3k
output
stringlengths
18
55k
Does closing a database connection in Dispose method is right? <p>I've had a suspicion that a database connection used in one of our applications is not always closed. I went to see the code and I've found a class DataProvider that has SqlConnection object. The connection is opened in the constructor of this class and ...
<p>Dispose is never called automatically.</p> <p>The connection will not be closed until the Dispose method of your object is explicitly called, or if your class in used in a using() block</p> <p>A safer way is to call the dispose method in your finalizer and ensure the finalizer is suppressed when the Dispose method...
EXC_BAD_ACCESS when moving iPhone app from 2.2 to 3.0 simulator <p>Well I had an app I was developing in iPhone SDK 2.2 and I recently built and launched it in the 3.0 simulator. The base SDK is still set to 2.2. I figured that would avoid issues. Instead I get</p> <pre><code>Exception Type: EXC_BAD_ACCESS (SIGSEGV) ...
<p>When I installed my 3.0 SDK my 2.0 tools went away, so not sure if this is applicable, but I don't think simulator builds are designed to be binary compatible to future runtimes.</p> <p>It is likely though that the problem lies in your code. If so, I can say is that you have a memory management issue and not "threa...
How can I strip invalid XML characters from strings in Perl? <p>I'm looking for what the standard, approved, and robust way of stripping invalid characters from strings before writing them to an XML file. I'm talking here about blocks of text containing backspace (^H) and formfeed characters etc.</p> <p>There <em>has<...
<p>As almost everyone else has said, use a regular expression. It's honestly not complex enough to be worth adding to a library. Preprocess your text with a substitution. </p> <p>Your comment about linefeeds above suggests that the formatting is of some importance to you so you will possibly have to decide exactly wha...
MetaStorm Ework and SharePoint 2007 <p>Has anyone had any experience working with MetaStorm Ework web parts in SharePoint 2007?</p> <p>I've been asked to have a look at this and would be interested to know your thoughts on the best way to approach this.</p> <p>All the best</p>
<p>I can't answer, but you can probably find an answer on our Metastorm BPM Forums, or post the question there and you can get a quick response:</p> <p><a href="http://metastorm.processmapping.com.au/" rel="nofollow">http://metastorm.processmapping.com.au/</a></p>
Django development add-ons <p>I have come across various <a href="http://en.wikipedia.org/wiki/Django_%28web_framework%29" rel="nofollow">Django</a> development add ons, particularly,</p> <ul> <li><p><a href="http://github.com/django-extensions/django-extensions/tree/master" rel="nofollow">django-extensions</a></p></l...
<p>I for one love <a href="http://bitbucket.org/offline/django-annoying/" rel="nofollow">django-annoying</a>'s <code>render_to</code> method.</p> <pre><code>@render_to('template.html') def foo(request): bar = Bar.objects.all() return {'bar': bar} # equivalent to def foo(request): bar = Bar.objects.all() ...
Can I subclass a abstract class which has another abstract class which is also subclassed? (C#) <p>Lets say I want to design a abstract system for counting sections in a document. I designed two classes, <em>Document</em> and <em>Section</em>, the document has a list of sections and a method to count them.</p> <pre><c...
<p>You need generics:</p> <pre><code>public abstract class Document&lt;T&gt; where T : Section public abstract class Section public class Book : Document&lt;Chapter&gt; public class Chapter : Section </code></pre> <p>You might <em>also</em> want to make a section know what kind of document it can be part of. Unfor...
Verify integrity Ceritifcate { RSACryptoServiceProvider - SHA1 - thumbprint } <p>sorry for my english.</p> <p>I have a little problem. I want to verify the integrity of my certificat.</p> <p>I make this code:</p> <pre><code>using System.Security.Cryptography; using System.Runtime.InteropServices; using System.Securi...
<p>There is no actual question here. You are right that you are unconditionally ignoring the initial value of verif. More importantly, have you considered using X509Certificate2 to do verification?:</p> <pre><code>X509Certificate2 x2 = new X509Certificate2(certificatEnCours); bool verif = x2.Verify(); </code></pre>...
How to show url address bar for safari using MM_openBrWindow()? <p>I am using function MM_openBrWindow() to open new window. Here is the javascript. </p> <pre><code>function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); return false; } </code></pre> <p>This is how t...
<p>You could try adding in the <code>locationbar</code> property.</p> <pre><code>&lt;a href="index.php" onclick="MM_openBrWindow('index.php','','scrollbars=yes,location=yes,locationbar=yes,menubar=no,width='+screen.availWidth+',height='+screen.availHeight);return false"&gt;&lt;img src="images/logo.jpg" alt="Logo" /&gt...
move image in text area in flex <p><img src="http://img31.imageshack.us/img31/1183/tedit.jpg" alt="alt text" /></p> <p>Hi Guys,</p> <p>I am trying to make a text editor in Flex. i can move image on mouse click. Problem is it moves with the key up or down handler. But it moves out of text area after the last line in...
<p>You may want to increase the white space of your 'text editor'. Just have numbers up till person entered text. That way when you move to the bottom you are not moving outside of the textArea. </p> <p>would need more example of what is going wrong with the key up or down handler. What events are you trying to captur...
What should be my standard choice of integer type in RPGLE? <p>When I want an integer in an RPGLE program, what data type should I choose? I'm talking about an integer that doesn't correspond to any field in the database, just a normal general purpose integer - kind of the equivalent of an <code>int</code> in Java.</p...
<p>Here's a chart from the ILE RPG Programmer's reference guide:</p> <pre><code>byte - 3I 0 (1-byte integer) short- 5I 0 (2-byte integer) int - 10I 0 (4-byte integer) long - 20I 0 (8-byte integer) </code></pre> <p>I use the 10I 0 form of integer most often. You'll find it's used in most of your API calls as w...
Possible ways of making an Object immutable <p>I am looking for some efficient way for building a immutable class, just like Java's String class.</p>
<ol> <li>All the fields must be <code>private</code> and preferably <code>final</code></li> <li>Ensure the class cannot be overridden - make the class final, or use static factories and keep constructors private</li> <li>Fields must be populated from the Constructor/Factory</li> <li>Don't provide any setters for the fi...
migrate from C#.net 2.0 to php so the hash value of the password - how to resolve? <p>we previously use a C#.net 2.0 to create a web app.</p> <p>Users password were hashed and stored in database using the following code.</p> <pre><code>private const string encryptionKey = "AE09F72B007CAAB5"; HMACSHA1 hash = new HMAC...
<p>In your C# app you generate the byte[] arrays in two different ways with a little bit different results. Your PHP script needs to emulate them exactly. <blockquote>hash.Key = HexToByte(encryptionKey)</blockquote> You pass in a 16 characters long string and get an array of 8 bytes, just like <code>hash.Key = new byte...
Rails flash message remains for two page loads <p>I'm using a flash notice in a Rails application, with the following code:</p> <pre><code>flash[:notice] = "Sorry, we weren't able to log you in with those details." render :action =&gt; :new </code></pre> <p>The flash message renders as expected on the 'new' action, b...
<p>There are two way to solve this problem. One is to use </p> <pre><code>flash.now[:notice] </code></pre> <p>when your flash must be discarded at the end of the current request and is not intended to be used after a redirect.</p> <p>The second one is to call</p> <pre><code>flash.discard(:notice) </code></pre> <p>...
Handling web.config differences across multiple machines when using version control <p>I'm sure everyone has to deal with these situations, we check in our solution to source control and each dev machine will have its own resources for debugging, building and testing..</p> <p>The most common being:</p> <ul> <li>Web s...
<p>One approach that I sometimes use is to break out environment-specific section into separate config file, that are usually excluded from deployment (except for the first time or if their structure change):</p> <p>Example for connection strings: In web.config:</p> <pre><code>&lt;connectionStrings configSource="conn...
store PDF file in DB as byte <pre><code> I am using Asp.Net MVC. in my project while uploading PDF file we convert the PDF file into byte then store it in DB. but i got the following exception. </code></pre> <p>" String or binary data would be truncated. The statement has been terminated."</p> <p>Can any one so...
<p>Just change the size of your field, try varbinary(MAX).</p>
key events <p>i have tried a lot ...as u all gave me the code segments as a solution...but still the same error is accured...so can anyone give me the solution... It seems a big oversight that the Robot cannot be used to enter basic non-alphanumeric characters.</p> <p>Is there a cross-platform API that converts charac...
<p><code>KeyStroke.getKeyStroke()</code></p>
Extract the Text in a Element with JQuery <p>I want to extract the Text inside a Element with JQuery</p> <pre><code>&lt;div id="bla"&gt; &lt;span&gt;&lt;strong&gt;bla bla bla&lt;/strong&gt;I want this text&lt;/span&gt; &lt;/div&gt; </code></pre> <p>I want only the text "I want this text" without the strong-tag. H...
<p>Try this...</p> <pre><code>&lt;script type="text/javascript"&gt; //&lt;![CDATA[ $(document).ready(function(){ $("#bla span").contents().each(function(i) { if(this.nodeName == "#text") alert(this.textContent); }); }); //]]&gt; &lt;/script&gt; </code></pre> <p>This doesn't need to remove any other n...
SQL Server 2008 retain last open databases <p>I use around 3 SQL Server 2008 databases. Every time I need to query on a database, I need to login to that db and then query. Is there a way to retain the last opened database in SQL Server 2008?</p> <p>As an analogy, think this is like firefox allowing to display the las...
<p>SQL Server retains last opened database. It actually never closes them (auto_close and user instances not withstanding). Do you mean Management Studio by any chance? You can add an USE statement to your saved query. You can use sqlcmd extensions in your query to simply run the query in one shot on all servers/db. Or...
How can I include unit tests in maven assembly? <p>Reason: Our project is using Ant as commandline interface. After making a new assembly with maven's assembly plugin, I want to make initial tests to see if all has been properly assembled. Therefore I need to include the unit tests in the final assembly. After assembli...
<p>There are two steps:</p> <ol> <li>Package the tests into a jar as well as the main code.</li> <li>Depend on that "-tests" jar in the module that makes the assembly.</li> </ol> <p>To package up the tests, you need to bin the <a href="http://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html">jar:test-jar<...
OSX Malicious Terminal Command (colon, brackets, curly brackets, apersand, etc) <p>Ok, so someone "challenged" me to enter this into my OSX Terminal, but I have no idea what it would do:</p> <p><strong>WARNING</strong> to the reader: the following line can be harmful; do <strong>NOT</strong> enter it unless you know w...
<p>It's a <a href="http://en.wikipedia.org/wiki/Fork%5Fbomb">fork bomb</a>. Don't do it. (Actually, as GB pointed out quickly, the copy here started out as a broken fork bomb. It was missing its final colon.) Still, if someone says, "Try this command" while snickering, and you don't know what it does, common sense says...
NuSOAP on XAMPP with PHP5: failed to open stream <p>Hey guys, I have a problem (again). This time I am trying to use NuSoap w/ XAMPP 1.7.1 which includes PHP5 and MySQL ... I wrote a soap-client:</p> <pre><code>&lt;?php // Pull in the NuSOAP code require_once('nusoap.php'); // Create the client instance $client = new ...
<p>I used NuSOAP version 1.7.3 with PHP5. In this NuSOAP 1.7.3, soapclient class renamed by nu_soapclient.</p> <p>You can try this:</p> <pre><code>$client = new nusoap_client('http://localhost/mysql/helloworld2.php'); </code></pre>
Fastest way of checking the condition l+1<r for int l,r in Java <p>What is the fastest way of checking the condition</p> <pre><code>l + 1 &lt; r </code></pre> <p>for <code>int l,r</code> in Java?</p> <p><code>l</code> and <code>r</code> are not constant and I know that <code>l &lt;= r</code>. The comparison is a sto...
<p>This kind of micro-optimization is almost always a bad idea; your performance for such a small bit will be entirely dependent on how the hotspot compiler optimizes your code, and subtle cache effects having to do with the surrounding code.</p>
Can't find MSVCP80.dll (side by side problem?) <p>when I try to start the release-version of my project from visual studio 2005 (SP1) I get the following error message:</p> <p>"This application has failed to start because MSVCP80.dll was not found. Re-installing the application may fix this problem"</p> <p>When I loo...
<p>can be a registry problem. Do what is suggested and reinstall MS CRT </p> <p><a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647" rel="nofollow">http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=200b2fd9-ae1a-4a14-984d-3...
Ideas on how to display a modeless message box as a tooltip <p>I need to display a modeless message box whenever a user hovers over a menu item. I can't use messagebox.show(...) because it is a modal. So what I did was create a seperate windows form and display the form using the hover event on the menu item. I have 2 ...
<p>To answer your second problem:</p> <p>If you set the <code>form.StartPosition</code> property to <code>FormStartPosition.Manual</code> then you can position the form at the cursor (for example):</p> <pre><code>form.StartPosition = FormStartPosition.Manual; form.Location = new Point(Cursor.Position.X - 1, Cursor.Po...
Problem with serialization <p>I have problem with serialization. I want to convert an object into a string and vice versa. I have two utility methods:</p> <pre><code>public static byte[] Serialize(Object o) { MemoryStream ms = new MemoryStream(); BinaryFormatter bf1 = new BinaryFormatter(); bf1.Serialize(ms, ...
<p>I have just tried the original code and it work's fine however, you need to make sure that the student class definition is marked as [Serializable]</p> <pre><code>[Serializable] public class Student { public string UserName; public string Password; public int[] lessonIds; public string[] lessonNames...
Are there wrappers for the Actionscripts's LocalConnection for C# or Java? <p>I want to communicate with the LocalConnection framework of Flash via C#/Java/C++. My search for already implemented wrappers was not as successfull as I wish ;). There exist several servers (like FluorineFx) which support binding of C# objec...
<p>After some thinking I discovered another approach: I build the "client" in ActionScript and use the compiled SWF file on a C# form (via the ActiveX Showckwave player). The client now communicates with the LocalConnection and to the Host (C#) application via ExternalInterface.</p>
Is Separator First Formating (SFF) with SQL Code Formating easier to read/maintain? <p>Do you place separators (commas, and, or operators) at the front of the line?</p> <pre><code>Select Field1 , Field2 --, Field3 From [some_table] as ST Inner Join [other_table] as OT ON ST.PKID = OT.FKID Where [this] = [that...
<p>It's easier to comment out, but I'd rather go for readability - Using a column layout like the one below is a bit awkward while the code is changing a lot, but it's very comfortable to get an overview:</p> <pre><code>select foo.bar, baz.ban, foobar.bazban from foomatic foo join bartastic bar on ...
ThickBox Problem on firefox (overflow:hidden no work) <p>i need a help with thickbox. I use it in my website, but a function of overflow:hidden, dont work in firefox, just in IE. Someone can helpme? thanks...</p> <p>html and css no problem, my problem is thickbox, becausa it work in IE 6 or 7, but no in mozilla(all ve...
<p>First off, it really helps if we can see the html/css that's causing the problem as well as an explanation of <em>how</em> it's not working.</p> <p>Secondly, install the <a href="http://getfirebug.com" rel="nofollow">firebug</a> extension. open firebug (F12) and Inspect the element you're concerned about. Look at t...
Input on how to keep object map in sync between browser (javascript) and server (asp.net web service/database)? <p>I have a object map on my server (objects representing Customers, Orders, Items, related to each other, based on content from a database) and want to keep an up to date version of that object map in the br...
<p><a href="http://en.wikipedia.org/wiki/Concurrency%5Fcontrol" rel="nofollow">Concurrency control</a> is a complex area and is more of a question of design, rather than what client-side/AJAX tools to use.</p> <p>For example:</p> <ol> <li>user A opens object X (to modify if)</li> <li>user B opens object X, modifies i...
How can I extend two classes the same way without copy-and-paste? <p>I've written an owner-drawn <code>TabControl</code>, but our project also uses <code>TabWorkspace</code> which derives from <code>TabControl</code>. At the moment, I've got</p> <pre><code>public class OurTabControl : TabControl { // some code t...
<p>You could do it using an interface and writing an extension method.</p> <pre><code>class OurTabControl: IBehavior class OurTabWorkspace: IBehavior interface IBehavior { } static class BehaviorExtensions { static [returntype] RepeatedBehavior(this IBehavior behavior) { //repeated code here } }...
Expand div to max width when float:left is set <p>I have something like that:</p> <pre><code>&lt;div style="width:100px;float:left"&gt;menu&lt;/div&gt; &lt;div style="float:left"&gt;content&lt;/div&gt; </code></pre> <p>both floats are neccesary. I want the content div to fill the whole screen minus those 100px for th...
<p>Hope I've understood you correctly, take a look at this: <a href="http://jsfiddle.net/EAEKc/">http://jsfiddle.net/EAEKc/</a></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8" /&gt; &lt;title&gt;Content with Menu&lt;/title&gt; ...
Why do people use linq to sql? <p>Given the premise:</p> <ul> <li>There are competent sql programmers (correlary - writing sql queries are not an issue)</li> <li>There are competent application developers (correlary - there is simple/strong/flexible architecture for handling connections and simple queries from code)</...
<blockquote> <p>I keep seeing questions about linq to sql and am wondering if I'm missing something.</p> </blockquote> <p>It's not that you're missing something. It's that you have something most shops don't have:</p> <blockquote> <p>There are competent sql programmers</p> </blockquote> <p>Additionally, in your...
open source custom tooltip (callout) control/code for asp.net <p>Looking for a custom tooltip (typical yellow baloon callout) on click of an anchor tag. The tooltip should appear and remain in view until the cross button on the tooltip is clicked.</p> <p>Just looking for a tried and tested open source solution. Tried ...
<p>I'm not aware of many good open source server side controls. But you should take a look at these:</p> <ul> <li><a href="http://www.obout.com/flyout/example_Googlemap_tooltip.aspx" rel="nofollow">http://www.obout.com/flyout/example_Googlemap_tooltip.aspx</a> - Free for commercial and personal use</li> <li><a href="h...
Sample read/write handling of packets in C <p>I'm a bit new to C, but I've done my homework (some tutorials, books, etc.) and I need to program a simple server to handle requests from clients and interact with a db. I've gone through Beej's Guide to Network programming, but I'm a bit unsure how to piece together and ha...
<p>If I understand correctly, you're asking, "how does the server understand the information the client sends it"?</p> <p>If that's what you're asking, the answer is simple: it's mutually agreed upon ahead of time that the data structures each uses will be compatible. I.e. you decide upon what your communication proto...
How to get X newest files from a directory in PHP? <p>The code below is part of a function for grabbing 5 image files from a given directory.</p> <p>At the moment readdir returns the images 'in the order in which they are stored by the filesystem' as per the <a href="http://us3.php.net/manual/en/function.readdir.php">...
<p>If you want to do this entirely in PHP, you must find all the files and their last modification times:</p> <pre><code>$images = array(); foreach (scandir($folder) as $node) { $nodePath = $folder . DIRECTORY_SEPARATOR . $node; if (is_dir($nodePath)) continue; $images[$nodePath] = filemtime($nodePath); } ...
How to remove references that are automatically added in web.config <p>All aplications in Visual Studio 2005 in my machine add n references automaticlly. How do I fix that?</p>
<p>My problem was in System.Web.Extensions 3.5, now I changed to System.Web.Extensions 1.6 and fix the problem.</p> <p>Thanks for the help.</p>
can a wcf service be exposed using ssl and consumed by a .net 1.1 client? <p>I haven't seen anything explicitly saying this can't be done, but I want to confirm...</p> <p>We have a client who needs to consume a web service and they are still using .NET 1.1</p> <p>I would love to use this as a reason to learn some WCF...
<p>Yes.</p> <p>Here's an <a href="http://social.msdn.microsoft.com/forums/en-US/wcf/thread/1f8c7fe9-784c-4beb-8d0f-060bf8bfc24f" rel="nofollow">article</a> with the same question and an answer on how you would do it.</p> <p>FTA:</p> <blockquote> <p>If you use a basicHttpBinding</p> <pre><code> &lt;endpoint addres...
Editing an XML file with JavaScript? <p>Hey guys, I'm just learning JavaScript and I have a question I hope someone can answer. Is it possible to get an XML file (not HTML) from a server, add/remove/edit particular parts of it with client-side JavaScript, and then send it back to the server to save it? JSON or any othe...
<p>Yes. Using jQuery...</p> <pre><code>$.get("myGetUrl.php", function(data) { var xml = $(data); xml.find("myNode").text("newValue"); $.post("myPostUrl.php", xml, function(resp) { alert(resp); }, "xml"); }); </code></pre>
C# Bubbling/Passing Along An Event <p>How do I pass along an event between classes?</p> <p>I know that sounds ridiculous (and it is) but I've been stumped on this for the past little while. Search didn't turn up a similar question so I figured I would pose it.</p> <p>Here are the objects involved:</p> <pre><code>Win...
<p>If I understood what you wanted in the basic sense. Is to have the Tweeter and Woofer fire an event that the Speaker is subscribed too then fire its own.</p> <p>Here is my code that has this output</p> <p><strong>OUTPUT</strong></p> <p><strong><em>OnSpeak Message = OnSpeakToMeHander Orginal Message: Fired By Twe...
The fastest way to query Work Items from TFS <p>I have 6000 work items stored in TFS</p> <ol> <li>Firstly, I need to receive them all (well, this is fairly simple to do using WIQL or something else) </li> <li>Then, I need to filter out all work items I was not working for a particular date range. For example, I am loo...
<p>Absolute fastest way, SSIS package (or any DTL) that performs data transformations and holds the denormalized data you need for this application somewhere. Depending on your scenario, this package could run nightly, hourly, whatever frequency (within sane limits) you need. However, if you need real time views of t...
Transactions with XML Files <p>I am looking to implement database like transactions in C#. I am processing multiple XML files. Any particular XML file can call child XML file during processing. The processor will start processing child XML file. If initialization conditions fail or there is an exception, then I want to...
<p>On the compact framework I think your going to roll your own transaction manager.</p> <p>On the full framework you could have probably built something using TransactionScope and IEnlistmentNotification. You would have had to do quite a bit of work to get all your actions transactable as there is not support for tra...
.NET Serialization Ordering <p>I am trying to serialize some objects using XmlSerializer and inheritance but I am having some problems with ordering the outcome.</p> <p>Below is an example similar to what I have setup: ~</p> <pre><code>public class SerializableBase { [XmlElement(Order = 1)] public bool Proper...
<p>Technically, from a pure xml perspective, I would say that this is probably a bad thing to want to do.</p> <p>.NET hides much of the complexity of things like XmlSerialization - in this case, it hides the schema to which your serialized xml should conform.</p> <p>The inferred schema will use sequence elements to d...
When to make a object delete itself? <pre><code>Callback* p = new Callback; func(p); </code></pre> <p>If I want to delete the callback object, when and how to delete that?</p> <p>If it gets deleted early, then the callback may be failed.</p>
<p>The best solution for this is to used a smart pointer.<br /> You initialize the pointer with the callback and pass it to the function. when the function or whatever process is done, the callback will be deleted automatically by the smart pointer.<br /> A good smart pointer implementation is <a href="http://www.boost...
Simplest way to do a fire and forget method in C#? <p>I saw in WCF they have the <code>[OperationContract(IsOneWay = true)]</code> attribute. But WCF seems kind of slow and heavy just to do create a nonblocking function. Ideally there would be something like static void nonblocking <code>MethodFoo(){}</code>, but I ...
<pre class="lang-cs prettyprint-override"><code>ThreadPool.QueueUserWorkItem(o =&gt; FireAway()); </code></pre> <p>(five years later...)</p> <pre><code>Task.Run(() =&gt; FireAway()); </code></pre> <p>as pointed out by <a href="http://stackoverflow.com/users/984780/luisperezphd">luisperezphd</a>.</p>
Cognos 8.3 No Data Content issues <p>Upgrading from 8.2 to 8.3 and testing out the new No Data Content functionality. Report looks in order if results are returned. The No Data message does not appear. However if we test the report (pass in parameters expecting no results), we are returned a blank page (pdf, html, e...
<p>We ran into this same problem when upgrading reports from 8.2 => 8.4. We reported it to Cognos as a bug -- Not sure if they've assigned a bug tracker id to it, but we got the impression it wasn't going to be fixed soon. (Obviously, if it exists in 8.3 and it has been carried forward to the next version, it's not a ...
Activate different Maven profiles depending on current module? <p>We have a multi module build with modules using different technologies, like Java and Flex. Is it somehow possible to activate different profiles based on the module that is compiled currently?</p> <p>I tried it with an activation like</p> <pre><code>&...
<p>After some more research I finally came to the conclusion that this is not possible for two reasons in the current Maven version (2.1.0):</p> <ul> <li>Maven profiles are not inherited, so you can't define a profile in a parent POM and activate that in a child POM.</li> <li>I haven't found a possibility to activate ...
How to convert object array to string array in Java <p>I use the following code to convert an Object array to a String array :</p> <pre><code>Object Object_Array[]=new Object[100]; // ... get values in the Object_Array String String_Array[]=new String[Object_Array.length]; for (int i=0;i&lt;String_Array.length;i++) ...
<p>Another alternative to <code>System.arraycopy</code>:</p> <pre><code>String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class); </code></pre>
How to determine the direction of a iPhone shake <p>I am using the accelerometer to scroll multiple subViews in a UIScrollVIew. I want the view (portrait orientation) to scroll to the right when the user flicks the iPhone to the right, and scroll to the left when the device is flicked to the left. </p> <p>I thought I ...
<p>OK, worked out a solution. When I detect a shake motion (acceleration greater than 1.5 on the x axis), I start a timer and set a BOOL to true. While the BOOL is true I add acceleration values. When the timer expires, I stop adding acceleration values and determine direction of the shake by the sign of the total acce...
performance of C++0x exceptions <p>What are the performance implications of using exceptions in C++0x? How much is this compiler dependent? Should we expect to use exceptions more for general logic handling like in Java?</p>
<pre><code>#include &lt;iostream&gt; #include &lt;stdexcept&gt; struct SpaceWaster { SpaceWaster(int l, SpaceWaster *p) : level(l), prev(p) {} // we want the destructor to do something ~SpaceWaster() { prev = 0; } bool checkLevel() { return level == 0; } int level; SpaceWaster *prev; }; void t...
How to write binary data to a file so that it can be read fast back? <p>I need to write a file format that writes out data to a file and can read it back.</p> <p>It should be able to read the data back fairly fast, which should involve blitting a large block of data into a <code>std::vector</code> (since their storage...
<p>This will depend on your compiler and platform. As far as I know, there is no way to enforce this in a completely cross-compiler and cross-platform manner, without defining lots of macros of your own.</p> <p>However, both VC++ and GCC (the big two) support the <code>#pragma pack</code> directive, which will allow y...
Advantage to parsing Excel Spreadsheet data vs. CSV? <p>I have tabulated data in an Excel spreadsheet (file size will likely never be larger than 1 mb). I want to use PHP to parse the data and insert in to a MySQL database. </p> <p>Is there any advantage to keeping the file as an .xls/.xlsx and parsing it using a PH...
<p>If you are just after the values, I would save it as a CSV. This is much easier to parse programatically, especially if you are trying to do this on a non-windows box.</p> <p>That being said, there will be information lost in the export to CSV. It will only save the values of the cells - not their formatting info...
Need help designing big database update process <p>We have a database with ~100K business objects in it. Each object has about 40 properties which are stored amongst 15 tables. I have to get these objects, perform some transforms on them and then write them to a different database (with the same schema.) This is ADO.Ne...
<p>This is exactly the sort of thing that SQL Server Integration Services (SSIS) is good for. It's documented in Books Online, same as SQL Server is.</p>
Application framework for Java desktop applications? <p>I'm currently using a custom framework to build Java Swing applications which have event monitoring over a network. I'd like to replace our custom networking layer with something like JMS but our framework is tightly coupled to its current implementation.</p> <p>...
<p>You can use Spring to do this, take a look at the following articles for an idea of how to use it to build Swing applications:</p> <p><a href="http://java.dzone.com/news/spring-enabling-decoupled-swin" rel="nofollow">http://java.dzone.com/news/spring-enabling-decoupled-swin</a></p>
How many numbers below N are coprimes to N? <h2>In short:</h2> <p>Given that <strong>a</strong> is coprime to <strong>b</strong> if <strong>GCD(a,b) = 1</strong> (where GCD stands for <a href="http://en.wikipedia.org/wiki/Greatest%5Fcommon%5Fdivisor">great common divisor</a>), how many positive integers below N are co...
<p><strong>[Edit]</strong> One last thought, which (IMO) is important enough that I'll put it at the beginning: if you're collecting a bunch of totients at once, you can avoid a lot of redundant work. Don't bother starting from large numbers to find their smaller factors -- instead, iterate over the smaller factors an...
Querying Core Data with Predicates - iPhone <p>So I'm trying to fetch objects from core data. I have list of say 80 objects, and I want to be able to search through them using a UISearchBar. They are displayed in a table.</p> <p>Using the apple documentation on predicates, I've put the following code in one of the UI...
<p>It seems as though iPhone doesn't like the LIKE operator. I replaced it with 'contains[cd]' and it works the way I want it to.</p>
Extending SharePoint Breadcrumbs across multiple site collections <p>I’ve been trying to find a way to extend SharePoint breadcrumbs across multiple site collections, and I’ve been unable to find a way. I can set the <em>portal site connection</em> setting on the site collection to link to its parent site collecti...
<p>Since you are implementing a custom masterpage (or customizing the default one), why not replace the breadcrumb control with your own? Or make a custom sitemap provider if you need to combine your sitemap with Sharepoint's generated map.</p>
Controlling application running on a virtual desktop (linux) <p>I need to run an application on a virtual Xorg desktop (let say desktop #2) and control it via another app running on the root desktop (desktop #1). That would include screen capture and mouse movements. So basically I capture the application window from d...
<p>It is certainly doable. If you use VirtualBox over linux, then you can use the Remote Desktop Protocol to run and control the virtual machine remotely. </p> <p>VirtualBox supports the standard Remote Desktop Protocol where a virtual machine can act as an RDP server, allowing you to "run" the virtual machine remotel...
How to replace a column using Python's built-in .csv writer module? <p>I need to do a find and replace (specific to one column of URLs) in a huge Excel .csv file. Since I'm in the beginning stages of trying to teach myself a scripting language, I figured I'd try to implement the solution in python.</p> <p>I'm having t...
<p>The reason you're getting an error is that the writer doesn't have data to iterate over. You're supposed to give it the data - presumably, you'd have some sort of list or generator that produces the rows to write out.</p> <p>I'd suggest just combining the two loops, like so:</p> <pre><code>for row in reader: r...
What's missing in Cocoa? <p>If you could add anything to Cocoa, what would it be? Are there any features, major or minor, that you would say are missing in Cocoa. Perhaps there is a wheel you have had to invent over and over because of an omission in the frameworks?</p>
<ul> <li><p>Built-in regular expression support (a la <a href="http://regexkit.sourceforge.net/" rel="nofollow">RegexKit</a>) would be <em>extremely</em> handy. NSRegularExpression is available on iOS 4.0+, but it is still not available on Mac OS X yet.</p></li> <li><p>An easy way to progressively read NSString objects...
Is there a way to exclude package-level functions and members from Doxygen output? <p>I'm working with Doxygen at the workplace and am having a problem with the Java code. With the EXTRACT_ALL=NO, EXTRACT_PRIVATE=NO, EXTRACT_STATIC=NO, EXTRACT_LOCAL_CLASSES=NO, and EXTRACT_LOCAL_METHODS=NO, the output still includes st...
<p>You can put stuff that you don't want to see in doxygen output inside a <code>\cond ... \endcond</code> block:</p> <pre><code>class EXAMPLE{ public static func1() /// \cond private static func2() static func3() /// \endcond } </code></pre>
How to store JSON response in jQuery? <p>I'd like to store my json response in a global variable so, i could use it through my app without making a getJSON request more than once.</p> <pre><code>var data; $.getJSON("panorama.json",function(json){ data = json.images[0].src; console.log(data); }); console.log(data)...
<p>If your real code is structured like that then you have a problem with trying to access the data that hasn't been set <strong>yet</strong>. Just because your <code>$.getJSON()</code> is above <code>console.log()</code> doesn't mean that you get the response before you log value of data.</p> <p>So your problem is no...
maximum size of a sprite in as3? <p>Is there an upper bound to the size of a sprite in as3 / flash 10?</p> <p>I know <a href="http://www.bit-101.com/blog/?p=1426" rel="nofollow">bitmapData has limitations</a>...</p>
<p>it seems, that xScale and yScale may not exceed 0x8000 ... </p> <p>size itself also seems to be bound ... i found a limit 0x6666660 ... </p> <p>here the code:</p> <pre><code>package { import flash.display.*; public class Main extends Sprite { public function Main():void { var size:Number = 1; ...
Are cookies sent with image requests? <p>If I have a site (e.g. foo.com) and on the home page of foo.com, there is a image request where the src=bar.com..., will the cookies on the bar.com domain be sent to the bar.com servers?</p> <p>Thanks!</p>
<p>Yes. HTTP doesn't distinguish between one kind of resource or another (image vs html).</p>
How can I configure JBoss JDBC data source connections outside the XML config file? <p>I would like to override the portion of JBoss that loads JDBC connection information from the XML config file. I would like to continue using the rest of JBoss's connection pooling/caching features. I just want to load the connectio...
<p>The JBoss -ds.xml descriptors actually cover a multitude of sins. If you look on the JBoss JVM console, you'll find 4 or 5 MBeans there for each data source. You could potentially do this programmatically, but I wouldn't give good odds on your chances.</p> <p>My suggestion would be to use a 3rd-party connection poo...
MPMoviePlayerController on iPhone 3.0 SDK <p>Did Apple change anything about the MPMoviePlayerController class on the iPhone 3.0 SDK? My app no longer pops up a video when I tap the correct button, no error popup or anything.</p>
<p>Nothing has changed from what I can see by comparing the 2.1 and 3.0 documentation for MPMoviePlayerController.</p>
pandora website user profile system <p>How does Pandora save user profiles/accounts after a user registers? How does it remember the user - even after the user has cleared cookies and cache. </p> <p>I found if you register with one browser and visit Pandora.com with another browser you are recognized as the registered...
<p>Pandora stores some information in the Flash local storage, including your username and login credentials. When you clear cookies in your browser, it does not clear Flash local storage which is why Pandora still remembers you.</p> <p>Also, since Flash local storage is shared between all browsers on that computer, ...
jQuery event delegation with non-trivial HTML markup? <p>I have two DIVs, first one has a link in it that contains the id of the second DIV in its HREF attribute (<a href="http://jsbin.com/azimo/edit" rel="nofollow">complete setup on jsbin</a>). </p> <p>I want to animate the second DIV when user clicks on the first - ...
<p>It took me so long to write up the question that I decided to post it anyway, perhaps someone suggests a better way. </p> <p>Here's the solution I found (<a href="http://jsbin.com/iyamo" rel="nofollow">jsbin sandbox</a>):</p> <pre><code>$('#a').click(function(e) { var n = $(e.target)[0]; var name = n.node...
Custom styles for custom widgets in Qt <p>Does anybody have experience with custom styled, custom widgets in Qt? (I am using Qt 4.5)</p> <p>The problems looks like this:</p> <p>I want to develop some custom controls that are not based entirely on existing drawing primitives and sub-controls. Since the entire applicat...
<p>The style sheet problem will not be solved, as it will not on custom classes. </p> <p>The extra goodies added to a custom style will not be understood and taken care by already existing classes. This is because C++ is a static language and there is no (clean and sane) way to monkey-patch the run-time classes. A pot...
How do I display a counter(ie, no. of times downloaded) in an MS Excel 07 spreadsheet when the spreadsheet(.xls) is downloaded off my webpage? <p>I know it is easy to display a counter on a webpage but I need to implement the same, ie, I need to write data to a cell in the Excel 2007 spreadsheet every time a person dow...
<p>That sounds like an exercise in futility since the number will be out of date as soon as the next person downloads the file. Is this what you really want to do?</p> <p>If yes, it's very possible using some server-side scripts. PHP, Perl and other languages all have libraries that can be used to edit Excel files pro...
.NET Log or View Call / Response of a SOAP WebService <p>What is the best way to inspect the calls &amp; responses from a web service in .NET?<br /> I'm interacting with a Web Service written in Perl and running into issues.<br /> How can I capture the text of the call and response?</p> <p><strong>UPDATE:</strong><br ...
<p>You can do this by creating a <code>SoapExtension</code> and enabling it in your web service client:</p> <blockquote> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension.aspx">System.Web.Services.Protocols.SoapExtension Class (MSDN)</a></p> </blockquote> <p>The link ab...
Speed of calculating powers (in python) <p>I'm curious as to why it's so much faster to multiply than to take powers in python (though from what I've read this may well be true in many other languages too). For example it's much faster to do</p> <pre><code>x*x </code></pre> <p>than</p> <pre><code>x**2 </code></pre> ...
<p>Basically naive multiplication is O(n) with a very low constant factor. Taking the power is O(log n) with a higher constant factor (There are special cases that need to be tested... fractional exponents, negative exponents, etc) . Edit: just to be clear, that's O(n) where n is the exponent.</p> <p>Of course the nai...
How to find a child of a parent unmanaged win32 app <p>Basically I am looking for a win32 method to invoke in C# to set the focus to a children of an unmanaged application.</p> <p>But first I need to find the child control's handle which is the problem. Any useful win32 functions to solve this?</p>
<p>Use <a href="http://msdn.microsoft.com/en-us/library/ms633500.aspx" rel="nofollow">FindWindowEx</a> to find the Handle of the Window you're looking for. Once you have that handle, use <a href="http://msdn.microsoft.com/en-us/library/ms633494%28VS.85%29.aspx" rel="nofollow">EnumChildWindows</a> to find the correct ch...
Python - configuration options, how to input/handle? <p>When your application takes a few (~ 5) configuration parameters, and the application is going to be used by non-technology users (i.e. <a href="http://en.wiktionary.org/wiki/KISS" rel="nofollow">KISS</a>), how do you usually handle reading configuration options, ...
<p>Do you usually read config options via: - command-line/gui options - a config text file </p> <p>Both. We use Django's settings.py and logging.ini. We also use command-line options and arguments for the options that change most frequently.</p> <p>How do multiple modules/objects have access to these options?...
Oracle performance with multiple same column indexes <p>I'm Working with a new Oracle DB, with one table having the following indexes:</p> <ul> <li>Index 1: ColA, ColB </li> <li>Index 2: ColA</li> </ul> <p>Is the second index redundant, and Will this have a negative impact on performance?</p>
<p>Google is my best friend :</p> <p><a href="http://www.orafaq.com/node/926" rel="nofollow">http://www.orafaq.com/node/926</a></p> <p>The main point of this article is :</p> <pre><code>If 2 indexes ( I1 and I2 ) exist for a table and the number of columns in Index I1 is less or equal to the number of column in i...
how do I explain these *narrow* spikes in jstat output? <p>When attempting to monitor the performance of a JVM using jstat, I see the following lines - </p> <pre><code> Timestamp PC PU OC **OU** YGC FGC FGCT GCT ... 283.7 132608.0 132304.8 1572864.0 **398734...
<p>Totally guessing, but it looks like it happened right as the young gen did a GC which could have kicked new objects into the old generation. That could have caused a more serious compacting pass in the old generation.</p> <p>I'm guessing it copies over all the new stuff (making the old gen bigger), then compresses...
"Find All References" broken in one solution <p>At some point "Find All References" feature got broken for a single solution that I have. It works in all other solutions. For this one, it always returns "Search found no results"</p> <p>What could be the problem?</p>
<p>In the old days (VC6 :) ) this type of problem was often fixed by deleting the .ncb file and letting it be rebuilt automatically. Not sure if this is still true in VS2005/8.</p>
When do I define objective-c methods? <p>I'm learning Objective-C, and have a C/C++ background. </p> <ul> <li><p>In object-oriented C++, you always need to declare your method before you define (implement) it, even if it is declared in the parent class. </p></li> <li><p>In procedural-style C, IIRC, you can get away ...
<p>For Objective-C methods, the general practice is to put methods you wish to expose in the <code>@interface</code> section of the header file so other code can include only the .h and know how to interact with your code. Order-based "lazy declaration" works just like functions in C — you don't <strong>have to</stro...
Put a Firefox window in full screen mode <p>I've projected an Intranet Ajax application and I want put it in a full screen mode so it seems as a real stand alone application.</p> <p>My problem is that with Firefox 3 the <code>window.open</code> with options to put the window in full screen mode not work well. I have a...
<p>That is not possible at all, if it were, it would be a huge security risk, phishing scams would be much more successful.</p> <p>To get a more real feeling of a standalone app, maybe you should take a look at <a href="http://prism.mozilla.com" rel="nofollow">Mozilla Prism</a> to use as client for your ajax web app.<...
tag for UITabBarItem <p>When I use the this method to initialize a <code>UITabBarItem</code>:</p> <pre><code>- (id)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag </code></pre> <p>Do I need to have a distinct tag for each tab bar item, or (since I don't use them) can I simply use the same ta...
<p>I'm pretty sure you can just leave them all as 0 or any other number you choose. Every UIView can potentially have a different tag, and Interface Builder sets them all to 0 by default. I haven't run into any problems with this.</p>
How to do PGP in Python (generate keys, encrypt/decrypt) <p>I'm making a program in Python to be distributed to windows users via an installer.</p> <p>The program needs to be able to download a file every day encrypted with the user's public key and then decrypt it.</p> <p>So I need to find a Python library that will...
<p>You don't need <code>PyCrypto</code> or <code>PyMe</code>, fine though those packages may be - you will have all kinds of problems building under Windows. Instead, why not avoid the rabbit-holes and do what I did? Use <code>gnupg 1.4.9</code>. You don't need to do a full installation on end-user machines - just <cod...
Deploying a Silverlight Application with built-in ASMX WebService to IIS <p>I've got a Silverlight application which uses a built-in .ASMX WebService to access a SQL database and run some queries. Everything runs without any hitches on my Development machine. </p> <p>I'm trying to deploy the application to IIS 6 and I...
<p>The most likely thing that's happening: Your webservice proxy on the client is using the address of the web service it was built against: ("http://localhost..."). Things to do:</p> <ul> <li>Use <a href="http://www.fiddler2.com/fiddler2/" rel="nofollow">fiddler</a> to confirm this is the issue. It will show you whe...
How do I run Django and PHP together on one Apache server? <p>I can currently run either Django through mod_wsgi or PHP on my Apache server.</p> <p>My Django projects run at: <a href="http://localhost">http://localhost</a> and source is at C:/django_proj</p> <p>My PHP projects run at: <a href="http://php.localhost">h...
<p>I run dozens of mod_wsgi/Django sites, PHP sites, and a Rails site with a single Apache.</p> <p>It's mostly done using virtual hosts but I have some that are running both on the same domain.</p> <p>You just need to put your <code>WSGIScriptAlias /...</code> after any other Location/Alias directives.</p> <p>Lets s...
How To Test Email Deliverability - % In Junk Folder <p>Does anyone know a good tool to test whether your emails are going into spam folders?</p> <p>My web app generates emails to users, and I've been getting a lot of reports back from people saying "hey, no one ever responded to my message".</p> <p>I have SPF rules i...
<p>To know if your email goes in the inbox, you need to get a metric called "Inbox Placement Rate". This indicator can be provided by Return Path, but it's quite expensive. If you're not sending huge volumes it might not worth it. The only way to measure the IPR is actually to have a certain number of test inboxes... I...
What process do you use to learn a new programming language? <p>This question is for experiences programmers. Do you have a set process that you follow when approaching a new language that you want to learn? Do you prefer learning alone or with a buddy? How do you begin? Do you have a favorite series of books? And is t...
<p>Personally I find that I need a substantial project to implement in a new interesting language. You can read a book at become familiar with syntax, and be exposed to interesting features, but a nothing gets you thinking in a new language like a project.</p>
A simple assembly program? <p>I've recently learned how to use MASM from MSVC++ IDE, and to test whether it works, I would like to run a short program.</p> <p>However, I don't know any assembly yet (that which I do is useless: ie: even though I know what <code>i+=1;</code> is in C++, I can't do anything without <code>...
<p>Here is the MASM documentation online: <a href="http://web.sau.edu/LillisKevinM/csci240/masmdocs/" rel="nofollow">http://web.sau.edu/LillisKevinM/csci240/masmdocs/</a></p> <p>Here is the difinitive tutorial on assembly: <a href="http://webster.cs.ucr.edu/" rel="nofollow">http://webster.cs.ucr.edu/</a></p> <p>I thi...
Can the iPhone 3.0 SDK provide full access to Bluetooth devices (headsets)? <p>So an iPhone can pair with a Bluetooth headset and use it to make calls (although an <a href="http://en.wikipedia.org/wiki/IPod_Touch" rel="nofollow">iPod Touch</a> with the 3.0 OS can not pair with a headset, go figure).</p> <p>But can I w...
<p>If a compatible Bluetooth headset is paired with the device, it will be used transparently if you're using the Core Audio APIs; you do not need to add specific support for Bluetooth headsets to your application.</p> <p>If you want to integrate specifically with Bluetooth devices, you will need to join the "Made for...
Function name conflict in php from 2 different libraries <p>I have 2 'libraries' which I need to include on the same page. Simple Machine Forums and Wordpress.</p> <p>However both have the function is_admin() which conflicts with each other.</p> <pre><code>Fatal error: Cannot redeclare is_admin() (previously declared...
<p>I believe you don't have too much choice but to rename the function or, wrap all functions around a class. That's the problem with PHP &lt;= 5.*: no namespaces, and developers often prefer to write a script full of loose functions, than to use an object oriented approach.</p>
Problems opening documents using SharePoint forms based authentication <p>I am trying to build a WSS 3.0 site.</p> <p>I am having difficulty with the dialog box that pops up when I try to check out a document. I tried to solve this by enabling forms based authentication but when I click on the document, Microsoft Wor...
<p>To prevent the popup you need to do that IE setting. I am afraid that for Internet site it wont help. If you change to FBA, its a different story, refer <a href="http://blogs.msdn.com/sharepoint/archive/2009/05/13/update-on-sharepoint-forms-based-authentication-fba-and-office-client.aspx" rel="nofollow">MSDN Blog</...
SWFUpload - anyone familiar? <p>I'm experimenting with SWFUpload ( <a href="http://swfupload.org" rel="nofollow">http://swfupload.org</a> ) and I'm wondering if, in PHP, its data will still be in the $_FILES array. If not, where does it go?</p>
<p>SWFUploader uses HTTP POST to upload the files. So from PHP's perspective, it is not different than a being posted with a file.</p> <p>The file will be in $_FILES and the extra postvars will be in $_POST.</p>
Comparing structures in C vs C++ <p>I want to compare C++ class/structure objects. In C, most of the time, one knows exact size of the <code>struct</code> by adding up the sizes of individual fields (assuming that compiler does not add padding). Hence one can use memcmp() function on two object to compare them very fas...
<p>Be wary on numerous counts...</p> <ol> <li>The values in any padding is indeterminate and hence not comparable.</li> <li>If your machine is little-endian, comparing integer fields will produce one answer; if your machine is big-endian, it will produce another answer.</li> <li>Most people regard -1 as smaller than 0...
Logo programming language implementations <p>The <a href="http://stackoverflow.com/questions/1003841/how-do-i-move-the-turtle-in-logo" rel="nofollow" title="How do I move the turtle in LOGO?">"joke" question Joel asked</a> during <a href="http://blog.stackoverflow.com/2009/06/podcast-58/" rel="nofollow" title="Stackove...
<p>Cross-platform versions: <a href="http://www.mathcats.com/gallery/logodownloadinfo.html">http://www.mathcats.com/gallery/logodownloadinfo.html</a></p> <p>MacOS X specific: <a href="http://www.alancsmith.co.uk/">http://www.alancsmith.co.uk/</a></p> <p>Open-source Logo:<br> <a href="http://sourceforge.net/projects/f...
loading a image from documents directory in iPhone <p>I want to load a image to UIImageView from my app documents library. I am trying to use the following code but it is not working.</p> <pre><code>UIImageView *background = [[[UIImageView alloc] initWithFrame:CGRectMake(3, 10, 48, 36)] autorelease]; [background setI...
<p>If you <em>really</em> want to load an image from your app's documents folder, you could use this:</p> <pre><code>NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES ); NSString *docDirectory = [sysPaths objectAtIndex:0]; NSString *filePath = [NSString stringWithForma...
I have an issue in mysql that i have a field id which is auto increment and some other fields <p>I have an issue in mysql that i have a field id which is auto increment and some other fields. where the id field should not be autoincremented while enterting the null values and should be autoincremented while entering v...
<p>It sounds like you need to generate the value for the id field yourself, in your own code, rather than having the database generate it. </p> <p>If you create an identity field in the database, the database will create the field automatically. Generally this occurs when the record is saved, whether there are null ...
Interacting with another command line program in Python <p>I need to write a Python script that can run another command line program and interact with it's stdin and stdout streams. Essentially, the Python script will read from the target command line program, intelligently respond by writing to its stdin, and then rea...
<p>To perform such detailed interaction (when, outside of your control, the other program may be buffering its output unless it thinks it's talking to a terminal) needs something like <a href="http://pexpect.sourceforge.net/pexpect.html">pexpect</a> -- which in turns requires <code>pty</code>, a Python standard library...
Why can't I run my C# program in release mode? <p>I have sample code (for deal with scanner in Motorola HC700)</p> <p>the problem is that i can run this program only on Debug mode</p> <p>if I try to run on Release mode, I get this error:</p> <p>The type or namespace name 'Mot' could not be found (are you missing a u...
<p>If you are using a standard csproj, note that files and references can be conditional - i.e. only there in some configurations. You have to go out of your way to do this (the VS IDE doesn't let you do it - only via direct file edit), so it seems unlikely, but it is a <em>possibility</em>.</p> <p>It is, unfortunatel...
Restrict custom attribute so that it can be applied only to Specifc types in C#? <p>I have a custom attribute which is applied to class properties and the class itself. Now all the classes that must apply my custom attribute are derived from a single base class.</p> <p>How can I restrict my Custom Attribute so that it...
<p>Darn, I hate it when I prove myself wrong... it works if you define the attribute as a <strong>protected</strong> nested type of the base-class:</p> <pre><code>abstract class MyBase { [AttributeUsage(AttributeTargets.Property)] protected sealed class SpecialAttribute : Attribute {} } class ShouldBeValid : ...
Programming slim C++ programs (like uTorrent) for Windows <p>I've always admired the original uTorrent program. It looked great, was less than 64kb, was extremely fast and had all the features I needed. Unfortunately the program is closed source (and becoming more bloated by the day) so I come to Stackoverflow for insp...
<p>The Windows Template Library is geared towards what you want to do. It's a light-weight, template-based C++ wrapper for the Win32 API. With it, you don't have to go through the pain of direct Win32 coding, but it doesn't add a lot of overhead like MFC.</p>
Caching data loaded with NHibernate <p>In my application I want to cache data loaded with NHibernate. I don't want to use the second level cache of NHibernate as this cache is not really meant to cache an entire graph of objects. But what is the best strategy to make sure I don' have any lazy loading proxies and/or col...
<p>NHibernate.NHibernateUtil.Initialize(object proxy)<br/> "Force initialization of a proxy or persistent collection."</p>
Is it possible to create an indexed view with SQL Server 2008 which selects from another indexed view? <p>Is it possible to create an indexed view with SQL Server 2008 which selects from another indexed view?</p> <pre><code>create view V1 as (select 1 as abc) create view V2 as (select abc from V1 group by abc) </code>...
<p>Here are the <a href="http://msdn.microsoft.com/en-us/library/ms188783.aspx" rel="nofollow">requirements</a> for indexed views (they are plentiful):</p> <ul> <li>The view must reference only base tables in the same database, not other views.</li> </ul>
Referencing Javascript libraries with Tomcat <p>I am using <strong>Eclipse Ganymede</strong> and <strong>Tomcat 5.5</strong>. I would like to add some javascript and especially ajax functionality to a dynamic web project and need some help.</p> <p>I would like to use jquery (but I am open to other suggestions, if you ...
<p>To be more specific (because it took me about half an hour to figure this out after getting to this point):</p> <p>When you create a Dynamic Web Project with Tomcat in Eclipse, among other things in the project you get a folder named "WebContent". That's the actual folder that gets deployed to the Tomcat server, in...