instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have a requirement to make a large amount of code MISRA compliant.<br>
First question: Can somebody to give an <strong>estimation</strong> for passing well written code for embedded system based on experience. I understand that "well written" is poorly defined and vague so i ask for raw estimation.<br>
Second ques... | <p>I also highly recommend PC-Lint. If you happen to be compiling your code with Visual Studio I recommend a plug-in 'Visual Lint' from Riverblade. If you cannot compile the code in Visual Studio, you can still run PC-Lint from the command line to good effect.</p>
<p>Some embedded system compilers provide MISRA comp... | <p>I appreciate that this is an old question, but for the benefit of any other Archaeologists (or searchers), it is important to remember that MISRA provides <strong>guidelines</strong> that should not always be blindly followed.</p>
<p>I commend writing new code with MISRA in mind; therefore it will be a lot easier t... | 8,848 |
<p>I am creating a new build process for a DotNet project which is to be held in Subversion.</p>
<p>For each dll/exe that I compile (via Nant) I would like to include 2 additional attibutes in the dlls that are built.</p>
<p>I already understand the workings of the 'asminfo' nant task. But I need help retrieving the ... | <p>Firstly, you can use "svn info --xml >out.xml" to get the svn information to a text file. You can then use a Nant xml-peek to get a value out of the file into a variable.</p>
<pre><code><xmlpeek file="out.xml" xpath="/info/entry/url" property="svn.url" />
</code></pre>
| <p>The entries in the .svn directory are not really meant to be accessed directly. I don't know much about what you're doing but I'd suggest you use the mechanism you use to checkout the project to find the HEAD version and path. (I'd actually assume that becuase you are checking out the project you already know the pa... | 23,211 |
<p>I'm looking for a plugin for jQuery that can validate as a key is pressed and after it loses focus (text boxes). </p>
<p>I'm currently using <a href="http://www.overset.com/2008/07/31/jval-jquery-form-field-validation-plugin/" rel="nofollow noreferrer">jVal - jQuery Form Field Validation Plugin</a>. It works pretty... | <p>This one looks like it would fit your description:</p>
<ul>
<li><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="nofollow noreferrer">jQuery plugin:validation (Homepage)</a></li>
<li><a href="http://jquery.bassistance.de/validate/demo/" rel="nofollow noreferrer">demo</a></li>
<li><a hre... | <p>I've use jQuery plugin:validation. it works pretty with creating DOM elements on the fly. When creating them on the fly make sure the attributes name and ID are included. I'm pretty sure the plugin uses the name attribute to find them in the html. If the name is missing they can't be found. </p>
<p>Also this m... | 25,655 |
<p>Can you package up the .Net framework in an installer created in Visual Studio? If so how?</p>
<p>I've seen this done with Install4J packaging a JVM but I think that was the JVM to run Install4J.</p>
| <p>I just learned this lesson about deployment projects: the .MSI file delivers the application to the target machine, but that SETUP.EXE is the bootstrapper that installs prerequisites, such as the .NET Framework, MDAC, or Windows Installer. I specified the .NET Framework as a prerequisite but, because I only distribu... | <p>Sucky, yeah - I created an installer just recently before realizing that the .Net Framework (which was one of the things I needed to install) was required. I ended up making a c++ program that installed .Net before my installer was launched.</p>
<p>Seems kind of odd to me to offer the ability to create an installe... | 19,690 |
<p>In some asp tutorials, like <a href="https://web.archive.org/web/20211020111619/https://www.4guysfromrolla.com/webtech/050900-1.shtml" rel="nofollow noreferrer">this</a>, i observe the following pattern:</p>
<blockquote>
<p>Application.Lock</p>
<p>'do some things with the application object</p>
<p>Application.Unlock... | <p>From the <a href="http://msdn.microsoft.com/en-us/library/ms525184.aspx" rel="nofollow noreferrer">MSDN documentation</a>:</p>
<p>The <code>Lock</code> method <strong>blocks other clients</strong> from modifying the variables stored in the Application object, ensuring that <strong>only one client at a time</strong>... | <p>If one page tries to lock the Application object while it is already locked, it will wait until the page holding the lock has released it. This will normally be quick (ASP code should only generally hold the lock for long enough to access the shared object that's stored in Application).</p>
| 20,566 |
<p>I am working on a program which manipulates images of different sizes. Many of these manipulations read pixel data from an input and write to a separate output (e.g. blur). This is done on a per-pixel basis.</p>
<p>Such image mapulations are very stressful on the CPU. I would like to use multithreading to speed ... | <p>If your compiler supports <a href="http://openmp.org/wp/" rel="noreferrer">OpenMP</a> (I know <a href="http://msdn.microsoft.com/en-us/library/tt15eb9t(VS.80).aspx" rel="noreferrer">VC++ 8.0 and 9.0</a> do, as does gcc), it can make things like this much easier to do. </p>
<p>You don't just want to make a lot of t... | <p>There's another option of using assembly for optimization. Now, one exciting project for dynamic code generation is <a href="https://gna.org/svn/?group=softwire" rel="nofollow noreferrer">softwire</a> (which dates back awhile - <a href="http://softwire.sourceforge.net/" rel="nofollow noreferrer">here</a> is the orig... | 42,308 |
<p>It's easy to wrap optional memcached caching around your existing database queries. For example:</p>
<p>Old (DB-only):</p>
<pre><code>function getX
x = get from db
return x
end
</code></pre>
<p>New (DB with memcache):</p>
<pre><code>function getX
x = get from memcache
if found
return x
... | <p>Read about the <a href="http://martinfowler.com/eaaCatalog/identityMap.html" rel="nofollow noreferrer">Identity Map</a> pattern. This is a way to make sure you only keep one copy of a given row in your application space. Whether you store it in memcached or just plain objects, this is a way to handle what you want... | <p>Well, I guess that's something you'll have to live with. Memcahced will work the best if you don't really do stuff in batches. For example it's great for stuff like "where are the things for this user? Here is a bunch of things for this user." This doesn't really mean that this query doesn't do batches. Of course it... | 34,898 |
<p>I'm building a fairly large website and my .htaccess is starting to feel a bit bloated, is there a way of replacing my current system of - one rule for each of the possibile number of vars that could be passed, to one catch all expression that can account for varying numbers of inputs ?</p>
<p>for example I current... | <p>Do like Drupal:</p>
<pre><code> RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</code></pre>
<p>And then handle all the stuff in your script using php code something like this</p>
<pre><code>$pathmap = ();
if ($_GET["q"]){
$path = split("... | <p>I don't believe that their is a way - but I'd say that your best bet would be to have the script "index.php" process a path instead of having to do so many back references.</p>
<p>So for example, your rewriterule would be </p>
<pre><code>RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILEN... | 14,351 |
<p>I have a c# form (let's call it MainForm) with a number of custom controls on it. I'd like to have the MainForm.OnClick() method fire anytime someone clicks on the form regardless of whether the click happened on the form or if the click was on one of the custom controls. I'm looking for behavior similar to the KeyP... | <p>In the form's ControlAdded event, add a MouseClick handler to the control, with the Address of the form's click event. I haven't tested this, but it might work.</p>
<pre><code>Private Sub Example_ControlAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.ControlEventArgs) Handles Me.ControlAdded
Add... | <p>Catching a click on an open space on the form is easy, but to get a click that's actually on a control, you'll need the cooperation of that control to send it to the form.</p>
<p>One possibility is to place a transparent control over the entire form, and accept clicks onto that, deal with them, and then pass them o... | 21,773 |
<p>I have a single user java program that I would like to have store data in a light weight database such as Derby or Sqlite. I would like to use a data abstraction layer in my program. Hibernate appears to require a lot of configuration and is overkill for what I need. What are light weight alternatives to Hibernate?<... | <p>Hibernate requires next to zero configuration if you use annotations. It even can auto-discover mapped beans in the classpath! I don't see any alternative to it from both simplicity <strong>and</strong> power point of view.</p>
<p>It can also expose itself as JPA, which is (IMHO) even simpler.</p>
| <p>Kiteframework is also very light orm framework. It provides almost all db operation with minimal configurations.</p>
<p><a href="http://deipakgarg.github.com/Kite-ORM/" rel="nofollow">http://deipakgarg.github.com/Kite-ORM/</a></p>
<p><strong>Disclosure: I am the author of this project</strong></p>
| 37,924 |
<p>I would like to be able to Serialize a DateTime with a specific Time Zone that is not the server, nor is it client time. Basically, any time zone.
Is it possible to override the DateTime serialization, in .Net2.0 webservices?</p>
<p>I compile an xmlschema using xsd.exe, so I made an attempt using XmlSchemaImporter... | <p>Don't serialize the <code>DateTimeOffset</code> directly, but serialize a string instead:</p>
<pre><code>// Don't serialize this one
[System.Xml.Serialization.XmlIgnore]
public System.DateTimeOffset metadataDateTime
{
get { ... }
set { ... }
}
// Serialize this one instead
[System.Xml.Serialization.XmlAtt... | <p>This was discussed 2 days ago. Does this do it for you?</p>
<p><a href="https://stackoverflow.com/questions/299387/c-serializing-class-to-xml-where-one-of-class-properties-is-datetime-how-to-mak#299418">C# serializing Class to XML where one of class properties is DateTime. How to make this property in ISO format?<... | 39,438 |
<p>I am trying to setup a WCF service with multiple endpoints with one of the endpoints using the enableWebScript endpoint behavior so that a Javascript proxy will be created on the client (jsdebug/js).</p>
<p>When adding the Service Reference to my AJAX ScriptManager, the jsdebug file is not found unless the address ... | <p><code><enableWebScript /></code> also known as AJAX-enabled endpoints essentially hard-codes everything to do with address so you can generate the client-side code.</p>
<p>The way it's hard-coded is that everything is directly relative to the .svc file.</p>
<p>See <a href="http://msdn.microsoft.com/en-us/lib... | <p>In the ScriptManager, put MyService.svc/ajax instead of MyService.svc</p>
| 34,319 |
<p>The problem with my Anet E12 should be on USB connection itself.</p>
<ol>
<li>If powered down, the board still gets power from USB</li>
<li>If board is resett, USB will still connect</li>
<li>Still works on SD; seem like most part not damage.
What cause the problem? Where to check first? How to fix it?</li>
</ol>
<p... | <p>Your formula doesn't seem to take into account two important factors: layer height and average speed.</p>
<p>Do the math differently:</p>
<p>voumetric flow rate [mm^3/s] = layer height [mm] * line width [mm] * speed [mm/s]</p>
<p>For example, 0.2 * 0.45 * 70 = 6.3 mm^3/s</p>
<p>which is realistic, the extruder on th... | <p>Your math looks correct, and is also a good approximation for what I've seen in the first few weeks with my own Ender 3.</p>
<p>Another way to calculate (to check yourself) is to calculate the volume extruded (nozzle area times extrusion percentage times print speed -- be sure you convert everything to the same unit... | 1,952 |
<p>I have been searching for something that does this for a while now, but with no luck yet... We have an internal application that stores/uses text in HTML format. Now I am looking for a new control for editing it. </p>
<p>I <strong>do not</strong> need a full-featured HTML editor, just something that can deal with... | <p>Here are a couple of options for for an open source .NET-based text editor that handles syntax highlighting</p>
<ul>
<li>The ICSharpCode.TextEditor component of the <a href="http://www.icsharpcode.net/OpenSource/SD/Download/" rel="nofollow noreferrer">SharpDevelop</a> C# IDE</li>
<li><a href="http://www.codeplex.co... | <p>I solved it using this <a href="http://www.codeplex.com/WinformHtmlTextbox" rel="nofollow noreferrer">HTML textbox</a>? It encapsulates IE and uses it for HTML editing, just like you did. No Spell checker.</p>
| 32,435 |
<p>What are some good package naming conventions for domain specific object models. For example, say you have a <strong>Person.java</strong> POJO, would you put it in a <strong>mydomain.model</strong> or <strong>mydomain.entity</strong> or <strong>mydomain.om</strong> (object model) package. The idea is to separate ... | <p>I use "com.mycompany.domain" personally, but that might not be the best answer.</p>
| <p>Not only that, be careful in the naming convention of your namespaces. I've seen cases where namespace names where duplicated in different assemblies. Talk about confusion. </p>
| 12,237 |
<p>I just upgraded the nozzle (to 1 mm) on an Ender 3v2 and want to make a test print. I added a new printer for the new nozzle size.... and can't find a setting for it. Some screenshots on the internet show a nozzle diameter setting in the machine settings, but I do not have that. (<strong>Manage printers</strong> &... | <h1>Mechanical interaction</h1>
<h2>Operator induced regular actions</h2>
<p>When an operator reaches into the machine and operates something on the bed, this can induce errors that slowly accumulate. The most typical operation would be to remove something from the printbed, cleaning the printbed or swapping the printb... | <p>The only ones I have found are.</p>
<p>Manually putting pressure on the bed when removing prints.</p>
<p>Removing the bed covering, eg a glass plate</p>
<p>Damaging the bed in some way. For example my bed has high spots on it (always has). This means that if I remove the glass plate I use and put it back, it sits sl... | 2,149 |
<p>I'm using an istream which could be stringstream, ifstream or a user-defined stream type and I need to know if, in the case of an ifstream, it was not opened in binary mode (so I can throw an exception). I have tried the following method:</p>
<pre><code>if ((_is.flags() & ios::binary) == 0)
throw exception(... | <p>flags() returns <a href="http://www.cplusplus.com/reference/iostream/ios_base/fmtflags.html" rel="noreferrer">ios_base::fmtflags</a> which is formatting flags, whereas binary is an <a href="http://www.cplusplus.com/reference/iostream/ios_base/openmode.html" rel="noreferrer">ios_base::openmode</a> flag. I'm not sure ... | <p>Nope, there is no way to test this.</p>
| 27,699 |
<p>I normally build my solution with MSBuild in order to keep Visual Studio responsive and save a bit of time. Right now, what I run at the command line is very simple:</p>
<pre><code>MSBuild.exe /m "C:\MyProject\MyProject.sln"
</code></pre>
<p>Up until now, this has worked just fine. However, today I added a class... | <p>This probably sounds like a stupid question, but are you sure the new class file was saved? Rebuild usually automatically saves all files, whereas MSBuild does not.</p>
| <p>Try specifying "ReBuild" in your msbuild command line call.</p>
<p>msbuild /t:Rebuild /p:Configuration=Debug</p>
<p>Season to taste.</p>
| 48,289 |
<p>I have the function below ENCRYPT.</p>
<pre><code>Public Function Encrypt(ByVal plainText As String) As Byte()
Dim key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
Dim iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219}
' Declare a UTF8Encoding object s... | <p>You can use <a href="http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx" rel="nofollow noreferrer">Encoding</a> class.</p>
<p>To convert array of bytes to a string you can use <a href="http://msdn.microsoft.com/en-us/library/system.text.encoding.getstring.aspx" rel="nofollow noreferrer">Encoding.GetS... | <p>You can use <a href="http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx" rel="nofollow noreferrer">Encoding</a> class.</p>
<p>To convert array of bytes to a string you can use <a href="http://msdn.microsoft.com/en-us/library/system.text.encoding.getstring.aspx" rel="nofollow noreferrer">Encoding.GetS... | 17,757 |
<p>I need to compile a wmi vbscript to executable (to automate configuration in several computers). Any free vbscript compiler or any other suggestions?</p>
| <p>One thing I would be especially concerned about in doing this is you must really trust the product that is compiling the script. After all, what better way to embed a virus or worm than to offer a free compiler that compiles your VBScript into an unreadable executable. </p>
| <p>ok that's interesting i guess, and I fully understand your point!</p>
<p>you can use the WSH Encoder <a href="http://www.microsoft.com/downloads/details.aspx?familyid=E7877F67-C447-4873-B1B0-21F0626A6329&displaylang=en" rel="nofollow noreferrer">here</a> (Windows Script Host), it's for free you can encrypt your... | 46,842 |
<p><a href="https://stackoverflow.com/questions/109488/is-it-bad-design-to-use-table-tags-when-displaying-forms-in-html">Is it bad design to use table tags when displaying forms in html?</a></p>
<p>The accepted answer to this question in short: YES...</p>
<p>...but what about something like this:</p>
<p><img src="ht... | <p>This type of question leads more to opinions than to hard and fast facts, but I would say that in this case it's definitely OK to use tables -- you're wanting a tabular display of information.</p>
<p>Just use the table tag and don't let people make you feel guilty for it :-)</p>
| <p>What everyone says is "you should only use tables for tabular data". So ... what does that mean?</p>
<p>Here's my criterion for when something actually is tabular data: when you can only know what something is/does by reference to its <em>coordinates</em>, its position in relation to column and row headers. </p>
<... | 42,921 |
<p>I know it is possible, and a lot faster than using GDI+. However I haven't found any good example of using DirectX to resize an image and save it to disk. I have implemented this over and over in GDI+, thats not difficult. However GDI+ does not use any hardware acceleration, and I was hoping to get better perform... | <p>You can load the image as a texture, texture-map it onto a quad and draw that quad in any size on the screen. That will do the scaling. Afterwards you can grab the pixel-data from the screen, store it in a file or process it further. </p>
<p>It's easy. The basic texturing DirectX examples that come with the SDK can... | <p>You can load the image as a texture, texture-map it onto a quad and draw that quad in any size on the screen. That will do the scaling. Afterwards you can grab the pixel-data from the screen, store it in a file or process it further. </p>
<p>It's easy. The basic texturing DirectX examples that come with the SDK can... | 20,873 |
<p>I'm trying to print a large piece with polycarbonate but it keeps warping, I'm using a Taz 5 printer and setting 290 C in the extruder and 145 C in the heating bed. </p>
<p>Other setting I have are:</p>
<ol>
<li>printing speed: 20 mm/s</li>
<li>layer height: 2.5mm</li>
<li>infil: 20%</li>
<li>brim: 15mm</li>
</ol>... | <p>Adjusting the design may also be able to help limit the amount of warping you get.</p>
<p>One of the major causes of warping is upper layers contracting while cooling when laid down over now-cool(er) lower layers which no longer contract so much but are still thin enough to flex when subject to tension along their ... | <p>I would take a look <a href="http://reprap.org/wiki/Polycarbonate" rel="nofollow noreferrer">here</a> and <a href="https://www.matterhackers.com/articles/how-to-succeed-when-printing-with-polycarbonate-filament" rel="nofollow noreferrer">here</a>.
Literally the first two results of Google.</p>
<p>To summarize what ... | 739 |
<p>How do I find duplicate addresses in a database, or better stop people already when filling in the form ? I guess the earlier the better?</p>
<p>Is there any good way of abstracting street, postal code etc so that typos and simple attempts to get 2 registrations can be detected? like: </p>
<pre><code>Quellenstrass... | <p>The earlier you can stop people, the easier it'll be in the long run! </p>
<p>Not being too familiar with your db schema or data entry form, I'd suggest a route something like the following:</p>
<ul>
<li><p>have distinct fields in your db for each address "part", e.g. street, city, postal code, Länder, etc.</p></l... | <p>In my opinion, assuming that you already had a lot of dirty data in your DB, </p>
<p>You have to do build your "handmade" dirty filter which may detect a maximum of german abreviation ... </p>
<p>But If you treat a lot of data, you will take the risk to find some false-positive and true-negative sample...</p>
<p>... | 5,831 |
<p>Sometimes while debugging, I need to restart a service on a remote machine. Currently, I'm doing this via Remote Desktop. How can it be done from the command line on my local machine?</p>
| <p>You can use the services console, clicking on the left hand side and then selecting the "Connect to another computer" option in the Action menu.</p>
<p>If you wish to use the command line only, you can use</p>
<pre><code>sc \\machine stop <service>
</code></pre>
| <p>Well, if you have Visual Studio (I know it's in 2005, not sure about earlier versions though), you can add the remote machine to your "Server Explorer" tag. At that point, you'll have access to the SERVICES that are running, or can be ran, from that machine (as well as event logs, and queues, and a couple other inte... | 22,761 |
<p>I want to discard all remaining characters in a string as soon as one of several unwanted characters is encountered.</p>
<p>As soon as a blacklisted character is encountered, the string before that point should be returned.</p>
<p>For instance, if I have an array:</p>
<pre><code>$chars = array("a", "b... | <p>The <a href="http://php.net/manual/en/function.strcspn.php" rel="noreferrer">strcspn</a> function is what you are looking for.</p>
<pre><code><?php
$mask = "abc";
$string = "log dog hat bat";
$result = substr($string,0,strcspn($string,$mask));
var_dump($result);
?>
</code></pre>
| <p>There is certainly nothing wrong with Vinko's answer and I might be more inclined to recommend that technique in a professional script because regex is likely to perform slower, but purely for a point of difference for researchers, regex could be used.</p>
<p>For the record, to convert the array of <code>['a', 'b', ... | 37,308 |
<p>Suppose I have the X, Y, and Z coordinates (either in a list or a function z = f(x,y)) that defines a shape as the one provided and I want to 3D print it with a solid bottom, is there an easy way to do this? If not, how can a functionally well-defined shape be put into a 3D modeling software like FreeCAD?</p>
<p><a ... | <p>For stuff like this, OpenSCAD is your friend. There are several different approaches you could take:</p>
<ol>
<li><p>Generate an image file with grayscale color representing the height of the function on an XY grid, and use the <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surfa... | <p>Not sure what you're asking exactly, but you can use this workflow:</p>
<ol>
<li>SideFX Houdini: math function + STL file generation
<a href="https://i.stack.imgur.com/28jr1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/28jr1.jpg" alt="enter image description here" /></a>
<a href="https://i.stac... | 2,032 |
<p>I have an image (mx) and i want to get the uint of the pixel that was clicked.</p>
<p>Any ideas?</p>
| <p>Here's an even simpler implementation. All you do is take a snapshot of the stage using the <strong>draw()</strong> method of bitmapData, then use <strong>getPixel()</strong> on the pixel under the mouse. The advantage of this is that you can sample anything that's been drawn to the stage, not just a given bitmap.</... | <p>A few minutes on the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html" rel="nofollow noreferrer">BitmapData LiveDoc Page</a> will take you where you need to go. Once you have your image loaded into a Bitmap variable, you can access its BitmapData property. Add a <a h... | 10,427 |
<p>I'm interested in implementing autocomplete in Python. For example, as the user types in a string, I'd like to show the subset of files on disk whose names start with that string. </p>
<p>What's an efficient algorithm for finding strings that match some condition in a large corpus (say a few hundred thousand string... | <p>For exact matching, generally the way to implement something like this is to store your corpus in a <a href="http://en.wikipedia.org/wiki/Trie" rel="noreferrer">trie</a>. The idea is that you store each letter as a node in the tree, linking to the next letter in a word. Finding the matches is simply walking the tr... | <p>The flexibility you want for matching your string is called <em>Fuzzy Matching</em> or <em>Fuzzy Searching</em> . I am not aware of any python implementation (but I haven't looked deeply in the subject) but there are C/C++ implementations that you can reuse, like the <a href="http://laurikari.net/tre/" rel="nofollow... | 47,275 |
<p>I am very curious as to how people write their own obfuscator.</p>
<p>How hard would it be to simply do the following:</p>
<ol>
<li>rename all public methods with GUID type names.</li>
</ol>
<p>Where would I start? How would I go about reading the .net dll assemby, pulling the public methods out and renaming the... | <p>You can check those two projects that are using <a href="http://www.mono-project.com/Cecil" rel="nofollow noreferrer" title="Cecil">Cecil</a> to write an open-source obfuscator:</p>
<ul>
<li><a href="http://code.google.com/p/obfuscar/" rel="nofollow noreferrer">http://code.google.com/p/obfuscar/</a></li>
<li><a hre... | <p>If you're starting with source, it's pretty simple to do text replacements and then run the code through a compiler. If you are starting with a compiled assembly, then you need to use the stuff in the System.Reflection namespace to load the assembly and System.CodeDom to generate compilable code units.</p>
| 43,752 |
<p>I have built a 3D printer from salvaged/purchased parts. I am using an Arduino Uno and three easy driver stepper drivers with 3 CD-ROMs drives and a PC power unit. I ordered a 3D pen and have it mounted with a transistor to switch it on/off. Everything works but when I try to run code that I got from makercam.com it... | <p>Download an stl file from Thingiverse.com </p>
<p>Put your .stl file in a slicer program like cura</p>
<p>It will output gcode for 3d objects rather than 2d.</p>
| <p>I would typically shy away from downloading gcode and printing it directly. Always slice it yourself since, inevitably, every printer is different. What happens if the gcode is setup for ABS (higher temps) and you are printing with PLA? If it's setup for a build platform larger than yours and you just hit endstop... | 712 |
<p>I'm working on something that requires traversing through the file system and for any given path, I need to know how 'deep' I am in the folder structure. Here's what I'm currently using:</p>
<pre><code>int folderDepth = 0;
string tmpPath = startPath;
while (Directory.GetParent(tmpPath) != null)
{
folderDepth+... | <p>Off the top of my head:</p>
<pre><code>Directory.GetFullPath().Split("\\").Length;
</code></pre>
| <p>Maybe someone need also some performance testing...</p>
<pre><code> double linqCountTime = 0;
double stringSplitTime = 0;
double stringSplitRemEmptyTime = 0;
int linqCountFind = 0;
int stringSplitFind = 0;
int stringSplitRemEmptyFind = 0;
string pth = @"D:\dir... | 40,804 |
<p>With multiple developers working on the same Tomcat application, I'd like to tell the application to install to a different path, based on the current user and revision control client/view.</p>
<p>So, if Bob is building, the app should be installed in Bob's test environment, maybe /bob1 or something like that. Bob... | <p>I typically use a variation on the default properties answer already given:</p>
<pre><code><property file="local.properties" />
<property file="default.properties" />
</code></pre>
<p>I read the local properties file first and the default one second. Users don't edit the default one (then accidentally ... | <p>Defining properties with the -D option at the command line is fine, though it can get tedious if there are many of them frequently. In order to resist the urge to wrap the ant invocation in a bash script, there is the common practise to import property files.</p>
<p>In the main build file you put: </p>
<pre><code>... | 34,479 |
<p>I have some source files that have comments written in Japanese. When I open these files in Visual Studio they appear like this:</p>
<pre><code>à–¾FNCAP‰¹—p‚̃XƒŒƒbƒh
</code></pre>
<p>I am using the English version of WinXP, but is there a way to get Visual Studio to display the actual Japanese characters rather t... | <p>Presumably VS is interpreting the file with the wrong encoding.</p>
<p>Reopen it using "File -> Open -> File... -> Open -> Open With... -> Source Code (Text) Editor With Encoding" and try various encodings.</p>
| <p>I faced the same issue and have found a solution that works for me.</p>
<p>The problem is that the files aren't unicode and VS is trying to open them with an encoding that matches your location. Luckily, you can set Windows default behavior for non-unicode files. Check out this link, <a href="http://msdn.microsoft.... | 25,845 |
<p>I had problems with print bed adhesion when using white PLA (Arctic White) but no problems when using other colors. So I tried to print three bottom layers with transparent PLA and all other layers with white PLA. I did not change any setting and printed both tries one after another using the same .stl file.</p>
<p>... | <p>Same G-code slice? The main cause of warping is temperature. If this is kept as a control variable and you have these results, it may be because of a different temperature the filament requires. Check the filament specs and adjust the bed/nozzle temperature to make the temperature difference smaller.</p>
<p>Edit: An... | <p>Problem was displaced by a factory reset of the 3D printer FlashForge Adventurer 3.</p>
<p><a href="https://i.stack.imgur.com/jxS9X.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jxS9X.jpg" alt="Photo of two versions" /></a></p>
<p>Right: white PLA only, left: transparent PLA bottom layers plus w... | 2,047 |
<p>I'm currently having a problem with a ShoppingCart for my customer.</p>
<p>He wants to be able to add Text between the CartItems so I was wondering if there is some way to still only have one List.</p>
<p>My solution would be to have two lists, one of type IList that gets iterated over when calculating Weight and ... | <p>Use an interface:</p>
<pre><code> ICartListItem
</code></pre>
<p>And make your list be:</p>
<pre><code> List<ICartListItem>
</code></pre>
<p>Now, create several types, have all of them implement this interface, and you can store them all safely in your list.</p>
<p>Alternatively, if you want there to be s... | <p>The Interface sounds like overkill. I'd just add a property to your current CartItem named something like "TextAfterItem".</p>
<p>Also: make sure your customer understands the cost of this feature in terms of security overhead. It sounds like they think this should be a simple update, but you're allowing users to... | 40,977 |
<p>I have a given certificate installed on my server. That certificate has valid dates, and seems perfectly valid in the Windows certificates MMC snap-in.</p>
<p>However, when I try to read the certificate, in order to use it in an HttpRequest, I can't find it. Here is the code used:</p>
<pre><code> X509Store stor... | <p>Try verifying the certificate chain using the <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509chain.aspx" rel="noreferrer">X509Chain</a> class. This can tell you exactly why the certificate isn't considered valid.</p>
<p>As erickson suggested, your X509Store may no... | <p>I believe x509 certs are tied to a particular user. Could it be invalid because in the code you are accessing it as a different user than the one for which it was created?</p>
| 12,355 |
<p>When I try to use <code>curl</code> or <code>file_get_contents</code> to read something like <a href="http://example.com/python/json/" rel="nofollow noreferrer">http://example.com/python/json/</a> from <a href="http://example.com/" rel="nofollow noreferrer">http://example.com/</a> I should be getting a JSON response... | <p>It looks like example.com is not the default domain for the IP address and that file_get_contents uses HTTP/1.0 instead of HTTP/1.1 and/or does not send a Host: header. Try the curl support in PHP instead:</p>
<pre><code>$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://example.com/');
curl_setopt($curl,... | <p>Something to do with the domain, maybe? Of course, you don't want to reveal it here, so you might have a bit to do, but I guess the sanity check would be that you can access that URL via a web browser (or command line tool such as GET if you're command-line only).</p>
<p>You could also just ping and/or traceroute t... | 31,290 |
<p>I own a DIY Hypercube Evolution equipped with Tevo Titan extruder, Clone Chimera hotend and Capricorn's High-temp PTFE tube. I use RAMPS with Mega and A4988's.</p>
<p>During prints, my extruder motor randomly clicks. I touched the filament and during the clicks I'ven't felt any problems with extrusion. I looked at ... | <p>Even though you may have acceptable extrusion, any clicking from that area of your printer is likely to be a missed step on the extruder motor. This may be insignificant with respect to print quality, but as you suggest, it is an irritation.</p>
<p>If you are confident that your nozzle is clean of debris (which is ... | <p>Even though you may have acceptable extrusion, any clicking from that area of your printer is likely to be a missed step on the extruder motor. This may be insignificant with respect to print quality, but as you suggest, it is an irritation.</p>
<p>If you are confident that your nozzle is clean of debris (which is ... | 971 |
<p>I'm working in .Net 3.5sp1 in C# for an ASP.Net solution and I'm wondering if there's any way to turn on the Class Name and Method Name drop-downs in the text editor that VB.Net has at the top. It's one of the few things from VB that I actually miss.</p>
<p>Edit: Also, is there any way to get the drop downs to be p... | <p>Go To:</p>
<pre><code>Tools -> Options -> Text Editor -> C# -> General -> Navigation Bar
</code></pre>
<p>Make sure it is clicked, and that should show something at the top of your code that has all the classes and methods listed in your file.</p>
| <p>note that the lists don't fill in until the cursor is within the namespace/class</p>
| 19,259 |
<p>In toad, I can see unicode characters that are coming from oracle db. But when I click one of the fields in the data grid into the edit mode, the unicode characters are converted to meaningless symbols, but this is not the big issue.</p>
<p>While editing this field, the unicode characters are displayed correctly as... | <p>You just need to add a public method for invoking the event. Microsoft already does this for some events such as <em>PerformClick</em> for controls that expose a <em>Click</em> event.</p>
<pre><code>public class CustomGUIElement
{
public void PerformClick()
{
OnClick(EventArgs.Empty);
}
... | <p>You really should wrap the code you want to be able to execute from the outside in a method. That method can then do whatever your event would do - and that event would also instead call that method.</p>
| 13,335 |
<p>We have a project consisting of multiple subprojects. With each subproject we potentially have some hibernate mapping files but in the end only <strong>one actual hibernate session</strong>. Those subprojects could be combined in several ways, some depend on each other. My problem is that actually I want to have a S... | <p>Another (and simpler) approach would be to gather all your model classes in one project. Make all your other projects depend on it and have your SessionFactory created there. That is how I managed to solve the same problem and it works pretty well.</p>
| <p><code>LocalSessionFactoryBean</code> has a configLocations property. You inject the list of config locations, and it will gather tham together for a single session factory configuration.</p>
| 19,034 |
<p>I'm trying to wrap my head around how to search for something that appears in the middle of a word / expression - something like searching for "LIKE %book% " - but in SQL Server (2005) full text catalog.</p>
<p>How can I do that? It almost appears as if both <code>CONTAINS</code> and <code>FREETEXT</code> really do... | <p>unfortunately CONTAINS only supports prefix wildcards:</p>
<pre><code>CONTAINS(*, '"book*"')
</code></pre>
| <p>why don't program an assembly in C# to compute all the non repeated sufixes. For example if you have the Text "eat the red meat" you can store in a field "eat at t the he e red ed d meat" (note that is not necesary to add eat at and t again) ind then in this field use full text search. A function for doing that can ... | 37,727 |
<p>When a webpage has moved to a new location, how do I show the moved web page AND return a 301 permanent redirect HTTP response status code in <a href="http://djangoproject.com/" rel="nofollow noreferrer">Django</a>?</p>
| <pre><code> from django import http
return http.HttpResponsePermanentRedirect('/yournewpage.html')
</code></pre>
<p>the browser will get the 301, and go to <code>/yournewpage.html</code> as expected. the other answer is technically correct, in that python is not handling the redirection per se, the browser is. t... | <p>You can't.</p>
<p>301 is an HTTP return code that is directly acted upon by the browser. Many sites handle these two issues by first sending the user to a redirect-er page that tells the user about the change and then X seconds later sends them to the new page. But the redirect-er page <em>must</em> have a 200 code... | 34,838 |
<p>We recently installed SVN 1.5.2 (with VisualSVN/Apache) on some of our servers / virtual machines, and now when I send a commandline command with username/password they don't get cached anymore.
Before, we were running SVN 1.5.0 installed with CollabNet, on svn://, and the credentials were cached after the first com... | <p>AFAIK the credential caching is a client responsibility. All the server does is ask for those credentials when necessary. I'd check the local client configuration files and maybe see what happens with different version clients.</p>
| <p>Are you fully qualifying the domain name of the SVN server? If the caching for HTTP is cookie based and the server is writing a cookie with the FQDN, but your request doesn't use the FQDN (you are using svnserver and the FQDN is svnserver.company) then the cookie may not be valid and each request will need authentic... | 18,385 |
<p>What are the differences between a wiki and a CMS? Is there any?</p>
| <p><strong>CMS:</strong></p>
<ol>
<li>A CMS focuses on <strong>content</strong> which is then published through standardized templates -- think of an online newspaper as driven by a huge CMS system. </li>
<li>It's about standardized <strong>publishing information</strong>. </li>
<li>CMS'es usually have a <strong>limi... | <p>A CMS is a <strong>Content Management System</strong>. The idea behind the development of CMS evolved when the need for a Management System amplified. A CMS works as a cornerstone for web development by the help of which a developer can build powerful and feature-rich websites in minimum amount of time and effort. A... | 27,957 |
<p>In java, which regular expression can be used to replace these,
for example:</p>
<p>before:
aaabbb
after:
ab</p>
<p>before:
14442345
after:
142345</p>
<p>thanks!</p>
| <p>In perl</p>
<pre><code>s/(.)\1+/$1/g;
</code></pre>
<p>Does the trick, I assume if java has perl compatible regexps it should work too.</p>
<p>Edit: Here is what it means</p>
<pre><code>s {
(.) # match any charater ( and capture it )
\1 # if it is followed by itself
+ # One or more times
}{$1}... | <p>in TextEdit (assuming posix expressions)
find: [a]+[b]+
replace with: ab</p>
| 13,158 |
<p>Do you normally set your compiler to optimize for maximum speed or smallest code size? or do you manually configure individual optimization settings? Why?</p>
<p>I notice most of the time people tend to just leave compiler optimization settings to their default state, which with visual c++ means max speed.
I've alw... | <p>As a Gentoo user I have tried quite a few optimizations on the complete OS and there have been endless discussions on the <a href="http://forums.gentoo.org/" rel="noreferrer">Gentoo forums</a> about it. Some good flags for GCC can be found in the <a href="http://gentoo-wiki.com/Safe_Cflags" rel="noreferrer">wiki</a>... | <p>We always use maximize for optimal speed but then, all the code I write in C++ is somehow related to bioinformatics algorithms and speed is crucial while the code size is relatively small.</p>
| 7,739 |
<p>In Pseudo code</p>
<pre><code>If Domain inList(GB,US,ES,FR Then
Print This Html
Else
Print This HTML
EndIf
</code></pre>
| <p>This is a<em>very</em> general form, but where you don't know the list at design-time, so long as you can get a reference to a nodeset which represents the list you can do a simple test like:</p>
<pre><code><xsl:when test="$listset/item[@property=$variable]">
</code></pre>
<p>where say $variable = /foo/bar/@... | <p>If you are using XSLT 2.0 given the file
</p>
<p>You can use something like this:<br>
<code>
<xsl:template match="list/item"><br>
Property [<xsl:value-of select="@property"/>] html<br>
</xsl:template><br>
<br>
<xsl:template match="list/item[some $x in ('us', 'gb') ... | 48,587 |
<p>Is it better to do this:</p>
<pre><code>try
{
...
}
catch (Exception ex)
{
...
throw;
}
</code></pre>
<p>Or this:</p>
<pre><code>try
{
...
}
catch (Exception ex)
{
...
throw ex;
}
</code></pre>
<p>Do they do the same thing? Is one better than the other?</p>
| <p>You should always use the following syntax to rethrow an exception. Else you'll stomp the stack trace:</p>
<pre><code>throw;
</code></pre>
<p>If you print the trace resulting from <code>throw ex</code>, you'll see that it ends on that statement and not at the real source of the exception.</p>
<p>Basically, it should... | <p>It depends. In a debug build, I want to see the original stack trace with as little effort as possible. In that case, "throw;" fits the bill.</p>
<p>In a release build, however, (a) I want to log the error with the original stack trace included, and once that's done, (b) refashion the error handling to ma... | 21,506 |
<p>I was just wondering if anyone knew of a good way that I could parse the file at the bottom of the post.</p>
<p>I have a database setup with the correct tables for each section eg Refferal Table,Caller Table,Location Table. Each table has the same columns that are show in the file below</p>
<p>I would really like ... | <p><a href="http://www.google.com/search?client=safari&rls=en-us&q=parse+.ini+vb+.net&ie=UTF-8&oe=UTF-8" rel="nofollow noreferrer">Google has the answers</a>, once you know that the file-format is called '.ini'</p>
<p><strong>Edit:</strong> That is, it's an .ini plus some extra leading/trailing gunk.</... | <pre><code>Using f As StreamReader = File.OpenText("sample.txt")
Dim g As String = "undefined"
Do
Dim s As String = f.ReadLine
If s Is Nothing Then Exit Do
s = s.Replace(Chr(9), " ")
If s.StartsWith("[") And s.EndsWith("]") Then
g = s.Substring("[".Length, s.Length - ... | 19,468 |
<p>I'm setting up CI at present using Thoughtworks Studios' Cruise, Gallio to run xunit.net fact/tests, and ncover 2 to do code-coverage.</p>
<p>I noticed that running the code-coverage pegs one of the four CPUs that our build-agent server has, and wondered whether there was a multi-threaded test-runner that I might u... | <p>Gallio <a href="http://code.google.com/p/mb-unit/issues/detail?id=355" rel="nofollow noreferrer">implements</a> parallel test execution.</p>
| <p>If nothing else, I know that in CruiseControl.NET, you could multiple two operations run simultaneously. I would think the same would be true for Cruise. You could have four instances of run on 1/4 of your tests each, and then stitch the results back together. Knowing when to merge them may be difficult though.</p... | 36,080 |
<p>I'm having a problem with a POST I'm doing using the HttpWebRequest object from C#. In order to analyze the problem I would like to know exactly what is being sent over the wire. The problem is that I'm also using HTTPS so I can't sniff the wire. I need some way of printing out to the Console all the relevant inform... | <p>You can use <a href="http://www.fiddler2.com/fiddler2/" rel="noreferrer">Fiddler</a> to debug HTTPS traffic.</p>
| <p>Could you set a breakpoint in the code and look at the Request object in the debugger and look through the ServerVariables collections to see what it has? Alternatively, you could do a Response.Write looping over each element in the Request.ServerVariables and see the name/value pairs that are stored in a web page ... | 40,631 |
<p>Tk GUI's seem to be universally considered ugly, but I'd like to know why specifically. Some in the Tcl/Tk world would argue that this is a moot point as there is much better support now for native look and feel, which is a big reason I decided on Tcl/Tk. Now, however, the problem is, because I'm leveraging a Tcl... | <p>I think part of the reason is that Tk is surprisingly powerful and easy to use but it doesn't do much hand-holding. Since it is so easy, people with little experience in UI design can get something to work in very short order. But, without a lot of experience they rely on defaults and shortest-path-to-a-solution (re... | <p>Tk is beautiful or not, it depends on the person but I would say that its atleast not ugly (except for android). Have a look at the screenshots of a program I made using pure python and tkinter (Tk). You just need to know how to use it in more beautiful manner.<img src="https://i.stack.imgur.com/inPgJ.png" alt="ente... | 45,465 |
<p>I have a page with a tab control and each control has almost 15 controls. In total there are 10 tabs and about 150 controls in a page (controls like drop down list, textbox, radiobutton, listbox only).</p>
<p>My requirement is that there is a button (submit) at the bottom of the page. I need to check using JavaScri... | <p>Assuming there's only one form on the page (if more then loop through forms and nest the below loop within).</p>
<pre><code> var selectedCount = 0;
var element;
for (var i = 0; i < document.forms[0].elements.length; i++)
{
element = document.forms[0].elements[i];
switch (element.type)
{
... | <p>I would look at something based on the prototype <a href="http://www.prototypejs.org/api/form#method-serializeelements" rel="nofollow noreferrer">serialize</a> method - it can give you a hash of all form controls - it might give you a headstart on what you want. </p>
<p>Something like firebug will help you see wha... | 22,648 |
<p>I have a string which is like this:</p>
<pre><code>this is "a test"
</code></pre>
<p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p>
<pre><code>['this', 'is', 'a test']
</code></pre>
<p>PS. I know you are going to ask &... | <p>You want <code>split</code>, from the built-in <a href="https://docs.python.org/library/shlex.html" rel="noreferrer"><code>shlex</code></a> module.</p>
<pre><code>>>> import shlex
>>> shlex.split('this is "a test"')
['this', 'is', 'a test']
</code></pre>
<p>This should do exactly what you... | <p>Try this:</p>
<pre><code> def adamsplit(s):
result = []
inquotes = False
for substring in s.split('"'):
if not inquotes:
result.extend(substring.split())
else:
result.append(substring)
inquotes = not inquotes
return result
</code></pre>
<p>Some test strings:</p>
... | 10,542 |
<p>How can I detect, using php, if the machine has oracle <code>(oci8 and/or pdo_oci)</code> installed?</p>
<p>I'm working on a <code>PHP</code> project where some developers, such as myself, have it installed, but there's little need for the themers to have it. How can I write a quick function to use in the code so ... | <p>if the oci extension isn't installed, then you'll get a fatal error with farside.myopenid.com's answer, you can use function_exists('oci_connect') or extension_loaded('oci8') (or whatever the extension's actually called)</p>
| <p>I dont know if I fully understand your question but a simple way would be to do this:</p>
<pre><code><?php
$connection = oci_connect('username', 'password', 'table');
if (!$connection) {
// no OCI connection.
}
?>
</code></pre>
| 13,666 |
<p>On my reading spree, I stumbled upon something called <a href="http://en.wikipedia.org/wiki/Intentional_programming" rel="noreferrer">Intentional Programming</a>.
I understood it somewhat, but I not fully. If anyone can explain it in better detail, please do. Is it being used in any real application?</p>
| <p>You got me started on this one...<br>
Looks like C. Simonyi wanted to step to the next level of abstraction from High level languages. Reduce the dependency of customers on developers to make every change.. in code (cryptic for people not in development).
So he invents this new product called IP, which has <strong>a... | <p>It's where you intend to program, you don't just accidently do it. ;)</p>
| 24,588 |
<p>I'm starting on a project that I expect will include a substantial amount of non-Java code (mostly shell and SQL scripts).</p>
<p>I would still like to manage this project with Maven. What are the best practices wrt non-Java source code and Maven? Where should the source go? What happens to them during the differen... | <p>You must not put the non-Java code into resources, if you don't want to include these files into your JAR files like heckj has suggested. Everything that is located in resources is automatically copied into the JAR file and I guess you don't want shell scripts and SQL scripts be included in a JAR file, right?</p>
<... | <p>I keep in a separate folder src/main/sql. Check <a href="http://maven.apache.org/pom.html#Resources" rel="nofollow">this</a> link for more info.</p>
| 20,985 |
<p>Is there a master list of the Big-O notation for everything? Data structures, algorithms, operations performed on each, average-case, worst-case, etc.</p>
| <p><a href="http://xlinux.nist.gov/dads/" rel="nofollow noreferrer">Dictionary of Algorithms and Data Structures</a> is a fairly comprehensive list, and includes complexity (Big-O) in the algorithms' descriptions. If you need more information, it'll be in one of the linked references, and there's always Wikipedia as a... | <p><a href="http://mitpress.mit.edu/algorithms/" rel="nofollow noreferrer">Introduction to Algorithms, Second Edition</a>, aka CLRS (Cormen, Leiserson, Rivest, Stein), is the closest thing I can think of.</p>
<p>If that fails, then try <a href="http://www-cs-faculty.stanford.edu/~knuth/taocp.html" rel="nofollow norefe... | 21,778 |
<p>Is there a method (other than trial and error) I can use to find unused image files? How about CSS declarations for ID's and Classes that don't even exist in the site?</p>
<p>It seems like there might be a way to write a script that scans the site, profile it, and see which images and styles are never loaded.</p>
| <p>You don't have to pay any web service or search for an addon, you already have this in Google Chrome under F12 <code>(Inspector)->Audits->Remove unused CSS rules</code></p>
<p>Screenshot:<img src="https://i.stack.imgur.com/Soozt.png" alt="Screenshot"></p>
<p><strong>Update: 30 Jun, 2017</strong></p>
<p>Now ... | <p>This little tool gives you a list of the css rules in use by some html.</p>
<p>Here it is on <a href="http://codepen.io/tmorrow-hyphensolutions/pen/GprdRQ" rel="nofollow">Code Pen</a></p>
<p>Click on <kbd>Run code snippet</kbd>, then click on <kbd>Full page</kbd> to get in to it. Then follow the instructions in th... | 5,326 |
<p>In C++, what is the purpose of the scope resolution operator when used without a scope? For instance:</p>
<pre><code>::foo();
</code></pre>
| <p>It means global scope. You might need to use this operator when you have conflicting functions or variables in the same scope and you need to use a global one. You might have something like:</p>
<pre><code>void bar(); // this is a global function
class foo {
void some_func() { ::bar(); } // this functi... | <p>referring to the global scope</p>
| 10,083 |
<p>I'm using Castle Windsor to do some dependency injection, specifically I've abstracted the DAL layer to interfaces that are now being loaded by DI.</p>
<p>Once the project is developed & deployed all the .bin files will be in the same location, but for while I'm developing in Visual Studio, the only ways I can ... | <p>Could you set the build output path of the concrete DAL project to be the bin folder of the dependent project? </p>
| <p>Mike: Didn't think of that, that could work, have to remember to turn off copy-local for any libraries / projects that are common between them</p>
| 5,156 |
<p>Can I use the ClickOnce deployment method to deploy and auto update applications targeted for the windows mobile platform (eg smartphone or pocket pc)?</p>
| <p>True Click-Once is not supported. You might look at these articles to give you a better feel for what can be done:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa446503.aspx" rel="noreferrer">MSDN Article on Deployment Patterns</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa446487... | <p>No. Hopefully in the future.</p>
| 14,222 |
<p>I've got the following user control:</p>
<pre><code><TabItem
x:Name="Self"
x:Class="App.MyTabItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:app="clr-namespace:App"
>
<TabItem.Header>
... | <p>What appears to be the problem is that you are using a ContentTemplate without actualy using the content property. The default DataContext for the ContentTemplate's DataTemplate is the Content property of TabItem. However, none of what I said actually explains <strong>why</strong> the binding doesn't work. Unfortuna... | <p>Try this. I'm not sure if it will work or not, but </p>
<pre><code><TabItem
x:Name="Self"
x:Class="App.MyTabItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:app="clr-namespace:App"
>
<TabItem.Co... | 17,914 |
<p>I am working on a .NET application that displays multiple charts. My users would like an easy way to say "take chart #3 and maximize it on my fourth monitor".</p>
<p>How can I determine the number of monitors so I can give them a selection of "monitor #1, monitor #2, etc"? (Not every user has the same number of m... | <p>The <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx" rel="nofollow noreferrer">Screen</a> class helps you a lot by finding the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.allscreens.aspx" rel="nofollow noreferrer">available screens</a>.</p>
<p>When ... | <p>Try the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx" rel="nofollow noreferrer">Screen</a> class in System.Windows.Forms. The <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.allscreens.aspx" rel="nofollow noreferrer">AllScreens</a> static member conta... | 24,592 |
<p>I have an asp page that uses jQuery ajax to load member counts into a bunch of <code>div</code>s after a page is loaded.</p>
<p>It works perfectly well in FireFox, and with clients that have a small number of groups.</p>
<p>For the small number of clients that have many groups (500+), I am getting an error in IE. ... | <pre><code>int getNextDay(int days_mask, int today) {
if (!days_mask) return -1; // no days set
days_mask |= days_mask << 7; // duplicate days into next week
mask = 1 << (today % 7); // keep track of the day
while (!(mask & days_mask)) {
mask <<= 1;
++today;
}
return ... | <p>I understand your question this way:</p>
<pre><code>// returns t (today) if no weekday is set in the mask.
int getNextDay(int m, int t) {
int i, idx;
for(i = 0, idx=t%7; i<7 && !((1<<idx)&m); i++, idx=(idx+1)%7)
/* body empty */ ;
return (i == 7) ? t : (idx + 1);
}
// getNe... | 45,742 |
<p>In my code behind I wire up my events like so:</p>
<pre><code>protected override void OnInit(EventArgs e)
{
base.OnInit(e);
btnUpdateUser.Click += btnUpateUserClick;
}
</code></pre>
<p>I've done it this way because that's what I've seen in examples. </p>
<ul>
<li>Does the base.OnInit() method need to be c... | <p>I should clarify:</p>
<p>The guidelines recommend that firing an event should involve calling a virtual "On<em>EventName</em>" method, but they also say that if a derived class overrides that method and forgets to call the base method, the event should still fire.</p>
<p>See the "Important Note" about halfway down... | <p>In this case, if you don't call the base OnInit, then the Init even will not fire.</p>
<p>In general, it is best practice to ALWAYS call the base method, unless you specifically know that you do not want the base behaviour to occur.</p>
<p>Whether its called at the start or the end depends on how you want things t... | 3,972 |
<p>I often find linq being problematic when working with custom collection object.
They are often defened as</p>
<p>The base collection</p>
<pre><code>abstract class BaseCollection<T> : List<T> { ... }
</code></pre>
<p>the collections is defined as</p>
<pre><code>class PruductCollection : BaseCollection... | <p>The problem is that LINQ, through extension methods on <code>IEnumerable<T></code>, knows how to build Arrays, Lists, and Dictionaries, it doesn't know how to build your custom collection. You could have your custom collection have a constructor that takes an <code>IEnumerable<T></code> or you could writ... | <p>Could this work with a BindingList ? as BindingList does not have a constructor which would take an IEnumerable but does implement it.</p>
<p>BindingList : Collection, IBindingList, IList, ICollection, IEnumerable, ICancelAddNew, IRaiseItemChangedEvents</p>
| 48,506 |
<p>I use several referenced tables with integer primary keys. Now I want to change ints to GUIDs leaving all references intact. What is the easiest way to do it?</p>
<p>Thank you!</p>
<p><strong>Addition</strong></p>
<p>I do understand the process in general, so I need more detailed advices, for example, how to fill... | <ul>
<li>Create a new column for the guid
value in the master table. Use the
uniqueidentifier data type, make it
not null with a newid() default so
all existing rows will be populated.</li>
<li>Create new uniqueidentifier columns
in the child tables.</li>
<li>Run update statements to build the guild relationships using... | <p>I think, you must do it manualy. Or you can write some utility for it. The scenario should be:</p>
<ul>
<li>Duplicate the "int" PK/FK columns with new "guid" columns.</li>
<li>Generates new values for "guid" PK columns.</li>
<li>Update values in "guid" FK columns with specified values ( you find the records via "in... | 16,725 |
<p>Anyone have an idea of what this means for MS SQL Server? I'm also calling this from ColdFusion, although I'm guessing that doesn't make any difference.</p>
| <p>Google implies that error 193 is a problem with the service. Does this happen for every query, or just one? Can you connect from SQL Management Studio?</p>
| <p>Are you using custom JDBC driver? Try the one that comes with CF.</p>
| 27,063 |
<p>I'd like to inspect the content of a file before it is uploaded to the SharePoint doc library.<br>
I hooked up a handler to the <code>ItemAdding()</code> event but don't know how to get the content of the file.<br>
Note: I know that in the <code>ItemAdded()</code> I can use <code>properties.ListItem.File</code> but ... | <p>Yes, the file has not been created at this point.</p>
<p>Try using the properties.AfterProperties or properties.BeforeProperties. </p>
<p>Edit: It is only <em>after</em> the file has been added that the lists properties are created.
SharePoint will add the defaults for the list metadata to the file (Office 2007 on... | <p>No you can't.<br>
During ItemAdding, you have access to document/item properties as Nat said, but you don't have access to file content. </p>
| 32,496 |
<p>I am using VS2005 VC++ for unmanaged C++. I have VSTS and am trying to use the code coverage tool to accomplish two things with regards to unit tests:</p>
<ol>
<li>See how much of my referenced code under test is getting executed</li>
<li>See how many methods of my code under test (if any) are not unit tested at al... | <p>You could try adding a line of code to call the function only if some condition is true, and guarantee that that condition will never be true. Just make sure the compiler can't figure that out. For example,</p>
<pre><code>
int main(int argc, char **argv)
{
if(argv == NULL) // C runtime says this won't happen
... | <p>Turn off inlining of functions. The easiest way to do this is to just compile in Debug mode.</p>
<p><strong>Edit:</strong> after seeing your clarification, I find my answer is in error. Perhaps if you moved the body of the function into another section of the .h file, using the "inline" keyword?</p>
| 13,052 |
<p>I'm trying to add a publisher policy file to the gac as per this <a href="https://stackoverflow.com/questions/283419/how-to-just-load-the-latest-version-of-dll-from-gac">thread</a> but I'm having problems when I try and add the file on my test server. </p>
<p>I get "A module specified in the manifest of assembly '... | <p>Wow - ok got it.</p>
<p>I should have paid more attention to exactly what this meant </p>
<p><a href="http://msdn.microsoft.com/en-us/library/dz32563a.aspx" rel="nofollow noreferrer">(MSDN) How to: Create a Publisher Policy</a></p>
<blockquote>
<p>Important Note: The publisher policy
assembly cannot be added... | <p>To add policy assemblies to the GAC using Wise, you do the same thing as you do to add the assembly the policy is for. So you add the policy assembly to the "Global Assembly Cache" in Wise, and as long as you have the policy file (.config) in the same location on the machine, Wise will automatically add it to GAC a... | 38,804 |
<p>Is there any way to create a ODBC DSN with C#?</p>
<p>Maybe a P/invoke?</p>
| <p>You can use Registry classes to write the dsn info in the registry, under</p>
<pre><code>HKLM\Software\ODBC\ODBC.INI\ODBC Data Sources
</code></pre>
<p>You'll need to check what values are needed for you ODBC driver.</p>
| <p>Following resources might be helpful:</p>
<p>MSDN:</p>
<p><a href="http://support.microsoft.com/kb/310988" rel="nofollow noreferrer">How To Use the ODBC .NET Managed Provider in Visual C# .NET and Connection Strings</a></p>
<p>CodeProject.com</p>
<p><a href="http://www.codeproject.com/KB/database/sdbODBCMngr.asp... | 11,794 |
<p>I have a Tab Control with multiple Tab Pages. I want to be able to fade the tabs back and forth. I don't see an opacity option on the Tab Controls. Is there a way to cause a fade effect when I switch from one Tab Page to another?</p>
| <p>There is no magic Fade switch in the standard windows control.</p>
<p>You could dump the content of the tab to a bitmap (using <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx" rel="nofollow noreferrer">DrawToBitmap</a> or <a href="http://msdn.microsoft.com/en-us/libra... | <p>Depending on how your tabs/page work, you may be able to handle it at the page level by adding meta tags to the page:</p>
<pre><code><meta http-equiv="Page-Enter" content="blendTrans(Duration=0)">
<meta http-equiv="Page-Exit" content="blendTrans(Duration=0)">
</code></pre>
<p>Just change the duration t... | 30,807 |
<p>According to Wikipedia, on the Comparison of programming languages page, it says that F# uses CLI. Does that mean that F# is designed for the purpose of making command-line applications and not graphical applications, or is there another meaning of CLI?</p>
| <p>in .NET it's the Common Language Infrastructure.</p>
<p><a href="http://en.wikipedia.org/wiki/Common_Language_Infrastructure" rel="noreferrer">http://en.wikipedia.org/wiki/Common_Language_Infrastructure</a></p>
| <p>Customer Loyalty Initiative - several companies use this to index themselves against their peers for improving/encouraging repeat business.</p>
<p>More items listedon Acronym Finder: <a href="http://www.acronymfinder.com/CLI.html" rel="nofollow noreferrer">http://www.acronymfinder.com/CLI.html</a></p>
| 21,657 |
<p>Imagine a .NET application designed using a Layered architecture.</p>
<p>Is it possible to use something like the <a href="http://msdn.microsoft.com/en-us/library/aa480587.aspx" rel="nofollow noreferrer">trusted subsystem</a> pattern when deploying all layers of an application to the same machine?</p>
<p>Is this d... | <p>It depends on how you're using the system and how your layers are deployed. </p>
<p>Let's say you have a machine where SQL Server is running in under one user account, your service layer is under another service account, and your users log in using a third account (without admin access, of course). Say the middle... | <p>If all layers are deployed in the same process, then I'd say almost by definition you aren't using the trusted subsystem model.</p>
<p>You could (at least in theory) deploy different layers to the same physical machine while still using the trusted subsystem model, but of course it would be harder to guarantee the ... | 45,253 |
<p>I have developed a simple page using JQuery. It works fine in almost all browsers (i.e. Firefox, IE, Chrome) but whenever the page is opened in IE, it prompts Javascript error like,</p>
<pre><code>'guid' is null or not an object on line 1834
</code></pre>
<p>Do you have any idea ?</p>
| <p>Thanks guys for your messages.</p>
<p>The error was on my part. For hover event, I was not passing function for "out". Therefore the handler was passed as undefined in jQuery.event function and that causing error for statement ,</p>
<p>if ( !handler.guid )</p>
<p>written at 1834 line of jquery-1.2.6.js file.</p>
... | <p>Maybe you're using the parentNode or parentElement property? There are some issues with that in IE vs other browsers.</p>
| 9,656 |
<p>I wish to ensure a user has access to an aspx page by 'Zone'. For example, "Financials" is a Security Zone which some users should not have access to.</p>
<p>The result should not involve patterns such as MVP, MVC, MVVM, etc. I'm looking for something that's light and quick to do.</p>
<p>To make things easier I ha... | <p>I've used this, whether it's the best way is seriously questionable. I have a class I derive from Page, called SecurePage. In that I usually have a cross table in a database that lists objects, such as the page, and groups/users that have access to that page. Running a stored procedure using the UserID and the Ob... | <p>Why not just use the security features such as forms authentication built into .NET? It's very easy.</p>
| 25,274 |
<p>Given the Marlin Firmware what is the difference between the following lines of code:</p>
<blockquote>
<p>G4 S20</p>
</blockquote>
<p>and</p>
<blockquote>
<p>G4 P2000</p>
</blockquote>
| <p>The answer is that <strong><em>it depends on the type of firmware</em></strong> you are using.</p>
<p>Let us look at the documentation of <a href="https://reprap.org/wiki/G-code#G4:_Dwell" rel="nofollow noreferrer"><code>G4</code></a> to find that <code>G4</code> is valid for all the listed firmware types:
<a href=... | <p>The code <code>G4</code> refers to <em>dwell</em>. (From what I'm seeing, it can be written as either <code>G4</code> or <code>G04</code>). <code>P</code>is the length of dwell time, usually in milliseconds. The parameter <code>S</code> seems to be invalid, because the only inputs are <code>X</code> (seconds), <code... | 1,092 |
<p>In Ruby, I'm trying to do the following.</p>
<pre><code>def self.stats(since)
return Events.find(:all, :select => 'count(*) as this_count', :conditions => ['Date(event_date) >= ?', (Time.now - since)]).first.this_count
end
</code></pre>
<p>where "since" is a string representing an amount of time ('1 hou... | <p>I hacked this together with the ActiveSupport gem:</p>
<pre><code>require 'active_support'
def string_to_date(date_string)
parts = date_string.split
return parts[0].to_i.send(parts[1])
end
sinces = ['1 hour', '1 day', '3 days']
sinces.each do |since|
puts "#{since} ago: #{string_to_date(since).ago(Time.now)... | <p>I agree with <a href="https://stackoverflow.com/a/40580/1933902">John Millikin</a>. <a href="http://chronic.rubyforge.org/" rel="nofollow noreferrer">Chronic</a>, or even your own helpers, would be a much lighter and effective dependency to carry than whole ActiveSupport, assuming you are not already trapped inside ... | 6,180 |
<p>Short version: I'm wondering if it's possible, and how best, to utilise CPU specific
instructions within a DLL?</p>
<p>Slightly longer version:
When downloading (32bit) DLLs from, say, Microsoft it seems that one size fits all processors.</p>
<p>Does this mean that they are strictly built for the lowest common den... | <p>I don't know of any <em>standard</em> technique but if I had to make such a thing, I would write some code in the DllMain() function to detect the CPU type and populate a jump table with function pointers to CPU-optimized versions of each function.</p>
<p>There would also need to be a lowest common denominator func... | <p>An easy way to get the SSE/SSE2 optimizations is to just use the <code>/arch</code> argument for MSVC. I wouldn't worry about fallback--there is no reason to support anything below that unless you have a very niche application.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/7t5yh4fd.aspx" rel="nofollow no... | 15,927 |
<p>Using SQL Server - which is the fastest or best practice method to use for date retrieval? Is there a difference?</p>
| <p><code>CURRENT_TIMESTAMP</code> is standard ANSI SQL, and so is theoretically one tiny little island of 'don't need to change' amongst your thousands of SQL Server-specific lines of SQL if you ever need to move databases....</p>
| <p>Books Online tells us that <code>CURRENT_TIMESTAMP</code> "is equivalent to <code>GETDATE()</code>".</p>
| 22,579 |
<p>I'e been programming Java forever, but have been away from it for a while. Can anyone recommend a really good Java reference, where "really good" is defined by "Good coverage of the language, detailed coverage of recent extensions, and written for the technical reader (not a "for Dummies" sort of book)"?</p>
| <p>As well as references saying what has changed in the languages (which other answers already cover better than I could) I can't recommend highly enough the <a href="https://rads.stackoverflow.com/amzn/click/com/0321356683" rel="noreferrer" rel="nofollow noreferrer">Second edition of Effective Java by Joshua Bloch</a>... | <p>i've always liked cay horstmann's books: <a href="http://www.horstmann.com/corejava.html" rel="nofollow noreferrer">http://www.horstmann.com/corejava.html</a>. these are 8'th editions. and there is gosling's <a href="http://java.sun.com/docs/books/javaprog/" rel="nofollow noreferrer">http://java.sun.com/docs/books/j... | 39,129 |
<p>How can I construct the following string in an Excel formula:</p>
<blockquote>
<p>Maurice "The Rocket" Richard</p>
</blockquote>
<p>If I'm using single quotes, it's trivial: <code>="Maurice 'The Rocket' Richard"</code> but what about double quotes?</p>
| <p>Have you tried escaping with an additional double-quote? By escaping a character, you are telling Excel to treat the " character as literal text.</p>
<pre class="lang-sql prettyprint-override"><code>= "Maurice ""The Rocket"" Richard"
</code></pre>
| <p>There is another way, though more for " How can I construct the following string in an Excel formula: "Maurice "The Rocket" Richard" " than " How to create strings containing double quotes in Excel formulas? ", which is simply to use two single quotes:</p>
<p><a href="https://i.stack.imgur.com/WCRke.jpg" rel="nofol... | 26,629 |
<p>We need to send email which contains Pound (currency) symbols in ColdFusion. Before sending email, we are dumping the data into a html file for preview. </p>
<ol>
<li>How to send a email with utf-8 encoding in ColdFusion</li>
<li>How to save a file with utf-8 encoding in ColdFusion</li>
</ol>
| <p>E-Mails are sent in the encoding that is specified in the ColdFusion Administrator. For ColdFusion MX (6.0) and up this is UTF-8 by default.</p>
<p>You can explicitly mention the encoding like this, but it should not be necessary.</p>
<pre><code><cfmail type="text/html; Charset=UTF-8" ...><!--- body ---&g... | <p>Try adding <code><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></code> in the <code><head></code> tag of your html file.</p>
| 44,141 |
<p>I've got many, many mp3 files that I would like to merge into a single file. I've used the command line method</p>
<pre><code>copy /b 1.mp3+2.mp3 3.mp3
</code></pre>
<p>but it's a pain when there's a lot of them and their namings are inconsistent. The time never seems to come out right either.</p>
| <p>As Thomas Owens pointed out, simply concatenating the files will leave multiple ID3 headers scattered throughout the resulting concatenated file - so the time/bitrate info will be wildly wrong.</p>
<p>You're going to need to use a tool which can combine the audio data for you.</p>
<p><a href="http://mp3wrap.source... | <p>Personally I would use something like mplayer with the audio pass though option eg -oac copy</p>
| 8,810 |
<p>I'm working with NHibernate and need to retrieve and process up to 2 million rows. Ideally, I could process each row - one at a time - without NHibernate loading all 2 million in memory at once (because, you know, that hurts). </p>
<p>I'd prefer to get an IEnumerable which would call the data reader iteratively f... | <p>ICriteria doesn't have any methods that return an IEnumerable, but <a href="http://fisheye3.atlassian.com/browse/nhibernate/trunk/nhibernate/src/NHibernate/IQuery.cs?r=3868#l96" rel="nofollow noreferrer">IQuery does</a>.</p>
| <p>What you want to do is wrap your data access in a method like so:</p>
<pre><code>public IEnumerable<YourObject> GetALotOfRows() {
..execute DataReader
while(..read..) {
yield return yourObject;
}
}
</code></pre>
<p>Don't have VS or nHibernate handy now, so sorry for semi-pseudo code. But the key he... | 47,368 |
<p>In the standard PrintDialog there are four values associated with a selected printer: Status, Type, Where, and Comment.</p>
<p>If I know a printer's name, how can I get these values in C# 2.0?</p>
| <p>As <a href="https://stackoverflow.com/questions/296182/how-to-get-printer-info-in-cnet#296232">dowski suggested</a>, you could use WMI to get printer properties. The following code displays all properties for a given printer name. Among them you will find: PrinterStatus, Comment, Location, DriverName, PortName, etc.... | <p>As an alternative to WMI you can get fast accurate results by tapping in to WinSpool.drv (i.e. Windows API) - you can get all the details on the interfaces, structs & constants from pinvoke.net, or I've put the code together at <a href="http://delradiesdev.blogspot.com/2012/02/accessing-printer-status-using-wins... | 37,875 |
<p>I have a GridView where one column is bound to an object property containing a nullable integer. I set SortExpression to the name of the property, and sorting works perfectly as long as all rows contain a value. If any rows contain null, however, I get an exception:</p>
<p>System.InvalidOperationException : Failed ... | <p>The Nullable type exposes a comparison method for comparing nullable types, so the solution is to override the gridview sorting logic and manually specify a comparison:</p>
<pre><code>gridview.Sorting += new GridViewSortEventHandler(gridView_Sorting);
protected void gridView_Sorting(object sender, GridViewSortEven... | <p>You could also override the null when you bind the data, placing a 0 instead. Your answer is far better. :)</p>
<p>You could also make a custom type that overrides the Compare operator. But that would just duplicate (and complicate) what you have above.</p>
| 20,232 |
<p>I need to do a dump of a table on a remote server, but I can't access the server directly. The only access I have is through PHP scripts.</p>
<p>Is there some way in which MySQL will return an </p>
<pre><code>INSERT INTO `table_name` (`field1`, `field2`) VALUES ('a', 'b'), ('c', 'd')
</code></pre>
<p>statement, l... | <p>1) can you run mysqldump from exec or passthru<br />
2) take a look at this: <a href="http://www.php-mysql-tutorial.com/perform-mysql-backup-php.php" rel="noreferrer">http://www.php-mysql-tutorial.com/perform-mysql-backup-php.php</a></p>
| <p>If you can use php-scripts on the server i would recommend <a href="http://www.phpmyadmin.net/home_page/index.php" rel="nofollow noreferrer">phpmyadmin</a>. Then you can do this from the web-interface.</p>
| 8,887 |
<p>Has anyone got much experience deploying applications to Amazons EC2? I am considering doing this in future and wonder about peoples experiences compared to shared hosting and dedicated server hosting are.</p>
| <p>So far, so good. Being able to turn on 5/10/50/100+ machines at a time is awesome. It's even better being able to turn them off and forget about them. You need to change your mindset about how you store your persistent data, but once you have the sky is the limit.</p>
<p>Performance wise, small instances are slow. ... | <p>I have an image that has my full stack and a script on each that automates the deployment of wars (java) from an S3 bucket to the local file system. </p>
<p>When an image starts the rc2.local runs this script to get the latest wars before starting tomcat. This works well for me</p>
| 27,089 |
<p>Related to this question:
<a href="https://stackoverflow.com/questions/353207/url-characters-replacement-in-jsp-with-urlrewrite">URL characters replacement in JSP with UrlRewrite</a></p>
<p>I want to have masked URLs in this JSP Java EE web project.
For example if I had this:</p>
<pre><code>http://mysite.com/prod... | <p>You could use a <code>URLRewrite filter</code>. It's like how mod_rewrite is for Apache's HTTP web server.</p>
<p><a href="http://tuckey.org/urlrewrite/" rel="nofollow noreferrer">http://tuckey.org/urlrewrite/</a></p>
<p>"Redirect one url</p>
<pre><code><rule>
<from>^/some/old/page\.html$</from>... | <p>Generally you're fronting your application with Apache. If so, look into using Apache's mod_rewrite. <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html" rel="nofollow noreferrer">http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html</a></p>
| 46,841 |
<p>I wonder if there is a way to either programatically or using a third party tool (profiler?) get an overview of how many instances of a class are currently active in the AppDomain (including or excluding derived classes), and even better, where they are allocated (not sure if that is even possible).</p>
<p>I know t... | <p>I think what you would want to use is SOS and the Windows Debugging Toolkit.</p>
<p>There is a great blog from Tess Ferandez which has tons of information on using it.</p>
<p><a href="http://blogs.msdn.com/tess/" rel="nofollow noreferrer">http://blogs.msdn.com/tess/</a></p>
| <p>I'm almost hesitant to answer because there's got to be a bunch of easier ways, but using <a href="http://msdn.microsoft.com/en-us/library/cc265629.aspx" rel="nofollow noreferrer">adplus</a> to take a hang dump, and then use <a href="http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx" rel="nofollow norefe... | 24,830 |
<p>Does Ruby have a stepwise debugger, similar to Perl's "perl -d"?</p>
| <p>The <a href="https://rubygems.org/gems/ruby-debug" rel="nofollow noreferrer">ruby-debug</a> (for ruby 1.8), <a href="https://rubygems.org/gems/debugger" rel="nofollow noreferrer">debugger</a> (for ruby 1.9), <a href="https://rubygems.org/gems/byebug" rel="nofollow noreferrer">byebug</a> (for ruby 2.0) and also the <... | <p>From the command line (if you have the <code>debug</code> module available):</p>
<pre><code>ruby -r debug /path/to/ruby_script.rb
</code></pre>
| 32,409 |
<p>I have a number of icons used throughout an application - let's take ok/cancel icons as an example. At the moment they might be a tick and a cross (tick.png, cross.png) but I may want to replace them in future. Also, I would like to keep the resource path in one place.</p>
<p>Is this ok:</p>
<pre><code>public clas... | <p>You may want to mark the constants as final.</p>
| <p>That seems to be a fairly easy way to do that. Although I would name the images with the same name as what they are for ("ok.png", "cancel.png"). And make sure that it is clear that removing or renaming the images may cause issues.</p>
| 48,237 |
<p>I've got a situation where I need to use LINQ's ExecuteCommand method to run an insert.</p>
<p>Something like (simplified for purposes of this question):</p>
<pre><code>object[] oParams = { Guid.NewGuid(), rec.WebMethodID };
TransLogDataContext.ExecuteCommand (
"INSERT INTO dbo.Transaction_Log (ID, WebMethodID) V... | <p>Did some research, and I found this:</p>
<blockquote>
<p>In my simple testing, it looks like
the parameters passed in the
ExecuteQuery and ExecuteCommand
methods are automatically SQL encoded
based on the value being supplied. So
if you pass in a string with a '
character, it will automatically SQL
... | <p>LINQ to SQL uses <em>exec_sql</em> with parameters, which is much safer than concatenating into the ad-hoc query string. It should be as safe againt SQL injection as using SqlCommand and its Paramaters collection (in fact, it's probably what LINQ to SQL uses internally). Then again, how safe is <em>that</em>?</p>
| 19,097 |
<p>I have some code which ignores a specific exception. </p>
<pre><code>try
{
foreach (FileInfo fi in di.GetFiles())
{
collection.Add(fi.Name);
}
foreach (DirectoryInfo d in di.GetDirectories())
{
populateItems(collection, d);
}
}
catch (UnauthorizedAccessException ex)
{
//i... | <p>Just rewrite it as</p>
<pre><code>catch (UnauthorizedAccessException) {}
</code></pre>
| <p>Even though I'm a Java developer (not C#), @Scott Dorman is absolutely right. Why are you "swallowing the exception"? Better yet, what <em>could</em> throw the UnauthorizedAccessException? Here are common-sense possibilities:</p>
<ol>
<li>The file doesn't exist</li>
<li>The directory doesn't exist</li>
<li>The curr... | 28,755 |
<p>I've recently been trying to create units tests for some legacy code.</p>
<p>I've been taking the approach of using the linker to show me which functions cause link errors, greping the source to find the definition and creating a stub from that. </p>
<p>Is there an easier way?
Is there some kind of C++ parser tha... | <p>You may want to investigate <a href="http://os.inf.tu-dresden.de/vfiasco/related.html#parsing" rel="noreferrer">http://os.inf.tu-dresden.de/vfiasco/related.html#parsing</a>. But C++ parsing is hard.</p>
<p>On the other hand, maybe ctags or something similar can extract class definitions...</p>
<p>You may also try ... | <p>If you're on the Windows platform, you might want to have a look at the <a href="http://research.microsoft.com/Phoenix/" rel="nofollow noreferrer">Microsoft Phoenix project</a>. It's a new compiler framework that lets you hook into any stage of the compilation process.</p>
| 29,213 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.