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 table which is full of arbitrarily formatted phone numbers, like this</p>
<pre><code>027 123 5644
021 393-5593
(07) 123 456
042123456
</code></pre>
<p>I need to search for a phone number in a similarly arbitrary format ( e.g. <code>07123456</code> should find the entry <code>(07) 123 456</code></p>
<p>The w... | <p>This looks like a problem from the start. Any kind of searching you do will require a table scan and we all know that's bad.</p>
<p>How about adding a column with a hash of the current phone numbers after stripping out all formatting characters. Then you can at least index the hash values and avoid a full blown t... | <blockquote>
<p>MySQL can search based on regular expressions.</p>
</blockquote>
<p>Sure, but given the arbitrary formatting, if my haystack contained <code>"(027) 123 456"</code> (bear in mind position of spaces can change, it could just as easily be <code>027 12 3456</code> and I wanted to match it with <code>0271... | 6,215 |
<p>I have a postgres table. I need to delete some data from it. I was going to create a temporary table, copy the data in, recreate the indexes and the delete the rows I need. I can't delete data from the original table, because this original table is the source of data. In one case I need to get some results that depe... | <p>New PostgreSQL ( since 8.3 according to docs ) can use "INCLUDING INDEXES":</p>
<pre><code># select version();
version
-------------------------------------------------------------------------------------------------
PostgreSQL 8.3.7 on x86_64-pc-linux-gnu, compiled by ... | <p>Create a new table using a select to grab the data you want. Then swap the old table with the new one.</p>
<pre><code>create table mynewone as select * from myoldone where ...
mess (re-create) with indexes after the table swap.
</code></pre>
| 24,131 |
<p>Given a relatively simple CSS:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>div {
width: 150px;
}</code></pre>
<pre class="snippet-code-html lang-html prettypri... | <p>Replace your hyphens with this:</p>
<pre><code>&shy;
</code></pre>
<p>It's called a "soft" hyphen.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>div {
width:... | <p>The non-breaking hyphen works well.</p>
<p><strong>HTML Entity (decimal)</strong> </p>
<pre><code>&#8209;
</code></pre>
| 2,334 |
<p>There is a question I have been wondering about for ages and I was hoping someone could give me an answer to rest my mind.</p>
<p>Let's assume that I have an input stream (like a file/socket/pipe) and want to parse the incoming data. Let's assume that each block of incoming data is split by a newline, like most com... | <p>There are normally two techniques for this</p>
<p>1) What I think readline uses - if the buffer fills return the data without the delimiter on the end</p>
<p>2) When the buffer fills, remeber it filled, keep reading until you get the delimiter and report an error (or truncate the record at the buffer size)</p>
| <p>Options (2) and (3) are out as you are losing data in both cases. Option (4) of a huge fixed size buffer would not solve the problem as it is just not possible to know what size is large enough? Is it all the physical memory + swap space + the free space available in all disks everywhere in the known universe?</p>
... | 36,117 |
<p>Since Unicode lacks a series of zero width sorting characters, I need to determine equivalent characters that will allow me to force a certain order on a list that is automatically sorted by character values. Unfortunately the list items are not in an alphabetical order, nor is it acceptable to prefix them with visi... | <p>Zero-width space (U+200B) should probably do what you want. From the Unicode spec:</p>
<blockquote>
<p>Zero Width Space. The U+200B ZERO WIDTH SPACE indicates a line break opportunity, except that it has no width. Zero-width space characters are intended to be used in languages that have no visible word spacing ... | <p>Personally, I just prefer to use a primary/secondary sort key. It's less kludgy, and easy to implement in a typical sql query (ORDER BY column_a,column_b). <strong>Edited to add</strong>: In Php, you could use <code>usort(array, comparisonFunction)</code> with a custom comparison function to add additional logic for... | 18,303 |
<p>I am using informix database, I want a query which you could also generate a row number along with the query</p>
<p>Like</p>
<pre><code>select row_number(),firstName,lastName
from students;
row_number() firstName lastName
1 john mathew
2 ricky pointing
3 sachin tendul... | <p>The best way is to use a (newly initialized) sequence.</p>
<pre><code>begin work;
create sequence myseq;
select myseq.nextval,s.firstName,s.lastName from students s;
drop sequence myseq;
commit work;
</code></pre>
| <p>I know its an old question, but since i just faced this problem and got a soultion not mentioned here, i tough i could share it, so here it is:</p>
<p>1- You need to create a FUNCTION that return numbers in a given range:</p>
<pre><code>CREATE FUNCTION fnc_numbers_in_range (pMinNumber INT, pMaxNumber INT)
RETURNIN... | 14,506 |
<pre><code>// A Mutex allows threads mutually exclusive access to a resource.
//-----------------------------------------------------------------------
class Mutex
{
private:
CRITICAL_SECTION m_mutex;
public:
Mutex() { InitializeCriticalSection(&m_mutex); }
~Mutex() { DeleteCriticalSection(&m_mut... | <p>CodeSnitch is apparently not smart enough to know that InitializeCriticalSection() <em>expects</em> to be working on a structure containing an uninitialized pointer.</p>
<p>Think of it from CodeSnitch's point of view. What's the difference between what you're doing, and this:</p>
<pre><code>struct Customer {
... | <p>I don't see anything wrong with your class <em>definition</em>. Where is it being used though? A particular instance could still be used incorrectly.</p>
<p>The Win32 definition of a CRITICAL_SECTION includes a pointer to a 'struct _RTL_CRITICAL_SECTION *'. The OS <em>could</em> be being clever in its handling ... | 39,302 |
<p>I was just wondering how many experienced programers out there actually map out their process or algorithms in a program like MS Visio or Gnome Dia? </p>
<p>I am trying to code some complex PHP for my website and just seem to be missing something. Is a diagram program going to help or should I be looking in anoth... | <p>I use Visio only for quick graph that doesn't need to follow UML rules. Sometime useful for documentation that aren't about the detail of the code : if you need to show some high abstract view of your code, Visio do the job, Example, documentation that display how each big part communicate, or a simple activity diag... | <p>When I want to make a sketch with 3 boxes and a handful of arrows I use graphviz.
I hate graphical stuff where you have to realign everything each time you change a name.</p>
<p>It's (nearly) as simple as writing :</p>
<pre><code>Input -> Frobnicator -> Output
</code></pre>
<p>in a text file then run "dot -... | 33,968 |
<p>From Wikipedia: <a href="http://en.wikipedia.org/wiki/SecurID" rel="nofollow noreferrer">RSA SecurID</a> is a mechanism developed by RSA Security for performing two-factor authentication for a user to a network resource.</p>
<p>I just read about this device, and it seems interesting to me. However, I'm not sure how... | <p><A HREF="https://pip.verisignlabs.com/" rel="nofollow noreferrer">Verisign's OpenID provider</A> supports such tokens (sold at a discount by EBay and PayPal), which is certainly the easiest way to get started using dual-factor authentication for web applications.</p>
| <p>My company, WiKID Systems, has a dual-source two-factor authentication system. In addition to radius, ldap etc, we have a very simple API called wAuth and packages available in PHP, Python, Ruby, Java and C#. These 'network client' packages are LGPL so you can put them in open source or commercial licensed software... | 30,626 |
<p>Actionscript 3.0 (and I assume Javascript and ECMAScript in general) lacks pass-by-reference for native types like ints. As a result I'm finding getting values back from a function really clunky. What's the normal pattern to work around this? </p>
<p>For example, is there a clean way to implement <em>swap( intA, ... | <p>I Believe the best you can do is pass a container object as an argument to a function and change the values of some properties in that object:</p>
<pre><code>function swapAB(aValuesContainer:Object):void
{
if (!(aValuesContainer.hasOwnProperty("a") && aValuesContainer.hasOwnProperty("b")))
throw... | <p>If ActionScript works like Javascript,</p>
<pre><code>[a,b] = [b,a]
</code></pre>
| 7,152 |
<p>I am experimenting with calling delegate functions from a delegate array. I've been able to create the array of delegates, but how do I call the delegate?</p>
<pre><code>public delegate void pd();
public static class MyClass
{
static void p1()
{
//...
}
static void p2 ()
{
//... | <p>If they're all the same type, why not just combine them into a single multicast delegate?</p>
<pre><code>static pd delegateInstance = new pd(MyClass.p1) + new pd(MyClass.p2) ...;
...
pd();
</code></pre>
| <pre><code>public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
pd[0](1);
pd[1](2);
}
public delegate void delegates(int par);
static delegates[] pd = new delegates[]
{
new de... | 31,830 |
<p>I have a Stored Procedure that is constantly failing with the error message "Timeout expired," on a specific user.</p>
<p>All other users are able to invoke the sp just fine, and even I am able to invoke the sp normally using the Query Analyzer--it finishes in just 10 seconds. However with the user in question, th... | <p>Some thoughts...</p>
<p>Reading the comments suggests that parameter sniffing is causing the issue.</p>
<ul>
<li>For the other users, the cached plan is good enough for the parameter that they send</li>
<li>For this user, the cached plan is probably wrong</li>
</ul>
<p>This could happen if this user has far more ... | <p>I think to answer your question, we may need a bit more information.</p>
<p>For example, are you using Active directory to authenticate your users? Have you used the SQL profiler to investigate? It sounds like it could be an auth issue where SQL Server is having problems authenticating this particular user.</p>
| 34,337 |
<p>When I create a new instance of a ChannelFactory:</p>
<pre><code>var factory = new ChannelFactory<IMyService>();
</code></pre>
<p>and that I create a new channel, I have an exception saying that the address of the Endpoint is null. </p>
<p>My configuration inside my web.config is as mentioned and everything... | <p>I finally found the answer. ChannelFactory doesn't read information from your Web.Config/app.config. ClientBase (which then work with a ChannelFactory) does.</p>
<p>All this costed me a few hours of work but I finally found a valid reason.</p>
<p>:)</p>
| <p>ChannelFactory instantiated by the new operator DOES read from web.config. AnAngel answer above is correct.
You just have to make sure that you provide your endpoint with a name.
And make sure that the endpoint contract is set correctly (very important)</p>
<p>I have an experience before where my web.config was gen... | 38,057 |
<p>Is there some equivalent of "friend" or "internal" in php? If not, is there any pattern to follow to achieve this behavior? </p>
<p><strong>Edit:</strong>
Sorry, but standard Php isn't what I'm looking for. I'm looking for something along the lines of what ringmaster did.</p>
<p>I have classes which are doing C-st... | <p>PHP doesn't support any friend-like declarations. It's possible to simulate this using the PHP5 __get and __set methods and inspecting a backtrace for only the allowed friend classes, although the code to do it is kind of clumsy.</p>
<p>There's some <a href="http://bugs.php.net/bug.php?id=34044" rel="noreferrer">s... | <p>I'm pretty sure what you're looking for is "protected" or "private", depending on your use case.</p>
<p>If you're defining an function in a class, and you only want it available to itself, you'll define it this way:</p>
<pre><code>private function foo($arg1, $arg2) { /*function stuff goes here */ }
</code></pre>
... | 41,063 |
<p>A little benchmark with ASP.NET MVC. Viewpage code:</p>
<pre><code> public string Bechmark(Func<string> url)
{
var s = new Stopwatch();
var n = 1000;
s.Reset();
s.Start();
for (int i = 0; i < n; i++)
{
var u = url();
}
s.Sto... | <p>I asked this question on the MS forums, which got an answer from an MS MVC developer.</p>
<p><a href="http://forums.asp.net/t/1335585.aspx" rel="nofollow noreferrer">The post</a></p>
<p><strong>The answer</strong></p>
<blockquote>
<p>From MVC Preview 2 to the recently released MVC Beta from yesterday there have been... | <blockquote>
<p>Caching links would probably be a good
suggestion for the team, as they won't
change for the life of the process
(for most apps anyway).</p>
</blockquote>
<p>How can you cache links, you can't do that as far as I know, because you need to cache the method that gets executed, which happens after... | 26,078 |
<p>I am currently programming a scheduling application which loosely based on iCalendar standard. Does anyone knows in which property can I store the event creator's information? By browsing through the iCalendar RFC 2445, I find this property: <a href="http://www.kanzaki.com/docs/ical/organizer.html" rel="nofollow nor... | <p>Some notes from the rfc2445</p>
<p>Conformance: This property MUST be specified in an iCalendar object
that specifies a group scheduled calendar entity. This property MUST
be specified in an iCalendar object that specifies the publication of
a calendar user's busy time. This property <strong>MUST NOT be sp... | <p>I am researching a similar application, concerned with event tracking and handling, and came to the same conclusions as Jeffrey04.</p>
<p>Specifically, to represent warning or alarm, it would seem appropriate to use the VJOURNAL component, as the event is in the past, and maybe continues through the present, but is... | 10,553 |
<p>Is there any substantial difference between those two terms?. I understand that JDK stands for Java Development Kit that is a subset of SDK (Software Development Kit). But specifying Java SDK, it should mean the same as JDK.</p>
| <p>From this <a href="http://en.wikipedia.org/wiki/Java_Development_Kit#Ambiguity_between_a_JDK_and_an_SDK" rel="noreferrer">wikipedia entry</a>:</p>
<blockquote>
<p>The JDK is a subset of what is loosely defined as a software development kit (SDK) in the general sense. In the descriptions which accompany their rece... | <p>There are two products JavaSE and JavaEE.
EE is the web application/enterprise edition that allows the development and running of web application.
SE is the plain Java product that has no EE specifics in it, but is a subset of EE.
The SE comes in two types a JDK and a JRE.</p>
<p>There is one big difference that ma... | 20,081 |
<p>I'm starting my adventure with Ruby on Rails and as IDE I choose Netbeans. It has bundled server Webrick and it had worked good. But after some changes in my first application it gives me internal error 500 - but nothing shows in console. And older actions give the same result.</p>
<p>How can I find where the probl... | <p>Your best bet is to always have a terminal window open and to issue the follow</p>
<pre><code>tail -f log/development.log
</code></pre>
<p>This will give you a real time, syntax colored feed of your log as you're working with your application.</p>
| <p>Answered myself - logs/development.log</p>
| 41,710 |
<p>I'm unfamiliar with Pocket PC development, but I have to make a few minor changes to an VS2005, Pocket PC 2003 Device application. One of the changes (which I thought would be trivial) is changing the text of app's shortcut, but I can't figure out where this text is set. The solution includes a setup project, so I... | <p>It depends on exactly how the shortcut is generated. There are generally 3 mechanisms that are used.</p>
<ol>
<li>Via the <a href="http://msdn.microsoft.com/en-us/library/ms938387.aspx" rel="nofollow noreferrer">CEShortcuts section of the INF</a>. For this, it's the text before the first comma</li>
<li>Via copyin... | <p>Thinking more about this, are you trying to simply find where in the Studio UI of the installer project to change the shortcut? If so, <a href="http://msdn.microsoft.com/en-us/library/aa446504.aspx" rel="nofollow noreferrer">this MSDN article</a> may help. What is very non-intuitive is that there are little icons ... | 44,749 |
<p>What is the best way to combine both hashes into %hash1? I always know that %hash2 and %hash1 always have unique keys. I would also prefer a single line of code if possible. </p>
<pre><code>$hash1{'1'} = 'red';
$hash1{'2'} = 'blue';
$hash2{'3'} = 'green';
$hash2{'4'} = 'yellow';
</code></pre>
| <h2>Quick Answer (TL;DR)</h2>
<pre>
%hash1 = (%hash1, %hash2)
## or else ...
@hash1{keys %hash2} = values %hash2;
## or with references ...
$hash_ref1 = { %$hash_ref1, %$hash_ref2 };
</pre>
<h2>Overview</h2>
<ul>
<li><strong>Context:</strong> Perl 5.x</li>
<li><strong>Problem:</strong> The use... | <p>For hash references. You should use curly braces like the following: </p>
<pre><code>$hash_ref1 = {%$hash_ref1, %$hash_ref2};
</code></pre>
<p>and <strong>not</strong> the suggested answer above using parenthesis: </p>
<pre><code>$hash_ref1 = ($hash_ref1, $hash_ref2);
</code></pre>
| 45,553 |
<p>Where do you put user input validation in a web form application?</p>
<ol>
<li>View: JavaScript client side</li>
<li>Controller: Server side language (C#...)</li>
<li>Model: Database (stored procedures or dependencies) </li>
</ol>
<p>I think there is validation required by each level:</p>
<ol>
<li>Did the user in... | <p>I check in all tiers, but I'd like to note a validation trick that I use.</p>
<p>I validate in the database layer, proper constraints on your model will provide automatic data integrity validation.</p>
<p>This is an art that seems to be lost on most web programmers.</p>
| <p>Simple input validation in the view. Full validation in the model. Reason? If you change your view technology, and the validation is in the view/controller, you have to rewrite your validation for the new view. This can introduce bugs. Put it in the model, and this is reused by all views...</p>
<p>But, as I said, s... | 16,268 |
<p>In C# how do you detect is a specific drive is a Hard Drive, Network Drive, CDRom, or floppy?</p>
| <p>The method GetDrives() returns a DriveInfo class which has a property DriveType that corresponds to the enumeration of System.IO.DriveType:</p>
<pre><code>public enum DriveType
{
Unknown, // The type of drive is unknown.
NoRootDirectory, // The drive does not have a root directory.
Removable... | <p><a href="http://msdn.microsoft.com/en-us/library/system.io.driveinfo.drivetype.aspx" rel="nofollow noreferrer">DriveInfo.DriveType</a> should work for you.</p>
<pre><code>DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.Writ... | 17,918 |
<p>Has anyone found a plugin for Visual Studio to allow for PowerShell syntax highlighting or IntelliSense? If not, does anyone have any idea why not? I keep hoping someone else with copious free time would have tackled this by now. I have hope since other folks have managed to take the limited documentation and build... | <p>Here's a useful one: <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/01516103-d487-4a7e-bb40-c15ec709afa3" rel="noreferrer">PowerGUI VS Extension</a>. </p>
| <p>The <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/67620d8c-93dd-4e57-aa86-c9404acbd7b3?SRC=VSIDE" rel="nofollow noreferrer">PowerConsole</a> extension for VS2010 is very nice and looks promising. I am not sure though that it is suitable (or able) to edit scripts. It is worth to try in any case. </p>
| 34,115 |
<p>What do you use to capture webpages, diagram/pictures and code snippets for later reference?</p>
| <p>Evernote <a href="http://www.evernote.com" rel="nofollow noreferrer">http://www.evernote.com</a> and delicious <a href="http://www.delicious.com" rel="nofollow noreferrer">http://www.delicious.com</a></p>
| <p>I prefer to use the <a href="http://del.icio.us" rel="nofollow noreferrer">good old url</a> for delicious</p>
<p>Apart from that i use the <a href="http://amb.vis.ne.jp/mozilla/scrapbook/" rel="nofollow noreferrer">Scrapbook extension</a> in firefox when i want to save something on the disk. It's possible to tag th... | 7,658 |
<p>I am familiar with nunit for unit testing of the business layer however I am looking now to automate the test of the win forms gui layer. </p>
<p>I have seen <a href="http://watin.sourceforge.net/" rel="noreferrer">watin</a> and the watin recorder for automating tests on web application by accessing the controls a... | <p>Check out <a href="http://www.codeplex.com/white" rel="noreferrer">http://www.codeplex.com/white</a> and <a href="http://nunitforms.sourceforge.net/" rel="noreferrer">http://nunitforms.sourceforge.net/</a>. We've used the White project with success.</p>
<p><em>Same Answer to a previous question</em></p>
<p><strong... | <p>You may also use Winium(<a href="https://github.com/2gis/Winium" rel="nofollow noreferrer">https://github.com/2gis/Winium</a>) that works on multiple Windows platform besides Windows 10 and is similar to Selenium with extra features that support controlling the application remotely.</p>
| 4,498 |
<p>Server Management Studio tends to be a bit un-intuitive when it comes to managing Extended Properties, so can anyone recommend a decent tool that improves the situation.</p>
<p>One thing I would like to do is to have templates that I can apply objects, thus standardising the nomenclature and content of the properti... | <p>Take a look at Data Dictionary Creator, an open source tool I wrote to make it easier to edit extended properties. It includes the ability to export the information in a variety of formats, as well.</p>
<p><a href="http://www.codeplex.com/datadictionary" rel="nofollow noreferrer">http://www.codeplex.com/datadiction... | <p>You might also think about having a nice re-runnable script that lets you maintain the extended properties. The system stored procedures for doing this work well, but they are a pain, so I wrap them with my own stored procedure so I can more easily deal with them.</p>
<p>For example, below is a stored procedure tar... | 3,887 |
<p>I currently use notepad to store little notes to myself about my code.
This is usually a mixture of code and requirements.</p>
<p>Is there a 'scratch pad' type window in VS where i could do this.</p>
<p>The other alternative is to use code comment blocks in the source files, but that's not quite what I'm looking f... | <p>On "Solution Level" you can add files (text, html or code) to act as notes files.</p>
<p>Also in projects, you can add files, and set the <em>Build Action</em> to <em>None</em>.</p>
| <p>I think Stick notes wont support VS 2005. Anyway WinDBG rocks.</p>
| 30,567 |
<p>I am re-building our poorly designed web application from scratch, and wanted to get into TDD and basically "do things right" as kind of a learning project. What tools, processes, and resources are recommended to do it "right" from the start? I will be working alone as the architect and developer, with the backup ... | <p>I highly recommend that you take a look at <a href="http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx" rel="nofollow noreferrer">MVC for ASP.NET</a> if you want to make unit testing a high priority in your development process. It sounds like it is perfect for what you are trying to... | <p>If you are just starting out then I would change as little as possible (especially since you are the only developer), so stick with Sourcesafe. There is absolutely nothing wrong with it in your situation.</p>
<p>Later down the line, you might look towards the MS Team System, or perhaps go for other 3rd Party tools.... | 11,195 |
<p>A colleague once told me that the last option when everything has failed to debug on Linux was to use <a href="http://man7.org/linux/man-pages/man1/strace.1.html" rel="noreferrer">strace</a>.</p>
<p>I tried to learn the science behind this strange tool, but I am not a system admin guru and I didn’t really get resul... | <p><strong>Strace Overview</strong><br />
strace can be seen as a light weight debugger. It allows a programmer / user to quickly find out how a program is interacting with the OS. It does this by monitoring system calls and signals.</p>
<p><strong>Uses</strong><br />
Good for when you don't have source code or don't w... | <p>I liked some of the answers where it reads <code>strace</code> checks how you interacts with your operating system.</p>
<p>This is exactly what we can see. The system calls. If you compare <code>strace</code> and <code>ltrace</code> the difference is more obvious. </p>
<pre><code>$>strace -c cd
Desktop Documen... | 21,096 |
<p>I am working on an embedded systems project and have run into an issue of the compiler being programatically embedded in the Paradigm C++ IDE. I would like to be able to automate building.</p>
<p>The processor is the AMD186ES. I am not working with the OS - just baremetal stuff.
I need to generate real-mode 16-bit ... | <p>Your best bet is probably <a href="http://www.openwatcom.org/index.php/Main_Page" rel="noreferrer">OpenWatcom</a>, which includes a C++ compiler. Back in the early-to-mid 90s, I believe this was the best C/C++ compiler around. It was open-sourced a few years ago.</p>
| <p>It has been a long time since I've looked at Paradigm stuff (are they still around?) -- are you sure they don't have command-line equivalents for the compiler? My recollection is that they were built on top of Borland's compiler toolchain... So maybe an old copy of Borland compilers might do the trick?</p>
<p>--
... | 28,193 |
<p>I was wondering if there is some option to keep ReSharper from removing just the <code>using System;</code> directive? Perhaps this is configurable somewhere?</p>
<p>Also, is there a way to have ReSharper sort the remaining directives just as Visual Studio 2008 does it (alphabetically, I think)?</p>
<p>Thanks.</p>... | <p>Yes, there is such an option: ReSharper->Languages->C#->Namespace Imports. You can add namespaces,that should not be removed, as well as namespaces, that should always be imported.</p>
| <p>Yes, in the options (<code>Resharper</code> > <code>Options</code> > <code>Languages</code> > <code>C#</code>), there is a <code>Namespace Imports</code> section that allows you to specify namespaces that should never be removed. You would put <code>System</code> into the prompt it gives.</p>
| 46,420 |
<p>I'm looking at the <a href="http://www.php.net/manual/en/" rel="noreferrer">PHP Manual</a>, and I'm not seeing a section on data structures that most languages have, such as lists and sets. Am I just blind or does PHP not have anything like this built in?</p>
| <p>The only native data structure in PHP is array. Fortunately, arrays are quite flexible and can be used as hash tables as well.</p>
<p><a href="http://www.php.net/array" rel="noreferrer">http://www.php.net/array</a></p>
<p>However, there is SPL which is sort of a clone of C++ STL.</p>
<p><a href="http://www.php.ne... | <p>PHP can also have an <em>array of arrays</em> which is called a "multidimensional array" or "matrix". You can have 2-dimensional arrays, 3-dimensional arrays, etc.</p>
| 4,241 |
<p>I need to put a control to the right of my MenuStrip. The MenuStrip fades in colour away from the BackColor on the left hand side to something whiter on the right, and ideally I would like to make my small control blend in by having the same backColor as the menustrip has on that side. Does anyone know how that colo... | <p>The tool strip renderer draws a gradient between two colors that are defined in the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.professionalcolortable.aspx" rel="nofollow noreferrer">ProfessionalColorTable</a> that is passed into the <a href="http://msdn.microsoft.com/en-us/library/system.w... | <p>I sample colours using Paint.Net: Make a screendump of the whole screen, or window, and then use Paint.Net to sample the color.</p>
| 15,403 |
<p>I took a look at the "Beginner's Guide to LINQ" post here on StackOverflow (<a href="https://stackoverflow.com/questions/8050/beginners-guide-to-linq">Beginners Guide to LINQ</a>), but had a follow-up question:</p>
<p>We're about to ramp up a new project where nearly all of our database op's will be fairly simple d... | <p>Some advantages of LINQ over sprocs:</p>
<ol>
<li><strong>Type safety</strong>: I think we all understand this.</li>
<li><strong>Abstraction</strong>: This is especially true with <a href="http://msdn.microsoft.com/en-us/library/bb386964.aspx" rel="noreferrer">LINQ-to-Entities</a>. This abstraction also allows the... | <p>Both LINQ and SQL have their places. Both have their disadvantages and advantages.</p>
<p>Sometimes for complex data retrieval you might need stored procs. And sometimes you may want other people to use your stored proc in Sql Server Management Studio.</p>
<p>Linq to Entities is great for fast CRUD development.</p... | 3,535 |
<p>So I totally buy into the basic tenents of ASP.NET, testability, SoC, HTML control...it's awesome. However being new to it I have a huge hang up with the markup. I know it comes from my hatred of classic ASP, and I can't help but feel like I've entered the twilight zone when <a href="http://www.flickr.com/photos/w... | <p>There are things you can do to help clean up the markup, but I agree it can get a bit tag-soupy. </p>
<ul>
<li>You can <a href="http://weblogs.asp.net/stephenwalther/archive/2008/06/13/asp-net-mvc-tip-1-creating-new-html-helpers-with-extension-methods.aspx" rel="nofollow noreferrer">make your own HTML helpers</a> t... | <p>If you press ctrl+z after it formats it just undoes the formatting and not the typing.</p>
<p>I find this helpful to keep the first bracket on the same line as the if statement</p>
| 47,455 |
<pre><code>struct a
{
char *c;
char b;
};
</code></pre>
<p>What is sizeof(a)? </p>
| <pre><code>#include <stdio.h>
typedef struct { char* c; char b; } a;
int main()
{
printf("sizeof(a) == %d", sizeof(a));
}
</code></pre>
<p>I get "sizeof(a) == 8", on a 32-bit machine. The total size of the structure will depend on the packing: In my case, the default packing is 4, so 'c' takes 4 bytes, 'b'... | <p>I assume you mean struct and not strict, but on a 32-bit system it'll be either 5 or 8 bytes, depending on if the compiler is padding the struct.</p>
| 17,277 |
<p>After working for a few days with Eclipse Java I totally got addicted to pressing <kbd>Ctrl</kbd> and clicking on an identifier to go to its definition. Since then I've been looking for a way to achieve this in Visual Studio as well.</p>
<p>I realize VS has right click, Go to definition, and that <kbd>F12</kbd> doe... | <p>If you use Visual Studio 2010, you can use the free
<a href="http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef" rel="noreferrer">Visual Studio 2010 Productivity Power Tools</a> from Microsoft to achieve this.</p>
| <p>I don't work in VS much, so I haven't used it, but I've heard incredibly good things about <a href="http://www.jetbrains.com/resharper/" rel="nofollow noreferrer">Resharper</a> from everyone I know who does. Everyone has told me it's worth every penny, and significantly improves efficiency in Visual Studio. I thin... | 20,326 |
<p>I have an array of items that are time sensitive. After an amount of time, the last item needs to fall off and a new item is put at the beginning.</p>
<p>What is the best way to do this?</p>
| <p>I would suggest using a queue, just a special instance of an array or list. When your timed event occurs, pop the last item from the queue, and then push your new item on.</p>
| <p>In csharp 3 you can do:</p>
<pre><code>original = new[] { newItem }.Concat(
original.Take(original.Count() - 1)).ToArray()
</code></pre>
<p>But you are probably better off using a specialised datastructure</p>
| 17,922 |
<p>When creating a class that has internal private methods, usually to reduce code duplication, that don't require the use of any instance fields, are there performance or memory advantages to declaring the method as static?</p>
<p>Example:</p>
<pre><code>foreach (XmlElement element in xmlDoc.DocumentElement.SelectNo... | <p>From the <a href="http://msdn.microsoft.com/en-us/library/ms245046.aspx" rel="noreferrer">FxCop rule page</a> on this:</p>
<blockquote>
<p>After you mark the methods as static, the compiler will emit non-virtual call sites to these members. Emitting non-virtual call sites will prevent a check at runtime for each ... | <p>As has already been stated, there are many advantages to static methods. However; keep in mind that they will live on the heap for the life of the application. I recently spent a day tracking down a memory leak in a Windows Service... the leak was caused by private static methods inside a class that implemented ID... | 16,355 |
<p>I'm working on an email solution in SQL Server ONLY that will use Database Mail to send out HTML formatted emails. The catch is that the images in the HTML need to be embedded in the outgoing email. This wouldn't be a problem if I were using a .net app to generate & send the emails but, unfortunately, all I hav... | <p>Yes, what you need to do is include the images as attachments and then they can be referenced within the HTML.</p>
<p>Use the <code>@file_attachment</code> parameter of <code>sp_send_dbmail</code></p>
| <p>You could try to encode the image as base64 and reference it directly in an img tag within the email ( <code><img src="data:image/png;base64[your encoded image here...]</code> ) but i think most email clients correlate this technique with spam. I think you're better off referencing hosted images or simply attachi... | 5,658 |
<p>Extension method is a really helpful feature that you can add a lot of functions you want in any class. But I am wondering if there is any disadvantage that might bring troubles to me. Any comments or suggestions?</p>
| <ul>
<li>The way that extension methods are imported (i.e. a whole namespace at a time) isn't granular. You can't import one extension from a namespace without getting all the rest.</li>
<li>It's not immediately obvious from the source code where the method is defined. This is also an <em>advantage</em> - it means you ... | <p>As far as disadvantages go, I would see them a bit like macros - you can potentially end up with code that is harder to maintain because others might not be familiar with the extensions you added.</p>
| 40,232 |
<p>I need to build a div with curved corner border, with out using any images in the corner. Is it possible?</p>
<p>I dont want to insert curved images in the corner, Please help me regarding this.</p>
| <p><a href="http://www.curvycorners.net/" rel="noreferrer">http://www.curvycorners.net/</a></p>
<p>Try this library out, it did wonders for me! It is a tested cross browser solution.</p>
| <p>I'd use a jQuery plugin to handle rounded corners. Here's the list of available rounded corner plugins on the jQuery site: <a href="http://plugins.jquery.com/taxonomy/term/189" rel="nofollow noreferrer">http://plugins.jquery.com/taxonomy/term/189</a></p>
| 47,251 |
<p>Are there any tools available that will calculate code metrics (for example number of code lines, cyclomatic complexity, coupling, cohesion) for your project and over time produce a graph showing the trends? </p>
| <p>On my latest project I used <a href="http://www.campwoodsw.com/sourcemonitor.html" rel="noreferrer">SourceMonitor</a>. It's a nice free tool for code metrics analysis.<br>
Here is an excerpt from SourceMonitor official site:</p>
<blockquote>
<ul>
<li>Collects metrics in a fast, single
pass through source file... | <p>On the PHP front, I believe for example <a href="http://phpundercontrol.org" rel="nofollow noreferrer">phpUnderControl</a> includes metrics through <a href="http://www.phpunit.de/" rel="nofollow noreferrer">phpUnit</a> (if I am not mistaken).</p>
<p>Keep in mind that metrics are often flawed. For example, a coder w... | 8,525 |
<p>I want to add an item to an ASP.Net combobox using Javascript. I can retrieve the ID (No Masterpage). How can I add values to the combobox from Javascript? My present code looks like this.</p>
<pre><code> //Fill the years (counting 100 from the first)
function fillvarYear() {
var dt = $('#txtBDate').... | <p>To see the value on postback:</p>
<pre><code>string selectedValue = Request.Params[combobox.UniqueId]
</code></pre>
<p>Remember, changing the values in a combobox with javascript will cause an Event Validation exception to be thrown, and is generally a bad idea, as you'll have to explicitly disabled event validati... | <p>I found a possible solution. I don't know why the earlier code didn't work for me, but the line below </p>
<p>document.form1.ddlYear.appendChild(new Option(ye, ye));</p>
| 35,429 |
<p>I'm looking for some kind of text-parser for ASP.NET that can make HTML from some style of text that uses a special format. Like in Wiki's there is some special syntax for headings and such. I have tried to look on google, but I did not found anything for .NET.</p>
<p>Do someone know about a library for .NET that c... | <p>how about the Markdown that StackOverflow uses?</p>
<p><a href="http://daringfireball.net/projects/markdown/" rel="nofollow noreferrer">http://daringfireball.net/projects/markdown/</a></p>
<p>from their home page:</p>
<blockquote>
<p>Thus, “Markdown” is two things: (1) a
plain text formatting syntax; and (2)
... | <p>Markdown is great - very intuitive syntax, and you have <a href="http://wmd-editor.com/" rel="nofollow noreferrer">WMD - this terrific editing tool</a> that I'm typing into now.</p>
| 19,774 |
<p>How do you (in Visual Studio) compare the controls in the different templates in a formview so you can track down a ViewState error? </p>
| <p>WebLoad is open source:</p>
<p><a href="http://www.webload.org/" rel="noreferrer">http://www.webload.org/</a></p>
| <p>If you want to visualize performance instead of just look at the numbers you might try Engulf. It's Open Source Software, distributed, and high-performance. <a href="http://engulf-project.org/#usage" rel="nofollow">http://engulf-project.org/#usage</a> Disclaimer: It's a project I work on.</p>
| 40,196 |
<p>I am working in Visual Basic 6 and need to sort by multiple columns in a ListView. For example, sorting a list of music tracks by artist, then album, then track number. As far as I know, VB6 does not support this out of the box. Here are the suggestions I have already heard:</p>
<ul>
<li>Sort the data in a SQL t... | <p>I would create a hidden column in the listview that concatenates those three columns and sort by that</p>
| <p>You can try sorting using the Windows API and callbacks: <a href="http://vbnet.mvps.org/index.html?code/callback/lvsortcallback.htm" rel="nofollow noreferrer">Link</a></p>
<p>Alternatively, you could try switching to a <a href="http://www.vbaccelerator.com/home/VB/Code/Controls/ListView/article.asp" rel="nofollow n... | 6,771 |
<p>From what I can find online about using VS2008 to create a integration/reporting services project it appears I need to have SQL 2008. Does anyone know of a work-around that would allow me to use VS2008 with SQL 2005?</p>
| <p>Installing SQL Server 2005 client/workstation tools should install BIDS 2005.</p>
| <p>Your license for SQL2008 should allow you to downgrade and use BIDS2005. I've had VS2005 and VS2008 both installed on the same machine concurrently.</p>
| 16,857 |
<p>DOING THE POST IS NOT THE PROBLEM! Formatting the message so that I get a response is the problem.</p>
<p>Ideally I'd be able to construct a message and use WinHTTP to perform a post to a WCF service (hosted in IIS) and get a response, but so far I've been unable to construct something that works properly.</p>
<p... | <p>You don't specify one thing: What binding are you exposing your service as? If you're using WsHttpBinding or BasicHttpBinding, then there's no simple "http post" you can do, because you need to include at the very least the entire SOAP envelope (with the right SOAP version and potentially security headers and so for... | <p>I wote some code a while ago for an excel macro which reads a XML file, posts the contents to a URL then saves the result.</p>
<pre><code>Sub ExportToHTTPPOST()
Dim sURL, sExtraParams
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Set rs = CreateObject("Scripting.FileSystemObject")
Set r = rs.OpenTextFile(... | 10,251 |
<p>There are a group of private methods in my class, and I need to call one dynamically based on an input value. Both the invoking code and the target methods are in the same instance. The code looks like this:</p>
<pre><code>MethodInfo dynMethod = this.GetType().GetMethod("Draw_" + itemType);
dynMethod.Invoke(this, n... | <p>Simply change your code to use the overloaded <a href="http://msdn.microsoft.com/en-us/library/system.type.getmethod.aspx" rel="noreferrer">version of <code>GetMethod</code></a> that accepts BindingFlags:</p>
<pre><code>MethodInfo dynMethod = this.GetType().GetMethod("Draw_" + itemType,
BindingFlags.NonPublic ... | <p>Read this (supplementary) answer (that is sometimes the answer) to understand where this is going and <strong>why</strong> some people in this thread complain that <em>"it is still not working"</em></p>
<p><a href="https://stackoverflow.com/a/25415496/1704458">I wrote exactly same code as one of the answers here</a... | 16,403 |
<p>I'm trying to connect two 3D printed parts (ABS) together with a threaded connection. Thus, I need to fix a threaded metal nut (M4) inside a corresponding slot which I've implemented in the design.</p>
<p>Right now I apply a conventional super glue on the nut and press it inside the print, wait for a couple of hour... | <p>One good option would be to - if possible - change the design, so the nut is inserted from the opposite side, so that the bolt just pulls it in tighter rather than pulling it out.</p>
<p>Another option would be to instead of using a nut, use a <a href="https://www.matterhackers.com/articles/fasteners-for-3d-printin... | <p>Just heat the nut with a soldering iron to seat it into place (after the print). I've done this many times myself.</p>
<p>EDIT: Try a bit of acetone, to allow the ABS near the nut to reflow.</p>
| 601 |
<p>Generally, how bad of a performance hit is storing a file in a database (specifically mssql) as opposed to the file system? I can't come up with a reason outside of application portability that I would want to store my files as varbinaries in SQL Server.</p>
| <p>Have a look at this answer:</p>
<p><a href="https://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay#3756">Storing Images in DB - Yea or Nay?</a></p>
<p>Essentially, the space and performance hit can be quite big, depending on the number of users. Also, keep in mind that Web servers are cheap and y... | <p>Not to be vague or anything but I think the type of 'file' you will be storing is one of the biggest determining factors. If you essentially talking about a large text field which could be stored as file my preference would be for db storage. </p>
| 3,042 |
<p>What java GUI layout manager does everyone use? Lately, I have been using <a href="http://www.miglayout.com/" rel="nofollow noreferrer">MigLayout</a>, which has some powerful component controls. Just wanted to see what other developers are using other than the standard JDK ones.</p>
| <p><a href="http://www.miglayout.com/" rel="nofollow noreferrer">MiGLayout</a> is the GUI layout manager which is widely used by Java Developers.</p>
| <p>The only layout manager that I have found, that I actually <strong>like</strong> is the <a href="http://www.onjava.com/pub/a/onjava/2002/09/18/relativelayout.html" rel="nofollow noreferrer">Relative Layout Manager</a>. The Relative Layout Manager works in a way that is consistent with how dialog boxes are <em>conce... | 14,248 |
<p>I recently purchased a spool of PETG to try working with it. I have managed to dial in most of the settings in Prusaslicer but one, in particular, is giving me a problem. As seen in the photo, the clip I printed has extra extrusion on the inside and outside. I have noticed that the nozzle will pause at the seam for ... | <p>After checking several places online, I finally got an answer in a Discord chat.</p>
<p>The solution was to turn off the <strong>Power-loss recovery</strong> setting on the printer itself.</p>
<p>After that was done, the print came out beautifully.</p>
| <p>Looks like <strong>Retract at layer change</strong> is causing this. Disable that and see. This will help you to improve the quality a lot.</p>
<p>It will be under retraction settings:</p>
<p><a href="https://i.stack.imgur.com/tdYOm.png" rel="nofollow noreferrer" title="Screenshot of retraction settings"><img src="h... | 2,189 |
<p>I'm trying to use <code>System.DirectoryServices</code> in a web site project and I'm getting this error:</p>
<blockquote>
<p>The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?)</p>
</blockquote>
<p>My project has a reference to <code>S... | <ol>
<li>Right click on References under your solution. </li>
<li>Select Add Reference.
The reference can be found under the Framework Assemblies list.
Select <em>System.DirectoryServices</em> and click Add.</li>
</ol>
| <p>I had the same problem when I tried to convert website to web-app.
It looks like vs failing to load the assembly should be related to versioning.
switch to <code>web.config</code> and add the assembly to it as bellow. make sure the DLL version is matching your application targeted .NET version.</p>
<pre class="lang... | 33,215 |
<p>After deploying our huge distributed system to one of our clients we experience an unexpected error. During the investigation we replace the assembly causing the error with one where we have added some diagnostic code. The dll we use is built in debug mode. And suddenly it all works!</p>
<p>Replacing the debug dll ... | <p>For causes... well, some hint of the symptom would help. One possibility is that you have code to a method like <code>Debug.WriteLine</code> that has side effects (i.e. makes it work). Calls to methods marked with <code>[Conditional(...)]</code> are not compiled unless you have the right symbols defined - so anythin... | <p>You probably know this, but,
variables are sometimes initialised differently in debug and release builds.
E.g.
I think variables are auto-init'd in VC6 debug builds, this can hide problems if you didn't initialise something. I also think debug arrays may use sentry bytes in an attempt to indicate overruns. This too... | 48,094 |
<p>Anyone have a quick method for de-duplicating a generic List in C#?</p>
| <p>If you're using .Net 3+, you can use Linq.</p>
<pre><code>List<T> withDupes = LoadSomeData();
List<T> noDupes = withDupes.Distinct().ToList();
</code></pre>
| <p>I think the simplest way is:</p>
<p>Create a new list and add unique item.</p>
<p>Example:</p>
<pre><code> class MyList{
int id;
string date;
string email;
}
List<MyList> ml = new Mylist();
ml.Add(new MyList(){
id = 1;
date = "2020/09/06";
email = "zarezadeh@gmai... | 7,001 |
<p>I'm using OLEDB provider for ADO.Net connecting to an Oracle database. In my loop, I am doing an insert:</p>
<pre><code>insert into ps_tl_compleave_tbl values('2626899', 0, TO_DATE('01/01/2002', 'MM/DD/YYYY'), 'LTKN', 'LTKN', '52', TO_DATE('01/01/2002', 'MM/DD/YYYY'), 16.000000, 24.000)insert into ps_tl_compleave_... | <p>In .net, when we try to execute a single Oracle SQL statement with a semicolon at the end. The result will be an oracle error: ora-00911: invalid character. OK, you figure that one SQL statement doesn't need the semicolon, but what about executing 2 SQL statement in one string for example:</p>
<pre><code>Dim db As... | <p>It's a long shot but in the first insert the sql date format is valid for both uk/us, the second insert is invalid if the Oracle DB is setup for UK date format, I realise you have used the TO_DATE function but I don't see anything else ...</p>
| 9,774 |
<p>I understand SSO as the one time login for all the applications connected. I would like to know more about SSO and how exactly it is achieved.</p>
| <blockquote>
<p>This is Donnie. He's a friend of mine.</p>
</blockquote>
<p>The basic mechanism is to trust your friend's friend.</p>
<p>Another metaphor that's used is the sticker they give you when you enter a secured building. In the morning, you show your valid ID (credential) to the security person, and for t... | <p>Single sign on is a functionality that comes by default when we implement the claim based authentication. It involves additional third party authentication by the issuer who is going to provide the token after getting the credentials from the user who wish to access an application.</p>
| 40,475 |
<p>I've factored out common attributes from two classes into an abstract base class, however I have another model that needs to reference either one of those classes. It's not possible to reference an ABC as it doesn't actually have a database table.</p>
<p>The following example should illustrate my problem:</p>
<pre... | <p>A <a href="https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations" rel="noreferrer">generic relation</a> seems to be the solution. But it will complicate things even further.</p>
<p>It seems to me; your model structure is already more complex than necessary. I would simply merge all three... | <p>My gut would be to suggest removing the abstract modifier on the base class. You'll get the same model structure, but Answer will be it's own table. The downside of this is that if these are large tables and/or your queries are complex, queries against it could be noticeably slower.</p>
<p>Alternatively, you coul... | 47,962 |
<p>When you start thinking about a programming project what do you do first? Do you pull out a piece of paper and start sketching out the architecture? Do you have a notebook for ideas? Do you start coding something? Or do you model the software in a fancy package. Come, come, elucidate your thoughts...</p>
| <p>In order to start thinking about architecture or design, I tend to write hypothetical snippets of code that I would like to "just work" in order to address the core problem of the application.</p>
<p>For instance, when designing my database, I usually try to think of some example queries I expect to write rather th... | <p>I'd start documenting a <strong>vision</strong>, a short document describing the project, the business around it and it's success criteria. </p>
<p>This helps prioritizing features, and gives the same direction to everyone working on the project. </p>
| 43,560 |
<p>If I have an embedded browser in a windows form, is it possible to initiate a javascript method from the container application? </p>
| <p>You can use Document.InvokeScript, as outlined in this excellent MSDN article:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/a0746166(VS.85).aspx" rel="nofollow noreferrer">How to: Implement Two-Way Communication Between DHTML Code and Client Application Code</a></p>
| <p>Yes There is.. </p>
<pre><code>webBrowser.Document.InvokeScript("doSomething()");
</code></pre>
| 38,486 |
<p>What are the patterns and dos and don'ts when one is writing tests for <a href="http://javolution.org/" rel="nofollow noreferrer">Javolution</a> tests? In particular I was wondering:</p>
<ul>
<li>TestCase.execute() does not allow throwing of exceptions. How to deal with them? Rethrow as RuntimeException or store in... | <p>The javadoc and javolution sources give some examples and design rationale.
See also <a href="http://www.theserverside.com/news/thread.tss?thread_id=46761" rel="nofollow noreferrer">an article on serverside</a>.</p>
<p>Javolution tests contain exactly one test, and the exercising of the tested code is separated fro... | <p>You can get some kind of graphical testrunner by using the following JUnit adapter and running it in eclipse. You can start / debug the failed tests separately. Unfortunately the graphical representation does not include anything about the actual test - it just shows the numbers [0], [1], etc.</p>
<p>@RunWith(Param... | 46,785 |
<p>In the Vim and Emacs terminal apps, the color schemes look horrid. How do I enable the colors to be as vibrant as the GUI version (or more than 8 colors for that matter)?</p>
<p>Should I just give up, and move over to their respective GUI applications? And if so, which?</p>
| <p>You can't have <strong>more</strong> colors in the terminal, because there are only ANSI codes for 8 colors (16 if you count bold/light). If you want to customize the colors, you can use the TerminalColours plugin from <a href="http://ciaranwal.sh/2007/11/01/customising-colours-in-leopard-terminal" rel="nofollow no... | <p>You are possibly being inhibited by the fact you are running in a VT100/WhateverItsCalled compatible terminal and it just doesn't <em>have</em> more than about 16 foreground and 16 background colours. If it did, the lovely library "CaCa" ( ColourAsciiColourArt ) would be much more pleasing to watch than it is. </p... | 11,085 |
<p>I'd like to have dashes separate words in my URLs. So instead of:</p>
<pre><code>/MyController/MyAction
</code></pre>
<p>I'd like:</p>
<pre><code>/My-Controller/My-Action
</code></pre>
<p>Is this possible?</p>
| <p>You can use the ActionName attribute like so:</p>
<pre><code>[ActionName("My-Action")]
public ActionResult MyAction() {
return View();
}
</code></pre>
<p>Note that you will then need to call your View file "My-Action.cshtml" (or appropriate extension). You will also need to reference "my-action" in any Html.Ac... | <p>If you have access to the IIS URL Rewrite module ( <a href="http://blogs.iis.net/ruslany/archive/2009/04/08/10-url-rewriting-tips-and-tricks.aspx" rel="nofollow">http://blogs.iis.net/ruslany/archive/2009/04/08/10-url-rewriting-tips-and-tricks.aspx</a> ), you can simply rewrite the URLs.</p>
<p>Requests to /my-contr... | 5,021 |
<p>Is it worth it to develop <a href="http://en.wikipedia.org/wiki/WAP_Push#WAP_Push" rel="nofollow noreferrer">WAP</a> webpage for cellular since now cellular have browser that is really better than before?</p>
<p>I have a PHP website and I would like to increase the use of portable device to use it. Is it worth it t... | <p>Frankly, no. I've written WAP pages (it's painful), I've never seen a person use a WAP browser, and for the 4.25 people in the world who do, there are <a href="http://en.wikipedia.org/wiki/WAP_gateway" rel="nofollow noreferrer">WAP Gateways</a>.</p>
<p>Unless your site is geared towards providing WAP friendly conte... | <p>More than being about technology, mobile internet is about different use cases and design. I recommend reading:</p>
<p><a href="http://www.sitepoint.com/article/designing-for-mobile-web/" rel="nofollow noreferrer">Designing for the mobile web</a>, and<br>
<a href="http://www.cameronmoll.com/archives/000577.html" re... | 15,127 |
<p>At every company I have worked at, I have found that people are still writing their SQL queries in the ANSI-89 standard:</p>
<pre><code>select a.id, b.id, b.address_1
from person a, address b
where a.id = b.id
</code></pre>
<p>rather than the ANSI-92 standard:</p>
<pre><code>select a.id, b.id, b.address_1
from pe... | <p>According to "SQL Performance Tuning" by Peter Gulutzan and Trudy Pelzer, of the six or eight RDBMS brands they tested, there was no difference in optimization or performance of SQL-89 versus SQL-92 style joins. One can assume that most RDBMS engines transform the syntax into an internal representation before optim... | <p>A new SQL standard inherits everything from the previous standard, a.k.a. 'the shackles of compatibility'. So the 'old' / 'comma-separated' / 'unqualified' join style is perfectly valid SQL-92 sytax.</p>
<p>Now, I argue that SQL-92's <code>NATURAL JOIN</code> is the only join you need. For example, I argue it is su... | 43,327 |
<p>Originally I thought to ask if there would be an easy way to provide an automatically managed last update field with MS Access.</p>
<p>After some googling I found following approach:</p>
<pre><code>Private Sub Form_Dirty(Cancel As Integer)
Me.Last_Update = Date()
End Sub
</code></pre>
<p>Which seems to do th... | <p>You could also put that same code into a BeforeUpdate.</p>
<p>The difference being that the OnDirty will tag the record when you first started to edit the record; while the BeforeUpdate will tag the record just before it gets committed to the database. </p>
<p>The latter may be preferable if you have a user who st... | <p>For anyone reading this in the days of ACE 16.0 (MS Access 2016/365) the answer above from onedaywhen, to use a CONSTRAINT clause, no longer seems to work, sadly. It would seem that ACE 16.0 fails on the constraint check with the NOW() keyword in it, when saving an edited record, and so doesn't update the date field... | 21,463 |
<p>We're currently planning a new <code>API</code> for an application and debating the various data formats we should use for interchange. There's a fairly intense discussion going on about the relative merits of <code>CSV</code>, <code>JSON</code> and <code>XML</code>.</p>
<p>Basically, the crux of the argument is wh... | <p>CSV is right out. JSON is a more compact object notation than XML, so if you're looking for high volumes it has the advantage. XML has wider market penetration (I love that phrase) and is supported by all programming languages and their core frameworks. JSON is getting there (if not already there).</p>
<p>Person... | <p>I don't have any experience with JSON, CSV works up to a point when your data is very tabular and evenly structured. XML can become unwieldy very quickly, especially if you don't have a tool that creates the bindings to your objects automatically. </p>
<p>I have not tried this either but <a href="http://code.google... | 16,814 |
<p>Changing a value prompt to a multi-select value prompt in Report studio, provide single select functionality. How can i get multi-select functionality?</p>
| <p>Look at the parameter associated with the prompt. Now go look and see how you use that parameter to filter the queries in your report. If you have the filter set as:-</p>
<p>[namespace].[table].[column] = ?MyParameter?</p>
<p>... then it doesn't matter that your prompt is a multi-select prompt, it will still run a... | <p>In addition to the above answer. If the prompt is embedded in the QuerySubject in your Framework, you may need to check the Query Subject and see if it uses #promptmany()# macro instead of #prompt#.</p>
| 14,727 |
<p>How to successfully pause 3D printing and turn off the printer and the next day, continue to print the model?</p>
| <p>If you enable <code>M413</code> in Marlin firmware, the printer will write a resume printing file to SD card e.g. every layer.</p>
<p>From <a href="http://marlinfw.org/docs/gcode/M413.html" rel="nofollow noreferrer">M413 - Power-loss Recovery documentation</a> I quote:</p>
<blockquote>
<p>Enable or disable the Power... | <p>1) Cut the model up in several parts and print one each day. Remove each part every day and in the end, glue them all together.</p>
<p>2) Cut the model up in several parts and each day, add a G-code to the file to be printed so it lowers the heat-bed and thus starts to print on top of yesterdays print. This cannot ... | 1,404 |
<p>So I have this large XML file containing 300+ elements for each record and I need to insert these records into a database table. The name of the nodes in the XML file are the same as the column names in the db. And they're all strings. Is there an automatic way to map them and insert the data or will I have to write... | <p>I'd agree that with SQL server, using bulk load or SQL/XML is a good option.</p>
<p>If the database isn't SQL server and doesn't support xml natively, another option would be to use a basic xslt to transform the xml into csv or tsv; most databases can import delimited files.</p>
<p>Of course, another question woul... | <p>What is the database engine are you using?</p>
<p>SQL server could import the data using bulk load, or import / export wizard, etc.</p>
<p><a href="http://support.microsoft.com/kb/316005" rel="nofollow noreferrer">Microsoft KB</a>, + <a href="http://www.google.com/search?q=sql+server+2005+import+xml" rel="nofollow... | 30,101 |
<p>I'm writing a data structure in C# (a priority queue using a <a href="http://en.wikipedia.org/wiki/Fibonacci_heap" rel="nofollow noreferrer">fibonacci heap</a>) and I'm trying to use it as a learning experience for TDD which I'm quite new to. </p>
<p>I understand that each test should only test one piece of the cl... | <p>Add a private accessor for the class to your test project. Use the accessor to set up the private properties of the class in some known way instead of using the classes methods to do so. </p>
<p>You also need to use <code>SetUp</code> and <code>TearDown</code> methods on your test class to perform any initializat... | <p>I think this is ok, but clear the queue at the start of your test method.</p>
| 25,409 |
<p>How should I format URLs with special/international characters?</p>
<p>Currently I try to make URLs "look good", so that: </p>
<pre><code>www.myhost.com/this is a test, do you know how?
</code></pre>
<p>is converted to: </p>
<pre><code>www.myhost.com/this_is_a_test_do_you_know_how
</code></pre>
<p>I know some i... | <p>What language are you using? PHP includes a function filter_var() that seems to do most of what you want. See <a href="http://us.php.net/manual/en/function.filter-var.php" rel="nofollow noreferrer">http://us.php.net/manual/en/function.filter-var.php</a>.</p>
<p>In general, the cost of making human-readable ASCII st... | <p>But doesn't Google take advantage of the URL? If some of the text from a given article is in the URL Google search engine will use that? But if there really is no cool way of handling the non-ascii letters, then those languages is lower prioritized on the "google-internet?" </p>
| 25,688 |
<p>In Unix/Linux, how do you find out what group a given user is in via command line?</p>
| <pre><code>groups
</code></pre>
<p>or</p>
<pre><code>groups user
</code></pre>
| <p>or just study /etc/groups (ok this does probably not work if it uses pam with ldap)</p>
| 45,571 |
<p>.NET has a lot of complex data structures. Unfortunately, some of them are quite similar and I'm not always sure when to use one and when to use another. Most of my C# and VB books talk about them to a certain extent, but they never really go into any real detail.</p>
<p>What's the difference between Array, ArrayLis... | <p>Off the top of my head:</p>
<ul>
<li><p><code>Array</code>* - represents an old-school memory array - kind of like a alias for a normal <code>type[]</code> array. Can enumerate. Can't grow automatically. I would assume very fast insert and retrival speed.</p></li>
<li><p><code>ArrayList</code> - automatically growi... | <p>There are subtle and not-so-subtle differences between generic and non-generic collections. They merely use different underlying data structures. For example, Hashtable guarantees one-writer-many-readers without sync. Dictionary does not. </p>
| 15,654 |
<p>Is it particularly bad to have a very, very large SQL query with lots of (potentially redundant) WHERE clauses?</p>
<p>For example, here's a query I've generated from my web application with everything turned off, which should be the largest possible query for this program to generate:</p>
<pre><code>SELECT *
FRO... | <p>Reading your query makes me want to play an RPG.</p>
<p>This is definitely not too long. As long as they are well formatted, I'd say a practical limit is about 100 lines. After that, you're better off breaking subqueries into views just to keep your eyes from crossing.</p>
<p>I've worked with some queries that a... | <p>Most databases support stored procedures to avoid this issue. If your code is fast enough to execute and easy to read, you don't want to have to change it in order to get the compile time down.</p>
<p>An alternative is to use prepared statements so you get the hit only once per client connection and then pass in on... | 12,214 |
<p>How would I get the length of an <code>ArrayList</code> using a JSF EL expression? </p>
<pre><code>#{MyBean.somelist.length}
</code></pre>
<p>does not work.</p>
| <p>Yes, since some genius in the Java API creation committee decided that, even though certain classes have <code>size()</code> members or <code>length</code> attributes, they won't implement <code>getSize()</code> or <code>getLength()</code> which JSF and most other standards require, you can't do what you want.</p>
... | <p>You can get the length using the following EL:</p>
<p><strong>#{Bean.list.size()}</strong></p>
| 25,257 |
<p>Does anybody know how I can get diff's color margins in VIM (if it is possible)? I mean something like this: (e.g., in NetBeans: <a href="http://www.picamatic.com/show/2008/11/05/05/39/1308705_147x152.png" rel="nofollow noreferrer">Netbeans color margins</a>). It was very useful when I was working with NetBeans, may... | <p>This is not exactly what you are looking for, but you can hide one window in vimdiff and the diff colours will remain active. Use 'vim -d file1 file2' and then :hide.</p>
| <p>AFAIK, this isn't something natively supported in Vim. There is the <a href="http://www.vim.org/scripts/script.php?script_id=2158" rel="nofollow noreferrer">diffchanges plugin</a>, which might be useful.</p>
| 33,087 |
<p>I'm printing stacked Prusa COVID-19 face shields on a modded Ender 3. It works fairly well until the second layer of masks, where we get this weird effect that's kind of like stringing. It looks like the curve is becoming "low poly." I'm sorry that I can't be more specific, but I really don't know how to describe it... | <p>So, after some day of yelling and disassembling, I figured out what was the issue. As many were suggesting, I indeed had an issue with the tubing lifting from the nozzle. it was lifting, so PLA was slowly infiltrating where it wasn't supposed to be to the point it created a blockage, resulting in skipping.</p>
<p>H... | <p>I my case helps reducing printing speed, from 100% to 80%.
Looks like the filament is cooling noozle to fast.
In some large prints at the begining (on first layers) I'm reducing speed to 60%.
This looks like the background temperature is not the same in the center and at the borders.</p>
| 1,632 |
<p>We have a JavaScript construct that will play .wav files within Firefox on Windows and MacOSX, but it does not work for Red Hat Linux. What extension do I need?</p>
| <p><del>Firefox 3.1 will support</del> Firefox 3.5, supports the <code><audio></code> tag, a standard tag to deal with sound. If you use that, you'll need no extensions.</p>
<p>Unfortunately, that will only work with the latest browsers (Firefox 3, for example, is the latest stable version and yet does not supp... | <p>Try mplayerplug-in, which is available in rpmforge and rpmfusion. It requires mplayer to be installed (obviously) and AFAIK it can play virtually anything.</p>
| 39,864 |
<p>I'm trying out <strong>Git on Windows</strong>. I got to the point of trying "git commit" and I got this error:</p>
<blockquote>
<p>Terminal is dumb but no VISUAL nor
EDITOR defined. Please supply the
message using either -m or -F option.</p>
</blockquote>
<p>So I figured out I need to have an environment va... | <p>Update September 2015 (6 years later)</p>
<p>The <a href="https://github.com/git-for-windows/git/releases/tag/v2.5.3.windows.1" rel="noreferrer">last release of git-for-Windows (2.5.3)</a> now includes:</p>
<blockquote>
<p>By configuring <strong><code>git config core.editor notepad</code></strong>, users <a href... | <p>I just use <a href="http://en.wikipedia.org/wiki/TortoiseGit" rel="nofollow noreferrer">TortoiseGit</a> straight out the box. It integrates beautifully with my <a href="http://en.wikipedia.org/wiki/PuTTY" rel="nofollow noreferrer">PuTTY</a> public keys. </p>
<p>It has a perfect editor for commit messages.</p>
| 3,175 |
<p>I'm developing a experimental <strong>Linux Kernel module</strong>, so...</p>
<p>How to <strong>UDP Broadcast</strong> from Linux Kernel?</p>
| <p>-13 is -EACCES. Do you have SO_BROADCAST set? I believe sock_sendmsg returns -EACCES if SO_BROADCAST isn't set and you're sending to a broadcast address.</p>
<hr>
<p>You're looking for <errno.h> for error codes.</p>
<hr>
<p>What kernel version are you developing under? I'd like to browse thru the kernel so... | <p>Look at the IPVS (linux virtual server) code in the Linux kernel. It already has a working implementation of UDP multicast, which it uses to share connection state for failover.</p>
<p>Having already taken a look at this and knowing some people who have done this, I would really recomend creating a netfilter link a... | 45,069 |
<p>How would I go about adding <code>enctype="multipart/form-data"</code> to a form that is generated by using <code><% Html.BeginForm(); %></code>?</p>
| <p>As part of htmlAttributes,e.g.</p>
<pre><code>Html.BeginForm(
action, controller, FormMethod.Post, new { enctype="multipart/form-data"})
</code></pre>
<p>Or you can pass <code>null</code> for action and controller to get the same default target as for BeginForm() without any parameters:</p>
<pre><code>Html.Be... | <p>You can also use the following syntax for the strongly typed version: </p>
<pre><code><% using (Html.BeginForm<SomeController>(x=> x.SomeAction(),
FormMethod.Post,
new { enctype = "multipart/form-data" }))
{ %>
</code></pre>
| 26,626 |
<ul>
<li>Is there a key shortcut for this in XCode?</li>
<li>Can I implement an Applescript for this and run it within XCode?</li>
</ul>
| <p>You can probably do that using a script (check out the relevent piece of Xcode documentation). Also see the "Insert Text Macro" menu item…</p>
<p>But you might find it to be more efficient to just use the auto-correct feature. I just type "[[F", then hit my auto-correct key (bound to F5 I believe, but I've changed ... | <p><a href="http://macromates.com/" rel="nofollow noreferrer">Textmate</a> will auto-back fill ['s for you. You can also build your xcode project from inside it as well as do thousands of other interesting things with the objective-c and other built in bundles that add functionality. It has a 30 day demo, give it a sho... | 26,611 |
<p>I havent used flash or action script much. I am planning a small project that i'd like to be online via flash but i'd like to reuse the code in my c/c++ projects</p>
<p>Is there a script language i can use? i am thinking lua or python. After googling i found flua which is incomplete and jython. Can i use java in fl... | <p>Have you taken a look at <a href="http://labs.adobe.com/technologies/alchemy/" rel="nofollow noreferrer">Alchemy</a>?</p>
<blockquote>
<p>With Alchemy, Web application developers can now reuse hundreds of millions of lines of existing open source C and C++ client or server-side code on the Flash Platform. Alchem... | <p>There's no way to embed Java within a Flash movie. If you're creating a SWF that will display in a browser then you're restricted to Actionscript. You could create a Java applet, load it in the same page, and use javascript to communicate between the two, though I wouldn't recommend that.</p>
<p>If you're using a... | 36,051 |
<p>Say I have a C function which takes a variable number of arguments: How can I call another function which expects a variable number of arguments from inside of it, passing all the arguments that got into the first function?</p>
<p>Example:</p>
<pre><code>void format_string(char *fmt, ...);
void debug_print(int db... | <p>To pass the ellipses on, you initialize a <code>va_list</code> as usual and simply pass it to your second function. You don't use <code>va_arg()</code>. Specifically;</p>
<pre><code>void format_string(char *fmt,va_list argptr, char *formatted_string);
void debug_print(int dbg_lvl, char *fmt, ...)
{
char form... | <p>I'm unsure if this works for all compilers, but it has worked so far for me.</p>
<pre><code>void inner_func(int &i)
{
va_list vars;
va_start(vars, i);
int j = va_arg(vars);
va_end(vars); // Generally useless, but should be included.
}
void func(int i, ...)
{
inner_func(i);
}
</code></pre>
<p>You can... | 25,180 |
<p>I wrote below code to remove checked item from radio group in my form by double click.</p>
<pre><code>$("input[type='radio']").each(function(){
$(this).dblclick(function(){
$(this).removeAttr("checked");
});
});
</code></pre>
<p>but this code doesn't work in FireFox ... | <p>Either way, you probably want to wire it up a little differently.</p>
<pre><code>$("input[type='radio']").dblclick(function(){
$(this).removeAttr("checked");
});
</code></pre>
<p>One thing that can help when learning jQuery is to think set-based, like SQL. Selectors can select one or a group of elements. Any fun... | <p>I am so sorry, It works. I think cache makes this issue.</p>
| 48,742 |
<p>Basically I have a website. I have a properly setup sitemap so I assume Google knows about all of my pages. And I've seen on some sites, the search form leads to a page with the shell of the original site but the results are clearly provided by Google. Similar to codinghorror.com's search, however his results are... | <p><a href="https://cse.google.com/cse/" rel="nofollow noreferrer">https://cse.google.com/cse/</a></p>
<p>^ Perhaps you're looking for Google Custom Search Engine</p>
| <p>This same answer i have suggested earlier to another question so this is the answer</p>
<p>Go to this link <a href="https://www.google.com/cse/" rel="nofollow">https://www.google.com/cse/</a> and create account
Create your custom search box
Customize looks as your wish
Copy the code after customizing
Paste in your ... | 34,677 |
<p>I moved a <a href="http://en.wikipedia.org/wiki/WordPress" rel="noreferrer">WordPress</a> installation to a new folder on a Windows/<a href="http://en.wikipedia.org/wiki/Internet_Information_Services" rel="noreferrer">IIS</a> server. I'm setting up 301 redirects in PHP, but it doesn't seem to be working. My post URL... | <p>Maybe, because you are under IIS, </p>
<pre><code>$_SERVER['PATH_INFO']
</code></pre>
<p>is what you want, based on the URLs you used to explain.</p>
<p>For Apache, you'd use <code>$_SERVER['REQUEST_URI']</code>.</p>
| <p>I have used the following code, and I am getting the right result...</p>
<pre><code><?php
function currentPageURL() {
$curpageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
$curpageURL.= "s";
}
$curpageURL.= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
... | 22,933 |
<p>I'm using Ruby on Rails for an internal site. Different users of the site have access to a wide variety of data and highly disparate perspectives of the data. Within those different classes of users, there needs to be levels of access. Within the levels of access I need to be able to add features from other classes ... | <p>Another totally different approach would be to use acts_as_authenticated and authorization plugins. The tables will be built by the plugins (ie <strong>users</strong>, <strong>roles</strong> and <strong>roles</strong>_users). From the doc:</p>
<blockquote>
<p>The authorization plugin provides the following:</p>
<... | <p>Another totally different approach would be to use acts_as_authenticated and authorization plugins. The tables will be built by the plugins (ie <strong>users</strong>, <strong>roles</strong> and <strong>roles</strong>_users). From the doc:</p>
<blockquote>
<p>The authorization plugin provides the following:</p>
<... | 5,296 |
<p>I have been trying to learn how to add testing to existing code -- currently reading reading <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="noreferrer" rel="nofollow noreferrer">Working Effectively With Legacy Code</a>. I have been trying to apply some of the principles in JavaScript, and n... | <p>There's no definitive <strong>right way</strong>, because so many people are doing so many different things.. There are many useful patterns.</p>
<p><strong>Crockford</strong> suggests that you "go with the grain", or write javascript in a way that corresponds to javascript's prototypal nature.</p>
<p>Of course, ... | <p>Prototype offers its own take on inheritance, from <a href="http://www.prototypejs.org/api/class/create" rel="nofollow noreferrer">http://www.prototypejs.org/api/class/create</a>:</p>
<pre><code>var Animal = Class.create({
initialize: function(name, sound) {
this.name = name;
this.sound = sound;
},
... | 27,715 |
<p>When editing HTML in emacs, is there a way to automatically pretty-format a blob of markup, changing something like this:</p>
<pre><code> <table>
<tr>
<td>blah</td></tr></table>
</code></pre>
<p>...into this:</p>
<pre><code><table>
<tr>
<td>
blah
&l... | <p>You can do <code>sgml-pretty-print</code> and then <code>indent-for-tab</code> on the same region/buffer, provided you are in html-mode or nxml-mode.</p>
<p><code>sgml-pretty-print</code> adds new lines to proper places and <code>indent-for-tab</code> adds nice indentation. Together they lead to properly formatted ... | <p>The easiest way to do it is via command line.</p>
<ul>
<li>Make sure you have tidy installed</li>
<li>type <code>tidy -i -m <<file_name>></code></li>
</ul>
<p>Note that <code>-m</code> option replaces the newly tidied file with the old one. If you don't want that, you can type <code>tidy -i -o <<... | 16,580 |
<p>In Eclipse IDE how do you customize the Java code style formatter to have it sort the class members with a specified order, for example to group all instance methods by visibility?</p>
| <p>If the question is, "how do you customize the 'Source -> Format' command to re-order members?", I don't think it can be done. To change the order used for the 'Source -> Sort Members' command, change the "Members Sort Order" preference: "Window -> Preferences -> Java -> Appearance -> Members Sort Order"</p>
| <p>I'm not sure when they added this functionality, but it seems to be there in 3.5:</p>
<p>Window -> Preferences</p>
<p>Java -> Editor -> Save Actions</p>
<p>Additional actions -> Configure ...</p>
<p>Code Organizing -> Members -> Sort Members</p>
| 24,136 |
<p>What is the best way to reset a PIC18 using C code with the HiTech Pic18 C compiler?</p>
<p>Edit:</p>
<p>I am currenlty using</p>
<pre><code>void reset()
{
#asm
reset
#endasm
}
</code></pre>
<p>but there must be a better way</p>
| <p>There's a <a href="http://www.microchipc.com/HiTechCFAQ/index.php#_Toc475127553" rel="nofollow noreferrer">FAQ here</a>.</p>
<p>Q: How do I reset the micro?</p>
<blockquote>
<p>One way is to reset all variables to
their defaults, as listed in the PIC
manual. Then, use assembly language
to jump to location... | <p>Unless there's a library function defined by the compiler vendor's runtime library (if such a lib even exists in the microcontroller world ... but it should), then no. C itself certainly won't help you out, doing "a reset" is far too much of a platform-specific issue for C to cover it.</p>
| 26,142 |
<p>I'm new to 3D printing and I recently got a LulzBot Taz 6 printer.</p>
<p>I'm interested in doing dual extrusion printing (especially with dissolvable supports), but I'm also interested in doing single extrusion prints. In particular, I would like to experiment with printing flexible filament.</p>
<p>The <a href="... | <p>Not an expert by any means but I can’t see any reason you couldn’t use one half of a dual extruder. The benefits of not using one though would be decreased extruder weight. Especially given that this is a direct drive so there will be two stepper motors I believe. Reduced weight means faster print times and a reduct... | <p>This may be too late to help, but I wanted to describe my own experience with the Lulzbot Taz Dual Extruder v3. It was...<a href="https://www.amazon.com/gp/customer-reviews/R259P3UB6DJYQ3?ref=pf_ov_at_pdctrvw_srp" rel="nofollow noreferrer">not good</a>.</p>
<p>In terms of your question, I spent a fair amount of ti... | 808 |
<p>I am looking for a (preferably) command-line tool that can reformat the C# source code on a directory tree. Ideally, I should be able to customize the formatting. Bonus points if the tool can be run on <a href="https://en.wikipedia.org/wiki/Mono_%28software%29" rel="nofollow noreferrer">Mono</a> (or Linux).</p>
| <p>You could also try <a href="http://www.narrange.net" rel="nofollow noreferrer">NArrange</a> to reformat your code. The formatting options it supports are still pretty limited, but it can process an entire directory and is a command-line tool. Also, NArrange runs under Mono.</p>
| <p>For completeness, check out <a href="http://uncrustify.sourceforge.net/" rel="nofollow noreferrer">http://uncrustify.sourceforge.net/</a></p>
| 4,690 |
<p>I work on a large C# application (approximately 450,000 lines of code), we constantly have problems with desktop heap and GDI handle leaks. WPF solves these issues, but I don't know what is the best way to upgrade (I expect this is going to take a long time). The application has only a few forms but these can contai... | <p>You can start by creating a WPF host. </p>
<p>Then you can use the <WindowsFormHost/> control to host your current application. Then, I suggest creating a library of your new controls in WPF. One at a time, you can create the controls (I suggest making them custom controls, not usercontrols). Within the style... | <p>There is a very interesting white paper on migrating a .NET 2.0 winform application toward WPF, see <a href="http://www.ythos.net/pdfs/EvolvingDotNet35Apps.pdf" rel="nofollow noreferrer">Evolving toward a .NET 3.5 application</a></p>
<p>Paper abstract:
<em>In this paper, I’m going to outline some of the thought pro... | 13,703 |
<p>Our site is dealing with electronics and practical engineering, so we use formulas in questions and answers on occasion, most usually when we have to figure out electronic ratings. </p>
<p>When we talk about the <a href="https://3dprinting.stackexchange.com/questions/760/analytic-equations-to-make-algorithm-of-3d-p... | <p>$$\text{3D Printing Stack Exchange} \subset \text{Stack Exchange sites that use MathJax}$$</p>
<p>There are <a href="http://data.stackexchange.com/3dprinting/query/879802/mathjax-inline" rel="nofollow noreferrer">~17 posts</a> that could use an edit. Most of those are prices that have been converted into MathJax. ... | <p>MathJax would be really helpful:</p>
<p>We recently discussed <a href="https://3dprinting.stackexchange.com/questions/6832/how-is-infill-generated-via-slicing/6836#6836">How is infill generated via slicing?</a> and the answer is linear algebra. Displaying linear algebra without formulas is a PITA.</p>
| 53 |
<p>I've got some C# code that resizes images that I think is pretty typical:</p>
<pre><code>Bitmap bmp = new Bitmap(image, new Size(width, height));
Graphics graphics = Graphics.FromImage(bmp);
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuali... | <p>It turns the code was just wrong. It was actually resizing the image without interpolation in the Bitmap constructor, and then attempting to smoothly resize that version to the size it was already at. Here is the amended code:</p>
<pre><code>Bitmap bmp = new Bitmap(width, height);
Graphics graph = Graphics.FromImag... | <p>The problem might be another place. I use similar code to resize images and it works ok, but the biggest difference is that when you save the image you have to specify quality (jpeg):</p>
<pre><code>ImageCodecInfo[] codecs=ImageCodecInfo.GetImageEncoders();
ImageCodecInfo codec = null;
for (int i = 0; i<codecs.L... | 43,241 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.