instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I am extending a template class using C++ in Visual Studio 2005. It is giving me an error when I try to extend the template base class with:</p> <pre><code>template &lt;class K, class D&gt; class RedBlackTreeOGL : public RedBlackTree&lt;K, D&gt;::RedBlackTree // Error 1 { public: RedBlackTreeOGL(); ~RedBlackT...
<p>The code is trying to inherit a constructor, not a class :-)</p> <p>The start of the class declaration should be </p> <pre><code>template &lt;class K, class D&gt; class RedBlackTreeOGL : public RedBlackTree&lt;K, D&gt; </code></pre>
<p><strong>@SDX2000:</strong></p> <p>Yes, I have defined a constructor in RedBlackTree::RedBlackTree:</p> <pre><code>template &lt;class K, class D&gt; class RedBlackTree { public: RedBlackTree(); // Deleting a storage object clears all remaining nodes ~RedBlackTree(); </code></pre> <p...
45,401
<p>I'm currently convering my ASP.NET v2 application to serialize/deserialize it's objects because I want to shift from inproc session state to stateserver. This is because my host, webhost4life, has a nasty tendency to recycle the worker process frequently thus causing session timeouts. Anyway... the question...</p> ...
<p>It will be nothing. The CLR serialization logic will create the object uninitialized by way of <a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatterservices.getsafeuninitializedobject.aspx" rel="nofollow noreferrer">FormatterServices.GetSafeUnitializedObject</a> without running any ...
<p>Why not write a simple test application to find out? Here's one I wrote (excuse the C# instead of VB, but I have the C# Express version of VS2008 open at the moment).</p> <pre><code>[Serializable] class TestClass { [NonSerialized] public Queue&lt;string&gt; queue = new Queue&lt;string&gt;(); } class Progra...
13,686
<p>I am using MS Access 2003. I want to run a lot of insert SQL statements in what is called 'Query' in MS Access. Is there any easy(or indeed any way) to do it?</p>
<p>yes and no.</p> <p>You can't do:</p> <pre><code>insert into foo (c1, c2, c3) values ("v1a", "v2a", "v3a"), ("v1b", "v2b", "v3b"), ("v1c", "v2c", "v3c") </code></pre> <p>but you can do</p> <pre><code>insert into foo (c1, c2, c3) select (v1, v2, v3) from bar </code></pre> <p>What does that get y...
<p>Based on the VBA workaround from @Jonathan, and for execution in the current Access database:</p> <pre class="lang-vb prettyprint-override"><code>Public Sub InsertMinimalData() CurrentDb.Execute &quot;INSERT INTO FinancialYear (FinancialYearID) VALUES ('FY2019/2020');&quot; CurrentDb.Execute &quot;INSERT INTO Fi...
8,796
<p>Does anybody know why</p> <pre><code> vector&lt;int&gt; test(10); int a=0; for_each(test.begin(),test.end(),(_1+=var(a),++var(a))); for_each(test.begin(),test.end(),(cout &lt;&lt; _1 &lt;&lt; " ")); cout &lt;&lt; "\n" </code></pre> <p>Gives : "0 1 2 3 4 5 6 7 8 9"</p> <p>but </p> <pre><code> transfo...
<p>Comma operator evaluates left to right, so the result of the</p> <pre><code>_1+=var(a), ++var(a) </code></pre> <p>is ++var(a), which you'll store using the transform version.</p> <ul> <li><p>for_each:</p> <p>_1 += var(a) is evaluated, updating your sequence (via the lambda _1), then ++var(a) is evaluated, but this h...
<p>Essentially, in the <code>for_each</code> you provide a function with a side-effect, while in the <code>transform</code>, your use the returnvalue of a function.</p> <p>In your case, you reuse the same function. Since <code>operator +=</code> happens to have a return value, this is the one used as a result of the ...
40,953
<p>I'm trying to use VBA to write a formula into a cell in Excel. My problem is that when I use a semicolon (<code>;</code>) in my formula, I get an error:</p> <blockquote> <p><strong><code>Run-time error 1004</code></strong></p> </blockquote> <p>My macro is the following : </p> <pre><code>Sub Jours_ouvres() D...
<p>You can try using FormulaLocal property instead of Formula. Then the semicolon should work.</p>
<p>I don't know why, but if you use </p> <pre><code>(...)Formula = "=SUM(D2,E2)" </code></pre> <p>('<strong><em>,</em></strong>' instead of '<strong><em>;</em></strong>'), it works.</p> <p>If you step through your sub in the VB script editor (F8), you can add <code>Range("F2").Formula</code> to the watch window and ...
44,350
<p>What would be the basic and obvious security considerations and recommendations in a Java EE Web application?</p>
<ul> <li>Use HTTPS</li> <li>Use <a href="http://www.jasypt.org/" rel="nofollow noreferrer">Jasypt</a> to simplify some stuff.</li> <li>Limit external access point.</li> <li>Make sure you don't have a single point of failure.</li> <li>Make sure communication channels are properly secured when needed.</li> <li>Secure acc...
<p>Don't trust anything that's not under your control. The primary, most important aspect of this is: <strong>Don't trust that the input to your POST/GET handlers will come from the forms you design.</strong></p> <p>Validate all client input, especially before you use it to interact with SQL, HQL, other external data...
44,400
<p>Part of the setup routine for the product I'm working on installs a database update utility. The utility checks the current version of the users database and (if necessary) executes a series of SQL statements that upgrade the database to the current version.</p> <p>Two key features of this routine:</p> <ul> <li>On...
<p>Check out SQL Packager from Red-Gate. I have not personally used it, but these guys make good tools overall and this seems to do what you're looking for. It let's you modify the script to customize the install: <a href="http://www.red-gate.com/products/SQL_Packager/index.htm" rel="nofollow noreferrer">http://www.red...
<p>Check out SQL Packager from Red-Gate. I have not personally used it, but these guys make good tools overall and this seems to do what you're looking for. It let's you modify the script to customize the install: <a href="http://www.red-gate.com/products/SQL_Packager/index.htm" rel="nofollow noreferrer">http://www.red...
17,925
<p>I'm trying to embed a window from my process into the window of an external process using the <strong>SetParent</strong> function and have encountered a few problems that I'm hoping someone can help me out with. First off, here is an outline of what I am currently doing to embed my window into the application:</p> ...
<p>Well, I finally found the answer to my question.</p> <p>To fix the issue with the main app losing focus you need to use the <strong>AttachThreadInput</strong> function to attach the embedded window thread to the main app thread.</p> <p>Also, one can use the <strong>TranslateAccelerator</strong> function in respons...
<p>I am not sure if you are still interested in this topic after almost three years. I am working on a similar application. My solution is to modify the window style before you call SetParent. With this solution, I don't have to call AttachThreadInput. </p> <p>However, one major issue of hosting child windows from an...
20,603
<p>What solutions have people come up with to develop their web applications offline when they made the decision to use OpenId for site membership?</p> <p>Couple of ideas:</p> <ol> <li>Create two login pages one for OpenId and one for ASP.NET Membership</li> <li>Create local OpenId provider with test accounts</li> </...
<p>You could use <a href="http://structuremap.sourceforge.net/Default.htm" rel="nofollow noreferrer">an inversion of control container</a> to contain your OpenID implementation and for a quick implementation you <a href="http://code.google.com/p/moq/" rel="nofollow noreferrer">could use Moq</a> to provide preconfigured...
<p>Just mock it!</p>
31,747
<p>This was a question raised by one of the software engineers in my organisation. I'm interested in the broadest definition.</p>
<h2>Summary</h2> <p><strong>A TCP socket is an endpoint <em>instance</em></strong> defined by an IP address and a port in the context of either a particular TCP connection or the listening state.</p> <p><strong>A port is a virtualisation identifier</strong> defining a service endpoint (as distinct from a service <em>in...
<p>A connection socket (fd) is presented for local address + local port + peer address + peer port. Process recv/send data via socket abstract. A listening socket (fd) is presented for local address + local listening port. Process can accept new connection via socket.</p>
18,396
<p>Given a string of JSON data, how can I safely turn that string into a JavaScript object?</p> <p>Obviously I can do this unsafely with something like:</p> <pre><code>var obj = eval("(" + json + ')'); </code></pre> <p>but that leaves me vulnerable to the JSON string containing other code, which it seems very danger...
<p><a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse" rel="noreferrer"><code>JSON.parse(jsonString)</code></a> is a pure JavaScript approach so long as you can guarantee a reasonably modern browser.</p>
<p>Try this. This one is written in typescript.</p> <pre><code>export function safeJsonParse(str: string) { try { return JSON.parse(str); } catch (e) { return str; } } </code></pre>
6,681
<p>I want to deploy my site on my web hosting package by doing a checkout through subversion. I do not have SSH access to my hosting package, which is just a basic LAMP web hosting package, but I do know that there is an SVN client installed on the web server.</p> <p>I was thinking of writing some sort of script (PHP ...
<p>The good news is that svn is very easily scriptable, but the bad news is that you are likely to have a difficult time without shell access.</p> <p>If you do this without shell access, be careful of anything that can change a file in a directory under svn. This can lead to conflicts between working copy and latest v...
<p>I would hesitate to manage your site on your web host with Subversion unless you have shell access. When performing Subversion operations, there might be things that require your interactive attention which you wouldn't be able to provide through a script interface.</p> <p>What I might suggest instead, is to mainta...
24,834
<p>I am told that SQL Server 2005 installation with BI tools and SQL Server 2008 with BI tools can't work together on the same computer. Apparently "some" things stop working. This was told to me by one of my team members. Since I'm new to SQL BI, I cant discount what he has said altogether and I dont want to install t...
<p>I'm not sure if this is your development system or the server... If its the server you can have side by side reporting services on the same server at the same time (though you use double the resources too). I am not sure why you would though; the reporting services 2008 is vastly superior and can report on data from...
<p>I'm not sure if this is your development system or the server... If its the server you can have side by side reporting services on the same server at the same time (though you use double the resources too). I am not sure why you would though; the reporting services 2008 is vastly superior and can report on data from...
28,861
<p>I've been developing business apps, basically CRUD, in ASP.Net for years now, and am interested in learning another language and platform.</p> <p>After a few trips to Borders and poking around a bit on the web, I have not found much dealing with generating reports in PHP. I can imagine, at least, how to generate E...
<p>It sounds like ASP.NET might be the best tool for that job, especially if you already know and use the tools involved.</p> <p>Why not find something new to do with a new language? That way, you can do two things and you know (some of) 2 languages, rather than knowing 1 thing in 2 languages.</p> <p>However, if you ...
<p>Many thanks benlumley. I'll check fpdf a little more closely. At the end of the day, if I can't make a presentable report, I would probably run into a serious problem somewhere down the line.</p> <p>Mike Thomas</p>
42,658
<p>This is what I am working with to get back to the web dev world</p> <p>ASP.Net with VS2008</p> <p>Subsonic as Data Access Layer</p> <p>SqlServer DB</p> <p>Home Project description: I have a student registration system. I have a web page which should display the student records. </p> <p>At present I have a grid...
<p>I use LINQ-to-SQL, not Subsonic, so YMMV, but my approach to filtering has been to supply an OnSelecting handler to the data source. In LINQ-to-SQL, I'm able to replace the result with a reference to a DataContext method that returns a the result of applying a table-valued function. You might want to investigate...
<p>How about something like this?</p> <p>Rather than assigning a data source / table to your grid control, instead attach a 'DataView' to it.</p> <p>Here's sort of a pseudocode example:</p> <pre><code>DataTable myDataTable = GetDataTableFromSomewhere(); DataGridView dgv = new DataGridView(); DataView dv = new Da...
34,844
<p>Greetings,</p> <p>I'm trying to find either a free .NET library or a command-line executable that lets me convert M4A files to either MP3s or WMA files. Please help :).</p>
<p>Found it!</p> <p><a href="http://pieter.wigleven.com/it/archives/3" rel="nofollow noreferrer">http://pieter.wigleven.com/it/archives/3</a></p> <p>There may be other solutions, but this is gold for what I was looking for.</p> <p>P.S. I've written <a href="https://github.com/AlexeyMK/M4A-to-MP3--.net-" rel="nofollo...
<p>Interesting.<br> The link you give points to a command line utility.<br> If you really want to do that programmatically, you might be interested by the DLL version I found at <a href="http://www.rarewares.org/aac-decoders.php" rel="nofollow noreferrer" title="AAC decoders at Rarewares">Rarewares</a>. Not sure if API...
17,423
<p>I've developed my own delivery extension for Reporting Services 2005, to integrate this with our SaaS marketing solution.</p> <p>It takes the subscription, and takes a snapshot of the report with a custom set of parameters. It then renders the report, sends an e-mail with a link and the report attached as XLS.</p> ...
<p>Some tips: Understand the JSF request <a href="http://www.java-samples.com/showtutorial.php?tutorialid=470" rel="nofollow noreferrer">lifecycle</a> and where your various pieces of code fit in it. Especially find out why your model values will not be updated if there are validation errors.</p> <p>Choose a tag libra...
<p>Select a good component library .Do not use richfaces , i suggest you dont use jsf , use spring mvc,jquery fro view and json in a rest architecture. but if you have to ,use primefaces it easy to use and has enough components.</p>
5,189
<p>I've got a C++ program that uses SQLite. I want to store the SQL queries in a separate file -- a plain-text file, <em>not</em> a source code file -- but embed that file in the executable file like a resource.</p> <p>(This has to run on Linux, so I can't store it as an actual resource as far as I know, though that w...
<p>You can use objcopy to bind the contents of the file to a symbol your program can use. See, for instance, <a href="http://www.linuxjournal.com/content/embedding-file-executable-aka-hello-world-version-5967" rel="noreferrer">here</a> for more information.</p>
<p>I have seen this to be done by converting the resource file to a C source file with only one char array defined containing the content of resource file in a hexadecimal format (to avoid problems with malicious characters). This automatically generated source file is then simply compiled and linked to the project. </...
9,824
<p>I am mostly use to using Subversion for my source control. However, my current position has me using TFS. The UI of the TFS explorer and its integration with Visual Studio has me a little disoriented. I miss having tools like SmartSVN where I could see at a glance what I've modified and is pending checkin.</p> <p>W...
<p>There's always <a href="http://codeplex.com/svnbridge" rel="nofollow noreferrer">SVNBridge</a></p>
<p>Sometimes my pending changes window lies to me, both by claiming I have changes where I don't, and (far worse) by not listing changes I have made, which obviously can be a disaster.</p> <p>One crude workaround is to go to the Source Control Explorer, right-click on a folder, and select compare.</p> <p>I do this wh...
27,983
<p>I have a TronXY printer (i3 Clone). It has a 220x220&nbsp;mm heated aluminum bed and I print with a Borosilicate glass plate.</p> <p>I have a slightly longer print (245&nbsp;mm) I would like to do and I think I could adjust to settings and end stop to stretch the y-dimension travel and I have found a 229x257&nbsp;...
<p>The aluminum plate is being heated by the heater element although I suspect the element does not encompass the entire area of the aluminum portion. There are going to be cooler spots on the aluminum but not enough to significantly affect the transfer to the glass.</p> <p>Once you extend the glass, without a corresp...
<p>After Fred's answer, I realized there was a way to test out how much the temperature would drop by offsetting my current glass base to extend past the exge then using a <a href="http://www.flir.com" rel="nofollow noreferrer">FLIR</a> IR Camera to see what the effect would be.</p> <p>Here are the results:</p> <p>Th...
651
<p>Using the following query and results, I'm looking for the most recent entry where the ChargeId and ChargeType are unique.</p> <pre><code>select chargeId, chargeType, serviceMonth from invoice CHARGEID CHARGETYPE SERVICEMONTH 1 101 R 8/1/2008 2 161 N 2/1/2008 3 101 ...
<p>You can use a <strong>GROUP BY</strong> to group items by type and id. Then you can use the <strong>MAX()</strong> Aggregate function to get the most recent service month. The below returns a result set with ChargeId, ChargeType, and MostRecentServiceMonth</p> <pre><code>SELECT CHARGEID, CHARGETYPE, MAX(SER...
<p>Demo at <a href="http://sqlfiddle.com/#!17/e5dff/8/1" rel="nofollow noreferrer">sqlfiddle</a>:</p> <ol> <li>Classical way.</li> </ol> <pre class="lang-sql prettyprint-override"><code>select chargeid, chargetype, SERVICEMONTH from invoice t0 where t0.SERVICEMONTH = ( select max(SERVICEMONTH) fr...
22,945
<p>Random quick question. </p> <p>The System.Web.Cache class, at what level is the information stored? On a per session level or whole application level?</p> <p>Thanks</p>
<p>AFAIK at the application level.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.caching.cache.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.web.caching.cache.aspx</a></p> <p>From the page:</p> <blockquote> <p>One instance of this class is created per application doma...
<p>An instance of the cache is per app domain</p>
49,885
<p>I have a ASP.Net website that is failing on AJAX postbacks (both with ASP.Net AJAX and a 3rd part control) in IE. FireFox works fine. If I install the website on another machine without .Net 3.5 SP1, it works as expected.</p> <p>When it fails, Fiddler shows that I'm getting a 405 "Method Not Allowed". The form...
<p>This appears to be correct for your <em>nested</em> Foo tags:</p> <pre><code>&lt;NewDataSet&gt; &lt;Foo&gt; &lt;!-- Foo-Id: 0 --&gt; &lt;Bar&gt;abcd&lt;/Bar&gt; &lt;Foo&gt;efg&lt;/Foo&gt; &lt;!-- Foo-Id: 1, Parent-Id: 0 --&gt; &lt;/Foo&gt; &lt;Foo&gt; &lt;!-- Foo-Id: 2 --...
<p>These are my observations rather than a full answer:</p> <p>My guess (without trying to re-produce it myself) is that a couple of things may be happening as the DataSet tries to 'flatten' a hierarchical structure to a relational data structure.</p> <p>1) thinking about the data from a relational database perspecti...
7,494
<p>How do you save data from ExtJS form? Load data from the business layer into form or grid?</p>
<p>For me, I have used an ASHX page to push straight XML - and then use the ExtJS data reader to read.. then, say using a form etc, I push the form data straight back to another ASHX page to interrogate/post to the DB.. darned if I know the best way - but it suited me, and seems very quick and stable, and most importan...
<p>If you interest to develop Extjs with java by gwt you can learn more at this extjs-gwt gxt blog. It maybe help you <a href="http://extjs-gwt.blogspot.com/" rel="nofollow noreferrer">How to setup Ext js-GWT : GXT and Example on Eclipse Ganymede 3.4</a></p>
22,558
<p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p> <p>If not, it should be pretty easy to write.. Easiest way would be to..</p> <ol> <li>run <code>python-autotest myfile1.py myfile2.py etc.py</code> <ul> <li>Check if files-to-be-monito...
<p>I found <a href="https://github.com/gfxmonk/autonose">autonose</a> to be pretty unreliable but <a href="http://pypi.python.org/pypi/sniffer/0.2.3">sniffer</a> seems to work very well.</p> <pre><code>$ pip install sniffer $ cd myproject </code></pre> <p>Then instead of running "nosetests", you run:</p> <pre><code>...
<p>Check out pytddmon. Here is a video demonstration of how to use it: <a href="http://pytddmon.org/?page_id=33" rel="nofollow">http://pytddmon.org/?page_id=33</a></p>
13,420
<p>How to format numbers in JavaScript?</p> <hr> <ul> <li><a href="https://stackoverflow.com/questions/51564/javascript-culture-sensitive-currency-formatting">JavaScript culture sensitive currency formatting</a></li> </ul>
<p>The best you have with JavaScript is toFixed() and toPrecision() functions on your numbers.</p> <pre><code>var num = 10; var result = num.toFixed(2); // result will equal 10.00 num = 930.9805; result = num.toFixed(3); // result will equal 930.981 num = 500.2349; result = num.toPrecision(4); // result will equal 5...
<p>The improved script (the previous was buggy, sorry; to be honest I haven't tested this exaustively either), it works like php number_format:</p> <pre><code>function formatFloat(num,casasDec,sepDecimal,sepMilhar) { if (num &lt; 0) { num = -num; sinal = -1; } else sinal = 1; va...
27,379
<p>Is there a reliable equivalent of xkill for Windows?</p> <p>For those who don't know what xkill is: it is a Unix tool which basically kills the process of any windows you click on.</p> <p>A Windows port can be downloaded <a href="http://solo-dev.deviantart.com/art/Windows-xKill-100737525" rel="noreferrer">here</a>...
<p>Windows <a href="http://www.ghacks.net/2008/10/18/windows-xkill/" rel="noreferrer">xkill</a>. </p> <p>Disclaimer: I got it from google and I haven't tried it.</p> <p><strong>Update</strong>: Process Explorer has a <a href="http://rfvicente.spaces.live.com/blog/cns!5228FAA8B79B6EB1!348.entry" rel="noreferrer">windo...
<p>There is <a href="https://casey.io/winkill/" rel="nofollow noreferrer">WinKill</a>. Does exactly that and it's free. Rightckick -> Kill to get rid of hidden processes too.</p>
26,438
<p>Problem : I have multiple projects checked out in my depot. I also have multiple pending numbered change lists, each change list containing checked out files specific to its project. When I check out a new file, it appears in the default change list instead of in the change list that is relevant to its project and I...
<p>The graphical clients make this pretty easy. Dragging a file(s) or folder(s) onto a change list will check it out for you. Instead of checking them out with the context menu or Ctrl+E, which will put them in the default change list, just drag them onto the appropriate change list and they are automatically checked...
<p>The way I handle this is that each project I'm working on has a separate client workspace configuration.</p> <p>However, this is a 6 of one, half dozen of the other situation - now I have to manage a bunch of workspaces. The problem I run into is that when I'm working on project A and want to do something quick in ...
26,693
<p>My current app needs to store address information for a user. I'm currently debating whether to use the customary street address / city / state / zip textboxes and dropdowns or to go with Google's method of simply having everything on one line. Any thoughts on the pros/cons of storing address information in either...
<p>You should split it up. It will make it far easier to do reporting down the road. What happens if you want to pull up all the residents of a state or zip code, or city? If you use all one field, you will be stuck and wish you had split it up.</p> <p>Also, users will forget to put in all the information you need ...
<p>I concur with Kibbee. I was even surprised to see people don't even read the field's labels, inverting first and last name, postal code and city, etc.<br> No, you can't determinate if a postal code is valid, in a Web application targeting international customers...<br> Some countries have alpha characters in postal ...
30,967
<p>I run quite a few Ender 3 Pro's using the same slicer settings (Simplify3D), and just recently I have noticed a very odd extrusion problem. </p> <p>I find that at about the same height on several printers the printer under extrudes by quite a margin. After that, it either continues to under extrude for the rest of ...
<p>It seems I misread your question. </p> <h2>3D Printed Mold</h2> <p>You were asking about (or the question now states) use of a mold release compound to prevent a molded part from sticking to a 3d print mold.</p> <p>Yes. It is always beneficial for the molded part to not stick to the mold. Easy separation and p...
<p>Welcome to the 3D Printing Stack Exchange site.</p> <h2>Used in Casting</h2> <p>A mold release agent is commonly used when a part is cast. The release agent is placed on the inside of the mold before the liquid object is added. As the object becomes solid, the release agent prevents the object from adhering to t...
1,460
<p>How can dynamic Key-value pairs of objects be stored in app.config in using the application settings api, at runtime?</p> <p>I've been trying to get my head around, and I can't find any meaningful example or documentation.</p> <p>I seems that .Net dictionary classes can't be serialized in XML to store them in app....
<p>After some more searching net, I've found a very good (albeit very long) article which describes in dept the .Net configuration model:</p> <p><a href="http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx" rel="nofollow noreferrer">Unraveling the Mysteries of .NET 2.0 Configuration</a></p> <p>I also f...
<p>Depending on what exactly you need, you may try System.Collections.ObjectModel.KeyedCollection&lt;TKey, TValue&gt;. This only works if you can derive the key for an item from the item itself, but in that case, it's fine for this purpose.</p>
21,593
<p>What are the differences between <a href="https://git-scm.com/docs/git-pull" rel="noreferrer"><code>git pull</code></a> and <a href="https://git-scm.com/docs/git-fetch" rel="noreferrer"><code>git fetch</code></a>?</p>
<p>In the simplest terms, <a href="http://git-scm.com/docs/git-pull" rel="noreferrer"><code>git pull</code></a> does a <a href="http://git-scm.com/docs/git-fetch" rel="noreferrer"><code>git fetch</code></a> followed by a <a href="http://git-scm.com/docs/git-merge" rel="noreferrer"><code>git merge</code></a>.</p> <hr />...
<p><strong>Git Fetch</strong></p> <p>Helps you to get known about the latest updates from a <code>git repository</code>. Let's say you working in a team using <code>GitFlow</code>, where team working on multiple <code>branches</code> ( features ). With <code>git fetch --all</code> <code>command</code> you can get know...
37,303
<p>Java Newbie here. I have a JFrame that I added to my netbeans project, and I've added the following method to it, which creates a JTable. Problem is, for some reason when I call this method, the JTable isn't displayed. Any suggestions?</p> <pre><code>public void showFromVectors(Vector colNames, Vector data) { ...
<p>"this" in your context is unclear. Is it inside an applet? a JFrame?</p> <p>You may be having a layout issue, make sure you've called setLayout on your class with a new borderlayout.</p> <p>In a swing application, you'd want to use getRootContentPane().add() instead of a raw add(), depending on the version.</p> <...
<p>If you are not running on the event thread, it could be a problem--I've seen that cause stuff not to display.</p> <p>If this code is called in response to an AWT event (mouse click, button press, ...) then that's not the problem, but if it's still the same thread that started your app, or this code is running off a...
14,799
<p>I have an Ender 3 which I primarily use for printing with PLA. I haven't branched out to other materials yet. :)</p> <p>I've done <a href="https://3dprinthq.com/desktop-3d-printer-safety/" rel="noreferrer">some research into PLA fumes and airborne particulates</a> which seemed to mention that PLA is mostly safe, bu...
<p>Fire is the most obvious risk - firmware can now detect some of the more obvious failure modes such as a detached thermistor, but loose or failing connections can still overheat. A smoke alarm is a fairly obvious (but not necessarily effective) protective measure.</p> <p>The risk from particulates in particular is ...
<p>Standard manufacturing practices contraindicate leaving a manufacturing device unmonitored while it's on. That being said, your workshop should be well ventilated anyways since you're probably using acetone, isopropyl alcohol, and other substances that you shouldn't inhale.</p> <p>If you can not move to a well vent...
1,009
<p>In .NET, Windows Forms have an event that fires before the Form is loaded (Form.Load), but there is no corresponding event that is fired AFTER the form has loaded. I would like to execute some logic after the form has loaded.</p> <p>Can anyone advise on a solution?</p>
<p>You could use the "Shown" event: <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.shown.aspx" rel="noreferrer">MSDN - Form.Shown</a></p> <p>"The Shown event is only raised the first time a form is displayed; subsequently minimizing, maximizing, restoring, hiding, showing, or invalidating a...
<p>You can close your form after some execution..</p> <p>//YourForm.ActiveForm.Close();</p> <pre><code> LoadingForm.ActiveForm.Close(); </code></pre>
26,913
<p>I'm using C# and I have windows form and web service...</p> <p>I have a custom object that I want to send to the web service..</p> <p>sometime, the object may contain a huge of data..</p> <p>as a best performance, what is the best way to send a custom object to the web service?</p>
<p>Web Services are designed to handle custom objects as long as they eventually breakdown into some standard types. As per sending a huge data, there are <a href="http://en.wikipedia.org/wiki/MTOM" rel="nofollow noreferrer">MTOM</a> and older <a href="http://msdn.microsoft.com/en-us/magazine/cc188797.aspx" rel="nofoll...
<p>If you are using / plan to use WCF within the network(as opposed to internet), named pipes on WCF is fast and simple. Use primitive types to pass objects. A string xml (although verbose) or a light weight binary object will do.</p> <p>If it's a wsHttp webservice, use string, I can't think of any other way you would...
45,151
<p>I am trying to understand difference between those two and really need a explanatory simple example for them.</p> <p>Thanks in advance..</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb763516.aspx" rel="nofollow noreferrer"><code>InsertOnSubmit</code></a> adds a single record. <a href="http://msdn.microsoft.com/en-us/library/system.data.linq.itable.insertallonsubmit.aspx" rel="nofollow noreferrer"><code>InsertAllOnSubmit</code></a> does the same, ...
<p>I found this example of InsertAllOnSubmit() at the very bottom of <a href="http://www.scip.be/index.php?Page=ArticlesNET02" rel="nofollow noreferrer">this page</a>. Just remember to add a using statement for System.Collections.Generic</p> <pre><code>// Create list with new employees List&lt;Employee&gt; employeesT...
48,633
<p><strong>E.g.</strong> Is it more secure to use <code>mod_php</code> instead of <code>php-cgi</code>? Or is it more secure to use <code>mod_perl</code> instead of traditional <code>cgi-scripts</code>?</p> <p>I'm mainly interested in security concerns, but speed might be an issue if there are significant differences....
<p>Security in what sense? Either way it really depends on what script is running and how well it is written. Too many scripts these days are half-assed and do not properly do input validation.</p> <p>I personally prefer FastCGI to mod_php since if a FastCGI process dies a new one will get spawned, whereas I have seen...
<p>Using a builtin module is definitely going to be faster than using CGI. The security implications depend on the configuration. In the default configuration they are pretty much the same, but cgi allows some more secure configurations that builtin modules can't provide, specially in the context of shared hosting. Wha...
10,356
<p>I'm considering migrating a project to managed code, but I've heard that the .NET runtime is huge--several times larger than my executable binary, in fact. That just seems like the tail wagging the dog to me. But I've also been told that some CLR implementations, such as Mono, are modular, and you can create a cus...
<p>You might find this site interesting.</p> <p><a href="http://www.hanselman.com/smallestdotnet/" rel="nofollow noreferrer">http://www.hanselman.com/smallestdotnet/</a></p>
<p>Scott Hanselman has a useful <a href="http://www.hanselman.com/blog/SmallestDotNetOnTheSizeOfTheNETFramework.aspx" rel="nofollow noreferrer">blog post</a> on the size of various .NET distributions, and the impact of these on software distribution.</p>
32,441
<p>I'm using <kbd>Ctrl</kbd>+<kbd>Left</kbd> / <kbd>Ctrl</kbd>+<kbd>Right</kbd> in a GreaseMonkey script as a hotkey to turn back / forward pages. It seems to works fine, but I want to disable this behavior if I'm in a text edit area. I'm trying to use document.activeElement to get the page active element and test if i...
<p>document.activeElement works for me in FF3 but the following also works</p> <pre><code>(function() { var myActiveElement; document.onkeypress = function(event) { if ((myActiveElement || document.activeElement || {}).tagName != 'INPUT') // do your magic }; if (!document.activeElement) { var elements...
<p>element.activeElement is part of HTML5 spec but is not supported by most browsers. It was first introduced by IE.</p>
6,434
<ol> <li>What is the most efficient way to check if an array is <strong>a flat array of primitive values</strong> or if it is a <strong>multidimensional array</strong>?</li> <li>Is there any way to do this without actually looping through an array and running <code>is_array()</code> on each of its elements?</li> </ol>
<p>The short answer is no you can't do it without at least looping implicitly if the 'second dimension' could be anywhere. If it has to be in the first item, you'd just do </p> <pre><code>is_array($arr[0]); </code></pre> <p>But, the most efficient general way I could find is to use a foreach loop on the array, shortc...
<p>I think this one is classy (props to another user I don't know his username):</p> <pre><code>static public function isMulti($array) { $result = array_unique(array_map("gettype",$array)); return count($result) == 1 &amp;&amp; array_shift($result) == "array"; } </code></pre>
17,525
<p>I realize you can't get the target entity in the Attribute itself, but what about in an associated Permission object when using a CodeAccessSecurityAttribute? The Permission object gets called at runtime so it seems there should be a way but I'm at a loss.</p> <pre><code>public sealed class MySecurityAttribute : C...
<p>What about walking the call stack? At least that would narrow down what you need to reflect over. Grab <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace.aspx" rel="nofollow noreferrer">System.Diagnostics.StackTrace</a> and use <a href="http://msdn.microsoft.com/en-us/library/system.diagn...
<p>Well, I guess you could use reflection to scan through all the loaded assemblies, looking for any class/member that has <code>this</code> as an attribute. It'd be quite slow, though, so it's not something you'd want to do often, or in a large project.</p>
35,673
<p>Why use one over the other?</p>
<p>== is the identity test. It will return true if the two objects being tested are in fact the same object. <code>Equals()</code> performs an equality test, and will return true if the two objects consider themselves equal.</p> <p>Identity testing is faster, so you can use it when there's no need for more expensive e...
<p>If you do disassemble (by dotPeek for example) of Object, so </p> <pre><code>public virtual bool Equals(Object obj) </code></pre> <p>described as:</p> <pre><code>// Returns a boolean indicating if the passed in object obj is // Equal to this. Equality is defined as object equality for reference // types and bitw...
17,430
<p><a href="http://leepoint.net/notes-java/data/expressions/22compareobjects.html" rel="nofollow noreferrer">http://leepoint.net/notes-java/data/expressions/22compareobjects.html</a></p> <blockquote> <p>It turns out that defining equals() isn't trivial; in fact it's moderately hard to get it right, especially in...
<blockquote> <p>If equals() must always be overridden, then what is a good approach for not being cornered into having to do object comparison?</p> </blockquote> <p>You are mistaken. You should override equals as seldom as possible.</p> <hr> <p>All this info comes from <a href="http://java.sun.com/docs/books...
<p>The main reason to override equals() in most cases is to check for duplicates within certain Collections. For example, if you want to use a Set to contain an object you have created you need to override equals() and hashCode() within your object. The same applies if you want to use your custom object as a key in a M...
47,016
<p>I have an element which may contain very big amounts of data, but I don't want it to ruin the page layout, so I set <code>max-height: 100px</code> and <code>overflow:auto</code>, hoping for scrollbars to appear when the content does not fit. </p> <p>It all works fine in Firefox and IE7, but IE8 behaves as if <code>...
<p>This is a really nasty bug as it affects us heavily on Stack Overflow with <code>&lt;pre&gt;</code> code blocks, which have <code>max-height:600</code> and <code>width:auto</code>.</p> <p>It is logged as a bug in the final version of IE8 with no fix.</p> <p><a href="http://connect.microsoft.com/IE/feedback/ViewFee...
<p>I found this : <a href="https://perishablepress.com/maximum-and-minimum-height-and-width-in-internet-explorer/" rel="nofollow">https://perishablepress.com/maximum-and-minimum-height-and-width-in-internet-explorer/</a></p> <blockquote> <p>This method has been verified in IE6 and should also work in IE5. Simply cha...
2,931
<p>I need to know, from within Powershell, if the current drive is a mapped drive or not.</p> <p>Unfortunately, Get-PSDrive is not working "as expected":</p> <pre><code>PS:24 H:\temp &gt;get-psdrive h Name Provider Root CurrentLocation ---- -------- ---- --------------- H Fi...
<p>Use the .NET framework:</p> <pre><code>PS H:\&gt; $x = new-object system.io.driveinfo("h:\") PS H:\&gt; $x.drivetype Network </code></pre>
<p>Try WMI:</p> <pre><code>Get-WMI -query "Select ProviderName From Win32_LogicalDisk Where DeviceID='H:'" </code></pre>
19,146
<p>I've noticed a lot of sites, SO included, use XHTML as their mark-up language and then fail to adhere to the spec. Just browsing the source for SO there are missing closing tags for paragraphs, invalid elements, etc.</p> <p>So should tools (and developers) use the XHTML doctype if they are going to produce invalid ...
<p>There are <a href="https://validator.w3.org/docs/why.html" rel="nofollow noreferrer">many reasons</a> to use valid markup. My favorite is that it allows you to use validation as a form of regression testing, preventing the markup equivalent of &quot;delta rot&quot; from leading to real rendering problems once the e...
<p>It depends. I had that <a href="http://www.stum.de/2008/02/29/valid-xhtml-and-youtube-embedding/" rel="nofollow noreferrer">issue with my blog</a> where a YouTube video caused invalid XHTML, but it rendered fine. On the other hand, I have a "Valid XHTML" link, and a combination of a "Valid XHTML" claim and invalid X...
2,557
<p>Is there a good Silverlight Design Architecture? </p>
<p>There is <a href="http://www.codeplex.com/CompositeWPF" rel="nofollow noreferrer">Prism</a> it was originally designed for WPF but there is now a Silverlight release. </p>
<p>Soon, Microsoft will be releasing a new version of Prism (though unlike the earlier answer), the Silverlight version of Prism is just a proof of concept. The PnP team hope to have a full release in the next couple of months. The prevailing story today is to use the same MVVM pattern that WPF has had success with (se...
40,336
<p>Curious to know how people set up their personal and/or work development environment, in terms of:</p> <p>Do you just have all of your developer tools (for example Visual Studio, SSMS, etc.) installed on your main operating system;<br> Do you use Virtual Machines to have a separate "clean" dev environment that cons...
<p>It all depends on the type of the job i guess. Here is how my setup is:</p> <ol> <li>The main PC. The one on my desk. Has everything on it.</li> <li>The secondary machine. Runs Vista.</li> <li>A bunch of "Clean" VMs for testing. Typically 2 machines of each OS we support.</li> <li>A build machine. VM with no instal...
<p>I have a VMWare network replication of the main servers in my environment including SQLservers, Web-Servers, a copy of my dev box, and AD Servers. I also use VS on my dev box for simple things that don't need as much testing.</p>
21,211
<p>I am interested in choosing a good structure for an online message board-type application. I will use SO as an example, as I think it's an example that we are all familiar with, but my question is more general; it is about how to achieve the right balance between organization and flexibility in online message board...
<p>The real problem with subforums comes when you guess wrong about which topics have enough interest to get their own subforums. While some topics end up with their own vibrant subcommunities others end up as empty ghettos, with little activity or feeling of community. Topics that might flourish as occasional subjec...
<p>Though I think that tagging is supperior to grouping, people tend to think hierarchically. In general it depends on the target group for the forum. </p> <p>Maybe you can go with a mixture: use tagging and later use tag groups to order to posts. Delicious uses this, for example, and I find it rather helpful.</p>
7,079
<p>I recently moved my website to a shared hosting solution at <a href="http://asmallorange.com" rel="nofollow noreferrer">asmallorange.com</a>, but I had to set my domain to use their provided nameservers in order for the site to properly resolve. I was determined to keep control of the domain's DNS but I could find ...
<p>Nothing. DNS simply maps topleveldomain.com to server.sharedhost.com. It's the webserver which looks at the <code>Host: topleveldomain.com</code> header and knows that's equivalent to server.sharedhost.com/~username.</p>
<p>apache has a "mod_user" which you can enable in your apache conf file. Using this and virtual hosts is how that is accomplished.</p>
14,984
<p><strong>UPDATE:</strong> Thanks to everyone for the responses. I didn't realize document.write() was deprecated. Add a another notch to the learning column. I'll be taking the advice posted here, but leave the original question so that the answers given make sense in context of the original question.</p> <hr> <p>I...
<p>My gut reaction is: <strong>don't do that</strong>. (Your example is poor, you should not be writing big chunks of content in your behavior layer.)</p> <p>Whenever you <em>have to</em> do this, either concat:</p> <pre><code>var longVar = 'asdfasdf asdf asdf asdfasdf asdfasdf asdf asdfasdf' + ' fasdf s9d0af asd...
<p>I would write it however is going to be easiest to read and maintain. Then test the performance. If it is too slow try incrementally improving the algorithm until the speed is acceptable.</p> <p>So ideas to improve the performance: - ensure script is minified. - do as much preprocessing on the server and serve th...
29,560
<p>I'm using a third-party library which accesses fonts through the GraphicsEnvironment: getAllFonts() call. This includes fonts in font registries belonging to both the JRE and the operating system.</p> <p>But on client machines that connect to our server I will likely not be able to install fonts into either of thes...
<p>Use <a href="http://java.sun.com/javase/6/docs/api/java/awt/GraphicsEnvironment.html#registerFont(java.awt.Font)" rel="nofollow noreferrer">GraphicsEnvironment.registerFont</a>. (For JDK 1.6)</p>
<p>Try <a href="http://java.sun.com/javase/6/docs/api/java/awt/Font.html" rel="nofollow noreferrer">Font.createFont()</a> and bundling the fonts you want to use.</p>
49,057
<p>I have a conflict when trying to mix those plugins, i have based my script in some demos. The problem is that when i drag something inside the same list it triggers the drop event and that item is added to the end of the list, wich is correct if the item is dropped in another list, but not in the same, when i drop i...
<p>You cannot mix those plugins: they process the same events, and cannot cooperate together. Either rethink your UI, or use different tools.</p> <p>Is it possible to do it? Yes, of course. For example, <a href="http://docs.dojocampus.org/dojo/dnd" rel="noreferrer">Dojo DnD</a> allows both sorting and drag-and-drop us...
<p>If you want to move a <code>&lt;li&gt;</code> element from one list to another, you can simply use the <code>connectWith</code> property of <code>sortable()</code>. Just look in the documentation.</p>
49,146
<p>I am ASP.NET developer from last 5 years and still loving it. There are lots of good voices in air about Ruby on Rails. I want to ask to community, Is there any worth trying to learn Ruby On Rails as a ASP.NET web developer on following point of view.</p> <ol> <li>Scalability</li> <li>Documentation</li> <li>Communi...
<p>I'm now in your shoes, because I'm learning RoR after commercially developing in .NET for 5 years. Here is my two cents:</p> <ol> <li>Scalability: I believe that rails can scale quite well, there are numerous options available, such as mongrel clusters on linux.</li> <li>This one is a bit worse than on .NET. But t...
<p>Well I dont know anything about the Scalability part, but personaly i started learning Ruby On Rails from ASP.NET a while ago. I really had a hard time finding some good documentation - the class documentation on Rails site was really poor in my eyes, and I had a simple question about what arguments you could put in...
43,629
<p>Is it possible to bypass the Freemarker cache when certain templates are requested? I realise that I'll probably have to implement my own TemplateLoader in order to do this, but even so, I can't see a way to check the cache when say template A is requested, but bypass it when template B is requested?</p> <p>If this...
<p>try disabling caching on your <a href="http://freemarker.sourceforge.net/docs/api/freemarker/template/Configuration.html#setTemplateUpdateDelay(int)" rel="nofollow noreferrer">configuration</a>:</p> <pre><code>configuration.setTemplateUpdateDelay(0); </code></pre> <p>This should cause it to check for a newer versi...
<p>You would set this on the configuration object itself. See <a href="http://freemarker.org/docs/pgui_config_templateloading.html#pgui_config_templateloading_caching" rel="nofollow noreferrer">this page</a> for details.</p> <p>For your particular problem, you could do the following:</p> <pre><code>cfg.setSetting(Con...
47,128
<p>I see the following code in the attribute_fu plugin:</p> <pre><code>module AttributeFu module Associations #:nodoc: def self.included(base) #:nodoc: ...
<pre><code># init.rb ActiveRecord::Base.class_eval { include AttributeFu::Associations } module AttributeFu module Associations def self.included(base) # base == ActiveRecord::Base (the class) base.class_eval do # class_eval makes self == ActiveRecord::Base, and make...
<p>In that case, <code>self</code> does not mean the anObject, it's more a sugar construct.</p> <pre><code>class &lt;&lt; self ... end </code></pre> <p>defines class methods for the enclosing object. The method <code>alias_method_chain</code> is a method, that alias things. In that case, it aliases <code>has_many</...
44,505
<p>I have a very tricky situation (for my standards) in hand. I have a script that needs to read a script variable name from <a href="https://docs.python.org/2/library/configparser.html" rel="nofollow noreferrer">ConfigParser</a>. For example, I need to read</p> <pre><code>self.post.id </code></pre> <p>from a .cfg fi...
<p>test.ini:</p> <pre><code>[head] var: self.post.id </code></pre> <p>python:</p> <pre><code>import ConfigParser class Test: def __init__(self): self.post = TestPost(5) def getPost(self): config = ConfigParser.ConfigParser() config.read('/path/to/test.ini') newvar = config.get('head', 'v...
<p>This is a bit silly.</p> <p>You have a dynamic language, distributed in source form.</p> <p>You're trying to make what amounts to a change to the source. Which is easy-to-read, plain text Python.</p> <p>Why not just change the Python source and stop messing about with a configuration file?</p> <p>It's a lot eas...
37,677
<p>I've had a bug in our software that occurs when I receive a connection timeout. These errors are very rare (usually when my connection gets dropped by our internal network). How can I generate this kind of effect artificially so I can test our software? </p> <p>If it matters the app is written in C++/MFC using CAsy...
<p>Connect to an existing host but to a port that is blocked by the firewall that simply drops TCP SYN packets. For example, www.google.com:81.</p>
<p>Plug in your network cable into a switch which has no other connection/cables. That should work imho.</p>
12,615
<p>When I am adding two textbox values that are <strong>1.001</strong> and <strong>0.001</strong> and then I do a <code>parseFloat</code> I get <strong>1.0019999999</strong>. I want it <strong>1.002</strong> . Can you help me?</p>
<p>The Javascript <a href="http://www.w3schools.com/jsref/jsref_obj_number.asp" rel="nofollow noreferrer">Number</a> class has a <code>toFixed()</code> function that will get you what you want.</p> <p>So you could do <code>parseFloat("1.0019999").toFixed(3)</code> and that would give you <strong>1.002</strong>.</p> <...
<p>If you want to a quick fix you can round to the nearest thousandth </p> <p>Math.round((1.001+0.001)*1000)/1000</p>
20,957
<p>I am using the Photoshop's javascript API to find the fonts in a given PSD.</p> <p>Given a font name returned by the API, I want to find the actual physical font file that font name corresponds to on the disc.</p> <p>This is all happening in a python program running on OSX so I guess I'm looking for one of:</p> <...
<p>Unfortunately the only API that isn't deprecated is located in the ApplicationServices framework, which doesn't have a bridge support file, and thus isn't available in the bridge. If you're wanting to use ctypes, you can use ATSFontGetFileReference after looking up the ATSFontRef.</p> <p>Cocoa doesn't have any nati...
<p>open up a terminal (Applications->Utilities->Terminal) and type this in:</p> <pre><code>locate InsertFontHere </code></pre> <p>This will spit out every file that has the name you want.</p> <p>Warning: there may be alot to wade through.</p>
2,291
<p>What are the strategies for versioning of a web application/ website? </p> <p>I notice that here in the Beta there is an svn revision number in the footer and that's ideal for an application that uses svn over one repository. But what if you use externals or a different source control application that versions sep...
<p>For my big apps I just use a incrementing version number id (1.0, 1.1, ...) that i store in a comment of the main file (usually index.php).<Br /> For just websites I usually just have a revision number (1,2,3,...).</p>
<p>I maintain a system of web applications with various components that live in separate SVN repos. To be able to version track the system as a whole, I have another SVN repo which contains all other repos as external references. It also contains install / setup script(s) to deploy the whole thing. With that setup, the...
4,958
<p>I have an htaccess file that uses mod_rewrite to redirect /controller to /index.php?controller=%controller%</p> <p>Like this:</p> <pre><code># Various rewrite rules. &lt;IfModule mod_rewrite.c&gt; RewriteEngine on # Rewrite current-style URLs of the form 'index.php?controller=x&amp;action=y'. RewriteCond %{...
<pre><code>&lt;Location /secret&gt; AuthName localhost AuthType Basic AuthUserFile &lt;file&gt; Require valid-user &lt;/Location&gt; </code></pre>
<p>I ended up using PHP to do it:</p> <pre><code>if (in_array($controllerString, $configuration['protected'])) { $authenticated = false; if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'You are unatuh...
35,746
<p>I am looking for an efficient way to pull the data I want out of an array called $submission_info so I can easily auto-fill my form fields. The array size is about 120.</p> <p>I want to find the field name and extract the content. In this case, the field name is <strong>loanOfficer</strong> and the content is <stro...
<p>You're probably best off going through each entry and creating a new associative array out of it.</p> <pre><code>foreach($submission_info as $elem) { $newarray[$elem["field_name"]] = $elem["content"]; } </code></pre> <p>Then you can just find the form fields by getting the value from $newarray[<em>&lt;field yo...
<p>I'm assuming that php has an associative array (commonly called dictionary or hashtable). The most efficient routine would be to run over the array once and put the fields into a dictionary keyed on the field name.</p> <p>Then instead of having to search through the original array when you want to find a specific f...
11,027
<p>I have an XML file, and I want to find nodes that have duplicate CDATA. Are there any tools that exist that can help me do this?</p> <p>I'd be fine with a tool that does this generally for text documents.</p>
<p>Here is a first attempt, written in Python and using only standard libraries. You can improve it in many ways (trim leading and ending whitespaces, computing a hash of the text to decrease memory requirments, better displaying of the elements, with their line number, etc):</p> <pre class="lang-python prettyprint-ov...
<p>never heard about anything like that, but it might be an intresting task to write such a program based on a <a href="http://en.wikipedia.org/wiki/Dictionary_coder" rel="nofollow noreferrer">dictionary coder</a> as used in archivers.</p>
30,842
<p>Does anybody know how to apply a "where in values" type condition using LINQ-to-Entities? I've tried the following but it doesn't work:</p> <pre><code>var values = new[] { "String1", "String2" }; // some string values var foo = model.entitySet.Where(e =&gt; values.Contains(e.Name)); </code></pre> <p>I believe t...
<p><strong>Update:</strong> found out how to do this. And EF will generate the appropriate SQL on the database. I'm not sure if this is for EF4 only but I got the tip from Entity Framework 4.0 Recipes</p> <hr> <pre><code>var listOfIds=GetAListOfIds(); var context=CreateEntityFrameworkObjectContext(); var results = fr...
<p>Yes it does translate to SQL, it generates a standard IN statement like this:</p> <pre><code>SELECT [t0].[col1] FROM [table] [t0] WHERE [col1] IN ( 'Value 1', 'Value 2') </code></pre>
11,409
<p>I was just wondering, if by moving complex if else statements and the resulting html markup to the code behind violates some 'MVC' law?</p> <p>It seems like a great option when faced with inline if else statements that can become extremely unreadable.</p>
<p>I prefer not to use the code behind class in my views. This is not because it violates MVC by default, but because I found that the "natural" way (at least for me) is different. </p> <p>When I face complex HTML markup that relates to purely view concerns, I usually write an extension method for <code>HtmlHelper</co...
<p>I believe as long as it's a rendering code and it's in a "View" not in a controller, then putting it on code behind or inline won't matter. Just make sure that you don't write this piece of the rendering code in the Controllers actions (this way you will really violate the MVC pattern).</p>
26,602
<p>i've written a UserControl descendant that <strong>is</strong> in an assembly dll.</p> <p>How do i drop the control on a form?</p> <pre><code>namespace StackOverflowExample { public partial class MonthViewCalendar : UserControl { ... } } </code></pre> <p>i've added a reference to the assembly under...
<p>Normally, when you build your project, your user control will appear in your toolbox at the top. Normally, you will see a new pane with each of your Assemblies and the controls in there.</p> <p>If that doesn't happen, you can also add your control by right clicking on the toolbox, selecting <em>Choose Items</em>, t...
<p>Add the ToolboxAttribute to your class.</p>
28,934
<p>I'm trying to find a way to fake the result of a method called from within another method.</p> <p>I have a "LoadData" method which calls a separate helper to get some data and then it will transform it (I'm interested in testing the transformed result).</p> <p>So I have code like this:</p> <pre><code>public class...
<p>As far as I know, you should create an interface or a base abstract class for the Helper object. With Rhino Mocks you can then return the value you want.</p> <p>Alternatively, you can add an overload for LoadData that accepts as parameters the data that you normally retrieve from the Helper object. This might even ...
<p>Yes, a mocking framework is exactly what you're looking for. You can record / arrange how you want certain mocked out / stubbed classes to return.</p> <p>Rhino Mocks, Typemock, and Moq are all good options for doing this.</p> <p><a href="http://weblogs.asp.net/stephenwalther/archive/2008/03/22/tdd-introduction-to...
11,597
<p>Is there a clean and OS independent way to determine the local machine's IP addresses from Perl?</p> <p>So far I have found the following solutions:</p> <ul> <li><p>parse the output of ifconfig and ipconfig (hard, different windows versions have different ipconfig outputs)</p></li> <li><p>establish a network conne...
<p><a href="http://search.cpan.org/perldoc?Net::Address::IP::Local" rel="noreferrer">Net::Address::IP::Local</a> looks promising.</p> <pre><code>use Net::Address::IP::Local; # Get the local system's IP address that is "en route" to "the internet": my $address = Net::Address::IP::Local-&gt;public; </code></pre>
<p>I have used a combination of these Linux commands so no dependancy on any perl module.</p> <pre><code>hostname -i hostname -I ls /sys/class/net ip -f inet addr show eth0| grep -Po 'inet \K[\d.]+' </code></pre>
42,807
<p>Does anyone know of any resources that talk about best practices or design patterns for shell scripts (sh, bash etc.)?</p>
<p>I wrote quite complex shell scripts and my first suggestion is "don't". The reason is that is fairly easy to make a small mistake that hinders your script, or even make it dangerous.</p> <p>That said, I don't have other resources to pass you but my personal experience. Here is what I normally do, which is overkill...
<p>Easy: use python instead of shell scripts. You get a near 100 fold increase in readablility, without having to complicate anything you don't need, and preserving the ability to evolve parts of your script into functions, objects, persistent objects (zodb), distributed objects (pyro) nearly without any extra code.</p...
10,396
<p>I would like to create a private customized social networking for my company employees and partners so that they can collaborate, exchange messages, share experiences (events, book references, etc) and be grouped into communities. Does anybody know good Java framework for start developing this? </p> <p>I would be l...
<p>Shindig is in incubation at Apache :<br> <a href="http://incubator.apache.org/projects/shindig.html" rel="noreferrer">http://incubator.apache.org/projects/shindig.html</a></p> <p>YouTube Link About Shindig :<br> <a href="http://www.youtube.com/watch?v=ZcWszaReqXI" rel="noreferrer">http://www.youtube.com/watch?v=ZcW...
<p>I 'v built my own social networking features such as creating group adding people to group, friends list, messages, events, comments, blogs and etc. If anyone is interested I can only provid you with the jar and the list of the rest of techs that you have to use with these features to work. If you like to add your...
36,010
<p>My program will take arbitrary strings from the internet and use them for file names. Is there a simple way to remove the bad characters from these strings or do I need to write a custom function for this?</p>
<p>Ugh, I hate it when people try to guess at which characters are valid. Besides being completely non-portable (always thinking about Mono), both of the earlier comments missed more 25 invalid characters.</p> <pre><code>foreach (var c in Path.GetInvalidFileNameChars()) { fileName = fileName.Replace(c, '-'); } </c...
<p>I find using this to be quick and easy to understand:</p> <pre><code>&lt;Extension()&gt; Public Function MakeSafeFileName(FileName As String) As String Return FileName.Where(Function(x) Not IO.Path.GetInvalidFileNameChars.Contains(x)).ToArray End Function </code></pre> <p>This works because a <code>string</cod...
43,181
<p>I need a Java library to convert PDFs to TIFF images. The PDFs are faxes, and I will be converting to TIFF so that I can then do barcode recognition on the image. Can anyone recommend a good free open source library for conversion from PDF to TIFF? </p>
<p>Disclaimer: I work for Atalasoft</p> <p><a href="http://www.atalasoft.com/products/dotimage/" rel="nofollow noreferrer">We have an SDK that can convert PDF to TIFF</a>. The rendering is powered by Foxit software which makes a very powerful and efficient PDF renderer.</p>
<p>I have some great experience with iText (now, I'm using 5.0.6 version) and this is the code for tiff convertion into pdf:</p> <pre><code>private static String convertTiff2Pdf(String tiff) { // target path PDF String pdf = null; try { pdf = tiff.substring(0, tiff.lastIndexOf('.') + 1) + "pdf";...
46,487
<p>I'm using firmware Marlin 2.0.3 on an Anet A8 printer. I'm using a Roko SN04-N NPN bed leveller. I've managed to set up 3 points bed levelling but I wanted to try the bilinear levelling.</p> <p>Issue is, the sensor goes out of the aluminum bed ever so slightly during levelling, resulting in the printing head crashi...
<p>If you have managed to setup 3-point levelling, you should be able to enable bi-linear levelling in the firmware.</p> <p>From the <a href="https://github.com/MarlinFirmware/Configurations/blob/master/config/default/Configuration.h" rel="nofollow noreferrer">configuration.h</a> file for Marlin firmware you can find ...
<p>Note for anyone looking at the answer above, but in 2.1.x: The <code>#define</code> lines have been renamed:</p> <pre><code>#if PROBE_SELECTED &amp;&amp; !IS_KINEMATIC #define PROBING_MARGIN_LEFT PROBING_MARGIN #define PROBING_MARGIN_RIGHT PROBING_MARGIN #define PROBING_MARGIN_FRONT PROBING_MARGIN #define PR...
1,586
<p>Usually when I need to fork in C, I do something like this:</p> <pre><code>pid_t p = fork(); if(p == 0) { /* do child stuff */ } else { /* do parent stuff and pray there wasn't an error */ } </code></pre> <p>It occured to me that I could ditch the extra variable and use:</p> <pre><code>if(fork() == 0) { /* child ...
<p>What you are suggesting will certainly work. However, error handling is not optional in any well-behaved application. The following implementation pattern is similarly succinct and also handles errors. Furthermore, it saves the fork() return value in the pid variable, in case you want to use it later in the paren...
<p>You are free to do that in C and it will work because the parent and child will receive different return values from the fork - and it is evaluated first. The only issues are the error handling as you mentioned. Also, you won't have any other way to recover the child PID in case you wanted to operate on it, such a...
16,281
<p>I would like information on algorithms that can help identify commonality and differences between sets of overlapping data. </p> <p>Using stackoverflow's tag system as an example:</p> <p>Let's say this question has been given 5 tags. Let's say there are 1000 other questions that have at least one of these tags. ...
<p>Look into Wager-Hamming distance. This is the Hamming distance defined on strings as the number of edit operations it takes to transform one string into another.</p> <p>You could also potentially use the partial order of equivalence classes and set inclusion: when questions A and B have the exact same set of tags ...
<p>Look into Wager-Hamming distance. This is the Hamming distance defined on strings as the number of edit operations it takes to transform one string into another.</p> <p>You could also potentially use the partial order of equivalence classes and set inclusion: when questions A and B have the exact same set of tags ...
49,206
<p>I'm storing an ArrayList of Ids in a processing script that I want to spit out as a comma delimited list for output to the debug log. Is there a way I can get this easily without looping through things?</p> <p>EDIT: Thanks to Joel for pointing out the List(Of T) that is available in .net 2.0 and above. That makes t...
<p>Yes, I'm answering my own question, but I haven't found it here yet and thought this was a rather slick thing:</p> <p>...in VB.NET:</p> <pre><code>String.Join(",", CType(TargetArrayList.ToArray(Type.GetType("System.String")), String())) </code></pre> <p>...in C#</p> <pre><code>string.Join(",", (string[])TargetAr...
<p>So far I found this is a good and quick solution</p> <pre><code>//CPID[] is the array string cps = &quot;&quot;; if (CPID.Length &gt; 0) { foreach (var item in CPID) { cps += item.Trim() + &quot;,&quot;; } } //Use the string cps </code></pre>
26,215
<p>Getting slanted or leaning prints when printing multiple parts. I checked the eccentric nuts and belts aren't rubbing anything. All works well when printing a single part. But multiple parts:</p> <p><a href="https://i.stack.imgur.com/d4BUR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d4BUR.jpg...
<p><em>If you want a more detailed answer, you need to give more details, e.g.; "What filament are you using?" "How old is the printer?" "What mods have you made to it?"</em></p> <hr> <p>I can tell you two possibilities. Either your x or y axis is slipping which could be because of worn out belts, belts that need to ...
<p>It could also be backlash in the system. Your belts aren't tight enough. Apparently the Y belt is not tight enough. That's a pretty awesome effect though. </p>
1,365
<p>Let's say I have the following simple table variable:</p> <pre><code>declare @databases table ( DatabaseID int, Name varchar(15), Server varchar(15) ) -- insert a bunch rows into @databases </code></pre> <p>Is declaring and using a cursor my only option if I wanted to iterate through ...
<p>First of all you should be absolutely sure you need to iterate through each row — set based operations will perform faster in every case I can think of and will normally use simpler code.</p> <p>Depending on your data it may be possible to loop using just <code>SELECT</code> statements as shown below:</p> <pre><co...
<p>This is the code that I am using 2008 R2. This code that I am using is to build indexes on key fields (SSNO &amp; EMPR_NO) n all tales</p> <pre><code>if object_ID('tempdb..#a')is not NULL drop table #a select 'IF EXISTS (SELECT name FROM sysindexes WHERE name ='+CHAR(39)+''+'IDX_'+COLUMN_NAME+'_'+SUBSTRING(table_n...
8,731
<p>Looking for an open source library, for C++, Java, C# or Python, for reading the data from Quicken <strong>.qdf</strong> files.</p> <p>@Swati: Quicken <strong>.qif</strong> format is for transfer only and is not kept up to date by the application like the .qdf file is.</p>
<p>QDF is proprietary and not really meant for reading other than my Quicken, probably for a reason as it is messy. </p> <p>I would recommend finding a way to export the qdf into an OFX (Open Financial Exchange) or qif file. I have done some financial and quickbooks automation and I did something similar. The probl...
<p>Check out <a href="http://qif.codeplex.com/" rel="nofollow">http://qif.codeplex.com/</a></p> <p>You may want to check the license before use. Thanks</p>
11,736
<p>I'm looking for some software to monitor a single server for performance alerts. Preferably free and with a reasonable default configuration.</p> <p>Edit: To clarify, I would like to run this software on a Windows machine and monitor a remote Windows server for CPU/memory/etc. usage alerts (not a single application...
<p>For performance monitor - start it on the server (<kbd>Win</kbd>+<kbd>R</kbd> and enter "perfmon"). Select "Performance Logs and Alerts" and expand. Select "Alerts". Select "Action" &amp; then "New Alert". Give the alert a name, click "Add" to add a counter (there are hundres of counters, for example CPU %), th...
<p>MS's solutions used to be called MOM. It looks like it's been <a href="http://www.microsoft.com/systemcenter/operationsmanager/en/us/default.aspx" rel="nofollow noreferrer">redesigned a bit</a> since I last used it.</p>
3,252
<p>I need a function like this:</p> <pre><code>// return true if 'n' is a power of 2, e.g. // is_power_of_2(16) =&gt; true // is_power_of_2(3) =&gt; false bool is_power_of_2(int n); </code></pre> <p>Can anyone suggest how I could write this?</p>
<p><code>(n &amp; (n - 1)) == 0</code> is best. However, note that it will incorrectly return true for n=0, so if that is possible, you will want to check for it explicitly.</p> <p><a href="http://www.graphics.stanford.edu/~seander/bithacks.html" rel="noreferrer">http://www.graphics.stanford.edu/~seander/bithacks.html...
<p>Another way to go (maybe not fastest) is to determine if ln(x) / ln(2) is a whole number. </p>
13,368
<p>I've been spoiled by ActiveRecords. So I'm on the lookout for migration system that can be applied to SQL Server, and either is executed as Java application, or a Win32 Executable. (Of course further compatibility with other DB's and host OS's is welcome.)</p> <p>The real desire is having a clear schema change ap...
<p>OpenNETCF's NetworkInformation namespace is not going to help - it's a wrapper around NDIS and WZC, which is not of much use for telephony. What is probebly relevent here is the <a href="http://msdn.microsoft.com/en-us/library/aa450239.aspx" rel="nofollow noreferrer">Telephony API (TAPI)</a>, though I have doubts w...
<p>OpenNETCF's NetworkInformation namespace is not going to help - it's a wrapper around NDIS and WZC, which is not of much use for telephony. What is probebly relevent here is the <a href="http://msdn.microsoft.com/en-us/library/aa450239.aspx" rel="nofollow noreferrer">Telephony API (TAPI)</a>, though I have doubts w...
34,393
<p>does anyone know if there is a simple way to bind a textblock to a List. What I've done so far is create a listview and bind it to the List and then I have a template within the listview that uses a single textblock.</p> <p>what I'd really like to do is just bind the List to a textblock and have it display all the ...
<p>Convert your List to a single string with "\r\n" as the delimiter in between. and bind that to the TextBlock. Make sure that the TextBlock is not restricted with its height , so that it can grow based on the number of lines. I would implement this as a Value Converter to XAML Binding which converts a List of strings...
<p>For concat collection of objects : </p> <pre><code> /// &lt;summary&gt;Convertisseur pour concaténer des objets.&lt;/summary&gt; [ValueConversion(typeof(IEnumerable&lt;object&gt;), typeof(object))] public class ConvListToString : IValueConverter { /// &lt;summary&gt;Convertisseur pour le Get.&lt;/summary&gt;...
44,938
<p>I'm building a public website which has its own domain name with pop/smtp mail services. I'm considering giving users the option to update their data via email - something similar to the functionality found in Flickr or Blogger where you email posts to a special email address. The email data is then processed and st...
<p>For starters you need to have hosting that allows you to create a catch-all mailbox.</p> <p>Secondly you need a good POP3 or IMAP library, which is not included AFAIK in the .NET stack.</p> <p>Then you would write a Command Line application or a Service that regularly checks the mailbox, pulls messages, inserts co...
<p>use a dotnet popclient to read the incoming emails, parse them for whatever you are expecting and insert the data into the database. </p> <p>see codeproject website for simple popclient implementation you would have to decided on the email content yourself, eg data only, payload of sql statements, etc</p>
15,328
<p>Why does the default IntelliJ default class javadoc comment use non-standard syntax? Instead of creating a line with "User: jstauffer" it could create a line with "@author jstauffer". The other lines that it creates (Date and Time) probably don't have javadoc syntax to use but why not use the javadoc syntax when ava...
<p>I'm not sure why Idea doesn't use the <code>@author</code> tag by default. </p> <p>But you can change this behavior by going to <code>File -&gt; Settings -&gt; File Templates</code> and editing the <code>File Header</code> entry in the <code>Includes</code> tab.</p> <p>As of IDEA 14 it's: <code>File -&gt; Settings...
<p>It is likely that the header snippet you show is older than javadoc and was just borrowed from some coding standard document, probably written for C++.</p>
8,912
<p>I'm working on a WinForm .Net application with the basic UI that includes toolbar buttons, menu items and keystrokes that all initiate the same underlying code. Right now the event handlers for each of these call a common method to perform the function.</p> <p>From what I've read this type of action could be handle...
<p>Let's first make sure we know what the Command pattern is:</p> <blockquote> <p>Command pattern encapsulates a request as an object and gives it a known public interface. Command Pattern ensures that every object receives its own commands and provides a decoupling between sender and receiver. A sender ...
<p>I can't help you with example link, but can provide example by myself.</p> <p>1) Define ICommand interface:</p> <pre><code>public interface ICommand { void Do(); void Undo(); } </code></pre> <p>2) Do your ICommand implementations for concrete commands, but also define abstract base class for them:</p> <pre...
3,582
<p>What culprits are the most likely to cause a <code>404 resource not found</code> error when a page in a given .WAR, autocreated by Sun's J2EE <code>deploytool</code>, is trying to load a Servlet in the same .WAR file? <br/> Eg:</p> <blockquote> <p> <h1>HTTP Status 404 - /MyServlet/MyServlet</h1><p><b>type</b> Sta...
<p>Is there a valid &lt;servlet-mapping&gt; for 'MyServlet' in your web.xml? That's been my number one culprit in the past</p>
<p>I just spent about an hour pulling my hair out on this very problem. Tomcat 5.5.27 on OSX was working just fine until I'd added another servlet and servlet-mapping at which point <em>everything</em> was returning a 404. I hadn't realized it, but when I'd added a new servlet/servlet-mapping pair I'd put the servlet-m...
9,230
<p>I'm trying to make a simple C# web server that, at this stage, you can access via your browser and will just do a "Hello World". </p> <p>The problem I'm having is that the server can receive data fine - I get the browser's header information - but the browser doesn't receive anything I send. Furthermore, I can only...
<p>You might like to know that you can use <a href="http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx" rel="nofollow noreferrer"><code>HttpListener</code></a> to write a basic web-server very easily - this deals with most of the painful bits, letting you concentrate on writing the actual code. The MS...
<p>Maybe I'm just missing something but the reason you can only connect on localhost is because the IP you are listening on is 127.0.0.1, this makes the TCPListener only listen on that IP address. And I don't see anywhere you are calling any client disconnect, the TCPListener is a blocking call, so it sits there foreve...
29,511
<p>I would like to use Visual Studio 2008 to the greatest extent possible while effectively compiling/linking/building/etc code as if all these build processes were being done by the tools provided with MASM 6.11. The exact version of MASM does not matter, so long as it's within the 6.x range, as that is what my colleg...
<p>There is a MASM rules file located at (32-bit system remove <code>(x86)</code>):</p> <pre><code>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCProjectDefaults\masm.rules </code></pre> <p>Copy that file to your project directory, and add it to the Custom Build Rules for your project. Then "Modify Rule File...
<p>If you are going to use Visual Studio, couldn't you give them a skeleton project in C/C++ with the entry point for a console app calling a function that has en empty inline assembly block, and let them fill their results in it?</p>
13,749
<p>I have an application that sometimes causes a BSOD on a Win XP machine. Trying to find out more, I loaded up the resulting *.dmp file (from C:\Windows\Minidump), but get this message when in much of the readout when doing so:</p> <pre><code>********************************************************************* * Sy...
<p>Quick answer is to </p> <p>c:\> set _NT_SYMBOL_PATH=SRV*C:\WINDOWS\Symbols*http://msdl.microsoft.com/download/symbols</p> <p>before starting windbg.</p>
<p>As @Vaibhav noted, you actually need to download the symbols and configure windbg to use them.</p> <p>Also note the following: !sym noisy -- Activates noisy symbol loading lm v -- Use with "m" parameter to look at information for a loaded module. lme D sm - List all modules w/o symbols.</p>
3,313
<p>What parts of a Grails application need to be stored in source-control? Some obvious parts that are needed:</p> <ul> <li>grails-app directory</li> <li>test directory</li> <li>web-app directory</li> </ul> <p>Now we reach questions like:</p> <ul> <li>If we use a Grails plug-in (like gldapo), do we need to check in...
<ul> <li>You do not want ./plugins/core (Core Grails plugins) under SVN</li> <li>You do not want anything under ./web-app/WEB-INF/ under SVN. You should not usually need to put files in here. Files from ./conf are copied to WEB-INF/classes so they are on the classpath, if you need to supply anything.</li> </ul> <p>Her...
<p>I would say, put all your project directory under versionning. Even the libs, it won't take that much disk space and you'll not change them so often. </p> <p>To my point of view, it's somehow "safer" than relying on external tools such as maven to grab all the dependencies, especially when one of the dependecies si...
18,075
<p>For deployment reasons, I am trying to use IJW to wrap a C# assembly in C++ instead of using a COM Callable Wrapper. </p> <p>I've done it on other projects, but on this one, I am getting an EEFileLoadException. Any help would be appreciated!</p> <p>Managed C++ wrapper code (this is in a DLL):</p> <pre><code>ext...
<p>The problem was where the DLLs were located.</p> <ul> <li>c:\dlls\managed.dll</li> <li>c:\dlls\wrapper.dll</li> <li>c:\exe\my.exe</li> </ul> <p>I confirmed this by copying managed.dll into c:\exe and it worked without issue. Apparently, the CLR won't look for managed DLLs in the path of the unmanaged DLL and will ...
<p>When you run in debugger C++ native project which use C++ managed dll you may get this exception. When VS2010 catch it and your application after some chain exceptions will be aborted you may try in exception filter (Menu|Debug|Excpetion) disable all C++ exceptions. You will still see this exception in output but yo...
11,937
<p>I have a VB6 dll that is trying to create a COM object using the following line of code:</p> <pre><code>Set CreateObj = CreateObject("OPSValuer.OPSValue") </code></pre> <p>However this fails with the error "Object variable or With block variable not set".</p> <p>I can see OPSValuer.OPSValue in dcomcnfg and it app...
<p>DMKing is right about OleView. Also try looking at the control in <a href="http://www.dependencywalker.com/" rel="nofollow noreferrer">Dependency Walker</a>, any missing dependencies should come quickly to the surface. </p> <p>Since this is a DCom component there also may be something failing in the components co...
<p>The error may be thrown within the object initializing routine. That I don't find "OPSValuer.OPSValue" on Google makes me think it is custom code that encounters a bug.</p>
24,785
<p>I'm having a JBoss EJB3 Application and a Swing client, running in 32-bit Java 6 VM's. We now have to change the Server JVM to 64 bit. May this combination of JVM's cause any trouble (do I need to use 64-bit JVM on the client, too)? </p> <p>Greetings,</p> <p>buzztee</p>
<p>No trouble with the combination. Anyway, its good practice to declare <strong>serialversionUID</strong> on your transmitted, serializable classes.</p>
<p>Will it cause any problems? No.</p>
24,969
<p>Ok,I'm running a setup with a single master and a number of slaves. All writes go through the master and are replicated down to the slaves which are used strictly for reads. </p> <p>Now I have a stored procedure (not function) which is called by a trigger on an insert. According to the MySQL docs, for replication t...
<p>In MySQL 5.0 (and MySQL 5.1 with statement based binary logging), only the calling query is logged, so in your case, the INSERT would be logged. </p> <p>On the slave, the INSERT will be executed and then the trigger will be re-run on the slave. So the trigger needs to exist on the slave, and assuming it does, the...
<p>In addition to Harrison's excellent answer:</p> <ul> <li>Assuming the databases are in sync (schema, data, same version) to start with, it should just work</li> <li>If it doesn't, then it may be that you're using something non deterministic in your queries or trigger. Fix that.</li> <li>Regardless of how you use re...
11,939
<p>How do I get a a complete list of all the urls that my rails application could generate? </p> <p>I don't want the routes that I get get form rake routes, instead I want to get the actul URLs corrosponding to all the dynmically generated pages in my application...</p> <p>Is this even possible?</p> <p>(Background: ...
<p>I was able to produce useful output with the following command:</p> <pre><code>$ wget --spider -r -nv -nd -np http://localhost:3209/ 2&gt;&amp;1 | ack -o '(?&lt;=URL:)\S+' http://localhost:3209/ http://localhost:3209/robots.txt http://localhost:3209/agenda/2008/08 http://localhost:3209/agenda/2008/10 http://localho...
<p>Check out the Spider Integration Tests written By Courtnay Gasking</p> <p><a href="http://pronetos.googlecode.com/svn/trunk/vendor/plugins/spider_test/doc/classes/Caboose/SpiderIntegrator.html" rel="nofollow">http://pronetos.googlecode.com/svn/trunk/vendor/plugins/spider_test/doc/classes/Caboose/SpiderIntegrator.ht...
10,986
<p>I do alot of systems programming where my apps have no chance of being used to communicate over the web or viewed through a browser. But, there has been some push by management to use XML. For example, if I want to keep a time log I could use a text file like this:</p> <p>command date time project<br> in 2008/09/...
<p>There's absolutely nothing wrong with using text-based data formatting. It has been the de-facto standard for decades. Big huge mainframe financial systems <em>still</em> use it today. The benefits are that it's trivial to produce, trivial to consume and incredibly lightweight. And how about log files? Do you k...
<p>It's easily parsable using regex and xml and xsl. </p> <p>Truth be told, there's not really an "advantage" to using XML unless you're sending the data to another system.</p>
15,450
<p><code>$0</code> is the variable for the top level Ruby program, but is there one for the current method?</p>
<p>Even better than my first answer you can use __method__:</p> <pre><code>class Foo def test_method __method__ end end </code></pre> <p>This returns a symbol – for example, <code>:test_method</code>. To return the method name as a string, call <code>__method__.to_s</code> instead.</p> <p><strong>Note:</stro...
<p>I got the same issue to retrieve method name in view file. I got the solution by</p> <pre><code>params[:action] # it will return method's name </code></pre> <p>if you want to get controller's name then</p> <pre><code>params[:controller] # it will return you controller's name </code></pre>
24,320