instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Sight is one of the senses most programmers take for granted. Most programmers would spend hours looking at a computer monitor (especially during times when they are <em>in the zone</em>), but I know there are blind programmers (such as T.V. Raman who currently works for Google).</p> <p>If you were a blind person (...
<p>I am a totally blind college student who’s had several programming internships so my answer will be based off these. I use windows xp as my operating system and <a href="http://freedomscientific.com/products/fs/jaws-product-page.asp" rel="noreferrer">Jaws</a> to read what appears on the screen to me in synthetic spe...
<p>What about inventing some kind of device that you plug in a usb port and that would be basically a "sheet of rubber" that would modify itself to show brail of your code, allowing blind people to read it instead to hear it?</p>
14,474
<p>I do TDD, and I've been fairly loose in organizing my unit tests. I tend to start with a file representing the next story or chunk of functionality and write all the unit-tests to make that work. </p> <p>Of course, if I'm introducing a new class, I usually make a separate unit-test module or file for that class, bu...
<p>Divide your tests in 2 sets:</p> <ul> <li>functional tests</li> <li>units tests</li> </ul> <p>Functional tests are per-user story. Unit tests are per-class. The former check that you actually support the story, the latter exercise and document your functionality.</p> <p>There is one directory (package) for functi...
<p>I try to look at the unit tests as a project on their own. As with any project the organisation should follow some internal logic. It does not however have to be specific or formally defined - anything you're comfortable with is OK as long as it keeps your project well-organised and clean.</p> <p>So for the unit t...
18,488
<p>I often use the <code>execv()</code> function in C++, but if some of the arguments are in C++ strings, it annoys me that I cannot do this:</p> <pre><code>const char *args[4]; args[0] = &quot;/usr/bin/whatever&quot;; args[1] = filename.c_str(); args[2] = someparameter.c_str(); args[3] = 0; execv(args[0], args); </c...
<p>The Open Group Base Specifications explains why this is: for compatibility with existing C code. Neither the pointers nor the string contents themselves are intended to be changed, though. Thus, in this case, you can get away with <code>const_cast</code>-ing the result of <code>c_str()</code>.</p> <p><a href="http:...
<p>I have usually hacked this with:</p> <pre><code>#define execve xexecve #include &lt;...&gt; #include &lt;...&gt; #include &lt;...&gt; #undef execve // in case of c++ extern "C" { int execve(const char * filename, char ** argvs, char * const * envp); } </code></pre> <p>;/</p>
23,075
<p>How do I detect when an iOS app is launched for the first time?</p>
<p>Pretty much what Marc and Chris said, though I prefer to change the value when the app quits in case there're multiple areas of the application that need to know about it. In code:</p> <p><strong>Objective-C</strong></p> <pre><code>// -applicationDidFinishLaunching: [[NSUserDefaults standardUserDefaults] registerD...
<p>You can set a boolean value in the user defaults to do this. Set the key to false when you call <code>registerDefaults:</code>, and then set it to true change it to true after you've shown your initial help screen or whatever you need to do.</p> <p>If you have a persistent data file that's always saved after the ap...
39,787
<p>I have a PHP application that displays a list of options to a user. The list is generated from a simple query against SQL 2000. What I would like to do is have a specific option at the top of the list, and then have the remaining options sorted alphabetically.</p> <p>For example, here's the options if sorted alph...
<pre><code>SELECT name FROM locations ORDER BY CASE WHEN name = 'Montreal' THEN 0 ELSE 1 END, name </code></pre>
<pre><code>create table Places ( add Name varchar(30), add Priority bit ) select Name from Places order by Priority desc, Name </code></pre>
10,859
<p>What is the Win32 API call to determine the system-wide font (in particular the color) for say Menus.</p> <p>This would be equivalent to going into Appearance Settings - Advanced - and then choosing Menu as the item to look at.</p> <p>I can use GetSysColor to find the colors of various system-wide window elements,...
<p>GetSysColor(COLOR_MENUTEXT) gives you the menu font colour.</p> <p>SystemParametersInfo Will allow you to recover some font information, likewise GetStockObject for drawing on the device context.</p> <p>But the system font is (probably) either Tahoma (on XP/W2K) or MS Sans Serif depending on how you set up your Di...
<p>In C#, there's <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.defaultfont.aspx" rel="nofollow noreferrer">Control.DefaultFont</a>, and for native access, <a href="http://blogs.msdn.com/oldnewthing/archive/2005/03/09/390706.aspx" rel="nofollow noreferrer">this blog</a> describes the win...
26,550
<p>My application is using <strong>Dojo 1.1.1</strong> on an <em>SSL-only</em> website. It is currently taking advantage of <code>dijit.ProgressBar</code> and a <code>dijit.form.DateTextBox</code>.</p> <p>Everything works fabulous in <em>Firefox 2 &amp; 3</em>, but as soon as I try the same scripts in <em>IE7</em> the...
<p>After reviewing the JavaScript sourcecode for Dijit, I thought it was likely the error results from an "insecure" refrence to a dynamically generated IFRAME. Note there are two versions of the script file, the uncompressed represents the original source (dijit.js.uncompressed.js) and the standard (dijit.js) has been...
<p>If your page is loading files from a non-https URL Firefox should tell you the same thing. Instead of an error the lock symbol at the bottom (in the status bar) should be crossed out. Are you sure that is not the case?</p> <p>If you see the symbol, click on it and check which files are "unsecure".</p>
8,441
<p>In cake 1.2 there is a feature that allows the developer to no have to create models, but rather have cake do the detective work at run time and create the model for you. This process happens each time and is neat but in my case very hazardous. I read about this somewhere and now I'm experiencing the bad side of thi...
<p><strong>Cake 1.2</strong></p> <p>It's a hack and it's ugly cus you need to edit core cake files but this is how i do it: \cake\libs\class_registry.php : line 127ish</p> <pre><code>if (App::import($type, $plugin . $class)) { ${$class} =&amp; new $class($options); } elseif ($type === 'Model') { /* Print out ...
<p>Uh...where do we start. First, as Alexander suggested, clear your app cache.</p> <p>If you still get the same behaviour, there is probably something wrong with the class and/or file names.</p> <p>Remember <a href="http://book.cakephp.org/view/23/File-and-Classname-Conventions" rel="nofollow noreferrer">the rules</...
12,566
<p>I've been recently asked to learn some MATLAB basics for a class.</p> <p>What does make it so cool for researchers and people that works in university? I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).</p> <p>Writing a function or parsing ...
<p>Adam is only partially right. Many, if not most, mathematicians will never touch it. If there is a computer tool used at all, it's going to be something like <a href="http://en.wikipedia.org/wiki/Mathematica" rel="noreferrer">Mathematica</a> or <a href="http://en.wikipedia.org/wiki/Maple_(software)" rel="noreferr...
<p>The main reason it is useful in industry is the plug-ins built on top of the core functionality. Almost all active Matlab development for the last few years has focused on these. </p> <p>Unfortunately, you won't have much opportunity to use these in an academic environment.</p>
21,704
<p>First a little intro:</p> <p>Last year i wrote this <a href="http://dragan.yourtree.org/code/canvas-3d-graph/" rel="noreferrer">http://dragan.yourtree.org/code/canvas-3d-graph/</a></p> <p>Now, i want to make complete rewrite of it, because that old version have some limitations, for example: sometimes it happens t...
<p>If this is specifically for a JavaScript related project then I understand but if you are simply doing this to grasp the basics of 3d rendering there might be more mature platforms out there for you. </p> <p>In any case..</p> <p>Links that might be useful to your learning:</p> <ul> <li><a href="http://hem.spray.s...
<p>Just a couple of suggestions, but probably not exactly what you're looking for:</p> <p>I suggest that you take a look at Jacob Seidelin's canvas examples at nihilogic.dk : <a href="http://blog.nihilogic.dk/search/label/canvas" rel="nofollow noreferrer"><a href="http://blog.nihilogic.dk/search/label/canvas" rel="no...
49,838
<p>I'm writing a program that creates a Word document with sensitive information. I'd like to encrypt and password protect the document and distribute it in a self-extracting file so that the user can double-click, provide a password, and then receive the unencrypted file.</p> <p>I'm okay creating the Word document, b...
<p><a href="http://www.finecrypt.net/" rel="nofollow noreferrer">finecrypt.net</a> should met your requirements (free version <a href="http://www.finecrypt.net/download.html" rel="nofollow noreferrer">here</a>)</p> <p><img src="https://i.stack.imgur.com/O5D8n.gif" alt="Finecrypt"></p>
<p>If you want to encrypt a Word document, dinamically on a LAMP server, exactly as MS Word does, you may use the Crypto API of PHPDocX: <a href="http://www.phpdocx.com/documentation/cryptophpdocx-word-document-protection-and-encryption-with-php" rel="nofollow">CryptoPHPDocX</a>.</p> <p>Take into account the encrypted...
37,847
<p>I have a NotifyIcon control that appears in the system tray. How can I find the location (x, y) of the icon on the screen?</p> <p>Thanks</p>
<p>Actually you can do this, here is code that shows you how and much more.</p> <p>In any Mouse Event from NotifyIcon, simply look at Control.MousePosition, this contains the (x,y) of the mouse. The same can be done to position a ContextMenu on a form/control exactly where the form/control was clicked using these (x,y...
<p>You can't. It isn't hard to get the window handle for the system tray, GetClassName() returns "ToolbarWindow32", the class name of the standard TOOLBAR common control. Beware that a 64-bit OS has two of them. Then you can send messages to it like TB_GETBUTTONINFO. Chief hang-ups are that you won't know what butt...
34,347
<p>I didn't find an explicit answer to this question in the WiX Documentation (or Google, for that matter). Of course I could just write the appropriate registry keys in HKCR, but it makes me feel dirty and I'd expect this to be a standard task which should have a nice default solution.</p> <p>For bonus points, I'd li...
<p>After some additional research, I found a partial answer to this question in the <a href="http://www.tramontana.co.hu/wix/lesson1.php#1.7" rel="noreferrer">WiX Tutorial</a>. It shows an advertised solution and does not work with WiX 3.0, but given that information, I figured it out. Add a ProgId element to the compo...
<p>"If your application handles its own file data type, you will need to register a file association for it. Put a ProgId inside your component. FileId should refer to the Id attribute of the File element describing the file meant to handle the files of this extension. Note the exclamation mark: it will return the shor...
16,778
<p>I have some very simple code to generate an assembly and invoke a method on a contained type. The method gets called and runs correctly, however when I view the generated assembly using Reflector, I don't see the type.</p> <p>Below is the sample code:</p> <pre><code>namespace ConsoleApplication2 { class Progg...
<p>The trick is to use a "persistable module" version of DefineDynamicModule method on the AssemblyBuilder instance. That is, instead of:</p> <pre><code>var module = ab.DefineDynamicModule(ab.GetName().Name); </code></pre> <p>use something like:</p> <pre><code>var module = ab.DefineDynamicModule(ab.GetName().Name, ...
<p>I am not sure why the type is not getting added. </p> <p>Another way of doing this however is to dynamically create code by just passing in a string which contains your class code. I think this is a bit easier than the above way of doing it as you can just build up the code using a string builder and test in studio...
23,565
<p>I'm stuck with the following:</p> <p>I have an Access2003 report "rptInvoices". Group levels are on CustomerID and PackingListID. </p> <p>What I like to achieve is that every 2nd (or 3rd etc.) page of an invoice starts with a blank section (of say 9cm) at the top of the page. For this I would use an empty PageHea...
<p>In the groupheader <code>format event</code> set the <code>pageheadersection.visible</code> to <code>true</code> so the page header prints for pages after the group header. In the group footer format event set the <code>pageheadersection.visible</code> to <code>false</code> so the page header does not print at the t...
<p>You can set the visible property of the page header in the format event of the group header.</p> <pre><code>Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer) Me.PageHeaderSection.Visible = False End Sub Private Sub Report_Page() Me.PageHeaderSection.Visible = True End Sub </code></...
49,442
<p>Is there a way to get the directory of a project in Eclipse? We are writing a plugin that will allow the user to select files, and then run some processes on those files. I would ideally like to be able to get all the files with a certain extension, but that is not necessary.</p>
<p>sure:</p> <pre><code>ResourcesPlugin.getWorkspace().getRoot().getProjects() </code></pre> <p>will get you a list of all the projects in the workspace. you can easily iterate to find the one you want. At that point, you can look for certain files by extensions, etc.</p>
<p>If you want to enable your users to select files inside eclipse workspace with a certain extension, you can look at the class <strong>org.eclipse.ui.dialogs.ElementTreeSelectionDialog</strong> (org.eclipse.ui.dialogs plugin)as a start.</p> <p>Then, to have an example on how to make it filter extensions, you can loo...
29,962
<p>What would be the best way to port an existing Drupal site to a Django application? I have around 500 pages (mostly books module) and around 50 blog posts. I'm not using any 3rd party modules. I would like to keep the current URLS (for SEO purposes) and migrate database to Django. I will create a simple blog applica...
<p>All Django development is similar, and yours will fit the pattern.</p> <ol> <li><p>Define the Django model for your books and blog posts. </p></li> <li><p>Unit test that model using Django's built-in testing capabilities.</p></li> <li><p>Write some small utilities to load your legacy data into Django. At this poi...
<p><a href="https://stackoverflow.com/a/210315/892951">S.Lott answer</a> is still valid after years, I try to complete the analysis with the tools and format to do the job.</p> <p>There are many Drupal export tools out of there by now but with the very same request I go for <a href="https://www.drupal.org/project/view...
25,793
<p>I am writing a web app using TurboGears, and in that app the users must be able to generate different reports. The data the reports need is stored in a database (MySQL). The reports must be returned either as a easily printable html document, or a pdf file.</p> <p>I have previously used jasper and iReport for creat...
<p>You can build some fancy PDFs from Python with the <a href="http://www.reportlab.com/opensource/" rel="nofollow noreferrer">ReportLab</a> toolkit.</p>
<p>A partial answer: the easily readable format you are looking for might be <a href="http://www.docbook.org/" rel="nofollow noreferrer">DocBook</a>. From there it is very easy to go to PDF, html, RTF, etc. etc.</p>
13,593
<p>Once again it is time to clean up my emacs setup. Before I go cleaning it up, are there any packages that you would recommend above and beyond c++-mode, cedet, ecb, speedbar etc. ? Especially stuff that's new in the last five years.</p>
<p><a href="https://stackoverflow.com/questions/271924/what-is-your-favourite-plugin-in-emacs">This could be helpful!</a></p>
<p>I use msf-abbrevs package for inserting code snippets as i type special code words - something like for, if, etc, but with highliting of positions, that should be filled out, and moving between them with TAB key</p>
45,659
<p>I'm using VB.net (2003), and calling the SelectNodes method on an xml document.<br> If I have a document:</p> <pre><code>&lt;InqRs&gt; &lt;DetRs&gt; &lt;RefInfo&gt; &lt;RefType&gt;StopNum&lt;/RefType&gt; &lt;RefId&gt;0&lt;/RefId&gt; &lt;/RefInfo&gt; &lt;RefInfo&gt; &lt;...
<p>You want all <strong><code>DetRs</code></strong> children of the top element:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;<code>/*/DetRs</code></p> <p>That have a <strong><code>RefInfo</code></strong> child:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;<code>/*/DetRs</code><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...
<p>Like so. You don't need the top-level InqRs in your XPath expression, though it doesn't hurt. You may not care about the DetRs either, but assuming you do, you want to say "give me the parent of the Refinfo element which has the following specification"</p> <pre><code>DetRs/Refinfo[RefType='Id' and RefId='0']/.. </...
47,748
<p>If you create a pure ActionScript project in Flex Builder 3 and want to do unit testing using flexunit, what is the best option?</p> <p>The built-in Flex builder will refuse to build the mxml file containing the TestRunnerBase component as it is a pure ActionScript project (no Flex allowed). It is impossible to add...
<p>There's always <a href="http://www.asunit.com/" rel="nofollow noreferrer">ASUnit</a>.</p>
<p>Try AS3Unit from libspark. They also have an async beta test kit. </p>
47,785
<p>Ok guys just a small game:</p> <p>I have some specifications for a project. At some point they ask for the following to encrypt a password over the net, saying that it is a challenge response protocol:</p> <pre> CLIENT ----------------------------- SERVER (1)ask for challenge --------------&gt; (2) &lt;------...
<p>How about the following:</p> <ol> <li>Server sends a random challenge</li> <li>Client sends SHA1 checksum of (challenge+password)</li> <li>Servers compares against SHA1 checksum of (challenge+stored password)</li> </ol>
<p>The way I would do this is the following:</p> <ol> <li>Challenge the server. </li> <li><p>Server responds with it's public key (for, say RSA encryption) digitally signed.</p></li> <li><p>Client verifies PK, and encrypts password with the key, then digitally signs the encrypted password.</p></li> <li><p>Server ve...
22,789
<p>In a custom role provider (inheriting from RoleProvider) in .NET 2.0, the IsUserInRole method has been hard-coded to always return true:</p> <pre><code>public override bool IsUserInRole(string username, string roleName) { return true; } </code></pre> <p>In an ASP.NET application configured to use this role provide...
<p>I looked at Roles.IsUserInRole(string rolename) in .net reflector, and it resolves to the following:</p> <pre><code>public static bool IsUserInRole(string roleName) { return IsUserInRole(GetCurrentUserName(), roleName); } </code></pre> <p>I would take a look at your current user. Here's why:</p> <pre><code>pr...
<p>Also beware if you have selected cacheRolesInCookie="true" in the RoleManager config. If you have added a new role to the database, it might be looking at the cached version in the cookie.</p> <p>I had this problem and the solution was to delete the cookie and re-login.</p>
47,367
<p>Are there any dictionary classes in the .NET base class library which allow duplicate keys to be used? The only solution I've found is to create, for example, a class like:</p> <pre><code>Dictionary&lt;string, List&lt;object&gt;&gt; </code></pre> <p>But this is quite irritating to actually use. In Java, I believ...
<p>If you're using .NET 3.5, use the <a href="http://msdn.microsoft.com/en-us/library/bb460184.aspx" rel="noreferrer"><code>Lookup</code></a> class.</p> <p>EDIT: You generally create a <code>Lookup</code> using <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.tolookup.aspx" rel="noreferrer"><cod...
<p>Duplicate keys break the entire contract of the Dictionary. In a dictionary each key is unique and mapped to a single value. If you want to link an object to an arbitrary number of additional objects, the best bet might be something akin to a DataSet (in common parlance a table). Put your keys in one column and your...
17,609
<p>I have this working definition:</p> <pre><code>IDENTIFIER [a-zA-Z][a-zA-Z0-9]* </code></pre> <p>I don't want to keep repeating the [a-zA-Z] and [0-9], so I made two new definitions</p> <pre><code>DIGIT [0-9] VALID [a-zA-Z] </code></pre> <p>How can I rewrite the IDENTIFIER rule to use the DIGIT and VALID ...
<p>It looks like you actually want:</p> <pre><code>IDENTIFIER {VALID}({VALID}|{DIGIT})* </code></pre> <p><code>[{VALID}{DIGIT}]</code> resolves to <code>[[A-Za-z][0-9]]</code> which is not a legal construct.</p>
<p>I think this will do it, but I can't test it. Do you have sample data?</p> <pre><code>(?:[a-zA-Z])+(?:[0-9])+ </code></pre>
21,579
<p>For simplicity lets say I have two flex mxml pages. </p> <p>form.mxml<br> button.mxml</p> <p>If the form.mxml page had the following code, it should work fine:</p> <pre><code>&lt;custom:SelectView dSource="{_thedata}" id="form" visible="false"&gt; &lt;/custom:SelectView&gt; &lt;mx:LinkButton label="Show" id="lbS...
<p>You could write a custom method that handles the button click events and raises a custom event. Then in form.mxml you can handle that event.</p> <p>Splitting it up like this is a bit cleaner, as it makes the button.mxml file work on its own. Having Button.mxml have a direct reference to your form causes a tight-c...
<p>Your <code>button.mxml</code> class must have a reference to the instance of the 'form' class which will be affected. Then it can operate on it directly:</p> <p><em>Button.mxml:</em></p> <pre><code>&lt;mx:Script&gt; &lt;![CDATA[ [Bindable] public var myForm:MyFormClass; ]]&gt; &lt;/mx:Script&gt; &lt;mx:LinkB...
22,755
<p>I am creating a standalone asp.net page that needs to be embedded into a sharepoint site using the Page Viewer Web Part. The asp.net page is published to the same server on a different port, giving me the URL to embed.</p> <p>The requirement is that after a user is authenticated using Sharepoint authentication, th...
<p>If you want to retrieve the currently authenticated user from the SharePoint context, you need to remain within the SharePoint context. This means hosting your custom web application within SharePoint (see <a href="http://msdn.microsoft.com/en-us/library/cc297200.aspx" rel="nofollow noreferrer" title="Deploying ASP....
<p>When it works in debug, is that being used in SharePoint?</p> <p>Your page and the Sharepoint site might as well be on different servers as far as authentication is concerned -- in order to get the information over you might need to pass it via the QueryString from the webpart if you can -- or you might need to mak...
13,790
<p>I wrote a simple tool to generate a DBUnit XML dataset using queries that the user enters. I want to include each query entered in the XML as a comment, but the DBUnit API to generate the XML file doesn't support inserting the comment where I would like it (above the data it generates), so I am resorting to putting...
<p>According to the <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#sec-comments" rel="noreferrer">XML specification</a>, a well-formed XML document is:</p> <blockquote> <p><code>document ::= prolog element Misc*</code></p> </blockquote> <p>where <code>prolog</code> is</p> <blockquote> <p><code>p...
<p>The processing instruction must be the very first thing in the XML content (see <a href="http://www.w3.org/TR/REC-xml/#sec-comments" rel="nofollow noreferrer">XML comment</a> and <a href="http://www.w3.org/TR/REC-xml/#sec-pi" rel="nofollow noreferrer">processing instructions</a>). The following should work:</p> <p...
7,365
<p>I feel like a fool, but here goes:</p> <pre><code>public interface IHasErrorController{ ErrorController ErrorController { get; set; } } public class DSErrorController: ErrorController{yadi yadi ya} public class DSWebsiteController : Controller, IHasErrorController{ public DSErrorController ErrorController {...
<p>C# (at the moment) has very little [co|contra]variance support; as such, the interface implementation must be an <em>exact</em> match, including the return type. To keep your concreate type on the class API, I would implement the interface explicitly - i.e. add:</p> <pre><code>ErrorController IHasErrorControlloer.E...
<p>This is true; that is not allowed. (The proper name is "Covariant return types")</p> <p>Note that DSWebsiteController.ErrorController can physically return a DSErrorController object; it's just that the property's return value must be defined as ErrorController.</p>
24,560
<p>I have a class like this:</p> <pre><code>public class myClass { public List&lt;myOtherClass&gt; anewlist = new List&lt;myOtherClass&gt;; public void addToList(myOtherClass tmp) { anewList.Add(tmp); } } </code></pre> <p>So I call "addToList" a hundred times, each adding a unique item to the list. I'v...
<p>Given the signature of your addToList method:</p> <pre><code>public void addToList(myOtherClass tmp) { anewList.Add(tmp); } </code></pre> <p>Is is possible that in the consumer of that method, you aren't actually creating a new instance?</p> <p>You said that you are calling addToList 100 times. Presumabl...
<p>Also note that when you use the exact form:</p> <pre><code> for (int j = 0; j &lt; tmpClass.anewList.Count(); j++) </code></pre> <p>The C# compile preforms a special optimization on the loop. If you vary from the syntax (e.g. by pulling the Count property out of the loop into a separate varaible, as you did in yo...
45,248
<p>I'm new to Spring Security. How do I add an event listener which will be called as a user logs in successfully? Also I need to get some kind of unique session ID in this listener which should be available further on. I need this ID to synchronize with another server.</p>
<p>You need to define a Spring Bean which implements <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/context/ApplicationListener.html" rel="noreferrer">ApplicationListener</a>.</p> <p>Then, in your code, do something like this:</p> <pre class="lang-java prettyprint-override"><code...
<p>In Grails, with Spring Security Plugin, you can do this in Config.groovy:</p> <pre><code>grails.plugins.springsecurity.useSecurityEventListener = true grails.plugins.springsecurity.onAuthenticationSuccessEvent = { e, appCtx -&gt; def session = SecurityRequestHolder.request.getSession(false) sessio...
22,013
<p>When running any kind of server under load there are several resources that one would like to monitor to make sure that the server is healthy. This is specifically true when testing the system under load.</p> <p>Some examples for this would be CPU utilization, memory usage, and perhaps disk space. What other resou...
<p>As many as you can afford to, and can then graph/understand/look at the results. Monitoring resources is useful for not only capacity planning, but anomaly detection, and anomaly detection significantly helps your ability to detect security events.</p> <p>You have a decent start with your basic graphs. I'd want t...
<p>I typically watch <code>top</code> and <code>tail -f /var/log/auth.log</code>.</p>
10,061
<p>I'm building a java/spring application, and i may need to incorporate a stateful web service call. Any opinions if i should totally run away from a stateful services call, or it can be done and is enterprise ready?</p>
<p>Stateful web services are a pain to maintain. The mechanism I have seen for them is to have the first call return an id (basically a transaction id) that is used in subsequent calls. A problem with that is that the web service isn't really stateful so it has to load all the information that it needs from some othe...
<p>Statefulness runs counter to the basic architecture of HTTP (ask Roy Fielding), and reduces scalability.</p>
12,024
<p>I am trying to convert my C# code to design (Reverese Engineering) using StarUML. I got the error while performing the Reverse engineering </p> <blockquote> <p>"Error occurred in the process of reverse engineering. message : Catastrophic failure". </p> </blockquote> <p>After the error, the application crashed.</...
<p>One of the problems with staruml is that apparently it does not support generics and when a file has the "&lt;", a parser error occurs</p>
<p>I'm not familiar with StarUML in particular, although there are a couple of ways that it could be going about the process of documenting your assemblies. The most likely method is .Net reflection.</p> <p>Lots of applications struggle with the more recent C# optimisations.</p> <p>The best application for reflecting...
13,944
<p>Are there any wizard type controls in WPF? I need functionality where I can go forward and back and use tabs to select a particular item which will show the details of the nested items. I can use the TabControl control but the tab items are dynamic so I cannot nest the region inside the tab item.</p>
<p>WPF has a navigation infrastructure built in:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms750478.aspx" rel="noreferrer">WPF Navigation Overview</a></p> <p>Also check out the <a href="http://msdn.microsoft.com/en-us/library/aa972123.aspx" rel="noreferrer">wizard sample</a></p>
<p>Found this great example on codeproject that should give you everything that you need:</p> <p><a href="http://www.codeproject.com/Articles/31837/Creating-an-Internationalized-Wizard-in-WPF" rel="nofollow">http://www.codeproject.com/Articles/31837/Creating-an-Internationalized-Wizard-in-WPF</a></p>
36,531
<p>If I have a list of data in a text file seperated by a new line, is there a way to append something to the start, then the data, then append something else then the data again?</p> <p>EG a field X would become new X = X;</p> <p>Can you do this with bash or sed or just unix tools like cut?</p> <p>EDIT:</p> <p>I a...
<p>You simply need to run your batch job in a 64-bit process. The problem is that SharePoint has many COM objects under the hood which are compiled for 64-bit in your test and production environment. The SPSite and SPWeb objects actually wrap the COM objects which is why they fail in your 32-bit process. </p> <p>One w...
<p>I don't think this is a 32/64bit issue as I am in the same situation as far as developing on 32bit and deploying to 64bit. (Actually, we are running a 32bit and 64bit WFE'S) </p> <p>Since the exception is being thrown from the SPSite constructor, I would investigate further, as to whether the machine you are runni...
31,143
<p>Why is Oracle's <code>to_char()</code> function adding spaces?</p> <pre><code>select length('012'), length(to_char('012')), length(to_char('12', '000')) from dual; </code></pre> <p><code>3, 3, 4</code></p>
<p>The extra leading space is for the potential minus sign. To remove the space you can use FM in the format:</p> <pre><code>SQL&gt; select to_char(12,'FM000') from dual; TO_C ---- 012 </code></pre> <p>By the way, note that to_char takes a NUMBER argument; to_char('012') is implicitly converted to to_char(to_number...
<p>Be aware when using the 'fm' syntax it will not include any values after the decimal place unless specified using zeros. For example:</p> <pre><code>SELECT TO_CHAR(12345, 'fm99,999.00') FROM dual </code></pre> <p>returns: <strong>'12,345.00'</strong> </p> <pre><code>SELECT TO_CHAR(1...
29,730
<p>I want to store a URL prefix in an Windows environment variable. The ampersands in the query string makes this troublesome though.</p> <p>For example: I have a URL prefix of <code>http://example.com?foo=1&amp;bar=</code> and want to create a full URL by providing a value for the <code>bar</code> parameter. I then w...
<p>This is not a limitation of the environment variable, but rather the command shell.</p> <p>Enclose the entire assignment in quotes:</p> <pre><code>set "myvar=http://example.com?foo=1&amp;bar=" </code></pre> <p>Though if you try to echo this, it will complain as the shell will see a break in there.</p> <p>You can...
<p>I think this should do it:</p> <pre><code>for /f "tokens=*" %i in (%myvar%) do set %myvar%=%~i </code></pre> <p>But you do not need this, </p> <pre><code>set myvar="http://example.com?foo=1&amp;bar=" start "" %myvar% </code></pre> <p>Will work too, you just need to supply a title to the start command.</p>
39,530
<p>I was running some dynamic programming code (trying to brute-force disprove the Collatz conjecture =P) and I was using a dict to store the lengths of the chains I had already computed. Obviously, it ran out of memory at some point. Is there any easy way to use some variant of a <code>dict</code> which will page part...
<p>Hash-on-disk is generally addressed with Berkeley DB or something similar - several options are listed in the <a href="http://docs.python.org/library/persistence.html" rel="noreferrer">Python Data Persistence documentation</a>. You can front it with an in-memory cache, but I'd test against native performance first; ...
<p>You should bring more than one item at a time if there's some heuristic to know which are the most likely items to be retrieved next, and don't forget the indexes like Charles mentions.</p>
28,038
<p>I have a binded DataGridView where depending on some BoundItem property value that line will be read only. What is the best way to implement this? Thanks</p>
<p>Try The event CellBeginEdit</p> <pre><code>Private Sub Dgv_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles Dgv.CellBeginEdit If YourCondition(BoundItem.Property) then e.cancel = true End Sub </code></pre> <p>This makes the cell readOnly depending on ...
<p>in the rowenter event, set the readonly property of the row accordingly</p> <pre><code>private sub MyView_RowEnter(...) handles MyView.RowEnter MyView.Rows(e.Rowindex).ReadOnly = (condition) end sub </code></pre>
34,173
<p>I've used several modules to make EXEs for Python, but I'm not sure if I'm doing it right.</p> <p>How should I go about this, and why? Please base your answers on personal experience, and provide references where necessary.</p>
<p><a href="https://pypi.org/project/auto-py-to-exe/" rel="noreferrer">Auto PY to EXE</a> - A .py to .exe converter using a simple graphical interface built using Eel and PyInstaller in Python.</p> <hr> <p><a href="http://www.py2exe.org/" rel="noreferrer">py2exe</a> is probably what you want, but it only works on Wi...
<p><a href="http://www.py2exe.org/" rel="nofollow noreferrer">py2exe</a>:</p> <blockquote> <p>py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.</p> </blockquote>
7,157
<p>I deploy a webapp on two different containers (Tomcat and Jetty), but their default servlets for serving the static content have a different way of handling the URL structure I want to use (<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=42411" rel="noreferrer">details</a>).</p> <p>I am therefore looking...
<p>There is no need for completely custom implementation of the default servlet in this case, you can use this simple servlet to wrap request to the container's implementation:</p> <pre><code> package com.example; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class DefaultWrapperServ...
<p>See StaticFile in JSOS: <a href="http://www.servletsuite.com/servlets/staticfile.htm" rel="nofollow noreferrer">http://www.servletsuite.com/servlets/staticfile.htm</a></p>
16,012
<p>Many languages have a facility to check to see if an Object is of a certain type (including parent subclasses), implemented with 'is' and used like this:</p> <pre><code>if(obj is MyType) </code></pre> <p>Or slightly more tediously you can in other languages check by using the 'as' keyword to do a soft typecast and...
<pre><code>if (objectReference instanceof type){ //Your code goes here } </code></pre> <p>More info <a href="http://www.java2s.com/Tutorial/Java/0060__Operators/TheinstanceofKeyword.htm" rel="nofollow noreferrer">here</a>.</p>
<p><code>obj instanceof TargetType</code> returns true just in case <code>TargetType</code> is in the type hierarchy that contains <code>obj</code>.</p> <p>See <a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/op2.html" rel="nofollow noreferrer">Sun's tutorial</a></p>
29,393
<p>Which JDBC jar should I use with java 1.5.0_16 and PostgreSQL 8.3.5?</p>
<p>From the <a href="http://msdn.microsoft.com/en-us/library/1whwt1k7.aspx" rel="nofollow noreferrer">Microsoft Documentation</a>.</p> <blockquote> <p>Use control state only for small amounts of critical data that are essential for the control across postbacks. Do not use control state as an alternative to v...
<p>You can disable view state for all page but you need to rebind datagrid, dataview in every postback. </p> <p>Sometimes it works better then saving a huge viewstate on the client.</p> <p>For standard server controls: if you modify Control Properties after init, then all modifications will be saved in ViewState too....
49,988
<p>I'm applying for a masters in fall of next year and was wondering if anyone had suggestions for interesting/challenging master's degrees in CS. I think that even though picking the right university is important, it is even more important to pick a master's degree where you'll find talented/creative people to interac...
<blockquote> <p>background: never taken AI, discrete math, compilers, operating systems, data structures, cryptography or anything involving c/c++ courses</p> </blockquote> <p>Hmmm ... It would have been OK had you not taken cryptogrophy or AI, but if you dont have an idea of Data Structures, Operating Systems, Comp...
<p>I would suggest taking a linear algebra course at a community college or at least self-teaching yourself, as regardless of what you go into, you will need this material. This is a generalization, but it seems to be true!</p> <p>That being said, here are my thoughts:</p> <ol> <li><p>Social interaction - The data mi...
29,611
<p>The amount of posts being voted to closed is getting ridiculous. The last two posts have been printing related, one looking for information and the other a design question for 3D printing yet both have been voted to be closed. </p> <p>Yes, I have read the other Meta post about how closing is not permanent (<a hre...
<p>I absolutely agree. I believe we all want this site to maintain high quality, but right now almost no questions fall within our desired scope and form.</p> <p>I think we either need to:</p> <ul> <li>Change the acceptable scope of questions to be asked</li> <li>Change how we welcome new users</li> </ul> <p>Right n...
<p>I've been active on SO since it was in beta, and have participated in numerous SE sites when they were in beta.</p> <p>It's my impression that there is much more enthusiasm for close votes here than in other sites which launched out of beta. I know that seems to discourage me from participating more, and may disco...
25
<p>I need to read account number from Maestro/Mastercard with smart card reader. I am using Java 1.6 and its javax.smartcardio package. I need to send APDU command which will ask EMV application stored on card's chip for PAN number. Problem is, I cannot find regular byte array to construct APDU command which will retur...
<p>You shouldn't need to wrap the APDU further. The API layer should take care of that.</p> <p>It looks like the 0x6D00 response just means that the application did not support the INS.</p> <p>Just troubleshooting now, but you did start out by selecting the MasterCard application, right?</p> <p>I.e. something like t...
<p>what about using a scanner, getting a picture of the card, scanning the content of the picture with a good java ocr library ( like <a href="http://ocr4j.sourceforge.net/" rel="nofollow">http://ocr4j.sourceforge.net/</a> for example ) and search for a (usually) 16 digit sequence XXXX-XXXX-XXXX-XXXX , then you will g...
35,899
<p>I want to check that two passwords are the same using Dojo.</p> <p>Here is the HTML I have:</p> <p><code></p> <blockquote> <p><code>&lt;form id="form" action="." dojoType="dijit.form.Form" /</code>></p> <p><code>&lt;p</code>>Password: <code>&lt;input type="password"<br> name="password1"<br> id=...
<p>This will get you a lot closer</p> <ul> <li>setting intermediateChanges=false keeps the validator running at every keystroke.</li> <li>the validation dijit's constraint object is passed to its validator. Use this to pass in the other password entry</li> <li>dijit.form.Form automatically calls isValid() on all its ...
<p>I've solved it!</p> <p>This <a href="http://dojotoolkit.org/forum/dijit-dijit-0-9/dijit-support/password-confirmation-validation" rel="nofollow noreferrer">page on the Dojo forum</a> was helpful.</p> <p>I changed the HTML for the confirm password to:</p> <blockquote> <p><code> <code>&lt;p</code>>Confirm: <cod...
39,744
<p>I have been asked to provide information on available techniques for assessing our current, and any future websites for security problems. the request is in the form of</p> <blockquote> <p>Do you know of any good free one that examines for security holes?</p> </blockquote> <p>I think our data security is probabl...
<p>NO. numerical primary keys will not reused, except you specify them manually(you should really avoid this!)</p>
<p>Yeah, it really depends on the way you generate the id.</p> <p>For example if you are using a GUID as the primary key, most implementations of getting a random new Guid are not likely to pick another guid again, but it will given enough time and if the Guid is not in the table the insert statement will go fine, bu...
31,606
<p>So far i have got the code below which works lovely when trying an update, delete or select statement. However I run into problems when I try to use an insert. If someone could point me in the correct direction i would be grateful.</p> <pre><code>private function escape($value) { if(get_magic_quotes_gpc()) ...
<p>It may help to start with using valid insert statements. </p> <pre><code>VALUES ( a , b , c ) </code></pre> <p>Not </p> <pre><code>VALUES a, b , c </code></pre> <p>Additionally, why the dickens are you combining a perpared insert with string substituion?</p> <p>you mean </p> <p>$q->prep("blah blah blah VALUES...
<p>You should probably wrap the values() in parens too, like:</p> <pre><code>$MyDB-&gt;prep("INSERT INTO `demo` (`id`, `name`, `score`, `dept`, `date`) VALUES ('1','James Kablammo', '1205550', 'Marketing', '$date'")); </code></pre>
40,944
<p>I have three related questions. </p> <p>I want to create a word file with a name from C++. I want to be able to sent the printing command to this file, so that the file is being printed without the user having to open the document and do it manually and I want to be able to open the document. Opening the document s...
<p>You can use Office Automation for this task. You can find answers to frequently asked questions about Office Automation with C++ at <a href="http://support.microsoft.com/kb/196776" rel="noreferrer">http://support.microsoft.com/kb/196776</a> and <a href="http://support.microsoft.com/kb/238972" rel="noreferrer">http:/...
<p>I have no experience from integrating with Microsoft Office, but I guess there are some APIs around that you can use for this.</p> <p>However, if what you want to accomplish is a rudimentary way of printing formatted output and exporting it to a file that can be handled in Word, you might want to look into the RTF ...
17,552
<p>I would like to retrieve the ethernet address of the network interface that is used to access a particular website.</p> <p>How can this be done in Java?</p> <p><strong>Solution</strong> Note that the accepted solution of <code>getHardwareAddress</code> is only available in Java 6. There does not seem to be a solut...
<p><a href="http://java.sun.com/javase/6/docs/api/java/net/NetworkInterface.html#getHardwareAddress%28%29" rel="noreferrer"> java.net.NetworkInterface.getHardwareAddress</a> (method added in Java 6)</p> <p>It has to be called on the machine you are interested in - the MAC is not transferred across network boundaries (...
<p>You can get the address that connects to your ServerSocket using <a href="http://java.sun.com/javase/6/docs/api/java/net/NetworkInterface.html#getInetAddresses()" rel="nofollow noreferrer">http://java.sun.com/javase/6/docs/api/java/net/NetworkInterface.html#getInetAddresses()</a></p> <p>However if your client is co...
5,411
<p>Both are mathematical values, however the float does have more precision. Is that the only reason for the error - the difference in precision? Or is there another potential (and more serious) problem?</p>
<p>It's because the set of integer values does not equal the set of float values for the 'int' and 'float' types. For example, the float value 0.5 has no equal in the integer set and the integer value 4519245367 might not exist in the set of values a float can store. So, the checker flags this as an issue to be checked...
<p>If you need to get around this (you have a legitimate reason and are happy none of the issues mentioned in the other answers are an issue for you) then just cast from one type to another.</p>
5,894
<p>Without routing, <code>HttpContext.Current.Session</code> is there so I know that the <code>StateServer</code> is working. When I route my requests, <code>HttpContext.Current.Session</code> is <code>null</code> in the routed page. I am using .NET 3.5 sp1 on IIS 7.0, without the MVC previews. It appears that <code>Ac...
<p>Got it. Quite stupid, actually. It worked after I removed &amp; added the SessionStateModule like so:</p> <pre><code>&lt;configuration&gt; ... &lt;system.webServer&gt; ... &lt;modules&gt; &lt;remove name="Session" /&gt; &lt;add name="Session" type="System.Web.SessionState.SessionStateModule"...
<p>a better solution is </p> <p></p> <p>runAllManagedModulesForAllRequest is a clever thing to do respect removing and resinserting session module.</p> <p>alk.</p>
26,821
<p>How can I do a script to catch strings as input and open them on a Firefox document? Each link would go to a different window or tab. Any ideas would be much appreciated.</p> <p>I just want to be able to take some links and open them. For example I have 50 Links. And copying and parsing those 50 Links take a really...
<p>if i got you right, i guess you could do something like this. This will open the four urls listed but it will probably be blocked by the popup blocker.</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Documento sin t&amp;iacute;tulo&lt;/titl...
<p>Write this to a file names "links.html" on your hard disk:</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;Your links&lt;/title&gt;&lt;/head&gt; &lt;body&gt; Your links:&lt;br /&gt; &lt;a href="XXX"&gt;XXX&lt;/a&gt;&lt;br /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Replace the two "XXX" with one link a...
45,281
<p>How does one go about authoring a <em><strong>Regular Expression</strong></em> that matches against all strings that are valid URIs, while failing to match against all strings that are invalid URIs?</p> <p>To be specific about what I am referencing when I say URI, I have added a link below for the most current URI R...
<p>Does <a href="http://msdn.microsoft.com/en-us/library/system.uri.iswellformeduristring.aspx" rel="noreferrer">Uri.IsWellFormedUriString</a> work for you?</p>
<p>Are there some specific URIs you care about or are you trying to find a single regex that validates <a href="http://rfc.net/std0066.html" rel="nofollow noreferrer">STD66</a>?</p> <p>I was going to point you to <a href="http://www.unix.com.ua/rfc/std0066.html#p50" rel="nofollow noreferrer">this regex</a> for parsing...
5,070
<p><a href="https://stackoverflow.com/questions/180/function-for-creating-color-wheels">Original Question</a></p> <p>I am looking for a function that attempts to quantify how "distant" (or distinct) two colors are. This question is really in two parts: </p> <ol> <li>What color space best represents human vision?</li>...
<p>Convert to La*b* (aka just plain "Lab", and you'll also see reference to "CIELAB"). A good quick measaure of color difference is </p> <blockquote> <p>(L1-L2)^2 + (a1-a2)^2 + (b1-b2)^2</p> </blockquote> <p>Color scientists have other more refined measures, which may not be worth the bother, depending on accur...
<p>The easiest <em>distance</em> would of course be to just consider the colors as 3d vectors originating from the same origin, and taking the distance between their end points.</p> <p>If you need to consider such factors that green is more prominent in judging intensity, you can weigh the values.</p> <p><a href="htt...
2,372
<p>I have a 3D printer at home, the Colido Compact, and for some reason when I 3D print big flat surfaces a really weird thing happens. I'm using some PLA from Colido too I think</p> <p><a href="https://i.stack.imgur.com/QOMPF.jpg" rel="nofollow noreferrer" title="Weeeird surface artefacts"><img src="https://i.stack.i...
<p>The oozing is due to hot-end getting hot before the bed leveling procedure: if you move the hot-end warm up command <strong>after</strong> the <code>G29</code> line you avoid that oozing</p> <pre><code>; Ender 3 Custom Start G-code M104 S{material_print_temperature_layer_0} ; Set Extruder temperature M140 S{materia...
<p>The best solution would be to heat the bed, but not the nozzle at startup. If you level with a cold bed, your ABL mesh is going to be off, since the aluminum heated bed plate expands considerably once the heat is applied. </p> <p>You could also issue a retract command before leveling, and then add a counteracting...
1,142
<p>When A Python exception is thrown by code that spans multiple lines, e.g.:</p> <pre><code> myfoos = [foo("bar", "baz", "quux", i) for i in range(10)] </code></pre> <p>Python will report the line number of the last line, and will show the code fragment from that li...
<p>Finding the beginning of the line will be really hard. You'll have to either parse the Python or maybe dig into the compiled byte code. There are modules in the standard library for parsing Python, but I can tell you from experience that interpreting their output is a black art. And I'm not sure the compiled byte...
<p>In a try/except block you can except NameError and try setting NameError.lineno, though I'm not exactly sure if or how this works, but it's the best I've found thusfar.</p> <pre><code>try: somecode except NameError NameError.lineno = [1,4] </code></pre> <p>You'll have to figure out where the statement begi...
37,178
<p>One of my programs requires a reliable way to log across unreliable network (ie internet). The sender or receiver may go offline any time and can come back later. But any message sent by client should not be missed. Obviously syslog does not fit the bill. I am exploring the use of messaging servers like Apache Activ...
<p>That all sounds fine to me</p>
<p>You may want to check out <A href="http://www.balabit.com/network-security/syslog-ng/" rel="nofollow noreferrer">syslog-ng</A> which has a tcp mode. This allows for reliable delivery, but you have to make sure you configure it correctly.</p>
37,671
<p>Does anybody have a snippet of Java that can return the newest file in a directory (or knowledge of a library that simplifies this sort of thing)?</p>
<p>The following code returns the last modified file or folder:</p> <pre><code>public static File getLastModified(String directoryFilePath) { File directory = new File(directoryFilePath); File[] files = directory.listFiles(File::isFile); long lastModifiedTime = Long.MIN_VALUE; File chosenFile = null; ...
<p>Here's a small modification to Jose's code which makes sure the folder has at least 1 file in it. Work's great in my app!</p> <pre><code>public static File lastFileModified(String dir) { File fl = new File(dir); File choice = null; if (fl.listFiles().length&gt;0) { File[] files =...
36,323
<p>I have a Request object which contains a list of Approvers. An approver has a name and an approval position.</p> <ol> <li>Mathew </li> <li>Mark </li> <li>Luke </li> <li>John</li> </ol> <p>Ultimately, a request will move through this chain, starting at Mathew and ended at John.</p> <p>I need to be able to re-order...
<p>How large are the lists likely to be? <a href="http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx" rel="noreferrer"><code>List&lt;T&gt;</code></a> is likely to be the easiest representation of the collection, but it means a copy is required every time you insert into or remove from the middle of the list. "Editin...
<p>Maintaining a position property is a pain, as you need to make lots of modifications to change something (while keeping everything logical). It also makes it hard to serialize/deserialize efficiently.</p> <p>Can you not simply infer the position from the position in a <code>List&lt;T&gt;</code> or similar? Then you...
29,609
<p>How do I programmatically set the record pointer in a C# DataGridView? </p> <p>I've tried "DataGridView.Rows[DesiredRowIndex].Selected=true;", and that does not work. All it does is highlight that row within the grid; it doesn not move the record pointer to that row.</p>
<p>To change the active row for the datagrid you need to set the current cell property of the datagrid to a non-hidden non-disabled, non-header cell on the row that you have selected. You'd do this like:</p> <pre><code>dataGridView1.CurrentCell = this.dataGridView1[YourColumn,YourRow]; </code></pre> <p>Making sure th...
<p>Try setting the focus of the <code>DataGrid</code> first . Some thing like this</p> <pre><code>dataGridView1.Focus(); dataGridView1.CurrentCell = this.dataGridView1[YourColumn,YourRow]; </code></pre> <p>This worked in my case, hope it helps you as well</p>
11,750
<p>As a matter of fact you have smth like <code>/java/src</code> and <code>/java/test</code>. But then, how do you name packages/classes the unittests go to? The same as classes they are written against? And when refactoring comes, do you manually rename in /test? Please share your experience.</p>
<p>I keep the tests in the same package as the class they are testing. This allows me to setup tests using package private members (when required). It also provides a nice, easy to remember convention. When I refactor, I usually do manually refactor the corresponding test classes. There was some IDE a while back th...
<p>In Java, keeping them in the same package as the class being tested, is a must. It's the only way to test methods with default/package-protected visibility.</p>
23,544
<p>I have a sample held in a buffer from DirectX. It's a sample of a note played and captured from an instrument. How do I analyse the frequency of the sample (like a guitar tuner does)? I believe FFTs are involved, but I have no pointers to HOWTOs.</p>
<p>The FFT can help you figure out where the frequency is, but it can't tell you <em>exactly</em> what the frequency is. Each point in the FFT is a &quot;bin&quot; of frequencies, so if there's a peak in your FFT, all you know is that the frequency you want is somewhere within that bin, or range of frequencies.</p> <p...
<p>Apply a <a href="http://en.wikipedia.org/wiki/Discrete_Fourier_transform" rel="nofollow noreferrer">DFT</a> and then derive the fundamental frequency from the results. Googling around for DFT information will give you the information you need -- I'd link you to some, but they differ greatly in expectations of math ...
9,104
<p>How do I make an instance of gwtext.client.widgets.Window appear at specific DIV in my html ? I tried window.anchorTo(DOM.getElementById("Some_Div"),"left", new int[]{0,0}), thinking the window will anchor itself to div id="Some_Div" in my html. it didnt. </p>
<p>I haven't used the gwt-ext library in a couple of months, but you might want to try this if you haven't already. It <em>should</em> attach the widget where you want it. That said, there are some cases where the gwt-ext widgets react in ways that are not intuitive to someone who really understands the normal GWT widg...
<p>You should use </p> <pre><code>window.alignTo(DOM.getElementById("Some_Div"),"tl-tl", new int[]{0,0}); </code></pre> <p>for positioning the window's top left to Some_Div's top left corner.</p> <p>These are the valid strings for position argument:</p> <pre><code>Value Description ----- -------------------------...
40,614
<p>Could someone explain? I understand the basic concepts behind them but I often see them used interchangeably and I get confused. </p> <p>And now that we're here, how do they differ from a regular function?</p>
<p>A <b>lambda</b> is just an anonymous function - a function defined with no name. In some languages, such as Scheme, they are equivalent to named functions. In fact, the function definition is re-written as binding a lambda to a variable internally. In other languages, like Python, there are some (rather needless) di...
<p>Lambda is an anonymous function <em>definition</em> that is not (necessarily) bound to an identifier.</p> <blockquote> <p>&quot;Anonymous functions originate in the work of Alonzo Church in his invention of the lambda calculus, in which all functions are anonymous&quot; - <a href="https://en.wikipedia.org/wiki/Anony...
27,173
<p>Is this functionality going to be put into a later Java version?</p> <p>Can someone explain why I can't do this, as in, the technical way Java's <code>switch</code> statement works?</p>
<p>Switch statements with <code>String</code> cases have been implemented in <a href="http://openjdk.java.net/projects/jdk7/features/" rel="nofollow noreferrer">Java SE 7</a>, at least 16 years <a href="https://bugs.java.com/bugdatabase/view_bug.do?bug_id=1223179" rel="nofollow noreferrer">after they were first request...
<p>Not very pretty, but here is another way for Java 6 and bellow: </p> <pre><code>String runFct = queryType.equals("eq") ? "method1": queryType.equals("L_L")? "method2": queryType.equals("L_R")? "method3": queryType.equals("L_LR")? "method4": "method5"; Method m = this.get...
43,894
<p>In an application that is hosting several WCF services, what would be the best way to add custom configuration information for each service? For example you may want to pass or set a company name or specify the connectionString a service or some other parameter. </p> <p>I'm guessing this might be possible by imple...
<p>I know this is old, but it was never marked answered, so I thought I'd take a shot. If I understand what you're after, you can do it with a custom ServiceHostFactory.<br> Good post on this <a href="http://blogs.msdn.com/dotnetinterop/archive/2008/09/22/custom-service-config-file-for-a-wcf-service-hosted-in-iis.aspx...
<p>It depends a lot of where and how you expect to use said information. If it's not something that's going to do a lot with the infrastructure (i.e. getting the services to run and processing requests), I'd be tempted to say that trying to push that into the WCF behaviors might be adding more complexity than it's wort...
25,930
<p>our partners sites leverages our iframes in their own websites. I was wondering if there is a way to track the analytics on the iframes. </p> <p>The problem is, if we also utilize these iframes on our own website, how do i avoid duplicate tracking where a visit is counted on our domain's analytics and also counted ...
<p>Adding the Google Analytics code to the iframe should work just fine. The easiest way to avoid duplicate tracking is probably to add a query parameter like ?partner=foo to the URLs that your partners use. You can check for your own site's value and not run the Google Analytics code at all, and also pass the partner ...
<p>You can also add <code>utm_nooverride=1</code> to your iframe source tag. This will make sure that the page that called your iframe on the 3rd party site will not get credit for the referral, but rather the initial source (AdWords campaign, search query, etc.).</p> <p>Example:</p> <pre><code>&lt;iframe src="mypage...
25,865
<p><strong>Scenario:</strong></p> <p>The task I have at hand is to enable a single-signon solution between different organizations/websites. I start as an authenticated user on one organization's website, convert specific information into an Xml document, encrypt the document with triple des, and send that over as a p...
<p>Send back a document that contains the from with hidden input and include an onload handler that posts the form immediately to the other site. Using jquery's document.ready() solves the issue of whether the DOM is loaded before the post occurs, though there are other ways to do this without jquery. You might want ...
<p>You are thinking about this too process oriented, it would take you a month of sundays to try and work out all the bugs and moving parts with what you suggest.</p> <p>You are already doing a post to another server so you really don't need to do anything. The form you have is already perfect, and when the other ser...
28,924
<p>I have a Rails project which has a Postgres database for the actual application but which needs to pull a heck of a lot of data out of an Oracle database. </p> <p>database.yml looks like</p> <pre><code>development: adapter: postgresql database: blah blah ... oracle_db: adapter: oracle database: blah bl...
<p>I believe this might have to do with your model name, rather than your connection. The Rails convention is that model class names are CamelCase, while the files they reside in are lowercase+underscore.</p> <p>The "LegacyModel" class should therefore be in <code>models/legacy_model.rb</code>. Your statement about ...
<p>I wrote something for an app at work that handles connections to other databases' at runtime, it might be able to help.</p> <p><a href="http://github.com/cherring/connection_ninja" rel="nofollow noreferrer">http://github.com/cherring/connection_ninja</a></p>
19,451
<p>Before the print has actually started I have set up Auto Bed Leveling using a BLTouch sensor, during the period that this runs I find that material leaks out of the nozzle and curls back onto itself and by the time it finishes it is substantial enough to cause problems when the nozzle is primed drawing the line to ...
<p>The oozing is due to hot-end getting hot before the bed leveling procedure: if you move the hot-end warm up command <strong>after</strong> the <code>G29</code> line you avoid that oozing</p> <pre><code>; Ender 3 Custom Start G-code M104 S{material_print_temperature_layer_0} ; Set Extruder temperature M140 S{materia...
<p>The best solution would be to heat the bed, but not the nozzle at startup. If you level with a cold bed, your ABL mesh is going to be off, since the aluminum heated bed plate expands considerably once the heat is applied. </p> <p>You could also issue a retract command before leveling, and then add a counteracting...
1,141
<p>How do you programmatically eject(safely remove) an USB mass storage device in Windows (XP)?</p>
<p>In <a href="http://www.autoitscript.com/autoit3/" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wOUx6.jpg" alt="" /> autoit</a>, you have a <a href="http://www.autoitscript.com/forum/index.php?showtopic=48585" rel="nofollow noreferrer">script</a> which does just that.</p> <p>It basically comes from t...
<p>You could spawn a process and use a <a href="http://quick.mixnmojo.com/readmes/USBDiskEjector.html" rel="nofollow noreferrer">command line tool</a>. This would also work from other languages such as java where calling the Win32 api is harder.</p>
25,269
<p>I have a sql statement that consists of multiple SELECT statements. I want to limit the total number of rows coming back to let's say 1000 rows. I thought that using the SET ROWCOUNT 1000 directive would do this...but it does not. For example:</p> <pre><code>SET ROWCOUNT 1000 select orderId from TableA select nam...
<p>Not in one statement. You're going to have to subtract @@ROWCOUNT from the total rows you want after each statement, and use a variable (say, "@RowsLeft") to store the remaining rows you want. You can then SELECT TOP @RowsLeft from each individual query...</p>
<p>The following worked for me:</p> <pre><code>CREATE PROCEDURE selectTopN ( @numberOfRecords int ) AS SELECT TOP (@numberOfRecords) * FROM Customers GO </code></pre>
47,413
<p>I use <a href="http://rsync.samba.org/" rel="nofollow noreferrer">rsync</a> to synchronize files to Windows clients in a server agnostic way. What methods are available to send the progress of rsync to the parent process for display in a gui progress bar?</p> <p>I imagine two or three choices exist. (1) Watch STDOU...
<p>For this type of tasks, I use my own <a href="http://www.autoitscript.com/autoit3/" rel="nofollow noreferrer">AutoIt</a> script (freeware, Windows only). The script redirects the standard output into a graphical window, displaying it with the ability to scroll back, etc (very useful in long processes like XCOPYs / P...
<p>Check out <a href="http://www.download.com/DeltaCopy/3000-2242_4-10471616.html" rel="nofollow noreferrer">DeltaCopy</a>. It is a Windows GUI for rsync.</p>
2,955
<p>Is there a good way to find out which exceptions a procedure/function can raise in Delphi (including it's called procedures/functions)? </p> <p>In Java you always have to declare which exceptions that can be thrown, but this is not the case in Delphi, which could lead to unhandled exceptions. </p> <p>Are there any...
<p>(Edit: It is now obvious that the question referred <em>only</em> to design-time checking.)</p> <p>New answer:</p> <p>I cannot state whether there are any tools to check this for you. Pascal Analyzer, for one, does not.</p> <p>I <em>can</em> tell you, however, that in most Delphi applications, even if there was a...
<p>Finalization sections of units can raise exceptions too. These will slip by I think... and are also somewhat problematic.</p> <p>I think Delphi IDE has a build-in &quot;stack trace&quot; or &quot;stack tree&quot; something like.</p> <p>This question reminds me of Skybuck's TRussianRoulette game... google it, it's co...
9,817
<p>During my work with databases I noticed that I write query strings and in this strings I have to put several restrictions in the where-clause from a list/array/collection. Should look like this:</p> <pre><code>select * from customer where customer.id in (34, 26, ..., 2); </code></pre> <p>You can simplify this by ...
<p>Note: This answers was good when it was written 11 years ago, but now there are far better options to do this more cleanly in a single line, both using only Java built-in classes or using a utility library. See other answers below.</p> <hr> <p>Since strings are immutable, you may want to use the StringBuilder clas...
<p>You may be able to use LINQ (to SQL), and you may be able to make use of the Dynamic Query LINQ sample from MS. <a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic...
25,183
<p>I am writing a Firefox extension. I would like to search the current webpage for a set of words, and count how many times each occurs. This activity is only performed when the user asks, but it must still happen reasonably quickly.</p> <p>I am currently using indexOf on the BODY tag's innerHTML element, but am find...
<p>I'm not sure if it is the fastest but the following worked pretty quickly for me.</p> <pre><code>var words = document.body.innerHTML.replace(/&lt;.*?&gt;/g,'').split(/\s+/); var i = words.length; var keywordCounts = {'keyword': 0, 'javascript': 0, 'today': 0}; var keywords = []; var keywordMatcher = ''; var word; f...
<p>node.nodeType should work as well and maybe a little faster since it is integer. A value of 3 is for text nodes.</p>
45,316
<p>Given the Python function:</p> <pre><code>def a_method(arg1, arg2): pass </code></pre> <p>How can I extract the number and names of the arguments. I.e., given that I have a reference to <code>func</code>, I want the <code>func.[something]</code> to return <code>("arg1", "arg2")</code>.</p> <p>The usage scenar...
<p>Take a look at the <a href="http://docs.python.org/library/inspect.html" rel="noreferrer"><code>inspect</code></a> module - this will do the inspection of the various code object properties for you.</p> <pre><code>&gt;&gt;&gt; inspect.getfullargspec(a_method) (['arg1', 'arg2'], None, None, None) </code></pre> <p>T...
<p>What about <code>dir()</code> and <code>vars()</code> now?</p> <p>Seems doing exactly what is being asked super simply…</p> <p><strong>Must be called from within the function scope.</strong></p> <p>But be wary that it will return <em>all</em> local variables so be sure to do it at the very beginning of the functi...
26,899
<p>Does anyone know of where to find unit testing guidelines and recommendations? I'd like to have something which addresses the following types of topics (for example):</p> <ul> <li>Should tests be in the same project as application logic?</li> <li>Should I have test classes to mirror my logic classes or should I ha...
<p>I would recommend <a href="https://rads.stackoverflow.com/amzn/click/com/0321146530" rel="noreferrer" rel="nofollow noreferrer">Kent Beck's</a> book on TDD.</p> <p>Also, you need to go to <a href="http://martinfowler.com/articles/mocksArentStubs.html" rel="noreferrer">Martin Fowler's</a> site. He has a lot of good ...
<p>I insistently recommend you to read <a href="https://rads.stackoverflow.com/amzn/click/com/0321146530" rel="nofollow noreferrer" rel="nofollow noreferrer">Test Driven Development: By Example</a> and <a href="https://rads.stackoverflow.com/amzn/click/com/0131016490" rel="nofollow noreferrer" rel="nofollow noreferrer"...
13,238
<p>Should I use a dedicated network channel between the database and the application server?</p> <p>...or... </p> <p>Connecting both in the switch along with all other computer nodes makes no diference at all?</p> <p>The matter is <strong>performance!</strong></p>
<p>Declare it like this:</p> <pre><code>&lt;bean id="doubleValue" class="java.lang.Double"&gt; &lt;constructor-arg index="0" value="3.7"/&gt; &lt;/bean&gt; </code></pre> <p>And use like this:</p> <pre><code>&lt;bean id="someOtherBean" ...&gt; &lt;property name="value" ref="doubleValue"/&gt; &lt;/bean&gt; </cod...
<p>Why don't you just use a <strong>Double</strong>? any reason?</p>
8,462
<p>I'm looking to add a tooltip to each row in a bound datagrid in vb.net winforms. How can this be done?</p>
<p>I haven't tried this myself but I would give it a shot:</p> <pre><code>System.Windows.Forms.ToolTip formToolTip = new System.Windows.Forms.ToolTip(); formToolTip .SetToolTip(item, "Row Tooltip"); </code></pre> <p>Where <code>item</code> corresponds to the cell you're setting the tool tip for.</p>
<pre><code>row.cells[indexof].ToolTipText= "tootip here". </code></pre> <p>In winforms, it doesn't look like you can do the whole row.</p> <p>if you NEED the whole row you can loop through the cells.</p> <pre><code> foreach (DataGridViewCell cell in row.Cells) { cell.ToolTipText =...
27,033
<p>I saw this quote on the question: <a href="https://stackoverflow.com/questions/105710">What is a good functional language on which to build a web service?</a></p> <blockquote> <p>Scala in particular doesn't support tail-call elimination except in self-recursive functions, which limits the kinds of composition you...
<p>This post: <a href="https://stackoverflow.com/questions/72209/recursion-or-loop#72522">Recursion or Iteration?</a> might help.</p> <p>In short, tail call optimization is hard to do in the JVM because of the security model and the need to always have a stack trace available. These requirements could in theory be sup...
<p>All sources point to the JVM being unable to optimize in the case of tail recursion, but upon reading <a href="http://books.google.ca/books?id=iPHtCfZQyqQC&amp;printsec=frontcover&amp;dq=java%20performance%20tuning&amp;hl=en&amp;ei=gGH2TOrfM4SKlwfT0ozVBQ&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=1&amp;ved...
13,137
<p>I can't get the inner div (with Hello World) to fit inside the "box" div in this code example (also at <a href="http://www.toad-software.com/test.html" rel="nofollow noreferrer">http://www.toad-software.com/test.html</a>).</p> <p>Despite the body being set to 100%, the inner div will not be contained! This is a tes...
<p>add <code>overflow:hidden;</code> to the container <code>&lt;div&gt;</code></p>
<p>add <code>overflow:hidden;</code> to the container <code>&lt;div&gt;</code></p>
32,456
<p>I've got a 1-based array of four items which I need to traverse. For a given index in the array, I need to work out the index of the next item, and the index of the previous item. This sounds simple but the array needs to wrap around. So when you are at the beginning of the array, the previous item is considered to ...
<p>Since modulo always works better on 0-based ranges, you can turn it into one of these using <code>CurrentItem - 1</code>.</p> <p>Then, with modulo 4, adding 3 is the same as subtracting 1 but has the advantage of never going negative (some modulo operators may not like negatives).</p> <p>Then you once again add 1 ...
<p>It might depends on the properties of your Modulus against negative values, but in Lua the following works:</p> <pre><code>for i = 1, 8 do local idxF = i % 4 + 1 local idxB = (i - 2) % 4 + 1 print(i .. " " .. idxF .. " " .. idxB) end </code></pre> <p>Should be <code>PreviousItem = Modulus(CurrentItem - 2, 4)...
40,484
<p>I'm wondering if a Java library can be called from a VB.net application.</p> <p>(A Google search turns up lots of shady answers, but nothing definitive)</p>
<p>No, you can't. Unless you are willing to use some "J#" libraries (which is not nearly the same as Java) or <a href="http://www.ikvm.net/" rel="nofollow noreferrer">IKVM</a> which is a Java implementation that runs on top of .NET, but as their documentation says:</p> <blockquote> <p>IKVM.OpenJDK.ClassLibrary.dll: ...
<p>You could use JNI to instantiate a virtual machine and then use Java Classes. It will be some fun, though, because you would need to use C++ as a bridge between VB.Net and Java.</p> <p>This article in java world has a quick tutorial on how to use Java from C++ and viceversa.</p> <p><a href="http://www.javaworld.c...
18,454
<p>What are some important practices to follow when creating a .NET assembly that is going to be embedded to SQL Server 2005?</p> <p>I am brand new to this, and I've found that there are significant method attributes like:</p> <pre><code>[SqlFunction(FillRowMethodName = "FillRow", TableDefinition = "letter nchar(1)")...
<p>Some that I remember:</p> <ul> <li>Keep its usage to a minimum, only use it when T-SQL proved too complex.</li> <li>Avoid pointers/cursors at all costs because a for loop is so easily abusable in CLR context.</li> <li>Only use the SQL-Server native data types unless totally necessary.</li> </ul> <p>Can't remember ...
<p>I would strongly advise against putting .net assemblies in your database server, think n-tier applications. Persistence &lt;- Business Logic &lt;-Presentation Logic &lt;- client Keep your Logic in your Business Logic layer. </p> <p>The only reason I can think of to put .net in your database would to add a new compl...
9,757
<p>In an information security lab I'm working on, I've been tasked with executing multiple commands with a single call to "system()" (written in C, running on Fedora). What is the syntax that will allow me to execute more than command through system()? (The idea being you could execute arbitrary commands through a pr...
<p>That depends on the shell being invoked to execute the commands, but in general most shells use <code>;</code> to separate commands so something like this should work:</p> <pre><code>command1; command2; command3 </code></pre> <p>[EDIT]</p> <p>As @dicroce mentioned, you can use <code>&amp;&amp;</code> instead of <...
<p>One possibility comes immediately to mind. You could write all the commands to a script then run it with:</p> <pre><code>system ("cmd.exe /c \"x.cmd\""); </code></pre> <p>or, now that I've noticed you're running on Fedora:</p> <pre><code>system ("x.sh"); </code></pre>
30,467
<p>I would like to replicate this in python:</p> <pre><code>gvimdiff &lt;(hg cat file.txt) file.txt </code></pre> <p>(hg cat file.txt outputs the most recently committed version of file.txt)</p> <p>I know how to pipe the file to gvimdiff, but it won't accept another file:</p> <pre><code>$ hg cat file.txt | gvimdiff...
<p>It can be done. As of Python 2.5, however, this mechanism is Linux-specific and not portable:</p> <pre><code>import subprocess import sys file = sys.argv[1] p1 = subprocess.Popen(['hg', 'cat', file], stdout=subprocess.PIPE) p2 = subprocess.Popen([ 'gvimdiff', '/proc/self/fd/%s' % p1.stdout.fileno(), fi...
<p>It just dawned on me that you are probably looking for one of the popen functions.</p> <p>from: <a href="http://docs.python.org/lib/module-popen2.html" rel="nofollow noreferrer">http://docs.python.org/lib/module-popen2.html</a></p> <p>popen3(cmd[, bufsize[, mode]]) Executes cmd as a sub-process. Returns the fi...
10,386
<p>I have an XML document which looks like this:</p> <pre><code>&lt;xconnect&gt; &lt;type&gt;OK&lt;/type&gt; &lt;response/&gt; &lt;report&gt; &lt;id&gt;suppressionlist_get&lt;/id&gt; &lt;name&gt;Suppression List Get&lt;/name&gt; &lt;timestamp&gt;24 Oct 08 @ 10:16AM&lt;/timestamp&gt; &lt;records type=\"...
<p>Try: </p> <pre><code>DataSet dataSet = new DataSet(); dataSet.ReadXML("Path to XML"); this.GridView1.DataMember = "record"; this.GridView1.DataSource = dataSet; this.GridView1.DataBind(); </code></pre>
<p>Create a test DataSet and write it out to Xml to get a feel for the Xml format used by a dataset, then either convert the Xml format to match this and then load it in to the Dataset using <code>DataSet.LoadXml()</code>. </p> <p>Or you could build a DataSet on the fly from your existing Xml format.</p>
28,830
<p>I was reading about refactoring a large slow SQL Query over <a href="https://stackoverflow.com/questions/320919/refactoring-extreme-sql-queries">here</a>, and the current highest response is from Mitch Wheat, who wants to make sure the query uses indexes for the major selects, and mentions:</p> <blockquote> <p>Fi...
<p>There is no need to 'rebuild' an index. They are always kept up-to-date. Maybe he was referring to rebuilding the table. Depending on your usage patterns and schema, you can get fragmented pages in InnoDB, and I think in MyISAM also. Rebuilding the table can improve performance by getting rid of fragmentation of...
<p>The answer you linked to about "regular maintenance" was in the specific context of a temporary table that gets truncated and repopulated regularly. You don't need to do this to the vast majority of MySQL database installs.</p>
41,607
<p>I am looking for a Windows based library which can be used for parsing a bunch of C files to list global and local variables. The global and local variables may be declared using typedef. The output (i.e. list of global and local variables) can then be used for post processing (e.g. replacing the variable names with...
<p>Some of the methods available:</p> <ul> <li><a href="http://www.cs.berkeley.edu/~smcpeak/elkhound/sources/elsa/" rel="nofollow noreferrer">Elsa: The Elkhound-based C/C++ Parser</a></li> <li><a href="https://people.eecs.berkeley.edu/~necula/cil/" rel="nofollow noreferrer">CIL - Infrastructure for C Program Analysis ...
<p>If it is plain C, <code>lex</code> and <code>yacc</code> are your friends, but you need to take on account C preprocessor - source files with unexpanded macros typically are do not comply with C syntax so parser, written with K&amp;R grammar in mind, most likely will fail.</p> <p>If you decide to parse the output o...
37,883
<p>SVN in Eclipse is spread into two camps. The SVN people have developed a plugin called <a href="http://subclipse.tigris.org/" rel="noreferrer">Subclipse</a>. The Eclipse people have a plugin called <a href="http://www.eclipse.org/subversive/" rel="noreferrer">Subversive</a>. Broadly speaking they both do the same th...
<p>Both are very similar but Subversive is the "eclipse svn provider". I primarily use Subversive because of a few convenient features:</p> <p><strong>Grouping of history</strong></p> <p>When I'm browsing the history of a branch instead of just seeing a bunch of rows for every commit it can group commits by today, we...
<p>If you are using Zend Studio 9, Zend's implementation of Eclipse, I recommend using Subclipse instead of Subversive which comes shipped with Zend Studio be default.</p> <p>I have posted a problem with Subversive and Zend Studio 9 and <a href="http://forums.zend.com/viewtopic.php?f=59&amp;t=42373&amp;p=98993#p98733"...
8,648
<p>We are working on designing an application that is typically OLTP (think: purchasing system). However, this one in particular has the need that some users will be offline, so they need to be able to download the DB to their machine, work on it, and then sync back once they're on the LAN.</p> <p>I would like to note...
<p>Using Guids as primary keys is acceptable and is considered a fairly standard practice for the same reasons that you are considering them. They can be overused which can make things a bit tedious to debug and manage, so try to keep them out of code tables and other reference data if at all possible.</p> <p>The thi...
<p>Guids will certainly be slower (and use more memory) than standard integer keys, but whether or not that is an issue will depend on the type of load your system will see. Depending on your backend DB there may be issues with indexing guid fields.</p> <p>Using guids simplifies a whole class of problems, but you pay...
6,144
<p>Sorry for the long question title.</p> <p>I guess I'm on to a loser on this one but on the off chance.</p> <p>Is it possible to make the calculation of a calculated field in a table the result of an aggregate function applied to a field in another table.</p> <p>i.e.</p> <p>You have a table called 'mug', this has...
<p>you can't have a computed column directly reference a different table, but you can have it reference a user defined function. here's a link to a example of implementing a solution like this.</p> <p><a href="http://www.sqlservercentral.com/articles/User-Defined+functions/complexcomputedcolumns/2397/" rel="noreferrer...
<p>No, it is not possible to do this. A computed column can only be derived from the values of other fields on the same row. To calculate an aggregate off another table you need to create a view.</p> <p>If your application needs to show the statistics ask the following questions:</p> <ol> <li>Is it really necessary...
20,114
<p>Is there a way to have a default parameter passed to a action in the case where the regex didnt match anything using django?</p> <pre><code> urlpatterns = patterns('',(r'^test/(?P&lt;name&gt;.*)?$','myview.displayName')) #myview.py def displayName(request,name): # write name to response or something </code><...
<p>The problem is that when the pattern is matched against 'test/' the groupdict captured by the regex contains the mapping 'name' => None:</p> <pre><code>&gt;&gt;&gt; url.match("test/").groupdict() {'name': None} </code></pre> <p>This means that when the view is invoked, using something I expect that is similar to b...
<p>I <em>thought</em> you could <code>def displayName(request, name=defaultObj)</code>; that's what I've done in the past, at least. What were you setting the default value to?</p>
29,048
<p>I thought people would be working on little code projects together, but I don't see them, so here's an easy one:</p> <p>Code that validates a valid US Zip Code. I know there are ZIP code databases out there, but there are still uses, like web pages, quick validation, and also the fact that zip codes keep getting is...
<p><strong>Javascript Regex Literal</strong>:</p> <p>US Zip Codes: <code>/(^\d{5}$)|(^\d{5}-\d{4}$)/</code></p> <pre><code>var isValidZip = /(^\d{5}$)|(^\d{5}-\d{4}$)/.test("90210"); </code></pre> <p>Some countries use <a href="http://en.wikipedia.org/wiki/Postal_code" rel="noreferrer">Postal Codes</a>, which would...
<p>Are you referring to address validation? Like the previous answer by Mike, you need to cater for the othe 95%.</p> <p>What you can do is when the user select's their country, then enable validation. Address validation and zipcode validation are 2 different things. Validating the ZIP is just making sure its integer....
19,410
<p>Greetings, currently I am refactoring one of my programs, and I found an interesting problem.</p> <p>I have Transitions in an automata. Transitions always have a start-state and an end-state. Some Transitions have a label, which encodes a certain Action that must be performed upon traversal. No label means no actio...
<p>I think its clear that nobody really understands your question. I would suggest putting it in context and making it shorter. As an example, here's one possible implementation of the state pattern in python, please study it to get an idea.</p> <pre><code>class State(object): def __init__(self, name): sel...
<p>From the code that was posted, the only difference between Transition and Labeled Transition is the return of get_lable() and has_label(). In which case you can compress these two a single class that sets a label attribute to None and </p> <pre><code>return self.label is not None </code></pre> <p>in the has_label...
15,548
<p>I need your advice regarding migration. I want to migrate existing project to ASP.NET MVC and I can figure out the proccess except of url rewriting issue:</p> <p>for example how can I make following route: </p> <p><a href="http://www.eireads.com/ireland/mayo/cars-3/1263-used-cars-citroen-c5-for-sale.aspx" rel="nof...
<p>I think that migrating a web forms applicaiton to MVC is going to be very hard unless you have a clear seperation of concerns in your current applicaiton. If you have followed a design pattern like MVP then it might be easier, but if not then much of your business logic is likey going to have to be moved to control...
<p>I think you should really re-write your question and try to detail exactly what you are attempting to accomplish here.</p> <p>If you are asking how to migrate an existing <strong>WebForm</strong> project into ASP.NET MVC keeping the same URL rewrite, the answer is; not easily. The models are too different.</p> <p>...
16,243