instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>From the documentation, I would expect adModeShareDenyWrite to be the way, but it's not working right.</p> <p>I'm using an Access database via ADO. My connection string says Mode=8, which is adModeShareDenyWrite. But when I try to delete a row from a table, I get:</p> <p>Unspecified error, Description:Could no...
<p>Cory Trager wrote:</p> <blockquote> <p>My motivation here is to minimize the chances of database corruption. One of the causes of mdb file corruption documented by Microsoft is two apps writing to the same db. So, I want to make sure that only one app can have a write connection to the db. Others can ...
<p>One solution is to give them access to a copy of the database. They can change whatever they want, but it won't keep past your copying it over with the master.</p>
19,919
<p>I browsed around here on Stackoverflow and found this topic : <a href="https://stackoverflow.com/questions/279/aspnet-visual-studio-and-subversion-how-to-integrate">https://stackoverflow.com/questions/279/aspnet-visual-studio-and-subversion-how-to-integrate</a></p> <p>However that didn't help me in my case, or i mi...
<p>It's possible. The Berkeley DB is used at the repository side, but it doesn't really affect the client side. Subversion creates .svn folders everywhere, so if you don't like that use <a href="http://samba.anu.edu.au/rsync/" rel="nofollow noreferrer">rsync</a>.</p> <p>Edit: I missed the part you already have <a href...
<p>What you need is a post-commit hook, they're small batch files that live in the repository's folders (there should be placeholder files in the hooks subfolder)</p> <p>You set up the post commit hook to checkout the repository to a folder on your server and point your webserver to that same folder. </p>
47,912
<p>In all the bigger prints I print on my Ender 5 with PETG I have problems with warping and raft detachment during printing. I have a glass bed and I'm using Ultimaker Cura 4.6.1 standard printing settings for PETG (Recently I had some success using 245 °C nozzle temperature and 80 °C build plate).</p> <p>Any ideas ho...
<p>Every print is somewhat affected by chamber temperature. On small prints, or prints with lower-temperature materials, the improvement is minor.</p> <p>However, large prints with higher-temperature materials (like PETG) really benefit from a heated chamber. This helps by keeping the entire build close to the glass tr...
<p>This sounds like a bed leveling issue. As reported by others, I get much less warping with PETG than with ABS or even PLA, and deal with too much adhesion with PETG rather than too little. With a Reprap x400, I printed a faceplate for the extruder to hold a electronic drop indicator. This gives me much higher pre...
1,732
<p>I have been recommended <a href="http://www.heaventools.com/command-line_resource_editor.htm" rel="nofollow noreferrer">"Resource Tuner console"</a> but it's a little out of my price range.</p> <p>I'm looking for something that could be launched from a nant build script and told to stamp an exe with an additional p...
<p>Resource hacker can be found here, btw: <a href="http://www.angusj.com/resourcehacker/" rel="nofollow noreferrer">http://www.angusj.com/resourcehacker/</a></p>
<p>Hi my name is Archit and few monts age i felt for same question... Now, There are many tools which will give you command line editing , Resource hacker : Free and good one, it provides scripting and saving resources go through help file where u get hell lot of examples about that , by the way u only asked for cheap ...
24,447
<p>I have this SQL query:</p> <pre><code>SELECT * FROM IMAGES WHERE IMAGENAME in ('IMG1', 'IMG2', 'IMG3', 'IMG4', 'IMG5', 'IMG6') ORDER BY CASE IMAGENAME WHEN 'IMG1' THEN 1 WHEN 'IMG2' THEN 2 WHEN 'IMG3' THEN 3 WHEN 'IMG4' THEN 4 WHEN 'IMG5' THEN 5 WHEN 'IMG6' THEN 6 ELSE 7 END </code></pre> <p>I cannot...
<p>I'm not sure if this is available in your target databases, but it might hopefully work at least as inspiration for a better approach. In MySQL, you would do what you want with the FIELD() function like this:</p> <pre><code>SELECT * FROM IMAGES WHERE IMAGENAME IN ('IMG1', 'IMG2', 'IMG3', 'IMG4', 'IMG5', 'IMG6') ...
<p>Could you strip the <code>IMG</code> (or non-numeric) part of the <code>IMAGENAME</code> to a new column when writing to the database, then sort on the new numeric-only column?</p> <p>For example:</p> <pre><code>SELECT * FROM IMAGES WHERE IMAGENAME in ('IMG1', 'IMG2', 'IMG3', 'IMG4', 'IMG5', 'IMG6') ORDER BY IMAGE...
38,694
<p>I have a prusa i3 and have been trying to calibrate it. I have been trying to upload the new steps per mm and I get to done uploading. However when I go into Repetier host and type M503 to get the printers settings it still shows the steps as 100 for the y axis, it needs to be 96.1810. I am using ramps 1.4 I think, ...
<p><a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8" rel="nofollow">See here</a> for why you <em>shouldn't</em> calibrate your X/Y-steps. The value of 100 is probably better and will give more accurate prints overall than the value you came up with.</p> <p>When uploading new firmware you generally do not have to p...
<p><a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8" rel="nofollow">See here</a> for why you <em>shouldn't</em> calibrate your X/Y-steps. The value of 100 is probably better and will give more accurate prints overall than the value you came up with.</p> <p>When uploading new firmware you generally do not have to p...
351
<p>The goal is to take the current working directory split it at <code>/clients/</code> and see if the user is in</p> <pre>[something]/clients/[their username]/[something]</pre> <p>for example, the goal would be for input:</p> <pre><code>cwd = "/volumes/raid0/www/clients/mikey/test_folder/" $session-&gt;username = "...
<p>There is no need to use regular expressions here, you're looking for a string in another string. So that would be something like:</p> <pre><code>$isAuthorized = strpos(str_replace('\\', '/', getcwd()), "/clients/$username/") !== FALSE; </code></pre>
<p>Does your regex try to account for backslashes in the paths too? That's probably not necessary. Then you can split on:</p> <pre><code>'%/clients/%' </code></pre> <p>(You shouldn't need to escape the regular slash since you use % as the regex delimiter.)</p>
49,067
<p>I currently have code in my ApplicationController to check if a user is logged in and has the required access to perform a given action (the tests take place in a before_filter).</p> <p>I require the same functionality in the views to decide if I should be showing the admin links in a list view, but how do I best a...
<p>I would say do away with the wrappers and just call <em>can_edit_customers?</em> directly on the user object passed to the view. </p> <p>If you want to keep them a solution might be to use <strong><a href="http://api.rubyonrails.org/classes/ActionController/Helpers/ClassMethods.html#M000323" rel="nofollow noreferre...
<p>I think helpers are the way to do what you want. As for checking in views whether the user has or not the priviledge to do something, you could put a flag in your session data (e.g. <code>session[:admin] = true</code> and check that in your view.</p>
49,389
<p>Apparently I can't move files on different volumes using Directory.Move.</p> <p>I have read that I have to copy each file individually to the destination, then delete the source directory.</p> <p>Do I have any other option?</p>
<p>Regardless of whether or not Directory.Move (or any other function) performed the move between volumes, it would essentially be doing a copy and delete anyway underneath. So if you want a speed increase, that's not going to happen. I think the best solution would be to write your own reusable move function, which w...
<p>Try to use this:</p> <pre><code>public static void RobustMove(string sourceDirectory, string destDirectory) { //move if directories are on the same volume if (Path.GetPathRoot(source) == Path.GetPathRoot(destination)) { Directory.Move(source, destination); } else { Co...
49,565
<p>I recently burnt out one of the MOSFETS on my RAMPS 1.4 board on my Sintron Kossel clone so have upgraded it to a RAMPS 1.6. Now my printer seems to only print 50 % of the intended size.</p> <p>After the machine homes it only comes down about 50 % of the distance and so starts printing in mid air.</p> <p>I thought i...
<p>Data from Firmware is not written into EEPROM on its own after updating your firmware. You need to send a <code>M502</code> to &quot;seed&quot; the firmware numbers as that is restoring the &quot;default&quot; settings in it. If you are unsure what is currently the EEPROM setting, use <code>M503</code> first.</p>
<p>If you changed you stepper drivers here's a list to check:</p> <ol> <li>Microstepping Jumpers</li> <li>In Marlin Configuration.h:</li> </ol> <ul> <li><code>X_DRIVER_TYPE</code>, <code>Y_DRIVER_TYPE</code>, <code>Z_DRIVER_TYPE</code> and<br /> <code>E0_DRIVER_TYPE</code></li> <li><code>DEFAULT_AXIS_STEPS_PER_UNIT</co...
2,164
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/76760/vs2008-setup-project-shared-by-all-users-application-data-files">VS2008 Setup Project: Shared (By All Users) Application Data Files?</a> </p> </blockquote> <p>Please can someone advice what is the best pl...
<p><a href="https://stackoverflow.com/questions/76760/vs2008-setup-project-shared-by-all-users-application-data-files">VS2008 Setup Project: Shared (By All Users) Application Data Files?</a></p>
<p>You can also put it in a database. </p>
20,154
<p>I curious to how different people solve integration of systems. I have a feeling that the last years more and more work has gone into integrating systems and that this kind of work need will increase as well.</p> <p>I wondering if you solve it developing your own small services that are then connected or if you use...
<p>wow - Ok - will get a post on this but will be big.</p> <p>Intergration needs to be backed up with a big understanding by the business on the benefits - Get an opertating model sorted out - as the business may acutally need to standardise instead of intergrate, as this can be costly - its why most SOA fail! <a href...
<p>In my experience it depends on what kind of problem you are tacking.</p> <p>In my experience it's difficult to beat BizTalk 2006 R2 for bang for the buck but it does imply the use of a Microsoft technology stack.</p> <p>Websphere MQ seems to be an easier sell to larger corporates and it probably seen greater use a...
3,311
<p>I've seen a lot of questions around that use improperly the expression "C/C++". The reasons in my opinion are: </p> <ul> <li>Newbie C and C++ programmers probably don't understand the difference between the two languages.</li> <li>People don't really care about it since they want a generic, quick and "dirty" answer...
<p>C/C++ is a holdout from the early days of C++, where they were much more similar than they were today. It's something that wasn't really wrong at first, but is getting more-so all the time.</p> <p>The basic structure is similar enough that most simple questions do still work between the two, though. There is an ent...
<p>Not only these two languages are different, but also the approaches are different. C++ is an OO language, while C is procedural language.</p> <p>Do I have to mention templates?</p> <p>Also, there are differences in C and C++ standards. If something is good in C, doesn't have to compile in C++</p>
21,649
<p>I'm trying to inverse a matrix with version Boost boost_1_37_0 and MTL mtl4-alpha-1-r6418. I can't seem to locate the matrix inversion code. I've googled for examples and they seem to reference lu.h that seems to be missing in the above release(s). Any hints?</p> <p><a href="https://stackoverflow.com/users/8643/mat...
<p>Looks like you use <code>lu_factor</code>, and then <code>lu_inverse</code>. I don't remember what you have to do with the pivots, though. From the <a href="http://www.osl.iu.edu/research/mtl/reference/html/index.html" rel="nofollow noreferrer">documentation</a>.</p> <p>And yeah, like you said, it looks like thei...
<p>I've never used boost or MTL for matrix math but I have used JAMA/<a href="http://math.nist.gov/tnt/" rel="nofollow noreferrer">TNT</a>.</p> <p>This page <a href="http://wiki.cs.princeton.edu/index.php/TNT" rel="nofollow noreferrer">http://wiki.cs.princeton.edu/index.php/TNT</a> shows how to take a matrix inverse. ...
43,811
<p>My question is what do most developers prefer for error handling, Exceptions or Error Return Codes. Please be language(or language family) specific and why you prefer one over the other.</p> <p>I'm asking this out of curiosity. Personally I prefer Error Return Codes since they are less explosive and don't force use...
<h1>For some languages (i.e. C++) Resources leak should not be a reason</h1> <p>C++ is based on RAII.</p> <p>If you have code that could fail, return or throw (that is, most normal code), then you should have your pointer wrapped inside a smart pointer (assuming you have a <em>very good</em> reason to not have your obj...
<p>For a language like Java, I would go with Exception because the compiler gives compile time error if exceptions are not handled.This forces the calling function to handle/throw the exceptions. </p> <p>For Python, I am more conflicted. There is no compiler so it's possible that caller does not handle the exception t...
12,488
<p>If you use the standard tab control in .NET for your tab pages and you try to change the look and feel a little bit then you are able to change the back color of the tab pages but not for the tab control. The property is available, you could set it but it has no effect. If you change the back color of the pages and ...
<p>The solution in Rajesh's blog is really useful, but it colours the tab part of the control only. In my case I had a tabcontrol on a different coloured background. The tabs themselves were grey which wasn't a problem, but the area to the right of the tabs was displaying as a grey strip. </p> <p>To change this colour...
<p>Thanks, LauraM. You helped get me on the right track. I had already found the link Oskar provided but that didn't do anything for the strip at the end.</p> <p>In the end, I had to change quite a bit because I needed a background image on the form to bleed through or if the parent was something without a backgroun...
9,287
<p>I'm executing stored procedures using SET FMTONLY ON, in order to emulate what our code generator does. However, it seems that the results are cached when executed like this, as I'm still getting a <em>Conversion failed</em> error from a proc that I have just dropped! This happens even when I execute the proc witho...
<p>Some statements will still be executed, even with <strong><code>SET FMTONLY ON</code></strong>. You "Conversion failed" error could be from something as simple as a <code>set variable</code> statement in the stored proc. For example, this returns the metadata for the first query, but throws an exception when it ru...
<ol> <li><p>This sounds like a client-side error. Do you get the same message when running through SQL Management Studio?</p></li> <li><p>Have you confirmed that there isn't another procedure with the same name that's owned by a different schema/user?</p></li> </ol>
9,764
<p>Imagine that you have a simple site with only 2 pages: login.aspx and secret.aspx. Your site is secured using nothing but ASP.net forms authentication and an ASP.net Login server control on login.aspx. The details are as follows:</p> <ul> <li>The site is configured to use the SqlMembershipProvider</li> <li>The si...
<p>You still have some variables that aren't accounted for:</p> <ul> <li>Security into the data store used by your membership provider (in this case, the Sql Server database). </li> <li>security of other sites hosted in the same IIS</li> <li>general network security of the machines involved in hosting the site, or on ...
<p>Asp.Net supports cookieless sessions, as <a href="http://stainedsole.wordpress.com/2008/02/12/cookieless-forms-authentication/" rel="nofollow noreferrer">this blog post shows</a>. Instead of a session cookie, it uses an identifier in the url to track users. </p> <p>I am not sure how secure this is, but I would thin...
16,114
<p>If unit-test names can become outdated over time and if you consider that the test itself is the most important thing, then is it important to choose wise test names?</p> <p>ie </p> <pre><code>[Test] public void ShouldValidateUserNameIsLessThan100Characters() {} </code></pre> <p>verse </p> <pre><code>[Test] publ...
<p>The name of any method should make it clear what it does.</p> <p>IMO, your first suggestion is a bit long and the second one isn't informative enough. Also it's probably a bad idea to put "100" in the name, as that's very likely to change. What about:</p> <pre><code>public void validateUserNameLength() </code></pr...
<p>The name needs to matter within reason. I don't want an email from the build saying that test 389fb2b5-28ad3 failed, but just knowing that it was a UserName test as opposed to something else would help ensure the right person gets to do the diagnosis.</p>
6,973
<p>One of the things I miss the most in ActionScript is the lack of operator overloading, in particular ==. I kind of work around this issue by adding a "Compare" method to my classes, but that doesn't help in many cases, like when you want to use things like the built in Dictionary.</p> <p>Is there a good way to work...
<p>Nope.</p> <p>But it doesn't hurt to add <code>equals</code> methods to your own classes. I try to never use <code>==</code> when comparing objects (the same goes for <code>===</code>, which is the same thing for objects) since it only checks <em>identity</em> .</p> <p>Sadly all the collections in Flash and Flex a...
<p>Yes it can be done (but be careful, its hacky): <a href="http://filimanjaro.com/2012/operators-overloading-in-as3-javascript-too-%E2%80%93-workaround/" rel="nofollow">http://filimanjaro.com/2012/operators-overloading-in-as3-javascript-too-%E2%80%93-workaround/</a></p> <p>In the tutorial I wrote about +=, -= operato...
7,381
<p>What im wondering how to do is when someone edits a list item and it goes through my event code that is fired when a change is made and save is hit, i dont want anyone to be able to edit that list item itself while its still processnig that request. So i was wondering if while in that event i can disable the individ...
<p>Not sure if I understand exactly what you are want.</p> <p>Try adding a field, hidden if you like, to the list or content type to use as a flag. When you enter your event code, make sure you check the flag first and if not set, set it and do your stuff. After you have done your stuff, unset the flag. </p> <p>Here ...
<p>I have no doubt that Bjørns solution will work but you have to be very carefull when implementing it. Pls. remember at your updating method should include a "finally" that resets the flag, no matter which exception gets thrown, other wise your list will be locked down for ever :-(</p>
37,033
<p>Looking to print a new part for a home appliance. There's going to need to be a new model created with the customizations made, but the model (after printing) will have to fit where the old part was. Is there any 3D modeling software that is better for this purpose? Will I just have to guess at proper proportions an...
<p>Here's a brief outline I threw out in chat once. I'm marking this as a &quot;community Wiki&quot; answer so feel free to edit.</p> <p>It is not a full Primer, so should date better than a Word6.0 manual.</p> <hr /> <p>Start by reading the instructions that came with your printer. There's a high chance that some as...
<p>Thera are plenty of such guides. But from necessity they deal with specifics, there are too many things to cover otherwise.</p> <p>Multiple types of printers, multiple brands, multiple slicers, multiple ways of modelling etc,. With more all the time. Reading up on something that tells me how to model and slice in Fr...
2,144
<p>I have a set of divs that I want to make <code>collapsible/expandable</code> using jQuery's <code>slideToggle()</code> method. How do I make all of these divs collapsed by default? I'd like to avoid explicitly calling <code>slideToggle()</code> on each element during/after page rendering.</p>
<p>You will have to assign a style: display:none to these layers, so that they are not displayed before javascript rendering. Then you can call slideToggle() without problems. Example:</p> <pre><code>&lt;style type="text/css"&gt; .text{display:none} &lt;/style&gt; &lt;script type="text/javascript"&gt; $(docum...
<p>Applying a CSS style behind the scenes will, as stated before, cause complications for users with scripts disabled. A way around this is to declare your element hidden as Anne said, or by defining your CSS in your script as a function to be altered, not as styling for the page (to keep structure, style and function ...
43,091
<p>We have a CMS system whose web interface gets served over HTTPS. This works beautifully for Firefox, but when we load it in IE6 or IE7, it complains that "This page contains both secure and nonsecure items."</p> <p>I've loaded the page in Firefox and checked with Firebug, and every connection seems to be going thro...
<p>Firefox has a number of bugs in mixed content detection. Generally you should try using Fiddler to spot insecure resources.</p> <p>If you install a tool I wrote (www.bayden.com/dl/scriptfreesetup.exe) you will get a different mixed content prompt which shows the exact URL of the first insecure resource on the page....
<p>If you can't see anything that isn't using SSL, then this is usually down to a broken SSL certificate somewhere. I don't know of anything off-hand that will tell you what exactly what the problem is, but you can get a list of everything that's loaded easily enough.</p> <p>The media tab on Firefox's 'page info' dial...
12,199
<p>I decide to learn more about vim and its syntax highlighting. Using examples for others, I am creating my own syntax file for Markdown. I have seen <a href="http://www.vim.org/scripts/script.php?script_id=1242" rel="noreferrer">mkd.vim</a> and it has this problem too. My issue is between list items and code block hi...
<p>Just make sure that the definition of mkdListItem is after the definition of mkdCodeBlock, like this:</p> <pre><code>syn match mkdCodeBlock /\(\s\{4,}\|\t\{1,}\).*\n/ contained nextgroup=mkdCodeBlock hi link mkdCodeBlock comment syn region mkdListItem start=/\s*[-*+]\s\+/ matchgroup=pdcListText end=".*" cont...
<p>Tao Zhyn, that maybe covers your use cases but it doesn't cover the Markdown syntax. In Markdown a list item <strong>could</strong> contain a code block. You could take a look at my solution <a href="https://github.com/gabrielelana/vim-markdown" rel="nofollow">here</a></p> <p>TL;DR; the problem is that vim doesn't ...
16,686
<p>I want to encrypt few files using python what is the best way I can use gpg/pgp using any standard/famous python libraries?</p>
<p><a href="http://www.pycrypto.org" rel="noreferrer">PyCrypto</a> seems to be the best one around.</p>
<p>I like pyDes (<a href="http://twhiteman.netfirms.com/des.html" rel="nofollow noreferrer">http://twhiteman.netfirms.com/des.html</a>). It's not the quickest, but it's pure Python and works very well for small amounts of encrypted data.</p>
11,578
<p>After an upgrade to BIRT 2.3.1 have a tons of logs:</p> <pre><code>org.eclipse.birt.report.model.metadata.ChoicePropertyType validateXml SEVERE: Not allowed choice any </code></pre> <p>Any thoughts how to rid of them will be appreciated.</p>
<p><a href="http://www.syntevo.com/git-svn/index.html" rel="nofollow noreferrer">This page</a> seems to indicate that <a href="http://www.syntevo.com/smartgit/index.html" rel="nofollow noreferrer">SmartGit</a> can do what you want. As far as I can tell, you have to do the initial init/clone from cmd/bash though.</p>
<p>I wonder if it would be possible to somehow intercept the Push command in git-gui and make it run git-svn dcommit instead? I have already added an git alias to run !git-svn dcommit.</p>
48,581
<p>I have two <code>DateTime</code> objects: <code>StartDate</code> and <code>EndDate</code>. I want to make sure <code>StartDate</code> is before <code>EndDate</code>. How is this done in C#?</p>
<pre><code>if (StartDate &lt; EndDate) // code </code></pre> <p>if you just want the dates, and not the time</p> <pre><code>if (StartDate.Date &lt; EndDate.Date) // code </code></pre>
<p>I'd like to demonstrate that if you convert to .Date that you don't need to worry about hours/mins/seconds etc:</p> <pre><code> [Test] public void ConvertToDateWillHaveTwoDatesEqual() { DateTime d1 = new DateTime(2008, 1, 1); DateTime d2 = new DateTime(2008, 1, 2); Assert.IsTrue(d...
12,146
<p>I have a web login page with the standard username password and login button controls. I would like to write a wrapper page that will render and auto fill the username and login form text boxes with a constant and force the onclick event for login button. Any suggestions how to accomplish this?</p>
<p>If you want this sort of functionality to decrease overall testing time you should also take a look at:</p> <p><a href="http://watin.sourceforge.net/" rel="nofollow noreferrer">WatiN</a></p> <p>or</p> <p><a href="http://code.google.com/p/ieunit/downloads/list" rel="nofollow noreferrer">IEUnit</a></p> <p>If you a...
<p>This sounds like a terrible idea, security-wise. Don't do it.</p>
32,375
<p>Im getting frustrated because of OpenDNS and other services (ie: roadrunner) that now always returns a ping even if you type any invalid url ie: lkjsdaflkjdsjf.com --- I had created software for my own use that would ping a url to verify if the site was up or not. This no longer works. Does anyone have any ideas a...
<p>You could create a simple web page with an address bar for the website and some javascript that uses AJAX to hit a site. If you get any HTTP response other than 200 on the async callback, the site isn't working.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script language="javascript" type="text/javascript"&...
<p>I've found ping to be very unreliable just because of all the hops you're having to jump through, and something in between can always interfere.</p> <p>Trying to open up an http connection with a web server is probably the best way to go.</p>
24,286
<p>I'm trying to simply use some of the examples and instructions regarding the YUI-Uploader, and I'm being frustrated by a number of issues.</p> <ol> <li>The "YUI Library: Uploader" cheat sheet's simple use case doesn't work for me because all the listed methods except <code>addListener()</code> do not exist on the m...
<p>You can find the source to <code>uploader.swf</code> <a href="http://github.com/yui/yui2/blob/fa7794624ce8dd3d3b231289ca1995c25bebecc4/src/uploader/as/Uploader.as" rel="nofollow noreferrer">here at <code>Uploader.as</code></a> now that the YUI source is available on GitHub.</p>
<p>You've got the wrong link for the simple example, here's the correct one.</p> <p><a href="http://developer.yahoo.com/yui/examples/uploader/uploader-simple-button.html" rel="nofollow noreferrer">YUI Uploader Simple Example</a></p> <p>You could also take a look at my implementation if you'd like, it's pretty barebon...
25,098
<p>I'm trying to create a UDF in <code>SQL Server 2005 Express</code> as below:</p> <pre><code>CREATE FUNCTION [CombineValues] () RETURNS VARCHAR(8000) AS BEGIN DECLARE @CuisineList VARCHAR(8000); RETURN ( SELECT @CuisineList = COALESCE(@CuisineList + ', ', '') + CAST(Cuisine AS varchar(20)) FR...
<p>This answer is from the original poster, Wild Thing. Please do not vote it up or down.</p> <pre><code>CREATE FUNCTION [CombineValues] () RETURNS VARCHAR(8000) AS BEGIN DECLARE @CuisineList VARCHAR(8000); SELECT @CuisineList = COALESCE(@CuisineList + ', ', '') + CAST(Cuisine AS varchar(20)) FROM Cuisines; RETURN ...
<p>try changing SELECT to SET and then end your function by SELECT (ing) your @CuisineList</p>
13,670
<p>How to load javascript files using google.load instead of directly using tag in freemarker template language?</p>
<p>For loading common JavaScript Libraries like jQuery, Prototype, MooTools, Dojo... from the Google CDN, you can find more information <a href="http://code.google.com/apis/ajaxlibs/" rel="nofollow noreferrer">here</a>.</p>
<p>And complementing CMS' answer: this is <a href="http://code.google.com/apis/ajax/documentation/#DetailedDocumentation" rel="nofollow noreferrer">the detailed documentation</a>.</p>
42,100
<p>I find the standard Powershell display of errors (red text, multi-line display) a bit distracting. Is it possible to customize this?</p>
<p>Yes and yes.</p> <p>You can use the built-in <code>$host</code> object if all you want to do is change the text color. However, you can't change the error message itself - that's hardcoded.</p> <p>What you could do is (a) suppress the error messages, and instead (b) trap the errors and display your own.</p> <p>Ac...
<p>Also, you can do this to write a specific line of error text:</p> <pre><code>$Host.UI.WriteErrorLine("This is an error") </code></pre> <p>(props to Chris Sears for this answer)</p>
48,327
<p>I have the following problem using subversion:</p> <p>I'm currently working on the trunk of my project and plan to do some refactoring (which includes renaming files or moving files to different directories).</p> <p>At the same time someone else is working on the same project on a branch.</p> <p>At some time I wa...
<p>I think this is an existing subversion <a href="http://subversion.tigris.org/issues/show_bug.cgi?id=898" rel="noreferrer">bug</a> - but don't hold your breath, its been open since 2002.</p>
<p>It's likely that you'll have to rename them in the branch. Can you merge the revision that renamed them from the trunk to branch? That might save some time. Otherwise, you'll have to rename them in the branch. Then try the merge back to the trunk.</p>
22,699
<p>This case is going to sound complicated, but it's not that bad. The javascript at the end of this code <em>seems</em> to be sound.</p> <p>EDIT: Here's the page running on a live server. The first example doesn't alternate between open and closed because I ripped out a lot of code in order to narrow the example down...
<p>I don't have time to read your entire code, but please pay attention to the following: you may be copying a HTML chunk and creating a clone of it in your code. This way, you actually get two textboxes with the same Id, although you see only one of them. At postback, the browser concatenates the values as a comma-sep...
<p>Sergiu is right, you are creating two html input with the same ID "Textbox1" as you can see in the screenshot captured using Firebug</p> <p><a href="http://www.flickr.com/photos/eduardo-molteni/3084894874/" rel="nofollow noreferrer" title="Stackoverflow Answer por edddy, en Flickr"><img src="https://farm4.static.fl...
44,502
<p><strong>Closed as exact duplicate of <a href="https://stackoverflow.com/questions/171970/how-can-i-find-the-method-that-called-the-current-method">"How can I find the method that called the current method?"</a></strong></p> <p>Is <a href="https://stackoverflow.com/questions/280389/javascript-how-do-you-find-the-cal...
<pre><code>Console.WriteLine(new StackFrame(1).GetMethod().Name); </code></pre> <p>However, this is not robust, especially as optimisations (such as JIT inlining) can monkey with the perceived stack frames.</p>
<p>From <a href="http://bytes.com/forum/thread213910.html" rel="nofollow noreferrer">here</a>:</p> <pre><code>System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(1); System.Diagnostics.StackFrame sf = st.GetFrame(0); string msg = sf.GetMethod().DeclaringType.FullName + "." + sf.GetMethod().Name; Messa...
35,458
<p>Making echo of a question around the web:</p> <blockquote> <p>Is the syntax for svn:ignore patterns documented somewhere? The only pattern matching character I could find in the SVN book under 'svn:ignore' is '*'.</p> </blockquote> <p><a href="http://svnbook.red-bean.com/en/1.0/ch07s02.html#svn-ch-7-sect-2...
<p>It seems to be documented <a href="http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.advanced.props.special.ignore" rel="noreferrer">here</a>.</p> <p>Edit: ...and to answer your specific question, you can use "?" to match a single character.</p>
<p>From what I saw at the page you linked and the <a href="http://www.cvsnt.org/manual/html/cvsignore.html" rel="nofollow noreferrer" title="Ignoring files via cvsignore">Ignoring files via cvsignore</a> page, it looks like it understand only glob syntax, ie. * for any string and ? for a character.</p> <p>If you need ...
46,105
<p>See code: </p> <pre><code>var file1 = "50.xsl"; var file2 = "30.doc"; getFileExtension(file1); //returns xsl getFileExtension(file2); //returns doc function getFileExtension(filename) { /*TODO*/ } </code></pre>
<p><strong>Newer Edit:</strong> Lots of things have changed since this question was initially posted - there's a lot of really good information in <a href="https://stackoverflow.com/a/1203361/23746">wallacer's revised answer</a> as well as <a href="https://stackoverflow.com/a/12900504/23746">VisioN's excellent breakdow...
<pre><code>var filetypeArray = (file.type).split("/"); var filetype = filetypeArray[1]; </code></pre> <p>This is a better approach imo. </p>
23,170
<p>I'm used to the Vi(m) editor and am using MS Visual Studio 2005 at work. I couldn't find a free Vi add-in (there's only one for the 2003 version). I googled a bit, saw that there was a 'Google summer of code' project this year to write such an add-in, and am eagerly awaiting the result. I've also heard of ViEmu (not...
<p>ViEmu works great with Visual Studio. I used Vi(m) strictly in Linux, but I was turned on to bringing the Vi(m) editing process into the Windows world by <a href="http://www.jpboodhoo.com/" rel="noreferrer">JP Boodhoo</a>. JP <a href="http://blog.jpboodhoo.com/HookedOnVIM.aspx" rel="noreferrer">praises</a> about i...
<p><a href="http://www.viemu.com/" rel="nofollow noreferrer">ViEmu</a> works great. I've been using it for about a year now and couldn't imagine coding in Visual Studio without it.</p> <p>Why can't you test it at work? It has a 30 day free trial.</p>
4,425
<p>Would like to hear from people about their experience with java clustering (ie. implementing HA solutions). aka . terracotta, JGroups etc. It doesn't have to be web apps. Experience writing custom stand alone servers would be great also.</p> <p><strong>UPDATE</strong> : I will be a bit more specific -> not that ...
<p><a href="http://docs.jboss.org/jbossas/jboss4guide/r4/html/cluster.chapt.html" rel="nofollow noreferrer">Jboss clustering</a> was very easy to get up and running. </p> <p>It seems to work well for us.</p>
<p>JBossCache is a standalone open source project that JbossClustering makes use of in the Application Server.</p> <p>Our company made use of it in our own custom network server, its working well so far in development, though yet to be deployed. </p> <p>Its a pretty simple API, and it comes in two flavors, a flat cac...
5,032
<p>Forgive my ignorance - still learning here.</p> <p>I am using Eclipse Ganymede (Java 1.5) and have been experimenting with web services - I have mangaged to get a simple web service up and running and the nice wizard you get in Eclipse generates all the necessary bits and pieces e.g. wsdl file etc - and you can tes...
<p>You will probably find that when you export the application as a WAR archive for installation into Tomcat that the axis jars are included inside the archive. Check in the WebContent/WEB-INF/lib directory and it is likely they'll be there.</p> <p>Alternatively, Eclipse could well be doing clever things with deployme...
<p>In the eclipse ganymede distribution if you chose the "J2EE" version or just add the "Web Tool Platform" plugin you will have the axis jar(s) in something like eclipse/plugins/org.apache.axis_version/lib</p>
24,980
<p>I'm doing simple string input parsing and I am in need of a string tokenizer. I am new to C# but have programmed Java, and it seems natural that C# should have a string tokenizer. Does it? Where is it? How do I use it?</p>
<p>You could use <a href="http://msdn.microsoft.com/en-us/library/system.string.split.aspx" rel="noreferrer" title="String.Split method msdn reference">String.Split method</a>.</p> <pre><code>class ExampleClass { public ExampleClass() { string exampleString = "there is a cat"; // Split string o...
<p>If you are using C# 3.5 you could write an extension method to System.String that does the splitting you need. You then can then use syntax:</p> <pre><code>string.SplitByMyTokens(); </code></pre> <p>More info and a useful example from MS here <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx" rel="nof...
9,580
<p>This is an age-old question where given a table with attributes 'type', 'variety' and 'price', that you fetch the record with the minimum price for each type there is.</p> <p>In SQL, we can do <a href="http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/" rel="noreferrer">this<...
<pre><code>Table.minimum(:price, :group =&gt; :type) </code></pre> <p>See <a href="http://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-minimum" rel="nofollow noreferrer">http://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-minimum</a> for more.</p>
<p>To update Avdi's answer above:</p> <blockquote> <p>Table.minimum(:price, :group => :type)</p> </blockquote> <p>Here is the updated URL:</p> <p><a href="http://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-minimum" rel="nofollow">http://api.rubyonrails.org/classes/ActiveRecord/Calculations....
22,446
<p>Say I've got this array: MyArray(0)="aaa" MyArray(1)="bbb" MyArray(2)="aaa"</p> <p>Is there a .net function which can give me the unique values? I would like something like this as an output of the function: OutputArray(0)="aaa" OutputArray(1)="bbb"</p>
<p>Assuming you have .Net 3.5/LINQ:</p> <pre><code>string[] OutputArray = MyArray.Distinct().ToArray(); </code></pre>
<p>Use the HashSet class included in .NET 3.5.</p>
10,894
<p>I am trying to upload a file using to Flickr using JQuery. I have a form (which works if I dont use JQuery) which I am submitting using the Form Plugin. My code is as follows:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Test Upload&lt;/title&gt; &lt;script type="text/javascript" src="jquery-1.2.6.js"&gt;...
<p>See this other thread about uploading files with AJAX:</p> <p><a href="https://stackoverflow.com/questions/166221/how-to-upload-file-jquery">How can I upload files asynchronously?</a></p> <p>I've never tried it, but it seems that you can't get the server response (not easily, anyway)</p>
<p>You will not be able to upload a file via AJAX this way.</p> <p>A pure AJAX file upload system is not possible because of security limitations of JavaScript.</p>
17,890
<p>What methods do you use to determine what kind of hardware you need for a server?</p> <p>I often find it very hard to predict what kind of hardware you will need for a web based application with a database.</p> <p>Do you have any good methods or recommendations on how to best pick hardware to use?</p>
<p>This is sort of the basic question of capacity planning. You start by defining a <em>workload model</em>, which describes what you expect to get in terms of traffic. This can be as simple as "I expect 20 page hits a minute maximum."</p> <p>Then you need to think about burst loads. Failing any other data, you can...
<p>It really depends on your web application demands and traffic expectations.</p> <p><strong>Very few websites will need more than one reasonable dedicated server within the first months.</strong> And if you do, then you can probably afford to buy more hardware ;)</p>
49,716
<p>I am trying to create an instance of a COM object. I have the class name that implements the interface and I get a CLSID by using CLSIDFromProgID(). So since I am getting a CLSID I thought everything should be fine from now on. However when I do a call to CreateInstance and pass in the CLSID, I get an error saying "...
<p>CLSIDFromProgId is simply looking up the ProgId's name in the registry and translating it to a CLSID, it doesn't have to look at anything beyond the registry or even check that something is actually implementing that CLSID.</p> <p>When you call CreateInstance on the CLSID, Windows will look up in the registry to fi...
<p>Using shell32 as an example, you can create a new instance like so;</p> <pre><code>var shl = (Shell) Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application")); </code></pre> <p>This will aquire a refernce to an existing component;</p> <pre><code>var shl2 = (Shell) Marshal.GetActiveObject("Shell.Applic...
32,489
<p>What is the way of separating Line-Breaks and Space in MultiLine Textbox or HTML Text area while inserting database (Asp.Net). For example what should I do if I want to insert </p> <p>Hello </p> <p>World </p> <p>to database with line breaks? And also While displaying what should I do? I don't want to use Edito...
<p>The line breaks should persist to the db. When you retreive the info and display as Html just replace the line break (i.e. Environment.NewLine) with a line break tag (i.e. <code> &lt; b r / > </code>)</p>
<p>I always store user input as it is provided, but then you must always be <strong>very careful</strong> when displaying it back again. Line breaks are simply a case of replacing System.Environment.Newline with "&lt;br /&gt;". Not sure what the best practice is for preserving other white space when rendered as html, w...
37,964
<p>I have floated images and inset boxes at the top of a container using <code>float:right</code> (or <code>left</code>) many times. Now, I need to float a <code>div</code> to the bottom right corner of another <code>div</code> with the normal text wrap that you get with <code>float</code> (text wrapped above and to th...
<p>Set the parent div to <code>position: relative</code>, then the inner div to... </p> <pre><code>position: absolute; bottom: 0; </code></pre> <p>...and there you go :)</p>
<p>Pretty old question, but still ... You can float a div to the bottom of the page like this:</p> <pre><code>div{ position: absolute; height: 100px; top: 100%; margin-top:-100px; } </code></pre> <p>You can see where the magic happens. I think you could do the same for floating it to the bottom of a paren...
40,205
<p>In C#, if I need to open an HTTP connection, download XML and get one value from the result, how would I do that?</p> <p>For consistency, imagine the webservice is at www.webservice.com and that if you pass it the POST argument fXML=1 it gives you back </p> <pre><code>&lt;xml&gt;&lt;somekey&gt;somevalue&lt;/someke...
<p>I use this code and it works great:</p> <pre><code>System.Xml.XmlDocument xd = new System.Xml.XmlDocument; xd.Load("http://www.webservice.com/webservice?fXML=1"); string xPath = "/xml/somekey"; // this node's inner text contains "somevalue" return xd.SelectSingleNode(xPath).InnerText; </code></pre> <hr> <p>EDIT: ...
<p>It may also be worth adding that if you need to specifically use POST rather than SOAP then you can configure the web service to receive POST calls:</p> <p>Check out the page on MSDN: <a href="http://msdn.microsoft.com/en-us/library/aa719747(VS.71).aspx" rel="nofollow noreferrer">Configuration Options for XML Web S...
7,405
<p>We are trying to move from using SQL DMO to SMO in our COM+ based application, as we are dropping support for SQL Server 2000 and adding support for SQL Server 2008 in addition to SQL Server 2005. </p> <p>I have been reading around on this, and found this particular quip on <a href="http://forums.microsoft.com/MSDN...
<p>Okay I figured out how to do this.</p> <p>The problem was that VB6 has no .Net 2.0 support and hence we cannot use SMO with VB6.</p> <p>To get around that, I wrote a COM wrapper in C# which uses SMO and maps (mostly) one-to-one with the kind of functionality I want from from my VB app.</p> <p>Basically, Create a ...
<p>I haven't tried it, but you could probably write vb.net code to interact with SQL SMO, and then write a com wrapper for the vb.net code. Of course, you'll still need to .net framework to use it.</p> <p>Instead, I would suggest that you migrate away from SQL DMO and SQL SMO. Anything you do with DMO or SMO can be ...
25,308
<p>How can our team gather requirements from our "Product Owner" in as low friction yet useable of a way as possible?</p> <p>Now here's the guidelines- No posts that it can't be done or that the business needs to make a decision that it cares about quality, yada yada. The product I work for is a small group that has b...
<p>Although the concept of "product owner" is a littl ambiguous to me, I think I am working in very similar circumstances: the customer is extremely buzy and always is a bottleneck in developing requirements.</p> <p>On the surface, what we try to do in this situation is quite obvious and seemingly simple: we try to ma...
<p>"Developers and team members gather requirements discussed in face to face meetings and write some quick notes"</p> <p>Start with that. If you aren't taking notes, just make one small change. Take Notes. Later, you might post them to a wiki or create a feature backlog or start using Scrum or bugzilla or somethin...
17,721
<p>I can't seem to find a good forum focusing on iCalendar format. Specifically how iCalendar is implemented with Outlook. </p>
<p>If you are producing iCalendar data and want to check for problems with Outlook then you could try validating it with <a href="http://icalvalid.cloudapp.net/" rel="nofollow noreferrer">Douglas Day's validator</a>.</p> <p>His validator not only measures your iCalendar data against the RFC 5545 specification but also...
<p>The best solution is usually to try it. Of course, that means installing Outlook or having a friend/user you can work with who does. I realise this is often a problem, but it's really the only way to know for sure how an application will behave.</p> <p>On the interop side: if you get it working in Apple Mail/iCal,...
47,428
<p>There are two pictureboxes with two different images.</p> <p>If I click on one picture box, the image in it should be cleared.</p> <p>To make the matters worse, both of the picture boxes have only one common event handler. How can I know which picturebox generated the event? I would appreciate source code in C++-C...
<p>How are you doing the cast? In most cases like this I would use:</p> <pre><code>PictureBox ^pb = safe_cast&lt;PictureBox^&gt;(sender); if(pb != null) { // logic goes here } </code></pre> <p>(Note that I've corrected the above code after Josh pointed out my reference flaw. Thanks!)</p> <p>the dynamic cast will...
<p>You can use the sender object. Cast it to a picture box control and compare it with the two available picture boxes.</p> <p>My Visual C++ is a little bit rusty and can't provide code now.</p>
41,937
<p>i have a databound GridView in asp.net 2.0 with a row-selection link. When a row is selected, I want to programmatically add a table row below the selected row, in order to nest another grid et al.</p> <p>I am researching this for a client and for an article, and i think my google-fu is not strong tonight. Any sugg...
<p>I think I figured it out. Here is a solution that seems to work. It could be improved using user controls but this is the gist of it:</p> <pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow &amp;&amp; (e.Row.RowState ...
<p>Thank you for sharing this code.</p> <p>I am trying to do the same thing (creating nested gridview), but actually, you don't have to create the gridview yourself. Instead, you just can wrap the control within tags. I have seen an example here <a href="http://www.codeproject.com/KB/aspnet/EditNestedGridView.aspx?ms...
21,858
<p>I'd like a loop that uses a UInt16 (ushort) to loop through all of its values. However, this doesn't do it:</p> <pre><code>for( ushort i = 0; i &lt; UInt16.MaxValue; i++ ) { // do something } </code></pre> <p>The problem is that the loop will quit when i == 0xFFFF and not "do something". If I change the 'for'...
<p>Use a <code>do...while</code> loop</p> <pre><code>ushort i = 0; do { // do something } while(i++ &lt; UInt16.MaxValue); </code></pre> <p>There is an interesting discussion of testing loops at the top vs. the bottom <a href="https://stackoverflow.com/questions/224059/do-your-loops-test-at-the-top-or-bottom">her...
<p>does it have to be a short? why not just</p> <pre><code>for(int i = 0;i&lt;=0xFFFF;i++) { //do whatever } </code></pre>
28,603
<p>I'm wondering what people use for storing their username, passwords, urls, IPs, domains, and any other login information they need to both do their job and in general life. It might also store serial numbers or similar data.</p> <p>I find that I'm registering for probably 5 sites a month, paying some piece of softw...
<p>I use KeePass. It has versions for various platforms (KeePassX for Linux, for example) and has been quite stable for me. No lost data yet, so I haven't had to resort to my backups :)</p>
<p>Use the same password for everything. Give it out to strangers.</p> <p>Just kidding. I use three tiers of passwords - the lowest one is really easy to remember, and applies to all accounts whose security I don't care about. I just use it for most things like this.</p> <p>For the other stuff, I don't find it to be su...
40,067
<p>Right now, we are using Perforce for version control. It has the handy feature of a strictly increasing change number that we can use to refer to builds, eg "you'll get the bugfix if your build is at least 44902".</p> <p>I'd like to switch over to using a distributed system (probably git) to make it easier to branc...
<p>I second the suggestion of using <code>git describe</code>. Provided that you have a sane versioning policy, and you don't do any crazy stuff with your repository, <code>git describe</code> will always be monotonic (at least as monotonic as you can be, when your revision history is a DAG instead of a tree) and uniqu...
<p>As you probably know, git computes a hash (a number) that uniquely identifies a node of the history. Using these, although they are not strictly increasing, seems like it would be good enough. (Even better, they <em>always</em> correspond to the source, so if you have the hash, you have the same code.) They're bi...
14,893
<p>In an application I'm developing, someone thought it would be ok idea to include commas in the values of a csv file. So what I'm trying to do select these values and then strip the commas out of these values. But the Regex I've built won't match to anything. </p> <p><strong><em>The Regex pattern is:</em></strong>...
<p>Commas are allowed in CSV's and should not cause a problem if you use a text qualifier (usually double quote ").</p> <p>Here are details: <a href="http://en.wikipedia.org/wiki/Comma-separated_values" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Comma-separated_values</a></p> <p><strong>On to the regex:</...
<p>Thanks for the answer Ryan. I should've kept my temper in check a bit more. Though still, commas in a CSV that don't seperate values? </p> <p>After asking around the office I got pointed towards a free Regex designer application that I used to build the pattern I needed. The application is <a href="http://www.radso...
46,674
<p>I've always taken the approach of first deploying the database with a minimal set of indexes and then adding/changing indexes as performance dictates.</p> <p>This approach works reasonably well. However, it still doesn't tell me where I could improve performance. It only tells me where performance is so bad that us...
<p>My approach is to gather commands against the server or database into a table using SQL Server Profiler. Once you have that, you can query based on the max and avg execution times, max and avg cpu times, and (also very important) the number of times that the query was run.</p> <p>Since I try to put all database acc...
<p>My advice would be to start with techniques applicable to all databases and then try the ones specific to MsSQL.</p> <p>Optimizing SQL is difficult, and there are no hard and fast rules. There are very few generic guidelines that you can follow, such as:</p> <ul> <li>95% of performance improvements will come from ...
12,899
<p>I'm trying this with Oracle SQL Developer and am on an Intel MacBook Pro. But I believe this same error happens with other clients. I can ping the server hosting the database fine so it appears not to be an actual network problem.</p> <p>Also, I believe I'm filling in the connection info correctly. It's somethin...
<p>That's the message you get when you don't have the right connection parameters. The SID, in particular, tends to trip up newcomers.</p>
<p>That's the message you get when you don't have the right connection parameters. The SID, in particular, tends to trip up newcomers.</p>
11,250
<p>Good morning everyone, </p> <p>I'm running into an issue using a SharePoint workflow project (C#, VS 2008) and connecting to a database. Here is my database connection string:</p> <pre><code>Data Source=DBSERVER;Initial Catalog=DBNAME;Integrated Security=True; </code></pre> <p>When I attempt to run the followi...
<p>Any DB access should run as a Windows Service account for security and connection pooling reasons.</p> <p>Regarding the Workflow Security Context, see: </p> <p>SharePoint, Workflows and Security <a href="http://cglessner.blogspot.com/2008/09/sharepoint-workflows-and-security.html" rel="nofollow noreferrer">http://...
<p>You cannot do that - the workflow does not run in the context of a user. Workflows are executed asynchronuously. Only (HTTP) WebPage-Requests run in the context of the user (if you turn on impersonation). You cannot flow the impersonation to the workflow. To restore impersonation in the workflow (which you should no...
23,364
<p>I have a list wrapper that maintains two Tstringlists and a TClassList</p> <p>I need this to be thread safe, such that:</p> <ul> <li>Concurrent writes are not allowed (wait state of some sort should be entered)</li> <li>Reading while writing (or vice versa) is not allowed (wait state of some sort should be entered...
<p>You should have a look at the TMultiReadExclusiveWriteSynchronizer class declared in sysutils.pas...</p>
<p>You really should look at TThreadList.</p> <p>The methods .Add, .Remove, .Clear automatically lock the list for you. If needed, you can also lock/unlock as needed:</p> <pre><code>x.LockList; try //do whatever finally x.Unlocklist; end; </code></pre> <p>TMultiReadExclusiveWriteSynchronizer is a grand ide...
38,863
<p>I'd like to mark a method as deprecated, so the people using it can easily check their code and catch up. In Java you set @Deprecated and everybody knows what this means.</p> <p>So is there a preferred way (or even tools) to mark and check for deprecations in Ruby?</p>
<p>For almost all cases, depending on a library or metaprogramming for a deprecation is overkill. Just add a comment to the rdoc and call the <code>Kernel#warn</code> method. For example:</p> <pre><code>class Foo # &lt;b&gt;DEPRECATED:&lt;/b&gt; Please use &lt;tt&gt;useful&lt;/tt&gt; instead. def useless war...
<p>We can use internal macros methods. Example:</p> <p><code>class Foo def get_a; puts "I'm an A" end def get_b; puts "I'm an B" end def get_c; puts "I'm an C" end</code></p> <pre><code>def self.deprecate(old_method, new_method) define_method(old_method) do |*args, &amp;block| puts "Warning: #{old_...
37,530
<p>I have recently installed .net 3.5 SP1. When I deployed a compiled web site that contained a form with its action set:</p> <pre><code>&lt;form id="theForm" runat="server" action="post.aspx"&gt; </code></pre> <p>I received this error.<br> Method not found: 'Void System.Web.UI.HtmlControls.HtmlForm.set_Action(Syste...
<p><a href="http://johnsheehan.me/blog/less-code-is-fun-aspnet-35-sp1-removes-need-for-control-adapter-when-using-url-rewriting/" rel="nofollow noreferrer">.NET 3.5 SP1 tries to use the action="" attribute</a> (.NET 3.5 RTM did not). So, when you deploy, your code is attempting to set the HtmlForm.Action property and f...
<p>I just ran into the same problem. From what I understood it is indeed caused by the fact the my PC has .NET 3.5 SP1 on it, and the server to which I deployed the project doesn't.<br> From what I understand, one solution is that the server be updated with .NET 3.5 SP1. As I don't want to do that yet, I just removed t...
5,513
<p>I'm optimizing some frequently run Perl code (once per day per file). </p> <p>Do comments slow Perl scripts down? My experiments lean towards no:</p> <pre><code>use Benchmark; timethese(20000000, { 'comments' =&gt; '$b=1; # comment ... (100 times) ', 'nocomments' =&gt; '$b=1;'}); </code></pre> <p>Gives pre...
<p>Perl is a just-in-time compiled language, so comments and POD have no effect on run-time performance.</p> <p>Comments and POD have a minuscule effect on compile-time, but they're so easy and fast for Perl to parse it's almost impossible to measure the performance hit. You can see this for yourself by using the <co...
<p>I would expect that the one comment would only get parsed once, not multiple times in the loop, so I doubt it is a valid test.</p> <p>I would expect that comments would slightly slow compilation, but I expect it would be too minor to bother removing them.</p>
33,937
<p>I'd like to give customers a choice of the database engine, but also want to minimize my troubles of such a decision.<br> The engines in question are MySQL (5 or later) and SQL Server (2005 or later).</p>
<p>Google for the differences in datatypes. </p> <p>But the schema is just a part of the picture. </p> <p>The SQL dialects are different too. Google for those differences. Then, either stick to a subset of SQL that's common to both, or build in a scheme to use somewhat different SQL in each.</p> <p>Don't wait u...
<p>One "fun" option is to not write SQL at all. Build a system that you can abstract the spec of what you want to do and then generate the schema/queries etc. I have a project where I'm building SQL code via the C pre processor.</p> <p>I would not recommend either of the above unless you <em>like</em> playing with hig...
35,855
<p>Yesterday I had a two-hour technical phone interview (which I passed, woohoo!), but I completely muffed up the following question regarding dynamic binding in Java. And it's doubly puzzling because I used to teach this concept to undergraduates when I was a TA a few years ago, so the prospect that I gave them misin...
<p>Java uses static binding for overloaded methods, and dynamic binding for overridden ones. In your example, the equals method is overloaded (has a different param type than Object.equals()), so the method called is bound to the <strong>reference</strong> type at compile time.</p> <p>Some discussion <a href="http://...
<p>I will try to explain this through two examples which are the extended versions of some of the examples that I came across online.</p> <pre><code>public class Test { public boolean equals(Test other) { System.out.println("Inside of Test.equals"); return false; } @Override public bo...
41,663
<p>Let's say I print a part out of ABS and wait for it to cool. I could theoretically do this with several copies of the same printer, modified to use print beds of different compositions.</p> <p>Will the material a bed is made out of affect how long it takes a part to cool?</p>
<p><strong>What bed material cools faster?</strong></p> <p>I found an <a href="http://www.engineeringtoolbox.com/thermal-conductivity-d_429.html">extensive list</a> which relates various materials to their <em>thermal conductivity</em>, k [W/mK]; the lower thermal conductivity, the better the material insulates, and t...
<p>Assuming you are meaning the build plate and not confusing it with a printed raft, yes, different materials for the build plate will have different cooling rates. I don't know the values of hand, but a Google search can get you to a formula to calculate how long a certain size build plate of a given material type sh...
143
<p>To trim the leading spaces we are using strmove. But we were advised to use strlmove instead of strmove. I have read and used strlcpy and strlcat. Whether strlmove does the similar functionality and what all are its advantages?</p> <p>Edit 1: Thank you Mike B and Chris Young. This is how we use strlcpy.</p> <pre><...
<p>As <a href="https://stackoverflow.com/questions/260962/what-is-the-advantage-of-strlmove-vs-strmove-in-c#260972">Chris Young mentions</a>, these routines are not standard (or as far as I known in wide, common use) so I can't be 100% certain with more specifics, but:</p> <p>Typically the <code>strl()</code> variatio...
<p>There is one big difference between strncpy and strlcpy at least in the version of Theo de Raadt, that you missed in your implementation. If the length of the given string is less than the buffer size, then strncpy pads the rest of the buffer with null bytes. This might be only a minor difference in many cases, but ...
32,625
<p>I'm trying to write a simple WCF Wrapper to load a SyndicationFeed as a client.</p> <p>Contract</p> <pre><code>[ServiceContract] public interface IFeedService { [OperationContract] [WebGet(UriTemplate="")] SyndicationFeed GetFeed(); } </code></pre> <p>Usage</p> <pre><code>using (var cf = new WebChann...
<p>Oracle also has a cached execution facility. The Query is hashed and matched to a plan if it hits on the hash table. You can also use this mechanism to force a plan for a particular query. As with SQL Server, you need to use a parameterised query to do this, rather than substituting the values into the string - a...
<p>There is something called client side statement caching: <a href="http://www.oracle.com/technology/oramag/oracle/06-jul/o46odp.html" rel="nofollow noreferrer">http://www.oracle.com/technology/oramag/oracle/06-jul/o46odp.html</a></p> <p>Be aware, client side result caching and client side statement caching are diffe...
48,685
<p>Here's the thing I want to print.</p> <p><a href="https://i.stack.imgur.com/4bgNK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4bgNK.png" alt="enter image description here"></a></p> <p>The red ring is 3.5&nbsp;mm above the bottom of the orange cylinder. The red ring is 1cm thick. I'd prefer n...
<p>You can print the support as a separate piece, then when the time is right pause the print, insert the support part into the ring and the resume printing. I guess you might have to use PVA glue on the support to ensure that it comes off easily when the time is right, but I'll leave that experimentation up to you. No...
<p>Assuming that the red flange needs to be flat on both sides, your best approach for printing in two parts may be a 45 degree conical cut through the flange. This will allow both parts to be printed flat on the bed, and (assuming a low layer height) should give a tolerable overhang result.</p>
1,422
<p>Is there a better way than the following to check to see if a string is nil OR has a length of 0 in Ruby?</p> <pre class="lang-ruby prettyprint-override"><code>if !my_string || my_string.length == 0 return true else return false end </code></pre> <p>In C# there's the handy</p> <pre class="lang-csharp prettypr...
<p>When I'm not worried about performance, I'll often use this:</p> <pre><code>if my_string.to_s == '' # It's nil or empty end </code></pre> <p>There are various variations, of course...</p> <pre><code>if my_string.to_s.strip.length == 0 # It's nil, empty, or just whitespace end </code></pre>
<p>For code golfers:</p> <pre class="lang-ruby prettyprint-override"><code>if my_string=~/./ p 'non-empty string' else p 'nil or empty string' end </code></pre> <p>Or if you're not a golfer (requires ruby 2.3 or later):</p> <pre class="lang-ruby prettyprint-override"><code>if my_string&amp;.size&amp;.positive? ...
30,806
<p>I have two tables that are joined together. </p> <p>A has many B</p> <p>Normally you would do: </p> <pre><code>select * from a,b where b.a_id = a.id </code></pre> <p>To get all of the records from a that has a record in b. </p> <p>How do I get just the records in a that does not have anything in b?</p>
<pre><code>select * from a where id not in (select a_id from b) </code></pre> <p>Or like some other people on this thread says:</p> <pre><code>select a.* from a left outer join b on a.id = b.a_id where b.a_id is null </code></pre>
<p>This will protect you from nulls in the IN clause, which can cause unexpected behavior.</p> <p>select * from a where id not in (select [a id] from b where <strong>[a id] is not null</strong>)</p>
18,217
<p>I have an installer that deploys web services to IIS. After this has finshed a custom action fires that updates the database with the scripts required by the webservices. The scripts are currently deploying to IIS aswell because they are part of the .net project. How can I configure the installation process so th...
<p>If you are using the standard Visual Studio setup projects do this:</p> <ol> <li>Add your scripts as files to your setup project</li> <li>Right-click on the files</li> <li>Select "Properties"</li> <li>Change the "PackageAs" property to "vsdpaLoose"</li> </ol> <p>Your files will now be output alongside your MSI so ...
<p>Using WIX, sorry no clue as to what you are using. I would create a <pre><code>&lt;Binary Id="webServiceScript.sql" src="[DirectoryToFile]\webServiceDataScript.sql" /&gt; </code></pre> <p>After setup a CA to run the script</p> <pre><code>&lt;CustomAction Id="CallCmd" Value="[Path_to_Exe_Folder][Your_EXE_TO_RUN_...
35,574
<p>I need to extract multiple text/dropdown list fields from an asp.net form and format appropriately ready for sending to recipient via email.</p> <p>What's the best way of reading those fields without having to hard code each item such as: </p> <pre><code>item1 = InputField1.Text; item2 = InputField2.Text; </code...
<p>@Chris has given you the basic idea -- copy out of the Request.Form collection. I would suggest that to make it easier, you give the inputs names that you can easily detect from the other fields on the page, some of which may be placed there for you by the framework. Perhaps use a naming scheme like "Email.FirstNa...
<p>Not sure why you're trying to do this - without more info it seems like you're probably taking an approach that is sub-optimal, but I digress. The form field values are also accessible via the Request.Form collection, which is a NameValueCollection if I recall. You could access that as-is like so:</p> <pre><code>fo...
40,121
<p>I am trying to implement a wpf user control that binds a text box to a list of doubles using a converter. How can i set the instance of user control to be the converter parameter?</p> <p>the code for the control is shown below</p> <p>Thanks </p> <pre><code>&lt;UserControl x:Class="BaySizeControl.BaySizeTextBox" ...
<p>The parameters are for constants needed by your converter. To provide an object instance to your converter, you can use MultiBinding.</p> <p>Note: For this solution to work, you also need to modify your converter to implement IMultiValueConverter instead of IValueConverter. Fortunately, the modifications involved a...
<p>I would name the control and then bind using ElementName:</p> <pre><code>&lt;UserControl x:Class="BaySizeControl.BaySizeTextBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:BaySizeControl" Name=...
49,482
<p>I have two machines setup to run Visual Studio 2008 (SP1) &amp; NET Framework 3.5 (SP1). If I create a .tt file in a console appliaction on machine #1 it automatically creates the sub .cs file for me, however if I do the exact same on machine #2 then no sub .cs file is created.</p> <p>I have tried toggling the "Sho...
<p>I'm assuming you want a count of the number of rows you'll be reading so as to do some pagination or similar? I don't understand your need for the LIMIT in the context of your question. However, if you just want a count of how many rows have been found, use one of the following.</p> <p>You select the count of all r...
<p>I'm assuming you want a count of the number of rows you'll be reading so as to do some pagination or similar? I don't understand your need for the LIMIT in the context of your question. However, if you just want a count of how many rows have been found, use one of the following.</p> <p>You select the count of all r...
36,867
<p>I am attempting to disable SSL v2.0 protocol on IIS 7.</p> <p>The following article refers to IIS v6: <a href="http://support.microsoft.com/kb/187498" rel="noreferrer">http://support.microsoft.com/kb/187498</a></p> <p>It doesn't seem to apply because the only protocol listed in the registry is SSL 2.0 (not all the...
<p>This article describes how you can disable SSL 2.0 in IIS 7:</p> <ul> <li><a href="http://www.sslshopper.com/article-how-to-disable-ssl-2.0-in-iis-7.html" rel="noreferrer">How to Disable SSL 2.0 in IIS 7</a></li> </ul> <blockquote> <ol> <li>Click <strong>Start</strong>, click <strong>Run</strong>, type <strong...
<p>Add a DWORD named "Enabled" with value 0x0 (default) to the SSL 2.0 key</p>
28,586
<p>I'm trying to setup a second ruby install in my home directory (a different version of ruby for testing). I've compiled ruby into <code>~/bin/</code> and everything is working until I try to install rubygems.</p> <p>I have <code>GEM_HOME</code> set to <code>~/gems</code> directory and <code>GEM_PATH</code> set to t...
<p>In addition to setting <code>GEM_HOME</code> you need to run <code>config</code> with your path. Here are the steps from <a href="http://www.rubygems.org/read/chapter/3#page83" rel="nofollow noreferrer">rubygems.org</a>.</p> <pre><code>$ export GEM_HOME=/home/mygemrepository $ ruby setup.rb config --prefix=/home/m...
<p>that fails in exactly the same way. I believe prefix is telling setup.rb where to put rubygems but isn't telling ruby where to find it. Also, the steps from rubygems.org is a different situation. They are installing rubygems in their home folder, but using the systems ruby binary. I'm trying to use a ruby binary fro...
48,360
<p>I'm writing a Rails plugin that includes some partials. I'd like to test the partials, but I'm having a hard time setting up a test that will render them. There's no associated controller, so I'm just faking one:</p> <pre><code>require 'action_controller' require 'active_support' require 'action_pack' require 'ac...
<p>checkout ActionView::TestCase - <a href="http://api.rubyonrails.org/classes/ActionView/TestCase.html" rel="nofollow noreferrer">http://api.rubyonrails.org/classes/ActionView/TestCase.html</a></p> <p>You can also use these to test helpers, which I've found extremely helpful.</p> <p>RSpec also has a way to test view...
<p>The closest I've gotten is</p> <pre><code>require 'action_controller' require 'active_support' require 'action_pack' require 'action_view' require 'action_controller/test_case' class StubController &lt; ActionController::Base append_view_path '...' def _renderizer; render params[:args]; end def rescue_acti...
33,459
<p>The Y-axis belt just broke on my Ender 3 v2. I believe that it was over tensioned from the factory. When I initially assembled the printer, I noticed that the Y-axis tensioner was tightened almost all the way. The belt itself felt very stiff. The X-axis belt, which I installed upon assembly, didn't require a lot of ...
<p>Generally, a timing belt is a complicated device and many things depend on its internal construction and materials (it may be damaged when bound in wrong direction, or when cut, and when overtighten of course, etc.). There is also physics and math applicable, based on <a href="https://en.wikipedia.org/wiki/Mersenne%...
<p>Mine came from the factory tight enough that it doesn't sag at all, but not so tight that it feels hard or stiff or difficult to deflect a bit with gentle pressure. With the bed pushed all the way to the back, I can push the y-axis belt to the side about 1/8&quot; with gentle pressure, and it feels like that's about...
1,822
<p>Can anyone suggest some references or other resources that are useful in learning MCML?</p> <p>I have a small pet project I have been working on for a while using C# and .Net 3.5. I have reached a point where I want to be able to send output from it to Windows Media Center, but I have been having a hard time findin...
<p>I suggest checking out (and contributing to) these three implementations of appengine sessions before rolling out your own:</p> <ul> <li><a href="http://code.google.com/p/app-engine-patch/" rel="nofollow noreferrer">app-engine-patch</a></li> <li><a href="http://gaeutilities.appspot.com/" rel="nofollow noreferrer">g...
<p>If you use web2py (version 1.46 or latter) sessions are on by default on GAE. This achieved by the following three lines of web2py code at the top of the scaffoling model:</p> <pre><code>from gluon.contrib.gql import * db=GQLDB() session.connect(request,response,db=db) </code></pre> <p>Here is a sample action th...
29,153
<p>I've got jQuery Autocomplete (UI 1.6rc2) up and running fine and when the user picks an item, it updates a hidden form value with the associated ID. How do I set the hidden form value to '0' when the text entered does not match a result from the autocomplete list? In this case, I'll be creating a new entry.</p>
<p>I did this in the autocomplete function:</p> <pre><code>change: function(event, ui){ $(this).next("input[id^=person_id]").val(''); return false; </code></pre> <p>After the user selects the option and it populates my hidden input with the item ID, if any changes occur to the visible input, the hidden input val...
<pre><code>$("#txtSearchProvider").autocomplete("../WebServices/PageMethods/AutoComplete.aspx", { minChars: 3, formatItem: function(data, i, n, value) { return value.split("-z-")[0]; }, formatResult:...
42,557
<p>Is it possible to have an ASP.NET MVC route that uses subdomain information to determine its route? For example:</p> <ul> <li><em><strong>user1</strong>.domain.example</em> goes to one place</li> <li><em><strong>user2</strong>.domain.example</em> goes to another?</li> </ul> <p>Or, can I make it so both of these go t...
<p>You can do it by creating a new route and adding it to the routes collection in RegisterRoutes in your global.asax. Below is a very simple example of a custom Route:</p> <pre><code>public class ExampleRoute : RouteBase { public override RouteData GetRouteData(HttpContextBase httpContext) { var url...
<p>Few month ago I have developed an attribute that restricts methods or controllers to specific domains. </p> <p>It is quite easy to use: </p> <pre><code>[IsDomain("localhost","example.com","www.example.com","*.t1.example.com")] [HttpGet("RestrictedByHost")] public IActionResult Test(){} </code></pre> <p>You can al...
35,188
<p>I want to find a way to allow our reporting guy to export data returned from a stored procedure into a CSV file. The procedure will need a (date) parameter passing to it.</p> <p>Is there a data export wizard I can get him to use, or some other user friendly way in SQL2005 that he can generate the CSV (after provid...
<p>Depending on what tools you are looking at, just give him SQL Server Management Studio. He can then execute the stored procedure and save the results in a CSV format. That is your most elegant way to be able to do it in a dynamic fashion.</p> <p>Otherwise, you might look at creating an SSIS package if the values ...
<p>Take a look at SQL Server Reporting services. You can export the results of a report to Excel.</p>
44,294
<p>I need to start and stop SQL Server from the command line. I am willing to write a small C# program if necessary, but I suspect that there's something (PowerShell, maybe?) that currently exists that does this gracefully.</p> <p>Thank you.</p>
<p><code>net {start|stop} mssqlserver</code></p>
<p>Here's an answer that actually contains a little bonus information...and more thoroughly answers the question. What if you have more than one instance of SQL server? Then you need to know the extended syntax of NET START. You can start services by Name, not just by service moniker (or whatever mssqlserver is an exam...
48,145
<p>We have an x-files problem with our .NET application. Or, rather, hybrid Win32 and .NET application.</p> <p>When it attempts to communicate with Oracle, it just dies. Vanishes. Goes to the big black void in the sky. No event log message, no exception, no nothing.</p> <p>If we simply ask the application to talk to...
<p>Here's what I would do. First, TRIPLE-check that you're seeing the behavior you think you're seeing. I can see this happening the other way around by not using System.IO.Path to concatenate paths, but not like you're seeing it. Triple-check that the file permissions make sense.</p> <p>Next, download <a href="htt...
<p>You should get a medal for perseverance for that !.</p> <blockquote> <p>"Exactly what XPO does now I don't really know, but if I dropped this table, and recreated it with the right case, using double quotes around all the column names to get the case right, the problem doesn't crop up.</p> <p>Exact...
29,654
<p>I've found <a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.scriptingjsonserializationsection.aspx" rel="noreferrer"><code>ScriptingJsonSerializationSection</code></a> but I'm not sure how to use it. I could write a function to convert the object to a JSON s...
<p>This should do the trick</p> <pre><code>Dim jsonSerialiser As New System.Web.Script.Serialization.JavaScriptSerializer Dim jsonString as String = jsonSerialiser.Serialize(yourObject) </code></pre>
<p>Try</p> <pre><code>System.Web.Script.Serialization.JavaScriptSerializer </code></pre> <p>or Check out <a href="http://www.json.org/" rel="nofollow noreferrer">JSON.org</a> there is a whole list of libraries written to do exactly what you want.</p>
5,555
<p>Can anyone recommend a good XML diff and merge tool?</p>
<p><a href="http://www.projectmerge.com" rel="nofollow noreferrer">Project: Merge</a> - Not free, but not expensive either.</p>
<p>I like <a href="http://www.oxygenxml.com/xml_diff_and_merge.html" rel="nofollow noreferrer">Oxygen</a>.</p>
16,245
<p>What is the best way to send Direct3D output to a printer or a plotter?</p>
<p>I would do it by creating a BMP file from the front buffer and then printing that BMP:</p> <p><a href="http://www.mvps.org/directx/articles/screengrab.htm" rel="nofollow noreferrer">http://www.mvps.org/directx/articles/screengrab.htm</a></p>
<p>I would just take a screenshot of the entire 3d scene, and then print it out.</p>
34,956
<p>How do you perform a CROSS JOIN with LINQ to SQL?</p>
<p>A cross-join is simply the Cartesian product of two sets. There's no explicit join operator for it.</p> <pre> var combo = from p in people from c in cars select new { p.Name, c.Make, c.Model, c.Colour }; ...
<p>Extension Method:</p> <pre><code>public static IEnumerable&lt;Tuple&lt;T1, T2&gt;&gt; CrossJoin&lt;T1, T2&gt;(this IEnumerable&lt;T1&gt; sequence1, IEnumerable&lt;T2&gt; sequence2) { return sequence1.SelectMany(t1 =&gt; sequence2.Select(t2 =&gt; Tuple.Create(t1, t2))); } </code></pre> <p>And use like:</p> <pr...
8,049
<p>I would like to use Emacs to edit some VB6 files but Emacs does not appear to have any of built-in niceties of other languages such as syntax highlighting, etc. </p> <p>Any plugins/extensions? What else can I do to make Emacs an acceptable and comfortable IDE for VB?</p>
<p>Visual Basic mode</p> <p><a href="http://www.emacswiki.org/cgi-bin/wiki/visual-basic-mode.el" rel="noreferrer">http://www.emacswiki.org/cgi-bin/wiki/visual-basic-mode.el</a></p> <p>edit: after installing this script (see script for instructions) syntax highlighting can be toggled via the options menu -- emacs call...
<p>For VB.NET, there is also a <a href="http://www.emacswiki.org/emacs/VbDotNetMode" rel="nofollow noreferrer">VBNET mode</a>.</p>
22,959
<p>In C# is there a technique using reflection to determine if a method has been added to a class as an extension method?</p> <p>Given an extension method such as the one shown below is it possible to determine that Reverse() has been added to the string class?</p> <pre><code>public static class StringExtensions { ...
<p>You have to look in all the assemblies where the extension method may be defined.</p> <p>Look for classes decorated with <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.extensionattribute.aspx" rel="noreferrer"><code>ExtensionAttribute</code></a>, and then methods within that class ...
<pre><code>void Main() { var test = new Test(); var testWithMethod = new TestWithExtensionMethod(); Tools.IsExtensionMethodCall(() =&gt; test.Method()).Dump(); Tools.IsExtensionMethodCall(() =&gt; testWithMethod.Method()).Dump(); } public class Test { public void Method() { } } public class TestW...
38,376
<p>I am trying to get intellisense in VS2008 in a js file, foo.js, from another js library/file I've written but cannot figure out the reference path ?syntax?/?string?</p> <p>The library is in a file called common.js which is in the same folder as foo.js I'm working on.</p> <p>Here's the paths I've tried...</p> <pre...
<p>First, make sure "common.js" is in your web project. Then drag "common.js" from the solution explorer into the editor window for the file you want to reference it from.</p>
<p>Did you try the VS hotfix for jQuery intellisense? <a href="http://blogs.msdn.com/webdevtools/archive/2008/02/08/jscript-intellisense-working-with-jquery.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/webdevtools/archive/2008/02/08/jscript-intellisense-working-with-jquery.aspx</a></p>
36,504
<p>I have recently inherited a brownfield application that is currently live. Through response, or a response with a link, how and what is the best method to make changes to a site and deploy them to a live ASP .NET website.</p>
<p>I always develop on my box first.</p> <p>I'll test, make a backup of the live site, and then ftp the updates over.</p> <p>Simple, but I haven't had an issue yet.</p> <p>Also: I have svn running, too, and I do commit changes before updating the live site. That way I have two backups: source control and physical, z...
<p>Don't know if this will work for you, but we use the "Use fixed naming and single page assemblies" publish model of VS2005. We test locally, deploy to a dev server to test with the other developer's changes (there are only 2 of us), and then deploy to a temp directory on the live server. Then we RDP into the live ...
11,831
<p>Visual Studio Test can check for expected exceptions using the ExpectedException attribute. You can pass in an exception like this:</p> <pre><code>[TestMethod] [ExpectedException(typeof(CriticalException))] public void GetOrganisation_MultipleOrganisations_ThrowsException() </code></pre> <p>You can also check for ...
<p>I would recommend using a helper method instead of an attribute. Something like this:</p> <pre><code>public static class ExceptionAssert { public static T Throws&lt;T&gt;(Action action) where T : Exception { try { action(); } catch (T ex) { return ex; } Assert.Fail("Exce...
<p>I came across this question while trying to resolve a similar issue on my own. (I'll detail the solution that I settled on below.)</p> <p>I have to agree with Gishu's comments about internationalizing the exception messages being a code smell. </p> <p>I had done this initially in my own project so that I could hav...
13,848
<p>I would like to save the programs settings every time the user exits the program. So I need a way to call a function when the user quits the program. How do I do that?</p> <p>I am using Java 1.5.</p>
<p>You can add a shutdown hook to your application by doing the following:</p> <pre><code>Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { // what you want to do } })); </code></pre> <p>This is basically equivalent to having a try {} finally {} block around your ent...
<p>Are you creating a stand alone GUI app (i.e. Swing)?</p> <p>If so, you should consider how you are providing options to your users how to exit the application. Namely, if there is going to be a File menu, I would expect that there will be an "Exit" menu item. Also, if the user closes the last window in the app, I w...
8,908
<p>I need to increment a number in a source file from an Ant build script. I can use the <code><a href="http://ant.apache.org/manual/Tasks/replaceregexp.html" rel="nofollow noreferrer">ReplaceRegExp</a></code> task to find the number I want to increment, but how do I then increment that number within the <code>replace<...
<p>You can use something like:</p> <p><code>&lt;propertyfile file="${version-file}"&gt; &lt;entry key="revision" type="string" operation="=" value="${revision}" /&gt; &lt;entry key="build" type="int" operation="+" value="1" /&gt;</code></p> <p>so the ant task is propertyfile.</p>
<p>Good question, it can be done in perl similar to that, but I think its not possible in ant, .NET and other areas.. If I'm wrong, I'd really like to know, because that's a cool concept that I've used in Perl many times that I could really use in situations like you've mentioned. </p>
16,115