instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I've been tasked with build an accessible RSS feed for my company's job listings. I already have an RSS feed from our recruiting partner; so I'm transforming their RSS XML to our own proxy RSS feed to add additional data as well limit the number of items in the feed so we list on the latest jobs.</p> <p>The RSS val...
<p>I haven't yet worked with WordML, but assuming that its elements are in a different namespace from RSS, it should be quite simple to do with XSLT.</p> <p>Start with a basic identity transform (a stylesheet that add all nodes from the input doc "as is" to the output tree). You need these two templates:</p> <pre><c...
<p>I would do something like this:</p> <pre><code>char[] charToRemove = { (char)8217, (char)8216, (char)8220, (char)8221, (char)8211 }; char[] charToAdd = { (char)39, (char)39, (char)34, (char)34, '-' }; string cleanedStr = "Your WordML filled Feed Text."; for (int i = 0; i &lt; charToRemove.Length; i++) { cleane...
29,895
<p>Now, before you say it: I <strong>did</strong> Google and my <code>hbm.xml</code> file <strong>is</strong> an Embedded Resource. </p> <p>Here is the code I am calling:</p> <pre><code>ISession session = GetCurrentSession(); var returnObject = session.Get&lt;T&gt;(Id); </code></pre> <p>Here is my mapping file for ...
<p>Sounds like you forgot to add a mapping assembly to the session factory configuration..</p> <p>If you're using app.config...</p> <pre><code>. . &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;property name="query.substitutions"&gt;true 1, false 0, yes 'Y', no 'N'&lt;/property&gt; &lt;mapping ...
<p>Had a similar problem when find an object by id... All i did was to use the fully qualified name in the class name. That is Before it was :</p> <pre><code>find("Class",id) </code></pre> <p>Object so it became like this : </p> <pre><code>find("assemblyName.Class",id) </code></pre>
8,222
<p>Can someone please tell me how to submit an HTML form when the return key is pressed and if there are no buttons in the form? <strong>The submit button is not there</strong>. I am using a custom div instead of that.</p>
<p>To submit the form when the enter key is pressed create a javascript function along these lines.</p> <pre><code>function checkSubmit(e) { if(e &amp;&amp; e.keyCode == 13) { document.forms[0].submit(); } } </code></pre> <p>Then add the event to whatever scope you need eg on the div tag:</p> <p><code>&l...
<p>Similar to Chris Marasti-Georg's example, instead using inline javascript. Essentially add onkeypress to the fields you want the enter key to work with. This example acts on the password field.</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;title&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;form action="" me...
4,977
<p>Currently my code is organized in the following tree structure:</p> <pre><code>src/ module1.py module2.py test_module1.py test_module2.py subpackage1/ __init__.py moduleA.py moduleB.py test_moduleA.py test_moduleB.py </code></pre> <p>Where the <code>modul...
<p>Whether you seperate or mix tests and modules is probably a matter of taste, although I would strongly advocate for keeping them apart (setup reasons, code stats etc).</p> <p>When you're using nosetests, make sure that all directories with tests are real packages:</p> <pre><code>src/ module1.py module2.py ...
<p>I'll give a <a href="http://www.testoob.org" rel="nofollow noreferrer">Testoob</a> answer.</p> <p>Running tests in a single file is like Nose:</p> <pre><code>testoob test_foo.py </code></pre> <p>To run tests in many files you can create suites with the Testoob collectors (in each subpackage)</p> <pre><code># src...
47,865
<p>The following error is being thrown:</p> <pre><code>com.sun.jdi.InternalException: Got error code in reply:35 occurred while retrieving value. for all expressions </code></pre> <p>I am getting this error for all expressions and cant find anything on it. My guess is that the debugger isn't correctly connecting to ...
<p>It looks like the problem is related to the new debug feature "Show method result after a step operation": See the thread <a href="https://www.eclipse.org/forums/index.php?t=msg&amp;th=1088650&amp;goto=1772065&amp;" rel="noreferrer">Eclipse Oxygen - Debugging Issue</a> on the Eclipse forum:</p> <p><strong>The worka...
<p>I am not sure but I have got this plenty of times. It comes when I debug the application, and I think it occurs when the debugger tries to wrap a exception which arises due to code. At one instance while debugging when I see the logs I get some business exception, but while debugging it gave me <code>com.sun.jdi.int...
37,797
<p>It looks like some work has been done to make <a href="http://sourceware.org/pthreads-win32/" rel="noreferrer">pthread-win32</a> work with x64, but there are no build instructions. I have tried simly building with the Visual Studio x64 Cross Tools Command Prompt, but when I try to link to the lib from an x64 applica...
<p>Until it's officially released, it looks like you have to check out the CVS head to get version 2.9 of the library. Version 2.9 has all the x64 patches, but you will still have problems if you try to compile the static library from the command line.</p> <p>The only workaround I know of is to use the DLLs instead of...
<p><a href="http://sources.redhat.com/ml/pthreads-win32/2007/msg00008.html" rel="nofollow noreferrer">This message</a> might help.</p>
19,272
<p>Is it possible to order results in SQL Server 2005 by the relevance of a freetext match? In MySQL you can use the (roughly equivalent) MATCH function in the ORDER BY section, but I haven't found any equivalence in SQL Server.</p> <p>From the <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-natural-language....
<p>If you are using <code>FREETEXTTABLE</code> then it returns a column name <code>Rank</code>, so <code>order by Rank</code> should work. I don't know if other freetext search methods are also returning this value or not. You can have a try.</p>
<p>Both <code>FREETEXTTABLE</code> and <code>CONTAINSTABLE</code> will return the <code>[RANK]</code> column, but make sure you are using either the correct variation or union both of them to get all appropriate results.</p>
7,704
<p>I tried out printing a "bridge" for the first time using this <a href="https://www.thingiverse.com/thing:284380" rel="nofollow noreferrer">Bridge Calibration model</a>. The model creator suggests printing, tweaking settings, and printing again until it works "properly." </p> <p>My first try worked reasonably well, ...
<p>Unless you are using a calibrated temperature sensor, it is a question what the temperature will be. </p> <p>Actually it doesn't really matter what the temperature exactly is, you just need to find the sweet spot for your filaments on your machine. With respect to reported temperatures by others, your settings may ...
<p>Temperature from thermosensors gets collected as a resistance value that changes with temperature. The chip in your board decides the temperature from this value based on a temperature-resistance table.</p> <p>If you are using Marlin Firmware, the setting which table is referenced by your machine to get its values ...
1,126
<p>I'm trying to find about ALL the possible options that I can set in <code>web.config</code>. Surprisingly, I can't find this at all. I expected it to be somewhere inside <a href="http://msdn.microsoft.com" rel="noreferrer">MSDN</a>.</p> <p>I know I can technically add "anything" to <code>web.config</code>, what I'm...
<p>It all starts on <a href="http://msdn.microsoft.com/en-us/library/zeshe0eb(v=vs.100).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/zeshe0eb(v=vs.100).aspx</a> :</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/dayb112d(v=vs.100).aspx" rel="noreferrer"><code>&lt;system.web&gt;</code></a...
<p>This might be what you're after (not all in one page), but the top of the schema - drill down recursively to find it all :)</p> <p><a href="http://msdn.microsoft.com/en-US/library/b5ysx397(v=vs.100).aspx" rel="nofollow noreferrer">ASP.NET Configuration Settings</a></p>
26,167
<p>I want to create templates for base new reports on to have common designs. How do you do it?</p>
<p>The need to produce reports with a common starting design and format is key to any project involving clients and their reports. I have been working on reports for over 10 years now. This has not been the largest portion of my jobs through the years but it has been a very import one. The key to any report project ...
<p>Further more, I would suggest wrapping up your template perhaps with externally linked images into an .msi for easier distribution. It is a lot easier to ask people in a department to run an installer than it is to hope they find the right path to put the reporting template in. Make sure you use the proper program...
9,058
<p>I need a way to detect mouse/keyboard activity on Linux. Something similar to what any IM program would do. If no activity is detected for, say 5 minutes, it will set your IM status to "I'm not here right now".</p> <p>Any help towards this is appreciated.</p> <p>Thanks.</p>
<p>Complete <a href="/questions/tagged/c" class="post-tag" title="show questions tagged 'c'" rel="tag">c</a> solution : (cut &amp; paste the whole code in a terminal)</p> <pre><code>cat&gt;/tmp/idletime.c&lt;&lt;EOF #include &lt;time.h&gt; #include &lt;stdio.h&gt; #include &lt;unistd.h&gt; #include &lt;X11/Xlib.h&gt; ...
<p>I wrote the <a href="https://gist.github.com/siers/3b97d3f84347e8600985ce19bf5fb35b" rel="nofollow">wait-while-idle.rb</a> which does the <em>"detecting keyboard, mouse activity in linux"</em> but the other way around — wait until the user's come back.</p> <p>Yes, sure — it's polling, but I doubt anyone requires pe...
27,468
<p>I have some elements on a page which are draggable. These same elements have a click event which navigates to another page. I'm trying to determine the best way of preventing the click event from firing if the user is dragging but still allow the click event if not dragging. Anyone have any ideas of the best way to ...
<p>I solved this by using something like the following:</p> <pre><code>new Draggable('id', { onStart: function() { dPhoto = $('id'); Event.stopObserving('id', 'click'); }, onEnd : function() { setTimeout("Event.observe('id', 'click', function() { location.href = 'url'; });", 500); ...
<p>Something like the following might do the trick (and prevent the click event to be fired up)</p> <pre><code>new Draggable('tag', { revert:function() { $('tag').onclick = function(){return false;}; setTimeout('$(\'tag\').onclick = function(){return true;}','500'); ...
34,631
<p>Anyone know a simple method to swap the background color of a webpage using JavaScript?</p>
<p>Modify the JavaScript property <code>document.body.style.background</code>.</p> <p>For example:</p> <pre><code>function changeBackground(color) { document.body.style.background = color; } window.addEventListener("load",function() { changeBackground('red') }); </code></pre> <p>Note: this does depend a bit on h...
<p>This code makes random color for background every second.</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-js lang-js prettyprint-override"><code>setInterval(changeColor,1000); function changeColor(){ let r = ...
24,064
<p>I have a migration that runs an SQL script to create a new Postgres schema. When creating a new database in Postgres by default it creates a schema called 'public', which is the main schema we use. The migration to create the new database schema seems to be working fine, however the problem occurs after the migratio...
<p>Well that depends what your migration looks like, what your database.yml looks like and what exactly you are trying to attempt. Anyway more information is needed change the names if you have to and post an example database.yml and the migration. does the migration change the search_path for the adapter for example ?...
<p>You can use <a href="https://github.com/TMXCredit/pg_power" rel="nofollow">pg_power</a>. It provides additional DSL for migration to create PostgreSQL schemas and not only.</p>
11,669
<p>I have a link on my webpage to print the webpage. However, the link is also visible in the printout itself.</p> <p>Is there javascript or HTML code which would hide the link button when I click the print link?</p> <p>Example:</p> <pre class="lang-none prettyprint-override"><code> "Good Evening" Print (click Here...
<p>In your stylesheet add:</p> <pre><code>@media print { .no-print, .no-print * { display: none !important; } } </code></pre> <p>Then add <code>class='no-print'</code> (or add the no-print class to an existing class statement) in your HTML that you don't want to appear in the printed version, ...
<p>As Elias Hasle said, JavaScript can override <code>!important</code>. So, I extended his answer with a theoretical implementation.</p> <p>This code identifies all elements with the class <code>no-print</code>, hides them with CSS before printing, and restores the original style after printing:</p> <pre class="lang-j...
46,309
<p>(Note: This is for MySQL's SQL, not SQL Server.)</p> <p>I have a database column with values like "abc def GHI JKL". I want to write a WHERE clause that includes a case-insensitive test for any word that begins with a specific letter. For example, that example would test true for the letters a,c,g,j because there's...
<p>Using REGEXP opearator:</p> <pre><code>SELECT * FROM `articles` WHERE `body` REGEXP '[[:&lt;:]][acgj]' </code></pre> <p>It returns records where column body contains words starting with a,c,g or i (case insensitive)</p> <p>Be aware though: this is not a very good idea if you expect any heavy load (not using index...
<p>Check the <a href="http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html" rel="nofollow noreferrer">Pattern Matching</a> and <a href="http://dev.mysql.com/doc/refman/5.0/en/regexp.html" rel="nofollow noreferrer">Regular Expressions</a> sections of the MySQL Reference Manual.</p>
33,594
<p>I'm working with JInternalFrame's under Mac OS X Java 5 and when maximizing a JInternalFrame within a JDesktopPane the window doesn't fully maximize, but the property to allow maximizing is definitely set to true. This is the result I'm getting when maximized:</p> <p><a href="http://www.kieransenior.co.uk/pics/jin...
<p>Swing may be respecting the fact that you can't fully maximize a window on the Mac. As in, if you maximize a real window, it will simply become big, but not fill the entire screen. The desktop pane may be emulating this behaviour.</p> <p>You may be able to override this by listening for maximize events and manually...
<p>True indeed, Mac OS doesn't fully maximize windows. The problem is that I won't achieve the effect of a 'docked' window by just setting the size of the active window, which means a different approach is most probably required. That seems to be a common approach to the problem though.</p>
42,348
<p>When you attempt to declare an unsigned variable in C#.NET with a value outside its value range it is flagged as a compiler error, but if you produce a negative value at runtime and assign it to that variable at runtime the value wraps.</p> <pre><code>uint z = -1; // Will not compile uint a = 5; uint b = 6; uint c...
<p>Declaring an unassigned variable in C# isn't flagged with an error - trying to assign an invalid value to a variable is. For instance, here's a variable which isn't definitely assigned (assuming it's local) after declaration:</p> <pre><code>uint z; </code></pre> <p>-1 isn't a valid value for a uint any more than 0...
<p>The reason it wraps to negative is because of <a href="http://en.wikipedia.org/wiki/Two%27s_complement" rel="nofollow noreferrer">Two's Complement</a> math that is used for integer arithmetic. </p> <p>The short answer is that the most significant bit is used as the sign. A zero is positive; a one is negative.</p>...
29,519
<p>How does one setup DUnit Testing in a Midas/DataSnap project in Delphi 2006 </p> <p>Edit </p> <p>How does one set up a Dunit Test into a TRemoteDataModule The project wizard in Delphi 2006 does not work with TRemoteDataModule </p>
<p>The question doesn't entirely make sense. Unit tests are performed in a separate project, not within your DataSnap server. Generally, tests which connect to a database are integration tests rather than unit tests. What is it, exactly that you want to test? If it's utility methods within, say, a TRemoteDataModule,...
<p>Sorry for the terse answer above, the iPad posts whenever I hit return while editing a post.</p> <p>dUnit is designed to perform unit testing, and what you are trying to do is NOT unit testing.</p> <p>A test is not a unit test if:</p> <ul> <li>It talks to the database</li> <li>It communicates across the network</...
30,812
<p>I have HTML code edited by FCKEditor stored in a database and would like to display (well render) it onto a view. So, for instance, something stored as:</p> <pre><code>&amp;lt;&amp;gt;pre&amp;lt;&amp;gt;This is some sample text&amp;lt;&amp;gt;pre&amp;lt;/&amp;gt </code></pre> <p>Will be displayed to the user as:</p>...
<p>Try this:</p> <pre><code>&lt;%= System.Web.HttpUtility.HtmlDecode(yourEncodedHtmlFromYouDatabase) %&gt; </code></pre> <p>More info <a href="http://msdn.microsoft.com/en-us/library/system.web.httputility.htmldecode.aspx" rel="nofollow noreferrer">here</a>.</p>
<p>You want to use <code>@Html.Raw(str)</code>.</p> <p>See <a href="https://learn.microsoft.com/en-us/dotnet/api/system.web.mvc.htmlhelper.raw" rel="nofollow noreferrer">MSDN</a> for more information.</p> <blockquote> <p>Returns markup that is not HTML encoded.</p> <p>This method wraps HTML markup using the IHtmlString...
38,509
<p>My application allows the user to enter a numeric value (currency) in a <code>UITextField</code> control, but the keyboard layout that I wish was available is unfortunately not one of the built-in options, so I had to choose the "Numbers &amp; Punctuation" option in Interface Builder. Here's the corresponding dialog...
<p>I have the urge to answer because this was the first entry I saw when I googled and the highest ranked answer wouldn't allow me to enter a currency.<br> I'm german, and in germany (and in many other countries) we use <code>,</code> as the decimalseparator. </p> <p>I just wrote a similar method and this is what I ha...
<p>Using shouldChangeCharactersInRange screws up the pop-up key board as the backspace button doesn't work.</p> <p>Number formatter is the way to go. Here's a sample I used to find positive decimals. I call it during the validation check- for e.g. when the user clicks on the save button.</p> <pre><code> -(BOOL...
44,483
<p>Has anyone used Mono, the open source .NET implementation on a large or medium sized project? I'm wondering if it's ready for real world, production environments. Is it stable, fast, compatible, ... enough to use? Does it take a lot of effort to port projects to the Mono runtime, or is it really, <em>really</em> com...
<p>There are a couple of scenarios to consider: (a) if you are porting an existing application and wondering if Mono is good enough for this task; (b) you are starting to write some new code, and you want to know if Mono is mature enough.</p> <p>For the first case, you can use the <a href="http://mono-project.com/Mo...
<p>It really depends on the namespaces and classes that you are using from the .NET framework. I had interest in converting one of my windows services to run on my email server, which is Suse, but we ran into several hard roadblocks with APIs that had not been completely implemented. There is a chart somewhere on the...
3,904
<p>Is there a way to identify, from within a VM, that your code is running inside a VM?</p> <p>I guess there are more or less easy ways to identify specific VM systems, especially if the VM has the provider's extensions installed (such as for VirtualBox or VMWare). But is there a general way to identify that you are n...
<p>A lot of the research on this is dedicated to detecting so-called "blue pill" attacks, that is, a malicious hypervisor that is actively attempting to evade detection. </p> <p>The classic trick to detect a VM is to populate the ITLB, run an instruction that <strong>must</strong> be virtualized (which necessarily cl...
<p>If it VM does the job well, it should be invisible to the client that it's being virtualized. However, one can look at other clues.</p> <p>I would imagine that looking for known drivers or software specific to the VM environment would be the best possible way.</p> <p>For example, on a VMWare client running Windows...
6,061
<p>If I open an image with <code>open("image.jpg")</code>, how can I get the RGB values of a pixel assuming I have the coordinates of the pixel?</p> <p>Then, how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value?</p> <p>I would prefer if I didn't have to download an...
<p>It's probably best to use the <a href="http://www.pythonware.com/products/pil/" rel="noreferrer">Python Image Library</a> to do this which I'm afraid is a separate download.</p> <p>The easiest way to do what you want is via the <a href="http://effbot.org/imagingbook/image.htm" rel="noreferrer">load() method on the ...
<pre><code>import matplotlib.pyplot as plt import matplotlib.image as mpimg img=mpimg.imread('Cricket_ACT_official_logo.png') imgplot = plt.imshow(img) </code></pre>
16,730
<p>I have two tables, both with start time and end time fields. I need to find, for each row in the first table, all of the rows in the second table where the time intervals intersect.</p> <p>For example:</p> <pre><code> &lt;-----row 1 interval-------&gt; &lt;---find this--&gt; &lt;--and this--&gt; &lt;--an...
<pre><code>SELECT * FROM table1,table2 WHERE table2.start &lt;= table1.end AND (table2.end IS NULL OR table2.end &gt;= table1.start) </code></pre>
<p>And what, if you want to analyse such an overlap on a minute precision with 70m+ rows? the only solution i could make up myself was a time dimension table for the join </p> <p>else the dublicate-handling became a headache .. and the processing cost where astronomical</p>
14,357
<p>The WPF control WindowsFormsHost inherits from IDisposable.</p> <p>If I have a complex WPF visual tree containing some of the above controls what event or method can I use to call IDispose during shutdown?</p>
<p>In the case of application shutdown there is nothing you need to do to properly dispose of the WindowsFormsHost. Since it derives from HwndHost disposing is handled when the Dispatcher is shutdown. If you use Reflector you will see that when HwndHost is initialized it creates a WeakEventDispatcherShutdown.</p> <p>I...
<p>You don't need to dispose controls when closing a form, the API will do it for you automatically if the control is in the visual tree of the form ( as a child of the form or other control in the form)</p>
31,715
<p>What install tool can I use to create Virtual Directory on IIS? OpenSource, free or to do in C#. </p>
<p><a href="http://wix.sourceforge.net/" rel="nofollow noreferrer">WiX</a> can create IIS virtual directories.</p>
<p>You could use <a href="http://blogs.iis.net/msdeploy/archive/2008/01/22/welcome-to-the-web-deployment-team-blog.aspx" rel="nofollow noreferrer">Microsoft Web Deployment Tool</a> to recreate a website structure.</p>
14,326
<p>In Java, is there a way to have a window that is "Always on top" regardless if the user switches focus to another application? I've searched the web, and all of the solutions lean to some sort of JNI interface with native bindings. Truly this can't be the only way to do it?.. or is it?</p>
<p>Try this method of the <code>Window</code> class:</p> <p><a href="http://java.sun.com/javase/6/docs/api/java/awt/Window.html#setAlwaysOnTop%28boolean%29" rel="noreferrer">Window.setAlwaysOnTop(boolean)</a></p> <p>It works the same way as the default in the Windows TaskManager: switch to another app but it shows al...
<p>dont use setFullScreenWindow,just get the screen size and then setSize, and everything will be fine.</p>
38,124
<p>Using Django's built in models, how would one create a triple-join between three models.</p> <p>For example:</p> <ul> <li>Users, Roles, and Events are the models.</li> <li>Users have many Roles, and Roles many Users. (ManyToMany)</li> <li>Events have many Users, and Users many Events. (ManyToMany)</li> <li>But fo...
<p><strong>zacherates</strong> writes:</p> <blockquote> <p>I'd model Role as an association class between Users and Roles (...)</p> </blockquote> <p>I'd also reccomed this solution, but you can also make use of some syntactical sugar provided by Django: <a href="http://docs.djangoproject.com/en/dev/topics/db/models...
<p>I'd model Role as an association class between Users and Roles, thus,</p> <pre><code>class User(models.Model): ... class Event(models.Model): ... class Role(models.Model): user = models.ForeignKey(User) event = models.ForeignKey(Event) </code></pre> <p>And enforce the one role per user per ev...
9,856
<p>I'm interested in finding online APIs where you could perform a call to some third party service with some print preparation request with my model (i.e. "heal a model" or "set up support") and get in return GCODE file I can send to a 3D printer. My input will be :</p> <ul> <li>The 3d model (obj, stl)</li> <li>My pr...
<p>There are printers designed for medical use, and the manufacturers supply them with varying levels of <a href="http://www.medicalplasticsnews.com/opinion/passing-the-test_1/" rel="nofollow">certification and testing</a>, however I've not seen a filament manufacturer certify their material as bio-compatible separate ...
<p>If you want to know something about what you are questioning, it is interesting to you to read <a href="http://e-nable.org/resources/prosthetics-students-consultation/" rel="nofollow noreferrer">http://e-nable.org/resources/prosthetics-students-consultation/</a></p> <p>That's a link with complementary information h...
118
<p>I have an object that starts a thread, opens a file, and waits for input from other classes. As it receives input, it writes it to disk. Basically, it's a thread safe data logging class...</p> <p>Here's the weird part. When I open a form in the designer (Visual&nbsp;Studio&nbsp;2008) that uses the object the file ...
<p>You can check the UsageMode of the LicenseManager, to check if the code is in design time or not.</p> <p>System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime</p> <p>Here is a quick example:</p> <pre><code>using System; using System.ComponentModel; using System.Windows.F...
<p>There are some things you shouldn't do with the designer. I don't have any hard evidence, but I found that the Windows Forms designer hates it when you take away the default constructor from it. Just go ahead and create new overloads, but leave the empty constructor in place.</p> <p>Also try to avoid doing <code>Fo...
35,700
<p>I'm having issues getting the C sockets API to work properly in C++ on z/OS.</p> <p>Although I am including <code>sys/socket.h</code>, I still get compile time errors telling me that <code>AF_INET</code> is not defined.</p> <p>Am I missing something obvious, or is this related to the fact that being on z/OS makes my...
<p>Keep a copy of the IBM manuals handy:</p> <ul> <li><a href="http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CBCPG1A0/CCONTENTS?DT=20090606065305" rel="noreferrer"> z/OS V1R11.0 XL C/C++ Programming Guide</a> </li> <li><a href="http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/EDCLB1A0/CCONTENTS...
<p>DISCLAIMER: I am not a C++ programmer, however I know C really well. I adapated these calls from some C code I have.</p> <p>Also markdown put these strange &#95; as my underscores.</p> <p>You should just be able to write an abstraction class around the C sockets with something like this:</p> <pre><code>class my_...
2,240
<p>In Python, you can do this:</p> <pre><code>print &quot;Hi! I'm %(name)s, and I'm %(age)d years old.&quot; % ({&quot;name&quot;:&quot;Brian&quot;,&quot;age&quot;:30}) </code></pre> <p>What's the closest, simplest Ruby idiom to replicate this behavior? (No monkeypatching the String class, please.)</p> <p>One of the ...
<p>You can also use </p> <pre><code>printf "1: %&lt;key1&gt;s 2: %&lt;key2&gt;s\n", {:key1 =&gt; "value1", :key2 =&gt; "value2"} </code></pre> <p>or</p> <pre><code>data = {:key1 =&gt; "value1", :key2 =&gt; "value2"} printf "1: %&lt;key1&gt;s 2: %&lt;key2&gt;s\n", data </code></pre> <p>or (this needs ruby 1.9, for ...
<p>puts "Hi! I'm #{name}, and I'm #{age} years old."</p>
23,920
<p>At my current job we have a CMS system that is .NET/SQL Server based. While customizing a couple of the modules for some internal use, I was a little surprised to see that instead of having APIs that returned data via your typical result set that was bound to a DataGrid/DataList/Repeater control, that the APIs retur...
<p>Keep one integer for each bit, and increment this collection appropriately for each integer in the array.</p> <p>At the end, some of the bits will have a count higher than half the length of the array - those bits determine N. Of course, the count will be higher than the number of times N occurred, but that doesn't...
<p>I have recollections of this algorithm, which might or might not follow the 2K rule. It might need to be rewritten with stacks and the like to avoid breaking the memory limits due to function calls, but this might be unneeded since it only ever has a logarithmic number of such calls. Anyhow, I have vague recollect...
35,170
<p>I have a table that has a column with a default value:</p> <pre><code>create table t ( value varchar(50) default ('something') ) </code></pre> <p>I'm using a stored procedure to insert values into this table:</p> <pre><code>create procedure t_insert ( @value varchar(50) = null ) as insert into t (value) ...
<p>Try an if statement ... </p> <pre><code>if @value is null insert into t (value) values (default) else insert into t (value) values (@value) </code></pre>
<p>The easiest way to do this is to modify the table declaration to be </p> <pre><code>CREATE TABLE Demo ( MyColumn VARCHAR(10) NOT NULL DEFAULT 'Me' ) </code></pre> <p>Now, in your stored procedure you can do something like.</p> <pre><code>CREATE PROCEDURE InsertDemo @MyColumn VARCHAR(10) = null AS INSERT I...
28,554
<p>I have an Excel spreadsheet with a few thousand entries in it. I want to import the table into a MySQL 4 database (that's what I'm given). I am using SQuirrel for GUI access to the database, which is being hosted remotely. </p> <p>Is there a way to load the columns from the spreadsheet (which I can name according t...
<p>One of the ways GWT was designed to be used is exactly as you've used it. We have done that in many of our apps - where there is one GWT module with multiple 'parts' that are loaded based on whether a given id exists on a page or not. So I don't see that you'll have any issues at all going this way. We often use thi...
<p>You're doing it right. Avoid avoid avoid the temptation to try to 'minimize' the GWT footprint by breaking it up into multiple separate apps. </p> <p>The key to GWT performance is to have as few downloads as possible and to make sure they're cached. Loading a 250k bundle once is much better than two 200k bundles an...
47,404
<p>I receive HTML pages from our creative team, and then use those to build aspx pages. One challenge I frequently face is getting the HTML I spit out to match theirs exactly. I almost always end up screwing up the nesting of <code>&lt;div&gt;</code>s between my page and the master pages.</p> <p>Does anyone know of a...
<p>You can use <a href="http://tidy.sourceforge.net/" rel="nofollow noreferrer">HTMLTidy</a> to convert the HTML to well-formed XML so you can use <a href="http://msdn.microsoft.com/en-us/library/aa302294.aspx" rel="nofollow noreferrer">XML Diff</a>, as Gulzar suggested.</p> <pre><code>tidy -asxml index.html </code></...
<p>winmerge is a good visual diff program</p>
7,114
<p>I need to copy files using Windows command-line (available on XP Pro or later by default) and show progress during the process.</p> <p>The progress indicator could be in a terminal or a GUI window. It is intended to be used during batch file scripting.</p>
<p>I used the copy command with the /z switch for copying over network drives. Also works for copying between local drives. Tested on XP Home edition.</p>
<p>Here is the script I use:</p> <pre><code>@ECHO off SETLOCAL ENABLEDELAYEDEXPANSION mode con:cols=210 lines=50 ECHO Starting 1-way backup of MEDIA(M:) to BACKUP(G:)... robocopy.exe M:\ G:\ *.* /E /PURGE /SEC /NP /NJH /NJS /XD "$RECYCLE.BIN" "System Volume Information" /TEE /R:5 /COPYALL /LOG:from_M_to_G.log ECHO Fin...
8,324
<p>Are there any good <a href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html" rel="noreferrer">value list handler</a> implementations available?</p> <p>I've found <a href="http://valuelist.sourceforge.net/" rel="noreferrer">valuelist</a>, but it seems to be stagnating... besides I real...
<p>Calling MiniMizeMemory() will do a garbage collection, trim the process working size, then compact the process' heap.</p> <pre><code>public static void MinimizeMemory() { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); SetProcessWorkingSetSize( Process.GetCurrentProcess().Handle, ...
<p>While this is in C#, look at the source code, it will solve any issues you have:</p> <p><a href="http://www.codeproject.com/KB/cs/NotifyIconExample.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/NotifyIconExample.aspx</a></p>
32,953
<p>How can I programmatically remove a (known) password from an Excel VBA project?</p> <p>To be clear: I want to remove the password from the VBA Project, not the workbook or any worksheets.</p>
<p>Another way to remove VBA project password is;</p> <ul> <li>Open xls file with a hex editor. (ie. Hex Edit <a href="http://www.hexedit.com/" rel="noreferrer">http://www.hexedit.com/</a>)</li> <li>Search for DPB</li> <li>Replace DPB to DPx</li> <li>Save file.</li> <li>Open file in Excel.</li> <li>Click "Yes" if you...
<p>After opening xlsm file with 7 zip, extracting vbaproject.bin and in Notepad ++ replacing DpB with DPx and re-saving I got a Lot of vbaproject errors and vba project password was gone but no code/forms.</p> <p>I right clicked to export and was able to re-import to a new project.</p>
34,297
<p>One thing I am concerned with is that I discovered two ways of registering delegates to events.</p> <ol> <li>OnStuff += this.Handle; </li> <li>OnStuff += new StuffEventHandler(this.Handle);</li> </ol> <p>The first one is clean, and it makes sense doing "OnStuff -= this.Handle;" to unregister from the event... But ...
<p>You don't need to worry about keeping a reference to the originally registered delegate, and you will not start a "nasty memory pool".</p> <p>When you call "OnStuff -= new StuffEventHandler(this.Handle);" the removal code does <em>not</em> compare the delegate you are removing by reference: it checks for equality b...
<p>If I remember correctly, the first alternative is merely syntactic sugar for the second.</p>
12,499
<p>This is a bit hypothetical and grossly simplified but...</p> <p>Assume a program that will be calling functions written by third parties. These parties can be assumed to be non-hostile but can't be assumed to be "competent". Each function will take some arguments, have side effects and return a value. They have no ...
<p>You don't specify the operating system or environment, this answer assumes Linux, glibc, and C.</p> <p>You can set __malloc_hook, __free_hook, and __realloc_hook to point to functions which will be called from malloc(), realloc(), and free() respectively. There is a __malloc_hook manpage showing the prototypes. You...
<p>Since you're worried about memory leaks and talking about malloc/free, I assume you're in C. I'm also assuming based on your question that you do not have access to the source code of the third party library.</p> <p>The only thing I can think of is to examine memory consumption of your app before &amp; after the c...
7,366
<p>I have a method lets say:</p> <pre><code>private static String drawCellValue( int maxCellLength, String cellValue, String align) { } </code></pre> <p>and as you can notice, I have a parameter called align. Inside this method I'm going to have some if condition on whether the value is a 'left' or 'right'.. sett...
<p>This should do it:</p> <pre><code>private enum Alignment { LEFT, RIGHT }; String drawCellValue (int maxCellLength, String cellValue, Alignment align){ if (align == Alignment.LEFT) { //Process it... } } </code></pre>
<p>Sure, you could use an enum. Would something like the following work?</p> <pre><code>enum Alignment { LEFT, RIGHT } </code></pre> <p>private static String drawCellValue(int maxCellLength, String cellValue, Alignment alignment) { }</p> <p>If you wanted to use a boolean, you could rename the align paramete...
17,214
<p>I'm trying to highlight just one specific row in a table using jQuery. The row will have an 'active' status. I have seen plenty of examples online which show how to do zebra striping for alternate row styling. Does anyone know of a jQuery expression which will get a element based on the value of a element in a spe...
<p>check out ":contains" on <a href="http://docs.jquery.com/Selectors" rel="nofollow noreferrer">http://docs.jquery.com/Selectors</a></p>
<p>You can use one of them:</p> <pre><code>$("td").contains("test"); </code></pre> <p>or</p> <pre><code>$("div:contains('John')"); </code></pre>
22,114
<p>I'm trying to set up <a href="http://www.autohotkey.com/" rel="nofollow noreferrer">AutoHotkey</a> macros for some common tasks, and I want the hotkeys to mimic Visual Studio's "two-step shortcut" behaviour - i.e. pressing <kbd>Ctrl</kbd>-<kbd>K</kbd> will enable "macro mode"; within macro mode, pressing certain key...
<p>This Autohotkey script, when you press <kbd>ctrl</kbd>+<kbd>k</kbd>, will wait for you to press a key and if you press <kbd>d</kbd>, it will input the current date.</p> <pre><code>^k:: Input Key, L1 FormatTime, Time, , yyyy-MM-dd if Key = d Send %Time% return </code></pre>
<p>A slight variation on the accepted answer - this is what I've ended up using. I'm capturing Ctrl+LWin (left Windows key) so it doesn't conflict with VS inbuilt Ctrl-K shortcuts.</p> <pre><code>; Capture Ctrl+Left Windows Key ^LWin:: ; Show traytip including shortcut keys TrayTip, Ctrl-Win pressed - waiting for sec...
24,476
<p>I've noticed on bank websites, etc, my user IDs aren't saved (they don't appear in a dropdown like other commonly entered stuff does) and there's no prompt for it to remember your password. How is this done? How do the sites notify the browser that they are in 'special' or else exceptions? Just curious.</p>
<p>Usually you just need to put the autocomplete="off" into the form or field you want to block.</p> <p>Keep in mind that users can get around this with a scriptlet, plugin, or grease-monkey script.</p> <p><a href="https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion#Exceptions_and_Recommended_Workaro...
<p>Autocomplete behavior can be controlled at TextBox also. </p> <p>As suggested in link below, use AutoCompleteType = "Disabled" to disable autocomplete for any textbox.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.autocompletetype.aspx" rel="nofollow noreferrer">http://m...
42,524
<p>I know there are tools to get text files to resource files for Visual Studio. But I want to get the text from my resource files to a text file so they can be translated. Or is there a better way to do this? </p>
<p>You can use <a href="http://simpleresxeditor.blogspot.com/" rel="nofollow noreferrer">Simple Resx Editor</a>, it has some interesting features that will help you into the translation process.</p>
<p>You could use winres.exe from Microsoft, it lets you localize windows forms without having to use Visual Studio. It doesn't save the resources to a text file, but the idea is that the localization expert for each culture could use the tool to generate a localized versions of the application.</p> <p>Here's a better...
24,225
<p>I remember when MS was developing Cassini - I believe they rolled it into VS 05/08, so I think this is a Cassini web server question. </p> <p>I am using Windows XP with Visual Studio 2008, and find it quite inconvenient when I want to test a web page/styling with multiple browsers and multiple OSes. Right now I h...
<p>just figured out a good solution: 1) Set up fiddler on development machine 2) Set up remote machine to use fiddler as proxy 3) browse to <code>http://localhost.:[insert your dev port # here</code>]/ on remote machine</p>
<p>Using Fiddler as reverse proxy, development web server could get the request, but it becomes internal request (127.0.0.1), which is useless in my case.</p> <p>I'm trying to catch remote request to debug it on there.</p>
27,125
<p>I have a couple of files containing a value in each line.</p> <p><strong>EDIT :</strong></p> <p>I figured out the answer to this question while in the midst of writing the post and didn't realize I had posted it by mistake in its incomplete state.</p> <p>I was trying to do:</p> <pre><code>paste -d ',' file1 file...
<p>file 1:</p> <pre> 1 2 3 </pre> <p>file2:</p> <pre> 2 4 6 </pre> <pre><code>paste --delimiters=\; file1 file2 </code></pre> <p>Will yield:</p> <pre> 1;2 3;4 5;6 </pre>
<p>you probably need to clarify or retag your question but as it stands the answer is below.</p> <p>joining two files under Linux</p> <pre><code>cat filetwo &gt;&gt; fileone </code></pre>
4,485
<p>I need to do the following for the purposes of paging a query in nHibernate:</p> <pre><code>Select count(*) from (Select e.ID,e.Name from Object as e where...) </code></pre> <p>I have tried the following, </p> <pre><code>select count(*) from Object e where e = (Select distinct e.ID,e.Name from ...) </code></pre>...
<pre><code>var session = GetSession(); var criteria = session.CreateCriteria(typeof(Order)) .Add(Restrictions.Eq("Product", product)) .SetProjection(Projections.CountDistinct("Price")); return (int) criteria.UniqueResult(); </code></pre>
<p>If you just need <code>e.Id</code>,<code>e.Name</code>:</p> <p><code>select count(*) from Object where</code>.....</p>
14,159
<p>Let's say we have a solution with the following structure:</p> <ul> <li>Project.DAL - Data access layer, depends on a lower-level library, e.g. Oracle.DataAccess w/copy local = true </li> <li>Project.BLL - Business logic layer, references Project.DAL as project </li> <li>Project.UI - UI layer, compiles to executabl...
<p>Yes, Visual Studio will copy a DLL to the output path in any of the two conditions below:</p> <ol> <li>The DLL is referenced explicitly with CopyLocal = true</li> <li>The DLL is referenced without CopyLocal or implicitly through some other referenced DLL <strong>and is not in the GAC</strong></li> </ol> <p>The rea...
<p>@RenniePet Here's a link to a blog which describes the method RenniePet described in a comment above (if you don't want to edit your project file manually as @Shaun suggested):</p> <p><a href="http://blogs.msdn.com/b/jjameson/archive/2009/11/18/the-copy-local-bug-in-visual-studio.aspx" rel="nofollow">http://blogs.m...
46,062
<p>My Prusa Mk3 has been making this sort of rough surface on prints, and I'm not sure what caused this. I am printing with PLA Prusament with 0.2&nbsp;mm layer height at the preset for PLA. What is this, and how can I fix it?</p> <p><a href="https://i.stack.imgur.com/qRzOM.jpg" rel="nofollow noreferrer"><img src="htt...
<p>The OP was not able to reproduce the problem as can be taken from an edit to his question:</p> <blockquote> <p>Changed absolutely nothing, tried again and problem solved!</p> </blockquote> <p><em>To honor the Q/A approach used on SE sites, this comment has been converted to a community answer, that once voted fo...
<p>To me this looks like your nozzle is too hot. Try turning the temp down by 5 degrees at a time and see if the issue goes away.</p>
1,208
<p>I need to create a BAT file to run an application through telnet, but as far as I know there is no way to do this on DOS. Telnet does not allow any command to be sent to the remote machine at the very instant of the connection, and each subsequent command in the BAT file would only be executed after telnet stops. Th...
<p>Have you tried:</p> <pre><code>echo "c:\application\app.exe -a -b -c" | telnet 100.99.98.1 </code></pre> <p>this won't work if the remote telnet server requires a username and password, though.</p>
<p>Does your telnet app need to run in a command window, or do you only need to <em>start</em> it from the command line? If you want to "launch and forget," you might consider a scriptable terminal program such as the free TeraTerm. You can launch it from the command line with the <code>start</code> command and let i...
35,981
<p>Given a source color of any hue by the system or user, I'd like a simple algorithm I can use to work out a lighter or darker variants of the selected color. Similar to effects used on Windows Live Messenger for styling the user interface.</p> <p>Language is C# with .net 3.5.</p> <p><strong>Responding to comment:</...
<p>Simply multiply the RGB values by the amount you want to modify the level by. If one of the colors is already at the max value, then you can't make it any brighter (using HSV math anyway.)</p> <p>This gives the exact same result with a lot less math as switching to HSV and then modifying V. This gives the same re...
<p>Assuming you get the color as RGB, first convert it to HSV (hue, saturation, value) color space. Then increase/decrease the value to produce lighter/darker shade of the color. Then convert back to RGB.</p>
12,315
<p>I have seen some websites use the following tag:</p> <pre><code>&lt;meta type="title" content="Title of the page" /&gt; </code></pre> <p>Is it needed when you have a <code>&lt;title&gt;</code>?</p> <p>Also, what's the best formatting for a page title? Some ideas:</p> <ul> <li>Page Description :: Company Name</li...
<p>The <code>&lt;meta type="title"&gt;</code> tag has little rank or relevance to search engine crawlers. The good old <code>&lt;title&gt;</code> tag is far and away the <a href="http://www.w3.org/QA/Tips/good-titles" rel="nofollow noreferrer">most important element of a good web page</a>.</p> <p>As for the format of...
<p> is what you want to use, because it stands out more than meta tags to most search engines.</p> <p>My suggestion is to put the keywords that matter first, and avoid repeating the name of your business other than on the homepage, because this only serves to dilute the value of the title text.</p>
29,799
<p>Does anyone know the format of the MAPI property <code>PR_SEARCH_KEY</code>?</p> <p>The <a href="http://msdn.microsoft.com/en-us/library/ms529414(EXCHG.10).aspx" rel="nofollow noreferrer">online documentation</a> has this to say about it:</p> <blockquote> <p>The search key is formed by concatenating the addres...
<p>I believe that the property <code>PR_SEARCH_KEY</code> will be of different formats for different objects (as alluded to by Moishe).</p> <p>A MAPI message object will have a unique value assigned on creation for <code>PR_SEARCH_KEY</code>, however if the object is copied this property value is copied also. I presum...
<p>The sentence before the ones you quoted from the online docs reads, "MAPI uses specific rules for constructing search keys for message recipients" which makes me think that it's talking about the PR_SEARCH_KEY property on MAPI_MAILUSER objects -- or at least not on MAPI_MESSAGE objects.</p>
24,891
<p>Subject says it all but he background:</p> <p>I want to trigger some TortoiseSVN action from a batch file? I suspect that I can do this by calling the right exe with the right args but I'd rather find a way to solve the more general problem of doing an arbitrary action.</p> <p><strong>Edit:</strong> The reason tha...
<p>Use TortoiseProc.exe /command: See Appendix E of the TortoiseSVN guide</p>
<p>Seems to me as if you answered the question yourself. To trigger an arbitrary action will still require knowing something about the action. I am not sure that you will get any benefit from triggering a right click on a menu over calling the exe with the args in the first place.</p>
33,477
<p>I have a GSM modem connected via USB. The modem creates 2 serial ports. The first is automatically attached to the modem, the second shows in Device Manager as "HUAWEI Mobile Connect - 3G PC UI Interface (COM6)"</p> <p>The second port is used to get vital information from the modem, such as signal quality; to sen...
<p>A long time ago I wrote a utility for a client to do just this, but for a GPS rather than a modem. </p> <p>I have just looked at it, and bits that jump-out as being possibly helpful are:</p> <pre><code> GUID guid = GUID_DEVCLASS_PORTS; SP_DEVICE_INTERFACE_DATA interfaceData; ZeroMemory(&amp;interfaceData, siz...
<p>Used the method posted by <a href="http://gaiger-programming.blogspot.tw/2015/07/methods-collection-of-enumerating-com.html" rel="nofollow">LiGenChen</a>. The method ComPortSetupAPISetupDiClassGuids gave the best time and friendly name.</p>
39,214
<p>I first encountered the concept of <a href="http://ajaxpatterns.org/Lazy_Registration" rel="noreferrer">lazy registration</a> the <a href="http://ajaxpatterns.org/Main_Page" rel="noreferrer">Ajax Patterns</a> site, where they define it as accumulating "bits of information about the user as they interact, with formal...
<p>Have a look at this vid, a very good overview of the lazy registration pattern: <a href="http://www.90percentofeverything.com/2009/03/16/signup-forms-must-die-heres-how-we-killed-ours/" rel="nofollow noreferrer">http://www.90percentofeverything.com/2009/03/16/signup-forms-must-die-heres-how-we-killed-ours/</a></p>
<p>One way that I was thinking about implementing this is when users leave blog comments. A common Wordpress format is to allow site visitors to comment as long as they leave a name and an email address. If I followed a similar pattern and then after they submit their comment, ask them if they would also like to regist...
16,600
<p>I have an ASP.NET website and when I press F5 it automatically attaches to the ASP.NET Development Server, how do I attach to IIS worker process instead when I press F5?</p>
<p>open project properties, go to the web tab and choose the option for IIS.</p> <p>That actually starts an instance of the app in IIS and attaches the debugger. If you only wanted to attach to an existing IIS instance, choose attach to process from the debug menu.</p>
<p>go to the properties of the web application. Select the "Start Options" section, and change from "USe default web server" to "use custom server". Enter "<a href="http://localhost" rel="nofollow noreferrer">http://localhost</a>" in the base url. </p> <p>(assumes VS 2008)</p>
25,804
<p>I have an Arduino sending and receiving instructions with a Python script via a serial port.</p> <p>The Arduino takes a button state and when it is pushed, it will send a message via the serial port to a Python script and await a response. (via <code>Serial.available()</code>). It works well enough.</p> <p>However...
<p>You have a limited ability to detect if there is something listening on the other side by using the DSR/DTR pins.</p> <p>When you open the serial port on the machine your scripts runs on, it should raise its DTR pin (or you should be able to convince it to do so: the documentation of the library you use to drive th...
<p>I agree with mdb that timeouts are necessary, but would also add that you might want to implement simple challenge/response system that periodically checks if anyone is listening. (I like ircd's Ping-Pong analogy). </p>
23,723
<p>I'm trying to implement (what I think is) a pretty simple data model for a counter:</p> <pre><code>class VisitorDayTypeCounter(models.Model): visitType = models.CharField(max_length=60) visitDate = models.DateField('Visit Date') counter = models.IntegerField() </code></pre> <p>When someone comes throug...
<p>As of Django 1.1 you can use the ORM's F() expressions. </p> <pre><code>from django.db.models import F product = Product.objects.get(name='Venezuelan Beaver Cheese') product.number_sold = F('number_sold') + 1 product.save() </code></pre> <p>For more details see the documentation:</p> <p><a href="https://docs.djan...
<p>Your should use database transactions to avoid this kind of race condition. A transaction lets you perform the whole operation of creating, reading, incrementing and saving the counter on an "all or nothing" base. If anything goes wrong it will roll back the whole thing and you can try again.</p> <p>Check out the D...
35,404
<p>I need an algorithm to determine if a sentence, paragraph or article is negative or positive in tone... or better yet, how negative or positive.</p> <p>For instance:</p> <blockquote> <blockquote> <p>Jason is the worst SO user I have ever witnessed (-10)</p> <p>Jason is an SO user (0)</p> <p...
<p>There is a sub-field of natural language processing called <a href="http://en.wikipedia.org/wiki/Sentiment_analysis" rel="noreferrer">sentiment analysis</a> that deals specifically with this problem domain. There is a fair amount of commercial work done in the area because consumer products are so heavily reviewed i...
<pre><code> use Algorithm::NaiveBayes; my $nb = Algorithm::NaiveBayes-&gt;new; $nb-&gt;add_instance (attributes =&gt; {foo =&gt; 1, bar =&gt; 1, baz =&gt; 3}, label =&gt; 'sports'); $nb-&gt;add_instance (attributes =&gt; {foo =&gt; 2, blurp =&gt; 1}, label =&gt; ['sports...
37,392
<p>I am using PHP with Apache on Linux, with Sendmail. I use the PHP <a href="http://php.net/manual/en/function.mail.php" rel="noreferrer"><code>mail</code></a> function. The email is sent, but the envelope has the <code>Apache_user@localhostname</code> in <code>MAIL FROM</code> (example nobody@conniptin.internal) and ...
<p>mail() has a 4th and 5th parameter (optional). The 5th argument is what should be passed as options directly to sendmail. I use the following:</p> <pre><code>mail('to@blah.com','subject!','body!','From: from@blah.com','-f from@blah.com'); </code></pre>
<p>What you actually need to do is <strong>change</strong> the <strong>hostname</strong> of the machine Apache is running on, plus the <strong>user</strong> Apache is running as.</p> <p>In your current case it is:</p> <ul> <li>Apache user:<strong>nobody</strong></li> <li>Server hostname: <strong>conniptin.internal</s...
21,587
<p>I want to be able to run my Chiron during night-time, but my neighbours tries to sleep at that time of day. I have put a lot of effort into making the printer silent. The controller-fan and power-supply-fan now run slower and only when needed, I have put the printer on those <a href="https://www.thingiverse.com/thin...
<p>Have you tried a concrete tile for garden with foam below it?</p> <p>Check <a href="https://www.cnckitchen.com/blog/reduce-your-3d-printing-noise-with-a-concrete-paver" rel="noreferrer">https://www.cnckitchen.com/blog/reduce-your-3d-printing-noise-with-a-concrete-paver</a></p> <p>The same is on</p> <p><div class="yo...
<p>I noticed that my TMC drivers make a loud KLANK sound when switching from stealthchop to spreadcycle. The solution is to keep the in stealthchop at all time by butting the threshold really high (I set mine to 1000 mm/s). You may also look for resonance in your frame. If you’re using Klipper, you can use input Shaper...
1,885
<p>I have this input text:</p> <pre><code>&lt;html&gt;&lt;head&gt;&lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt;&lt;/head&gt;&lt;body&gt;&lt;table cellspacing="0" cellpadding="0" border="0" align="center" width="603"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt;&lt;table cellspacing="0" cellp...
<p>There are excellent HTML parsers for Perl, learn to use them and stick with that. HTML is complex, allows > in attributes, heavily use nesting, etc. Using regexes to parse it, beyond very simple tasks (or machine generated code), is prone to problems.</p>
<p>I think you want my <a href="http://search.cpan.org/dist/HTML-SimpleLinkExtor" rel="nofollow noreferrer">HTML::SimpleLinkExtor</a> module:</p> <pre> use HTML::SimpleLinkExtor; my $extor = HTML::SimpleLinkExtor->new; $extor->parse_file( $file ); my @imgs = $extor->img; </pre> <p>I'm not sure what exactly you're t...
47,249
<p>I would like to do some integration testing of a web service from within NUnit or MBUnit. I haven't delved into this too deeply yet, but I am pretty sure I will need to spin up WebDev.WebServer.exe within the "unit test" to do this. (I know it's not really a unit test).</p> <p>Yes, I can test the underlying objects...
<p>I found <a href="http://haacked.com/archive/2006/12/12/using_webserver.webdev_for_unit_tests.aspx" rel="nofollow noreferrer">this post</a> and <a href="http://www.hanselman.com/blog/NUnitUnitTestingOfASPNETPagesBaseClassesControlsAndOtherWidgetryUsingCassiniASPNETWebMatrixVisualStudioWebDeveloper.aspx" rel="nofollow...
<p>Not sure what you're asking. If you're looking to do this without some sort of webserver in between your test and the service, you're going to be disappointed.</p> <p>If that's not what you're asking... maybe some clarification?</p>
4,124
<p>I'm rewriting an old application and use this as a good opportunity to try out C# and .NET development (I usually do a lot of plug-in stuff in C).</p> <p>The application is basically a timer collecting data. It has a start view with a button to start the measurement. During the measurement the app has five differen...
<p>Creating a bunch of overlaid panels is a design-time nightmare.</p> <p>I would suggest using a tab control with each "view" on a separate tab, and then picking the correct tab at runtime. You can avoid showing the tab headers by putting something like this in your form's Load event:</p> <pre><code>tabControl1.Top...
<p>I would also check out <a href="http://msdn.microsoft.com/en-us/library/cc707819.aspx" rel="nofollow noreferrer">Composite Application Guidance for WPF</a> or <a href="http://msdn.microsoft.com/en-us/library/aa480450.aspx" rel="nofollow noreferrer">Smart Client Software Factory</a> </p>
4,478
<p>Hello I am compiling a program with make but I get the error of No such file or directory but the file is in a directory of the path.</p> <p>I have this #include "genetic.h", that file is in a directory called /home/myuser/toolbox/lib/genalg and in the PATH I have ...:/home/myuser/toolbox/lib/genalg, so I do not wh...
<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,040
<p>How can i build provisioning profile for deploying an iPhone application?</p>
<p>Agree with above, but here is a the gist of it.</p> <ol> <li>Register with Apple as an iPhone developer.</li> <li>Give them 100 bucks to get your entrance into the club that can deploy apps onto phones.</li> <li>Create your mobile provisioning in the <a href="https://developer.apple.com/ios/manage/overview/index.ac...
<p>Ensure that your iPhone is not jailbroken. The process described is a bit of a pain but it's a one-time thing.</p>
48,048
<p>Do you expect your WPF developers to know expression blend?</p> <p>Any good resources for learning more about Blend?</p> <p>[UPDATE] Does knowing blend make you more productive?</p>
<p>I found Blend a great way to ease into XAML. Many of the common things you want to do are easy in Blend, especially databinding. Databinding has no intellisense and I found doing things in Blend a great way of discovering how do write the databinding syntax.</p> <p>I now find myself mostly editing raw XAML buy han...
<p>Developers don't <strong>need</strong> to know Expression at all.</p> <p>What you <strong>do</strong> need to know is XAML and not hide behind some tool, which would be the worst thing you could do as a WPF developer. Your tool of choice is yours to decide on. I used to use the XML editor in Visual Studio.</p> <p>...
8,658
<p>I changed the filament (PLA) in my Wanhao Duplicator I3+. I ended the first try to print when I saw that the 'lines' were too thin. I re-sliced with a higher temperature (195°C instead of 190°C). Now the print started without a problem but after about 25% no more filament came out of the extruder. What can be the re...
<p>I redid the print in order to reply to some questions posed in the answer of @kdtop. The print started but the output was not consistent and sometimes stopped. The temperature is 195°C and sometimes 'drop' to 194°C. First I pushed the new real so that the extruder did not need to pull so much. When this did not solv...
<p>My slicer (Cura-lulzbot) has a setting for initial printing temp, and then printing temp after the first few layers. Is it possible that your temp is initially OK, but then drops too low? Does your printer have a readout that shows the current temp? Is the temp still OK when it stops?</p> <p>It sounds like you a...
926
<p>I'm a relatively new Java programmer coming from C++/STL, and am looking for a class with these characteristics (which the C++ std::deque has, as I understand it):</p> <ol> <li>O(1) performance for insertion/removal at the beginning/end</li> <li>O(1) performance for lookup by index</li> <li>are growable collections...
<p>Primitive Collections for Java has an ArrayDeque with a get(int idx) method.</p> <p><a href="http://sourceforge.net/projects/pcj" rel="noreferrer">http://sourceforge.net/projects/pcj</a></p> <p>I can't vouch for the quality of this project though.</p> <p>An alternative would be to get the JDK ArrayDeque source an...
<p>My default approach would be to hack together my own class, with ArrayList as an underlying implementation (e.g. map my own class's indices to ArrayList indices)... but I hate reinventing the wheel especially when there's a good chance of screwing up...</p>
45,558
<p>Why does the following code sometimes causes an Exception with the contents "CLIPBRD_E_CANT_OPEN":</p> <pre><code>Clipboard.SetText(str); </code></pre> <p>This usually occurs the first time the Clipboard is used in the application and not after that.</p>
<p>Actually, I think this is the <a href="https://cloudblogs.microsoft.com/enterprisemobility/2006/11/20/why-does-my-shared-clipboard-not-work-part-2/" rel="noreferrer">fault of the Win32 API</a>.</p> <p>To set data in the clipboard, you have to <a href="http://msdn.microsoft.com/en-us/library/ms649048(VS.85).aspx" re...
<p>The difference between Cliboard.SetText and Cliboard.SetDataObject in WPF is that the text is not copied to the clipboard, only the pointer. I checked the source code. If we call SetDataObject(data, true) Clipoard.Flush() will also be called. Thanks to this, text or data is available even after closing the applicati...
9,423
<p>The C++ standard dictates that member variables inside a single access section must be layed out in memory in the same order they were declared in. At the same time, compilers are free to choose the mutual ordering of the access sections themselves. This freedom makes it impossible in theory to link binaries creat...
<blockquote> <p>This freedom makes it impossible in theory to link binaries created by different compilers.</p> </blockquote> <p>It's impossible for a number of reasons, and structure layout is the most minor. vtables, implementations of <code>operator new</code> and <code>delete</code>, data type sizes...</p> <blo...
<p>EDIT: I'm afraid i misunderstood your question</p> <p>I think it's an optimization for memory access. For example, if we got this structure:</p> <pre><code>struct example { int16 intData; byte byteData; int32 intData; byte intData; int32 intData; } </code></pre> <p>Let's suppose the word in this plat...
36,879
<p>I've been trying to build subversion (on a limited account) for a long time but without any luck :(</p> <p>The instructions I'm following: <a href="http://wiki.dreamhost.com/Subversion_Installation" rel="nofollow noreferrer">http://wiki.dreamhost.com/Subversion_Installation</a></p> <p>Running this:</p> <pre><code...
<ol> <li>you don't have libcrypto.a and libcrypto.so on your system</li> <li>you need to install install libcrypto, which is in the libssl-dev package (<code>aptitude install libssl-dev</code>)</li> <li>Neon is the WebDAV library included in subversion; WebDAV being one of the wire protocols that subversion supports (h...
<p>NB: I'm using a <strong>shared host</strong> so I'm not able to do some things.</p> <p>Calling </p> <pre><code>apt-get install libssl-dev </code></pre> <p>gives me this error:</p> <pre><code>E: Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied) E: Unable to lock the administration director...
34,603
<p>I have the following dead simple elisp functions; the first removes the fill breaks from the current paragraph, and the second loops through the current document applying the first to each paragraph in turn, in effect removing all single line-breaks from the document. It runs fast on my low-spec Puppy Linux box usi...
<p>As the first try, you should download and install Emacs 22.3 for your Windows box and then compare the speed.</p> <p>Speed difference shouldn't be that big after upgrade.</p>
<p>Perhaps it is the big value you assign to fill-column (they suggest less than 80).</p>
44,302
<p>Can anyone provide and example of downloading a PDF file using Watin? I tried the SaveAsDialogHandler but I couldn't figure it out. Perhaps a MemoryStream could be used?</p> <p>Thanks,</p> <p>--jb</p>
<p>This code will do the trick. The UsedialogOnce class can be found in the WatiN.UnitTests code and will be part of the WatiN 1.3 release (which will probably be released tonigh 14 october).</p> <p>FileDownloadHandler fileDownloadHandler = new FileDownloadHandler(file.FullName); using (new UseDialogOnce(ie.DialogWatc...
<p>Take a look at this post:</p> <p><a href="https://stackoverflow.com/questions/1191897/how-to-check-if-pdf-was-successfully-opened-in-the-browser-using-watin/1457215#1457215">How to check if PDF was successfully opened in the browser using WatiN?</a></p>
24,148
<p>For fun, I'm trying to write one of my son's favorite board games as a piece of software. Eventually I expect to build a WPF UI on top of it, but right now I'm building the machine that models the games and its rules.</p> <p>As I do this, I keep seeing problems that I think are common to many board games, and perh...
<p>it seems this is a 2 month old thread that I've just noticed now, but what the heck. I've designed and developed the gameplay framework for a commercial, networked board game before. We had a very pleasant experience working with it.</p> <p>Your game can probably be in a (close to) infinite amount of states becau...
<p><a href="http://www.threerings.com/code/" rel="nofollow noreferrer">Three Rings</a> offers LGPL'd Java libraries. Nenya and Vilya are the libraries for game related stuff.</p> <p>Of course, it would help if your question mentioned platform and/or language restrictions you might have.</p>
47,113
<p>Most of the MVC samples I have seen pass an instance of the view to the controller like this</p> <pre><code>public class View { Controller controller = new Controller(this); } </code></pre> <p>Is there any advantage to passing a class which provides access to just the the properties and events the controlle...
<p>My advice is to use the cached framework regardless of your user-base. The fact is, you won't be alone in doing so and it will only be a matter of time before it pays off (even if it is on return visits).</p>
<p>This is probably not the solution you want, but just to help you with the log parsing, you can use this to get counts for each from the logs (assuming you're on a linux server) :</p> <pre><code>grep -c \.swz web_log_dir/* grep -c \.swf web_log_dir/* </code></pre>
11,405
<p>I am fairly new to programming and while doing a lot of reading this concept of a lambda keeps coming up but I'm having a hard time putting my finger on what it actually is and how implementing it will make my programming life so much better. So first, what is a lambda and second how might it be implemented?</p> <...
<p>Lambda are hard to catch, but once you have pictured them, you cannot understand why you didn't get it before.</p> <h2>Lamdba are anonymous functions</h2> <p>Lambda are ordinary functions, <strong>the only difference is that you don't give them a name.</strong></p> <p>To understand that, you must know first that ...
<p>Lambda is <a href="http://en.wikipedia.org/wiki/Lambda_calculus" rel="nofollow noreferrer">lambda calculus</a>, but I think people use it with the term <a href="http://en.wikipedia.org/wiki/Closure_%28computer_science%29" rel="nofollow noreferrer">closure</a> interchangeably. See <a href="https://stackoverflow.com/q...
48,883
<p>Some ways to iterate through the characters of a string in Java are:</p> <ol> <li>Using <code>StringTokenizer</code>?</li> <li>Converting the <code>String</code> to a <code>char[]</code> and iterating over that.</li> </ol> <p>What is the easiest/best/most correct way to iterate?</p>
<p>I use a for loop to iterate the string and use <code>charAt()</code> to get each character to examine it. Since the String is implemented with an array, the <code>charAt()</code> method is a constant time operation.</p> <pre><code>String s = "...stuff..."; for (int i = 0; i &lt; s.length(); i++){ char c = s.c...
<p>See <a href="http://java.sun.com/docs/books/tutorial/java/data/strings.html" rel="nofollow noreferrer">The Java Tutorials: Strings</a>.</p> <pre><code>public class StringDemo { public static void main(String[] args) { String palindrome = "Dot saw I was Tod"; int len = palindrome.length(); ...
23,918
<p>How does one convert an image from one color profile to another (screen to printer, or scanner to screen). In Visual C++ you would use the function in ICM.h, is there a managed way to do this with GDI+?</p> <p>I need to use GDI+, not WPF. I'd prefer to have a managed solution, but if it is not available, I guess ...
<p>There are a number of solutions.</p> <ol> <li>For GDI+, <a href="https://web.archive.org/web/20090224151626/http://support.microsoft.com/kb/317825/" rel="nofollow noreferrer">check out this article at MSDN</a> (HOW TO: Use GDI+ and Image Color Management to Adjust Image Colors).</li> <li>For WPF (.NET 3.0), see the ...
<p>You should take a look at <a href="http://www.littlecms.com/" rel="nofollow noreferrer">Lcms</a>. Its a colour management system, fairly complete, but written in C. you can use pinvoke, but I would recommend Managed C++ wrapper. I am actually currently working on a managed wrapper around the engine (just the basics,...
5,918
<p>The <a href="http://doi.org/" rel="noreferrer">DOI</a> system places basically no useful limitations on what constitutes <a href="http://doi.org/handbook_2000/enumeration.html#2.2" rel="noreferrer">a reasonable identifier</a>. However, being able to pull DOIs out of PDFs, web pages, etc. is quite useful for citation...
<p>Ok, I'm currently extracting thousands of DOIs from free form text (XML) and I realized that <a href="https://stackoverflow.com/a/10300246/89771">my previous approach</a> had a few problems, namely regarding encoded entities and trailing punctuation, so I went on reading <a href="http://www.doi.org/doi_handbook/2_Nu...
<p>The following regex should do the job (Perl regex syntax):</p> <pre><code>/(10\.\d+\/\d+)/ </code></pre> <p>You could do some additional sanity checking by opening the urls</p> <pre><code>http://hdl.handle.net/&lt;doi&gt; </code></pre> <p>and</p> <pre><code>http://dx.doi.org/&lt;doi&gt; </code></pre> <p>where ...
4,757
<p>I have the following regular expression : I figured out most of the part which is as follows :</p> <pre> ValidationExpression="^[\u0020\u0027\u002C\u002D\u0030-\u0039\u0041-\u005A\u005F\u0061-\u007A\u00C0-\u00FF°&#46;/]{1,256}$" u0020 : SPACE u0027 : APOSTROPHE u002C : COMMA u002D : HYPHEN / MINUS u0030-\u0039\ : ...
<p>weird... according to the character map on Windows I'd say "À to ÿ"</p> <p>Those are some variations (accents, cedillas) on A, C, E, I, D, N, O, U, Y, the german Sharp s, ...</p>
<p>It looks to be the range of characters presented in the last 2 columns in TABLE ASCII-II at the following link to <a href="http://www.cdrummond.qc.ca/cegep/informat/Professeurs/Alain/files/ascii.htm" rel="nofollow noreferrer">The Extended ASCII Chart</a></p>
22,779
<p>I type </p> <pre><code>ArrayList memberNames = new ArrayList() { "Jim", "John", "George" }; </code></pre> <p>and Visual Studio tells me "ArrayList" cannot be found so I have to manually go to the top of the file and type</p> <pre><code>using System.Collections; </code></pre> <p>Is there a way to get Visual Studi...
<p>SHIFT-ALT-F10 Will activate the Smart Tag on the class, which will give you the options "using System.Collections", and "System.Collections.ArrayList". It's typically two keystrokes to add a using.</p> <p>Edit: Seems I had a mangled keyboard profile. Updated the key combo to the default. Thanks to Alan for poin...
<p><strong>CTRL+.</strong> also activates the Smart Tag, which might be more intuitive.</p>
37,282
<p>I've been tasked with the the maintenance of a nonprofit website that recently fell victim to a SQL injection attack. Someone exploited a form on the site to add text to every available text-like field in the database (varchar, nvarchar, etc.) which, when rendered as HTML, includes and executes a JavaScript file. </...
<p>Restore the data from a recent backup.</p>
<p>This will reverse that, also it would be wise to take sysobject permissions away from the username your site runs with, and to sanitize input of course</p> <pre><code>DECLARE @T VARCHAR(255),@C VARCHAR(4000) DECLARE Table_Cursor CURSOR FOR SELECT a.name,b.name FROM sysobjects a,syscolumns b WHERE a.id=b.id and a...
5,234
<p>I have been working on a legacy C++ application and am definitely outside of my comfort-zone (a good thing). I was wondering if anyone out there would be so kind as to give me a few pointers (pun intended).</p> <p>I need to cast 2 bytes in an unsigned char array to an unsigned short. The bytes are consecutive. </p>...
<p>Well, you are widening the char into a short value. What you want is to interpret two bytes as an short. <code>static_cast</code> cannot cast from <code>unsigned char*</code> to <code>unsigned short*</code>. You have to cast to <code>void*</code>, then to <code>unsigned short*</code>:</p> <pre><code>unsigned short ...
<p>Did nobody see the input was a string!</p> <pre><code>/* If it is a string as explicitly stated in the question. */ int byte1 = packetBuffer[1] - '0'; // convert 1st byte from char to number. int byte2 = packetBuffer[2] - '0'; unsigned short result = (byte1 * 256) + byte2; /* Alternatively if is an array of byte...
38,576
<p>I want to recreate the stickiness and snapping of windows, like it is implemented in Winamp.</p> <p>The basic premise is, when you drag a window and it comes close to another one, it will snap to it and will stick. When you move it the two will move together.</p> <p>I need it for a MDI application.</p>
<p>You could read this article and try to adopt it for your program:</p> <p><a href="http://www.codeproject.com/KB/cs/stickywindows.aspx" rel="nofollow noreferrer">Sticky Windows - How to make your (top-level) forms to stick one to the other or to the screen</a></p> <p>The class presented in the article inherits from...
<p>Check out this one:</p> <p><a href="http://www.codeproject.com/KB/cs/eugsnapformextender.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/eugsnapformextender.aspx</a></p>
13,579
<p>I want to output the function name each time it is called, I can easily copy and paste the function name, however I wondered if there was a shortcut that would do the job for me?</p> <p>At the moment I am doing:</p> <pre><code>SlideInfoHeader* lynxThreeFile::readSlideInfoHeader(QDataStream &amp; in) { qDebug("...
<p>"<code>__FUNCTION__</code>" is supported by both MSVC and GCC and should give you the information you need. </p>
<p>If you check out boost there is a macro BOOST_CURRENT_FUNCTION that is portable across platforms. In the C99 standard there is a compiler variable <code>__func__</code> that has the desired effect. I believe has been accepted into the C++0x standard. A reasonable number of compilers will already support this.</p>
20,946
<p>I have a checkstyle suppression filter setup (e.g. ignore magic numbers in unit test code).</p> <p>The suppression xml file resides in the same folder as the checkstyle xml file. However, where this file actually is varies: on my windows dev box it is in d:\dev\shared\checkstyle\config on the Linux CI server it wil...
<p>I had this same problem with the Checkstyle suppression configuration when I was going back and forth between Linux and Windows. Here's how I solved it in my Ant-based build system:</p> <p>Basically, I inject the proper, platform-specific directory value into the main Checkstyle configuration file by configuring a ...
<p>Since CheckStyle 4.26.0 you can use predefined constants in your config files.</p> <p>(<a href="https://github.com/jshiell/checkstyle-idea/issues/217" rel="nofollow noreferrer">https://github.com/jshiell/checkstyle-idea/issues/217</a>) : </p> <blockquote> <ul> <li>${basedir} &amp; ${project_loc} - gets mapped ...
24,144
<p>Recently when I looked into iPhone memory management, I tried to compare the convenience method and init method on the same object. For example, I have UIImageView where it displays a downloaded NSData:</p> <p>Convenience method:</p> <pre><code>imageView.image = [UIImage imageWithData:[downloads dataAtIndex:0]]; <...
<p>Your autoreleased objects created by the convenience methods will not be released until the containing autorelease pool is drained. It is advisable to wrap memory intensive operations inside of an <code>NSAutoreleasePool</code> block if you will be making heavy use of them.</p>
<p>The only difference that could be causing this is that imageWithData: doesn't use the system image cache, while initWithData: does. So maybe the image that's made with the initializer can release it's image data when it receives a memory warning since it can go back to the system cache, while the one that's created ...
36,883
<p>Recently developers highlighted that it is bit hard for them to keep track of which document has been updated. And they thus suggested that using SVN to keep track of document changes will be better as they will be able to know if document if being updated when doing checking out of the project. </p> <p>But i also ...
<p>We use Subversion for document management at work. It works great.</p> <ul> <li>Don't worry about the disk space. Revisions are stored compressed anyway.</li> <li>Checking out a project with documentation doesn't take much more time than one without. Unless your documents are absolutely huge, this shouldn't be a pr...
<p>Subversion <strong>only</strong> stores the difference between revisions, which makes it very efficient. I'm not aware if this is true for binary files (such as Word or Excel files), however I believe it may be. If not, it may be to your advantage to use CSV files if possible instead of .XLS files and RTF files if p...
30,060
<p>I realise that the view/controller stuff will be different between Mac and IPhone apps but the model code may well be similar/the same. So whats the best way to organise a project(s) so that the model code is/can be shared?</p> <ol> <li>Copy/paste - just duplicate it and manually keep it in sync </li> <li>Have 2 x...
<p>There are a few ways to do this. The first thing you can do is is create a project that builds as a framework on Mac OS X. Since you cannot use frameworks on iPhone, you can make static library target that contains the same code files. That basically works, but the header paths will be different. If you want the hea...
<p>You could develop your application in JavaScript, CSS, and HTML. You would use the WebView and UIWebView objects on the Mac and the iPhone respectively. You can do pretty much anything you want in the WebView objects, even make calls down to Objective-C.</p> <p>The QuickConnectiPhone installer, found here <a href...
28,323
<p>I'm trying to find a good way to print leading <code>0</code>, such as <code>01001</code> for a <a href="https://en.wikipedia.org/wiki/ZIP_Code" rel="noreferrer">ZIP Code</a>. While the number would be stored as <code>1001</code>, what is a good way to do it?</p> <p>I thought of using either <code>case</code> statem...
<pre><code>printf(&quot;%05d&quot;, zipCode); </code></pre> <p>The <code>0</code> indicates what you are padding with and the <code>5</code> shows the width of the integer number.</p> <p>Example 1: If you use <code>&quot;%02d&quot;</code> (useful for dates) this would only pad zeros for numbers in the ones column. E.g....
<p>More flexible.. Here's an example printing rows of right-justified numbers with fixed widths, and space-padding.</p> <pre><code>//---- Header std::string getFmt ( int wid, long val ) { char buf[64]; sprintf ( buf, "% *ld", wid, val ); return buf; } #define FMT (getFmt(8,x).c_str()) //---- Put to use print...
18,589
<p>I have a VS 2005 C# project that uses a special Plugin folder to load extra DLLs (for use as nodes in an asset conversion process).</p> <p>I have a mixture of C# and C++ DLLs in this folder.</p> <p>The issue I have is that when Shadow Copying is enabled, the C++ DLLs refuse to load using Assembly.LoadFrom. I have ...
<p>Sounds like a trust issue. Try getting a Fusion log (see <a href="http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx" rel="nofollow noreferrer">this blog post</a>). Your C++ DLLs are unverifiable since they weren't compiled with <code>/clr:safe</code>, so they can only be loaded as full trust. Presumably wh...
<p>Assembly.Load(byte[] ...) explicitly disallows unverifiable (mixed mode) assemblies. you can check the issue on <a href="https://connect.microsoft.com/VisualStudio/feedback/details/97801/loading-mixed-assembly-with-assembly-load-byte-throw-exception-changed-behaviour" rel="nofollow noreferrer">Microsoft Connect</a>....
34,236
<p>I have a function which searches an STL container then returns the iterator when it finds the position, however I am getting some funny error messages, can tell me what I am doing wrong?</p> <p>Function:</p> <pre><code>std::vector&lt; CClass &gt;::iterator CClass::SearchFunction( const std::string&amp; strField ) ...
<p>Your search function is returning a const_iterator. You should either return the same type, i.e. <code>std::vector&lt; CClass &gt;::const_iterator</code>, or cast it to a <code>std::vector&lt; CClass &gt;::iterator</code> if you intend the caller to be able to modify the found item through the iterator.</p> <p>EDIT...
<p>Sounds like you have your const_iterators mixed up. Please post more code, specifically how you are declaring your iterator.</p>
40,498
<p>Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button look "pressed"? Imagine this button is an on/off switch. <code>ToolStripButton</code> has the Checked property, but the regular Button does not.</p>
<p>One method you can used to obtain this option is by placing a "CheckBox" object and changing its "Appearance" from "Normal" to "Button" this will give you the same functionality that I believe you are looking for.</p>
<p>I think you may need a <code>ToggleButton</code>. You can take a look at third party vendors of WinForms components such as Telerik, DevExpress, ComponentFactory, ViBlend which provide such control. They all provide toggle buttons.</p>
2,690
<p>The rich presentational capabilities of WPF and Silverlight mean developers like me will be working closely with graphic designers more often these days, as is the case in my next project. </p> <p>Does anyone out there have any tips and experience (from both points of view) on making this go more smoothly? </p> ...
<p>I have spent 4 months on a project working extremely closely with a designer and he has still not picked up the basic idea of CVS (which is not my choice of source control system). I'm talking template files, JavaScript and CSS here. He's not stupid, it's just one of these things that makes his job harder so he resi...
<p>Quite frankly you should tell the designer that images can, should and "will be put in source control mister!" :) </p> <p>It may be slightly non-conventional and you wont be able to do a merge or anything of that nature, but there will be revisions and a history, etc .. Images can also be embedded in a resource fi...
7,478
<p>I've make an application in PHP that uses DOMDocument() in PHP 5.</p> <p>The problem is that my server uses PHP 4 and DOM object is not recognized. What can I do?</p> <p>Can I download any kind of software and put it in my server and use include? Which one? </p> <p>Thanks a lot.</p>
<p>You can use the DOM XML extension in PHP4: <a href="http://de.php.net/manual/en/book.domxml.php" rel="nofollow noreferrer">http://de.php.net/manual/en/book.domxml.php</a>.</p> <p>Please note that the API is not compatible with the <a href="http://de.php.net/manual/en/book.dom.php" rel="nofollow noreferrer">PHP5 DOM...
<p>PHP 5</p> <p>Have your server admin upgrade your server.</p>
26,962