instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I've heard of a few ways to implement tagging; using a mapping table between TagID and ItemID (makes sense to me, but does it scale?), adding a fixed number of possible TagID columns to ItemID (seems like a bad idea), Keeping tags in a text column that's comma separated (sounds crazy but could work). I've even heard...
<p>Three tables (one for storing all items, one for all tags, and one for the relation between the two), properly indexed, with foreign keys set running on a proper database, should work well and scale properly. </p> <pre><code>Table: Item Columns: ItemID, Title, Content Table: Tag Columns: TagID, Title Table: ItemT...
<p>I would suggest following design : Item Table: Itemid, taglist1, taglist2<br> this will be fast and make easy saving and retrieving the data at item level. </p> <p>In parallel build another table: Tags tag do not make tag unique identifier and if you run out of space in 2nd column which contains lets say 10...
4,123
<p>Is there a way to make a TSQL variable constant?</p>
<p>No, but you can create a function and hardcode it in there and use that.</p> <p>Here is an example:</p> <pre><code>CREATE FUNCTION fnConstant() RETURNS INT AS BEGIN RETURN 2 END GO SELECT dbo.fnConstant() </code></pre>
<p>The best answer is from SQLMenace according to the requirement if that is to create a temporary constant for use within scripts, i.e. across multiple GO statements/batches.</p> <p>Just create the procedure in the tempdb then you have no impact on the target database.</p> <p>One practical example of this is a datab...
4,619
<p>I have a program that runs osql.exe from microsoft sql server tools directory and runs a script. </p> <p>The problem is that on computers that don't have an installation of sql server, this tool is missing. So my question is whether or not is possible to run it as a standalone( along with any dll that may be requir...
<p>Yes, you can. Just copy the binary and off you go.</p>
<p>Why are you spawning osql?</p> <p>I've written simple programs to execute scripts using SMO - mostly insired by <a href="http://weblogs.asp.net/jgalloway/archive/2006/11/07/Handling-_2200_GO_2200_-Separators-in-SQL-Scripts-_2D00_-the-easy-way.aspx" rel="nofollow noreferrer">this post</a>.</p> <p><strong>EDIT</stro...
33,781
<p>I'm serializing an object in a C# VS2003 / .Net 1.1 application. I need it serialized without the processing instruction, however. The XmlSerializer class puts out something like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-16" ?&gt; &lt;MyObject&gt; &lt;Property1&gt;Data&lt;/Property1&gt; &lt...
<p>In 2.0, you would use <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlwritersettings.omitxmldeclaration.aspx" rel="noreferrer">XmLWriterSettings.OmitXmlDeclaration</a>, and serialize to an XmlWriter - however I don't think this exists in 1.1; so not <em>entirely</em> useful - but just one more "consid...
<p>If by "processing instruction" you mean the xml declaration, then you can avoid this by setting the OmitXmlDeclaration property of XmlWriterSettings. You'll need to serialize using an XmlWriter, to accomplish this.</p> <pre><code>XmlSerializer serializer = new XmlSerializer(typeof(MyObject)); StringBuilder builder...
19,894
<p>I am currently writing an open source wrapper for a COM object. I have just installed StyleCop and run it against some of my code, and as I expected it threw up a load of warnings (some of which I should have been doing already eg adding "this." to all local method calls and variables)</p> <p>How many of these war...
<p>The general idea with StyleCop is: All of them :)</p> <p>The more options you turn off the less value StyleCop has in enforcing a one-true code format. That being said, if you don't like some of the options then some options is better than none, include the StyleCop settings file with your code and others working o...
<p>Most large open source projects have their own style guidelines. For example, here's the <a href="http://httpd.apache.org/dev/styleguide.html" rel="nofollow noreferrer">Apache C Language Style Guide</a>.</p> <p>As a start, I suggest trawling the FAQ for the OS project you're interested in and take it from there.</p...
43,303
<p>This is the trace of my app,when I updated my device to 2.2.</p> <p>any idea to get rid of this leak? because I think that's the culprit who keep crashing my application.<br> This is trace when I run my application in os2.2,see the image which show the part which might be generating leak,and if you can give me some...
<p>That trace is rather meaningless without access to the code. My suggestion would be to download and install the Clang Static Analyzer and run your code against it to determine where the leak exists. It can be found at <a href="http://clang.llvm.org/StaticAnalysis.html" rel="nofollow noreferrer">http://clang.llvm.o...
<p>You need to click the "View" button in the upper right of Instruments and choose "Extended Detail" then click the line item as you have selected above then click the details in the Extended Details right hand side column and it will open up to the line of code at fault in XCode </p>
44,578
<p>I'm looking for a way in .NET (2.0, C# in particular) for source code to trigger a debugging break as if a breakpoint was set at that point, without having to remember to set a specific breakpoint there in the debugger, and without interfering with production runtime.</p> <p>Our code needs to swallow exceptions in ...
<p>You probably are after something like this:</p> <pre><code>if(System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break(); </code></pre> <p>Of course that will still get compiled in a Release build. If you want it to behave more like the Debug object where the code simply doesn't exist in a Rele...
<p>In Visual Studio 2010, hitting <strong>Retry</strong> on a <code>Debug.Assert</code> dialog takes you to the failed debug assertion, just as if you had a breakpoint.</p>
47,172
<p>Does anyone know of a faster decimal implementation in python?</p> <p>As the example below demonstrates, the standard library's decimal module is ~100 times slower than <code>float</code>.</p> <pre class="lang-py prettyprint-override"><code>from timeit import Timer def run(val, the_class): test = the_class(1...
<p>The <a href="http://gmplib.org" rel="noreferrer">GMP</a> library is one of the best arbitrary precision math libraries around, and there is a Python binding available at <a href="http://www.aleax.it/gmpy.html" rel="noreferrer">GMPY</a>. I would try that method.</p>
<p>python Decimal is very slow, one can use float or a faster implementation of Decimal cDecimal.</p>
23,703
<p>Is SQL case sensitive? I've used <a href="https://en.wikipedia.org/wiki/MySQL" rel="nofollow noreferrer">MySQL</a> and <a href="https://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="nofollow noreferrer">SQL Server</a> which both seem to be case insensitive. Is this always the case? Does the standard define cas...
<p>The SQL keywords are case insensitive (<code>SELECT</code>, <code>FROM</code>, <code>WHERE</code>, etc), but they are often written in all caps. However, in some setups, table and column names are case sensitive.</p> <p>MySQL has a configuration option to enable/disable it. Usually case sensitive table and column na...
<p><strong>Have the best of both worlds</strong></p> <p>These days you can just write all your SQL statements in lowercase and if you ever need to have it formatted then just install a plugin that will do it for you. This is only applicable if your code editor has those plug-ins available. <a href="https://en.wikiped...
18,596
<p>When I click on a row in my GridView, I want to go to a other page with the ID I get from the database. </p> <p>In my RowCreated event I have the following line:</p> <pre><code>e.Row.Attributes.Add( "onClick", ClientScript.GetPostBackClientHyperlink( this.grdSearchResults, "Select$" + e.Row.Row...
<p>I have the solution.</p> <p>This is what i have done:</p> <pre><code>if(e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes["onClick"] = "location.href='view.aspx?id=" + DataBinder.Eval(e.Row.DataItem, "id") + "'"; } </code></pre> <p>I have putted the preceding code in the RowDataBound event.</p>
<p>Can your ID be related to the data item displayed in the gridview?</p> <p>If so you can use e.Row.DataItem, and cast it to whatever type it is.</p>
42,904
<p>I'm looking for a script or application that tidies up and reformats SQL queries. I've found some good online SQL formatters (see <a href="http://www.wangz.net/gsqlparser/sqlpp/sqlformat.htm" rel="nofollow noreferrer">here</a>) , as well as some downloadable commercial applications. I'm cautious about using an onlin...
<p>Some things to try out (SQLinForm is free until 2009). It's weird how some niches totally lack good open source tools.</p> <p><a href="http://www.trialpay.com/checkout/?c=bb7014d&amp;tid=6rGUpGo" rel="nofollow noreferrer">http://www.trialpay.com/checkout/?c=bb7014d&amp;tid=6rGUpGo</a></p> <p><a href="http://www.sq...
<p>Red Gate SQL Refactor (trial) + a Virtual Machine</p>
27,160
<p>With text-recognition improving and CAPTCHA-breakers using Mechanical Turks to break otherwise unbreakable keys, what's the next technology to keep scripts from spam-botting a site that relies on user input?</p>
<p>I like the concept of an 'Invisible Captcha'. Phil Haack details one implementation <a href="http://haacked.com/archive/2006/09/26/Lightweight_Invisible_CAPTCHA_Validator_Control.aspx" rel="nofollow noreferrer">here</a>.</p> <p>This banks on the fact that bots, spiders, and crawlers don't implement javascript engi...
<p>The most fundamental tool to keep people from spambotting a user input site is the "nofollow" tag on links. Most comment-spammers are interested in Google juice rather than actually having their stuff seen, so nofollow removes the incentive. </p>
8,443
<p>is there any known pattern/algorithm on how to perform sorting or filtering a list of records (from database) in the correct way? My current attempt involves usage of a form that provides some filtering and sorting options, and then append these criteria and sorting algorithm to my existing SQL. However, I find it c...
<p>First off, this query will look and perform better if you use joins:</p> <pre><code>SELECT * FROM app_event._event_view EV INNER JOIN app_event.calendar C ON EV.calendar_id = C.calendar.id INNER JOIN app_event._ical_class IC ON C.class_id = EV.class_id WHERE C.is_persona...
<p>It's hard to understand that query, because I have to scroll massively and since I don't know the database...</p> <p>But if the privilegues are "one dimensional", e.g. admins can see everything, power users can see less than admins, guests can see less than power users, etc.: you could probably implement the privil...
37,692
<p>Is Structured Exception Handling bad? What is the right way to handle exceptions?</p> <p><strong>EDIT: Exception Handling in .NET using C#.</strong></p> <p>I usually have a set of specific exception classes (DivideByZeroException, ArrayTypeMismatchException) and don't have a generic "catch (Exception ex)".</p> <p...
<p>I'm not sure what you mean by 'structured exception handling'. </p> <p>The worst thing that can be done in exception handling is to 'swallow' the exception or handle it silently.</p> <p>Do NOT do this:</p> <pre><code>try { ... } catch (Exception e) { //TODO: handle this later } </code></pre> <p>This is ver...
<p>I'm not a Windows programmer, but it seems to me that using structured exception handling to treat hardware exceptions like software exceptions means that:</p> <ul> <li>Your code does something that in the C++ standard produces undefined or implementation-defined behaviour (such as dividing by zero).</li> <li>Windo...
45,964
<p>I'm trying to animate Visio objects with a loop, such as:</p> <pre><code>For reposition = 2 To 6 xpos = reposition ypos = reposition sh1.SetCenter xpos, ypos Sleep 1000 Next reposition </code></pre> <p>While this DOES move the object from the starting position to the ending, the intermediate ste...
<p>Try a <code>DoEvents</code> statement before your sleep</p>
<p>Make sure you have Application.Screenupdating set to true...I have a similar macro that animates a shape and I don't need to use DoEvents to update the screen...</p>
35,166
<p>When a getter returns a property, such as returning a <code>List</code> of other related objects, should that list and it's objects be immutable to prevent code outside of the class, changing the state of those objects, without the main parent object knowing?</p> <p>For example if a <code>Contact</code> object, has...
<p>It's a matter of whether you should be "defensive" in your code. If you're the (sole) user of your class and you trust yourself then by all means no need for immutability. However, if this code needs to work no matter what, or you don't trust your user, then make everything that is externalized immutable.</p> <p>Th...
<p>When I was starting out I was still heavily under the influence of HIDE YOUR DATA OO PRINCIPALS LOL. I would sit and ponder what would happen if somebody changed the state of one of the objects exposed by a property. Should I make them read only for external callers? Should I not expose them at all? </p> <p>Col...
13,952
<p>Is there a way to distinguish if a script was invoked from the command line or by the web server? </p> <p>(<strong>See <a href="https://stackoverflow.com/questions/173851/what-is-the-canonical-way-to-determine-commandline-vs-http-execution-of-a-php-s">What is the canonical way to determine commandline vs. http exec...
<p><strike>If called from command line, the server variable HTTP_USER_AGENT is not set. I use this constant to define, whether the script is called from command line or not:</p> <pre><code>define("CLI", !isset($_SERVER['HTTP_USER_AGENT'])); </code></pre> <p></strike></p> <p><strong>UPDATE:</strong> Since this answer...
<p>I've compared the <code>$_SERVER</code> superglobal in both invocations. It seems that <code>$_SERVER['argc']</code> (i.e. number of arguments passed to the script) is only set when running from shell/command line:</p> <pre><code>&lt;?php if (isset($_SERVER['argc'])) { define('CLI', true); } else { define('...
44,678
<p>I'm trying to read a Paradox 5 table into a dataset or simular data structure with the view to putting it into an SQL server 2005 table. I've trawled google and SO but with not much luck. I've tried ODBC:</p> <pre><code>public void ParadoxGet() { string ConnectionString = @"Driver={Microsoft Paradox Driver (*.d...
<p>I've had the same error. It appeared when I started my C# project on Win2008 64 (previos OS was Win2003 32). Also I found out that it worked fine in console apps and gave different errors in winforms. It seems that problem comes from the specifics of 32 ODBC driver working on 64-bit systems. My solution was:</p> <p...
<p>This isn't an answer, but more of a question: any particular reason you're trying to use C# to do the data manipulation as opposed to using SQL Server tools to load the data directly? Something like DTS or SSIS would seem like a better tool for the job.</p>
39,217
<p>I have some problems on a site with the concurrent access to a list. This list keeps a cart of items, and multiple deletes are crashing the site. <strong>Which is the best method to sync them?</strong> Is a lock enough? The lock option seems to be ugly because the code is spread all over the place and is pretty mes...
<p>So is this in-memory list shared between requests? That sounds like a potential cause of problems even when you've got locking. Mutable shared collections should generally be avoided, IME.</p> <p>Note that if you <em>do</em> decide to synchronize, you'll need to do things like locking the list for the whole course ...
<p>@Samuel That's exactly the point: You can NOT correct a problem like this just by modifying the existing class. Nevermind that the <code>class extends List&lt;T&gt;</code>, which in keeping with MS ways mostly avoids virtual methods (only where MS intends us to override do they make it virtual, which mostly makes se...
22,573
<p>how can I check at runtime home many parameters a method or a function have in PHP.</p> <p>example</p> <pre> class foo { function bar ( arg1, arg2 ){ ..... } } </pre> <p>I will need to know if there is a way to run something like</p> <pre> get_func_arg_number ( "foo", "bar" ) </pre> <p>and the result...
<p>You need to use <a href="http://php.net/oop5.reflection" rel="noreferrer">reflection</a> to do that.</p> <pre><code>$method = new ReflectionMethod('foo', 'bar'); $num = $method-&gt;getNumberOfParameters(); </code></pre>
<p>I believe you are looking for func_num_args()</p> <p><a href="http://us3.php.net/manual/en/function.func-num-args.php" rel="nofollow noreferrer">http://us3.php.net/manual/en/function.func-num-args.php</a></p>
45,120
<p>The standard way to load an image in a J2ME application is using the Image.createImage method and the recommended image format is PNG.</p> <p>Now, the J2ME specs dont lay down any restrictions on the implementation of this method or the in memory representation of an Image so, each vendor has a different implementa...
<p>One thing on Sony Ericsson. Don't give them so much credit. They take (image_width x image_height x bytes_per_pixel) of memory as well when loading images. </p> <p>From the SE J2ME developer doc, "<em>All images are stored in phone memory in a 16-bit per pixel RGB format, possibly with a 1-bit or 8-bit per pixel al...
<p>PNG's tend to be bloaty.</p> <p>Why not use gif instead.</p> <p><a href="http://www.ddj.com/mobile/184406435;jsessionid=SBUQN2ECITM5OQSNDLOSKHSCJUNN2JVN?_requestid=76071" rel="nofollow noreferrer">http://www.ddj.com/mobile/184406435;jsessionid=SBUQN2ECITM5OQSNDLOSKHSCJUNN2JVN?_requestid=76071</a></p>
33,236
<p>Is there any way to convert a bmp image to jpg/png without losing the quality in C#? Using Image class we can convert bmp to jpg but the quality of output image is very poor. Can we gain the quality level as good as an image converted to jpg using photoshop with highest quality?</p>
<pre><code>var qualityEncoder = Encoder.Quality; var quality = (long)&lt;desired quality&gt;; var ratio = new EncoderParameter(qualityEncoder, quality ); var codecParams = new EncoderParameters(1); codecParams.Param[0] = ratio; var jpegCodecInfo = &lt;one of the codec infos from ImageCodecInfo.GetImageEncoders() with m...
<p>You can try:</p> <pre><code>Bitmap.InterpolationMode = InterpolationMode.HighQualityBicubic; </code></pre> <p>and</p> <pre><code>Bitmap.CompositingQuality = CompositingQuality.HighQuality; </code></pre> <p>Which does keep the quality fairly high, but not the highest possible.</p>
6,303
<p>Here's an example:</p> <pre><code>&gt;git status # On branch master nothing to commit (working directory clean) &gt;git checkout -b test-branch &gt;vi test.c &gt;git add test.c &gt;git commit -m "modified test.c" &gt;vi README &gt;git add README &gt;git commit -m "modified README" </code></pre> <p>Now I want to do...
<p>Have you tried: <code>git rebase -i master</code>?</p>
<pre><code>git rebase -i --onto @{u}... @{u} </code></pre> <p>Interactive rebase starting from the single merge point of HEAD and its upstream including all commits in HEAD that are not in its upstream.</p> <p>In other words exactly what you want.</p>
47,507
<p>When compiling from source, I never know which configure flags to use to optimize the compilation for my environment. Assume the following hardware/OS:</p> <ul> <li>Single Core, 2 GHz Intel</li> <li>512MB Ram</li> <li>Debian 4</li> </ul> <p>I usually just go with </p> <p><code>./configure --prefix=/usr/local</cod...
<p>I always use Debian packages. Compiling from sources can break your development environment during libraries conflicts and such problems are hard to detect.</p>
<p>You might want to check those few options out, which may be required by a Ruby On Rails environment, in which case they should be compiled. Just make sure the directory corresponds to your current settings.</p> <p>--with-openssl-dir=/usr --with-readline-dir=/usr --with-zlib-dir=/usr</p>
4,354
<p>In one of my projects I need to build an ASP.NET page and some of the controls need to be created dynamically. These controls are added to the page by the code-behind class and they have some event-handlers added to them. Upon the PostBacks these event-handlers have a lot to do with what controls are then shown on t...
<p>I think that you have to provide the same ID for your buttons every time you add them like this for example (in first line of <code>AddButtonControl</code> method):</p> <pre><code>var button = new Button { Text = id , ID = id }; </code></pre> <hr> <p><strong>EDIT</strong> - My solution without using session:</p> ...
<p>AFAIK, creating of controls should not be placed in Page_Load but in Page_PreInit (ViewState and SessionState is loaded before Page_Load but after Page_PreInit).</p> <p>With your problem, I would suggest to debug the AddButtons function to find out what exactly (and when) is stored in Session["ClickedButton"]. Then...
31,816
<p>Let's say we have</p> <pre><code>public interface ITimestampProvider { DateTime GetTimestamp(); } </code></pre> <p>and a class which consumes it</p> <pre><code>public class Timestamped { private ITimestampProvider _timestampProvider public Timestamped(ITimestampProvider timestampProvider) { ...
<p>I think it depends on the scenario, and is basically a function of who the consumer the code is (library vs. application) and whether you're using an IoC container or not.</p> <ul> <li><p>If you're using an IoC container, and this is not part of a public API, then let the container do the heavy lifting, and just ha...
<p>I try to avoid this - there are a few places where I've found it to be a useful design but more often than not I've found it just leads to me making mistakes that can be a little puzzling to work out.</p> <p>The need for the default injected objects is greatly reduced by using a dependency injection container (I us...
38,485
<p>We disassembled everything in order to unclog the filament from the tube, but now I can't seem to get the nozzle to screw back in to the hotbed with the PTFE tube in place. Is there some kind of trick? I feel like if the tube were slightly smaller in diameter it would work. I'm using the same tube, just without the ...
<p>I was able to fix my problem so thought I'd post how I solved it for anyone else that is looking for a possible answer:</p> <p>I believe the actual problem was that there was filament hardened inside the nozzle which I couldn't see, so that prevented me from being able to push the PTFE tube into the nozzle deep eno...
<p>I got the same issue before. When you tried to push out the material from the tube, one end of the tube was being pressed. The tube was so soft that the diameter at that end was slightly increased. Hence it was difficult to put the tube back. When you tried to tighten the screw, more force applied and the tube end w...
1,529
<p>Specifically, I am looking to use CA on properties of types other than </p> <ul> <li>integers and doubles</li> <li>CGRect, CGPoint, CGSize, and CGAffineTransform structures</li> <li>CATransform3D data structures</li> <li>CGColor and CGImage references</li> </ul> <p>and in objects other than CALayers or NSViews</p>...
<p>If you can do the changes yourself and the class you use is custom, you might want to add a setProgress:(float) f method to your class and use CA to animate it, then modify the desired properties as needed as a function of f.</p> <p>Just do a</p> <pre><code>[[someObject animator] setValue:[NSNumber numberWithFloat...
<p>Well, it seems I cannot do that. What I should be doing is [subclassing NSAnimation](<a href="https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/AnimationGuide/Articles/TimingAnimations.html" rel="nofollow noreferrer">https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/...
6,986
<p>I received a WSDL file for a web service interface that our system should call somewhere in the future. </p> <p>Until then, I'd like to setup a dummy/mockup web service that does nothing else than to log the web service invocations and return dummy data.</p> <p>What I've done so far is to generate Java objects fro...
<p>We just faced this same problem, and found <a href="http://www.soapui.org/" rel="noreferrer">SoapUI</a> to be the perfect tool. Given a WSDL it'll create a service on your machine you can call, and it allows you to edit the response as you need.</p>
<p>You can use <a href="http://ws.apache.org/axis/java/user-guide.html#WSDL2JavaBuildingStubsSkeletonsAndDataTypesFromWSDL" rel="nofollow noreferrer">Apache Axis's wsdl2java</a> to generate skeleton classes from the WSDL:</p> <blockquote> <p>Just as a stub is the client side of a Web Service represented in Java, a skel...
26,053
<p>I've just written a small XBox 360 Wireless Controller managed interface that basically wraps around the low-lever <a href="http://slimdx.mdxinfo.com/wiki/index.php?title=Main_Page" rel="nofollow noreferrer">SlimDX</a> wrapper library and provides a easy, managed API for the XBOX 360 controller.</p> <p>Internally, ...
<p>Is a polling architecture the only option?</p> <p>In any case, personally I would restructure the system so that outside world can subscribe to events that is fired from the controller class.</p> <p>If you want the controller to fire the events on the right thread context, then I would add a property for a ISynchr...
<p>The 360 controller can only report it's current state. There is no other means to get the state without polling. Using System.Threading.Timer or opening up a new Thread that does Thread.Sleep() is really the same in my view, both of them fulfill the functionality of a UI-less timer class.</p> <p>Thanks for mentionin...
37,541
<p>I'm on .NET 2.0, running under Medium Trust (so <a href="http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx" rel="nofollow noreferrer">TimeZoneInfo</a> and the Registry are not allowed options). I'm asking the user for two dates and a time zone, and would really love to be able to automatically determ...
<p>In .NET 2.0 you have to code this yourself. It involves researching daylight savings time laws in various regions and building that into your own data structures. The problem is somewhat simplified if you only care about a subset of time zones, for example just in the USA, but if you need all global time zones, yo...
<p>Well, since <code>TimeZoneInfo</code> is excluded, you're probably not going to find a solution in the framework itself (but don't quote me on that).</p> <p>In which case, have you considered reflectoring the <code>TimeZoneInfo</code> class and using what you find there?</p>
6,657
<p>I have a string</p> <pre><code>var s:String = "This is a line \n This is another line."; this.txtHolder.text = s; //.text has \n, not a new line </code></pre> <p>and i want to put it into a text area, but the new line character is ignored. How can i ensure that the text breaks where i want it to when its assigned?...
<p>On flex, while coding <code>\n</code> is working well on <code>mxml</code> or any <code>xml</code> to define a line just use <code>&amp;amp;#13;</code> line entity.</p> <p>I mean:</p> <pre><code>lazy&amp;amp;#13;fox </code></pre> <p>gives us</p> <pre><code>lazy&lt;br /&gt; fox </code></pre>
<p>It should work or at the very least <strong>&lt; br \></strong> (without the spaces before the "br") should work if you are using htmlText.</p> <p>I was using XML to fill in the TextArea and since I'm not entirely sure how to use HTML inside of XML (they mention that I should wrap it with CDATA tags) but I just did...
40,644
<p>If you were to self-fund a software project which tools, frameworks, components would you employ to ensure maximum productivity for the dev team and that the "real" problem is being worked on.</p> <p>What I'm looking for are low friction tools which get the job done with a minimum of fuss. Tools I'd characterize as...
<ul> <li><strong>Versioning.</strong> <em>Subversion</em> is the popular choice. If you can afford it, <em>Team Foundation Server</em> offers some benefits. If you want to be super-modern, consider a distributed versioning system, such as <em>git</em>, <em>bazaar</em> or <em>Mercurial</em>. Whatever you do, don't use S...
<p>I'd definitely recommend Coderush+Refactor or Resharper (Coderush being my personal favourite), these tools dramatically reduce the time to go from code in your head to code on the page.</p> <p>For quick development the UI component sets from the likes of Telerik/DevExpress/Infragistics can be good, but in my exper...
8,633
<p>In a detailsview, how can I prepopulate one of the textboxes on the insertcommand (When the user clicks insert and the view is insert).</p> <p>I think this would work for codebehind:</p> <p>Dim txtBox As TextBox = FormView1.FindControl("txtbox")</p> <p>txtbox.Text = "Whatever I want"</p> <p>Is this right? What d...
<p>I would update the field in the DetailsView to a TemplateField: </p> <pre><code>&lt;asp:TemplateField&gt; &lt;InsertItemTemplate&gt; &lt;asp:TextBox ID="txtField" runat="server" Text='&lt;%# Bind("GUID") %&gt;'/&gt; &lt;/InsertItemTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="lblField" runat="s...
<p>I'm guessing you need to use one of detailsview events. Hook up to ItemCommand, ModeChanging or ModeChanged events and fill your value there.</p>
34,182
<p>When I download my program from my website to my windows 2003 machine, it has a block on it and you have to right click on the exe, then properties, then select the button "Unblock".</p> <p>I would like to add detection in my installer for when the file is blocked and hence doesn't have enough permissions. </p> <...
<p>This is done using NTFS File Streams. There is a stream named "Zone.Identifier" added to downloaded files. When IE7 downloads certain types of file that stream contains:</p> <pre><code>[ZoneTransfer] ZoneId=3 </code></pre> <p>The simplest way to set it is to create a text file with those contents in it, and use mo...
<p>Thanks for this it helped me a lot.</p> <p>You can make the process even easier if you create a batch file with the contents.</p> <pre><code>echo [ZoneTransfer] &gt; Zone.Identifier echo ZoneId=3 &gt;&gt; Zone.Identifier more Zone.Identifier &gt; %1:Zone.Identifier </code></pre> <p>This will generate the Zone.Ide...
16,420
<p>How does googlebot treat iframes? Does it follow the src attribute like a link? Is the iframe content analyzed as if it was part of the page where it is included?</p>
<blockquote> <p>IFrames are sometimes used to display content on web pages. <strong>Content displayed via iFrames may not be indexed</strong> and available to appear in Google's search results. We recommend that you avoid the use of iFrames to display content. If you do include iFrames, make sure to <strong>provide a...
<p>Anecdotal evidence suggests it treats it like a link (so you can end up with a page designed to be viewed inside the frame being loaded on its own via a link from a search engine).</p>
17,674
<p>I've never used the Global Temporary Tables however I have some questions how they will work in a php environment.</p> <p>How is data shared: Assuming persistent connections to oracle through php using oci8. Is the data tied to a database id? is it done based on the Apache httpd demons? Or is each individual requ...
<p>The global temporary table is simply the logical definition of a table structure (Name, column names, column data types etc). When a session references it by inserting data, a data segment is created in a temporary tablespace to hold only that session's data. Different sessions can therefore reference the same logic...
<p>If I remember correct, the data in global temporary tables is available only from one active session and only for this active session (I mean session = connection). So you can see only data which was inserted before in active session. Therefore I belive, this data is cleared after closing session. No matter which la...
14,974
<p>I'm having a problem running a VS 2005 app on some machines and not others. I looked up the error message on google and found a post by someone who had the same error and fixed it by uninstalling and reinstalling the .NET framework. When I try to do that, Windows won't let me because it is in use.</p> <p>Am I exp...
<p>Check out Aaron Stebner's <a href="https://web.archive.org/web/20160301085724/http://blogs.msdn.com:80/b/astebner/archive/2008/08/28/8904493.aspx" rel="nofollow noreferrer">.NET Framework Cleanup Tool</a>. Works quite nicely.</p>
<p>Boot into safe mode and uninstall the framework from add/remove programs.</p>
19,950
<p>We have a custom section in my app.config file related to our IoC container class. How can I get intellisense when editing the config file for this section, as well as getting rid of the compiler messages informing me of the missing schema.</p> <p>I found this question here: <a href="https://stackoverflow.com/quest...
<p>XML Intellisense will not automatically work for a custom configuration section. </p> <p>Visual Studio may report warnings on compilation complaining that the attributes of the custom configuration section are not defined. These warnings may be ignored. </p> <p>If you want XML IntelliSense support for a custom con...
<p>If you don't want to modify your DotNetConfig.xsd you could add the xsd configuration "inline".</p> <p>In your case add the following attributes to the custom section</p> <pre><code>&lt;ServiceContainers xmlns="your_xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="your_xmlns loc...
49,519
<p>In Windows for ASP, you can get it perfmon, but...</p> <p>How to get <strong>"requests per second"</strong> for Apache in Linux?</p>
<p>In realtime, or can you use <a href="http://www.cyberciti.biz/faq/apache-server-status/" rel="noreferrer">mod_status</a>?</p> <p>And apparently, there is a version of <a href="http://www.linuxhaxor.net/2008/01/15/real-time-display-of-apache-usage/" rel="noreferrer">top for apache</a>...</p>
<p>mod_status is the one! if you call it with:</p> <p>http://{ip}/server-status?refresh=1&amp;auto-refresh=true</p> <p>Then it auto refreshes every 2 seconds so you can see a constant realtime view :-)</p>
44,962
<p>I'm trying to read a value from a file and use it in a subsequent command.</p> <p>I have a file called <code>AppServer.pid</code> which contains the process id of my app server (just the number, it's not a properties file or anything like that).</p> <p>The app server is hanging, so I want to take this value and pa...
<p>This works:</p> <pre><code>SET /P VALUE_FROM_FILE= &lt; AppServer.pid taskkill /pid %VALUE_FROM_FILE% /f </code></pre> <p>The /P parameter used with SET allows you to set the value of a parameter using input from the user (or in this case, input from a file)</p>
<pre><code>for /f %%G in (appid.txt) do (SET PID=%%G) echo %PID% taskkill etc here... </code></pre> <p>This might help !</p>
38,179
<p>I would like to sort an array in ascending order using <code>C/C++</code>. The outcome is an array containing element indexes. Each index is corespondent to the element location in the sorted array.</p> <p><strong>Example</strong></p> <pre><code>Input: 1, 3, 4, 9, 6 Output: 1, 2, 3, 5, 4 </code></pre> <p><strong>Ed...
<p>Since you're using C++, I would do it something like this. The <code>SortIntPointers</code> function can be any sort algorithm, the important part is that it sorts the array of pointers based on the <code>int</code> that they are pointing to. Once that is done, you can go through the array of pointers and assign the...
<p>Well, there's a trival n^2 solution.</p> <p>In python:</p> <pre><code>newArray = sorted(oldArray) blankArray = [0] * len(oldArray) for i in xrange(len(newArray)): dex = oldArray.index(newArray[i]) blankArray[dex] = i </code></pre> <p>Depending on how large your list is, this may work. If your list is very lo...
3,441
<p>Does anyone know how to move the "Solution Explorer" tab in Visual Studio 2005? It's on the left, and I can't move it to the right.</p> <p>Thanks,</p> <p>Alan</p>
<p>Click on the title bar, and drag it to the right portion of the screen. Eventually you'll see a compas like structure popup. Make sure you hover over the right area and let go of the mouse button. That will bind it to the right side.</p>
<p>Go to View-> Appearance -> Move Side Bar Left</p>
41,666
<p>I've seen a lot of example c++ code that wraps function calls in a FAILED() function/method/macro. Could someone explain to me how this works? And if possible does anyone know a c# equivalent?</p>
<p>It generally checks COM function errors. But checking any function that returns a <code>HRESULT</code> is what it's meant for, specifically. <code>FAILED</code> returns a true value if the <code>HRESULT</code> value is negative, which means that the function failed ("error" or "warning" severity). Both <code>S_OK</c...
<blockquote> <p>And if possible does anyone know a c# equivalent?</p> </blockquote> <p>You won't actually need that in C#, unless you're using COM objects. Most .NET functions either already return a (more or less) meaningful value (i.e. null, false) or throw an exception when they fail.</p> <p>If you're directly a...
49,410
<p>In OS X, in order to quickly get at menu items from the keyboard, I want to be able to type a key combination, have it run a script, and have the script focus the Search field in the Help menu. It should work just like the key combination for Spotlight, so if I run it again, it should dismiss the menu. I can run t...
<p>Here is the script I came up with.</p> <pre><code>tell application "System Events" tell (first process whose frontmost is true) click menu "Help" of menu bar 1 end tell end tell </code></pre>
<p>Here is the script I came up with.</p> <pre><code>tell application "System Events" tell (first process whose frontmost is true) click menu "Help" of menu bar 1 end tell end tell </code></pre>
9,477
<p>I have a bunch of objects in my application (Organisations, Individuals, Orders, etC) and I need a nice clean way to decide which users can and can't view/edit these objects. User have a range of permissions such as 'Can edit own contacts' and 'Can view team's contacts' and can also be members of groups such as 'Acc...
<p>Check out <a href="http://www.securitypatterns.org/patterns.html" rel="nofollow noreferrer">Security Patterns</a>, especially in the areas about authentication and authorization. </p>
<p>Google for the term entitlements management and XACML. This will get you pointed in a better direction.</p>
38,755
<p>s it possible to do the following in subsonic.</p> <p>SELECT * FROM TABLE1</p> <p>WHERE Column1 > Column2 or Column1 &lt; Colum3</p> <p>All examples that I've seen assume you now a value to pass to the where clause. I'm trying to do this without creating a view.</p> <p>Thanks</p>
<p>If it's in our stack I can't find it :). It would be a good thing to add though :). You can, for now, use an Inline query to simply execute the statement you wrote (it takes straight SQL). I know it's fugly but...</p> <p>Rick - if you did get that to work I'd be interested in how. "Col2" will try and be parsed to a...
<p>Yes it is.</p> <pre><code>Dim TableList As Generic.List(Of Database.Table1) = _ New SubSonic.Select().From("Table1"). _ Where("Col1").IsGreaterThan("Col2"). _ Or("Col1").IsLessThan("Col3").ExecuteTypedList(Of Database.Table1)() </code></pre>
30,292
<p>I have a WordPress site (2.6.2) in which I have set the Home page to a static page instead of the normal posts page. The ID of this page is 2, so in the WordPress template I have changed the <code>wp_list_pages</code> to look like this:</p> <pre><code>&lt;?php wp_list_pages('exclude=2&amp;title_li=&amp;depth=1' ); ...
<p>Setting a static page as the front page doens't highlight the menu link, which is at the heart of the question.</p> <p>So, you could server-side customize (hack) the wp_list_pages function, but here's a client-side option if you so choose:</p> <p>Use the jQuery library (conveniently it comes with WP 2.2+), call:</...
<p>You can set a static page as the front page in the Administration > Settings > Reading panel after logging in as the administrator.</p> <p>The Wordpress manual entry on this subject can be found <a href="http://codex.wordpress.org/Creating_a_Static_Front_Page" rel="nofollow noreferrer">here</a>.</p>
27,066
<pre><code>select Table1.colID, Table1.colName, (select * from Table2 where Table2.colID = Table1.colID) as NestedRows from Table1 </code></pre> <p>The above query gives you this error: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, &lt;, &lt;= , >, >= or when the subquery...
<p>Because the subquery in a select clause must be "inserted" into a column value in every row of the result set from the outer query. You cannot put a set of values into a single cell (a single column of a single row) of the result set. </p> <p>You need to use an inner join. the multiple rows returned by joined tab...
<p>You would be better off using an INNER JOIN between the two tables and simply selecting the rows you want from each table.</p> <pre><code>SELECT tab1.colID, tab1.colName, tab2.Column1, tab2.column2 FROM dbo.Table1 AS tab1 INNER JOIN dbo.Table2 AS tab2 ON tab1.colID = tab2.colID </code></pre> <p>However...
48,557
<p>For my programming class I have to write a linked list class. One of the functions we have to include is next(). This function would return the memory address of the next element in the list.</p> <pre><code>#include &lt;iostream&gt; using namespace std; class Set { private: int num; Set *nextva...
<p><code>Set*</code> is correct. You are suffering from a rather silly bug in this function:</p> <pre><code>Set* Set::next() { Set *current; current = this; return current-&gt;next; } </code></pre> <p>The last line should be <code>return current-&gt;nextval</code>. Otherwise you are trying to return a p...
<p>luqui is correct, although your <strong>next</strong> function is overly complex, there's no reason to copy the <em>this</em> pointer, that's just silly. Use this instead:</p> <pre><code>Set* Set::next() { return nextval; } </code></pre>
40,247
<p>I have the following C# which simply replaces parts of the input string that look like EQUIP:19d005 into URLs, like this:</p> <pre><code>input = Regex.Replace(input, @"(EQUIP:)(\S+)", @"&lt;a title=""View equipment item $2"" href=""/EquipmentDisplay.asp?eqnum=$2""&gt;$1$2&lt;/a&gt;", RegexOptions.IgnoreCase); </cod...
<p>OK, 2 solutions, one inline:</p> <pre><code>input = Regex.Replace(input, @"(EQUIP:)(\S+)", m =&gt; string.Format(@"&lt;a title=""View equipment item {1}"" href=""/EquipmentDisplay.asp?eqnum={2}""&gt;{0}{1}&lt;/a&gt;", m.Groups[1].Value, m.Groups[2].Value, m.Groups[2].Value.ToUpper()), RegexOptions.IgnoreCase); </co...
<p>Assuming that input is a string:</p> <p><code>input = Regex.Replace(input.ToUpper, @"(EQUIP:)(\S+)", @"&lt;a title=""View equipment item $2"" href=""/EquipmentDisplay.asp?eqnum=$2""&gt;$1$2&lt;/a&gt;", RegexOptions.IgnoreCase);</code></p> <p>Changing the case of a string isn't something regex does.</p>
25,163
<p>how do I bind a <code>std::ostream</code> to either <code>std::cout</code> or to an <code>std::ofstream</code> object, depending on a certain program condition? Although this invalid for many reasons, I would like to achieve something that is semantically equivalent to the following:</p> <pre><code>std::ostream out...
<pre><code>std::streambuf * buf; std::ofstream of; if(!condition) { of.open("file.txt"); buf = of.rdbuf(); } else { buf = std::cout.rdbuf(); } std::ostream out(buf); </code></pre> <p>That associates the underlying streambuf of either cout or the output file stream to out. After that you can write to "out...
<p>Being a novice to C++, I don't know if this is exception-safe, but here's how I usually do it:</p> <pre><code>std::ostream&amp; output = (condition)?*(new std::ofstream(filename)):std::cout; </code></pre>
47,897
<p>When sending data over HTTPS, I know the content is encrypted, however I hear mixed answers about whether the headers are encrypted, or how much of the header is encrypted.</p> <p>How much of HTTPS headers <em>are</em> encrypted?</p> <p>Including GET/POST request URLs, Cookies, etc.</p>
<p>All the HTTP headers are encrypted<sup>†</sup>. That's why SSL on vhosts doesn't work too well - you need a dedicated IP address because the Host header is encrypted.</p> <p><sup>†</sup>The Server Name Identification (SNI) standard means that the hostname may not be encrypted if you're using TLS. Also, whether you'r...
<p>To understand, what is encrypted and what not, you need to know that SSL/TLS is the layer between the transport-layer and the application-layer.</p> <p>in the case of HTTPS, HTTP is the application-layer, and TCP the transport-layer. That means, all Headers below the SSL-Level are unencrypted. Also, SSL itself may e...
22,739
<p>I wonder what are the main challenges to porting those emulator engines. </p> <p>Could there been any sucess without having to rewrite all the code? Any conversion tools available that can help? </p>
<p>Some people have tried but it seems they <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1011253&amp;SiteID=1" rel="nofollow noreferrer">gave up</a>:</p> <p><a href="http://sourceforge.net/projects/scummvmxna/" rel="nofollow noreferrer">scummvmxna</a></p> <p>Other route could be the approach taken b...
<p>There is some people over at XDA developers that is making a DLL wrapper for C#.Net/XNA/Silverlight... The DllImport Project: <a href="http://forum.xda-developers.com/showthread.php?t=1006331" rel="nofollow">http://forum.xda-developers.com/showthread.php?t=1006331</a></p> <p>As I understand it this is for wrapping ...
37,457
<p>At my current job I've been working on making web apps with Java, Tapestry, Hibernate, MSSQL, and Tomcat.</p> <p>I've got an idea for a little web game I'd like to write. I'd like to know what the SO community would use for something like this.</p> <p>Should I stick to what I know? I was thinking it would be very ...
<p>If its a personal project then take this as an opportunity to learn something new.</p>
<p>If your thinking about an online game like a RPG or card game I might be selfish and suggest you have a look at <a href="http://www.projectdarkstar.org" rel="nofollow noreferrer">Project Darkstar</a> and let us know how you got on. I've been trying to get started with it and cannot get it up running in my environmen...
49,704
<p>I am thinking about providing a version of say, the database schema and the <code>dlls</code> for business logic in the footer of my web application.</p> <p>Is this advised?</p> <p>Are there any pitfalls, or pointers of how to do this best?</p> <p>Usability concerns?</p> <p><strong>I already have a version schem...
<p>I quite like what is done e.g. <a href="http://episteme.arstechnica.com/" rel="noreferrer">here</a>. If you look towards the bottom of the page, there's a piece of text "powered by eve community". If you click that text you get a small chunk of technical information.</p> <p>To me, this is a nice tradeoff between ...
<p>IMO, the only reasons to show version numbers are:</p> <ul> <li>To show progress is being made</li> <li>To help bug reports be localized to the version they were discovered in</li> </ul> <p>So if these things are important for your bug reports, then expose them. If not, then don't.</p>
4,439
<p>I'm trying to load a page that is basically an edit form inside a dialog (ui.dialog). I can load this page fine from an external (I'm using asp.net) page.</p> <p>The problem is that inside of my "popup" form, I need to <code>$(function() {my function here});</code> syntax to do some stuff when the page loads, alon...
<p>If you really need to load that form via AJAX you could to do all the Javascript stuff in $.ajax callback itself. So, you load the popup form like this:</p> <pre><code>$.ajax({ //... success: function(text) { // insert text into container // the code from $(function() {}); } }); </code></pre...
<p>The script isn't getting run because the document's ready event has already been fired. Remove your code from within the </p> <pre><code>$() </code></pre>
8,988
<p>Of all the forms of CAPTCHA available, which one is the "least crackable" while remaining fairly human readable?</p>
<p>I agree with Thomas. Captcha is on its way out. But if you must use it, <a href="http://www.recaptcha.net" rel="noreferrer">reCAPTCHA</a> is a pretty good provider with a simple API.</p>
<p>As far as I know, the Google's one is the best that there is. It hasn't been broken by computer programs yet. What I know that the crackers have been doing is to copy the image and then send it to many phishing websites where humans solve them to enter those websites.</p>
8,421
<p>I'm inserting something in the cache when the user does a login. </p> <p>Now I want to delete that from the cache when the user's session expires. HttpContext is null .. so I don't know for which user the session expired. How can I go about finding this ?</p> <p><strong>EDIT:</strong> unfortunately SessionID doesn...
<p>Instead of creating Excel or HTML files on Oracle server, you can fetch Oracle data to existing Excel document via ODBC or OLEDB. The shortcoming is, that you should be careful with user permissions.</p> <p><a href="https://www.youtube.com/watch?v=Adz0zZFePf8" rel="nofollow noreferrer">https://www.youtube.com/watc...
<p>You could save a (small) Excel sheet as html in Excel, and then reproduce that format.</p>
38,239
<p>I have an MFC application that uses several MFC extension DLL's. I want this app (and several other similar apps) to be able to access some parts of the .net framework. I wrote a C# library to do the .net work I want and was hoping to be able to write an MFC dll to hide all the C++/CLI code from my apps. The apps wo...
<p>You can't reference managed assemblies from pure native code. You have to either flip the /clr switch on the consumer (either project-wide or in certain files,) or do some interop.</p> <p>One interop option that will allow your consumer to say pure native is calling into the managed assembly via <a href="http://msd...
<p>The MFC dll project references the C# library and has one file compiled with /clr that handles the interface into my C# library. I have actually seen this work sometimes at run time but have never been able to debug into the MFC dll or into the C# code. However it doesn't seem to be at all stable and crashes in the ...
27,396
<p>I have the following code:</p> <pre><code>MemoryStream foo(){ MemoryStream ms = new MemoryStream(); // write stuff to ms return ms; } void bar(){ MemoryStream ms2 = foo(); // do stuff with ms2 return; } </code></pre> <p>Is there any chance that the MemoryStream that I've allocated will som...
<p>You won't leak anything - at least in the current implementation.</p> <p>Calling Dispose won't clean up the memory used by MemoryStream any faster. It <em>will</em> stop your stream from being viable for Read/Write calls after the call, which may or may not be useful to you.</p> <p>If you're absolutely sure that y...
<p>I'm no .net expert, but perhaps the problem here is resources, namely the file handle, and not memory. I guess the garbage collector will eventually free the stream, and close the handle, but I think it would always be best practice to close it explicitly, to make sure you flush out the contents to disk.</p>
28,971
<p>I need to 3D print several composites. The constituent materials are photopolymer resins. The composites are very similar to a Rubik's cube. Considering it that way, each voxel (every small piece of the Rubik's cube) is either entirely printed by material A or B.</p> <p>I have the binary files ready for the parts. M...
<p>It appears that your question is directed to solving the problem of converting your file of parameters to a 3D printable form. I'm far from an OpenSCAD wizard, but I suspect that your parameters file could be read into a properly coded OpenSCAD document to create the necessary STL to be printed.</p> <p>Your referenc...
<p>Stratasys industrial machines generally use proprietary software to prepare the print files for printing and don't use common slicers like Ultimaker Cura or Prusa-slicer.</p> <p>The software that is suggested by the manufacturer for both arranging and preparing prints on their machines of the Objet type is <a href="...
2,087
<p>A class I am taking currently requires us to do all of our coding in smalltalk (it's a Design class). On one of our projects, I am looking to do some things, and am having a tough time finding how to do them. It seems that what most people do is modify their own version of smalltalk to do what they need it to do. I ...
<p>The problem is that</p> <pre><code> (expr) and: (expr) ifTrue: aBlock </code></pre> <p>is parsed as the method <code>and:ifTrue:</code> If you look at the Boolean class (and either True or False in particular), you notice that ifTrue: is just a regular method, and that no method and:ifTrue: exists - however, plai...
<p><strong>To create several random integers between 1 and 1000</strong><br> First create a random number series. Do this just once.</p> <p>Then create a new random number by taking the next number from the series. Repeat as necessary.</p> <pre><code>aRandomSeries := Random new . "Seed a new series of random n...
34,130
<p>I have a website setup in IIS 6, let's say it's called <strong><a href="http://www.this.com" rel="nofollow noreferrer">http://www.this.com</a></strong>.</p> <p>I have setup a redirection for this website to <strong><a href="http://www.that.com" rel="nofollow noreferrer">http://www.that.com</a></strong> which mainta...
<p>You could implement a custom error page for the <code>page not found</code> error (404) that does the redirection for you. You'd turn off the redirection in IIS. Build the logic for the redirection in your custom error page. Then configure your web site so that 404 errors redirect to your error page.</p>
<p>If you can install software on your IIS server, I'd recommend using a tool to rewrite your request URLs.</p> <p>For IIS 6.0 I've used <a href="http://www.isapirewrite.com/" rel="nofollow noreferrer">ISAPI_Rewrite</a> and it works really well. It's lightweight and very configurable. There's a "Lite" version availabl...
46,394
<p>I have a c# winforms program and it opens up a serial port. The problem happens when the end user unplugs the usb cable and then the device disappears. After this the program will crash and want to report the error to microsoft. </p> <p>Is there a way to capture this event and shut down gracefully? </p>
<p>You can use WMI (Windows Management Instrumentation) to receive notification on USB events. I did exactly that two years ago, monitoring for plugging and unplugging of a specific usb device.<br> Unfortunately, the code stays with my former employer, but I found one example at <a href="http://bytes.com/topic/net/answ...
<p>If your try statement isn't catching the exception then let's hope Microsoft will inspect the dumps.</p> <p>There are some SetupDi APIs (I think ... it's been a while) that permit you to be advised of device arrivals and removals, but it won't help if you already crashed because the removed device was in the middle...
36,361
<p>What steps I need to perform in order to convert asp.net 2 application from IIS7 classic to integrated mode?</p>
<p>Here is a process: <a href="http://www.west-wind.com/WebLog/posts/6075.aspx" rel="noreferrer">Rick Strahl's blog</a></p>
<p>Nothing really. ASP.NET 2.0 applications will run just as they have in IIS 6.0. If you want to take advantage of any of the new features then you just need to update your code. But unless you are changing the structure of the header of the response or intercepting requests for other applications you probably will...
3,193
<p>What is the best way to store instances of a class to file/database?</p> <p>We have a base class called Command and loads of derived classes. Users create instances of these classes by adding commands to a graphical designer where they can configure them. (Set the properties).</p> <p>We then need a way to store th...
<p>serialization does the trick! Serialization is nothing more than converting an object or a connected graph of objects into a stream of bytes (in order to persist the current state of the object). This can be a binary stream, XML or whatever. You don't have to do this conversion by your own since .Net has great suppo...
<p>Pretty blurry question, why don't you just use .NET's built-in serialization possibilities (e.g. XmlSerializer).</p>
46,367
<p>We have a PHP project that we would like to version control. Right now there are three of us working on a development version of the project which resides in an external folder to which all of our Eclipse IDEs are linked, and thus no version control.</p> <p>What is the right way and the best way to version control ...
<p>We were in a similar situation, and here's what we ended up doing:</p> <ul> <li>Set up two branches -- the release and development branch.</li> <li>For the development branch, include a post-commit hook that deploys the repository to the dev server, so you can test.</li> <li>Once you're ready, you merge your change...
<p>Each of you could run it locally, or on your own dev server (or even the same one with a different port...).</p>
2,694
<p>I am evaluating VintaSoft .net control and Atalasoft DotTwain Image Capture. And I am very but very lost with the most of the definitions and keywords.</p> <p>So I am asking this because I think I am in Lala land. Is it possible to listen or have the scanner tell my app that there is a scanned image and I can proce...
<p>I have only worked with the native interfaces to TWAIN and WIA, so I can't vouch for these other layers on top of them. However, with regards to TWAIN, some mechanisms do exist that allow an application to be notified to capture data. I believe this is handled with STI.dll, an older library that is available on Wind...
<p>It is possible to have the scanner tell your app that there is a scanned image. I am not familiar with VintaSoft .net control and Atalasoft DotTwain Image Capture, but with some twain sdks, there is OnPostTransfer/OnPostAllTransfer event which is triggered after each scanning so that you can "notify" your winservice...
33,006
<p>I have a folder full of files i need to post to a webservice using cURL but i'm not sure on the whole variables and iterations in batch files thing.</p> <p>I know the syntax for curl should be </p> <pre><code>c:\curl\bin\curl -X POST -F File=@[filename] -F "title=[title]" -F "notes=[notes]" "http://xxx/AddScannedI...
<p>You should try with the <code>-g</code> aka <code>--globoff</code> cURL option.</p> <p>The default behavior is to :</p> <blockquote> <p>You can specify multiple URLs or parts of URLs by writing part sets within braces as in:</p> <pre><code>http://site.{one,two,three}.com </code></pre> <p>or you can g...
<p>You should try with the <code>-g</code> aka <code>--globoff</code> cURL option.</p> <p>The default behavior is to :</p> <blockquote> <p>You can specify multiple URLs or parts of URLs by writing part sets within braces as in:</p> <pre><code>http://site.{one,two,three}.com </code></pre> <p>or you can g...
48,979
<p>I've recently purchased an Ender 3 and have had great success with some Cura settings found on a YouTube Tutorial at 0.2 mm resolution.</p> <p>So then I noticed that there were default settings in Cura for the Ender 3. Except printing at 0.2 mm it selects a 20 % infill, and when choosing 0.1 mm it changed the infill...
<p>The more infill, the more material. The more material, the more stress is inside the part while it cools down from printing temperature to ambient temperature. Parts with higher infill density tend to warp more (the edges curl up).</p> <p>But 20 % should be fine, you shouldn't have any issue at that percentage (unle...
<p>Basically you have 2 issues, first, an adhesion in combination with layer thickness problem, second, an infill problem.</p> <p>Starting with the infill issue, when you lower the layer height, without increasing the amount of layers for the &quot;Top/Bottom Thickness&quot;, you get a very thin shell (unless the top b...
1,110
<p>Basically, we have a rule setup to run a script when a code word is detected in the body of an incoming message. The script will append the current subject header with a word in front. For example, Before: "Test Message", After: "Dept - Test Message". Any ideas?</p>
<p>Or if you need an entire script:</p> <p>Do the Run a script with the MailItem as the parameter.</p> <pre><code>Sub RewriteSubject(MyMail As MailItem) Dim mailId As String Dim outlookNS As Outlook.NameSpace Dim myMailItem As Outlook.MailItem mailId = MyMail.EntryID Set outlookNS = Application....
<p>Not tested:</p> <pre><code>mailItem.Subject = "Dept - " &amp; mailItem.Subject mailItem.Save </code></pre>
12,116
<p>How do you manage deploying InfoPath forms to different sharepoint servers? Is there a better way to deal all the data connections being site-specific without opening the forms, editing the data connections and republishing for each environment?</p>
<p>If I understand your scenario correctly:</p> <p>You have an InfoPath form, with data connections that submit your data. You wish to deploy this form on multiple SharePoint Servers and have those data connections submit data to the currently deployed server.</p> <p>You can't really get around needing to do work on ...
<p>By site-specific, do you mean that the data connections in your forms refer to the server the form is deployed to? If that's the case perhaps you could tweak your connections to use localhost instead of the server name for the hostname part of the data connection URLs.</p>
4,076
<p>I am writing an application with a hand-crafted domain model (classes) and a hand-crafted data model (tables/relationships), and letting NHibernate take care of the mapping.</p> <p>Is it best to tell the database to perform cascading updates or deletes or to tell NHibernate to do it (cascade="all-delete-orphan")? C...
<p>I prefer to let NHibernate do this for me. It's easier to setup and it works well.</p> <p>cascade: all-delete-orphan is something that you wouldn't be able to do in SQL without a trigger, so there's another reason</p>
<blockquote> <p>Can they both be set up to do it at the same time?</p> </blockquote> <p>I think if you try, you might get NHibernate complaining, as most of it's operations check the row count to ensure that the expect number of rows were inserted/updated/deleted.</p> <p>As Ben says, get NHibernate to do it. </p> ...
20,134
<p>I just came across the proposed <a href="http://web.archive.org/web/20171008232044/http://dancinghacker.com:80/code/dataflow/dataflow/introduction/dataflow.html" rel="nofollow noreferrer">Boost::Dataflow</a> library. It seems like an interesting approach and I was wondering if there are other such alternative frame...
<p><strong>Wikipedia</strong></p> <p>There are a couple of good articles in the Wikipedia about the theory of the dataflow programming:</p> <ul> <li><a href="http://en.wikipedia.org/wiki/Dataflow" rel="nofollow noreferrer">Dataflow</a></li> <li><a href="http://en.wikipedia.org/wiki/Dataflow_programming" rel="nofollow...
<p>If your area is sound generation/processing, use <a href="http://www.synthedit.com/" rel="nofollow noreferrer">http://www.synthedit.com/</a> </p> <p>It looks promising, I've found a good answers for a deep problem in the SDK docs (polyphony). Funny, but they don't mention the word <em>dataflow</em>.</p>
9,753
<p>Can someone post a simple example of starting two (Object Oriented) threads in C++. </p> <p>I'm looking for actual C++ thread objects that I can extend run methods on (or something similar) as opposed to calling a C-style thread library.</p> <p>I left out any OS specific requests in the hopes that whoever replied ...
<p>Create a function that you want the thread to execute, for example:</p> <pre><code>void task1(std::string msg) { std::cout &lt;&lt; &quot;task1 says: &quot; &lt;&lt; msg; } </code></pre> <p>Now create the <code>thread</code> object that will ultimately invoke the function above like so:</p> <pre><code>std::threa...
<p>It largely depends on the library you decide to use. For instance, if you use the <a href="https://en.wikipedia.org/wiki/WxWidgets" rel="nofollow noreferrer">wxWidgets</a> library, the creation of a thread would look like this:</p> <pre><code>class RThread : public wxThread { public: RThread() : wxThrea...
33,371
<p>I have a lot of classes in the App_Code directory could this be a problem? Would it build faster if it was in a separate library?</p> <p>Any other tips?</p>
<p>There's a decent article <a href="http://weblogs.asp.net/bradleyb/archive/2005/12/06/432441.aspx" rel="nofollow noreferrer">here</a>. Items listed there are:</p> <ul> <li>Do not disable batch compilation</li> <li>Leverage Server-side Compilation</li> <li>Move App_Code files into a separate class library project</li>...
<p>I would recommend a second project, let's say "MyLibrary", instead of having a bloated App_Code folder.</p>
21,429
<p>How can I match (PCRE) everything inbetween two tags?</p> <p>I tried something like this:</p> <blockquote> <p>&lt;!--\s&#42;LoginStart\s&#42;--&gt;(.*)&lt;!--\s&#42;LoginEnd\s&#42;--&gt;</p> </blockquote> <p>But it didn't work out too well for me..</p> <p>I'm kind of new to regular expressions, so I was hoping...
<pre><code>$string = '&lt;!-- LoginStart --&gt;&lt;div id="stuff"&gt;text&lt;/div&gt;&lt;!-- LoginEnds --&gt;'; $regex = '#&lt;!--\s*LoginStart\s*--&gt;(.*?)&lt;!--\s*LoginEnds\s*--&gt;#s'; preg_match($regex, $string, $matches); print_r($matches); // $matches[1] = &lt;div id="stuff"&gt;text&lt;/div&gt; </code></pre> ...
<p>i have tried Owen's answer but its fails for the conditions like</p> <p><code>&lt;!-- LoginStart --&gt;&lt;div id="stuff"&gt;text&lt;/div&gt;&lt;!-- LoginEnds --&gt;<b>"DONT MIND THIS"</b>&lt;!-- LoginStart --&gt;&lt;div id="stuff"&gt;text&lt;/div&gt;&lt;!-- LoginEnds --&gt;</code></p> <p>This includes the line "D...
36,644
<p>For data types such as std::set and std::map where lookup occurs in logarithmic time, is the implementation required to maintain the begin and end iterators? Does accessing begin and end imply a lookup that could occur in logarithmic time?</p> <p>I have always assumed that begin and end always occur in constant tim...
<p>They happen in constant time. I'm looking at page 466 of the ISO/IEC 14882:2003 standard:</p> <p><strong>Table 65 - Container Requiments</strong></p> <p>a.begin(); <em>(constant complexity)</em></p> <p>a.end(); <em>(constant complexity)</em></p> <p><strong>Table 66 - Reversible Container Requirements</str...
<p>For std::set</p> <p>begin: constant, end: constant, rbegin: constant, rend: constant, </p> <p>For std::map</p> <p>they are also constant (all of them)</p> <p>if you have any doubt, just check <a href="http://www.cplusplus.com" rel="nofollow noreferrer">www.cplusplus.com</a></p>
10,920
<p>I'm looking for a free templating engine to generate simple reports. I want some basic features such as :</p> <ul> <li>Ability to Write Loops (with any IEnumerable)</li> <li>Passing Variables</li> <li>Passing Templates Files (main template, footer, header)</li> </ul> <p>I'll use this to generate reports in HTML an...
<p>I second not recommending nVelocity. It is a horrible port.</p> <p>.NET actually has built in templating abilities by using CodeDOM.</p> <p>Here is a pretty good walkthrough of how to do it:</p> <p><a href="http://www.codeproject.com/KB/cs/smarttemplateengine.aspx" rel="nofollow noreferrer">http://www.codeproject...
<p>Thanks for the help, CodeDOM specifically showed me a nice way, now I'm working with this : <a href="http://www.stefansarstedt.com/templatemaschine.html" rel="nofollow noreferrer">http://www.stefansarstedt.com/templatemaschine.html</a></p> <p>It's not the best and a bit dirty but doing the trick for me. It's LGPL ...
45,080
<p>Currently I have this (edited after reading advice):</p> <pre><code>struct Pair&lt;T, K&gt; : IEqualityComparer&lt;Pair&lt;T, K&gt;&gt; { readonly private T _first; readonly private K _second; public Pair(T first, K second) { _first = first; _second = second; } public T Fi...
<p>It looks like you need IEquatable instead:</p> <pre><code>internal struct Pair&lt;T, K&gt; : IEquatable&lt;Pair&lt;T, K&gt;&gt; { private readonly T _first; private readonly K _second; public Pair(T first, K second) { _first = first; _second = second; } public T First { get { return _fir...
<p>Regarding the warning, you can use default(T) and default(K) instead of null.</p> <p>I can't see what you're trying to achieve, but you shouldn't be using the hashcode to compare for equality - there is no guarantee that two different objects won't have the same hashcode. Also even though your struct is immutable,...
14,688
<p>Is there any way in the Servlet API to access properties specified in web.xml (such as initialization parameters) from within a Bean or Factory class that is not associated at all with the web container?</p> <p>For example, I'm writing a Factory class, and I'd like to include some logic within the Factory to check ...
<p>One way you could do this is:</p> <pre><code>public class FactoryInitialisingServletContextListener implements ServletContextListener { public void contextDestroyed(ServletContextEvent event) { } public void contextInitialized(ServletContextEvent event) { Properties properties = new Properties...
<p>I think that you will have to add an associated bootstrap class which takes a reference to a ServletConfig (or ServletContext) and transcribes those values to the Factory class. At least this way you can package it separately.</p> <p>@toolkit : Excellent, most humbled - This is something that I have been trying to ...
6,302
<p>I'm having an issue setting up one of my projects in TeamCity (v4.0), specifically when it comes to using Object Initializers.</p> <p>The project builds fine normally, however it would seem that TeamCity transforms the build file into something it likes (some MSBuild mutation) and when it comes to compiling the cod...
<p>Are you using the sln2005 build runner? That will use the 2.0 csc. Check your build configuration and change it to the sln2008 runner ( see <a href="http://www.jetbrains.net/confluence/display/TCD4/3.Build+Runners" rel="nofollow noreferrer">http://www.jetbrains.net/confluence/display/TCD4/3.Build+Runners</a> ). That...
<p>For NAnt script one may simply define system property teamcity_dotnet_use_msbuild_v35 in the build configuration settings ( <a href="http://www.jetbrains.net/confluence/display/TCD4/6.Properties+and+environment+variables" rel="nofollow noreferrer">http://www.jetbrains.net/confluence/display/TCD4/6.Properties+and+env...
48,832
<p>In WPF, how would I apply multiple styles to a <code>FrameworkElement</code>? For instance, I have a control which already has a style. I also have a separate style which I would like to add to it without blowing away the first one. The styles have different TargetTypes, so I can't just extend one with the other....
<p><strong>I think the simple answer is that you can't do (at least in this version of WPF) what you are trying to do.</strong></p> <p><em>That is, for any particular element only one Style can be applied.</em></p> <p>However, as others have stated above, maybe you can use <code>BasedOn</code> to help you out. Check ...
<p><strong>If you are trying to apply a unique style to just one single element</strong> as an addition to a base style, there is a completely different way to do this that is IMHO much better for readable and maintainable code.</p> <p>It's extremely common to need to tweak parameters per individual element. Defining ...
3,680
<p>Virtualizing the mobile is way different from virtualizing the server or the desktop, where in the the hardware components are almost standardized [like the keyboard, mouse , usb, LAN etc] so the hardware could be easily abstracted for any of the OS.</p> <p>While on a mobile there is a multitude of hardware [like t...
<p>Not everyone can afford to supply their testers/developers with full-blown mobiles. That's when virtualization comes into game as nearly everyone today has a computer capable of running some kind of VM.</p>
<p>There's also the twin drives of:</p> <ul> <li>It's useful for cases like S60 and Windows mobile where there isn't the gulf between hardware (or perhaps virtualise your android mobile so you can use WM until android stops being shaky and having huge root exploits :))</li> <li>Because they can</li> </ul> <p>I'm inte...
38,132
<p>To add a svg graphics in html page, it is common to use object tag to wrap it like this:</p> <pre><code>&lt;object id="svgid" data="mysvg.svg" type="image/svg+xml" wmode="transparent" width="100" height="100"&gt; this browser is not able to show SVG: &lt;a linkindex="3" href="http://getfirefox.com"&gt;http://ge...
<p><strong>> Is there any way to get svg's size by using JavaScript?</strong></p> <p>No and yes.</p> <p><strong>No:</strong></p> <p>JavaScript won't be able to access the SVG file contents that are sitting in the browser.</p> <p>So it wouldn't be possible to have a page containing an arbitrary SVG image and then ha...
<blockquote> <p>Is there any way to get svg's size by using JavaScript?</p> </blockquote> <p><strong>YES</strong></p> <pre><code>var filesize = function(url, requestHandler) { var requestObj = new XMLHttpRequest(); requestObj.open('head', address, true); requestObj.onreadystatechange = callback; reque...
28,677
<p>Still 'diving in' to Python, and want to make sure I'm not overlooking something. I wrote a script that extracts files from several zip files, and saves the extracted files together in one directory. To prevent duplicate filenames from being over-written, I wrote this little function - and I'm just wondering if ther...
<p>One issue is that there is a race condition in your above code, since there is a gap between testing for existance, and creating the file. There may be security implications to this (think about someone maliciously inserting a symlink to a sensitive file which they wouldn't be able to overwrite, but your program ru...
<p>How about </p> <pre><code>def ensure_unique_filename(orig_file_path): from time import time import os if os.path.lexists(orig_file_path): name, ext = os.path.splitext(orig_file_path) orig_file_path = name + str(time()).replace('.', '') + ext return orig_file_path </code></pre> ...
22,184
<pre><code>rsync -auve ssh --backup --suffix='2008-10-03-1514539' --backup-dir='/tmp/' module.pm root@web1:/path/to/module.pm </code></pre> <p>I run this command without the --backup-dir option and when it copies the file over, it creates a backup with a current timestamp. When I include the --backup-dir option, it ma...
<p>the manual says:</p> <blockquote> <p>--backup make backups (see --suffix &amp; --backup-dir)</p> <p>--backup-dir=DIR make backups into hierarchy based in DIR</p> <p>--suffix=SUFFIX backup suffix (default ~ w/o --backup-dir)</p> </blockquote> <p>so it seems that you can use one or the ot...
<p>You could also use something like this </p> <pre><code># Backup mkdir -p /tmp/`date +\%Y-\%m-\%d`-`date +\%A`/ rsync -avz /tmp/`date --date=yesterday +\%Y-\%m-\%d`-`date --date=yesterday +\%A`/ /tmp/`date +\%Y-\%m-\%d`-`date +\%A`/ rsync -avz -e ssh root@web1:/path/to/module.pm /tmp/`date +\%Y-\%m-\%d`-`date +\%A`/...
20,196
<p>Is there <strong>any</strong> way (maybe directly editing resource files) to configure a Tab Control (add/remove tabs and their captions and contents) at <strong>design time</strong> with Visual Studio 2008 without SP1 (I heard that SP1 has such feature)? P.S.: I use c++ with wtl</p>
<p>There are various schemas which are effective, each with their own performance implications for the common queries you'll need as the number of tagged items grows:</p> <ul> <li><a href="http://howto.philippkeller.com/2005/04/24/Tags-Database-schemas/" rel="noreferrer">http://howto.philippkeller.com/2005/04/24/Tags-...
<p>In my app BugTracker.NET, I make an assumption that there won't be TOO many bugs. Maybe tens of thousands, but not tens of millions. That assumption allows me to cache the tags and the ids of the items they reference.</p> <p>In the database, the tags are stored as they are entered, with the bugs, in a comma deli...
20,802
<p>I am using a Visual Studio project with custom build script/batch file (ala make, ant, etc.).</p> <p>When the build is run from the command line we have placed colored highlighting on various output lines.</p> <p>However, when built via Visual Studio (2005 in my case) the output window does not show the color anym...
<p>If you don't want to go with the pro version of the VSCommands plug-in, there is a free one called VSColorOutput, which does just that. I've worked with it a bit, does what it says.</p> <p>See <a href="http://coolthingoftheday.blogspot.com/2011/12/vscoloroutput-visual-studio-output.html" rel="noreferrer">http://coo...
<p>The problem isn't with your build scripts, but with Visual Studio not supporting <a href="http://en.wikipedia.org/wiki/ANSI_escape_code" rel="noreferrer">ANSI control codes</a> to change the color.</p>
7,245
<p>Generally, what's the best way to tackle a layout bug in IE6? What are the most common bugs or problems that one should look for when trying to figure out why your page suddenly looks like a monkey coded it?</p>
<h2>First Things First</h2> <p>Get yourself the <a href="http://www.microsoft.com/en-us/download/details.aspx?id=18359" rel="nofollow noreferrer">Internet Explorer Developer Toolbar</a>. It's a life saver and works great with IE6 and/or IE7. It's no replacement for Web Developer Toolbar or Firebug for Firefox, but i...
<p>We had a floating div issue that was only evident in a particular version of IE6. It was fixed by downloading the latest service pack.</p>
10,925
<p>Do you generate your data dictionary? If so, how?</p> <p>I use extended procedures in SQL Server 2005 to hold onto table and field information. I have some queries that create a dictionary out of them, but it's ... meh. Do you have a particular query or tool you use? Do you generate it off of your database diagram...
<p><a href="http://schemaspy.sourceforge.net/" rel="nofollow noreferrer">SchemaSpy</a> is a really nice tool that can reverse engineer a description of a database. This includes:</p> <ul> <li>ERD</li> <li>List of tables, columns, and constraints</li> <li>Set of warnings about DB anomalied (e.g. tables without indexes)...
<p>We generate the database's dictionnary on the developper's side of the application. We have a nice procedure using an ADODB connection + ADOX objects and collections. This procedure will browse all tables in the database. The following main data is collected:</p> <ol> <li>TableName </li> <li>ColumnName</li> <li>Col...
35,696
<p>I'm trying to write a regular expression that validates a date. The regex needs to match the following</p> <ul> <li>M/D/YYYY</li> <li>MM/DD/YYYY</li> <li>Single digit months can start with a leading zero (eg: 03/12/2008)</li> <li>Single digit days can start with a leading zero (eg: 3/02/2008)</li> <li>CANNOT inclu...
<p>This is not an appropriate use of regular expressions. You'd be better off using</p> <pre><code>[0-9]{2}/[0-9]{2}/[0-9]{4} </code></pre> <p>and then checking ranges in a higher-level language.</p>
<p>A slightly different approach that may or may not be useful for you.</p> <p>I'm in php.</p> <p>The project this relates to will never have a date prior to the 1st of January 2008. So, I take the 'date' inputed and use strtotime(). If the answer is >= 1199167200 then I have a date that is useful to me. If someth...
7,422
<p>I have</p> <pre><code>class Foo &lt; ActiveRecord::Base named_scope :a, lambda { |a| :conditions =&gt; { :a =&gt; a } } named_scope :b, lambda { |b| :conditions =&gt; { :b =&gt; b } } end </code></pre> <p>I'd like</p> <pre><code>class Foo &lt; ActiveRecord::Base named_scope :ab, lambda { |a,b| :conditions =...
<p>At least since 3.2 there is a clever solution :</p> <pre><code>scope :optional, -&gt;() {where(option: true)} scope :accepted, -&gt;() {where(accepted: true)} scope :optional_and_accepted, -&gt;() { self.optional.merge(self.accepted) } </code></pre>
<p>@<a href="https://stackoverflow.com/questions/29011/is-there-a-way-to-combine-named-scopes-into-a-new-named-scope#30719">PJ</a>: you know, I had considered that, but dismissed it because I thought I wouldn't be able to later chain on a <em>third</em> named scope, like so:</p> <pre><code>Foo.ab(x, y).c(z) </code></p...
4,868
<p>What is a good setup for .hgignore file when working with Visual Studio 2008?</p> <p>I mostly develop on my own, only occasionly I clone the repository for somebody else to work on it.</p> <p>I'm thinking about obj folders, .suo, .sln, .user files etc.. Can they just be included or are there file I shouldn't inclu...
<p>Here's my standard .hgignore file for use with VS2008 that was originally modified from a Git ignore file:</p> <pre><code># Ignore file for Visual Studio 2008 # use glob syntax syntax: glob # Ignore Visual Studio 2008 files *.obj *.exe *.pdb *.user *.aps *.pch *.vspscc *_i.c *_p.c *.ncb *.suo *.tlb *.tlh *.bak *....
<p>some others I use:</p> <pre><code>output PrecompiledWeb _UpgradeReport_Files #Guidance Automation Toolkit *.gpState #patches *.patch </code></pre>
5,514
<p>I'm using jQuery to handle all my ajax needs for an ASP.NET site coded in VB. When I use the built in $.ajax function to POST to a code-behind function and there is an exception, it simply exits the function, and shows an error on the client side.</p> <p>Besides making debugging difficult when coding, the bigger is...
<p>I figured out a work around. Although I did not find a way to directly get the error to fire the Application_Error event, I discovered a property on the jQuery XMLHttpRequest object that contains the actual exception text.</p> <p>Here is an example that will show the error in an alert:</p> <pre><code>error: functi...
<p>With .Net 3.5 you can pull in the <a href="http://www.asp.net/Ajax/Documentation/Live/overview/ScriptManagerOverview.aspx" rel="nofollow noreferrer">ScriptManager object</a> and register your javascript with it, this allows .Net to manage the scripts (it's not jsut for MS Ajax, it works with third party libraries), ...
33,267
<p>Is there a way to get the tests inside of a <code>TestCase</code> to run in a certain order? For example, I want to separate the life cycle of an object from creation to use to destruction but I need to make sure that the object is set up first before I run the other tests.</p>
<p>Maybe there is a design problem in your tests.</p> <p>Usually each test must not depend on any other tests, so they can run in any order.</p> <p>Each test needs to instantiate and destroy everything it needs to run, that would be the perfect approach, you should never share objects and states between tests.</p> <...
<p>There really is a problem with your tests if they need to run in a certain order. Each test should be totally independent of the others: it helps you with defect localization, and allows you to get repeatable (and therefore debuggable) results.</p> <p>Checkout <a href="http://www.xunitpatterns.com" rel="nofollow n...
3,143
<p>I would like to find out if a particular python datetime object is older than X hours or minutes. I am trying to do something similar to: </p> <pre><code>if (datetime.now() - self.timestamp) &gt; 100 # Where 100 is either seconds or minutes </code></pre> <p>This generates a type error. </p> <p>What is the proper...
<p>Use the <code>datetime.timedelta</code> class:</p> <pre><code>&gt;&gt;&gt; from datetime import datetime, timedelta &gt;&gt;&gt; then = datetime.now() - timedelta(hours = 2) &gt;&gt;&gt; now = datetime.now() &gt;&gt;&gt; (now - then) &gt; timedelta(days = 1) False &gt;&gt;&gt; (now - then) &gt; timedelta(hours = 1)...
<p>You can subtract two <a href="http://docs.python.org/lib/module-datetime.html" rel="nofollow noreferrer">datetime</a> objects to find the difference between them.<br> You can use <code>datetime.fromtimestamp</code> to parse a POSIX time stamp.</p>
15,866
<p>I would like to compress a folder and all its sub-folders/files, and email the zip file as an attachment. What would be the best way to achieve this with Python? </p>
<p>You can use the <a href="http://docs.python.org/dev/library/zipfile.html" rel="nofollow noreferrer">zipfile</a> module to compress the file using the zip standard, the <a href="http://docs.python.org/dev/library/email.html" rel="nofollow noreferrer">email</a> module to create the email with the attachment, and the <...
<p>You can use <a href="http://www.python.org/doc/2.5.2/lib/module-zipfile.html" rel="nofollow noreferrer">zipfile</a> that ships with python, and <a href="http://snippets.dzone.com/posts/show/2038" rel="nofollow noreferrer">here</a> you can find an example of sending an email with attachments with the standard smtplib...
20,445
<p>I must confess I'm somewhat of an OOP skeptic. Bad pedagogical and laboral experiences with object orientation didn't help. So I converted into a fervent believer in Visual Basic (the classic one!).</p> <p>Then one day I found out C++ had changed and now had the STL and templates. I really liked that! Made the lang...
<p>Really really short answer: No. Inheritance is not needed because only byte code is truly needed. But obviously, byte code or assemble is not a practically way to write your program. OOP is not the only paradigm for programming. But, I digress.</p> <p>I went to college for computer science in the early 2000s when i...
<p>In the following, inheritance is used to present a particular property for all of several specific incarnations of the same type thing. In this case, the GeneralPresenation has a properties that are relevant to all "presentation" (the data passed to an MVC view). The Master Page is the only thing using it and expe...
35,167