instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I need to do some memory profiling of a .NET Framework application. Should I use a debug or a release build? </p>
<p>A release build, built with debug symbols. </p> <p>That way there's no debug build overhead (like extra memory added after arrays for overrun detection), but you still have the names needed to associate addresses with variables.</p>
<p>You should profile the builds that are causing the problems. I'm assuming you are giving your users a Release build and so that's the one you should profile.</p>
21,231
<p>I want to use an AOP framework, but I have two constraints.</p> <p>Any framework that I choose</p> <ol> <li><p>Must be fairly independent. I plan to use this in a legacy code base, and hence cannot upgrade prospective dependencies like commons-logging-XXX.jar to commons-logging-newest.jar.</p></li> <li><p>Must be...
<p><a href="http://www.eclipse.org/aspectj/" rel="nofollow noreferrer">AspectJ</a> as far as I can tell is just a compiler and imposes no dependencies on compiled programs other than including the AspectJ runtime jar. </p> <p>It is also actively maintained, part of the Eclipse project and has a nice development enviro...
<p>Okay, this one doesn't fit all your requirements, but I think, it's worth a look: <a href="http://dynamicaspects.sourceforge.net/" rel="nofollow noreferrer">http://dynamicaspects.sourceforge.net/</a></p> <p>Positives</p> <ul> <li>No dependencies except needs java 1.5 due to using the JavaAgent </li> <li>No XML mar...
26,858
<p>How do I get the <code>GridView</code> control to render the <code>&lt;thead&gt;</code> <code>&lt;tbody&gt;</code> tags? I know <code>.UseAccessibleHeaders</code> makes it put <code>&lt;th&gt;</code> instead of <code>&lt;td&gt;</code>, but I cant get the <code>&lt;thead&gt;</code> to appear.</p>
<p>This should do it:</p> <pre><code>gv.HeaderRow.TableSection = TableRowSection.TableHeader; </code></pre>
<p>You can also use jQuery to add it. This avoids the problem with TableRowSection.TableHeader where gets dropped on PostBack.</p> <p><code>$('#myTableId').prepend($("&lt;thead&gt;&lt;/thead&gt;").append($(this).find("#myTableId tr:first")));</code></p>
39,826
<p>I'm just about wrapped up on a project where I was using a commercial SVN provider to store the source code. The web host the customer ultimately picked includes a repository as part of the hosting package, so, now that the project is over, I'd like to relocate the repository to their web host and discontinue the co...
<p>If you want to move the repository and keep history, you'll probably need filesystem access on both hosts. The simplest solution, if your backend is FSFS (the default on recent versions), is to make a filesystem copy of the entire repository folder.</p> <p>If you have a Berkley DB backend, if you're not sure of wh...
<p>Assuming you have the necessary privileges to run svnadmin, you need to use the <a href="http://svnbook.red-bean.com/en/1.4/svn.ref.svnadmin.c.dump.html" rel="nofollow noreferrer">dump</a> and <a href="http://svnbook.red-bean.com/en/1.4/svn.ref.svnadmin.c.load.html" rel="nofollow noreferrer">load</a> commands.</p>
7,201
<p>What is the best way to get a file (in this case, a .PDF, but any file will do) from a WebResponse and put it into a MemoryStream? Using .GetResponseStream() from WebResponse gets a Stream object, but if you want to convert that Stream to a specific type of stream, what do you do?</p>
<p>There is a serious issue with SoloBold's <a href="https://stackoverflow.com/questions/179676/how-do-i-put-a-webresponse-into-a-memory-stream/179712#179712">answer</a> that I discovered while testing it. When using it to read a file via an <code>FtpWebRequest</code> into a <code>MemoryStream</code> it intermittently ...
<p>I found the following at <a href="http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/eeeefd81-8800-41b2-be63-71acdaddce0e/" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/eeeefd81-8800-41b2-be63-71acdaddce0e/</a></p> <pre><code> Dim request As WebRequest ...
21,672
<p>I'd like to bind a configuration file to my executable. I'd like to do this by storing an MD5 hash of the file inside the executable. This should keep anyone but the executable from modifying the file.</p> <p>Essentially if someone modifies this file outside of the program the program should fail to load it again.<...
<p>A better solution is to store the MD5 in the configuration file. But instead of the MD5 being just of the configuration file, also include some secret "key" value, like a fixed guid, in the MD5.</p> <pre><code>write(MD5(SecretKey + ConfigFileText)); </code></pre> <p>Then you simply remove that MD5 and rehash the ...
<p>just make a const string that holds the md5 hash and compile it into your app ... your app can then just refer to this const string when validating the configuration file</p>
5,554
<p>Had anybody found a way to migrate MediaWiki pages over to WSS Wikis? We just put up Sharepoint 2007 and while it appears to meet our needs, it doesn't appear to be any tool provided by Microsoft to migrate MediaWiki pages over to WSS wikis.</p>
<p>There is no such tool provided by Microsoft at this time.</p> <p>There is one being developed though in the <a href="http://blogs.msdn.com/sharepoint/archive/2007/06/18/community-kit-for-sharepoint-2-0-pre-release-announcement.aspx" rel="nofollow noreferrer">SharePoint Community Kit</a>.</p> <blockquote> <p><strong>...
<p>You can't expect even remotely similar functionality from such imported pages. See <a href="http://wikiworks.com/enterprise-mediawiki-vs-sharepoint.html" rel="nofollow noreferrer">http://wikiworks.com/enterprise-mediawiki-vs-sharepoint.html</a> for an explanation of why you might want to reconsider this kind of mig...
17,902
<p>If I have a sorted list (say quicksort to sort), if I have a lot of values to add, is it better to suspend sorting, and add them to the end, then sort, or use binary chop to place the items correctly while adding them. Does it make a difference if the items are random, or already more or less in order?</p>
<p>If you add enough items that you're effectively building the list from scratch, you should be able to get better performance by sorting the list afterwards.</p> <p>If items are mostly in order, you can tweak both incremental update and regular sorting to take advantage of that, but frankly, it usually isn't worth t...
<p>Inserting an item into a sorted list is O(log n), while sorting a list is O(n log N) Which would suggest that it's always better to sort first and then insert</p> <p>But remeber big 'O' only concerns the scaling of the speed with number of items, it might be that for your application an insert in the middle is expe...
20,384
<p>I'm going to try to ask my question in the context of a simple example...</p> <p>Let's say I have an abstract base class Car. Car has-a basic Engine object. I have a method StartEngine() in the abstract Car class that delegates the starting of the engine to the Engine object.</p> <p>How do I allow subclasses of ...
<p>The Abstract Factory pattern is precisely for this problem. Google GoF Abstract Factory {your preferred language}</p> <p>In the following, note how you can either use the concrete factories to produce "complete" objects (enzo, civic) or you can use them to produce "families" of related objects (CarbonFrame + TurboE...
<p>There are lots of ways it could be done. </p> <p>I would favour having a <code>setEngine()</code> method on <code>Car</code>, then having the <code>Ferrari</code> constructor call <code>setEngine()</code> and pass in an instance of a <code>TurboEngine</code>.</p>
35,261
<p>For those of you who are decent with subsonic!</p> <pre><code> TblNewsCollection col = new Select().From(Tables.TblNews) .InnerJoin(Tables.TblContent) .Paged(currentPage, pageSize) .OrderDesc(TblContent.Columns.PubDate) .ExecuteAsCol...
<p>I found that joins work better using the TableColumnSchema as in the above Northwind example as opposed to the column name.</p>
<pre><code>Northwind.CustomerCollection customersByCategory = new Select() .From(Northwind.Customer.Schema) .InnerJoin(Northwind.Order.Schema) .InnerJoin(Northwind.OrderDetail.OrderIDColumn, Northwind.Order.OrderIDColumn) .InnerJoin(Northwind.Product.ProductIDColumn, Northwind.OrderDetail.ProductIDColum...
38,231
<p>I have two routes I want mapped in my ASP.NET MVC application</p> <ol> <li>/User/Login</li> <li>/User/{userid}/{username}/{action} (e.g. /User/1/blah/profile)</li> </ol> <p>Here are the routes I've defined: </p> <pre><code> routes.MapRoute( "Profile", "Users/{userID}/{username}/{action}",...
<p>You want to use <code>&lt;%=Html.RouteLink%&gt;</code></p> <p>This is very similar to the <a href="https://stackoverflow.com/questions/323572/asp-mvc-routing-with-1-parameter">problem I had which you can view here</a></p>
<p>is your route hitting an Authorize filter? Is there a requirement to be logged in to view the /Users/1/blah page? (ie. is there an [Authorize] attribute on the UsersController class, or on the Profile Action?)</p> <p>well then, if it is not an Authorize filter, I <em>highly</em> suggest you implement this <a href=...
48,614
<p>The title is a bit abstract so maybe it is easier to explain with a specific example:</p> <p>I find it useful to have my exception classes take an enum parameter instead of a string message. </p> <pre><code>throw new SpecificException(SpecificExceptionCode.ThisThingWentWrong); </code></pre> <p>There are few reaso...
<p>Your current code is broken... there is only one static field; the last static ctor to execute wins.</p> <p>Re using a non-static method - note that calling virtual/abstract methods in a constructor is a bit dangerous - the concrete class won't have initialized yet, so the override could attempt to use data that is...
<p>Why does it have to be a static property? You can make the Resources normal property:</p> <pre><code>protected abstract static ResourceManager Resources{get;} </code></pre> <p>and just leave it for the implementer to implement it to return a static object:</p> <pre><code>private static ResourceManager resources =...
41,903
<p>I have an HTML form with two buttons as follows:</p> <pre><code>&lt;input type="submit" name="confirm" value="Yes, Delete" /&gt; &lt;button name="confirm" type="button" onclick="history.back()" value="No, Go Back"&gt;No, Go Back&lt;/button&gt; </code></pre> <p>Now, when I click on either in Firefox, the behavior ...
<p>Firefox, Safari, Chrome, Opera <strong><em>all play</em></strong> the "<strong><em>first match wins</em></strong>" game, but IE plays the "<em>last match wins</em>" game.</p> <p>(<a href="http://webbugtrack.blogspot.com/2008/06/bug-or-feature-round-three.html" rel="nofollow noreferrer">see bug/feature report here</...
<p>I believe this is because the names of both buttons are the same. The second button must be "overriding" the attributes of the first button. At any rate, changing the name of the second button solved the problem.</p>
48,054
<p>I went to <a href="http://www.json.org/js.html" rel="nofollow noreferrer">http://www.json.org/js.html</a> and downloaded the json2.js, thinking i'd be fine, afterall that site is on the top in a google search for 'json javascript' - also they have this really cool url :)</p> <p>So i've been working a bit with it an...
<p><a href="https://blog.codinghorror.com/obscenity-filters-bad-idea-or-incredibly-intercoursing-bad-idea/" rel="nofollow noreferrer" title="Obscenity Filters: Bad Idea, or Incredibly Intercoursing Bad Idea?">Obscenity Filters: Bad Idea, or Incredibly Intercoursing Bad Idea?</a> ^_^</p> <p>Also see <a href="https://st...
<p>Well, what we (*) did is to create a two-tiered list of "bad words" (using regex to hopefully catch some variations). Using a Tier 1 word will get you a warning saying that you are violating the Terms of Service, and you cannot save that message until you fix it. If you use a Tier 2 word, the message is posted, bu...
38,365
<p>I'm writing an application and I'm trying to tie simple AJAX functionality in. It works well in Mozilla Firefox, but there's an interesting bug in Internet Explorer: Each of the links can only be clicked once. The browser must be completely restarted, simply reloading the page won't work. I've written a <a href="htt...
<p>This happens because Internet Explorer ignores the no-cache directive, and caches the results of ajax calls. Then, if the next request is identical, it will just serve up the cached version. There's an easy workaround, and that is to just append random string on the end of your query.</p> <pre><code> xmlHttp.open...
<blockquote> <p>xmlHttp.open("GET","blurb.php?"+Math.random();</p> </blockquote> <p>I agree with this one.. it works perfectly as a solution to this problem. the problem is that IE7's caching of urls were terrible, ignoring the no-cache header and save the resource to its cache using its url as key index, so the bes...
30,383
<p>I'd like to create an application that would run on Google's appengine.</p> <p>However, this application needs to be able to generate PDFs dynamically.</p> <p>How could I do this?</p>
<p>You can use the <a href="http://www.reportlab.org/rl_toolkit.html" rel="noreferrer"><code>reportlab</code> library</a> to generate a PDF from Python. You can just include the ReportLab files in with your application's code, or you can include a <a href="http://code.google.com/appengine/articles/django10_zipimport.ht...
<p>I would recommend <strong>PyFPDF</strong>, which is a pure-Python port of the lightweight yet highly powerful PHP FPDF library. It is hardly a few dozen kilobytes.</p> <p>See <a href="http://code.google.com/p/pyfpdf/" rel="nofollow">http://code.google.com/p/pyfpdf/</a></p>
42,476
<p>I need to alter the length of a column <code>column_length</code> in say more than 500 tables and the tables might have no of records ranging from 10 records to 3 or 4 million records.</p> <ol> <li>The column may just be a normal column</li> </ol> <pre><code>CREATE TABLE test(column_length varchar(10)) </code></pre>...
<p>Yes you should be able to just modify the columns. From my experience it is faster to leave the index and primary key in place.</p>
<p>Likely you will need to do alter column on the foreign key tables as well to increase the size. SO first you drop the fk constraint, then fix the forign kkey fields, then fix the primary key field then put the constraints back on.</p>
16,227
<p>What are you favorite LogParser 2.2 Scripts to run against IIS logs and Event logs?</p> <p>I am putting a list of scripts together to run against our production environment to proactively look for issues and to help when isolating performance problems.</p> <p>Do you have a certain list of LogParser 2.2 scripts tha...
<p>I like to run queries to identify the top pages requested, the pages that have the highest sum of "time taken" as well as the pages with the highest average "time taken".</p> <p>With these it helps to identify heavy load sections, and sometimes leads to areas that can be improved with caching ETC.</p>
<p>We usually yank the lot back into SQL server then query what we're after from there. I work for a shared hoster and one of the things we look for is excessive scripting errors in the IIS logs and ASP.NET exceptions logged to the event log. On shared box with 1200 sites these can bring it to it's knees if not kept in...
21,072
<p>I have some .net apps running that I need to monitor for example, then MethodA is called in App1, my monitor app should detect this. I have a lot of running apps and the solution proposed here is to recompile all those apps and include a new line in the desired methods that we want to monitor. I want to do this only...
<p>There are several ways you could do this. One is to use log4Net, 'sprinkle' your methods with calls to log4Net's write methods. You can choose a variety of logging appenders (destinations) such as email or a database, but a less known tip is to download the standalone program, <a href="http://technet.microsoft.com/e...
<p>System.Diagnostics.PerformanceCounter is a good place to start. You can create new counters that can be viewed in the Performance control panel applet. They're a little confusing at the start, but when you realize average counters need two components to calculate a percentage it gets a lot easier.</p>
13,963
<p>How long will it take to enroll in the iPhone developer program after paying the $99?</p> <p>Is there anything to do after paying it? (I mean paperwork, faxing or sending physical stuff)</p> <p>How will Apple pay your revenues? (In what form and intervals, and what will they do if you are not in US?)</p>
<p>About 1 week after the $99 - perhaps a little less or a little more.</p> <p>Yes, you have to manage certificates and provisions. Also, you have to submit your contact, tax, and bank information. Nothing complicated though - just the standard stuff.</p> <p>Apple pays by depositing funds into your bank account and p...
<p>You also might have to fax them a copy of your passport/ID if your contact address differs from the creditcard billing address.</p>
45,000
<p>I need to develop a CRM system which will allow users to have a local copy of the DB which can then be synched with the main server system. The idea is that a sales team can travel to non-internet enabled areas and still operate with relatively up to date information and then synch up when they get back to the offic...
<p>Having written just such a system myself, I'd recommend avoiding it if possible. The ways that users can mess up such a system are legion, particularly when the users are the sales team. A CRM system named Act! (you are probably familiar with) has offered such a sync option in the past, and maybe they still do. W...
<p>You might want to take a look at the <a href="http://msdn.microsoft.com/en-us/sync/default.aspx" rel="nofollow noreferrer">Microsoft Synch Framework</a>. I haven't used it yet, so I cannot give a personal opinion on it though.</p>
41,053
<p>I am using RedCloth with Rails 2.1.1. The Textile <code>&lt;del&gt;</code> tag markup format (i.e. -delete-) was not translating at all. Tried a few choice options.</p> <pre><code>&gt; x=RedCloth.new('foobar -blah-') =&gt; "foobar -blah-" &gt; x.to_html =&gt; "&lt;p&gt;foobar &lt;del&gt;blah&lt;/del&gt;&lt;/p&gt;"...
<p>Looks like RedCloth needs a little more syntax to interpret the delete tag as the first element after a list item...</p> <pre><code>&gt;&gt; RedCloth.new("foobar\n* [-blah-]").to_html =&gt; "&lt;p&gt;foobar&lt;/p&gt;\n&lt;ul&gt;\n\t&lt;li&gt;&lt;del&gt;blah&lt;/del&gt;&lt;/li&gt;\n&lt;/ul&gt;" </code></pre>
<p>This is because <strong>a star on a new line represents a list item</strong>, and it is ignoring delete markers without explicitly telling it to render them as Michael points out.</p>
28,658
<p>I am wondering what is best practice when it comes to dependencies and how releases should be done. In my case I have a library that relies on log4net and I am wondering if I should distribute log4net.dll (set the log4net reference to copy local) along with the release? </p> <p>Could I simply state that log4net sho...
<p>Testing your function plus curl plus the server is more integration test than unit test. That being said, you don't have to be that dogmatic, if you only have one test like that this certainly is viable. I've written, and still have tests that are not pure unit tests, but they do their job. I'll keep them as far as ...
<p>I think you should be mocking the method the function uses to detect that it has spent long enough waiting, then you can test the timeout instantly and not wait in real time.</p>
39,197
<p>I am confronted with a new kind of problem which I haven't encountered yet in my very young programming "career" and would like to know your opinion about how to tackle it best.</p> <p><strong>The situation</strong> A research application (php/mysql) gathers stress related health data from users. User gets a an ana...
<p>What you're considering could be done in a number of ways.</p> <ol> <li><p>You could setup a trigger in your DB to recalculate the values whenever a new record is updated. You could store the code needed to update the values in a sproc if necessary.</p></li> <li><p>You could write a PHP script and run it regularly...
<p>If the volume of data is big enough that calculating it on the fly is too much, then either:</p> <ol> <li>Cron job with php script to denormalise the totals</li> <li>Trigger on inserts that increments totals </li> </ol>
10,879
<p>I need to create a configuration section, that is able to store key-value pairs in an app.config file and the key-value pairs can be added runtime regardless of their type. It is also important that the value keeps its original type. I need to extend the following interface </p> <pre><code>public interface IPrefere...
<p>I found two great articles on codeproject.com that are explaining these issues in great detail. </p> <p>Unraveling the Mysteries of .NET 2.0 Configuration <a href="http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/dotnet/mysteriesofconfigurat...
<p>That's all you get in a an ASCII text file - strings. :-)</p> <p>However, you can encode the "value" strings to include a type parameter like:</p> <pre><code>&lt;key="myParam" value="type, value" /&gt; </code></pre> <p>for example:</p> <pre><code>&lt;key="payRate" value="money,85.79"/&gt; </code></pre> <p>then ...
15,253
<p>Mixing the use of primitive data types and their respective wrapper classes, in Java, can lead to a lot of bugs. The following example illustrates the issue:</p> <pre><code>int i = 4; ... if (i == 10) doStuff(); </code></pre> <p>Later on you figure that you want the variable <em>i</em> to be either defined or un...
<p>Using the boxed types <em>does</em> have both performance and memory issues.</p> <p>When doing comparisons (eg <code>(i == 10)</code> ), java has to unbox the type before doing the comparison. Even using <code>i.equals(TEN)</code> uses a method call, which is costlier and (IMO) uglier than the == syntax.</p> <p>Re...
<p>Thee java POD types are there for a reason. Besides the overhead, you can't do normal operations with objects. An Integer is an object, which need to be allocated and garbage collected. An int isn't.</p>
15,100
<p>In Python, I want to make <strong>selected</strong> instance attributes of a class be readonly to code outside of the class. I want there to be no way outside code can alter the attribute, except indirectly by invoking methods on the instance. I want the syntax to be concise. What is the best way? (I give my current...
<p>You should use the <code>@property</code> decorator.</p> <pre><code>&gt;&gt;&gt; class a(object): ... def __init__(self, x): ... self.x = x ... @property ... def xval(self): ... return self.x ... &gt;&gt;&gt; b = a(5) &gt;&gt;&gt; b.xval 5 &gt;&gt;&gt; b.xval = 6 Traceback (most...
<p>You could use a metaclass that auto-wraps methods (or class attributes) that follow a naming convention into properties (shamelessly taken from <a href="http://www.python.org/download/releases/2.2/descrintro/#metaclasses" rel="nofollow noreferrer">Unifying Types and Classes in Python 2.2</a>:</p> <pre><code>class a...
15,200
<p>In my small WPF project, I have a <code>TabControl</code> with three tabs. On each tab is a <code>ListBox</code>. This project keeps track of groceries we need to buy. (No, it's not homework, it's for my wife.) So I have a list of <code>ShoppingListItem</code>s, each of which has a <code>Name</code> and a <code>...
<p>You can use a <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.collectionviewsource.aspx" rel="nofollow noreferrer">CollectionViewSource</a> to reuse the original collection with a filter. </p> <pre><code>&lt;Window.Resources&gt; &lt;CollectionViewSource x:Key="NeededItems" Source="{Binding ...
<p>Here are a couple of ideas:</p> <ol> <li>When tabs Bought and Needed load, filter them yourself by creating new collections with the items you want, or</li> <li>when tabs Bought and Needed load, override the list item databind and toggle visability based on Needed</li> </ol>
34,560
<p>I'd like to be able to switch the sound output source in Mac OS X without any GUI interaction.</p> <p>There are tools to do control the sound output, such as <a href="http://rogueamoeba.com/freebies/" rel="noreferrer">SoundSource</a> and an <a href="http://www.macosxhints.com/article.php?story=20050614171126634" re...
<p>Don’t think of it in terms of preferences; there’s no centralized system preference framework for this sort of thing. I believe what you need to do is use Core Audio to set the <code>kAudioHardwarePropertyDefaultOutputDevice</code> and <code> kAudioHardwarePropertyDefaultSystemOutputDevice</code> properties of the...
<p>I created a command-line application to do exactly this.</p> <p>You may download it at <a href="http://code.google.com/p/switchaudio-osx/downloads" rel="nofollow noreferrer">http://code.google.com/p/switchaudio-osx/downloads</a>. Source code is available on the project site as well.</p> <p><strong>UPDATE</strong>...
20,548
<p>for some reason, templatetags do not render in templates for django admin.</p> <p>with this snippet from: <a href="http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#shortcut-for-simple-tags" rel="nofollow noreferrer">http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#shortcut-fo...
<p>That's only an example, the <code>is_logged_in</code> variable is not actually defined in any templates unless you put it in the context.</p> <p>If you added that line and got <code>Please log in.</code> it does mean that the tag is rendering. If it fails the <code>if</code> and goes to the <code>else</code> it is...
<p>I just tried this one:</p> <p>request.user.is_authenticated</p> <p>Right in the template and just worked as we wish!</p>
31,148
<p>Does anyone know any good tool that I can use to perform stress tests on a video streaming server? I need to test how well my server handles 5,000+ connections. </p>
<p>One option is to use VLC. You can specify a url on the command line. (see <a href="http://wiki.videolan.org/VLC_command-line_help" rel="nofollow noreferrer">here</a> for details). You could then write a brief shell script to open up all 5000 connections.</p> <p>eg. the following perl script (very quick hack - check...
<p>This <a href="http://www.mocomsoft.com/en-US/products/HLSAnalyzer.aspx" rel="nofollow">HLS Analyzer</a> software can be used for stress testing HTTP Live Streaming server and monitoring downloading performance. </p>
18,247
<p>or "How do I answer questions on SO in Firefox using gVim inside the textboxes?"</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/4125" rel="noreferrer">It's All Text!</a></p> <p>From the extension page:</p> <blockquote> <p>At the bottom right corner of any edit box, a little edit button will appear. Click it. If this is the first time you've used "It's All Text!" then you wil...
<p>With Firefox-57 on Linux, I installed textern <a href="https://addons.mozilla.org/en-US/firefox/addon/textern/" rel="nofollow noreferrer">https://addons.mozilla.org/en-US/firefox/addon/textern/</a>, and found it to be a suitable replacement for ViewSourceWith for editing text boxes.</p>
10,125
<p>I am developing an application, and have URLs in the format <code>www.example.com/some_url/some_parameter/some_keyword</code>. I know by design that there is a maximum length that these URLs will have (and still be valid). Should I validate the URL length with every request in order to protect against buffer overflo...
<p>If you are not expecting that input, reject it.</p> <p>You should always validate your inputs, and certainly discard anything outside of the expected range. If you already know that your URL's honestly won't be beyond a certain length then rejecting it before it gets to the application seems wise.</p>
<p>I think this may give you some modicum of safety and might save you a little bandwidth if people do send you crazy long URLs, but largely you should just validate your data in the actual application as well. Multiple levels of security are generally better, but don't make the mistake of thinking that because you ha...
11,804
<p>Given a table of votes (users vote for a choice, and must supply an email address):</p> <pre><code>votes -- id: int choice: int timestamp: timestamp ip: varchar email: varchar </code></pre> <p>What's the best way to count "unique" votes (a user being a unique combination of email + ip) given the constraint they ma...
<p>Something like </p> <pre><code>select email, ip, count(choice) from votes group by email, ip, datepart(hour, timestamp) </code></pre> <p>If I understand correctly</p>
<p>You could rewrite your insert statement to only allow votes to be inserted based on your contrainsts:</p> <pre><code>Insert Into Votes (Choice, Timestamp, IP, Email) Select Top 1 @Choice, @Timestamp, @IP, @Email From Votes Where (Select Count(*) From Votes Where IP = @IP and Email = @Email and Timestamp...
9,688
<p>I am trying to show and hide an inline element (eg a span) using jQuery.</p> <p>If I just use toggle(), it works as expected but if I use toggle("slow") to give it an animation, it turns the span into a block element and therefore inserts breaks.</p> <p>Is animation possible with inline elements? I would prefer a...
<p><code>toggle()</code> has a bunch of weird things with it, including hiding or transforming odd elements at times. here's a similar solution:</p> <pre><code>$('.toggle').click(function() { $('.hide').animate({ 'opacity' : 'toggle', }); }); </code></pre> <p><strong>edit</strong>: here's a way to add smooth ...
<p>As other answers have shown, fading is possible. However, I don't think "smooth sliding" will be. Simply put, a specific property of the element has to be animated. An inline span like you mention has no specific height or width, though it does have an opacity.</p>
28,713
<p>The default seems to be upper case, but is there really any reason to use upper case for keywords?</p> <p>I started using upper case, because I was just trying to match what <a href="https://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="nofollow noreferrer">SQL Server</a> gives me whenever I tried to create somet...
<p>It's just a matter of style, probably originating in the days when editors didn't do code colouring.</p> <p>I used to prefer all upper case, but I'm now leaning towards all lower.</p> <p>Either way, be consistent.</p>
<p>I call most of my mySQL code from within PHP, and I do all of my PHP editing within vim (or I suppose in this case, VIM ;-). Now I am sure there are plugins out there to highlight the mySQL code within PHP, but I have not found it, and I don't have to the time to go looking for it. Therefore, I prefer to have <stron...
37,256
<p>Is there some way to block access from a referrer using a .htaccess file or similar? My bandwidth is being eaten up by people referred from <a href="http://www.dizzler.com" rel="nofollow noreferrer">http://www.dizzler.com</a> which is a flash based site that allows you to browse a library of crawled publicly availab...
<p>That's like saying you want to stop spam-bots from harvesting emails on your publicly visible page - it's very tough to tell the difference between users and bots without forcing your viewers to log in to confirm their identity.</p> <p>You could use robots.txt to disallow the spiders that actually follow those rule...
<p>It's not a very elegant solution, but you could block the site's crawler bot, then rename your mp3 files to break the links already on the site.</p>
10,682
<p>I have a few huge tables on a production SQL 2005 DB that need a schema update. This is mostly an addition of columns with default values, and some column type change that require some simple transformation. The whole thing can be done with a simple "SELECT INTO" where the target is a table with the new schema.</p> ...
<p>We have a similar problem and I've found that the fastest way to do it is to export the data to delimited files (in chunks - depending on the size of the rows - in our case, each file had 500,000 rows), doing any transforms during the export, drop and recreate the table with the new schema, and then do a bcp import ...
<p>Add the column allowing null, then do the update to the default value manually, then re-alter the table to add the default value. This way you can control the updates and do them in smaller chunks.</p>
46,970
<p>Is there anything out there freeware or commercial that can facilitate analysis of memory usage by a PHP application? I know xdebug can produce trace files that shows memory usage by function call but without a graphical tool the data is hard to interpret. </p> <p>Ideally I would like to be able to view not only t...
<p>As you probably know, Xdebug dropped the memory profiling support since the 2.* version. Please search for the &quot;removed functions&quot; string here: <a href="http://www.xdebug.org/updates.php" rel="noreferrer">http://www.xdebug.org/updates.php</a></p> <blockquote> <p><strong>Removed functions</strong></p> <p>Re...
<p>A graphical tool for xdebug output is <a href="http://kcachegrind.sourceforge.net/" rel="nofollow noreferrer">KCacheGrind</a>.</p>
31,939
<p>What is a good way to represent sparse set of integers (really C memory addresses) in a compact and fast way. I already know about the obvious things like bit-vectors and run-length encoding. but I want something much more compact than one word per set element. I need to add and remove elements and test for membersh...
<p>You are referring to a judy array. It was a HP project. I think they are used in ruby and are available in c. Very interesting data structure. Making use of the fact that allocations are (at least) word aligned, having separate structures for dense and sparse ranges.</p> <p><a href="http://judy.sourceforge.net/inde...
<p>If you want the structure smaller than the data set than you should probably look at some kind of tree arrangement. Make each level of a 4 way the tree key off 2 bits starting at the high end and it might compact quite well (if the pointers have any degree of spacial locality). The trick would be encoding it compact...
47,116
<p>I have an application that has many different types of objects that each persist themselves back to the db. This has worked fine so far without transactions and I'm not looking to go hog wild adding them. But there is an occasional need to start a transaction before a whole collection of the objects start updating t...
<p>First, I wouldn't be handling the transactional logic in the page. Write a business class of some sort to do this - a service, a data utility class, something you can abstract away from ASP.Net. </p> <p>Next, you might look at using the <em>TransactionScope</em> class (in System.Transactions namespace, reference ...
<ol> <li>I would prefer declarative transactions over trying to do manual DB transactions.</li> <li>As Mitch Wheat already mentioned, a transaction has context and is connection based, so it will include your changes happening in the page/method, and commit if all ok, or rollback if there was an exception.</li> <li><st...
40,376
<p>I've had some trouble forking of processes from a Perl CGI script when running on Windows. The main issue seems to be that 'fork' is emulated when running on windows, and doesn't actually seem to create a new process (just another thread in the current one). This means that web servers (like IIS) which are waiting f...
<p>If you want to do this in a platform independent way, <a href="http://search.cpan.org/~bzajac/Proc-Background/lib/Proc/Background.pm" rel="nofollow noreferrer">Proc::Background</a> is probably the best way.</p>
<p><a href="http://www.xav.com/perl/lib/Pod/perlfork.html" rel="nofollow noreferrer">perlfork</a>:</p> <blockquote> <p>Perl provides a fork() keyword that corresponds to the Unix system call of the same name. On most Unix-like platforms where the fork() system call is available, Perl's fork() simply calls ...
6,779
<p><em>[This question is related to but not the same as <a href="https://stackoverflow.com/questions/206106/is-a-safe-way-to-convert-to-bool-in-c">this one</a>.]</em></p> <p>My compiler warns about implicitly converting or casting certain types to bool whereas explicit conversions do not produce a warning:</p> <pre><...
<p>I was puzzled by this behaviour, until I found this link:</p> <p><a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99633" rel="noreferrer">http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99633</a></p> <p>Apparently, coming from the Microsoft De...
<p>I don't think performance is the issue here. The reason you get a warning is that information is lost during conversion from int to bool.</p>
25,306
<p>I am playing movie using MPMoviePlayerController,</p> <p>I am using TableView,what happening with my application is when I press accessory button it will display detailed view and when I press cell area it will play movie that I wanted,(the way youtube application does)</p> <p>but when I press "DONE" while playin...
<p>Ideally if your code is correct, pressing the Done button on MPMoviePlayerController object would close the MPMOviePlayerController and return to the controller which invoked it (which in your case is the detail view)</p> <p>You do not need to do anything in the movieDidFinishCallback except maybe release the movie...
<pre><code>-(void)myMovieFinishedCallback:(NSNotification*)aNotification { MPMoviePlayerController* theMovie = [aNotification object]; theMovie.initialPlaybackTime = -1.0; } </code></pre>
49,762
<p>I have a J2EE project in Eclipse 3.2 and at the end of every build I want to automatically create and deploy a WAR file. At the moment I have to do this by hand which is 5 or 6 mouse-cliks and it would be nice to automate it.</p> <p>I know I can do this with a custom build script using ANT but I am hoping for an E...
<p>If you can implement it as an Ant script, then you can have Eclipse invoke that Ant script on each build automatically (and inside the Eclipse environment). Use Project->Properties->Builders->Add->Ant Builder. Give that builder you custom Ant script and it will automatically be executed after the "normal" builders o...
<p>Right click on your project: Export -> Web -> WAR File Do what you want to do.</p>
45,251
<p>I have a SQL SELECT query which has a LIKE clause containing an underscore, which should specifically look for an underscore, not treat it as a wildcard: </p> <pre><code>SELECT * FROM my_table WHERE name LIKE '_H9%'; </code></pre> <p>I understand that I can change the actual clause to '[_]H9%' for this to work as ...
<p>If you're using Criteria to create the query, you can create your own expression which subclasses org.hibernate.criterion.LikeExpression, using one of the protected constructors that takes in 'Character escapeChar', and does substitution in the value for you. Assuming that '!' is a known value that won't be in any s...
<p>Why can you not do a string replacement on the value? How is this being used so that this is a non-workable solution?</p>
37,814
<p>I would like to print multiple parts continuously (non-interactively), so I can leave the printer alone for a longer time. So after finish, parts could be moved somehow out from the printing area, so the next can start.</p> <p>Are there any methods of achieving that with standard desktop printers without having to ...
<p>The only thing I can think of off hand is an old mod for the early MakerBot machines. It first was released for the Thing-O'-Matic I believe, but is compatible with Replicator 1 machines (and its knock-offs). Here's the <a href="http://www.thingiverse.com/thing:4056" rel="noreferrer">Thingiverse page</a>, but look u...
<p>I Don't really think that it is possible without hardware modifications, or maybe some small parts that will fit in the bed of the printer all on the same time</p>
106
<p>I am considering making use of GWT as the front-end to an <strong>existing</strong> web application.</p> <p>I can't justify a complete rewrite to 100% GWT in one go. It is likely that I would migrate parts of the system to GWT gradually. However for consistency I would like to make use of the GWT TabPanel, MenuBar,...
<p>One of the ways GWT was designed to be used is exactly as you've used it. We have done that in many of our apps - where there is one GWT module with multiple 'parts' that are loaded based on whether a given id exists on a page or not. So I don't see that you'll have any issues at all going this way. We often use thi...
<p>You're doing it right. Avoid avoid avoid the temptation to try to 'minimize' the GWT footprint by breaking it up into multiple separate apps. </p> <p>The key to GWT performance is to have as few downloads as possible and to make sure they're cached. Loading a 250k bundle once is much better than two 200k bundles an...
47,403
<p>I'm trying to create a cube with a single measure. This measure is a distinct count of a "name" column. The cube works perfectly if the measure is set to "count" type. However when I set distinct count I get this error:</p> <p>"Errors in the OLAP storage engine: The sort order specified for distinct count records i...
<p>my answer may be too late for you, but hope this can help other which have the same problem. </p> <ol> <li>Go to the data source view in Solution Explorer</li> <li>Find a table which contains the GUID column which needs to be aggregated</li> <li>Right-click on the header of the selected table and select 'Create Nam...
<p>I will answer myself, maybe this is helpful for somebody else.</p> <p>The short answer is YES.</p> <p>I have created some test tables with the same structure but just a few test rows. The cube works perfectly with this data.</p> <p>So, I guess there are some corrupt data on the original tables, or maybe some rare...
41,446
<p>My web application generates pdf files and either e-mails or faxes them to our customers. Somehow IIS6 is keeping hold of the file and blocking any other requests for it claiming the old '..the process cannot access the file 'xxx.pdf' because it is being used by another process.'</p> <p>When I recycle the applicati...
<p>As with everyone said, do call the <code>Close</code> and <code>Dispose</code> method on any IO objects you have open when reading/writing the PDF files.</p> <p>But I suppose you'd incorporated a <strong>3rd party component?</strong> to do the PDF writing for you? If that's the case you might want to check with the...
<p>I'd look through your code and make sure all handles to open (generated) files have been closed properly. Sometimes you just can't rely on the garbage collector to sort these things out.</p>
9,752
<p>I am getting the following error when I get to the line that invokes a REALLY BASIC web service I have running on Tomcat/Axis.</p> <pre><code>Element or attribute do not match QName production: QName::=(NCName':')?NCName </code></pre> <p>Have I got something wrong with QName?- I can't even find any useful informat...
<p>As the exception says, you call the QName constructor incorrectly:</p> <pre><code>new QName("http://testPackage.fc.com/, doBasicStuff") </code></pre> <p>is incorrect. I think you have to pass two strings, one containing the namespace, one the localname. The documentation will typically contain a description on how...
<p>You should use one of these:</p> <pre><code>public QName(String localPart) or public QName(final String namespaceURI, final String localPart) </code></pre> <p>but new QName("<a href="http://testPackage.fc.com/" rel="nofollow noreferrer">http://testPackage.fc.com/</a>, doBasicStuff") is wrong, since both va...
24,600
<p>I'm running some JUnit tests on my applications. Every test has a for loop calling respective method 10000 times. The tested methods produce a lot of log. These logs are also automatically collected by JUnit as test output. This situation takes to OutOfMemoryError because the string buffer where JUnit keeps the out...
<p>What type of logging are you using? Is there some way you can override the default logging behavior to just disregard all log messages?</p>
<p>I would just increase the available memory.. Try adding -Xmx256m -Xmx256m to your VM.</p>
12,910
<p>I need to rename the database but when I do in <code>PGAdmin : ALTER DATABASE "databaseName" RENAME TO "databaseNameOld"</code> it told me that it cannot.</p> <p>How can I do it?</p> <p>(<strong>Version 8.3 on WindowsXP</strong>)</p> <p><strong>Update</strong></p> <ul> <li><p>The first error message : Cannot be...
<p>Try not quoting the database name:</p> <pre><code>ALTER DATABASE people RENAME TO customers; </code></pre> <p>Also ensure that there are no other clients connected to the database at the time. Lastly, try posting the error message it returns so we can get a bit more information.</p>
<p>For anyone running into this issue using DBeaver and getting an error message like this:</p> <pre><code>ERROR: database "my_stubborn_db" is being accessed by other users Detail: There is 1 other session using the database. </code></pre> <p>Disconnect your current connection, and reconnect to the same server with...
17,346
<p>How do I extract the value of a property in a PropertyCollection?</p> <p>If I drill down on the 'Properties' in the line below is visual studion I can see the value but how do I read it?</p> <pre><code>foreach (string propertyName in result.Properties.PropertyNames) { MessageBox.Show(ProperyNames[0].Value.ToStri...
<p>Try this:</p> <pre><code>foreach (string propertyName in result.Properties.PropertyNames) { MessageBox.Show(result.Properties[propertyName].ToString()); } </code></pre> <p>Or this:</p> <pre><code>foreach (object prop in result.Properties) { MessageBox.Show(prop.ToString()); } </code></pre> <p>Also: ther...
<p>Try:</p> <pre><code>foreach (string propertyName in result.Properties.PropertyNames) { MessageBox.Show(properyName.ToString()); &lt;--Wrong! } </code></pre>
30,185
<p>Here is one trivial question, that I am not sure how to handle. I need to display list of categories on every page, and to be able to choose items from a specific category to be displayed. I use asp.net MVC, and have chosen to create a user control that will display categories. My question is: what is the best appro...
<p>I'm using mvc components, which replaced ascx user controls in preview 4.<br> Example: <a href="http://blog.wekeroad.com/blog/asp-net-mvc-preview-4-componentcontroller-is-now-renderaction/" rel="nofollow noreferrer">http://blog.wekeroad.com/blog/asp-net-mvc-preview-4-componentcontroller-is-now-renderaction/</a><br> ...
<p>it is the mvc futures project. i will probably try this <a href="http://forums.asp.net/t/1303328.aspx" rel="nofollow noreferrer">http://forums.asp.net/t/1303328.aspx</a>. I need to render menu with categories.</p>
3,449
<p>Some of my script are using different encoding, and when I try to combine them, this has becom an issue.</p> <p>But I can't change the encoding they use, instead I want to change the encodig of the result from script A, and use it as parameter in script B. </p> <p>So: is there any simple way to change a string fro...
<p>Have a look at <a href="http://php.net/function.iconv" rel="noreferrer"><code>iconv()</code></a> or <a href="http://php.net/function.mb-convert-encoding" rel="noreferrer"><code>mb_convert_encoding()</code></a>. Just by the way: why don't <a href="http://php.net/function.utf8-encode" rel="noreferrer"><code>utf8_encod...
<pre><code>function parseUtf8ToIso88591(&amp;$string){ if(!is_null($string)){ $iso88591_1 = utf8_decode($string); $iso88591_2 = iconv('UTF-8', 'ISO-8859-1', $string); $string = mb_convert_encoding($string, 'ISO-8859-1', 'UTF-8'); } } </code></pre>
48,965
<p>I have the next function:</p> <pre><code>function setImagesWidth(id,width) { var images = document.getElementById(id).getElementsByTagName("img"); for(var i = 0; i &lt; images.length;i++) { // If the real width is bigger than width parameter images[i].style.width=width; //} ...
<p>Here is, hopefully, enough sample code to give you what you want:</p> <pre><code>var myImage = document.getElementById("myImagesId"); var imageWidth = myImage.offsetWidth; var imageHeight = myImage.offsetHeight; </code></pre> <p>That should give you the numbers you need to derive the solution you want. I think you...
<p>Careful, it looks like you might rather want <code>clientWidth</code>:</p> <p><a href="http://developer.mozilla.org/en/Determining_the_dimensions_of_elements" rel="nofollow noreferrer">http://developer.mozilla.org/en/Determining_the_dimensions_of_elements</a></p>
6,376
<p>I have a MySQL table consisting of:</p> <pre><code>CREATE TABLE `url_list` ( `id` int(10) unsigned NOT NULL auto_increment, `crc32` int(10) unsigned NOT NULL, `url` varchar(512) NOT NULL, PRIMARY KEY (`id`), KEY `crc32` (`crc32`) ); </code></pre> <p>When inserting data into a related table I need to loo...
<p>I would recommend ditching the <code>id</code> column and the <code>crc32</code> because they're not necessary.</p> <p>You can use an <code>MD5()</code> hash to provide a fixed-length, virtually unique value computed from the lengthy URL data, and then use that hash as the primary key.</p> <pre><code>CREATE TABLE ...
<p><a href="http://blogs.msdn.com/miah/archive/2008/02/17/sql-if-exists-update-else-insert.aspx" rel="nofollow noreferrer">This website</a> offers a solution to a similar problem.</p>
41,054
<p>I am building a web page to show a customer what software they purchased and to give them a link to download said software. Unfortunately, the data on what was purchased and the download information are in separate databases so I can't just take care of it with joins in an SQL query.</p> <p>The common item is SKU....
<p>As long as the two databases are on the same physical server (assuming MSSQL) and the username/password being used in the connection string has rights to both DBs, then you should be able to perform a join across the two databases. Example: </p> <pre><code>select p.Date, p.Amount, d.SoftwareName, ...
<p>I am thinking off the top of my head here. If you load both as Data Tables in the same Data Sets, and define a relation between the two over SKU, and then run a query on the Data Set which produces the desired result.</p>
2,445
<p>I'm looking for a cross-browser method - I know IE has something (I've already forgotten what), and the way to do it in Mozilla may have to do with a focusNode thing I found, that seems related to getting text selections.</p> <p>Methods involving jQuery or another common JS library are fine by me.</p> <p>Thanks!</...
<p>Check out the <a href="http://www.softwareunity.com/sandbox/JQueryMoreSelectors/" rel="nofollow noreferrer">extra selectors plugin</a> for <a href="https://jquery.com/" rel="nofollow noreferrer">jQuery</a>, it includes a <code>:focus</code> selector that answers your need. You can use just the implementation of that...
<p>OK then, so use jQuery.</p> <p>There is no current, available way to just ask this. You need to track the focus events when they happen, so this sample (thanks to Karl Rudd <a href="http://groups.google.com/group/jquery-en/browse_thread/thread/e31e21ba4ef3160c/21c2d4c016336fad?lnk=raot&amp;pli=1" rel="nofollow nore...
18,241
<p>What is the best way to scale a 2D image array? For instance, suppose I have an image of 1024 x 2048 bytes, with each byte being a pixel. Each pixel is a grayscale level from 0 to 255. I would like to be able to scale this image by an arbitrary factor and get a new image. So, if I scale the image by a factor of 0.68...
<p>There is no simple way of accomplishing this. Neither <a href="http://en.wikipedia.org/wiki/Image_scaling" rel="nofollow noreferrer">scaling</a> nor rotating are trivial processes.</p> <p>It is therefore advisable to use a 2d imaging library. <a href="http://www.imagemagick.org/Magick++/" rel="nofollow noreferrer">M...
<pre><code>point scaling(point p,float sx,float sy) { point s; int c[1][3]; int a[1][3]={p.x,p.y,1}; int b[3][3]={sx,0,0,0,sy,0,0,0,1}; multmat(a,b,c); s.x=c[0][0]; s.y=c[0][1]; return s; } </code></pre>
38,333
<p>The fundamental equation of weight loss/gain is:</p> <pre><code>weight_change = convert_to_weight_diff(calories_consumed - calories_burnt); </code></pre> <p>I'm going on a health kick, and like a good nerd I thought I'd start keeping track of these things and write some software to process my data. I'm not attenti...
<p>Look at <a href="http://www.fourmilab.ch/hackdiet/www/hackdiet.html" rel="nofollow noreferrer">The Hacker's Diet</a> and <a href="http://www.physicsdiet.com/" rel="nofollow noreferrer">physicsdiet.com</a> - this wheel has already been invented.</p>
<p>I dunno how accurate this is because it's Wikipedia but it looks like a good basis for a rule-of-thumb-o-meter.</p> <p><a href="http://en.wikipedia.org/wiki/Food_energy" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Food_energy</a></p>
28,850
<p>In Ruby (forgive me for mentioning it's name) I noticed you could do a anchor link with "link to unless current", which would remove the link if it was the current page.</p> <p>I know there's nothing built into CodeIgniter to do something similar, but I'm trying to come up with the best way to do this. I've got a f...
<p>Why not write your own helper that follows the html helper link_tag checker... put one more condition inside there to check if your in the current controller. Looking at codeIgniter with xdebug, the object returned by get_instance provides access to pretty much everything the controller had. so ci->router->uri->rs...
<p>You can</p> <p>A. Use an if statement around the link</p> <p>or</p> <p>B. Make your own function</p> <p>CodeIgniter is a significantly smaller framework than ruby on rails as far as features go. I doubt they have a copy of every useful function rails has. </p>
33,058
<p>I have a validation control that has the following expression:</p> <pre><code>(?=(.*\\d.*){2,})(?=(.*\\w.*){2,})(?=(.*\\W.*){1,}).{8,} </code></pre> <p>That's a password with at least <strong>2 digits</strong>, <strong>2 alpha characters</strong>, <strong>1 non-alphanumeric</strong> and <strong>8 character minimum...
<p><code>(?=(.*\W.*){0,})</code> is not 0 non-alphanumeric characters. It is <em>at least 0</em> non-alphanumeric characters. If you wanted the password to not contain any non-alphanumeric characters you could do either <code>(?!.*\W)</code> or <code>(?=\w*$)</code>.</p> <p>A simpler solution would be to skip the <cod...
<p>How about one of the existing jQuery based password strength validators - like: <a href="http://scripts.simplythebest.net/4/Ajax-Password-Strength-Meter-software.html" rel="nofollow noreferrer">http://scripts.simplythebest.net/4/Ajax-Password-Strength-Meter-software.html</a></p>
24,247
<p>During the load of my cocoa application, my program crashes with the messsage EXC_BAD_ACCESS. The stack trace is not helpful. Any clues to how I can find the problem?</p>
<p>I've seen times where this can happen when you are trying to access a object that you didn't retain properly so its either not pointing to a valid copy of your object or its pointing to an object of another type. Placing breakpoints early and analyzing the objects as you step through startup using po and print in gd...
<p>This is one possible reason. There is a IBOutlet object that isn't being initialized and a message is being invoked on nil. The stack trace might look like this:</p> <pre><code>#0 0x90a594c7 in objc_msgSend #1 0xbffff7b8 in ?? #2 0x932899d8 in loadNib #3 0x932893d9 in +[NSBundle(NSNibLoading) _loadNib...
9,054
<p>I need a short code snippet to get a directory listing from an HTTP server.</p> <p>Thanks</p>
<p>A few important considerations before the code:</p> <ol> <li>The HTTP Server has to be configured to allow directories listing for the directories you want;</li> <li>Because directory listings are normal HTML pages there is no standard that defines the format of a directory listing;</li> <li>Due to consideration <s...
<p>You can't, unless the particular directory you want has directory listing enabled and no default file (usually index.htm, index.html or default.html but always configurable). Only then will you be presented with a directory listing, which will usually be marked up with HTML and require parsing.</p>
15,150
<p>I'm missing something here, but I've stared at it too long to see it. I've got a simple ListView, with the typical Edit/Update/Cancel buttons. I've got the following set up in my EditITemTemplate when the row goes into edit mode:</p> <pre><code>&lt;EditItemTemplate&gt; &lt;asp:Label ID="AccountIdLabel" runat="s...
<p>Found it - I had code in the ItemCommand event that was handling other events, but it was doing the GetData() at the end regardless of the command, so basically the data was being refreshed right before the ItemUpdating event fired. I tightened up ItemCommand, and it's now working as expected.</p>
<p>I think this is because the ItemUpdating event fires before the ListView updates the record. You probably want to put this code in the ItemUpdated event instead.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.itemupdating.aspx" rel="nofollow noreferrer">http://msdn.micro...
41,656
<p>I am particularly interested in Document Libraries, but in terms of general SharePoint lists, can anyone answer the following...?</p> <ol> <li>What is the maximum number of items that a SharePoint list can contain?</li> <li>What is the maximum number of lists that a single SharePoint server can host?</li> <li>When ...
<p>In SharePoint v.2:</p> <ul> <li><strong>Max # list items</strong> : 2000 (per folder level)</li> <li><strong>Max lists per site</strong> : 2000 is a "reasonable" number</li> <li><strong>Effect when we reach the limit</strong> : Exponential degradation of performance.</li> </ul> <p>More info: <a href="http://techn...
<p>Beware, the Performance of SiteDataQuery degrades heavily he more subsites you have. A hundred subsites can take 20 seconds to query.</p>
5,509
<p>I am using Java back end for creating an XML string which is passed to the browser. Currently I am using simple string manipulation to produce this XML. Is it essential that I use some XML library in Java to produce the XML string? I find the libraries very difficult to use compared to what I need.</p>
<p>It's not essential, but advisable. However, if string manipulation works for you, then go for it! There are plenty of cases where small or simple XML text can be safely built by hand.</p> <p>Just be aware that creating XML text is harder than it looks. Here's some criteria I would consider:</p> <ul> <li>First: how...
<p>No - especially for generating (parsing I would be less inclined to as input text can always surprise you). I think its fine - but be prepared to shift to a library should you find yourself spending more then a few minutes maintaining your own code. </p>
4,450
<p>I've been for the past few hours trying to figure out why <code>openCV</code> doesn't compile on leopard. I've been googling for references but all point to a dead google group.</p> <p>So my question is quite simple: I've read INSTALL file, read all documentation <em>i</em> could find and still couldn't figure a so...
<p>Based on the error, my suggestion is:</p> <p>Try building it in a folder that doesn't have spaces in the name.</p> <p>("/Users/fmsf/Projects/Motion Tracking/" vs "ar: /Users/fmsf/Projects/Motion: No such file or directory")</p>
<p>you may be trying 1.1. this is pretty new. consider trying 1.0. i have built 1.0 on windows and ubuntu.</p>
30,833
<p>I plan to serialize a Django model to XML when it's saved or updated. (The XML's going to be imported into a flash movie). Is it better to listen for a post_save() or pre_save() signal and then perform the serialization, or to just handle it in the model's save() methon</p>
<p>If it's core functionality for saving the model you'll want it as part of the save method. However, if you already have a functioning model and you want to extend it for other purposes then signals are your best bet since they allow for properly decoupled modules.</p> <p>A good example might be that you want to add...
<p>Post save. That way the new data (the reason for performing the serialization) is already in the database. It'll make for a much cleaner bit of code that simply takes from the database and doesn't have to worry about adding an extra value.</p> <p>The other way that comes to mind is to maintain the xml file in paral...
15,940
<p>What is the most efficient way of setting values in C# multi-dimensional arrays using a linear index? For example given an array...</p> <pre><code>int[,,] arr2 = { {{0,1,2}, {3,4,5}, {6,7,8}} , {{9,10,11}, {12,13,14}, {15,16,17}} , {{18,19,20}, {21,22,23}, {24,25,26}} }; </...
<p>why do you need the IList ? </p> <pre><code>static void SetValue2(this Array a, object value, int i) { int[] indices = new int[a.Rank]; for (int d = a.Rank - 1; d &gt;= 0; d--) { var l = a.GetLength(d); indices[d] = i % l; i /= l } a.SetValue(value, indices); } </code></pre> ...
<p><code>SetValue()</code> should work. Take a look at <a href="http://msdn.microsoft.com/en-us/library/758awxk7.aspx" rel="nofollow noreferrer">this</a> for a little more inspiration.</p> <p>EDIT: Could you not just do</p> <pre><code>{{30,30,30}, {30,30,30}, {30,30,30}} , {{30,30,30}, {30,30,30}, {30,30,30}} , {{...
46,956
<p>Is there ever a good reason to <em>not</em> declare a virtual destructor for a class? When should you specifically avoid writing one?</p>
<p>There is no need to use a virtual destructor when any of the below is true:</p> <ul> <li>No intention to derive classes from it</li> <li>No instantiation on the heap</li> <li>No intention to store with access via a pointer to a superclass</li> </ul> <p>No specific reason to avoid it unless you are really so pressed ...
<p>The performance answer is the only one I know of which stands a chance of being true. If you've measured and found that de-virtualizing your destructors really speeds things up, then you've probably got other things in that class that need speeding up too, but at this point there are more important considerations. ...
38,593
<h1>My situation</h1> <ul> <li>Input: a set of rectangles </li> <li>each rect is comprised of 4 doubles like this: (x0,y0,x1,y1)</li> <li>they are not "rotated" at any angle, all they are "normal" rectangles that go "up/down" and "left/right" with respect to the screen</li> <li>they are randomly placed - they may be t...
<p>An efficient way of computing this area is to use a sweep algorithm. Let us assume that we sweep a vertical line L(x) through the union of rectangles U: </p> <ul> <li>first of all, you need to build an event queue Q, which is, in this case, the ordered list of all x-coordinates (left and right) of the rectangles. <...
<p>You can find the overlap on the x and on the y axis and multiply those. </p> <pre><code>int LineOverlap(int line1a, line1b, line2a, line2b) { // assume line1a &lt;= line1b and line2a &lt;= line2b if (line1a &lt; line2a) { if (line1b &gt; line2b) return line2b-line2a; else if (line1b &gt; line2...
30,314
<p>Today I had a coworker suggest I refactor my code to use a label statement to control flow through 2 nested for loops I had created. I've never used them before because personally I think they decrease the readability of a program. I am willing to change my mind about using them if the argument is solid enough howev...
<p>Many algorithms are expressed more easily if you can jump across two loops (or a loop containing a switch statement). Don't feel bad about it. On the other hand, it may indicate an overly complex solution. So stand back and look at the problem.</p> <p>Some people prefer a "single entry, single exit" approach to all...
<p>Personally whenever I need to use nested loops with the innermost one having to break out of all the parent loops, I just write everything in a method with a return statement when my condition is met, it's far more readable and logical.</p> <p>Example Using method:</p> <pre class="lang-java prettyprint-override"><co...
6,864
<p>What would be the disadvantages (if any) of automating business process for a Enterprise/organization?</p>
<ul> <li>Loosing discretionary error checking, i.e. numbers that look out of line;</li> <li>Potentially, knowledge of how a process is operated could be lost if it is automated but not documented. More often than not, manual processes are passed on;</li> <li>Accountability for the process becomes muddled.</li> </ul>
<p>Automating a business process just for the sake of automation is a fools errand. And is likely to cost your business A LOT (in every way you can imagine - financial impact, business disruption, new technical issues, morale, etc...).</p> <p>Without care, automating a business process can:</p> <ul> <li>cost lots of...
28,376
<p>I need to encrypt a small block of data (16 bytes) using 512 bit RSA public key -- quite an easy task for most cryptography libraries known to me, except for MS CSP API, as it seems. Documentation for <a href="http://msdn.microsoft.com/en-us/library/aa379924(VS.85).aspx" rel="nofollow noreferrer">CryptEncrypt</a> fu...
<p>For who still needs this: I just created this article here that shows how to do it in WPF. <a href="http://www.codeproject.com/Articles/642151/Pixel-shaders-in-a-background-thread-in-WPF" rel="nofollow">http://www.codeproject.com/Articles/642151/Pixel-shaders-in-a-background-thread-in-WPF</a></p> <p>The relevant co...
<p>What is generally done in C++ / DirectX to achive this is:</p> <p>Preparation (done once)</p> <ul> <li>Create render target using CreateRenderTarget</li> <li>Create off-screen surface using CreateOffscreenPlainSurface</li> <li>Set render target surface using SetRenderTarget</li> <li>Create any other input resources ...
37,742
<p>Based on several report parameters in SQL Server 2005 reporting services, I would like to automatically generate one or several chart(s) for each row in the return result and paginate or space them out. How do I go about that?</p>
<p>If the number of charts will vary for each row, but the variations are known (e.g. it's either just chart 1, or chart 1 and 3, or charts 1 2 and 3) then it's simple enough using a table.</p> <p>In the default detail row add any normal fields you need. Now insert a new detail row for each chart you might need. Lastl...
<p>What you can do is place a <a href="http://msdn.microsoft.com/en-us/library/ms159121(SQL.90).aspx" rel="nofollow noreferrer">List control</a> on the page, set <a href="http://msdn.microsoft.com/en-us/library/ms159660(SQL.90).aspx" rel="nofollow noreferrer">List grouping</a> by record unique key (ID, or several field...
18,801
<p>As much as I generally don't like the discussion/subjective posts on SO, I have really come to appreciate the "Hidden Secrets" set of posts that people have put together. They provide a great overview of some commonly missed tools that you might now otherwise discover.</p> <p>For this question I would like to expl...
<p>One of my favorite features is the <a href="http://msdn.microsoft.com/en-us/library/232dxah7(VS.80).aspx" rel="noreferrer">"When Hit..."</a> option available on a breakpoint. You can print a message with the value of a variable along with lots of other information, such as:</p> <ul> <li><code>$ADDRESS</code> - Cur...
<p>You can open and place a breakpoint in a source file if the file belongs to another solution (external file). The debugger can still hit the breakpoint. No need to open another Visual Studio instance to debug the external file. Helpful in debugging web services which you source to. This works as long as all the sour...
15,937
<p>We have a web application, which involves a lot of documents. In a typical use case, a document will be generated from our web application. The user download the generated document to the local file system and modify it. After this work, the user upload the modified document back to the web application. </p> <p>I n...
<p>I don't think this is possible without a plugin. I've used activex in the past, maybe it would be possible to write a cross-platform java applet?</p>
<p>You can use google docs that give the facility of editing the documents. This is free and you can use it in your web application also. you just have to reference the dlls.</p> <p>Please see the following link for more details.<br /> <a href="http://code.google.com/apis/documents/docs/2.0/developers_guide_dotnet.htm...
39,810
<p>I have a report that is used by a windows service and a form application. So, I want to put embed the report in a DLL file that can be used by both.</p> <p>The problem is that if I try to set the ReportEmbeddedResource property of a ReportViewer control in my windows form app, it will search the windows form app f...
<p>Something like this should do it:</p> <pre><code>Assembly assembly = Assembly.LoadFrom("Reports.dll"); Stream stream = assembly.GetManifestResourceStream("Reports.MyReport.rdlc"); reportViewer.LocalReport.LoadReportDefinition(stream); </code></pre>
<p>Probably the best thing to do would be to get a stream to the RDLC resource from the other assembly, then pass that to the "LoadReportDefinition" method of the Report Viewer control.</p> <p>Details of how to get a stream from an embedded resource in a different assembly can be found here : <a href="http://msdn.micr...
31,632
<p>Under Linux, my C++ application is using fork() and execv() to launch multiple instances of OpenOffice so as to view some powerpoint slide shows. This part works.</p> <p>Next I want to be able to move the OpenOffice windows to specific locations on the display. I can do that with the XMoveResizeWindow() function bu...
<p>The only way I know to do this is to traverse the tree of windows until you find what you're looking for. Traversing isn't hard (just see what xwininfo -root -tree does by looking at xwininfo.c if you need an example). <p> But how do you identify the window you are looking for? <b>Some</b> applications set a windo...
<p>If you use python, I found a way <a href="https://bbs.archlinux.org/viewtopic.php?id=113346" rel="nofollow noreferrer">here</a>, the idea is from <a href="https://github.com/BurntSushi/" rel="nofollow noreferrer">BurntSushi</a></p> <p>If you launched the application, then you should know its cmd string, with which ...
18,249
<p>Can you please let me know the SQL to split date ranges when they overlap?</p> <p>Data (sample data with a date range and possibly other columns):</p> <pre><code> Col1 FromDate ToDate 1. 1 1/1/2008 31/12/2010 2. 1 1/1/2009 31/12/2012 3. 1 1/1/2009 31/12/2014 </code></pre> <p>Output:</p> <pre><code...
<p>This should do the trick (MySQL dialect, but easily adaptable)</p> <p>Initial setup</p> <pre><code>SQL query: SELECT * FROM `test` LIMIT 0, 30 ; Rows: 3 start end 2008-01-01 2010-12-31 2009-01-01 2012-12-31 2009-01-01 2014-12-31 </code></pre> <p>Query</p> <pre><code>SELECT `start` , min( `end` ) FROM...
<p>Skliwz's answer adapted for SQL Server:</p> <pre><code>DECLARE @DateTest TABLE ( FromDate datetime, ToDate datetime ) insert into @DateTest (FromDate, ToDate) ( select cast('1/1/2008' as datetime), cast('12/31/2010' as datetime) union select cast('1/1/2009' as datetime), cast('12/31/2012' as datetime) un...
22,386
<p>I've got a Subversion repository, backed by the berkeley DB. Occasionally it breaks down due to some locks and such not being released, but this morning it was impossible to recover it using the 'svnadmin recover' command. Instead it failed with the following error:</p> <pre><code>svnadmin: Berkeley DB error for fi...
<blockquote> <p>I've got a Subversion repository, backed by the berkeley DB.</p> </blockquote> <p>Sorry to hear that. I would suggest that at your earliest convenience, you dump that repository (<code>svnadmin dump</code>) and reload it into a new one backed by FSFS (<code>svnadmin load</code>).</p>
<p>have you tried <a href="http://www.google.com/search?q=man+db_recover" rel="nofollow noreferrer">db_recover</a>? the latter tends to be able to correct more issues than svnadmin</p>
14,568
<p>I have some code which returns InnerXML for a XMLNode.</p> <p>The node can contain just some text (with HTML) or XML.</p> <p>For example:</p> <pre><code>&lt;XMLNode&gt; Here is some &amp;lt;strong&amp;gt;HTML&amp;lt;/strong&amp;gt; &lt;XMLNode&gt; </code></pre> <p>or</p> <pre><code>&lt;XMLNode&gt; &lt;X...
<p>why not inserting them as &amp;lt; and &amp;gt; ? you avoid mixing xml and custom markup stuff with this...</p>
<p>why not inserting them as &amp;lt; and &amp;gt; ? you avoid mixing xml and custom markup stuff with this...</p>
24,628
<p>I have a C# web application that needs to deploy a file to the client computer's hard drive. (A javascript file for Adobe Acrobat)</p> <p>If the client is using a mac, I have an applescript that will search their applications directory for acrobat and then deploy the JS file in the correct location.</p> <p>The pro...
<p>I can't think of a good way to dynamically generate an AppleScript (especially on a non-Mac OS platform), but couldn't you have the C# (ASP.NET?) server write to a file, and have the AppleScript read the message from that?</p>
<p>I can't think of a good way to dynamically generate an AppleScript (especially on a non-Mac OS platform), but couldn't you have the C# (ASP.NET?) server write to a file, and have the AppleScript read the message from that?</p>
34,620
<p>I'm starting work on a program which is perhaps most naturally described as a batch of calculations on database tables, and will be executed once a month. All input is in Oracle database tables, and all output will be to Oracle database tables. The program should stay maintainable for many years to come.</p> <p>It ...
<p>Normally I say put as little in PL/SQL as possible - it is typically a lot less maintainable - at one of my last jobs I really saw how messy and hard to work with it could get. </p> <p>However, since it is batch processing - and since the input and output are both the DB - it makes good sense to put the logic into...
<p>It's not usually more expressive because most stored procedure languages suck by design. But it will probably run faster than in an external app.</p> <p>I guess it boils down to how familiar you are with PL/SQL, how much time you have to write this, how important is performance and if you can reasonably expect main...
10,407
<p>I know I can configure command line arguments in the Run configuration but I want to run a java file multiple times with different command line arguments. It's a pain to change the Run Configuration every time.</p> <p>Is there a way I can make Eclipse prompt me for command line arguments every time I run the progra...
<p>Add <code>string_prompt</code> as a <code>Program Argument</code> in the <code>Run</code> configuration.</p> <pre><code> ${string_prompt} </code></pre> <p>There are also a <code>file_prompt</code> and a <code>folder_prompt</code> if you want specifically files\folders.</p> <p>These are available through the <code...
<p>In addition you can add a string to the prompt by using ${string_prompt:My Prompt Text} which will show the dialog box with 'Please input a value for My Prompt Text'.</p>
40,385
<p>Is there a more concise/standard idiom (e.g., a JDK method) for "piping" an input to an output in Java than the following?</p> <pre><code>public void pipe(Reader in, Writer out) { CharBuffer buf = CharBuffer.allocate(DEFAULT_BUFFER_SIZE); while (in.read(buf) &gt;= 0 ) { out.append(buf.flip()); ...
<p><a href="http://commons.apache.org/io/" rel="noreferrer">IOUtils</a> from the Apache Commons project has a number of <a href="http://commons.apache.org/io/api-1.4/org/apache/commons/io/IOUtils.html" rel="noreferrer">utilily methods</a> that do exactly what you need.</p> <p><code>IOUtils.copy(in, out)</code> will pe...
<p>Take a look at <a href="http://java.sun.com/javase/6/docs/api/java/io/PipedInputStream.html" rel="nofollow noreferrer">java.io.PipedInputStream</a> and <a href="http://java.sun.com/javase/6/docs/api/java/io/PipedOutputStream.html" rel="nofollow noreferrer">PipedOutputStream</a>, or <a href="http://java.sun.com/javas...
15,550
<p>I have a 15x15 cm heating resistor from my current printer (printing area: 12x12 cm).</p> <p>I would like to switch to a glass bed and to rework my printer to increase the printing area to 20 cm (22x22 cm glass plate).</p> <p>Would it be possible to use the old heating resistor placed only in the centre? this way ...
<p>If you're using borosilicate glass (aka pyrex) then it won't crack. You can get squares of ~20x20 cheaply off aliexpress.</p> <p>If you're using window glass, picture frame class etc then you might have issues with cracking, it will depend on lots of factors like the wattage of your heater and the temperature of th...
<p>The glass will be taking up the heat to slowly cover its full area. That means two things:</p> <ol> <li>it will not crack as there is no thermal shock</li> <li>it will put more pressure on the heater as there will be bigger heat absorption, so in an edge case, you could end-up with not getting a required temperatur...
881
<p>I have a web service application which has suddenly stopped working. I have enabled directory browsing in IIS, and can view the application directory. I can view the xml files within the application directory, but I cannot view the .config files, nor can I view the wsdls of any of the web services. When I try to ...
<p>Have you looked in the server's event log? Many ASP.NET errors will end up there, this sounds like it might qualify</p>
<p>Regarding the first question about loading, are you able to browse to the site on the server?</p> <p>IIS protects Web.config files by default and will typically return a "This type of page is not served" error message. This is a good thing which will keep your connection strings and what not from being casually vie...
45,703
<p>I'm trying to run a batch file, as another user, from my web app. For some reason, the batch file hangs! I can see "cmd.exe" running in the task manager, but it just sits there forever, unable to be killed, and the batch file is not running. Here's my code:</p> <pre><code>SecureString password = new SecureString();...
<p>I believe I've found the answer. It seems that Microsoft, in all their infinite wisdom, has blocked batch files from being executed by IIS in Windows Server 2003. Brenden Tompkins has a work-around here:</p> <p><a href="http://codebetter.com/blogs/brendan.tompkins/archive/2004/05/13/13484.aspx" rel="noreferrer">htt...
<p>My guess would be that the build.cmd is waiting for some sort of user-interaction/reply. If you log the output of the command with the "<strong>> logfile.txt</strong>" operator at the end, it might help you find the problem.</p>
5,437
<p>Does anyone know if there's a way to automatically expand a list in Python, separated by commas? I'm writing some Python code that uses the MySQLdb library, and I'm trying to dynamically update a list of rows in a MySQL database with certain key values.</p> <p>For instance, in the code below, I'd like to have the ...
<p>try:</p> <pre><code>",".join( map(str, record_ids) ) </code></pre> <p><code>",".join( list_of_strings )</code> joins a list of string by separating them with commas</p> <p>if you have a list of numbers, <code>map( str, list )</code> will convert it to a list of strings</p>
<p>Alternitavely, using <em>replace</em>:</p> <pre><code>sqlStmt="UPDATE apps.sometable SET lastmod=SYSDATE() where rec_id in " + record_ids.__str__().replace('[','(').replace(']',')') </code></pre>
40,750
<p>Doing a refresh after certain action in asp.net seems to make them happen again even when that action doesn't make sense (think double delete). The web way to deal with this situation is to redirect after a post to get a clean version of the page that can be refreshed without reposting an action to the webserver. H...
<p>I have a feeling there is a deeper problem I'm not getting but here goes. In your postback event:</p> <pre><code>// the post handling logic, e.g. the click event code Response.Redirect(Request.RawUrl); </code></pre>
<p>Use Server.Transfer method.</p> <p>The Server.Transfer method has a second parameter—"preserveForm". If you set this to True, using a statement such as Server.Transfer("WebForm2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.</p> <p><a hre...
42,913
<p>The bottom of my prints warp/curve upwards, most often at the corners. This is a very slight curve, only about 1-2 mm.</p> <ul> <li>I print with a raft all the time.</li> <li>I don't have a heated bed.</li> <li>I print with PLA at 199 °C (390 °F) with a print speed of approximately 40 mm/s</li> <li>I have a Sindoh 3...
<p><strong>The first thing to understand is what causes warping</strong>. Warping is caused by the thermal contraction of the plastic when it cools down.</p> <p>Simplifying things a fair bit, you can visualise the process like this:</p> <ol> <li>hot, expanded plastic gets deposited on cooler, shrunk layers,</li> <li...
<p>If you have a heat bed, heat it up accordingly (for example for PLA 50 °C first layers, 40 °C then can be a good starting point).</p> <p>If the first layer isn't close enough, then warping can happen (Happened to me when moving from 0.3 mm layers to 0.1 mm).</p> <p>If you are under extruding / have dirt in the syste...
781
<p>Could you recommend a lightweight SQL database which doesn't require installation on a client computer to work and could be accessed easily from .NET application? Only basic SQL capabilities are needed.</p> <p>Now I am using Access database in simple projects and distribute .MDB and .EXE files together. Looking for...
<p>Depends on what you mean by lightweight. Easy on Ram? Or lighter db file? Or lighter connector to connect to db? Or fewer files over all? I'll give a comparison of what I know:</p> <pre><code> no of files cumulative size of files db size Firebird 2.5 5 6.82 MB ...
<p><a href="http://www.sqlite.org/" rel="nofollow noreferrer">SQLite</a> will be what you're after</p>
34,118
<p>I have the following code</p> <pre><code>Try 'Some code that causes exception Catch ex as ExceptionType1 'Handle Section - 1 Catch ex as ExceptionType2 'Handle section - 2 Catch ex as ExceptionType3 'Handle section - 3 Finally ' Clean up End Try </code></pre> <p>Suppose ExceptionType1 is th...
<p>Change the code to catch all the exceptions in one block and determine the type and execution path from there. </p>
<p>I think you could get the behavior you want if you do nested try blocks. Once an exception is thrown, execution goes to the catch block. If nothing is rethrown, it moves on to finally. </p>
47,512
<p>I'm just starting out with F# and I can't find the syntax to do object initialization like in C# 3. </p> <p>I.e. given this:</p> <pre><code>public class Person { public DateTime BirthDate { get; set; } public string Name { get; set; } } </code></pre> <p>how do I write the following in F#:</p> <pre><code>var ...
<p>You can do it like this:</p> <pre><code>let p = new Person (Name = "John", BirthDate = DateTime.Now) </code></pre>
<p>You can also omit the <code>new</code> keyword and use less verbose syntax: </p> <pre><code>let p = Person(BirthDate = DateTime.Now, Name = "John") </code></pre> <p><a href="https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/members/constructors" rel="nofollow noreferrer">https://learn.microsoft.co...
48,609
<p>I want to write a simple utility to upload images to various free image hosting websites like TinyPic or Imageshack via a right-click context menu for the file.</p> <p>How can I do this using .NET? I've seen some linux scripts that use cURL to post images to these website but I'm not sure how I could create the po...
<p>Use HttpWebRequest.</p> <p>Using this class, you can POST data to a remote HTTP address, just set the mime/type to multi-part/form encoded, and post the binary data from the image with the request.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(VS.71).aspx" rel="nofollow noreferr...
<p><a href="http://tinypic.com" rel="nofollow noreferrer">TinyPic.com</a> doesn't have an API as far as I know, but the Cropper SendToTinyPic Plugin tries to upload using "Screen scraping". The official version of the plugin doesn't work right now, but I put together a patch using the same approach, and submitted it to...
34,740
<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>I just became curious after seeing several tests 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...
<p>Because 0 is false and null in C/C++ and you can make handy short cuts when that happens.</p>
42,743