instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<pre><code>template &lt;class M, class A&gt; class C { std::list&lt;M&gt; m_List; ... } </code></pre> <p>Is the above code possible? I would like to be able to do something similar.</p> <p>Why I ask is that i get the following error:</p> <pre><code>Error 1 error C2079: 'std::_List_nod&lt;_Ty,_Alloc&gt;::_Node::_Myv...
<p>My guess: you forward declared class M somewhere, and only declared it fully after the template instantiation.</p> <p>My hint: give your formal template arguments a different name than the actual ones. (i.e. class M)</p> <pre><code>// template definition file #include &lt;list&gt; template&lt; class aM, class aT...
<p>Yes. </p> <p>It is used a lot by the STL for things like allocators and iterators.</p> <p>It looks like you are running into some other issue. Perhaps you are missing a template on an out of line method body definition that was first declared in the ... you elided?</p>
33,790
<p>It's just so much <code>HRESULT E_FAIL</code>, if you know what I'm talking about. </p> <p>And if you use Visual Studio, you know what I'm talking about.</p> <p>Similar thread, but not a duplicate: <a href="https://stackoverflow.com/questions/196001/is-the-design-view-for-aspx-pages-in-visual-studio-useful">Is th...
<p>There could be some possible reasons.</p> <p>1st is if you have created a web form (aspx) page Nested it with Master Page; and on the child page you registered a control where you have develop your page.</p> <p>in short I want to say that.</p> <p>You nested your child page in the Master page but on that child pag...
<p>Try this: Put your MasterPages in a seperate folder (if they aren't already. Call it <code>masterpages</code>. Then add this to your <code>web.config</code>:</p> <pre><code>&lt;location path="MasterPage"&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow users="?" /&gt; &lt;/authorization&gt; &lt;/sys...
26,381
<p>It's been said on the blogosphere and by Microsoft themselves that MEF isn't another IoC container.</p> <p>OK...but why? It seems the same to me. Maybe it's not as good as Unity or <a href="https://en.wikipedia.org/wiki/Castle_Project#Features" rel="noreferrer">Castle Windsor</a>, but it still fits the definition, ...
<p>MEF has <strong>potential</strong>, but as a DI container, it lacks:</p> <ol> <li>Code as Configuration </li> <li>Auto Registration </li> <li>XML configuration (not so important to me) </li> <li>Custom Lifetimes </li> <li>Interception </li> </ol> <p>Those things are pretty important. </p> <p>For Lifestyle it lack...
<p>In my world DI is based on three dimensions, Object Composition, Lifetime Management, and Interception. This is what other full-blown DI containers, such as Unity, Castle Windsor, and Ninject facilitates. MEF only supports the one dimension, Object Composition. It is doing this quite well, but the remaining two dime...
26,624
<p>I have wirtten a RESTful WCF Service. Incorporating E-Tags, expires headers. </p> <p>The caching works great when using it from a browser. However how does the caching work when calling it from a WCF Channel Factory or .NET Web Request Objects?</p> <p>So in the scenario where I have my website calling the WCF r...
<p>Yes, you're going to have to handle that yourself, same as that you're responsbile for sending the datetime in the request, so the server can determine if there was a change. I would look at the <a href="http://www.rssbandit.org/" rel="nofollow noreferrer">RSS Bandit source</a> for a sample implementation.</p>
<p>We have a sample that illustrates how to do this (using .NET 4) <a href="http://code.msdn.microsoft.com/cannonicalRESTEntity" rel="nofollow">http://code.msdn.microsoft.com/cannonicalRESTEntity</a></p>
11,620
<p>What aspects of the UpdatePanel are sensitive to time?</p> <p>I have an UpdatePanel that works fine. If I leave the page for a few minutes and come back, the UpdatePanel doesn't work. Looking at firebug, I see that it sends the Request and gets a Response back. However, the page itself doesn't update. I'm not s...
<p>Maybe your application domain recycled or your Session was lost. Have you tried seeing what is being called on the server? That'd be my suggestion on where to look next.</p>
<p>Turn off Firebug network monitoring if enabled.</p>
17,164
<p>I am looking for an Applet with similar functionality to the Oracle/Stellent OutsideIn ActiveX control or the Autonomy KeyView technology that act as a browser plug-in allowing the rendering/display of a large number of file formats (Word processing, spreadhseet, graphics, etc.) I currently use the Stellent solution...
<p>If a commercial product is an option, <a href="http://www.daeja.com/products/viewone1.asp" rel="nofollow noreferrer">ViewOne</a> is a nice product. It's an Applet and you can view a large variety of document.</p>
<p>It's not a plugin, but <a href="http://multivalent.sourceforge.net/" rel="nofollow noreferrer">multivalent</a> is a java library and browser for a large number of document formats, but probably not all the ones you'd like to cover.</p> <p>It does at least cover the PDF, HTML, and any reasonable image format, but no...
29,075
<p>Building on <a href="https://stackoverflow.com/questions/1476/how-do-you-express-binary-literals-in-python#13107">How Do You Express Binary Literals in Python</a>, I was thinking about sensible, intuitive ways to do that Programming 101 chestnut of displaying integers in base-2 form. This is the best I came up with...
<p>For best efficiency, you generally want to process more than a single bit at a time. You can use a simple method to get a fixed width binary representation. eg.</p> <pre><code>def _bin(x, width): return ''.join(str((x&gt;&gt;i)&amp;1) for i in xrange(width-1,-1,-1)) </code></pre> <p>_bin(x, 8) will now give a ...
<p>Not screaming-fast, but straightforward:</p> <pre><code>&gt;&gt;&gt; def bin(x): ... sign = '-' if x &lt; 0 else '' ... x = abs(x) ... bits = [] ... while x: ... x, rmost = divmod(x, 2) ... bits.append(rmost) ... return sign + ''.join(str(b) for b in reversed(bits or [0])...
22,679
<p>Is there anything similar to an <code>indexOf</code> function in the NSString objects?</p>
<p>Use <code>-[NSString rangeOfString:]</code>:</p> <pre><code>- (NSRange)rangeOfString:(NSString *)aString; </code></pre> <blockquote> <p>Finds and returns the range of the first occurrence of a given string within the receiver.</p> </blockquote>
<p>I know it's late, but I added a category that implements this method and many others similar to javascript string methods<br> <a href="https://github.com/williamFalcon/WF-iOS-Categories" rel="nofollow">https://github.com/williamFalcon/WF-iOS-Categories</a></p>
32,004
<p>How would I go about creating a real world form creation class that I can use to display a new form with fields of different types, as how many fields I want, I can use drop downs and I can do all of this by using OOP?</p>
<p>You definitely can. Consider a Form class which stores information about the form itself: the <code>method</code>, <code>action</code>, <code>enctype</code> attributes. Also throw in stuff like an optional heading and/or description text at the top. Of course you will also need an array of input elements. These coul...
<p>Just for reference, <a href="http://php.xivix.net/php_7_24_Object_Oriented_Forms_Introduction" rel="nofollow">Object Oriented Forms</a> by Khurram Khan is an excellent OO forms implementation for PHP.</p> <p>Here is a sample of what the code looks like:</p> <pre><code>$form = new Form("Register", "form.php"); $p...
36,744
<p>In C I know about the recursive function but I heard about the re-entrant function.<p>What is that? And whats the difference between them? </p>
<p>A function is re-entrant if it supports having multiple threads of execution "going through" it at the same time. This might be due to actual multi-threading, and I use this case below, or due to other things as pointed out by other posters. Multi-threading was the first that came to mind, and is perhaps also the ea...
<p>All re-entrant code is a recursion but not all recursion is a re-entrant. Example for recursion is, any function, which calls itself directly or indirectly. Example for re-entant is, interrupt handler routines.</p>
32,665
<p>We are embarking on some R&amp;D for a staff rostering system, and I know that there are some suggested algorithms such as the memetic algorithm etc., but I cannot find any additional information on the web.</p> <p>Does anyone know any research journals, or pseudocode out there which better explains these algorithm...
<p>Here is a useful document:</p> <p><a href="http://www.cs.nott.ac.uk/~exo/docs/publications/ISCIS05_MAforNR.pdf" rel="noreferrer">Memetic Algorithms for Nurse Rostering (pdf)</a></p> <p>It contains a little bit of theory and pseudo-code.</p> <p>Scheduling problem is NP-hard and usually being solved using genetic a...
<p>Or by using <a href="http://www.scienceofbetter.org/what/index.htm" rel="nofollow noreferrer">OR</a> ;)</p>
25,427
<p>I'm looking to get the result of a command as a variable in a Windows batch script (see <a href="https://stackoverflow.com/questions/58207/using-the-result-of-a-command-as-an-argument-in-bash#58214">how to get the result of a command in bash</a> for the bash scripting equivalent). A solution that will work in a .ba...
<p>The humble <strong>for</strong> command has accumulated some interesting capabilities over the years:</p> <pre><code>D:\&gt; FOR /F "delims=" %i IN ('date /t') DO set today=%i D:\&gt; echo %today% Sat 20/09/2008 </code></pre> <p>Note that <code>"delims="</code> overwrites the default space and tab delimiters so th...
<p>Please refer to this <a href="http://technet.microsoft.com/en-us/library/bb490982.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/library/bb490982.aspx</a> which explains what you can do with command output.</p>
13,382
<p>Normal practice is to use case studies, construct work- and data-flows, etc. But this does not necessarily create a shared vocabulary between the user/sponsor and the analyst-designer: one or the other, both normally, will have to acquire terms and views of the "internals" of the others area of expertise, and this u...
<p>Try to eliminate as many <strong>intermediate steps</strong> between the user and final implementer as possible. Every such step obscures and loses information. The most valuable members of your team may be people who can wear <strong>both suits</strong> - "interface" with users, and actually implement the thing.</p...
<p>A good interaction designer should be able to describe the software workings in layman terms. If not, he should not do frontends, IMHO.</p>
12,604
<p>Let's say I have this model named <em>Product</em> with a field named <em>brand</em>. Suppose the values of <em>brand</em> are stored in the format <em>this_is_a_brand</em>. Can I define a method in the model (or anywhere else) that allows me to modify the value of <em>brand</em> before it is called. For example, if...
<p>I would recommend using the square bracket syntax (<code>[]</code> and <code>[]=</code>) instead of <code>read_attribute</code> and <code>write_attribute</code>. The square bracket syntax is shorter and <a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001375" rel="noreferrer">designed to wrap the ...
<p>In your model you can override the method call <code>brand</code>.</p> <pre><code>def brand #code to modify the value that is stored in brand return modified_brand end </code></pre> <p>This will allow it to be stored as this_is_a_brand. But, it will be returned as "this is a brand".</p>
21,933
<p>I have the following code:</p> <pre><code>Using cmd As SqlCommand = Connection.CreateCommand cmd.CommandText = "UPDATE someTable SET Value = @Value" cmd.CommandText &amp;= " WHERE Id = @Id" cmd.Parameters.AddWithValue("@Id", 1234) cmd.Parameters.AddWithValue("@Value", "myValue") cmd.ExecuteNonQu...
<p>Whilst not perfect, here's something I knocked up for TSQL - could be easily tweaked for other flavors... If nothing else it will give you a start point for your own improvements :)</p> <p>This does an OK job on data types and output parameters etc similar to using "execute stored procedure" in SSMS. We mostly used...
<p>One liner:</p> <pre><code>string.Join(",", from SqlParameter p in cmd.Parameters select p.ToString()) </code></pre>
33,232
<p>What do I use to search for multiple words in a string? I would like the logical operation to be AND so that all the words are in the string somewhere. I have a bunch of nonsense paragraphs and one plain English paragraph, and I'd like to narrow it down by specifying a couple common words like, "the" and "and", bu...
<p>Regular expressions support a "lookaround" condition that lets you search for a term within a string and then forget the location of the result; starting at the beginning of the string for the next search term. This will allow searching a string for a group of words in any order.</p> <p>The regular expression for ...
<p>Assuming PCRE (Perl regexes), I am not sure that you can do it at all easily. The AND operation is concatenation of regexes, but you want to be able to permute the order in which the words appear without having to formally generate the permutation. For N words, when N = 2, it is bearable; with N = 3, it is barely ...
25,842
<p>OS: Vista enterprise</p> <p>When i switch between my home and office network, i always face issues with getting connected to the network. Almost always I have to use the diagnostic service in 'Network and sharing center' and the problem gets solved when i use the reset network adapter option.</p> <p>This takes a l...
<p>You can use WMI from within PowerShell to accomplish this. Assuming there is a network adapter who's device name has <em>Wireless</em> in it, the series of commands might look something like the following:</p> <pre><code>$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"...
<p>You could also try <code>netsh</code> commands. Example:</p> <pre><code>netsh wlan disconnect &amp;&amp; netsh wlan connect [ONE OF YOUR WLAN PROFILES] </code></pre> <p>You can get a list of those "profiles", using:</p> <pre><code>netsh wlan show profiles </code></pre>
25,400
<p>I am working on an application for college music majors. A feature i am considering is slowing down music playback without changing its pitch. I have seen this done in commercial software, but cannot find any libraries or open source apps that do anything like this. </p> <ol> <li>Are there libraries out there?</li...
<p>Timestretching is quite hard. The more you slow down or speed up the sound the more artifacts you get. If you want to know what they sound like listen to "The Rockafeller Skank" by Fat Boy Slim. There are a lot of ways to do it that all have their own strengths and weaknesses. The math can get really complex. That's...
<p>audacity does it out of the box and it's free. THere are several plug ins for mp3 players as well that are free. Apparently it's pretty easy to do with an mp3 since it's already coded in the frequency domain.</p>
8,470
<p>In my application, a user has_many tickets. Unfortunately, the tickets table does not have a user_id: it has a user_login (it is a legacy database). I am going to change that someday, but for now this change would have too many implications.</p> <p>So how can I build a "user has_many :tickets" association through...
<p>I think you want the <code>:primary_key</code> option to <code>has_many</code>. It allows you to specify the column on the current Table who's value is stored in the <code>:foreign_key</code> column on the other table.</p> <pre><code>has_many :tickets, :foreign_key =&gt; "user_login", :primary_key =&gt; "login" </...
<p>Just answering to myself, in case there is no better solution. I could not find a solution with the has_many association, so I ended up creating a simple finder method. Not great at all: it does allow me to call <strong>some_user.tickets</strong>, but it does not give me all the benefits of the has_many associatio...
42,585
<p>.NET 3.5, C#</p> <p>I have a web app with a "search" feature. Some of the fields that are searchable are first-class columns in the table, but some of them are in fact nested fields inside an XML data type. </p> <p>Previously, I built a system for dynamically constructing the SQL for my search. I had a nice clas...
<p>Now that is an interesting question. </p> <p>Right now, you cannot instruct SQL Server to perform XML functions directly from Linq. However, you can get Linq to use user defined functions... so, you could setup a udf to process the xml, get the right data, etc, and then use that in your Linq expresion. This will e...
<p>This is not the best, not for all queries, and not completely linq, but works and is fast :</p> <p>an xml sql field accept the "<strong>.ToString</strong>", so you can do :</p> <pre><code>Dim txt as String = "&lt;File&gt;3&lt;/File&gt;" Return (From P In DC.LPlanningRefs Where P.Details.ToString.Contains(txt) Sele...
35,759
<p>In my database, I would like to store a decimal score. A score can have a value from 0 to 10, and values in between, such as 2.3 or 9.4.</p> <p>I recently learned that <strong>int</strong> only stores whole numbers and not decimals. I found out that you could use either <strong>double</strong> or <strong>decimal</s...
<p>Decimals are more precise, doubles are more efficient, usually.</p> <p><s>With decimal you can set how many digits you want to use before and after the decimal point.</s><br> <strong>Edit:</strong> You can set digit count for decimal <strong>and</strong> double, my bad.</p> <p>Decimals are better for things like m...
<p>Why not use INT and let the Score go from 0 to 100? Let the application display the score divided by ten.</p> <p>This rids you of the decimal places / rounding errors problem.</p>
22,800
<p>I'm working on an RSS feed for a custom tasking system we use, and I'm still wrapping my head around how things should work. What I want to have is a feed for each user that shows tasks assigned to them, and additionally a feed for each task that shows updates for the task.</p> <p>What I want to know right now con...
<p>Changing the &lt;pubDate&gt; does indicate that the entry changed, but there is no requirement that a given RSS reader do anything about it. (Strictly speaking, there is no requirement than an RSS reader do anything, but let's remain reasonable.) Some reader <em>do</em> mark updated entries as changed. For exampl...
<p>The solution is to also change the GUID which means including the updated time in it. The GUID provides the uniqueness for each item in the feed and will be marked as unread if you put the date updated in it.</p>
19,838
<p>Is it frowned upon to release your software with a version number high than 1?</p> <p>For example, some <strong>non</strong> tech-savy people might see a competitor's product with a higher version number as meaning my software is not as good.</p>
<p>I believe there are 3 major ways people market product versions:</p> <ol> <li>Product Name [Version #] (i.e. Wordperfect 5.0)</li> <li>Product Name [Release Year] (i.e. Gentoo 2008.0)</li> <li>Product Name [Code Name] (i.e. Windows Vista)</li> </ol> <p>I actuall prefer the release year as part of the versioning st...
<p>You could use the year of release, or a fancy codename instead of a version number, thus bypassing the ethical issue of artificially making your software seem more crufty than it actually is :)</p> <p>Marketing has a lot to answer for.</p>
16,288
<p>I have the situation where i use GIS software which stores the information about GIS objects into separate database table for each type/class of GIS object (road, river, building, sea, ...) and keeps the metadata table in which it stores info about the class name and its DB table.</p> <p>Those GIS objects of differ...
<p>@Brian Chiasson</p> <p>Unfortunately, it's not an option to create all classes of GIS data because classes are created dynamically in the application. Every GIS data of the same type should be a class, but my user has the possibility to get new set of data and put it in the database. I can't know in front which cla...
<p>one way you could do it is to declare an interface say IGisObject that has the common properties declared on the interface. Then implement a concrete class which maps to each table. That way they'll still be all of type IGisObject.</p>
7,483
<p>I have Apache running on a public-facing Debian server, and am a bit worried about the security of the installation. This is a machine that hosts several free-time hobby projects, so none of us who use the machine really have the time to constantly watch for upstream patches, stay aware of security issues, etc. But ...
<p>Chroot jails can be really insecure when you are running a complete sandbox environment. Attackers have complete access to kernel functionality and for example may mount drives to access the "host" system.</p> <p>I would suggest that you use linux-vserver. You can see linux-vserver as an improved chroot jail with a...
<p>Make a virtual machine. try something like vmware or qemu</p>
17,546
<p>I am looking for some JavaScript based component to be used as a course scheduler which would be a cross between Google Calendar and the login time. I do not know if the right term for this is <i>Course Scheduler</i> but I shall describe this in more detail here.</p> <p><b>Course Scheduler</b><br> The widget would ...
<p>this could be what you're looking for:</p> <p><a href="http://www.dhtmlx.com/docs/products/dhtmlxScheduler/index.shtml" rel="noreferrer">DHTMLxScheduler link</a></p> <ul> <li>It has day/week/month views</li> <li>It is free</li> <li>Data can be loaded in xml or iCal formats</li> </ul> <p>You can populate the calen...
<p>try the following open source one. <a href="http://www.web-delicious.com/jquery-events-calendar-wdcalendar/">wdCalendar</a> is a jquery based google calendar clone. It cover most google calendar features.</p> <pre><code>* Day/week/month view provided. * create/update/remove events by drag &amp; drop. * Easy way to...
4,578
<p>Which Template-Engine and Ajax-Framework/-Toolkit is able to load template information from JAR-Files?</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,014
<p>I am a little confused by the multitude of ways in which you can import modules in Python. </p> <pre><code>import X import X as Y from A import B </code></pre> <p>I have been reading up about scoping and namespaces, but I would like some practical advice on what is the best strategy, under which circumstances and...
<p>In production code in our company, we try to follow the following rules.</p> <p>We place imports at the beginning of the file, right after the main file's docstring, e.g.:</p> <pre><code>""" Registry related functionality. """ import wx # ... </code></pre> <p>Now, if we import a class that is one of few in the im...
<p>The <code>import X as Y</code> is useful if you have different implementations of the same module/class.</p> <p>With some nested <code>try..import..except ImportError..import</code>s you can hide the implementation from your code. See <a href="http://codespeak.net/lxml/tutorial.html" rel="nofollow noreferrer">lxml ...
23,568
<p>Scenario: I'm cruising <a href="https://www.thingiverse.com/" rel="nofollow noreferrer">Thingiverse</a>, and I find the awesomest thing. I NEED THIS IN MY LIFE. I download it, print it, and for whatever reason, it doesn't work quite right. OK, no big deal, I'll just download the source because the maker was so k...
<p>I should start by saying that I am not a lawyer. I have been both the complainant and defendant in patent cases, and have had the role of observing copyright compliance for a performing arts organization. With that in mind, the following is my own opinion and information.</p> <hr> <p>Ultimately, there is no simp...
<p>When you remix, either by modifying the existing CAD files (STL or sCAD or whatever), or by rebuilding essentially the same item from scratch, that <strong>is</strong> a remix and subject to whatever restrictions the original author put on his work. </p> <p>So the critical issue so far as copyright is concerned is...
965
<p>Can you recommend a good MySQL stored procedure debugger?<br> <strong>Extra points if it is open source, and works in linux :)</strong></p>
<p>It's neither open source (<strong>but freeware</strong>) nor works in linux, but <a href="http://www.toadsoft.com/toadmysql/" rel="nofollow noreferrer">Toad® for MySQL</a> should be able to assist you in debugging stored procedures on a Windows client.</p>
<p>You can try Illatis StepIn, debug MySQL stored procedures in Windows and Linux. See this page: <a href="http://www.illatis.com/downloads/downloads.php" rel="nofollow noreferrer">http://www.illatis.com/downloads/downloads.php</a>.</p> <p>Cheers</p>
27,462
<p>I need help executing a bat file from asp.net 2.0 and c++.</p> <p>How to import runtime Sql Server2000 data into Oracle 9i?</p> <p>How to manage project?</p>
<p>Oracle and SQL can talk replication/subscriptions. Otherwise you can use standard SSIS/ETL methods such as BCP, SQLLDR, etc.</p>
<p>That's a real combo of question</p> <p>Try to be more especific and/or separate in different questions</p>
41,415
<p>I want to consume a web service over https from a java client. What steps will i need to take in order to do this?</p>
<p>Really, there shouldn't much different from consuming a web service over HTTP. The big thing is that the process calling the web service will have to trust the server's SSL certificate. If the certificate was purchased from a well-known certificate-issuing authority, this usually isn't a problem. Otherwise, the clie...
<p>Blair says it right. all the same, try it out using SoapUI , which is a web service test client. This is an open source utility : so you get a chance to see how things work under the covers.</p>
16,953
<p>I've previously used <a href="https://jqueryui.com/tabs/" rel="nofollow noreferrer"><code>jquery-ui tabs</code></a> extension to load page fragments via <code>ajax</code>, and to conceal or reveal hidden <code>div</code>s within a page. Both of these methods are well documented, and I've had no problems there.</p>...
<p>I would take a look at the <a href="http://docs.jquery.com/UI/Tabs#Events" rel="noreferrer">events</a> for Tabs. The following is taken from the jQuery docs:</p> <pre><code> $('.ui-tabs-nav').bind('tabsselect', function(event, ui) { ui.options // options used to intialize this widget ui.tab // anchor ele...
<p>thanks, jobscry - the 'ui.tab' you pointed out gave me the clicked anchor tag, from which I can extract its class, id, href, etc... I choose to use the id to encode my url. My final tabs() call looks like this:</p> <pre><code>$(document).ready(function() { $('#edit_tabs').tabs( { selected: [% page.sel...
22,399
<p>I'm writing a lightweight XML editor, and in cases where the user's input is not well formed, I would like to indicate to the user where the problem is, or at least where the first problem is. Does anyone know of an existing algorithm for this? If looking at code helps, if I could fill in the FindIndexOfInvalidXml...
<p>I'd probably just cheat. :) This will get you a line number and position:</p> <pre><code>string s = "&lt;?xml version=\"1.0\"?&gt;&lt;tag1&gt;&lt;tag2&gt;Some text.&lt;/taagg2&gt;&lt;/tag1&gt;"; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); try { doc.LoadXml(s); } catch(System.Xml.XmlException ex...
<p>You'd want to load the string into an XmlDocument object via the load method and then catch any exceptions.</p> <pre><code>public bool isValidXml(string xml) { System.Xml.XmlDocument xDoc = null; bool valid = false; try { xDoc = new System.Xml.XmlDocument(); xDoc.loadXml(xmlString); ...
24,288
<p>I want to create a box like this with title:</p> <p><img src="https://i.stack.imgur.com/2rip1.gif" alt="CSS box with title"></p> <p>Can any one please let me know if there is a default CSS tag to do this? Or do I need to create my custom style?</p>
<p>I believe you are looking for the <code>fieldset</code> HTML tag, which you can then style with CSS. E.g.,</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt...
<p>You can try this out.</p> <pre><code>&lt;fieldset class="fldset-class"&gt; &lt;legend class="legend-class"&gt;Your Personal Information&lt;/legend&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Name&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' name='name'&gt...
13,874
<p>Looking for an answer for C# and C++. (in C#, replace 'destructor' with 'finalizer')</p>
<p>Preamble: Herb Sutter has a great article on the subject:</p> <p><a href="http://herbsutter.wordpress.com/2008/07/25/constructor-exceptions-in-c-c-and-java/" rel="noreferrer">http://herbsutter.wordpress.com/2008/07/25/constructor-exceptions-in-c-c-and-java/</a></p> <h2>C++ : Yes and No</h2> <p>While an object destru...
<p>C++ -</p> <p>Nope. Destructor is not called for partially constructed objects. A Caveat: The destructor will be called for its member objects which are completely constructed. (Includes automatic objects, and native types)</p> <p>BTW - What you're really looking for is called "Stack Unwinding"</p>
22,884
<p>When making a cylinder, sometimes I need to only take a pie slice. I'm currently using <a href="http://forum.openscad.org/Creating-pie-pizza-slice-shape-need-a-dynamic-length-array-tp3148p3149.html" rel="noreferrer">this</a> neat trick to make pie slices for angles under 90 degrees. However, I have need of a few ang...
<p>This is what I use:</p> <pre><code>module pieSlice(a, r, h){ // a:angle, r:radius, h:height rotate_extrude(angle=a) square([r,h]); } pieSlice(110,20,3); </code></pre>
<p>Although generating complex shapes by combining primitive OpenSCAD shapes is a well-established tradition, and is often all that is needed, it would be more elegant in this case to generate a pie slice directly using the <code>polygon</code> function and a list comprehension.</p> <pre><code>module pie_slice(r=3.0, ...
1,419
<p>SQL to find duplicate entries (within a group)</p> <p>I have a small problem and I'm not sure what would be the best way to fix it, as I only have limited access to the database (Oracle) itself. In our Table "EVENT" we have about 160k entries, each EVENT has a GROUPID and a normal entry has exactly 5 rows with the ...
<p>You can get the answer with a join instead of a subquery</p> <pre><code>select a.* from event as a inner join (select groupid from event group by groupid having count(*) &lt;&gt; 5) as b on a.groupid = b.groupid </code></pre> <p>This is a fairly common way of obtaining the all the info...
<p>Does this work do what you want, and does it offer better performance? (I just thought I'd throw it in as a suggestion).</p> <pre><code>select * from group g where (select count(*) from event e where g.groupid = e.groupid) &lt;&gt; 5 </code></pre>
22,059
<p>What are your favourite assemblers, compilers, environments, interpreters for the good old <a href="http://en.wikipedia.org/wiki/ZX_Spectrum" rel="noreferrer">ZX Spectrum</a>?</p>
<p>I always used to use <a href="http://www.worldofspectrum.org/infoseek.cgi?regexp=%5EComplete+Machine+Code+Package$&amp;pub=%5ERoybot$&amp;loadpics=1" rel="noreferrer">Roybot Assembler</a> - which had you enter your program using the BASIC editor and REM statements. It comes with a decent debugger/disassembler that ...
<p>Well outside of GEN80, <a href="http://en.wikipedia.org/wiki/HiSoft_Systems" rel="nofollow noreferrer">HiSoft Pascal</a> and <a href="http://en.wikipedia.org/wiki/HiSoft_Systems" rel="nofollow noreferrer">Hisoft C</a> were pretty impressive. <em>Proper</em> high level languages, way cool. Before I learnt Z80, and ...
10,299
<p>I have a custom WinForms control (inherits from control, i.e. without user interface jsut as Timer) to which I want to add a custom command add design time. </p> <p>This could be similar to the "right click and choose 'Edit Items...'" of a menu.</p> <p>Is this posisble? How?</p> <p>Also, could you recommend some ...
<p>First here is a link to the relevant MSDN doco on the subject</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms171567(VS.80).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms171567(VS.80).aspx</a></p> <p>and more specifically</p> <p><a href="http://msdn.microsoft.com/en-us/library/system....
<p>Another good link is </p> <p><a href="http://msdn.microsoft.com/en-us/magazine/cc163758.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc163758.aspx</a></p> <p>The article covers most of what is mentioned on this subject in Chris Sells' book, but the book is still worth buying.</p>
37,415
<p>The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?</p> <p>... or am I just being lazy?</p> <p>Note: rubysspi-1.2.4 does not work.</p> <p>This also works for "igem", part of the IronRuby pr...
<p>I wasn't able to get mine working from the command-line switch but I have been able to do it just by setting my <code>HTTP_PROXY</code> environment variable. (Note that case seems to be important). I have a batch file that has a line like this in it:</p> <pre><code>SET HTTP_PROXY=http://%USER%:%PASSWORD%@%SERVER%:%...
<p>for anyone tunnelling with SSH; you can create a version of the <code>gem</code> command that uses SOCKS proxy:</p> <ol> <li>Install <code>socksify</code> with <code>gem install socksify</code> (you'll need to be able to do this step without proxy, at least)</li> <li><p>Copy your existing gem exe</p> <pre><code>cp...
2,642
<p>As an exercise for myself, I was translating a sample program into various languages. Starting in C#, I had a visitor-pattern interface like so:</p> <pre><code>interface Visitor { void Accept(Bedroom x); void Accept(Bathroom x); void Accept(Kitchen x); void Accept(LivingRoom x)...
<p>You can force the keyboard focus to stay on the <code>TextBox</code> by handling the <code>PreviewLostKeyBoardFocus</code> event like this:</p> <pre class="lang-xml prettyprint-override"><code> &lt;TextBox PreviewLostKeyboardFocus=&quot;TextBox_PreviewLostKeyboardFocus&quot; /&gt; </code></pre> <pre class="lang...
<p>It sounds to me that you'll want to handle two events:</p> <p>GotFocus: Will trigger when the textbox gains focus. You can store the initial value of the box.</p> <p>LostFocus: Will trigger when the textbox loses focus. At this point you can do your validation and decide if you want to roll back or not.</p>
6,606
<p>I'm currently using the ModelStateDictionary in asp.net mvc to hold validation errors and pass then back to the user. Being able to check if the whole model is valid with ModelState.IsValid is particularly. However, a current application I'm working on has a need to be able to report warnings. These aren't as critic...
<p>So the route that I was headed down before turned out to be a bad idea, there just isn't enough access in the framework to get at the bits that you need. At least not without reinventing the wheel a few times.</p> <p>I decided to head down the route of extending the ModelState class to add a warnings collection to ...
<p>I used the solution from Simon Farrow as a starting point to make the warnings work with Kendo's datasource. By default you can return and show <code>Data</code> OR <code>Errors</code> but I wanted to return and show <code>Data</code> AND <code>Warnings</code>. So I've wrapped Kendo's <code>DataSourceResult</code> a...
48,012
<p>I have an existing database that has some testing data into and I'm interested in turning it into a set of DDL, DML, and DCL files so that I could run it against other database systems and create the same schema and such. The database is MS Access 2003.</p> <p>Thoughts?</p>
<ol> <li><p>If your target DB is MS SQL Server, you can use the upsizing wizard to port the access database. You can install and use the MS SQL Server Express Edition and pull the DDL from there.</p></li> <li><p>MS Visio 2003 Enterprise has a Database Reverse Engineering tool that can import the objects from the Access...
<ol> <li><p>If your target DB is MS SQL Server, you can use the upsizing wizard to port the access database. You can install and use the MS SQL Server Express Edition and pull the DDL from there.</p></li> <li><p>MS Visio 2003 Enterprise has a Database Reverse Engineering tool that can import the objects from the Access...
44,316
<p>I have a complex command that I'd like to make a shell/bash script of. I can write it in terms of <code>$1</code> easily:</p> <pre><code>foo $1 args -o $1.ext </code></pre> <p>I want to be able to pass multiple input names to the script. What's the right way to do it? </p> <p>And, of course, I want to handle fi...
<p>Use <code>"$@"</code> to represent all the arguments:</p> <pre><code>for var in "$@" do echo "$var" done </code></pre> <p>This will iterate over each argument and print it out on a separate line. $@ behaves like $* except that when quoted the arguments are broken up properly if there are spaces in them:</p> ...
<p><strong>getopt</strong> Use command in your scripts to format any command line options or parameters.</p> <pre><code>#!/bin/bash # Extract command line options &amp; values with getopt # set -- $(getopt -q ab:cd "$@") # echo while [ -n "$1" ] do case "$1" in -a) echo "Found the -a option" ;; -b) param="$2" echo "Fo...
31,930
<p>Anyone have any experience or tools for unit testing PL/SQL. The best looking tool I've seen for this seems to be Quests Code Tester, but i'm not sure how well that would integration with continuous integration tools or command line testing?</p>
<p>I use utPLSQL as the framework and OUnit as the client. utPLSQL isn't really meant to be used by itself, a good graphical client is required. OUnit is the predecessor to Qute. Qute is also a good tool but more complex than my requirements - it allows you to construct tests using a GUI and does good stuff like test c...
<p>I've recently used successfully unit testing framework of <a href="http://code.google.com/p/plsql-commons/" rel="nofollow">PL/SQL Commons</a> toolkit (see also <a href="http://www.slideshare.net/areuser/plsql-commons-v10-6623604" rel="nofollow">author's slides</a>). The toolkit is not yet publicly available (at the ...
18,394
<p>I'm trying to save the contents of a particular registry key to a file using the RegSaveKey() API:</p> <pre><code>HKEY key; LRESULT result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\MyProduct", 0, KEY_ACCESS_ALL, &amp;key); result = RegSaveKey(key, L"c:\\temp\\saved.reg", NULL); </code></pre> <p>However, RegSa...
<p>Despite running as a local administrator or as a service, you probably don't have the "Backup" privilege enabled by default. You'll need to enable this privilege before you try to save the registry key.</p> <p>MSDN has a good example on how to enable a security privilege in C/C++: <a href="http://msdn.microsoft.co...
<p>Note that SetPrivilege() of reuben's answer is user-defined, according to MSDN, the function body goes thus...</p> <pre><code>BOOL SetPrivilege( HANDLE hToken, // access token handle LPCTSTR lpszPrivilege, // name of privilege to enable/disable BOOL bEnablePrivilege // to enable or disable p...
49,938
<p>I'm looking to find alternatives to <a href="http://lucene.apache.org/solr/" rel="noreferrer">Solr</a> from the Apache Software Foundation. </p> <p>For those that don't know, Solr is an enterprise search server. A client application uses a web-services like interface to submit documents for indexing and also to per...
<p>I wrote a long post about my experiences and features of all the engines I listed below but I scrapped it because formatting is a pita. But quite simply if you don't want to shell out money Solr/Lucene or Fast (now MSSE) is really about the best you can do.</p> <p>Excluded because I have no experience of this produc...
<p><a href="http://omnifind.ibm.yahoo.net/" rel="nofollow noreferrer">IBM Omnifind Yahoo Edition</a> is an Enterprise search server which uses <a href="http://lucene.apache.org/" rel="nofollow noreferrer">Apache Lucene</a> for indexing. It is simple, easy to install and administer. It also has a built in Open Search AP...
9,250
<p>So I have a snazzy custom route for login</p> <pre><code># routes.rb map.login '/login', :controller =&gt; 'sessions', :action =&gt; 'new' </code></pre> <p>Visit www.asite.com/login and you're there. As is custom with failed login, however, we'll do the following in our action. Note what happens on failed login....
<p>Your problem is this: the user first visits <code>/login</code> and fills in the form. When they submit the form, they POST to <code>/sessions</code>, which is why the browser URL changes. To get around this you can do two things:</p> <p>As Michael mentioned, you can redirect back to the :new action, changing the...
<p>Change <code>render :action =&gt; 'new'</code> to <code>redirect_to login_path</code></p>
28,662
<p>We have a JavaScript function named "move" which does just "windows.location.href = <em>any given anchor</em>". <br/> This function works on IE, Opera and Safari, but somehow is ignored in Firefox. Researching on Google doesn't produce a satisfactory answer <strong>why</strong> it doesn't work. <br/> Does any JavaSc...
<p>Have you tried just using </p> <pre><code>window.location = 'url'; </code></pre> <p>In some browsers, <code>window.location.href</code> is a read-only property and is not the best way to set the location (even though technically it should allow you to). If you use the <code>location</code> property on its own, th...
<p>Another option:</p> <pre><code>document.location.href ="..." </code></pre>
34,667
<p>I'm writing a simple .bat file and I've run into some weird behavior. There are a couple places where I have to do a simple if/else, but the code inside the blocks don't seem to be working correctly.</p> <p>Here's a simple case that demonstrates the error:</p> <pre><code>@echo off set MODE=FOOBAR if "%~1"=="" (...
<p>You are running into the problem of cmd's static variable expansion. The MODE variable is only evaluated once. You can see this if you omit the @echo off line.</p> <p>From the set /? documentation:</p> <blockquote> <p>Finally, support for delayed environment variable expansion has been added. This support is ...
<p>Looks like the read and write use different scoping rules.</p> <p>If you eliminate this line</p> <pre><code>set MODE=FOOBAR </code></pre> <p>it will work as expected. So you'll probably need to have a complex series if if/elses to get the variables populated as you'd like.</p>
39,313
<p>I'd like to group the digits in a double by thousands, but also output however number of decimals are actually in the number. I cannot figure out the format string. </p> <pre class="lang-cs prettyprint-override"><code> 1000 =&gt; 1,000 100000 =&gt; 100,000 123.456 =&gt; 123.456 100000.21 =&gt; 100,000.21 10...
<p>This appears to do exactly what you want:</p> <pre><code>public void Code(params string[] args) { Print(1000); Print(100000); Print(123.456); Print(100000.21 ); Print(100200.123456); } void Print(double n) { Console.WriteLine("{0:###,###.#######}", n); } 1,000 100,000 123.456 100,000.21 10...
<p>Try this one:</p> <p>VB:</p> <pre><code>Dim vals() As Double = {1000, 100000, 123.456, 100000.21, 100200.123456} For Each val As Double in vals Console.WriteLine(val.ToString("###,###.#########")) Next val </code></pre> <p>C#:</p> <pre><code>double[] vals = new double[] {1000, 100000, 123.456, 100000.21, 1002...
37,832
<p>So, I'm writing a Cocoa application that needs to be able to display web content using Opera's rendering engine. This is for a feature, not because I'm an Opera fanboi (I'm not). All I've been able to find on the subject is this <a href="http://www.opera.com/pressreleases/en/2003/09/30/" rel="nofollow noreferrer">pr...
<p>Adobe has gone to Opera and licensed their software for some (exorbitant?) amount of money. What that probably means is Adobe has access to the library and SDK documentation so they can embed it in their applications. Opera doesn't give its engine away for free as in beer or freedom. It appears there are several B2B...
<p>Why do you need to embed the Opera engine, instead of the platform-standard rendering engine?</p> <p>"Consistency between platforms" — the typical argument I hear for something like this — is far better achieved by carefully managing your content, providing appropriate style sheets, and so on.</p> <p>You'll be muc...
29,319
<p>I've been experimenting with <a href="http://www.adobe.com/products/flex/" rel="nofollow noreferrer">Adobe Flex</a> recently. Being a long-time server-side web app developer, I'm faced with difficulties that I last experienced when I dabbled in Java Swing development a long time ago. It mainly revolves around the <s...
<p>There's two models I'm seeing in the market right now:</p> <ul> <li>Blended UI. The server is still involved in the UI construction effort, but a lot of it is offloaded to javascript. This is how a lot of the javascript toolkits work (except dojo, extjs, ...).</li> <li>Separated concerns. The server is treated as a...
<p>Two pieces of advice:</p> <ul> <li>Your server should never ever trust anything given to it by the client. Like any web app, data originating on the client can be compromised.</li> <li>Visualise. That's the real (perhaps only) benefit of RIA: the ability to give rich interactive visualisations of data, that can be ...
21,361
<p>Example:</p> <pre><code>public class Name { public string FirstName { get; private set; } public string LastName { get; private set; } private Name() { } public Name(string firstName, string lastName) { FirstName = firstName; LastName = lastName; } } </code></pre> <p>When...
<p>Wow, that's strange. I just tried it myself on my copy of VS2008 (I'm also running SP1) and had the exact same results. When there was more than one parameter, the private constructor showed up in Intellisense, but not when there was only one. My guess is, it's a bug.</p>
<p>Don't know why intellisense is showing you weird things. But you should have an abstract base class for you domain objects with a public constructor, so you don't have to pepper your objects with the private ones. You should also put there things like your properties for your primary keys and such.</p> <pre><code>p...
45,823
<p>I have this line in a javascript block in a page:</p> <pre><code>res = foo('&lt;%= @ruby_var %&gt;'); </code></pre> <p>What is the best way to handle the case where <code>@ruby_var</code> has a single-quote in it? Else it will break the JavaScript code.</p>
<p>I think I'd use a ruby <a href="http://json.org" rel="noreferrer">JSON</a> library on @ruby_var to get proper js syntax for the string and get rid of the '', fex.:</p> <pre><code>res = foo(&lt;%= @ruby_var.to_json %&gt;) </code></pre> <p>(after require "json"'ing, not entirely sure how to do that in the page or if...
<p>I don't work with embedded Ruby too much. But how about using <code>p</code> (which invokes <code>inspect</code>) instead of <code>&lt;%=</code> which might be doing something like <code>print</code> or <code>puts</code>. <code>p</code> always prints the string as if it were code wrapped in double quotes:</p> <pr...
13,204
<p>I want this method to work for any given number of arguments, i can do that with code generation(with a lot of ugly code), can it be done with recursion? if so how? I understand recursion, but i dont know how to write this.</p> <pre><code>private static void allCombinations(List&lt;String&gt;... lists) { if (li...
<p>Here is a simple recursive implementation:</p> <pre><code>private static void allCombinations(List&lt;String&gt;... lists) { allCombinations(lists, 0, ""); } private static void allCombinations(List&lt;String&gt;[] lists, int index, String pre) { for (String s : lists[index]) { if (index &lt; lists.length ...
<p>here's my recursive solution with correct ordering, based on Rasmus' solution. it works only if all lists are of same size.</p> <pre><code>import java.util.Arrays; import java.util.List; public class Test { public static void main(String[] args) { List&lt;String&gt; first = Arrays.asList(new Stri...
25,487
<p>The title pretty much says it all, but for those of you who are familiar with both the latest VMWare Fusion and the "linked clone" feature found in VMWare workstation, can you confirm whether this feature is currently present or absent in Fusion?</p> <p>This could be considered an update of this previous question: ...
<p>VMWare Fusion does <em>support</em> linked clones, but doesn't give you a GUI to create them.</p> <p>Take a quick look at <a href="http://communities.vmware.com/docs/DOC-5611" rel="nofollow noreferrer">http://communities.vmware.com/docs/DOC-5611</a> for details. In short, you'll create the base VM, copy it's virtu...
<p>fusion 2 has full support for linked clones, except for actually creating them. If you use workstation to create clones, you can run them in fusion 2 without any issues or features missing.</p>
37,175
<p>When designing for 3d FDM printing, I'm wondering what is best practice for items with large overhangs which cannot have (or would be fairly impractical) support structures. Consider my following design:</p> <p><a href="https://i.stack.imgur.com/Rfmyd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.co...
<p>When constructing a model intended to be 3D printed, your approach is sound. Overhangs and the required supports can be a severe problem and I believe your assessment is accurate.</p> <p>The complexity of the upper portion would make printed supports an inappropriate path for the reasons you've provided, while your ...
<p>If your end product allows it, one possible solution would be to remodel your part so that instead of having a square channel in the center, the channel had sloping or curved sides so that the overhand was removed, and then to print out an infill piece that could be clotted into the channel to square it off.</p> <p>...
2,227
<p>I have a site using a custom favicon.ico. The favicon displays as expected in all browsers except IE. When trying to display the favicon in IE, I get the big red x; when displaying the favicon in another browser, it displays just fine. The page source includes and it does work in other browsers. Thanks for your th...
<p>Right you've not been that helpful (providing source would be have been really useful!) but here you go... Some things to check:</p> <p>Is the code like this:</p> <pre><code>&lt;link rel="icon" href="http://www.example.com/favicon.ico" type="image/x-icon" /&gt; &lt;link rel="shortcut icon" href="http://www.example...
<p>Run Internet Explorer as Administrator. If you open IE in normal mode then favicon will not display on IE 11 (Win 7). I am not sure about the behavior on other version of browsers.</p>
14,834
<p>I need to update a pair of old classic asp pages&mdash; a <code>search.asp</code> page that provides a simple form which is then posted to a <code>results.asp</code> page. One of the form options on the search page is a drop down list (<code>&lt;select</code>) for the "format". If the user chooses the excel format...
<p>As far as I know, browsers don't offer you any hooks as to how far a download has progressed. In theory, you could do something on the server side and use AJAX to query the server to see how much of the download has been sent, but I don't know how to do it.</p>
<p>hmm, would it be possible to do this via ajax maybe? ie, user selects the format, query is sent via ajax, and the appropriate document is loaded into an iframe on search.asp for example. you could then pick up the succesful event in your ajax call and appropriately deal with the messages.</p>
40,767
<p>I have been given the task of modifying a VB6 project. Nothing incredibly serious, adding a couple forms and fixing a few bugs for the most part. The project uses SQL Server (if that is of any relevance).</p> <p>My background in programming has been VB/C# .NET, PHP, C++ and mostly MySQL although I have used SQL Ser...
<p>It is probably already there, but make sure <strong>Option Explicit</strong> is at the top of all of the files. It forces variable declaration and reduces the chance of a typo inadvertently creating a variable on the fly.</p>
<p>Do not use <code>On Error Resume Next</code> unless really necessary (there are some unique cases, like final cleanup after error processing or VB Collection element existence check, but usually you don't need it inside function body).</p> <p>Implement proper error handling, do not use more than one exit point, do ...
35,723
<p>At work, we have a dedicated SEO Analyst who's job is to pour over lots of data (KeyNote/Compete etc) and generate up fancy reports for the executives so they can see how we are doing against our competitors in organic search ranking. He also leads initiatives to improve the SEO rankings on our sites by optimizing t...
<p>I would suggest using compression at the transport layer, and eliminating whitespace from the HTML, but not sacrificing the semantics of your markup in the interest of speed. In fact, the better you "compress" your markup, the less effective the transport layer compression will be. Or, to put it a better way, let th...
<p>Using compression does not hurt your page ranking. Matt Cutts talks about this in his article on <a href="http://www.mattcutts.com/blog/crawl-caching-proxy/" rel="nofollow noreferrer">Crawl Caching Proxy</a></p> <p>Your page load time can also be greatly improved by <a href="http://bdwebster.com/2008/04/16/resizing...
7,009
<p>I know <code>class foo(object)</code> is an old school way of defining a class. But I would like to understand in more detail the difference between these two.</p>
<p>Prior to python 2.2 there were essentially two different types of class: Those defined by C extensions and C coded builtins (types) and those defined by python class statements (classes). This led to problems when you wanted to mix python-types and builtin types. The most common reason for this is subclassing. If...
<p>Referring to <a href="https://mail.python.org/pipermail/python-dev/2014-August/135701.html" rel="nofollow noreferrer">this</a> The object in class Foo(object) is meant to make your python 3 code compatible with python 2 and 3.</p>
43,039
<p>I have huge 3D arrays of numbers in my .NET application. I need to convert them to a 1D array to pass it to a COM library. Is there a way to convert the array without making a copy of all the data?</p> <p>I can do the conversion like this, but then I use twice the ammount of memory which is an issue in my applicati...
<p>I don't believe the way C# stores that data in memory would make it feasible the same way a simple cast in C would. Why not use a 1d array to begin with and perhaps make a class for the type so you can access it in your program as if it were a 3d array?</p>
<p>Without knowing details of your COM library, I'd look into creating a facade class in .Net and exposing it to COM, if necessary.<br> Your facade would take a double[,,] and have an indexer that will map from [] to [,,].</p> <p>Edit: I agree about the points made in the comments, Lorens suggestion is better.</p>
12,162
<p>The question pretty much sums it up. Just want to run a regular expression match on a string in J2ME.</p>
<p>JRegex will not run on CLDC device. Try this one: <a href="http://code.google.com/p/regexp-me/" rel="nofollow noreferrer">code.google.com/p/regexp-me/</a>.</p>
<p>JRegex doesn't compile on J2ME (at least in the blackberry dev environment). I'm interested in a regex library as well but JRegex doesn't seem to work for this purpose.</p>
14,831
<p>Maybe it's the really late night I had but I can't figure this one out. First the html:</p> <pre><code>&lt;div&gt; &lt;a href="#internal"&gt;Internal Link&lt;/a&gt; &lt;a href="http://external.com"&gt;External Link&lt;/a&gt; &lt;a href="#internal2"&gt;Internal Link2&lt;/a&gt; &lt;/div&gt; </code></pre> <p>in order...
<p><strong>Selenium</strong> can automate most browser based tasks. <a href="http://selenium.seleniumhq.org/" rel="nofollow noreferrer">http://selenium.seleniumhq.org/</a></p> <p><strong>The Grinder</strong> comes with a local proxy that can record traffic and is scriptable with Python. <a href="http://grinder.sourcef...
<p><a href="http://services.alphaworks.ibm.com/coscripter" rel="nofollow noreferrer">CoScripter</a> does pretty much exactly what you need.</p>
38,574
<p>How do I extend my parent's options array for child classes in PHP?</p> <p>I have something like this:</p> <pre><code>class ParentClass { public $options = array( 'option1'=&gt;'setting1' ); //The rest of the functions would follow } </code></pre> <p>I would like to append to that optio...
<p>I think it is better practice to initialize this property in the constructor and then you can extend the value in any descendant class:</p> <pre><code>&lt;?php class ParentClass { public $options; public function __construct() { $this-&gt;options = array( 'option1'=&gt;'setting1' ...
<p>PHP or no, you should have an accessor to do it, so you can call <code>$self-&gt;append_elements( 'foo' => 'bar' );</code> and not worry about the internal implementation.</p>
27,685
<p>I wanna add server controls by using javascript. The main purpose of why I want is to add controls without any postback and get them in code-behind.</p>
<p>You can check the Request.Form collection for all form values (client side controls) on the server. Each control will need to have a unique ID to access it in the request.Form collection.</p> <p>For example, if you had the following control</p> <pre><code>&lt;input type="text" id="testBox" value="blah" /&gt; </co...
<p>That is not generally possible. You must add server side controls <em>on the server</em>.</p> <p>If you want to avoid the <em>visibility</em> of a postback, use AJAX and an UpdatePanel. Otherwise you're out of luck.</p>
46,276
<p>How can I modify the <code>NSDatePickerElementFlags</code> for the <code>NSDatePicker</code> in row templates for <code>NSDate</code> properties returned by <code>[NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:inEntityDescription:]</code>? I would like the <code>NSDatePicker</code> to show hrs:minutes ...
<p>If WCF meets your needs, it's worth looking at. <a href="http://www.zeroc.com" rel="noreferrer">ZeroC </a> and other alternative higher level libraries exist. Otherwise there are several different ways to work closer to the socket level if that's what you need.</p> <h3>TcpClient/UdpClient</h3> <p>These provide a r...
<p>It depends on what you want to focus on. </p> <p>If you want to focus on functionality and leave the plumbing to the framework, then start with Windows Communication Foundation. </p> <p>If you're looking to build your own plumbing, then use <code>System.Net.Sockets.Socket</code> class. </p>
25,876
<p>Would it be a good idea to use Terracotta as a persistence solution (replacing a database)? I'm specifically wondering about data integrity issues and support for transactional systems.</p>
<p>Terracotta is <a href="http://terracotta.org/web/display/docs/Concept+and+Architecture+Guide#ConceptandArchitectureGuide-Transactions" rel="noreferrer">transactional</a> (synchronized blocks form transactions of modified objects) but is not and doesn't want to be JTA-compliant. There is a fairly lengthy discussion ...
<p>Terracotta is Java only. If it's OK for you to be locked into this technology, without the possibility to just write some scripts (without the JVM) in other languages, then go with it.</p> <p>The article <a href="http://willcode4beer.com/design.jsp?set=kill_your_db" rel="nofollow noreferrer">Kill Your Database with...
45,102
<p>I'm trying to store the names of some variables inside strings. For example:</p> <pre><code>Dim Foo1 as Integer Dim Foo1Name as String ' -- Do something to set Foo1Name to the name of the other variable -- MessageBox.Show(Foo1Name &amp; " is the variable you are looking for.") ' Outputs: ' Foo1 is the variable yo...
<p>Well, you can clearly just set Foo1Name = "Foo1" - but I strongly suspect that's not what you're after.</p> <p>How would you know which variable you're trying to find the name of? What's the bigger picture? What you want <em>may</em> be possible with reflection, if we're talking about non-local variables, but I sus...
<p>For finding the variable name, see: <a href="https://stackoverflow.com/questions/72121/finding-the-variable-name-passed-to-a-function-in-c">Finding the variable name passed to a function</a></p> <p>This would apply to VB.Net as well.</p>
45,989
<p>I have seen a few mentions of this idiom (including <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c#9282">on SO</a>):</p> <pre><code>// Deliberately empty subscriber public event EventHandler AskQuestion = delegate {}; </code></pre> <p>The upside is clear - it avoids the need to check for nu...
<p>The only downside is a very slight performance penalty as you are calling extra empty delegate. Other than that there is no maintenance penalty or other drawback.</p>
<p>One thing is missed out as an answer for this question so far: <strong>It is dangerous to avoid the check for the null value</strong>.</p> <pre><code>public class X { public delegate void MyDelegate(); public MyDelegate MyFunnyCallback = delegate() { } public void DoSomething() { MyFunnyCal...
20,611
<p>C++ is probably the most popular language for <a href="https://stackoverflow.com/questions/112277/best-intro-to-c-static-metaprogramming">static metaprogramming</a> and <a href="https://stackoverflow.com/questions/112320/is-static-metaprogramming-possible-in-java">Java doesn't support it</a>.</p> <p>Are there any o...
<p>The alternative to template style meta-programming is Macro-style that you see in various Lisp implementations. I would suggest downloading <a href="http://www.paulgraham.com/onlisp.html" rel="noreferrer">Paul Graham's <em>On Lisp</em></a> and also taking a look at <a href="http://clojure.org" rel="noreferrer">Cloj...
<p>It does not matter what language you are using -- any of them is able to do Heterogeneous Generative Metaprogramming. <strong>Take any dynamic language</strong> such as Python or Clojure, or Haskell if you are a type-fan, <strong>and write models</strong> in this host language that are <em>able to compile themself i...
14,215
<p>I am looking for a <strong>3rd party solution to integrate a <a href="http://en.wikipedia.org/wiki/QR_Code" rel="nofollow noreferrer">QR code</a> reader</strong> in Windows Mobile Applications (.NET Compact Framework). The component should <strong>integrate Reader (camera) and Decoder (algorithm)</strong>.</p> <p>I...
<p><a href="http://www.codeproject.com/KB/cs/qrcode.aspx" rel="nofollow noreferrer">Here</a> is an open source C# port of the Java QR Code <a href="http://qrcode.sourceforge.jp/" rel="nofollow noreferrer">library</a>.</p>
<p>Did you try this one: <a href="http://webscripts.softpedia.com/script/E-Commerce/QRCode-NET-Compact-Framework-Package--30802.html" rel="nofollow noreferrer">QRCode .NET Compact Framework Package</a> ?</p>
8,754
<p>I'm writing an winforms app that needs to set internet explorer's proxy settings and then open a new browser window. At the moment, I'm applying the proxy settings by going into the registry:</p> <pre><code>RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Interne...
<p>This depends somewhat on your exact needs. If you are writing a C# app and simply want to set the default proxy settings that your app will use, use the class System.Net.GlobalProxySelection (<a href="http://msdn.microsoft.com/en-us/library/system.net.globalproxyselection.aspx" rel="noreferrer">http://msdn.microsoft...
<p>Quick Code example (from msdn):</p> <pre><code>WebProxy proxyObject = new WebProxy("http://proxyserver:80/",true); WebRequest req = WebRequest.Create("http://www.contoso.com"); req.Proxy = proxyObject; </code></pre>
24,059
<p>I want Windows Update to automatically download and install updates on my Vista machine, however I don't want to be bothered by the system tray reboot prompts (which can, at best, only be postponed by 4 hours).</p> <p>I have performed the registry hack described <a href="http://www.howtogeek.com/howto/windows-vista...
<p>Not sure if it is the same for vista, but worth a try. </p> <p>On Windows XP, you can modify a group policy setting to change how frequently it re-prompts you. (start -> run type gpedit.msc)</p> <p>Look under Computer Configuration/Administrative Templates/Windows Components/Windows Update</p> <p>The setting you ...
<p>I will risk some down-votes here by saying: this seems a little bit schizophrenic, though a lot of people ask for it.</p> <p>If you want Windows to download and install the updates, but <strong>not</strong> complete the install process by rebooting - what's the point? Why not simply turn of AutoUpdates in the first...
8,072
<p>I have a button on an ASP.Net page that will call Response.Redirect back to the same page after performing some processing in order to re-display the results of a query. However, for some reason, the page comes up blank. It seems that IsPostBack is returning true after the redirect. Anybody know why this would happe...
<p>Sorry, it was an id-10-t error. My event handler wasn't getting called at all. The page had EnableViewState="false". Once I changed that to true it worked.</p> <p>I also took tvanfosson suggestion. This allows me to display a confirmation message. I can easily check to see if the action has already been taken and s...
<p>The page is posted back , that is why you're getting it as true. make sure it is false.</p>
26,680
<p>I'm new to .net and c#, so I want to make sure i'm using the right tool for the job.</p> <p>The XML i'm receiving is a description of a directory tree on another machine, so it go many levels deep. What I need to do now is to take the XML and create a structure of objects (custom classes) and populate them with inf...
<p>I would use the XLINQ classes in System.Xml.Linq (this is the namespace and the assembly you will need to reference). Load the XML into and XDocument:</p> <pre><code>XDocument doc = XDocument.Parse(someString); </code></pre> <p>Next you can either use recursion or a pseudo-recursion loop to iterate over the child...
<p>Load your XML into an XMLDocument. You can then walk the XMLDocuments DOM using recursion.</p> <p>You might want to also look into the factory method pattern to create your classes, would be very useful here.</p>
37,160
<p>I have a bunch of Spring beans which are picked up from the classpath via annotations, e.g.</p> <pre><code>@Repository("personDao") public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao { // Implementation omitted } </code></pre> <p>In the Spring XML file, there's a <a href="http://static.spr...
<p>You can do this in Spring 3 using EL support. Example:</p> <pre><code>@Value("#{systemProperties.databaseName}") public void setDatabaseName(String dbName) { ... } @Value("#{strategyBean.databaseKeyGenerator}") public void setKeyGenerator(KeyGenerator kg) { ... } </code></pre> <p><code>systemProperties</code> is ...
<p>Use Spring's "PropertyPlaceholderConfigurer" class </p> <p>A simple example showing property file read dynamically as bean's property</p> <pre><code>&lt;bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="locations"&gt; ...
41,043
<p>Here is my situation: I know almost nothing about Perl but it is the only language available on a porting machine. I only have permissions to write in my local work area and not the Perl install location. I need to use the <a href="http://search.cpan.org/dist/Parallel-ForkManager" rel="noreferrer">Parallel::ForkMana...
<p>From <a href="http://faq.perl.org/perlfaq8.html#How_do_I_keep_my_own" rel="noreferrer">perlfaq8: How do I keep my own module/library directory?</a>:</p> <p>When you build modules, tell Perl where to install the modules.</p> <p>For C-based distributions, use the INSTALL_BASE option when generating Makefiles:</p> ...
<p>Consider using cpanminus, a suggested on <a href="https://stackoverflow.com/questions/2980297/how-to-use-cpan-as-a-non-root-user">this other thread</a></p>
31,354
<p>I'm a newbie to pgsql. I have few questionss on it:</p> <p>1) I know it is possible to access columns by <code>&lt;schema&gt;.&lt;table_name&gt;</code>, but when I try to access columns like <code>&lt;db_name&gt;.&lt;schema&gt;.&lt;table_name&gt;</code> it throwing error like</p> <pre><code>Cross-database referenc...
<ol> <li><p>Cross Database exists in PostGreSQL for years now. You must prefix the name of the database by the database name (and, of course, have the right to query on it). You'll come with something like this:</p> <p>SELECT alias_1.col1, alias_2.col3 FROM table_1 as alias_1, database_b.table_2 as alias_2 WHERE ...</...
<p>1: A workaround is to open a connection to the other database, and (if using psql(1)) set that as your current connection. However, this will work only if you don't try to join tables in both databases.</p>
16,689
<p>I'm maintaining a .NET 1.1 application and one of the things I've been tasked with is making sure the user doesn't see any unfriendly error notifications.</p> <p>I've added handlers to <code>Application.ThreadException</code> and <code>AppDomain.CurrentDomain.UnhandledException</code>, which do get called. My probl...
<p>Oh, in Windows Forms you definitely should be able to get it to work. The only thing you have to watch out for is things happening on different threads.</p> <p>I have an old Code Project article here which should help:</p> <p><em><a href="http://www.codeproject.com/KB/exception/ExceptionHandling.aspx" rel="nofollo...
<p><strong>The Short Answer,</strong> <em>Looks like, an exception occurring in Form.Load doesn't get routed to Application.ThreadException or AppDomain.CurrentDomain.UnhandledException without a debugger attached.</em></p> <p><strong>The More accurate Answer/Story</strong> This is how I solved a similar problem. I can...
2,337
<p>I'm advising a friend who manages a SQL 2k5 box that has several users who have dbo access to multiple databases. The problem is:</p> <ol> <li>These users haven't had their passwords changed for some months,</li> <li>These users put their IDs into applications and the applications run as DBO.</li> </ol> <p>So - as...
<p>I realize that this is a 5 year old post but it was never answered correctly and there's some really bad information that's been posted.</p> <p>First, let's see what Books Online has to say about the "DBO" role (priv). The emphasis is mine.</p> <blockquote> <p>Members of the db_owner fixed database role can per...
<p>yes. dbo has rights to do whatever it wants on the database. even run xp_cmdshell. and once you can run xp_cmdshell you can do pretty much anything on the system. this is all possible provided dbo has sysadmin rights which by default it has.</p>
36,990
<p>What's the best tool that you use to monitor Web Service, SOAP, WCF, etc. traffic that's coming and going on the wire? I have seen some tools that made with Java but they seem to be a little crappy. What I want is a tool that sits in the middle as a proxy and does port redirection (which should have configurable lis...
<p>For Windows HTTP, you can't beat <a href="http://www.fiddler2.com" rel="noreferrer">Fiddler</a>. You can use it as a <a href="http://www.fiddler2.com/Fiddler/help/reverseproxy.asp" rel="noreferrer">reverse proxy</a> for port-forwarding on a web server. It doesn't necessarily need IE, either. It can <a href="http://w...
<p>I use <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en" rel="nofollow noreferrer">LogParser</a> to generate graphs and look for elements in IIS logs. </p>
14,597
<p>I'm facing a problem on the Win32 API. I have a program that, when it handles <code>WM_PAINT</code> messages, it calls <code>BeginPaint</code> to clip the region and validate the update region, but the <code>BeginPaint</code> function is always generating a <code>WM_NCPAINT</code> message with the same update region...
<p>The MSDN entry for WM_PAINT says: </p> <blockquote> <p>The function <strong>may</strong> also send the <code>WM_NCPAINT</code> message to the window procedure if the window frame must be painted and send the <code>WM_ERASEBKGND</code> message if the window background must be erased.</p> </blockquote> <p>I'm tryi...
<p>I guess the <code>WM_NCPAINT</code> message is always sent with the assumption that the border needs to be repainted as well!</p>
12,561
<p>I don't want to ask off-topic and opinion questions here, but I would like to find a cadre of others dialing in their devices. Any ideas?</p>
<p>I stumbled across this forum/group, <a href="https://forum.prusaprinters.org/forum/english-forum-original-prusa-i3-mmu2s-mmu2/" rel="nofollow noreferrer">Original Prusa i3 MMU2S &amp; MMU2</a>, amongst all of the other <a href="https://forum.prusaprinters.org" rel="nofollow noreferrer">Prusa printers forums</a> on t...
<p>There is a lot of activity on Reddit related to 3D printing and the Prusa printers.</p>
65
<p>Does that mean that I can't share a Form between delphi 2007 and 2009?</p>
<p>Yes. It is not possible unless you remove the properties that are not published in Delphi 2007 from the DFM.</p>
<p>Each form has a dfm file which contains the property settings of the form and its components. Some property values have defaults so they are not stored if the default value is kept. Is just did a small test:</p> <ul> <li>Create a form in 2009</li> <li>Add a couple of standard controls</li> <li>Save it</li> <li>Ope...
34,201
<p>I have installed and setup RubyCAS-Server and RubyCAS-Client on my machine. Login works perfectly but when I try to logout I get this error message from the RubyCAS-Server:</p> <pre><code>Camping Problem! CASServer::Controllers::Logout.GET ActiveRecord::StatementInvalid Mysql::Error: Unknown column 'username' in ...
<p>Do you need something more than what can be provided by MsgBox?</p> <pre><code>MsgBox("Do you want to see this message?", MsgBoxStyle.OkCancel + MsgBoxStyle.Information, "Respond") </code></pre>
<p>Are you unable to use the <a href="http://msdn.microsoft.com/en-us/library/aa335422(VS.71).aspx" rel="nofollow noreferrer">MessageBox class</a>?</p>
8,840
<p>I am importing the CreateICeeFileGen() function from the unmanaged DLL mscorpe.dll in a C# application, in order to generate a PE file. This function returns a pointer to an C++ object <a href="http://msdn.microsoft.com/en-us/library/ms404463.aspx" rel="nofollow noreferrer">defined here</a>, is there any way I can ...
<p>You need a wrapper library to be able to use the class from C#. </p> <p>The best bet would be to create the wrapper using C++/CLI, which can directly call the unmanaged function and expose the details with a managed class. This will eliminate the need to use P/Invoke for anything.</p> <p>(Well, technically if yo...
<p>It looks like COM class/interface. Can you not just use COM instead?</p>
24,058
<p>I am using Marlin firmware with a RAMPS board on an Anet A8 printer. </p> <p>The bed size for the printer is 220 x 220 mm and that is stated in the <code>configuration.h</code> file. When using mesh bed leveling, the nozzle jumps to the first corner on the bed perfectly after setting the x-min to 5.0 but the next t...
<hr> <p><em>None of the answers address your question to solve it! The only sensible contribution comes from a comment of <a href="https://3dprinting.stackexchange.com/users/26/tom-van-der-zanden">@TomvanderZanden</a>.</em></p> <hr> <p>For the sensor to stay <em>within</em> the limits of the bed (considering the off...
<p>The problem is in the code. Please use these:</p> <pre><code>// The size of the print bed #define X_BED_SIZE 220 #define Y_BED_SIZE 220 // Travel limits (mm) after homing, corresponding to endstop positions. #define X_MIN_POS 5 #define Y_MIN_POS 0 #define Z_MIN_POS 0 #define X_MAX_POS X_BED_SIZE #define Y_MAX_POS ...
627
<p>So what I have right now is something like this:</p> <pre><code>PropertyInfo[] info = obj.GetType().GetProperties(BindingFlags.Public); </code></pre> <p>where <code>obj</code> is some object.</p> <p>The problem is some of the properties I want aren't in <code>obj.GetType()</code> they're in one of the base classe...
<p>Use this:</p> <pre><code>PropertyInfo[] info = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); </code></pre> <p>EDIT: Of course the correct answer is that of <a href="https://stackoverflow.com/questions/245055/how-do-you-get-the-all-properties-of-a-class-and-its-base-classes-up-the-hierar...
<p>Just to be complete, you can't get PRIVATE fields and properties from base classes this way. You'll have to use a recursive loop for that:</p> <pre><code>public static IEnumerable&lt;PropertyInfo&gt; GetProperties(Type type, bool forGetter) { // Loop over public and protected members foreach (var item in typ...
30,400
<p>I am looking to build a multi-threaded text import facility (generally CSV into SQL Server 2005) and would like to do this in VB.NET but I am not against C#. I have VS 2008 trial and just dont know where to begin. Can anyone point me in the direction of where I can look at and play with the source of a <em>VERY</...
<p>The referenced <em>DevX</em> article is from 2001 and .Net Framework 1.1, but today .Net Framework 2.0 provides the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(VS.95).aspx" rel="nofollow noreferrer">BackgroundWorker</a> class. This is the recommended threading class if yo...
<p>About the best threading document I ever found was this <a href="http://www.albahari.com/threading/" rel="nofollow noreferrer">http://www.albahari.com/threading/</a></p> <p>If I may, the problem with simple examples is that that they're often too simple. Once you get past the counting or sort in background demos y...
12,123
<p>I am working on a web application that allows users to upload attachments. These attachments are stored on a different drive than that of the web application. How can I create an alias (equivalent to Apache HTTP server's aliases) to this drive so that users can download these attachments?</p> <p>Currently I am cr...
<p>I spent a lot more time researching this and found a solution that solves the random deletion of the context files. I found this excerpt on Apache's website under the host configuration section:</p> <blockquote> <p>You can nest one or more Context elements inside this Host element, each representing a differ...
<p>See the initial part of my newer question for ways to do this by editing the context.xml file <a href="https://stackoverflow.com/questions/12715331/how-do-i-add-aliases-to-a-servelet-context-in-java-code">How do I add aliases to a Servlet Context in java?</a>. According to several people now, it is no longer necessa...
45,677
<p>I have a solution with multiple projects and we need to do some serious global replacements.</p> <p>Is there a way to do a wildcard replacement where some values remain in after the replace?</p> <p>So, for instance if I want every <strong>HttpContext.Current.Session[“whatevervalue”]</strong> to become <strong>Http...
<p>First, Backup your Projects, just in case... Always a good idea before mass replacements.</p> <p>Then, in the Find/Replace Dialog, select the Use Regular Expressions checkbox:</p> <p>In the Find box, use the pattern:</p> <pre><code>HttpContext\.Current\.Session\["{.@}"\] </code></pre> <p>and in the Replace box,...
<p>You can use <a href="http://www.wholetomato.com/" rel="nofollow noreferrer">Visual Assist</a> for tasks like this. It's a powerful tool for different kinds of refactoring.</p>
24,251
<p>How can i map a date from a java object to a database with Hibernate? I try different approaches, but i am not happy with them. Why? Let me explain my issue. I have the following class [1] including the main method i invoke and with the following mapping [2]. The issue about this approach you can see, when you look ...
<p>MySql DateTime precision is only to the second. Java Date precision is to the millisecond. That is why the last three digits are zeros after it has been put in the database.</p> <p>Do this to your original Date:</p> <p>date = date.setTime((date.getTime() / 1000) * 1000);</p> <p>This will set it to the last exact...
<p>Personnaly, I truncate every date I receive in my POJO object with the Apache commons lang package class named DateUtils.</p> <p>See [Apache commons site][1]</p> <p>[1]: <a href="http://commons.apache.org/lang/api/org/apache/commons/lang/time/DateUtils.html#truncate(java.util.Date" rel="nofollow noreferrer">http:/...
28,363
<p>I have some static images in a folder on my IIS 6-based website that I want to be downloaded as little as possible (to preserve bandwidth). I've set the Content Expiration to expire after 30 days. Is there anything else I can do in IIS to try to maximize the caching by browsers, proxy, and gateway caches?</p> <p>Su...
<p>How are they inputting it? The way we used to work at my last job is editing a text file, and loading it with SQL*Plus. You can just put that source file under version control. </p> <p>The source must be between "<code>CREATE OR REPLACE PACKAGE MYPACKAGE AS</code>" and "<code>END;</code>" followed by a single slash...
<p>Take also a look at <a href="http://deltasql.sourceforge.net" rel="nofollow">this link</a>. It's a PHP/mySQL versioning tool which works with any database type and is fairly simple to learn.</p>
36,564
<p>In my cross-platform architecture, I would like to act on a context menu click (right button click) during a mouse click event. In Cocoa, can you detect that the user either Ctrl-Clicked or double-tapped on touchpad (right-click equivalent) DURING the mouseDown event? I am aware of NSView's menuForEvent but do not...
<p>If you're using AppKit, and you want to detect a right-click in your view, you should override <code>-[NSResponder rightMouseDown:]</code>.</p>
<p>Swift version:</p> <pre><code>override func mouseDown(theEvent: NSEvent) { if theEvent.modifierFlags.contains(.ControlKeyMask) { return rightMouseDown(theEvent) } super.mouseDown(theEvent) } </code></pre>
28,196
<pre><code>1 Dim x as Integer? = Nothing 2 If x = Nothing Then 3 'this is what I think will happen 4 Else 5 'this is what really happens 6 End If </code></pre> <p>The proper way to write that is "If x Is Nothing".</p> <p>Is there a FXCop rule that checks for this? Or better yet, can someone show...
<p>Another good resource for writing custom FxCop rules can be found here: <a href="http://www.binarycoder.net/fxcop/index.html" rel="nofollow noreferrer">binarycoder</a></p>
<p>Your best bet to learn to write custom rules for FXCop is the forum <a href="http://social.msdn.microsoft.com/forums/en-US/vstscode/threads/" rel="nofollow noreferrer">here</a> It involves writing an custom assembly to parse the code and check it.</p> <p>Specifically you want to write a rule that says "Instead of u...
42,502
<p>I have a web application running on a Gentoo-based LAMP stack. My customers buy the software as a service and I host everything. However, there is some demand for on-site deployment inside the clients' own networks.</p> <p>Currently, because I host the system, there is no built-in license management in the app. I b...
<p>Don't. Every hour that you spend writing a license key system is an hour that you are not spending fixing bugs or adding features. By writing a license management system, you are spending resources in order to reduce the value of your product!</p> <p>Copyright your code, have a lawyer and be ready to prosecute an...
<p>I am sure you can get to the serial number of the cpu on most os's; you could use that, after all if they transplant the cpu its safe to assume that the old machine would no longer be in use?</p> <p>Secondly a web service could be used to find out the current data capacity and what the client has paid for.</p>
7,437