input
stringlengths
51
42.3k
output
stringlengths
18
55k
Why does Visual Studio launch multiple WebDevs when I debug? <p>I have a Visual Studio 2008 solution with several projects in it - some of which are web applications / sites. </p> <p>Whenever I go "Debug > Start new instance" for a specific web application and VS launches the ASP.net Development Server (WebDev.WebServ...
<p>See the accepted answer here:</p> <p><a href="http://stackoverflow.com/questions/16363/how-do-you-configure-vs2008-to-only-open-one-webserver-in-a-solution-with-multi#16390">http://stackoverflow.com/questions/16363/how-do-you-configure-vs2008-to-only-open-one-webserver-in-a-solution-with-multi#16390</a></p>
IDictionary<string, string> versus Dictionary<string, string> <p>what is the value of using IDictionary here?</p>
<p>The value of using an interface is always the same: you don't have to change client code when switching to another backend implementation.</p> <p>Consider that profiling your code later shows that a hash table implementation (used in the <code>Dictionary</code> class) isn't suited for your task and that a binary se...
Synchronizing databases <p>I am developing an Adobe AIR application which stores data locally using a SQLite database. At any time, I want the end user to synchronize his/her local data to a central MySQL database.</p> <p>Any tips, advice for getting this right? Performance and stability is the key (besides security ;...
<p>I can think of a couple of ways:</p> <ol> <li><p>Periodically, Dump your MySQL database and create a new SQLite database from the dump. You can then serve the SQLite database (SQLite databases are contained in a single file) for your users client to download and replace the current database.</p></li> <li><p>Create ...
C: the definitive truth about rand, random and arc4random <p>There's a lot of conflicting information about this topic. So let's try to agree on a definitive answer:</p> <p>Which one of these random number generator in C create better randomness: rand, random or arc4random?</p> <p>note: Just to make the question clea...
<p>Of these functions, only rand is part of standard C. random is part of POSIX, and arc4random is only provided in BSD (and derived). So only rand is "in C".</p> <p>For rand, the C standard says nothing about the quality of the generator, i.e. returning always the same number would be conforming. It says that the num...
Looking for some good resources to get started with Django <p>All,</p> <p>I'd like to check Django out and maybe hack together some web pages to see how it feels - but after having a look at a few tutorials like <a href="http://www.showmedo.com/videos/video?name=stoops010" rel="nofollow">this one</a> I am starting to ...
<p>As someone who just started playing around with Django as well, I found the official documentation very helpful. Just walk through the "First steps" tutorials at:</p> <p><a href="http://docs.djangoproject.com/en/dev/" rel="nofollow">http://docs.djangoproject.com/en/dev/</a></p> <p>It will teach you the gist of Dja...
Best Practice: When to dispatch back to the UI Thread <p>I have a question on best pactices. When is the best time to dispatch a call back to the UI when using a helper loading method like the two below? Button1 uses the Dispatcher when returned and Button2 allows the helper loading class to encapsulate the call on t...
<p>If the code is generic and not really tight to WPF infrastructure, the first method is definitely more generic as it completely ignores the use of a dispatcher object. If your class is tightly integrated to WPF, the second method is a better practice since you have to call the method using a Dispatcher. In the first...
Accessing stored structures for which I have an xml description <p>I have set up a sort of introspection-enabling C++ library that allows, using minimum macros and a fair amount of template trickery, to declare structures and classes that get enriched with some meta-information.</p> <p>This meta-information captures a...
<p>/* smarc's keeping it simple */</p> <pre><code> class xmlstream { ... }; class ibase { void read( xmlstream&amp; rStream ) = 0; void write( xmlstream&amp; rStream ) = 0; }; class classfactory { void produce( xmlstream&amp; rStream ); void consume( xmlstream&amp; rStream ); ibase* crea...
FileNotFound exception when using XmlSerializer <p>When trying to serialize a type (a generic <code>List&lt;T&gt;</code> which T is a class marked with XmlRootAttribute) into XML using <code>XmlSerializer</code>, a <code>FileNotFoundException</code> is thrown (sometimes) and serialization fails.</p> <p>It seems that <...
<p>XmlSerializer works by generating <em>code</em> to do the serialization/deserialization, and storing this in a temporary assembly. (This approach gives good performance for repeated serialization/deserialization but (traditionally) shockingly awful performance for the first run)</p> <p>To help mitigate the shockin...
Should I design the application or model (database) first? <p>I am getting ready to start building a new web project in my spare time to bring to fruition an idea that has been bouncing around my head for a while.</p> <p>I have never gotten down whether I am better off first building the model and then the consuming a...
<p>When you're building the whole application yourself, I would start with the user. What does the user want? What information do they need? That should drive the design of the application and model, not the other way round. When the model is designed first, there is a temptation to expose the user to it directly, whic...
UIView bounds with top bar <p>When creating a UIView with a navigation bar in interface builder, the top bar takes some space, but the view still has the same size. This mean that the bottom of the view is not visible.</p> <p>Is there a way to get the "visible size" of a UIView? I would like to show a subview at the...
<p>You should use the 'struts-and-springs' control in IB to set your base view to be full-justified. Then it will auto-resize. Once you do this, you can just use the view.bounds property to access its visible area.</p>
Singleton heritage <p>The singleton is explained here: <a href="http://en.wikipedia.org/wiki/Singleton_pattern#PHP_5" rel="nofollow">http://en.wikipedia.org/wiki/Singleton_pattern#PHP_5</a>. I want to use the singleton class as a superclass, and extend it in other classes that are supposed to be singletons. The problem...
<p>This is a limitation of PHP - a parent class cannot determine the name of a subclass on which its methods are statically called.</p> <p>PHP 5.3 now has support for late static bindings, which will let you do what you need to, but it will be a while before that is widely available. See some information <a href="http...
MySaifu JVM and BlueCove API on an iPAQ <p>Having a bit of an issue running BlueCove on my iPAQ (h5550). I installed MySaifu JVM and added the BlueCove jar library to the classpath, but whenever I try to run the tester jar or any other files that reference the BlueCove API, I get class not found exceptions.</p> <p>Any...
<p>Some time ago I tested MySaifu JVM and it didn't seem to have a complete imlementation of the CDC Personal Profile 1.1 (the most complete). I don't know what J2ME profile does that program need but problems could start from that point.</p> <p>Other issue is that not all Windows CD/Mobile platforms are identical so ...
How do I programatically change options in Access? <p>in Microsoft Access, is there a way which I can programatically set the Confirm Action Queries flag on the options screen to False? Ideally when the database is started up I would like to check if it's true, and if so, mark it as false for the currently logged in us...
<p>Place the following in a method when the database starts:</p> <pre><code>If Application.GetOption("Confirm Action Queries") Then Application.SetOption "Confirm Action Queries", False End If </code></pre>
Can you enable [Authorize] for controller but disable it for a single action? <p>I would like to use <code>[Authorize]</code> for every action in my admin controller except the <code>Login</code> action. </p> <pre><code>[Authorize (Roles = "Administrator")] public class AdminController : Controller { // what can I...
<p>You can decorate your controller with [Authorize] and then you can just decorate the method that you want to exempt with [AllowAnonymous]</p>
How to setup 2 actions with the same name, 1 Authorized and 1 not Authorized? <p>Is it possble to have something like this in ASP.NET MVC...</p> <pre><code>[Authorize] [AcceptVerbs(HttpVerbs.Get)] public string AddData(string Issues, string LabelGUID) { return "Authorized"; } [AcceptVerbs(HttpVerbs.Get)] public s...
<p>Yes, its possible. You would need to create your own <code>ControllerActionInvoker</code> and override the <code>FindActionMethod</code> member. I'd let the base class do it's work and then check to see if the method it returns satisfies your criteria and if not, return a better match.</p> <p>I'm doing something ...
Can any processing be done on the model? [MVC] <p>I've decided to make a big push towards MVC for all new sites I make. I have a question about whether or not you can have any processing on the model level.</p> <p>The case that brought up this question is a video site. I have a Video class (model) and one of the thi...
<p>Ruby on Rails has the motto <a href="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model" rel="nofollow">skinny controller, fat model</a>. This doesn't apply to just Rails and should be practiced with any mvc framework.</p>
Can Silverlight 2.0 pages be removed from a collection manually (garbage collected)? <p>I have multiple xaml based pages stored as children of a canvas on another page. I add and remove the children pages as the application runs. However, pages that are removed from the children collection are still running and respo...
<p>When you have your XAML pages displayed, are you registering for keyboard events? If so, are you forgetting to unregister from keyboard events when you remove those pages from the screen?</p> <p>Since there is no "Unloading"-like event on either the UserControl or Page class in Silverlight (at least that I know of)...
CSS: Fixed or Float Layout? <p>My question revolves around CSS Fixed Layout vs a Float Layout that extends to fill the width of the browser.</p> <p>Right now the issue I'm running into is to have the masthead resize depending on the width of the page (something that I understand isn't possible given current browser im...
<p>What about revealing more or less of the image as the browser is resized, rather than scaling the image? It's not quite the same effect, but it's an easy way to fill an entire space with an image.</p> <p>Let's assume, for the sake of the example, that your masthead's background image contains a logo of some sort on...
how can I draw it using starUml <p>I am using staruml, I find it is hard to draw a perfect UML class diagram when the relation is complex.<a href="http://img360.imageshack.us/my.php?image=serviceloadertw5.jpg" rel="nofollow">uml diagram</a></p>
<p>If your UML Diagrams are getting too complex try breaking the digram up into several diagrams each of which covers a smaller subset of classes. You may even want to move your classes into seperate packages to keep them organised. In Star UML (and other UML Tools) classes can appear in more than one diagram so you ca...
Rationale behind return 0 as default value in C/C++ <p>Is there a reason why zero is used as a "default" function return value? I noticed that several functions from the stdlib and almost everywhere else, when not returning a proper number (e.g pow(), strcpy()) or an error (negative numbers), simply return zero.</p> <...
<p>The rationale is that you want to distinguish the set of all the possible (negative) return values corresponding to different errors <em>from</em> the only situation in which all went OK. The simplest, most concise and most C-ish way to pursue such distinction is a logical test, and since in C all integers are "true...
How do I show a caret (^) in math mode in LaTeX? <p>I'm trying to display a caret (<code>^</code>) in math mode in LaTeX to represent the exclusive or operation implemented in the "C languages". By default, <code>^</code> is for creating a superscript in math mode. The closest I can seem to get is by using <code>\wedge...
<p>You might want to use the common symbol for exclusive or instead, \oplus (but give it a proper name with something like <code>\newcommand\XOR{\oplus}</code>). </p> <p>The caret is a bit too small to be noticeable as a binary operator. However, if you do insist using a caret instead, use this:</p> <pre><code>\newco...
List selectors for Objective-C object <p>I have an object, and I want to list all the selectors to which it responds. It feels like this should be perfectly possible, but I'm having trouble finding the APIs.</p>
<p>This is a solution based on the runtime C functions:</p> <p>class_copyMethodList returns a list of class methods given a Class object obtainable from an object.</p> <pre><code>#import &lt;objc/runtime.h&gt; </code></pre> <p>[..]</p> <pre><code>SomeClass * t = [[SomeClass alloc] init]; int i=0; unsigned int mc =...
Problem using NSURLRequest to POST data to server <p>I create an <code>NSURLRequest</code> to post my data in the iPhone application to a server to proceed the PHP script. My PHP script is look like this.</p> <pre><code>&lt;?php $name = $_POST['name']; $email = $_POST['email']; $link = mysql_connect("loca...
<p>You should remove the leading <code>&amp;</code> in <code>myRequestString</code> and the problem is likely that the correct <code>content-type</code> header is not being sent. Try adding a call to</p> <pre><code>[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"]; </code></pre...
Strategy for large scale refactoring <p>I'm currently working in a piece of code where both logic and data access are present in the GUI classes. Obviously, I would like to improve on this situation.</p> <p>The current current structure is basically:</p> <ul> <li>Big ball of mud</li> </ul> <p>The ultimate goal is to...
<p>Never attempt "Big Bang". It almost always blows in your face, since it's a high-risk, desperate measure when everything else has failed.</p> <p>Divide and conquer: This works well ... if your world has only two sides. In real software, you have to conquer so many fronts at the same time, you can rarely afford to l...
Setting LinqDataSource bound DropDownList using URL querystring <p>This is a puzzle for me, I am able to get three DropDownLists to behave like a cascade (it fetches the correct data) but where I run into problem is where I try to set the value for the dropdownlist based on the value of the querystring. </p> <p>Only ...
<p>You can only set the SelectItem/Value/Text after databinding has happened.</p>
How to get username without domain <p>In an aspx page I get the Windows username with the function <code>Request.LogonUserIdentity.Name</code>. This function returns a string in the format "domain\user".</p> <p>Is there some function to only get the username, without resorting to the <code>IndexOf</code> and <code>Sub...
<p>If you are using Windows Authentication. This can simply be achieved by calling <code>System.Environment.UserName</code> which will give you the user name only. If you want only the Domain name you can use <code>System.Environment.UserDomainName</code></p>
Restart ASP.NET application when folder contents change <p>I'm writing a web application that will have "plugins". The plugins will be .DLL files which will export their functionality through predefined interfaces 'n stuff. All the .DLL files are in a folder called "Plugins", and the ASP.NET application loads them all ...
<p>IF the plugins directory is under your Bin directory, the web app will automatically be restarted when anything changes.</p>
How to resolve this VC++ 6.0 linker error? <p>This is a Windows Console application (actually a service) that a previous guy built 4 years ago and is installed and running. I now need to make some changes but can't even build the current version! Here is the build output:</p> <pre><code>--------------------Configurati...
<p>LNK4098 may not be a problem. For example, it can occur if you link against a release version of some library which uses static runtime linkage and causes LIBCMT (note the absense of "D" suffix) to be added to default libraries. Your application, being built in Debug config, uses LIBCMT**D**, thus the conflict. It m...
Why is itemStateChanged on JComboBox is called twice when changed? <p>I'm using a JComboBox with an ItemListener on it. When the value is changed, the itemStateChanged event is called twice. The first call, the ItemEvent is showing the original item selected. On the second time, it is showing the item that has been jus...
<p>Have a look at this source:</p> <pre><code>import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Tester { public Tester(){ JComboBox box = new JComboBox(); box.addItem("One"); box.addItem("Two"); box.addItem("Three"); box.addItem("Four"); ...
PowerShell based database synchronisation using a binary file <p>I have written a database application using a binary file as storage. it is accessed via powershell cmdlets.</p> <p>You can put information into the database using the put- and you can read information using get-.</p> <p>The problem is synchronisation. ...
<p>I think a <a href="http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx" rel="nofollow">mutex</a> would work well here. </p>
Can you use SIMBL to develop a plug-in for the iPhone's Safari? <p>Can you use SIMBL to develop a plug-in for the iPhone's Safari?</p>
<p>No, you cannot.</p>
Comparing Infinities in Java <p>What does the following expression return in Java?</p> <pre><code>Math.max(Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); </code></pre> <p>I saw this question in a website and the answer is <code>Double.POSITIVE_INFINITY</code>. I'm not sure about this answer as how can we compar...
<p>Float.POSITIVE_INFINITY returns float and Double.POSITIVE_INFINITY returns double.</p> <p>There is no method called Math.max(float, double). only Math.max(float, float) and Math.max(double, double)</p> <p>Therefore when the method is called Math.max(float, double), it converts the float argument to double and so t...
Creating a strip of selectable letters for a form <p>I wish to display a list of letters from a through z on a form. Each letter needs to be clickable with that value being passed as a click argument. Aside from creating 26 letters and using the click event of each letter does anyone know of a quick way to do this? I k...
<p>This is the "dynamic way" I would do it in. I know you asked for other clever ways to do it in but I think this is the most accepted way to do it. This will produce those buttons and add a click-handler that takes the button as sender. It will also see to that the buttons location wraps if outside of the forms width...
PHPMailer error(s) <pre><code>function register_contact ($person = array()) { $nogood = false; foreach ($person as $val) { if (strlen($val)==0) { $nogood = true; $status = "There was an error sending the registration please fill in all fields"; } } if (!$nogood) { require_once("class.phpmailer.php"); ...
<p>It sounds like you have two problems.</p> <p>1) Your language file isn't being loaded - see <a href="http://phpmailer.codeworxtech.com/index.php?pg=install" rel="nofollow">installation</a></p> <p>2) The recipient is being rejected - errr double check the SMTP settings and the recipient address</p>
How do I add HTML links in C# TextBox? <p>How can I put a link in a C# <code>TextBox</code>? I have tried to put HTML tags in the box but instead of showing a link it shows the entire HTML tag. Can this be done with a <code>TextBox</code>?</p>
<p>Use the <a href="http://msdn.microsoft.com/en-us/library/f591a55w.aspx">RichTextBox</a>, no need to build your own, it cames with VS</p>
How to quickly parse a list of strings <p>If I want to split a list of words separated by a delimiter character, I can use</p> <pre><code>&gt;&gt;&gt; 'abc,foo,bar'.split(',') ['abc', 'foo', 'bar'] </code></pre> <p>But how to easily and quickly do the same thing if I also want to handle quoted-strings which can conta...
<pre><code>import csv input = ['abc,"a string, with a comma","another, one"'] parser = csv.reader(input) for fields in parser: for i,f in enumerate(fields): print i,f # in Python 3 and up, print is a function; use: print(i,f) </code></pre> <p>Result:</p> <pre> 0 abc 1 a string, with a comma 2 another, one ...
BlackBerry - How to add content to the Home Screen? <p>In the Windows Mobile world you can create a so-called Today plugin that adds content to the phone's main screen -- the one where you see the number of missed calls, unread sms and upcoming events. Is it possible to do something similar on the BlackBerry? I'd lik...
<p>To provide some information on the Home Screen you can use App Icon:<br> <a href="http://stackoverflow.com/questions/1699369/add-a-notification-icon-at-the-status-bar-in-blackberry-jde-4-5-0">Add a notification icon at the status bar in BlackBerry JDE 4.5.0</a><br> <img src="http://img691.imageshack.us/img691/6459/i...
Localize Images in ASP.NET <p>A couple of years ago, we had a graphic designer revamp our website. His results looked great, but he unfortunately introduced a new unsupported font by the web browser. </p> <p>At first I was like, "What!?!"... since most of our content is dynamic and there was no real way to pre-make al...
<p>see my response <a href="http://stackoverflow.com/questions/317191/find-a-localized-file#317231">here</a></p> <p>This can be done manually or using some sort of automated (CMS) system.</p> <p>The basic method is to cache your images in a language specific directory structure and then write an HTTP handler that eff...
URL rewriting problems with ASP .NET 2 on IIS7 and Vista <p>I've got a website running under ASP .NET 2/IIS7/Vista. I have a URL rewriting module which allows me to have extensionless URLs. To get this to work I have configured the system.webServer section of the config file such that all requests are forwarded to the ...
<p>This is a bit of a long shot, but have you tried actually making the configuration changes inside of IIS?</p> <p>I know that the web.config way is supposed to be 100% foolproof, but I've seen a few things where it helps to just configure it in IIS to get it working correctly.</p>
Encoding problem classic ASP <p>I have a problem with classic ASP. The encoding is wrong when I send data with <code>XMLHttp.send</code>. The response is a PDF file, but the “ÆØÅ” gets wrong, the “Ø” is read as “øy” for example. It’s like it’s a converting mistake from UTF-8 to ISO-8859-1, but i...
<p>Try:</p> <pre><code>Session.CodePage = 28591 </code></pre> <p>There is some good information <a href="http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/en/RAS_SDK/rassdk_com_doc/doc/rassdk_com_doc/BestPractices11.html" rel="nofollow">here</a>, and I got the CodePage number <a href="http://support.micros...
Serializing objects for asynchronous messaging <p>I'm considering using AMQP (using qpid) to enable a mixture of Python and Java services communicate with each other. Basic text messaging seems simple enough but, as with every other messaging technology I've investigated, that's where it seems to stop. Except for build...
<p>Owen, may I offer a few words about RabbitMQ. </p> <p>AMQP is a binary protocol and you can certainly do much more than send strings around! Which Python client do you plan to use? We recommend Barry Pederson's client for most uses: <a href="http://barryp.org/software/py-amqplib/" rel="nofollow" rel="nofollow">h...
Server based reuse - DLL, GAC, or REST? <p>We have a piece of functionality that is used by several different applications (clients) on the same server. It can best be modeled as a service, has a backend database, and there will only be one version of the functionality and the database in use at any one time.</p> <p>U...
<p>This is a problem I've struggled with many times and there really isn't any best answer other then it depends. My personal opinion is that you need to stay away from option 1 for a couple of reasons:</p> <ol> <li>By having all your clients share a single binary it will now require all of your clients to be tested e...
What does this Perl conditional do? <p>I'm trying to understand a particular Perl code from <a href="http://sourceforge.net/projects/vcake" rel="nofollow">vcake</a>. Usually I find my way around in Perl but the following statement baffles me. I suspect that this is simply an error but I'm not completely sure. The state...
<p><code>my $numReads</code> means: Create a new local variable within the context of the <code>foreach</code> loop. Its initial value is <code>undef</code>, which in numerical context is treated as <code>0</code>. So the code reads:</p> <pre><code>if ((...) and (0 &gt;= ($coverage)) ) { } </code></pre> <p>which mean...
Thread was being aborted <p>I am getting a " Thread was being aborted " Exception in an ASP.NET page.I am not at all using any Response.Redirect/Server.Transfer method.Can any one help me to solve this ?</p>
<p>The <strong>bad</strong> solution is using </p> <pre><code>Response.Redirect(URL, False) </code></pre> <p>which will cause <strong>not</strong> to Response.End() current page, however be careful this might lead problems because rest of the page will get <strong>executed</strong> and might cause <strong>login bypas...
Why does NSSet objectEnumerator increment the retain count? <p>After getting the objectEnumerator in the following code, the set1 retain count goes to 3. I was surprised to see that because I didn't expect it to change. I searched the <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/...
<p>It's generally not a good idea to rely on the retain count of objects, as it's an internal detail of the framework. Instead make sure your code adheres to the memory management principles, particularly ensuring that retain/new/copy and release/autorelease are balanced.</p>
Namespace Organization - AOP Validators <p>I have started using aspects for parameter validation in our development framework. It works nicely, and I enjoy not littering the first half of a public method with validation code.</p> <p>What I am wondering is if anyone has any recommendations with where in the namespace ...
<p>Right now you are considering partioning using technical criteria, i.e. "Put all validators in a namespace because they are validators". This does not take into account the reason why the validators <em>exist</em>.</p> <p>My suggestion is to partition by functionality:</p> <ol> <li><p>All-purpose validators (such ...
How to fix "Referenced assembly does not have a strong name" error? <p>I've added a weakly named assembly to my <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio#Visual_Studio_2005">Visual&nbsp;Studio&nbsp;2005</a> project (which is strongly named). I'm now getting the error:</p> <blockquote> <p>"Referen...
<p>To avoid this error you could either:</p> <ul> <li>Load the assembly dynamically, or</li> <li>Sign the third-party assembly. </li> </ul> <p>You will find instructions on signing third-party assemblies in <em><a href="http://buffered.io/post/2008-07-09-net-fu-signing-an-unsigned-assembly-without-delay-signing/">.NE...
How to write a Web Service for Google App Engine? <p>I am simply wondering how to write a Web Service (XML - SOAP) for Google App Engine? I am really new with Python and I have been looking for example for a while, but no chance. </p> <p><strong>Does anybody could point me out any article or simply could give me an ex...
<p>I was curious about this myself and not finding anything I decided to try to get something to work. The short answer is that it turns out a SOAP service can actually be done using the latest alpha <a href="http://pywebsvcs.sourceforge.net/zsi.html">ZSI library</a>. However it isn't simple and I didn't do much more t...
RewriteRule redirect <p>Okay I have this RewriteRule which is supposed to redirect any request for the file base.css to {folder of .htacces file}/include/style/base.css, but is just keeps redirecting in an infinite loop, I thought the L parameter would make sure that wouldn't happen.</p> <pre><code>RewriteRule (.*)/ba...
<p>You have Redirect and Rewrite confused. A redirect is a HTTP status code that tells the browser to go to another URL. You actually just want to Rewrite the location to another file location. Try</p> <pre><code>RewriteRule (.*)/(.*).css$ /include/style/$2.css [L,NC] </code></pre> <p>If this doesn't work try addi...
Using Unicode in C++ source code <p>What is the standard encoding of C++ source code? Does the C++ standard even say something about this? Can I write C++ source in Unicode?</p> <p>For example, can I use non-ASCII characters such as Chinese characters in comments? If so, is full Unicode allowed or just a subset of Uni...
<p>Encoding in C++ is quite a bit complicated. Here is my understanding of it.</p> <p>Every implementation has to support characters from the <em>basic source character set</em>. These include common characters listed in §2.2/1 (§2.3/1 in C++11). These characters should all fit into one <code>char</code>. In additio...
Validation of viewstate MAC failed <p>I am currently receiving this error:</p> <blockquote> <p>Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <code>&lt;machineKey&gt;</code> configuration specifies the same validationKey and validation algorithm. AutoGenerate ...
<p>Is your web app hosted in a webfarm?</p> <p>If so, the reason for this is that a page is rendered by server 1, and posted to server 2. Therefore, machine keys are different, and the validation failed.</p> <p>It will work on ASP.NET 3.5 as well.</p>
How do I fix this MySQL query? <pre><code>SELECT avg(con_hits) as avg_hits FROM content WHERE con_type = 1 AND con_posttime &lt; $twelve_hrs_ago AND con_refresh = 0 ORDER BY con_posttime DESC LIMIT 100 </code></pre> <p>I would like it to go to the first record that was posted at least 12 hours ag...
<p><code>LIMIT</code> is applied to the resultset, after <code>AVG</code> is calculated. You can do what you want, with a subselect:</p> <pre><code>SELECT avg(con_hits) as avg_hits FROM ( SELECT con_hits FROM content WHERE con_type = 1 AND con_posttime &lt; $twelve_hrs_ago AND con_refresh = 0 ORDER...
When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used? <p>What are the proper uses of:</p> <ul> <li><code>static_cast</code></li> <li><code>dynamic_cast</code></li> <li><code>const_cast</code></li> <li><code>reinterpret_cast</code></li> <li>C-style cast <code>(type)value</code></li> <li>Functi...
<p><strong><code>static_cast</code></strong> is the first cast you should attempt to use. It does things like implicit conversions between types (such as <code>int</code> to <code>float</code>, or pointer to <code>void*</code>), and it can also call explicit conversion functions (or implicit ones). In many cases, expli...
How new programming frameworks help analysts, designers and programmers better work together? <p>It may be Water fall, iterative or agile development or anything else. No matter what development lifecycle mode we talk about there always several perspectives for same problem. From business to problem oriented and furthe...
<p>A framework only provides 2 things:</p> <ol> <li>A dictionary which is the same for everybody, so you can communicate and know that you are talking about the same thing</li> <li>A process for people to follow, should you get confused.</li> </ol> <p>The rest is up to you as a team.</p>
How do I Unit Test Actions without Mocking that use UpdateModel? <p>I have been working my way through Scott Guthrie's excellent post on <a href="http://weblogs.asp.net/scottgu/archive/2008/10/16/asp-net-mvc-beta-released.aspx">ASP.NET MVC Beta 1</a>. In it he shows the improvements made to the UpdateModel method and ...
<p>I don't think it can be done since TryUpdateModel, which UpdateModel uses, references the ControllerContext which is null when invoked from a unit test. I use RhinoMocks to mock or stub the various components needed by the controller.</p> <pre><code>var routeData = new RouteData(); var httpContext = MockRepository...
iPhone video buffer <p>I'm trying to build a video recorder without jailbreaking my iPhone (i've a Developer license). I began using PhotoLibrary private framework, but i can only reach 2ftp (too slow). Cycoder app have a fps of 15, i think it uses a different approach. I tried to create a bitmap from the previewView o...
<p>Here is the code:</p> <pre><code>image = [window _createCGImageRefRepresentationInFrame:rectToCapture]; </code></pre> <p>Marco</p>
Is there a service which will let me create a snippet of a webpage <p>I am looking for a way to get the essence or the most important aspect of a webpage? If I provide a URL, is there any external service which can accomplish this? I am not looking for snap.com like service as it provides a snapshot.</p> <p>I might be...
<p>You can try <a href="http://developer.yahoo.com/search/content/V2/termExtraction.html" rel="nofollow">Yahoo's Term extraction service</a></p> <p><strong>Update 02-May-2012</strong></p> <p>Yahoo has release a new <a href="http://developer.yahoo.com/contentanalysis/" rel="nofollow">Content Analysis Web service</a> w...
Is there a REAL performance difference between INT and VARCHAR primary keys? <p>Is there a measurable performance difference between using INT vs. VARCHAR as a primary key in MySQL? I'd like to use VARCHAR as the primary key for reference lists (think US States, Country Codes) and a coworker won't budge on the INT AUTO...
<p>It's not about performance. It's about what makes a good primary key. Unique and unchanging over time. You may think an entity such as a country code never changes over time and would be a good candidate for a primary key. But bitter experience is that is seldom so.</p> <p>INT AUTO_INCREMENT meets the "unique and u...
How do you organize C# code in to files? <p>In C#, the questions of what types to create, what members they should have, and what namespaces should hold them, are questions of OO design. They are not the questions I'm interested in here.</p> <p>Instead, I want to ask how you store these in disk artifacts. Here are s...
<p>Whatever you do, just PLEASE do it consistently. I don't believe there is any one single answer (though there are a few wrong ones). But just make sure you stay true to your form as this will be the key for your successor(s) to find things easily.</p>
Is it possible to Serialize a LINQ object? <p>I'd like to serialize some LINQ generated objects and store them in a table as a binary field (Never you mind why). I'd like to be able to write some code that looks something like this:</p> <pre><code>SerialTestDataContext db = new SerialTestDataContext(); relation_table...
<p>With linq-to-sql (from tags), then yes: you can mark the dmbl as serializable, which uses the [DataContract]/[DataMember] approach. You do this by setting the "Serialization Mode" to "Unidirectional" in the designer, or you can do it in the dbml itself:</p> <pre><code>&lt;Database ... Serialization="Unidirectional"...
SQLite .dump command from SQLiteConnection object <p>Using SQLite from .net, Is there a way to access the <code>.dump</code> command or something equivalent from the SQLiteConnection class?</p>
<p>The <code>.dump</code> command is part of the sqlite command line program (<code>shell.c</code>), not part of the sqlite library. So, it is unlikely to be provided by a .net connection class. </p> <p>However, since the source code for the sqlite command line program is in the public domain, and uses the same librar...
non-member non-friend function syntax <p>Is their a way to use a non-member non-friend function on an object using the same "dot" notation as member functions?</p> <p>Can I pull a (any) member out of a class, and have users use it in the same way they always have?</p> <p>Longer Explanation:</p> <p><a href="http://ww...
<p>Yes, it means that part of the interface of an object is composed of non member functions.</p> <p>And you're right about the fact it involves the use of the following notation, for an object of class T:</p> <pre><code>void T::doSomething(int value) ; // method void doSomething(T &amp; t, int value) ; // non-me...
Msg 64, Level 20, State 0, Line 0 SQL Server Error <p>I am running a sproc on an SQL Server 2005 server which is resulting in the following error:</p> <blockquote> <p>Msg 64, Level 20, State 0, Line 0 A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error:...
<p>This happens when the DB server is made unavailable with a client connection open.</p> <p>To reproduce: If you have a query open in SSMS, restart the SQL instance, run the query again to get this error.</p> <p>Thoughts:</p> <ul> <li>Is the SQL instance being restarted?</li> <li>Is the DB being <a href="http://msd...
Generating large sets of random data vb6/vb net <p>Is there an easy way in either language to generate a large set of random data quickly so far all the functions I've tried haven't worked too well when I need to generate a group of say 500,000 characters :( Any ideas?</p>
<blockquote> <p>Use UUIDGen.</p> </blockquote> <p>Don't. GUIDs aren't really random. You can actually generate large amounts of data very fast using the <code>System.Random</code> class in VB.NET. 500,000 characters/bytes are no problem:</p> <pre><code>Dim buffer As Byte() = Nothing Array.Resize(buffer, 500000) Cal...
"Atomically" changing a System.Threading.Timer <p>Let's say I have an existing System.Threading.Timer instance and I'd like to call Change on it to push it's firing time back:</p> <pre><code>var timer = new Timer(DelayCallback, null, 10000, Timeout.Infinite); // ... (sometime later but before DelayCallback has execute...
<p>it sounds like what you really want is the application-idle event</p> <pre><code>System.Windows.Forms.Application.Idle </code></pre>
simple linq to sql has no supported translation to SQL <p>i have this in my BlogRepository</p> <pre><code>public IQueryable&lt;Subnus.MVC.Data.Model.Post&gt; GetPosts() { var query = from p in db.Posts let categories = GetCategoriesByPostId(p.PostId) let comments = G...
<p>You are calling <code>GetCommentsByPostId</code> within what is ultimately an expression tree. That tree, when composed in <code>BlogService.GetPublicPosts</code>, is converted to SQL.</p> <p>During that conversion, it is just a method call, nothing more. Linq to Sql understands certain method calls, and yours is n...
I'm looking for a way to search the values in a .net hashtable using wildcards <p>I've got a whole host of values stored in a .net 2.0 hashtable. What I would really like to find is a way to, essentially, do a SQL select statement on the table.</p> <p>Meaning, I'd like to get a list of keys whose associated values m...
<p>If you are truly looking for things that start with a number, then you can do it much faster than with a Regex. Just look at the first character of each key and determine if it is a digit. Store the keys you want to remove in a List since you only need to keep the key.</p> <pre><code> List&lt;string&gt; keysTo...
Ping a site in ruby? <p>What replacements are available for pinging an ip address in Ruby? The stdlib "ping" library seems to be pretty limited in functionality. I'm not interested in rolling my own code here. Are there good gems available? Should I just suck it up and live with it?</p> <p>(I'm coding in Ruby 1.8.6 on...
<p><code><a href="https://rubygems.org/gems/net-ping" rel="nofollow">net-ping</a></code> is worth a look. It allows for TCP pings (like the standard ruby <code>ping</code>) but also UDP, HTTP, and ICMP pings. An ICMP ping requires root privileges but the others do not. </p>
Useful regular expression tutorial <p>Is there a good tutorial on using regular expressions, especially with <a href="http://en.wikipedia.org/wiki/Grep" rel="nofollow">grep</a>? I tried googling for some, but most tutorials are too basic and cover things I already know.</p>
<p><a href="http://www.regular-expressions.info/tutorial.html" rel="nofollow">Regular-expressions.info has a tutorial section</a>. This site is pretty comprehensive for regular expressions in general, although the emphasis is on support in scripting and programming languages.</p> <p>The J. Friedl book, (mentioned prev...
VB.NET Extension Methods <p>when I apply the tag above my methods I get the error </p> <blockquote> <p>Type System.Runtime.CompilerServices.Extension is not defined.</p> </blockquote> <p>Here is my sample</p> <pre><code>&lt;System.Runtime.CompilerServices.Extension()&gt; _ Public Sub test() End Sub </code><...
<p>What version of .net framework the IDE is pointing towards?</p> <p>Also, at first glance the syntax of extension method looks incorrect.</p> <p>The code is incomplete. Please put the using statements in the example for anyone to use the code and compile it - to reproduce the error.</p>
Java Protected Access Not Working <p>In java, there's three levels of access:</p> <ul> <li>Public - Open to the world</li> <li>Private - Open only to the class </li> <li>Protected - Open only to the class and its subclasses (inheritance).</li> </ul> <p>So why does the java compiler allow this to happen?</p> <p>TestB...
<p>Actually it should be:</p> <blockquote> <p>Open only to the <a href="http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html"><strong>classes on the same package</strong></a> the class and its subclasses (inheritance)</p> </blockquote> <p>That's why</p>
Is there a graceful way to stop svnserve -d <p>I'm looking for something like: </p> <pre><code>svnserve stop </code></pre>
<p>The recommended way is to do it is by using the <code>kill</code> command which will allow subversion to shut down properly. I don't think there is any better way to do it.</p>
Open source or free financial analysis programs/libraries <p>I'm looking for something containing similar functions to Matlab’s financial and financial derivatives toolbox but don’t have the cash to spend on matlab. I would appreciate any info on free or open source libraries or programs that will let me easily cal...
<p>How about <a href="http://www.jquantlib.org/index.php/Main_Page">JQuantLib</a> or <a href="http://quantlib.org/index.shtml">QuantLib</a>?</p>
Build Tar file from directory in PHP without exec/passthru <p>So I have a client who's current host does not allow me to use tar via exec()/passthru()/ect and I need to backup the site periodicly and programmaticly so is there a solution?</p> <p>This is a linux server.</p>
<p>PHP 5.3 offers a much easier way to solve this issue.</p> <p>Look here: <a href="http://www.php.net/manual/en/phardata.buildfromdirectory.php">http://www.php.net/manual/en/phardata.buildfromdirectory.php</a></p> <pre><code>&lt;?php $phar = new PharData('project.tar'); // add all files in the project $phar-&gt;buil...
Singleton vs Static Class for exposing data read from xml <p>We have a PageRoles xml file which contains the page path and the user role that can access that page.</p> <p>We are maintaining a Dictionary in a static class, which gets loaded int static constructor for the class. The class has a method CheckIfRoleAllowed...
<p>I can see two advantages of using the singleton pattern (if implemented through, say, a static property):</p> <ol> <li>you can delay loading the XML file until the first page is accessed.</li> <li>you can check whether the XML file has changed on disk, and automatically reload it on the next access.</li> </ol> <p>...
Parallelization: What causes Java threads to block other than synchronization & I/O? <p>Short version is in the title.</p> <p>Long version: I am working on a program for scientific optimization using Java. The workload of the program can be divided into parallel and serial phases -- parallel phases meaning that highl...
<p>All graphics operations run on a single thread in swing. If they are rendering to the screen they will effectively be contending for access to this thread.</p> <p>If you are running on Windows, all graphics operations run on a single thread no matter what. Other operating systems have similar limitations.</p> <p>I...
Implementing a search page using url parameters in ASP.NET and ASP.NET MVC <p>Let's say I have a search page called Search.aspx that takes a search string as a url parameter ala Google (e.g. Search.aspx?q=This+is+my+search+string).</p> <p>Currently, I have an asp:TextBox and an asp:Button on my page. I'm handling the...
<p>You need to understand that MVC doesn't directly reference .aspx pages like WebForms in its URLs. Its main purpose is to separate concerns, that is model (data), controller (logic), and view (presentation).</p> <p>First, you'd have to create a route matching your URLs, which would now look like this for example : /...
How to design a simple C++ object factory? <p>In my application, there are 10-20 classes that are instantiated once[*]. Here's an example:</p> <pre><code>class SomeOtherManager; class SomeManagerClass { public: SomeManagerClass(SomeOtherManager*); virtual void someMethod1(); virtual void someMethod2(); };...
<p>Assuming a class (plugin1) which inherits from SomeManagerClass, you need a class hierarchy to build your types:</p> <pre><code>class factory { public: virtual SomeManagerClass* create() = 0; }; class plugin1_factory : public factory { public: SomeManagerClass* create() { return new plugin1(); } }; </code>...
Detecting mouse double-click in Flash (AS2) <p>Is there a way to detect mouse double-click on a button object using ActionScript 2.0? </p>
<p>To make explicit what the other answers imply, there's no built-in way. You just have to listen for two clicks and decide whether they're close enough together to count as a double, or else use a package that does that, or else use AS3.</p>
Best Practice for Designing User Roles and Permission System? <p>I need to add user roles and permission system into my web application built using PHP/MySQL. I want to have this functionality: </p> <ol> <li>One root user can create sub-roots, groups, rules and normal users( all privileges) .</li> <li>Sub-roots can cr...
<p>The pattern that suits your needs is called <a href="http://en.wikipedia.org/wiki/Role-based_access_control" rel="nofollow">role-based access control</a>.</p> <p>There are several good implementations in PHP, including <a href="http://framework.zend.com/manual/1.12/en/zend.acl.html" rel="nofollow">Zend_Acl</a> (goo...
Symbian S60 - Scrolling text in a CEikLabel <p>I have a single line CEikLabel in my application that needs to scroll text.</p> <p>The simple solution that comes to mind (but possibly naive) would be something like..</p> <pre><code>[begin pseduo code] on timer.fire { set slightly shifted text in label redraw lab...
<p>I don't know whether there is another way to do it and can't say whether the approach you have in your mind will be inefficient. However, you may want to take a look at <a href="http://www.newlc.com/forum/how-create-moving-text-symbain" rel="nofollow">this thread</a> which discusses pretty much the same question as ...
Any easy REST tutorials for Java? <p>Every tutorial or explanation of REST just goes too complicated too quickly - the learning curve rises so fast after the initial explanation of CRUD and the supposed simplicity over SOAP. Why can't people write decent tutorials anymore!</p> <p>I'm looking at Restlet - and its not ...
<p>Could you describe precisely what caused you troubles in our Restlet tutorials? We are interested in fixing/improving what needs to. </p> <p>Did you check the screencasts? <a href="http://www.restlet.org/documentation/1.1/screencast/">http://www.restlet.org/documentation/1.1/screencast/</a></p> <p>Otherwise, there...
Fetching only rows that match all entries in a joined table (SQL) <p>I have the following five tables:</p> <ul> <li>ISP</li> <li>Product</li> <li>Connection</li> <li>AddOn</li> <li>AddOn/Product (pivot table for many-to-many relationship).</li> </ul> <p>Each Product is linked to an ISP, each Connection is listed to a...
<pre><code>GROUP BY set-of-column HAVING SUM(CASE WHEN ISNULL(pa.addon_id, 0) IN (1,14,237) THEN 1 ELSE 0 END) = 3 </code></pre>
How can I print different bands depending on the value of a Field in a DataSet using FastReport? <p>I have a product's dataset and I want to have distinct bands for each type of product, something like, if the product is a fruit, print it's weight, if the product is a car print its color and so on.</p> <p>And I want t...
<p>FastReports allows you to intercept the program's default report construction process with events at several useful places. If you have, for example a master band, in its OnBeforePrint event, you can put code that checks out the type of product and then a case statement could set the visible property to true only on...
Passing web context to a 'service' in ASP MVC app <p>I'm trying to work out a way of passing the web current http context to a service class (or initialising the class with a reference to it). I am doing this to abstract the rest of the app away from needing to know anything about the http context. </p> <p>I also want...
<p>This is why HttpContextBase and HttpContextWrapper were introduced. You probably want to use HttpContextBase and when passing the real context in, use <code>new HttpContextWrapper( httpContext )</code>, although, I think that what is available to you in the controller is already of type HttpContextBase. I would cr...
"Copying" a Tree from SVN into a local repository and merging it back afterwards <p>I have a SVN Repository at my main PC, to which only I have access. I also have a Laptop, and I don't want to lose SVN Functionality when I am not connected to my PC. So at the moment, I simply copy accross the whole Repository to the L...
<p>Instead of copying the entire repository each time, I recommend to use <a href="http://en.wikipedia.org/wiki/Rsync" rel="nofollow">rsync</a>. If you use the fsfs backend of svn (which you should), then it will synchronize only the new revisions, and do so quickly. Of course, concurrent checkins wouldn't be possible ...
How should methods updating database tables be unit tested? <p>I have an application that is database intensive. Most of the applications methods are updating data in a database. Some calls are wrappers to stored procedures while others perform database updates in-code using 3rd party APIs. </p> <p>What should I be...
<p>I do number 2, i.e., test the update by updating a record, and then reading it back out and verifying that the values are the same as the ones you put in. Do both the update and the read in a transaction, and then roll it back, to avoid permanent effect on the database. I don't think of this as testing Framework ...
Is there a way to disable/override the default style for disabled WebControls <p>that one has been nagging me ever since I dabbled in web developpement; is there a way for this? Could I override that style and rely on some other mean to inform my users that that control can't be ineracted with?</p> <p>My problem is t...
<p>Sure! What it sounds like you're looking for is a <a href="http://css.maxdesign.com.au/selectutorial/selectors_attribute.htm" rel="nofollow">CSS attribute selector</a>:</p> <pre><code>input[@disabled=true], input[@disabled] { .. insert your new style here .. } </code></pre> <p>Hope that helps!</p>
MySQL - how to SHOW PROCESSLIST only with current user's processes? <p>Is there a way in MySQL 5 to show only the current user's processes(queries)?</p> <p>The user has the <code>PROCESS</code> privilege, therefore <code>SHOW PROCESSLIST</code> displays running processes of all users. According to the documentation, <...
<p>If you use MySQL 5.1.7 or newer, you can use the <a href="http://dev.mysql.com/doc/refman/5.1/en/processlist-table.html">PROCESSLIST</a> table in the INFORMATION_SCHEMA. So you can query it with ordinary <code>SELECT</code> queries and apply filtering conditions in a <code>WHERE</code> clause.</p> <p>This feature ...
contextswitchdeadlock <p>Whilst debugging my program in VS 2008 I have come across the following error:</p> <p>The CLR has been unable to transition from COM context 0x34fc1a0 to COM context 0x34fc258 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait...
<p>You can turn this off if you think you've definitely <em>not</em> got a deadlock situation:</p> <p>Debug->Exceptions->Managed Debug Assistants menu in Visual Studio and uncheck the ContextSwitchDeadlock</p>
Using an anchor as a javascript action, what should the link be? <p>I've seen (and used) code to have a link spawn a javascript action many times in my life, but I've never come to a firm conclusion on if the href attribute should be blank or #. Do you have any preference one way or the other, and if so, why?</p> <pr...
<p>You <strong>must</strong> have <em>something</em> for the <code>href</code> attribute, otherwise the browser will not treat it as a link (for example, making it focusable or giving it an underline) - that's why the use of "#" has become prevalent.</p> <p>Also, the contents of the event attributes (<code>onclick</co...
Uninstall Without MSI File <p>I often get a problem with Windows Installer trying to uninstall a package, but it complains that</p> <blockquote> <p>The feature you are trying to use is on a network resource that is unavailable.</p> </blockquote> <p>Is there a known means of uninstalling such packages when the origi...
<p>Please note that Microsoft has now released an official tool to resolve these issues, without the problems that previously existed with MSIZAP.</p> <ul> <li>Microsoft Fixit: <a href="http://support.microsoft.com/mats/Program_Install_and_Uninstall">Fix problems with programs that can't be installed or uninstalled</a...
Which JavaScript library you recommend to use with Java EE + Struts + iBatis? <p>Which JavaScript library you recommend to use with Java EE + Struts + iBatis ? Something like Ext JS, Dojo, frameworks that can be easily integrated with Struts.</p>
<p>There exists a framework that is supposed to tie in nicely with Java Server/Middleware called <a href="http://oss.metaparadigm.com/jsonrpc/" rel="nofollow">JSON-RPC</a></p> <p>However I have never used it and cannot vouch for it.. Aside from that my favourite framework is <em>cough</em> <a href="http://jquery.com/"...
Opening a folder in explorer and selecting a file <p>I'm trying to open a folder in explorer with a file selected.</p> <p>The following code produces a file not found exception: </p> <pre><code>System.Diagnostics.Process.Start( "explorer.exe /select," + listView1.SelectedItems[0].SubItems[1].Text + "\\" ...
<pre><code> // suppose that we have a test.txt at E:\ string filePath = @"E:\test.txt"; if (!File.Exists(filePath)) { return; } // combine the arguments together // it doesn't matter if there is a space after ',' string argument = "/select, \""...
SQL Server Alerts - Best Practices <p>What SQL Server Alerts do you always setup for every database? What do you always monitor regardless of the database?</p>
<p>You should monitor and be alerted for severity levels 17 to 25. <br></p> <p>Severity levels from 17 through 19 will require intervention from a DBA, they're not as serious as 20-25 but the DBA needs to be alerted.<br> 17 Insufficient Resources<br> 18 Nonfatal Internal Error Detected<br> 19 Error in Resource<br> <br...
C# Problem setting label text on another form <p>I am a very new C# programmer and I am trying to make a kiosk application more accessible by increasing the size of fonts. No problem on the main form. I'm having a problem replacing messageboxes (for which I believe there is no way to increase the font size) with smal...
<p>You cannot access the ErrorForm as if it was static. That is just the class definition, you need to set the property on an instance of the ErrorForm.</p> <p>Somewhere in your app, you created a new ErrorForm. You need to take that variable and set your LblNotCheckedInBecause property on that.</p> <p>Look for code ...
Are goto and destructors compatible? <p>This code leads to undefined behavior:</p> <pre><code> void some_func() { goto undefined; { T x = T(); undefined: } } </code></pre> <p>The constructor is not called. </p> <p>But what about this code? Will the destructor of x be called? I think it will be, but I w...
<p>Yes, destructors will be called as expected, the same as if you exited the scope early due to an exception.</p> <p>Standard 6.6/2 (Jump statements):</p> <blockquote> <p>On exit from scope (however accomplished), destructors are called for all constructed objects with automatic storage duration that are declared ...
Implementing Rails' layout functionality with Apache Tiles <p>Has anybody tried duplicating Ruby on Rails' layout functionality with Apache Tiles 2 ? I'm trying to integrate Tiles 2 with Spring. I have a previously written custom view resolver for the Spring framework that does this quite nicely, but I'm upgrading to ...
<p>I've done exactly this. Here's some snippets from that Java app.</p> <pre><code>&lt;definition name="registration" template="/tiles/layouts/defaultLayout.jsp"&gt; &lt;put-attribute name="body" value="undefined" /&gt; &lt;put-attribute name="footer" value="/tiles/footer.jsp?alt=true" /&gt; &lt;/definition&gt; ...
MySQL Composite PK with Nullable FKs <p>First off, let me preface this question by stating that I'm really a pretty terrible data modeler. I know only enough to be dangerous.</p> <p>The table I'm building has four foreign keys, two of which reference the same table. Here's the create statement for that table.</p> <...
<pre><code>CREATE TABLE IF NOT EXISTS `abnr`.`reputation_event_log` ( `id` INT NOT NULL AUTO_INCREMENT , `reputation_event_id` INT NULL , `giver_user_id` INT NOT NULL , -- mandatory giver_user_id `receiver_user_id` INT NULL , -- optional receiver_user_id . . . </code></pre> <p>...
C# How to replace Microsoft's Smart Quotes with straight quotation marks? <p>My post below asked what the curly quotation marks were and why my app wouldn't work with them, my question now is how can I replace them when my program comes across them, how can I do this in C#? Are they special characters?</p> <p><a href=...
<p>A more extensive listing of problematic word characters</p> <pre><code>if (buffer.IndexOf('\u2013') &gt; -1) buffer = buffer.Replace('\u2013', '-'); if (buffer.IndexOf('\u2014') &gt; -1) buffer = buffer.Replace('\u2014', '-'); if (buffer.IndexOf('\u2015') &gt; -1) buffer = buffer.Replace('\u2015', '-'); if (buffer....