instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I would like to include a Google map in a Flash site I am building. I would like to retain as much of the zoom, print, copy/send url, direction functionality as is practically possible. Please could somebody advise the best way to do this? Thanks.</p>
<p>See <a href="http://code.google.com/apis/maps/documentation/flash/" rel="nofollow noreferrer">Google Maps API for Flash</a></p> <blockquote> <p>This API lets Flex developers embed Google Maps in Flash applications. Similar to the JavaScript version, this ActionScript API provides a number of utilities for...
<p>I have seen google maps on flash. May be you can buy some kind of component.</p>
21,455
<p>I want to make a generic class that accepts only serializable classes, can it be done with the where constraint?</p> <p>The concept I'm looking for is this:</p> <pre><code>public class MyClass&lt;T&gt; where T : //[is serializable/has the serializable attribute] </code></pre>
<p>Nope, I'm afraid not. The only things you can do with constraints are:</p> <ul> <li><code>where T : class</code> - T must be a reference type</li> <li><code>where T : struct</code> - T must be a non-nullable value type</li> <li><code>where T : SomeClass</code> - T must be SomeClass or derive from it</li> <li><code>...
<p>If you are looking for any class that is serializable, I think you are out of luck. If you are looking for objects that you have created, you could create a base class that is serializable and have every class you want to support derive from it.</p>
27,330
<p>I am having a problem setting the Authorize attribute Role value from a variable. The error message says it requires a const variable. When I create a const type variable it works fine but I am trying to load the value from the Web.Config file or anything else that will allow the end user to set this. I'm using in...
<p>You can use <code>User.InRole( "RoleName" )</code> within a controller.</p> <p><strong>EDIT: The code below will not work since GetCustomAttributes() apparently returns a copy of each attribute instead of a reference to the actual attribute. Left as answer to provide context for other answers.</strong></p> <p>As ...
<p>You could create a new Authorize class like so:</p> <pre><code>[AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = true)] public class AuthorizedGmp : AuthorizeAttribute { public AuthorizedGmp() { Roles = Config.GMPUser; } } </code></pre>
49,308
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1217088/what-does-mapname-mean-in-ruby">What does map(&amp;:name) mean in Ruby?</a> </p> </blockquote> <p>I was watching a railscast and saw this code.</p> <pre><code>[Category, Product].(&amp;:delete_all) </c...
<p>This relies upon a Ruby 1.9 extension that can be done in 1.8 by including the following:</p> <pre><code>class Symbol def to_proc proc { |obj, *args| obj.send(self, *args) } end end </code></pre> <p>I believe Rails defines this in <code>ActiveSupport</code>.</p>
<p>It's some Rails specific patching of Ruby, <a href="http://blog.hasmanythrough.com/2006/3/7/symbol-to-proc-shorthand" rel="nofollow noreferrer">symbol to proc</a>.</p>
12,455
<p>I want to iterate through a contacts properties and add those that contain the word &quot;Number&quot; to a list with the value, i tries using reflection but it doesn't work.</p> <pre><code>using System; using System.Collections; using System.Collections.Generic; using System.Reflection; using Microsoft.Office.Inter...
<p>Try using MAPI CDO.</p> <p>Here's a microsoft site that might get you started: <a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;179083" rel="nofollow noreferrer">How to use CDO to read MAPI Addresses</a></p> <p>Here's some MAPI Blogs to help as well:</p> <ul> <li><a href="http://blogs.msdn.com/ste...
<p>Of cause it doesn't work - it's a COM object. You should use the properties from CDO space.</p>
25,191
<p>I have a UserControl that consists of three TextBoxes. On a form I can have one or more or my UserControl. I want to implement my own tab behavior so if the user presses Tab in the second TextBox I should only move to the third TextBox if the the second TextBox has anything entered. If nothing is entered in the seco...
<p>As a general rule, I would say overriding the standard behavior of the TAB key would be a bad idea. Maybe you can do something like disabling the 3rd text box until a valid entry is made in the 2nd text box.</p> <p><em>Now, having said this, I've also broken this rule at the request of the customer. We made the e...
<p>I agree with DannySmurf. Messing with the tab order might give you hell later on if the requirements for the application change.</p> <p>Another thing that you could do is to implement some kind of wizard for the user to go through.</p>
3,431
<p>I'm experiencing what I believe is a circular dependency issue with my PHP application. Please let me know if this is incorrect. Here is the situation:</p> <p>Two classes, LogManager and DBSession.</p> <p>DBSession is used to interact with the database, and LogManager is used to log to files. Both are widely used ...
<p>Don't extend LogManager, let it be an aggregate type. And delay the choice of where you want to log, i.e.:</p> <pre><code>$logManager = new LogManager(); $dbSession = new DbSession($logManager); $logManager-&gt;add(new FileLog($filename) ); $logManager-&gt;add(new DBLog($dbSession) ); </code></pre> <p>Where of cou...
<p>Maybe you can apply some pattern, like the <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow noreferrer">Singleton Pattern</a> to ensure that you only have one instance of your LogManager class for example.</p>
23,697
<p>(I'm using the <a href="http://developer.berlios.de/projects/pyprocessing" rel="nofollow noreferrer">pyprocessing</a> module in this example, but replacing processing with multiprocessing should probably work if you run <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow noreferrer">python 2....
<p>Isnt that what select is for??</p> <p>Only call accept on the socket if the select indicates it will not block...</p> <p>The select has a timeout, so you can break out occasionally occasionally to check if its time to shut down....</p>
<p>Probably not ideal, but you can release the block by sending the socket some data from the signal handler or the thread that is terminating the process.</p> <p>EDIT: Another way to implement this might be to use the <strike>Connection</strike> <a href="http://docs.python.org/dev/library/multiprocessing.html#pipes-a...
46,639
<p>I've been using <a href="http://en.wikipedia.org/wiki/Apache_Subversion" rel="nofollow noreferrer">Subversion</a> for a few years and after using <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_SourceSafe" rel="nofollow noreferrer">SourceSafe</a>, I just love Subversion. Combined with <a href="http://en.wiki...
<p>Git is not better than Subversion. But is also not worse. It's different.</p> <p>The key difference is that it is decentralized. Imagine you are a developer on the road, you develop on your laptop and you want to have source control so that you can go back 3 hours.</p> <p>With Subversion, you have a Problem: The S...
<p>First, concurrent version control seems like an easy problem to solve. It's not at all. Anyway...</p> <p>SVN is quite non-intuitive. Git is even worse. [sarcastic-speculation] This might be because developers, that like hard problems like concurrent version control, don't have much interest in making a good UI. [/s...
2,330
<p><strong>Original Question</strong></p> <p>I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (<em>But the ans...
<p>I've had to work with several beginner (never wrote a line of code) programmers, and I'll be doing an after school workshop with high school students this fall. This is the closest thing I've got to documentation. It's still a work in progress, but I hope it helps.</p> <p>1) <b>FizzBuzz.</b> Start with command line...
<p>I would actually argue to pick a simpler language with fewer instructions. I personally learned on BASIC at home, as <a href="http://www.codinghorror.com/blog/archives/001104.html" rel="nofollow noreferrer">did Jeff</a>. This way, you don't have to delve into more complicated issues like object oriented programmin...
2,525
<p>I'm using Oracle 10g and I'm trying to "stack" the conditions in a CASE statement, like I would do in C++ :</p> <pre><code>case 1: case 2: // instructions break; </code></pre> <p>i.e. having the same code block executed for two different successful conditions.</p> <p>I've tried :</p> <pre><code>WHEN 1, 2...
<p>You need to use this format:</p> <pre><code>CASE WHEN v_n = 1 OR v_n = 2 THEN dbms_output.put_line('Case 1 or 2'); WHEN v_n = 3 THEN dbms_output.put_line('Case 3'); END CASE; </code></pre>
<p>It is possible to use IN just as in SQL:</p> <pre><code>BEGIN CASE WHEN EXTRACT(YEAR FROM SYSDATE) IN (2015, 2016, 2017) THEN dbms_output.put_line('Yes'); ELSE dbms_output.put_line('No'); END CASE; END; / </code></pre>
40,102
<p>I have a .Net 2.0 app that is used internally and we want to use the WebBrowser control to access some Web resources. We want to add encryption to these sites using SSL using self signed certificates.</p> <p>My question is if there is way to disable all the warnings about the SSL keys coming from an untrusted sourc...
<p>I do not believe there is a work around for this, you will always get the warning when accessing the above mentioned web resources via the WebBrowser control (or Internet Explorer for that matter) You could however distribute the <strong>root</strong> cert via Group Policy.</p>
<p>I have a work around for this elventear. It is part of a Code Project article that I am writing that illustrates various 'tricks' you can perform when dealing with security and the WebBrowser Control. I will advise here when it is available.</p>
15,185
<p>I'm using brand new PLA filament and am getting frequent clogs in my extruder.</p> <p>I've had this problem with 2 different filaments from 2 different vendors.</p> <p>It will be print just fine, then clog up. It doesn't ever seem to go more than 5 minutes before clogging. When it clogs, and I pull out the filame...
<p>The shape you get is quite easy to explain. It's the shape of the lowest energy possible in your situation. Simple but it doesn't explain the issue... or does it?</p> <p>It does. The filament cannot be put into the extruder as it becomes plugged. This leads us to some obvious explanations. You can read <a href="htt...
<p>The distance between heat block and heat sink is too big (3/4 inch, almost 2 cm). In this area your filament is some half melt state, not cooled as in heat sink part, not melted as in heat block part. You should make as small as possible, less then 0.5 cm.</p> <p>Great source of information about hot ends is video ...
274
<p>Are there any extruders and printers that do a good job with ceramic clay?</p> <p>I assume the clay has to be fine grained and with enough water added to be able to be pushed out through the extruder's nozzle. I also assume the print speed would have to be arther low for the already printed layers to gain stability...
<p>What you are looking for is the Frostruder style extruders.</p> <p>Here is a link to a <a href="http://www.thingiverse.com/thing:1143" rel="nofollow noreferrer">thingiverse file for it</a>.</p> <p>You honestly cannot expect fantastic results but it will get the job done! There are many other types. Quality will depe...
<p>I cant speak for the quality or type of clay, but there are several designs out there that print in clay. Here is the first one that popped up on my google search.</p> <p><a href="http://www.wasproject.it/w/en/wasp-launches-the-new-professional-clay-extruder/" rel="nofollow noreferrer">http://www.wasproject.it/w/en...
451
<p>I understand the main function of the lock key word from MSDN</p> <blockquote> <p>lock Statement (C# Reference)</p> <p>The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock.</p> </...
<blockquote> <p>When should the lock be used?</p> </blockquote> <p>A lock should be used to protect shared resources in multithreaded code. Not for anything else.</p> <blockquote> <p>But is it necessary when the application does not spin off any other threads?</p> </blockquote> <p>Absolutely not. It's just a t...
<p>There is no point in having locks in the app if there is only one thread and yes, it is a performance hit although it does take a fair number of calls for that hit to stack up into something significant. </p>
8,422
<p>I read somewhere once that the modulus operator is inefficient on small embedded devices like 8 bit micro-controllers that do not have integer division instruction. Perhaps someone can confirm this but I thought the difference is 5-10 time slower than with an integer division operation.</p> <p>Is there another way ...
<p>Ah, the joys of bitwise arithmetic. A side effect of many division routines is the modulus - so in few cases should division actually be faster than modulus. I'm interested to see the source you got this information from. Processors with multipliers have interesting division routines using the multiplier, but you ...
<p>The print statement will take orders of magnitude longer than even the slowest implementation of the modulus operator. So basically the comment "slow on some systems" should be "slow on all systems".</p> <p>Also, the two code snippets provided don't do the same thing. In the second one, the line</p> <pre>if(fizzco...
7,041
<p>What is a <code>StackOverflowError</code>, what causes it, and how should I deal with them?</p>
<p>Parameters and local variables are allocated on the <strong>stack</strong> (with reference types, the object lives on the <strong>heap</strong> and a variable in the stack references that object on the heap). The stack typically lives at the <strong>upper</strong> end of your address space and as it is used up it he...
<p>Here's an example</p> <pre><code>public static void main(String[] args) { System.out.println(add5(1)); } public static int add5(int a) { return add5(a) + 5; } </code></pre> <p>A StackOverflowError basically is when you try to do something, that most likely calls itself, and goes on for infinity (or until ...
26,396
<p>In my application I have a DataGridView control that displays data for the selected object. When I select a different object (in a combobox above), I need to update the grid. Unfortunately different objects have completely different data, even different columns, so I need to clear all the existing data and columns, ...
<p>Rather than adding the rows of the data grid one at a time, use the <code>DataGridView.Rows.AddRange</code> method to add all the rows at once. That should only update the display once. There's also a <code>DataGridView.Columns.AddRange</code> to do the same for the columns.</p>
<p>You may also try this, its work.</p> <pre><code>public static void DoubleBuffered(Control formControl, bool setting) { Type conType = formControl.GetType(); PropertyInfo pi = conType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic); pi.SetValue(formControl, setting, null); }...
8,943
<hr /> <p><strong> The <a href="http://docs.php.net/manual/en/class.httprequestpool.php" rel="noreferrer">HttpRequestPool</a> class provides a solution. Many thanks to those who pointed this out.</p> <p>A brief tutorial can be found at: <a href="http://www.phptutorial.info/?HttpRequestPool-construct" rel="noreferrer"...
<p>I'm pretty sure <a href="http://docs.php.net/manual/en/class.httprequestpool.php" rel="noreferrer">HttpRequestPool</a> is what you're looking for.</p> <p>To elaborate a little, you can use forking to achieve what you're looking for, but that seems unnecessarily complex and not very useful in a HTML context. While I...
<p>You could use pcntl_fork() to create a separate process for each request, then wait for them to end:</p> <p><a href="http://www.php.net/manual/en/function.pcntl-fork.php" rel="nofollow noreferrer">http://www.php.net/manual/en/function.pcntl-fork.php</a></p> <p>Is there any reason you don't want to use cURL? The c...
20,392
<p>When writing code do you consciously program defensively to ensure high program quality and to avoid the possibility of your code being exploited maliciously, e.g. through buffer overflow exploits or code injection ?</p> <p>What's the "minimum" level of quality you'll always apply to your code ?</p>
<p>In my line of work, our code has to be top quality.<br> So, we focus on two main things:</p> <ol> <li>Testing</li> <li>Code reviews</li> </ol> <p>Those bring home the money.</p>
<p>I always work to prevent things like injection attacks. However, when you work on an internal intranet site, most of the security features feel like wasted effort. I still do them, maybe just not as well.</p>
2,854
<p>I've been googling for a while now, and can't figure out how to create an event in the calendar on a newer Palm OS device. Any ideas on how to do this? I'm guessing that I'll be creating a record in the calendar database, but the format of the data in that record, and which database to put it in, I don't know.</p>...
<p>In Palm's later devices, they moved to an extended format for the PIM applications like Contacts and Calendar. This was done to allow better mapping between the device's databases and those used by Microsoft Outlook, but it meant that the format changed from the traditional format in the original PIMs.</p> <p>Palm...
<p>Ok, literally ten seconds after I posted this question, I got an email from the palm developer network that led me right where I needed to go. Frustrating. It appears that you'll need the PIM SDK, which is available through the Palm Developer network <a href="https://dts.pdn.palm.com/cgi-bin/palmdev.cfg/php/enduse...
10,402
<p>A bunch of CSS files were pulled in and now I'm trying to clean things up a bit.</p> <p>How can I efficiently identify unused CSS definitions in a whole project?</p>
<p><a href="https://developers.google.com/chrome-developer-tools/" rel="noreferrer">Chrome Developer Tools</a> has an <strong>Audits</strong> tab which can show unused CSS selectors. </p> <p>Run an audit, then, under <strong>Web Page Performance</strong> see <strong>Remove unused CSS rules</strong></p> <p><img src="h...
<p>Google Chrome Developer Tools has (a currently experimental) feature called <a href="https://css-tricks.com/new-in-chrome-css-overview/" rel="nofollow noreferrer">CSS Overview</a> which will allow you to find unused CSS rules.</p> <p>To enable it follow these steps:</p> <ol> <li>Open up DevTools (Command+Option+I on...
16,425
<p>I have a script that needs to run after tomcat has finished starting up and is ready to start deploying applications. I'm using <code>$TOMCAT_HOME/bin/startup.sh</code> which returns immediately. How can I wait until tomcat has finished starting up?</p>
<p>There are probably several ways to do this. The trick we use is:</p> <pre><code>#!/bin/bash until [ "`curl --silent --show-error --connect-timeout 1 -I http://localhost:8080 | grep 'Coyote'`" != "" ]; do echo --- sleeping for 10 seconds sleep 10 done echo Tomcat is ready! </code></pre> <p>Hope this helps!</...
<p>There isn't an easy method. As far as startup.sh and catalina.sh are concerned, tomcat is running when they finish. Although, internally, tomcat is still initializing and starting contexts.</p> <p>It would help to know if you were trying to find out if your context finished loading or if you are just wanting a ge...
49,255
<p>Long winded title, short question:</p> <p>If one wants to develop for Windows but not have to rely on any external dependency (no runtime, thus ruling out .net), what supported, alive and fully functioning* alternatives are there?</p> <p>Visual Basic 6 is dead, Visual C++ is obvious and Delphi seems to be the prim...
<p>Have a look at this -</p> <p><a href="http://www.codegear.com/products/delphi" rel="nofollow noreferrer">http://www.codegear.com/products/delphi</a></p> <p>Glynn</p>
<p>Have a look at this page:</p> <p><a href="http://dada.perl.it/shootout/" rel="nofollow noreferrer">http://dada.perl.it/shootout/</a></p> <p>It's a port of the computer language shootout to compile on the Win32 platform. In the chart of languages used, he lists which ones compile to native code (the compiler is lis...
25,746
<p>I'd like to include custom .Net controls and .Net forms within MS Access. It's possible but I was wondering if there was any new good articles on that subject.<br> Over time I've found a few related to the subject the but always found the process a bit cumbersome (see references below).</p> <p>One of the issue is d...
<p>Just a word of warning - I used to work on an access based system that had evolved way beyond what access was designed for and it was a real chore.</p> <p>I know nothing of your project, but it might be an idea to consider a move to a more flexible/scalable system to avoid problems down the line.</p>
<p>&quot;Anything you can do in Access can be done better in a .Net application using ADO.Net&quot;</p> <p>Lets try this: Anything you can do in Access can be done better using COBOL.</p> <p>Or this: Anything you can do in Access can be done better PAPPER, PEN AND A LITTLE CALCULATOR.</p> <p>I know that Access is limit...
40,283
<p>I have two Slackware Linux systems on which the POSIX semaphore <code>sem_open()</code> call fails with errno set to 38. Sample code to reproduce below (the code works fine on CentOS / RedHat).</p> <p>Are there any kernel or system configuration options that could cause this? Other suggestions?</p> <p>Systems with...
<p>Is /dev/shm mounted? Older versions of slackware may not have mounted this filesystem at boot. From /etc/fstab:</p> <pre><code>tmpfs /dev/shm tmpfs defaults 0 0 </code></pre> <p>Edit: That is probably not the problem after all. I think you may just need to upgrade your kernel or maybe even librt.</p> <p>...
<p>Another way to share a semaphore across processes is to use SystemV semaphores. </p> <p>These do work even where shared POSIX semaphores don't (at least on the systems described above.). </p> <p>See <a href="http://www.linuxdevcenter.com/pub/a/linux/2007/05/24/semaphores-in-linux.html" rel="nofollow noreferrer">ht...
33,945
<p>Typical way of creating a <a href="http://en.wikipedia.org/wiki/Comma-separated_values" rel="noreferrer">CSV</a> string (pseudocode):</p> <ol> <li>Create a CSV container object (like a StringBuilder in C#).</li> <li>Loop through the strings you want to add appending a comma after each one.</li> <li>After the loop, ...
<p>You could use <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query#LINQ_to_Objects" rel="noreferrer">LINQ to Objects</a>:</p> <pre><code>string [] strings = contactList.Select(c =&gt; c.Name).ToArray(); string csv = string.Join(",", strings); </code></pre> <p>Obviously that could all be done in one line...
<p>How about tracking whether you are on the first item, and only add a comma <em>before</em> the item if it is not the first one.</p> <pre><code>public string ReturnAsCSV(ContactList contactList) { StringBuilder sb = new StringBuilder(); bool isFirst = true; foreach (Contact c in contactList) { i...
2,644
<p>I try to keep it brief and concise. I have to write a program that takes queries in SQL form and searches an XML. Right now I am trying to disassemble a string into logical pieces so I can work with them. I have a string as input and want to get a MatchCollection as output.</p> <p>Please not that the test string be...
<p>I think you need to explicitly match the line terminators, as well as handle spaces better as others have suggested. Assuming the user can choose between \r and \n, try</p> <pre><code>@"(?&lt;select&gt;\Aselect .+)[\n\r]" + @"(?&lt;from&gt;\s*from .+)[\n\r]" + @"(?&lt;where&gt;\s*where .+)[\n\r]" + @"(?&lt;groupBy...
<p>There may be a problem with the newline matching: is it LF (Unix standard), CR (MacOS), or CR LF (Windows)? If you don't know, perhaps you should match it with: <code>[\n\r]+</code></p> <p><em>edit</em>: You included some whitespace in your test string, surrounding the newlines, that you don't account for in your ...
37,369
<p>I want to query a number of different databases mainly Oracle and Informix. Can anyone suggest me some tool using which I can do this easily?</p>
<p>Try WinSQL lite at <a href="http://www.indus-soft.com/SynametricsWebApp/WinSQL.jsp" rel="nofollow noreferrer">http://www.indus-soft.com/SynametricsWebApp/WinSQL.jsp</a>. It is absolutely free and does not expire. It is only one file and does not come with any bulky DLLs. If you don't like it, simply delete the file ...
<p>The best alround one is <a href="http://www.toadsoft.com/" rel="nofollow noreferrer">TOAD</a></p>
5,416
<p>If I make a JFrame like this</p> <pre><code>public static void main(String[] args) { new JFrame().setVisible(true); } </code></pre> <p>then after closing the window the appication doesn't stop (I need to kill it).</p> <p>What is the proper way of showing application's main windows ?</p> <p>I'd also like to...
<p>You should call the <code>setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);</code> in your JFrame.</p> <p>Example code:</p> <pre><code>public static void main(String[] args) { Runnable guiCreator = new Runnable() { public void run() { JFrame fenster = new JFrame("Hallo Welt mit Swing"); ...
<p>You can set a <em>window listener</em> to the frame so the program terminates after you close it.</p> <pre class="lang-java prettyprint-override"><code>frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } </code></pre>
30,555
<p>I have a few places in the code where I need to use the TimeZone. I can get the timezone name using <a href="http://search.cpan.org/dist/DateTime" rel="nofollow noreferrer">DateTime::TimeZone</a>. Is it reasonable to put the timezone name in a constant? Or should it be in a variable?</p>
<p>If the value can change, use a variable, of it is guaranteed to stay the same, use a constant. </p> <p>For a timezone, the chance it will change is not big, but it is also not 0. The user can change the timezone and it would be nice if the program behaves accordingly.</p>
<p>I vote for variable. You could end up with different users in different timezones working with your application, even if you doubt that could ever happen. It happened to me a couple of years ago.</p>
27,802
<p>In JUnit 3 I simply called</p> <pre><code>suite.addTestSuite( MyTest.class ) </code></pre> <p>However if MyTest is a JUnit 4 test which does not extend TestCase this doesn't work. What should I do instead to create a suite of tests?</p>
<p>Assuming that you are talking about Windows, there are essentially three ways to do this. </p> <p>The first is to open the audio device's main output as a recording source. This is only possible when the driver supports it, although most do these days. Common names for the virtual device are "What You Hear" or "Wav...
<p>If you were using OSX, <a href="http://rogueamoeba.com/audiohijackpro/" rel="nofollow noreferrer">Audio Hijack Pro from Rogue Amoeba</a> probably is the easiest way to go. </p> <p>Anyway, why not just looping your audio back into your line in and recording that? This is a <em>very</em> simple solution. Just plug a ...
25,989
<p>I have an array <code>NSMutableArray</code> with happy objects. These objects viciously turn on (leak) me whenever I try to clear the array of all the objects and repopulate it.</p> <p>It's allocated in the init function like so</p> <pre><code>self.list = [NSMutableArray array]; </code></pre> <p>The different met...
<p>How did you create the objects that are leaking? If you did something like this:</p> <pre><code>- (void)addObjectsToArray { [list addObject:[[MyClass alloc] init]; OtherClass *anotherObject = [[OtherClass alloc] init]; [list addObject:anotherObject]; } </code></pre> <p>then you will leak two objects ...
<p>I'd say I don't really have enough Information here to give you a great answer. Are you saying that the <code>NSMutableArray</code> is still allocated, but empty and doesn't have any objects in it but that the objects once previously in the array are still allocated even though they should be dealloc'd at that point...
21,670
<p>A friend of mine has embedded a google earth plugin into a C# user control. All works fine but when you close the window we recieve and "Unspecified Error" with the option to continue running the scripts or not. From our tracking it down it appears this is being cause by a script that google is dropping onto the pag...
<p>Here is an example, by me, of c#/Google Earth API integration that covers the problem you are having (see the comments) <a href="http://fraserchapman.blogspot.com/2008/08/google-earth-plug-in-and-c.html" rel="nofollow noreferrer">http://fraserchapman.blogspot.com/2008/08/google-earth-plug-in-and-c.html</a></p> <p>A...
<p>We have now tried this in both IE and FF. Works fine. Any ideas why the error only comes up on close? can we somehow disable it? here is our code.</p> <pre><code>&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt; &lt;html&gt; &lt;head&gt; &lt;script src="http://www.google.com/jsapi?key=...
22,115
<p>I have designed a bread mark and printed it on the Prusa i3 MK3.</p> <p><a href="https://i.stack.imgur.com/qs5PP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qs5PP.png" alt="Bread mark"></a></p> <p>I wanted it to have as sharp edges as possible, so I used a triangle:</p> <p><a href="https://...
<p>This is dependent on the slicer and the nozzle diameter. Typically, you cannot print a wall smaller than twice the nozzle diameter because walls need an inner and outer line. Therefore, your slicer will make some cutoff and won't print walls below a certain threshold, in order to try to faithfully replicate your mod...
<p>The absolute minimum a slicer will allow existing in a g-code is one extrusion diameter, which is typically roundabout a nozzle diameter. So for a standard 0.4 mm nozzle, the model will be cut in a way that keeps at <em>least</em> 0.4 mm thick walls, or, if the slicer is extra careful, double that, as the model dema...
1,101
<p>I am trying to figure out a crash in my application. WinDbg tells me the following: (using dashes in place of underscores)</p> <p><br><b>LAST-CONTROL-TRANSFER: from 005f5c7e to 6e697474 <br>DEFAULT-BUCKET-ID: BAD_IP <br>BUGCHECK-STR: ACCESS-VIOLATION</b></p> <p>It is obvious to me that 6e697474 is NOT a valid a...
<p>Bad-IP is Bad Instruction Pointer. From the description of your problem, I would assume it is a <b>stack corruption</b> instead of a stack overflow.</p>
<p>I can think of the following things that could cause a jump to invalid address, in decreasing order of likelyhood: </p> <ul> <li>calling a member function on a deallocated object. (as you suspect)</li> <li>calling a member function of a corrupted object.</li> <li>calling a member function of an object with a corru...
15,868
<p>One of the <a href="http://www.sqlite.org/whentouse.html" rel="noreferrer">appropriate uses</a> for <a href="http://www.sqlite.org" rel="noreferrer">sqlite3</a> is "in-memory databases". This sounds like a really useful tool for my C++ applications. Does anyone have an example of how this is done in C or C++? I'm...
<p>It's actually quite easy. Just specify ':memory:' as the database filename when opening a database using the C/C++ API. It's a special constant that the engine will recognize. The same actually works for other languages such as Python or Ruby, since they typically just wrap the C/C++ API. See <a href="http://sqlite....
<p>Just open the file :memory: and that should do it (at least it does in PHP).</p> <p>You mention that you want to read in several flat files and do joins on them. If it's possible to store the flat files as SQLite databases, you can work directly with both by attaching one to the other:</p> <pre><code>ATTACH foo.db...
39,117
<p>In a Django form, how do I make a field read-only (or disabled)?</p> <p>When the form is being used to create a new entry, all fields should be enabled - but when the record is in update mode some fields need to be read-only.</p> <p>For example, when creating a new <code>Item</code> model, all fields must be edita...
<p>As pointed out in <a href="https://stackoverflow.com/questions/324477/in-a-django-form-how-do-i-make-a-field-readonly-or-disabled-so-that-it-cannot/34538169#34538169">this answer</a>, Django 1.9 added the <a href="https://docs.djangoproject.com/en/stable/ref/forms/fields/#disabled" rel="noreferrer">Field.disabled</a...
<p>If you are using Django admin, here is the simplest solution.</p> <pre><code>class ReadonlyFieldsMixin(object): def get_readonly_fields(self, request, obj=None): if obj: return super(ReadonlyFieldsMixin, self).get_readonly_fields(request, obj) else: return tuple() class ...
42,018
<p>I'm trying to design an application to hold academic reference information. The problem is that each different type of reference (eg. journal articles, books, newspaper articles etc) requires different information. For example a journal reference requires both a journal title and an article title, and also a page n...
<p>I'd go for having a single table for all references, but additional tables like BookReferences and so on for metadata not applicable for all reference types.</p> <p>Searching and querying would not be more difficult - after all you could just create a view which aggregates all information as in the single-table sol...
<p>How about both? <strong>Have your cake and eat it too!</strong></p> <p>There's another option somewhere between the "one big table" and the "fully normalized" DB that really combines the best of both worlds: You can use something called <a href="http://en.wikipedia.org/wiki/Materialized_view" rel="nofollow noreferr...
24,445
<p>Can anyone provide some pseudo code for a roulette selection function? How would I implement this: I don't really understand how to read this math notation.I want General algorithm to this.</p>
<p>The other answers seem to be assuming that you are trying to implement a roulette game. I think that you are asking about roulette wheel selection in evolutionary algorithms.</p> <p><a href="https://github.com/dwdyer/watchmaker/blob/master/framework/src/java/main/org/uncommons/watchmaker/framework/selection/Roulet...
<p><strong>Random Number Generator pseudo code</strong></p> <ul> <li>add one to a sequential counter</li> <li>get the current value of the sequential counter</li> <li>add the counter value by the computer tick count <em>or some other small interval timer value</em></li> <li>optionally add addition numbers, like a numb...
38,180
<p>I need to edit <code>/etc/sudoers</code> from a script to add/remove stuff from white lists.</p> <p>Assuming I have a command that would work on a normal file, how could I apply it to <code>/etc/sudoers</code>?</p> <p>Can I copy and modify it, then have <code>visudo</code> replace the original with the modified co...
<p>Old thread, but what about:</p> <pre><code>echo 'foobar ALL=(ALL:ALL) ALL' | sudo EDITOR='tee -a' visudo </code></pre>
<p>This worked for me based off what others posted here. When i used other peoples script it would open visudo for me but would not make the edit. This made the edit i needed to allow all users, including standard users, to install java 7u17 for safari/firefox. </p> <pre><code>#!/usr/bin/env bash rm /etc/sudoers.new c...
41,942
<p>I have a report that uses a TChart that I am maintaining. One of the TLineSeries that gets added automatically gets assigned the color clWhite, which is too close to the background (clBtnFace). </p> <p>If I change it, then the next series that gets added takes clWhite. So short of going back and changing it afte...
<p>OK not one to give up easily, I did some more searching. There is a unit variable called <strong>ColorPalette</strong> of type <em>TColorArray</em> in the <em>TeeProcs</em> unit. If I find and replace white with a different color that fixes it. There may be an instance copy of it. I'll keep looking since that w...
<p>You can use the series methods ClearPalette then AddPalette to create your custom palette.</p>
24,849
<p>I have WPF ListBox which is bound to a ObservableCollection, when the collection changes, all items update their position.</p> <p>The new position is stored in the collection but the UI does not update. So I added the following:</p> <pre><code> void scenarioItems_CollectionChanged(object sender, System.Collecti...
<p>I have a Listbox bound to an object property which is of type <code>List&lt;MyCustomType&gt;()</code> and I verified that the following code updates the listbox when the List is updated.</p> <pre><code>void On_MyObjProperty_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { MyList...
<p>If you have an ObservableList of objects, and you're changing properties inside those objects, the notification doesn't apply since the collection is not changing directly. I have been forcing notification after changing my object properties by using Insert() to re-add my changed object to the collection, then Remo...
31,537
<p>I have a problem. I am coding using VS2008. I am calling webservices from my JavaScript Page. An example</p> <pre><code>Services.ChangeDropDownLists.GetNowPlayingMoviesByLocationSVC( blah, OnSuccessMoviesByRegion, OnError, OnTimeOut ); </code></pre> <p>after execution, it goes to the function <cod...
<p>I would write it in <a href="http://www.antlr.org/" rel="noreferrer">ANTLR</a>. Write the grammar, let ANTLR generate a C# parser. You can ANTLR ask for a parse tree, and possibly the interpreter can already operate on the parse tree. Perhaps you'll have to convert the parse tree to some more abstract internal repre...
<blockquote> <p>The programming language that this interpreter will use should be simple, since it is targeting non- software developers.</p> </blockquote> <p>I'm going to chime in on this part of your question. A simple language is not what you really want to hand to non-software developers. Stripped down languag...
32,024
<p>I have a singleton that uses the "static readonly T Instance = new T();" pattern. However, I ran into a case where T is disposable, and actually needs to be disposed for unit tests. How can I modify this pattern to support a disposable singleton?</p> <p>The interface I would like is something like:</p> <pre><code>...
<p>Mark <code>Release</code> as <code>internal</code> and use the <code>InternalsVisibleTo</code> attribute to expose it only to your unit testing assembly. You can either do that, or if you're wary someone in your own assembly will call it, you can mark it as <code>private</code> and access it using reflection.</p> <...
<p>You could use a nested lazy singleton (See <a href="http://www.yoda.arachsys.com/csharp/singleton.html" rel="nofollow noreferrer">here</a>) with some simple modifications:</p> <pre><code>public sealed class Singleton : IDisposable { Singleton() { } public static Singleton Instance { get...
27,900
<p>I populated a datagridview from a datatable. How do I read from the datagridview when the application is running?</p>
<p>how did you populate it? is the DataSource something useful like a BindlingList? If it is then something like:</p> <pre><code>BindingSource bindingSource = this.dataGridView1.DataSource as BindingSource; //substitute your business object type for T T entity = bindingSource.Current as T; </code></pre> <p>would ge...
<pre><code>namespace WindowsFormsApplication2 { public partial class Form1 : Form { public static DataTable objDataTable = new DataTable("UpdateAddress"); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) ...
13,470
<p>I have uriscan installed on my Win2003 server and it is blocking an older ColdFusion script. The log entry has the following--</p> <p>2008-09-19 00:16:57 66.82.162.13 1416208729 GET /Admin/Uploads/Mountain/Wolf%2520Creek%2520gazeebo.jpg Rejected URL+is+double+escaped URL - -</p> <p>How do I get uriscan to allow s...
<p>To quote another post on the subject,</p> <blockquote> <p>some aspect of your process for submitting URIs is doing some bad encoding.</p> <p><a href="http://www.usenet-forums.com/archive/index.php/t-39111.html" rel="nofollow noreferrer">http://www.usenet-forums.com/archive/index.php/t-39111.html</a></p> </blockquote...
<blockquote> <p>How do I get uriscan to allow submissions like this without turning off the double-escaped url feature?</p> </blockquote> <p>How do you get it to allow double-escaped URLs without turning off the double-escaped url feature? I think there's something wrong with what you're trying to do. My quest...
12,994
<p>I have a table called logs which has a datetime field. I want to select the date and count of rows based on a particular date format. </p> <p>How do I do this using SQLAlchemy?</p>
<p>I don't know of a generic SQLAlchemy answer. Most databases support some form of date formatting, typically via functions. SQLAlchemy supports calling functions via sqlalchemy.sql.func. So for example, using SQLAlchemy over a Postgres back end, and a table my_table(foo varchar(30), when timestamp) I might do so...
<p>I don't know SQLAlchemy, so I could be off-target. However, I think that all you need is:</p> <pre><code>SELECT date_formatter(datetime_field, "format-specification") AS dt_field, COUNT(*) FROM logs GROUP BY date_formatter(datetime_field, "format-specification") ORDER BY 1; </code></pre> <p>OK, maybe ...
26,631
<pre><code>class MyContainedClass { }; class MyClass { public: MyContainedClass * getElement() { // ... std::list&lt;MyContainedClass&gt;::iterator it = ... // retrieve somehow return &amp;(*it); } // other methods private: std::list&lt;MyContainedClass&gt; m_contained; }; </code></pre> <p>Though ...
<p>I don't see the use of encapsulating this, but that may be just me. In any case, returning a reference instead of a pointer makes a lot more sense to me.</p>
<p>I think the bigger problem is that you're hiding the type of collection so even if you use a collection that doesn't move elements you may change your mind in the future. Externally that's not visible so I'd say it's not a good idea to do this.</p>
13,374
<p>Is there any way in SQL Server to get the results starting at a given offset? For example, in another type of SQL database, it's possible to do:</p> <pre><code>SELECT * FROM MyTable OFFSET 50 LIMIT 25 </code></pre> <p>to get results 51-75. This construct does not appear to exist in SQL Server. </p> <p>How can I ...
<p>I would avoid using <code>SELECT *</code>. Specify columns you actually want even though it may be all of them.</p> <p><strong>SQL Server 2005+</strong></p> <pre><code>SELECT col1, col2 FROM ( SELECT col1, col2, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum FROM MyTable ) AS MyDerivedTable WHERE MyDerivedTabl...
<p>I've been searching for this answer for a while now (for generic queries) and found out another way of doing it on SQL Server 2000+ using ROWCOUNT and cursors and without TOP or any temporary table.</p> <p>Using the <code>SET ROWCOUNT [OFFSET+LIMIT]</code> you can limit the results, and with cursors, go directly to...
22,784
<p>I am using the code below to display all the files from a directory in a drop down menu. Does anyone know how to make this alphabetical? I presume it has something to do with the sort function, I just can't figure out how!</p> <pre><code>&lt;?php $dirname = "images/"; $images = scandir($dirname); $dh = opendir($dir...
<p>Why are you reading all the filenames using scandir() and then looping through them with the readdir() method? You could just do this:</p> <pre><code>&lt;?php $dirname = "images/"; $images = scandir($dirname); // This is how you sort an array, see http://php.net/sort sort($images); // There's no need to use a di...
<p>As <a href="https://stackoverflow.com/users/2725/william-macdonald">William Macdonald</a> pointed out <a href="https://stackoverflow.com/questions/260387/ordering-a-list-of-files-in-a-folder-using-php#260451">here</a> <a href="http://de3.php.net/scandir" rel="nofollow noreferrer">scandir()</a> will in fact sort the ...
32,544
<p>I've worked on many projects where I've been given code by others to update. More often than not I compile it and get about 1,000+ compiler warnings. When I see compiler warnings they make me feel dirty, so my first task is to clean up the code and remove them all. Typically I find about a dozen problems like uninit...
<p>I would clean up any warning. Even the ones that you know are harmless (if such a thing exists) will give a bad impression of you to whoever will compile the code.</p> <p>It one of the "smelly" signs I would look for if I had to work on someone else code.</p> <p>If not real errors or potential future issues, it w...
<p>I dislike warnings. I remove them as much as possible.<br> Sometimes, when under pressure to finish the job, i leave some of them. I rarely leave them though. I feel like you, dirty if there are any left.</p>
22,223
<p>I've been unable to build <a href="http://www.perforce.com/perforce/loadsupp.html#api" rel="nofollow noreferrer">P4Python</a> for an Intel Mac OS X 10.5.5.</p> <p>These are my steps:</p> <ol> <li>I downloaded p4python.tgz (from <a href="http://filehost.perforce.com/perforce/r07.3/tools/" rel="nofollow noreferrer">...
<p>The newer version 2008.1 will build with Python 2.4.</p> <p>I had posted the minor changes required to do that on my P4Python page, but they were rolled in to the official version.</p> <p>Robert</p>
<p>Very outdated, but maybe you can use <a href="http://public.perforce.com:8080/@md=d&amp;cd=//guest/miki_tebeka/p4py/&amp;c=5Fm@//guest/miki_tebeka/p4py/main/?ac=83" rel="nofollow noreferrer">http://public.perforce.com:8080/@md=d&amp;cd=//guest/miki_tebeka/p4py/&amp;c=5Fm@//guest/miki_tebeka/p4py/main/?ac=83</a> for ...
20,319
<p>In SQL Server would a <code>varbinary(16)</code> be the most efficient way of storing an <strong>MD5 hash</strong>? Won't be doing anything with it except returning it in a <strong>linq</strong> query.</p>
<p>Based on the <a href="http://msdn.microsoft.com/en-us/library/ms188362.aspx" rel="noreferrer">documentation on MSDN</a> and my experience, binary is better, since the md5 hash does not vary in size.</p> <p>The size for a binary data type is n bytes, so the size of the data. The size of a varbinary data type is n b...
<p>Null values change things: </p> <p>A null varbinary(16) is 2 bytes. <br /> A null binary(16) is 16 bytes. <br /> 16 bytes stored in varbinary(16) takes 18 bytes. <br /> 16 bytes in binary(16) takes 16 bytes. <br /></p> <p><a href="https://stackoverflow.com/a/3731195">https://stackoverflow.com/a/3731195</a></p>
7,156
<p>Is there a way to delete a folder, lets call it FolderX from an SVN trunk recursively? A quick search on google only tells me how to recursively delete all .svn folders and this is not what I want to do</p>
<p>Try something like the following on a posix system:</p> <pre><code>find ./ -name "FolderX" | xargs svn delete --force </code></pre> <p>This will find all matching files/folders starting in the current directory and perform the action on them i.e. svn delete. I'm not sure how to do this in windows though without cy...
<p>It's worked well for me</p> <pre><code>find directory_to_delete/ -type d -name '*.svn' | xargs rm -rf </code></pre>
33,106
<p>Being new to Objective-C (but a long term C/++) programmer I'm looking for advice/recommendations on naming conventions for variables.</p> <p>My personal preference would be to utilize a prefix for instance variables both for clarity within functions and to prevent shadowing of function parameters. However I'm a fa...
<p>Most Cocoa projects use underbar as a non-<code>IBOutlet</code> instance variable prefix, and use no prefix for <code>IBOutlet</code> instance variables.</p> <p>The reason I don't use underbars for <code>IBOutlet</code> instance variables is that when a nib file is loaded, if you have a setter method for a connecte...
<p>I don't like using underscores as prefixes for any identifiers, because C and C++ both reserve certain underscore prefixes for use by the implementation.</p> <p>I think using "self.variable" is ugly.</p> <p>In general, I use unadorned identifiers (that is, no prefixes nor suffixes) for instance variables. If your...
3,155
<p>I have developed a high speed transactional server for transfering data over the internet so I do not need to rely upon a database implementation like MySQL to provide this. That opens up the question of which SQL version to use?</p> <p>I really like SQLite, but I am not convinced it is industrial strength yet What...
<p>SQLite is used in more applications than any other DB. (Citation required).</p> <p>There are some issues with MySQL, like that it doesn't respect foreign integrity constraints.</p> <p>I'm currently a fan of PostgreSQL, which is also freely available (and, I think if you read the licensing of MySQL, actually turns...
<p>Sorry to be pedantic, but the title should really be "Which RDBMS?" - the way it's phrased makes about as much sense as "Which Java?" or "<a href="http://thedailywtf.com/Articles/Which-Internet.aspx" rel="nofollow noreferrer">Which Internet?</a>"...</p>
3,993
<p>Using c#, VS2005, and .NET 2.0. (XP 32 bit) This is a Winforms app that gets called by a VBA addin (.xla) via Interop libraries. This app has been around for a while and works fine when the assembly is compiled and executed anywhere other than my dev machine. On dev it crashes hard (in debugger and just running the...
<p>I've had problems in this scenario with Office 2003 in the past. Some things that have helped:</p> <ul> <li><p>Installing Office 2003 Service Pack 2 stopped some crashes that happened when closing Excel.</p></li> <li><p>Installing Office 2003 Service Pack 3 fixes a bug with using XP styles in a VSTO2005 applicatio...
<p>Is your dev machine Win64? I've had problems with win64 builds of apps that go away if you set the build platform to x86.</p>
12,909
<p>I know SQL Injection is one... what are the others...</p>
<p>OWASP.org keeps a list. Start with the <a href="http://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project" rel="nofollow noreferrer">OWASP top ten</a>.</p>
<p>Sending plain text passwords without first encrypting them is never a good idea.</p>
32,798
<p>The documentation of the Python <a href="http://www.python.org/doc/2.5.2/lib/module-readline.html" rel="noreferrer"><code>readline</code></a> module says "Availability: Unix". However, it doesn't appear to be available on OS X, although other modules marked as Unix are available. Here is what I'm using:</p> <pre> $...
<p>Have you tried to install the <code>py-readline</code> (or <code>py25-readline</code> for Python 2.5) port?</p> <p>Also, in the snippet above, you are NOT using the MacPort python, but rather the Apple Python.</p> <p>The MacPort version should be located in the <code>/opt/local</code> directory structure. You shou...
<p>It's not shipped in OS X because of licensing issues (restrictions brought to you by the GPL).</p> <p>Macports python should be fine if you have the readline package installed.</p>
42,404
<p>This question may sound fairly elementary, but this is a debate I had with another developer I work with.</p> <p>I was taking care to stack allocate things where I could, instead of heap allocating them. He was talking to me and watching over my shoulder and commented that it wasn't necessary because they are the s...
<p>Stack allocation is much faster since all it really does is move the stack pointer. Using memory pools, you can get comparable performance out of heap allocation, but that comes with a slight added complexity and its own headaches. </p> <p>Also, stack vs. heap is not only a performance consideration; it also tells...
<p>I'd like to say actually code generate by GCC (I remember VS also) <strong>doesn't have overhead to do stack allocation</strong>.</p> <p>Say for following function:</p> <pre><code> int f(int i) { if (i &gt; 0) { int array[1000]; } } </code></pre> <p>Following is the code gen...
19,464
<p>What tools and techniques do you use to find dead code in .NET?</p> <p>In the past, I've decorated methods with the Obsolete attribute (passing true so the compiler will issue an error, as described in <a href="http://msdn.microsoft.com/en-us/library/aa664623.aspx" rel="noreferrer">MSDN</a>).</p> <p>I'd be interes...
<p>Why do you need other answers? FxCop and Resharper do the trick, especially seeing as FxCop is now integrated into VS through "Code Analysis".</p>
<p>it appears gray in ReSharper if it's dead code (at least within the solution only)...like uncalled methods or classes or unused properties and variables</p>
19,665
<p>Is there a way when creating web services to specify the types to use? Specifically, I want to be able to use the same type on both the client and server to reduce duplication of code.</p> <p>Over simplified example:</p> <pre><code> public class Name { public string FirstName {get; set;} pub...
<p>Okay, I see know that this has been an explicit design decision on the part of SOAP so you're not actually supposed to do this. I found the following <a href="http://msdn.microsoft.com/en-us/library/ms978594.aspx" rel="nofollow noreferrer">page</a> that explains why:</p> <blockquote> <p><strong>Services share schema...
<p>If you want to have a type or structure shared between your web service and your client, add a public struct to your web service project like so:</p> <pre><code>public struct Whatever { public string A; public int B; } </code></pre> <p>then add a method to your web service that has this struct as its retur...
15,501
<p>I've got a variable in Emacs called my-var that I'd like to set whenever I press C-v. How do I do that? I tried this:</p> <pre><code>(defun set-my-var (value) "set my var" (interactive) (defvar my-var value "a variable of mine") ) (global-set-key "\C-v" 'set-my-var) </code></pre> <p>But that fails:</p> ...
<p>Actually, defvar doesn't do what you think it does either: it only changes the value IF there was no value before. Here's a chunk that does what you're looking for, using the CTRL-u argument:</p> <pre><code>(defun set-my-var (value) "Revised version by Charlie Martin" (interactive "p") (setq my-var value)) <...
<p>It's in the argument. Look over at the text I just posted about <code>(interactive)</code>. When you bind <code>set-my-var</code> to a key, it's looking for an argument, but since you used <code>(interactive)</code> there's no argument to be had. What you <em>wanted</em> is something like <code>(interactive "p")<...
49,646
<p>The <code>Close</code> method on an <code>ICommunicationObject</code> can throw two types of exceptions as MSDN outlines <a href="http://msdn.microsoft.com/en-us/library/ms195520.aspx" rel="nofollow noreferrer">here</a>. I understand why the <code>Close</code> method can throw those exceptions, but what I don't unde...
<p>You can mark variables as "<a href="https://velocity.apache.org/engine/1.5/user-guide.html#quietreferencenotation" rel="noreferrer">silent</a>" like this:</p> <pre><code>$!variable </code></pre> <p>If $variable is null, nothing will be rendered. If it is not null, its value will render as it normally would.</p>
<p>You will also need to be sure and use the proper syntax. Your example is missing the dollar before the variable. It should be $!{person.age}, not just {person.age}.</p>
4,368
<p>Recently on one of her videos a YouTuber stated that prints from large format printers are more brittle than if you were to print them in parts and glue them together. This seems to contradict the testimonials from the customers of a large format printer, who say that they get good prints from those printers (which ...
<p>If you break up a large piece into multiple smaller pieces and properly glue them together, you basically add stiffeners (as a result of printing walls). This could lead to a more stiff model; this might have been confused by calling large prints more brittle opposed to constructed models.</p> <p>If printing is con...
<p>I'd recommend getting the object to fit together by design, rather than glue - though I tend (if the item is never to be disassembled) use Zap-a-gap - that stuff sticks like crazy though you must not squeeze the parts together but let it naturally sit.</p>
1,352
<p>We have a build box that uses CruiseControl.Net and has been building VB.Net and C# projects using msbuild. All I have installed on the box as far as .Net is concerned is .Net 2.0 SDK (I'm trying to keep the box as clean as possible). We are now trying to get a C++ app building on this box. The problem we are run...
<p>Visual Studio is not needed, but for C++ you need the Platform SDK as well:</p> <p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&amp;displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?familyid=484269E2-3B89-47E3-8EB7-1F2...
<p>No, you have to install the windows platform SDK.</p> <p>You'll need to download this:</p> <p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&amp;displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4...
6,534
<p>I would like to create a custom XmlDeclaration while using the XmlDocument/XmlDeclaration classes in c# .net 2 or 3. </p> <p>This is my desired output (it is an expected output by a 3rd party app):</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;?MyCustomNameHere attribute1="val1" attribute2=...
<p>What you are wanting to create is not an XML declaration, but a "processing instruction". You should use the <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlprocessinginstruction.aspx" rel="noreferrer">XmlProcessingInstruction</a> class, not the <a href="http://msdn.microsoft.com/en-us/library/system....
<p>You would want to append a <strong>XmlProcessingInstruction</strong> created using the <strong>CreateProcessingInstruction</strong> method of the <em>XmlDocument</em>.</p> <p>Example:</p> <pre><code>XmlDocument document = new XmlDocument(); XmlDeclaration declaration = document.CreateXmlDeclaration("1.0", ...
43,333
<p>Can anyone recommend some good resources that highlight the differences between Oracle and the AS/400 database?</p> <p>I am trying to help someone with a lot of AS/400 experience implement an Oracle installation, and they need some guidance.</p> <p>A book or online resource would be ideal.</p>
<p>I've done this a fair few times and the solutions out there really depend on the environment (enterprise / mission critical or development). The BEST way would be the <strong><em>Oracle AS/400 Gateway</em></strong>. Here are some important links in that area:</p> <p>Allow AS/400 apps to access oracle with the Ora...
<p>These links are not AS/400 specific, but generally a good place starting with Oracle: </p> <p><a href="http://tahiti.oracle.com" rel="nofollow noreferrer">http://tahiti.oracle.com</a><br> <a href="http://asktom.oracle.com" rel="nofollow noreferrer">http://asktom.oracle.com</a></p>
4,344
<p>My company currently has a transactional db running on Sql Server 2005. We are going to add a MySql (running on linux) reporting db. We'll need to get replication running from the MS-Sql db to the MySql db. It doesn't have to be real time but should be within a few minutes.</p> <p>I've got pretty good MSSql Dev ski...
<p>Friend of mine for almost the same case (he copies some data from just a few tables from MSSQL to MySQL) built something like that:</p> <ul> <li>Added trigger to each table which will be replicated. Trigger save primary key, operation type (i)nsert/(u)pdate/(d)elete and source table name in special table (less or ...
<p>A third-party application claims the ability to do this: Daffodil Replicator. I think it's available both as Open Source and Enterprise.</p>
20,407
<p>I have an issue with my Anet A8 printer and how it interlocks with Ultimaker Cura. </p> <p>I want to print this file named <code>Loki_hörner_v2.stl</code>and Cura slices it fine, but when it comes to printing all the preheat happens, but then it stops, not going on at all. What might be wrong here?</p>
<p>Special characters like <code>Ä</code> <code>Ö</code> or <code>Ü</code> in the stl-filename resulted in Ultimaker Cura creating a comment of the filename in the g-code that read like </p> <pre><code>;MESH:Loki_hörner_v2.stl </code></pre> <p>This apparently could not be parsed by the Anet A8, leading to an error an...
<h3>Avoid naming <code>.gcode</code> files with non-ASCII characters</h3> <em>(this includes <a href="https://en.wikipedia.org/wiki/Extended_ASCII" rel="nofollow noreferrer">EASCII</a>)</em> <p>I know of no firmware on a printer that can handle files that have characters not present in the set of 95 non-control <a href...
1,230
<p>Is there a way to detect that a DirectShow filtergraph has reached the end of its file? By end of its file, I mean that a filtergraph with a SampleGrabber filter will never receive another SampleCB call.</p> <p>Here are some things that don't work:</p> <ul> <li>Trust <code>IMediaDet::get_StreamLength</code> (it's...
<p>Maybe using the <a href="http://msdn.microsoft.com/en-us/library/ms785899(VS.85).aspx" rel="nofollow noreferrer">IMediaEventEx</a> interface? One of the event codes is <a href="http://msdn.microsoft.com/en-us/library/ms783543(VS.85).aspx" rel="nofollow noreferrer">EC_COMPLETE</a> documented as 'All data from a parti...
<p>Assuming the main thread is blocking on <code>WaitForSingleObject</code>, could you not specify a timeout for the wait? Then if the wait returns because it has timed out rather than because it has received a signal you'll know it's the last frame.</p>
42,061
<p>I'm doing something like the following:</p> <pre><code>SELECT * FROM table WHERE user='$user'; $myrow = fetchRow() // previously I inserted a pass to the db using base64_encode ex: WRM2gt3R= $somepass = base64_encode($_POST['password']); if($myrow[1] != $somepass) echo 'error'; else echo 'welcome'; </code></pre> ...
<p>Try using <code>var_dump</code> instead of echo - maybe one of them has a space or newline at the start/end.</p> <p>Edit:</p> <p>You must be storing it as CHAR(40): <code>A fixed-length string that is always right-padded with spaces to the specified length when stored</code></p> <p>Use VARCHAR or <code>trim()</co...
<p>If $myrow[1] is actually the correct password in base64-encoding, I don't see any errors.</p> <p>Try this ind the end:</p> <pre><code>echo "&lt;br /&gt;$myrow[1] != $somepass"; </code></pre> <p>What does it say?</p> <p>And by the way: I don't see any reason to base64-encode the passwords. What are you trying to ...
26,269
<p>I'm new to the forum and very new to silverlight. Myself and my coworker are working on a custom application. We are building a menu system that will only display buttons if that useris in an assigned role. A new property was created to allow roles to be defined, and for testing purposes we are simply trying to a...
<p>Every abstract class should either have a,</p> <ul> <li>protected destructor, or,</li> <li>virtual destructor.</li> </ul> <p>If you've got a public non-virtual destructor, that's no good, since it allows users to delete through that pointer a derived object. Since as we all know, that's undefined behavior. </p> <...
<p>I'll add that there have been times when I have scratched my head for a while on destructors not getting called when I forgot a virtual in the parent or child class. I guess I know to look for that now though. :)</p> <p>Someone might argue that there are times the parent class does something in its destructor that ...
46,092
<p>I have a C++ program representing a TCP header as a struct:</p> <pre><code>#include "stdafx.h" /* TCP HEADER 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+...
<p>Because the compiler is packing your bitfield into a 32-bit int, not a 16-bit entity.</p> <p>In general you should avoid bitfields and use other manifest constants (enums or whatever) with explicit bit masking and shifting to access the 'sub-fields' in a field.</p> <p>Here's one reason why bitfields should be avoi...
<p>The compiler is padding the non-bitfield struct member to 32-bit -- native word alignment. To fix this, do #pragma pack(0) before the struct and #pragma pack() after.</p>
18,070
<p>I have files with extensions like ".dae" , ".gtc" , etc. When I try to hit these files over http, the server returns a 404, but they are in the directories. However I can serve readily known file extensions; if i just rename them to say, xml, they are accessible.</p> <p>Any suggestions for what the problem may be?<...
<p>If you request a file with an extension that is <strong>not a defined MIME type on your IIS 6.0 Web server</strong>, you receive a "<em>HTTP Error 404 - File or directory not found</em>" error message.</p> <p>To <strong>define a MIME type for a specific extension</strong> (.dae in your case), follow these steps:</...
<p>You need to define additional MIME types on IIS 6 for the extensions that you mentioned.</p> <p>Here is the MS article on how to add additional MIME types to IIS6:</p> <p><a href="http://support.microsoft.com/kb/326965" rel="nofollow noreferrer">http://support.microsoft.com/kb/326965</a></p>
13,567
<p>At University we have VS 2005 and it has some refactoring tool like rename, extract method, extract class, etc.</p> <p>I have decide to download VS 2008 from MSDN and it has only Rename and Extract method, how can I activate the other?</p> <p>EDIT: I have downloaded Microsoft VS 2008 C# Express Edition. </p>
<p>Have you downloaded the Express Edition? The Express Edition does not have all Refactoring. At University you might have version other than Express.</p> <h2>Update:</h2> <p>Since you posted that you have the Express Edition : You cannot have those refactoring tool from Visual Studio that you had at school. The Expre...
<p>You can install a free edition of Refactor! from <a href="http://www.devexpress.com/" rel="nofollow noreferrer">DevExpress</a></p> <p><a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/VBRefactor/" rel="nofollow noreferrer">Refactor! for VB</a></p> <p><a href="http://www.devexpress.com/Products/Visua...
48,747
<p>There are a lot of webs still using classic ASP instead of ASP.NET but that is not the question - "never change a running project".</p> <p>The question is if it is still a first choice as a base for a new web-project or would it be worth to switch to ASP.NET? Would you recommend a classic ASP programmer another lan...
<p>While I would personally never willingly choose to create another ASP project over an ASP.NET project, the single biggest reason to do so is "skillset". I'd definitely recommend an ASP developer pickup ASP.NET, but if there is a project needed "now", go with what you know. Then learn ASP.NET before you have <stron...
<p>well I honestly wouldnt... With asp .net you can take advantage of the .net framework, and object oriented programming... That alone is good enough reason for me to use asp .net instead of classic asp...</p>
17,172
<p>What are the trade-offs between using a System V and a Posix semaphore?</p>
<p>From <a href="http://www.linuxdevcenter.com/pub/a/linux/2007/05/24/semaphores-in-linux.html?page=4" rel="noreferrer">O'Reilly</a>:</p> <blockquote> <ul> <li>One marked difference between the System V and POSIX semaphore implementations is that in System V you can control how much the semaphore count can b...
<p>Concerning the performances, POSIX semaphores are based on the <a href="https://man7.org/linux/man-pages/man2/futex.2.html" rel="nofollow noreferrer">futex</a> under Linux. This makes them much more efficient than SYSV semaphores.<br /> The SYSV semaphores require systematic system calls for the P()/V() operations. ...
48,082
<p>I have a number of tracks recorded by a GPS, which more formally can be described as a number of line strings.</p> <p>Now, some of the recorded tracks might be recordings of the same route, but because of inaccurasies in the GPS system, the fact that the recordings were made on separate occasions and that they migh...
<p>Compute the <a href="http://cgm.cs.mcgill.ca/~athens/cs507/Projects/2002/StephanePelletier/#what" rel="nofollow noreferrer">Fréchet distance</a> on each pair of tracks. The distance can be used to gauge the similarity of your tracks.</p> <p><em>Math alert:</em> Fréchet was a pioneer in the field of <a href="http://...
<p>I actually side with the person (Aaron F) who said that you might be interested in the Levenshtein distance problem (and cited <a href="http://en.wikipedia.org/wiki/Fasta" rel="nofollow noreferrer">this</a>). His answer seems to me to be the best so far.</p> <p>More specifically, Levenshtein distance (also called e...
8,793
<p>I usually use C++ stdlib map whenever I need to store some data associated with a specific type of value (a key value - e.g. a string or other object). The stdlib map implementation is based on trees which provides better performance (O(log n)) than the standard array or stdlib vector.</p> <p>My questions is, do yo...
<p>If you're using C++11, you have access to the <code>&lt;unordered_map&gt;</code> and <code>&lt;unordered_set&gt;</code> headers. These provide classes <a href="http://en.cppreference.com/w/cpp/container/unordered_map" rel="noreferrer"><code>std::unordered_map</code></a> and <a href="http://en.cppreference.com/w/cpp/...
<p><a href="http://www.sgi.com/tech/stl/hash_map.html" rel="nofollow noreferrer">std::hash_map</a></p>
16,167
<p>There doesn't appear to be any Perl libraries that can open, manipulate, and re-save PDF documents that use the newer PDF version (1.5 and above I believe) that use a cross-reference stream rather than table. Does anyone know of any unix/linux-based utilities to convert a PDF to an older version? Or perhaps there'...
<p>Done! An hour ago, I uploaded CAM::PDF v1.50 to CPAN. It now supports PDF v1.5 compressed object streams and cross-reference streams. I've tested it with a few PDF files that I found online, but I'd sure appreciate feedback (good or bad).</p>
<p>I would try running it through ghostscript with appropriate parameters.</p> <p>Something like <code>gs -dBATCH -dNOPAUSE -sDEVICE=pdfwriter -dCompatibilityLevel=1.2</code></p>
11,782
<p>I have an Exchange mailbox linked as a table in an MS Access app. This is primarily used for reading, but I would also like to be able to "move" messages to another folder. </p> <p>Unfortunately this is not as simple as writing in a second linked mailbox, because apparently I can not edit some fields. Some critic...
<p>Is this two problems? Mail can be moved using the Move method. Here is a snippet:</p> <pre><code> Set oApp = CreateObject("Outlook.Application") Set oNS = oApp.GetNamespace("MAPI") Set oMailItems = oNS.GetDefaultFolder(olFolderInbox) Set itm = oMailItems.Items(6) itm.Move oNS.GetDefaultFolder(olFolderDeletedItems...
<p>I don't think Access is the right tool for the job. You will not get around using an Outlook.Application object or a MAPI wrapper like CDO. CDO will be the more elegant and performant way, but it must explicitly be installed on the client via Office Setup.</p> <p>If you want to avoid the script security dialog (and...
12,646
<p>I have this application installed on my Macbook Pro that allows me to disable a core on my CPU. It got me wondering: How does disabling a core affect the running processes?</p> <p>I am also interested if disabling a core has an affect on the following</p> <ul> <li>Battery Life</li> <li>Heat generation</li> <li>Inc...
<h2>How does disabling a core affect the running processes?</h2> <p>It doesn't, unless the program you're using is phenomenally badly written. The OS scheduler will be alerted that the processor is no longer available, and will simply stop scheduling processes into that processor. Putting a process from "running" in...
<p>I don't know about power consumption, but I expect you would save some margin. This depends upon the percentage of power used within the MBP by the CPU.</p> <p>As for impact on raw processing power, it depends upon the nature of the applications you're running. Most applications aren't designed to utilise multipl...
39,456
<p>In C#.NET I am trying to programmatically change the color of the border in a group box.</p> <p>Update: This question was asked when I was working on a winforms system before we switched to .NET.</p>
<p>Building on the previous answer, a better solution that includes the label for the group box:</p> <pre><code>groupBox1.Paint += PaintBorderlessGroupBox; private void PaintBorderlessGroupBox(object sender, PaintEventArgs p) { GroupBox box = (GroupBox)sender; p.Graphics.Clear(SystemColors.Control); p.Graphics....
<p>This tweak to Jim Fell's code placed the borders a little better for me, but it's too long to add as a comment</p> <p>...</p> <pre><code> Rectangle rect = new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y + (int)(strSize.Height / 2), ...
10,208
<p>I want to call a few "static" methods of a CPP class defined in a different file but I'm having linking problems. I created a test-case that recreates my problem and the code for it is below.</p> <p>(I'm completely new to C++, I come from a Java background and I'm a little familiar with C.)</p> <pre><code>// CppCl...
<p>It's obvious you come from a Java background because you haven't yet grasped the concept of header files. In Java the process of defining something is usually in one piece. You declare and define at the same time. In C/C++ it's a two-step process. <strong>Declaring</strong> something tells the compiler "something ex...
<p>Sure looks like the linker is not picking up you second source file.</p>
14,218
<p>I have one applicationContext.xml file, and it has two org.springframework.orm.jpa.JpaTransactionManager (each with its own persistence unit, different databases) configured in a Spring middleware custom application. <br><br>I want to use annotation based transactions (@Transactional), to not mess around with Transa...
<p>I guess you have 2 choices</p> <p>If your use-cases never require updates to both databases within the same transaction, then you can use two JpaTransactionManagers, but I'm not sure you will be able to use the @Transactional approach? In this case, you would need to fallback on the older mechanism of using a simpl...
<p>The only situation in which you can have two Spring transaction managers is if you never have both transactions open at one time. This is not intrinsically to do with distributed transactions - the same restrictions apply even if you want the two datasources to have completely separate (but potentially overlapping ...
10,129
<p>Does anyone know if there's a de-facto standard (i.e., TR1 or Boost) C++ function object for accessing the elements of a std::pair? Twice in the past 24 hours I've wished I had something like the <code>keys</code> function for Perl hashes. For example, it would be nice to run std::transform on a std::map object an...
<p><code>boost::bind</code> is what you look for.</p> <pre><code>boost::bind(&amp;std::pair::second, _1); // returns the value of a pair </code></pre> <p>Example:</p> <pre><code>typedef std::map&lt;std::string, int&gt; map_type; std::vector&lt;int&gt; values; // will contain all values map_type map; std::transform(...
<p>One option that wasn't suggested is <code>std::tr1::get</code>. See sections 6.1.2 and 6.1.4 of <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1745.pdf" rel="nofollow">n1745</a>.</p> <pre><code>std::pair&lt; std::string, int &gt; p( "foo", 1729 ); int hr = std::tr1::get&lt; 1 &gt;( p ); </code>...
48,719
<p>I've been doing ASP.NET development for a little while now, and I've used both the GridView and the DataGrid controls before for various things, but I never could find a really good reason to use one or the other. I'd like to know:</p> <p>What is the difference between these 2 ASP.NET controls? What are the advanta...
<p>DataGrid was an ASP.NET 1.1 control, still supported. GridView arrived in 2.0, made certain tasks simpler added different databinding features:</p> <p>This link has a comparison of DataGrid and GridView features -</p> <p><a href="https://msdn.microsoft.com/en-us/library/05yye6k9(v=vs.100).aspx" rel="noreferrer">ht...
<p>some basic diffrence between gridview and details view</p> <p>the GridView control also has a number of new features and advantages over the DataGrid control, which include: </p> <p>· Richer design-time capabilities. · Improved data source binding capabilities. · Automatic handling of sorting, paging, updates, ...
2,624
<p>I'm in the process of adding custom buttons to my iPhone UI and want to make them have the glassy look from Apple's apps. I have a good default glass image, but I'd hate to have to have a separate image for each tint I want (red, green, blue, etc.). </p> <p>Is there a way to load a grayscale PNG and adjust it to th...
<p>There isn't a one-liner way that I know of, but you might be able to get the desired effect by taking the default grayscale image and compositing it with (i.e. drawing it on top of) a solid color. If you look through the Core Graphics documentation, you can see there are over a dozen different compositing methods (...
<p>I ended up creating my own custom button that closely matches the rendering used in the "Delete Contact" button in the contacts edit view.</p> <p>For those interested, it can be found on github at</p> <p><a href="https://github.com/appsinyourpants/Pants-Framework/blob/master/Classes/Views/PFTintedButton.m" rel="no...
14,786
<p>I'm trying to install <a href="http://laconi.ca/" rel="noreferrer">Laconica</a>, an open-source Microblogging application on my Windows development server using XAMPP as per the <a href="http://laconi.ca/trac/wiki/InstallationWindows" rel="noreferrer">instructions provided</a>.</p> <p>The website cannot find PEAR, a...
<p>You need to fix your <code>include_path</code> system variable to point to the correct location. </p> <p>To fix it edit the <code>php.ini</code> file. In that file you will find a line that says, "<code>include_path = ...</code>". (You can find out what the location of php.ini by running <code>phpinfo()</code> on a...
<p>Try adding the drive letter:</p> <pre><code>include_path='.;c:\xampplite\php\pear\PEAR' </code></pre> <p>also verify that PEAR.php is actually there, it might be in \php\ instead:</p> <pre><code>include_path='.;c:\xampplite\php' </code></pre>
8,815
<p>Let me preface this with me being quite a newbie to 3D printing, however, I am an engineer and coder, so tinkering with stuff like this is quite the norm for me. Don't be afraid to be too technical, knowledge is power!</p> <p>I recently purchased a new Creality Ender 3 V2 based on a friend's recommendation and with...
<p>Okay, so after yet another frustrating night of troubleshooting. I believe I have identified the specific problem. I reduced the G-code file to about 100 lines of code, that 100% reproduced the issue on the BIQU H2 stepper. With the original 4042 stepper, the problem was intermittent, but did occur from time to t...
<p>Check your retraction and run some experiments with it. I just had a very similar problem, when I switched from 0.6 mm retraction to 0.8 mm filament tended to get stuck between rolers and the cooler on layer change. I don't have and never had linear advance enabled, so it's not the issue. Unless I've misunderstood a...
1,997
<p>I am currently in an operating systems class and my teacher spent half of the class period talking about PIDs. She mentioned, as many know, that processes know their parent's ID.</p> <p>My question is this:</p> <p>Does a process's PCB know its child's ID? If so, what is the way to go about it obtaining it?</p>
<p>As far as I know a process doesn't have an explicit list of its children's PIDs, but it can easily be built, since a process should know which child processes it spawns. For example the UNIX fork() call returns the child PID in the parent process and 0 in the child process, CreateProcess() on Windows returns (IIRC) ...
<p>Process's PCB know its child's ID.</p> <p>As we know the Fork() is used to create processes.It takes no arguments and returns a process ID.After a new child process is created both parent and child will execute the next instruction following the fork(). There we have to distinguish the parent from the child.This ca...
8,487
<p>Windows Forms allows you to develop Components, non-visual elements that can have a designer. Built-in components include the BackgroundWorker, Timer, and a lot of ADO .NET objects. It's a nice way to provide easy configuration of a complicated object, and it it enables designer-assisted data binding.</p> <p>I've...
<p>Just from my own observations, it seems like Microsoft is trying to move away from having components and similar things in the GUI. I think WPF tries to limit most of what's in the XAML to strictly GUI things. Data binding I guess would be the only exception. I know I try to keep most everything else in the code-...
<p>So far, the only approach I see that makes sense is to make an instance of the class a static resource and configure it from XAML. This works, but it'd be nice if there were something like the WinForms designer component tray that these could live in.</p>
19,080
<p>I'd love to know if there is such a thing as a Gecko.NET ;) I mean, just like we can embed a WebView and that is an "instance" of IE7 inside any Windows Forms application (and tell it to <code>navigateto(fancy_url);</code>). I'd love to use Firefox or WebKit. </p> <p>Anybody tried this?</p> <p><strong>UPDATE</stro...
<p><a href="http://code.google.com/p/geckofx/" rel="noreferrer">http://code.google.com/p/geckofx/</a></p> <p>This is a nice .NET-wrapped version of Gecko</p>
<p>Additionally, if you find yourself using Gtk instead of Windows.Forms, there is a tarball of webkit-sharp available that allows for easy embedding of WebViews into Gtk# applications.</p>
4,574
<p>I refactor my code and I am looking for a solution to grep my source files for something like</p> <pre><code>if ( user &amp;&amp; user.name &amp;&amp; user.name.length() &lt; 128 ) ... </code></pre> <p>in order to replace it later with ruby's andand or groovy's ?. operator (safe navigation operator).</p>
<p>Here's something to get you started, I wonder if this can be generalized more without having to generate the regexp programatically</p> <pre><code>line = "user &amp;&amp; user.name &amp;&amp; user.name.length()" p line.match(/(?:(\w*)(?:\s\&amp;\&amp;\s(\1\.(\w*)))(?:\s\&amp;\&amp;\s(\2\.(\w*))))/).to_a. reject {...
<p>IntelliJ idea has a "structural search &amp; replace" that will let you do this. This understands the semantics of the language so you can do all sorts of interesting replace operations.</p> <p><a href="http://www.jetbrains.com/idea/documentation/ssr.html" rel="nofollow noreferrer">http://www.jetbrains.com/idea/doc...
46,868
<p>I used to work with eclipse for nearly all the languages I need. I'm asked to work on a tool developed in C# and so, I would like to stay in the same familiar environment.</p> <p>I've found the <a href="http://www.improve-technologies.com/alpha/esharp/" rel="noreferrer">improve's plugin</a> but its last release is ...
<p><a href="http://emonic.sourceforge.net/" rel="noreferrer">Emonic</a> integrates mono into the eclipse framework, that may be of use.</p>
<p>Emonic is worth a look as Jasper suggested. I've installed it in the past myself, but over a year ago. Checking the change logs on the site, it does not appear that they have had any new releases since then. The worst thing about it is that it does not supply a debugger or any refactoring tools. I've found that ...
17,540
<p>I was wrestling with some Perl that uses hash references.</p> <p>In the end it turned out that my problem was the line:</p> <pre><code>$myhash{$key} |= {}; </code></pre> <p>That is, "assign $myhash{$key} a reference to an empty hash, unless it already has a value".</p> <p>Dereferencing this and trying to use it ...
<p>The reason you're seeing an error about using a string as a hash reference is because you're using the wrong operator. <code>|=</code> means &quot;bitwise-or-assign.&quot; In other words,</p> <pre><code> $foo |= $bar; </code></pre> <p>is the same as</p> <pre><code> $foo = $foo | $bar </code></pre> <p>What's happen...
<p>Try this:</p> <pre><code>my %myhash; $myhash{$key} ||= {}; </code></pre> <p>You can't declare a hash <em>element</em> in a <code>my</code> clause, as far as I know. You declare the hash first, then add the element in.</p> <p>Edit: I see you've taken out the <code>my</code>. How about trying <code>||=</code> inste...
18,736
<p>At some point in time I turned on a setting in Visual Studio 2005 that produces a warning when methods/classes don't have an xml comment associated with them. I would like to turn this off, but can't seem to find the setting again. Anyone know where this is?</p>
<p>Right-click your project and goto Properties.</p> <p>Select the Build tab on the left.</p> <p>Under Supress Warnings enter... 1591,1592,1573,1571,1570,1572.</p> <p>Though I don't recommend this because the whole point of generating documentation is to have it documented. If you don't like the warnings you can de...
<p>The only way I know is turning off XML documentation generation. This can be done on under Project properties / Compile / Generate XML documentation file.</p>
21,083
<p>I seem to have an app on my Dev server that has lots of open connections (they should be there, but some bad data layer was used to open them, that forgot to close them). I just want them closed so I can keep other apps running on the server. How can I force all the connections to close?</p>
<p>Use the following script to kill inactive sessions from a specific host / login. You could use it from a scheduled job, of course your priority should be to fix your app tier. </p> <pre><code>SET NOCOUNT ON; DECLARE @host VARCHAR(50), @login NVARCHAR(128); SET @host = 'fooHost'; --NULL to kill sessions from a...
<p>Other than killing your connections manually, you can</p> <ul> <li>Dispose of the connections. That is, retrieve the Connection objects somehow and call .Close and .Dispose() on them. Using "using" would be ideal since it calls .Dispose() automatically for you.</li> <li>Recycle your application pool.</li> </ul>
48,044