instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>how can one know that each process or a thread is consuming how much memory in MYSQL?</p>
<p>Assuming you just want just the memory usage of the mysql server program.</p> <p>On windows you can use <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="noreferrer">Process Explorer</a> </p> <p>On linux you can use the top command.</p> <ol> <li>Use "ps -e" to find the pid of the mysql ...
<p>on linux you can also use top|grep mysql to get a running report of the stats of the mysql process, 1 row per top refresh period.</p>
12,369
<p>8 bits representing the number 7 look like this:</p> <pre><code>00000111 </code></pre> <p>Three bits are set.</p> <p>What are the algorithms to determine the number of set bits in a 32-bit integer?</p>
<p>This is known as the '<a href="https://en.wikipedia.org/wiki/Hamming_weight" rel="nofollow noreferrer">Hamming Weight</a>', 'popcount' or 'sideways addition'.</p> <p>Some CPUs have a single built-in instruction to do it and others have parallel instructions which act on bit vectors. Instructions like x86's <a href=...
<pre><code>// How about the following: public int CountBits(int value) { int count = 0; while (value &gt; 0) { if (value &amp; 1) count++; value &lt;&lt;= 1; } return count; } </code></pre>
13,428
<p>Now this is .NET but I am sure the principal should apply to all OOP language, to simplify I take .NET as an example:</p> <p>R# usually creator constructor and passing incoming variable to private field, which for me mi tend to pass it to Property. </p> <p>Any opinion on how the different and what is the best prac...
<p>Using properties is OK as long as they are not virtual/overridden. Properties are essentially methods, and you should not call virtual methods from within the constructor because the appropriate type may not be constructed yet. Microsoft has listed their own <a href="http://msdn.microsoft.com/en-us/library/ms22906...
<p>I manipulate fields inside the constructor. Fields really represent the inherent state of your object, and the constructor job is to initialize this internal state. Properties are just here for encapsulation purpose, and are a part of the public interface to the object state.</p> <p>The transformation logic you app...
15,960
<p>A link that stands out is <a href="http://www.devdaily.com/blog/post/jfc-swing/handling-main-mac-menu-in-swing-application/" rel="noreferrer">http://www.devdaily.com/blog/post/jfc-swing/handling-main-mac-menu-in-swing-application/</a> however the menu bar under Mac OS X displays as the package name as opposed to the...
<p>@Kezzer</p> <p>I think I see what's going on. If you put the main() method in a <em>different class</em>, then everything works. So you need something like:</p> <pre><code>public class RootGUILauncher { public static void main(String[] args) { try { System.setProperty("apple.laf.useScreenMe...
<p>If you want to deliver an application that looks native on Mac OS X, one important part is to deliver an appplication bundle. Within the application bundle, you will be able to provide a property list file in order to solve this problems.</p> <p>Some official info: <a href="http://developer.apple.com/documentation/...
39,505
<p>If I have a source.c file with a struct:</p> <pre><code>struct a { int i; struct b { int j; } }; </code></pre> <p>How can this struct be used in another file (i.e. <code>func.c</code>)?</p> <p>Should I create a new header file, declare the struct there and include that header in <code>func.c<...
<h3>if this structure is to be used by some other file func.c how to do it?</h3> <p>When a type is used in a file (i.e. func.c file), it must be visible. The very worst way to do it is copy paste it in each source file needed it.</p> <p>The right way is putting it in an header file, and include this header file wheneve...
<p>a.h:</p> <pre><code>#ifndef A_H #define A_H struct a { int i; struct b { int j; } }; #endif </code></pre> <p>there you go, now you just need to include a.h to the files where you want to use this structure.</p>
28,301
<p>I have problems with Boost.Spirit parsing a string. </p> <p>The string looks like </p> <pre><code>name1 has this and that.\n name 2 has this and that.\n na me has this and that.\n </code></pre> <p>and I have to extract the names. The text "has this and that" is always the same but the name can consist of space...
<p>I think this will do the trick:</p> <pre><code>vector&lt;string&gt; names; string name; parse(str, *( (*(anychar_p - "has this and that.")) [assign_a(name)] &gt;&gt; "has this and that.\n") [push_back_a(names, name)] )) </code></pre>
<p>I presume there is a reason why you are using <a href="http://www.boost.org/doc/libs/1_37_0/libs/spirit/classic/index.html" rel="nofollow noreferrer">Boost.Spirit</a> and not <a href="http://www.sgi.com/tech/stl/table_of_contents.html" rel="nofollow noreferrer">STL</a>'s <a href="http://www.cplusplus.com/reference/s...
47,710
<p>I've recently used our company's spare laptop (that has a general user set up) while mine was being repaired. I've checked the "Remember password" option in SQL Server Management Studio when logging in to the database. </p> <p>I need to clear the login and password information that I have used to prevent the next p...
<p>Another answer here also mentions since 2012 you can remove Remove cached login via <a href="https://stackoverflow.com/questions/10993861/how-to-remove-cached-server-names-from-the-connect-to-server-dialog">How to remove cached server names from the Connect to Server dialog?</a>. Just confirmed this delete in MRU l...
<p>Select the Login drop down arrow. Delete the users from the list</p>
45,496
<p>I'm a CompSci student, and fairly new at C#, and I was doing a "Josephus Problem" program for a class, and I created an Exit button that calls Application.Exit() to exit at anytime, but if C# is still working on painting and the button is pressed it throws an ObjectDisposedExeception for the Graphics object. Is ther...
<p>You should be called the Close() method of the Form that contains the button in order to close down the form in an orderly manner. Closing the main form will cause the application to exit for you anyway.</p>
<p>You should be called the Close() method of the Form that contains the button in order to close down the form in an orderly manner. Closing the main form will cause the application to exit for you anyway.</p>
11,599
<p>How do I make an array shorter in Perl? I read some webpages indicating that I can assign:</p> <pre><code>$#ARRAY = 42; </code></pre> <p>I read that the use of $# is deprecated. I need a solution that will work for an array of arrays, too. This didn't work:</p> <pre><code>$#$ARRAY[$i] = 42; </code></pre>
<p>I'm not aware of assigning <code>$#ARRAY</code> being deprecated; <code>perldoc perldata</code> from 5.10.0 certainly says nothing about it. It is the fastest way to truncate an array.</p> <p>If you want something a little more readable, use <code>splice</code>:</p> <pre><code>splice @ARRAY, 43; </code></pre> <p>...
<p>$#{$ARRAY[$i]} = 42;</p>
11,835
<p>How to represent the start and end times for one day?</p> <p>Using October 23, 2008 as an example, is it start 2008-10-23 12:00:00 AM and end 2008-10-23 11:59:59 PM?</p>
<p>I would like to cite a site, <a href="http://www.cl.cam.ac.uk/~mgk25/iso-time.html" rel="noreferrer">http://www.cl.cam.ac.uk/~mgk25/iso-time.html</a></p> <p>The international standard notation for the time of day is</p> <pre><code>hh:mm:ss </code></pre> <p>where hh is the number of complete hours that have passed...
<p>The definition of the day you mention in the question is any time that is >= 2008-10-23 00:00:00 and &lt; 2008-10-24 00:00:00 .</p>
26,781
<p>What is the most efficient way to cacluate the closest power of a 2 or 10 to another number? e.g.</p> <p>3.5 would return 4 for power of 2 and 1 for power of 10</p> <p>123 would return 128 for power of 2 and 100 for power of 10</p> <p>0.24 would return 0.25 for power of 2 and 0.1 for power of 10</p> <p>I'm just ...
<pre><code>n^round(log_n(x)) </code></pre> <p>where log_n is the logarithm to base n. You may have to modify the round() depending on how you define "closest".</p> <p>Note that <code>log_n(x)</code> can be implemented as:</p> <pre><code>log_n(x) = log(x) / log(n) </code></pre> <p>where <code>log</code> is a logarit...
<p>I think that I might approach the problem, but using log base 2 and log base 10.</p> <p>log10 of (123) is 2.something. take the floor of that then raise 10 to that power, and that ought to get you close.</p> <p>the same thing ought to work with log base 2.</p> <p>log2 of (9) is 3.something take the floor of that ...
33,074
<p>I committed a bunch of files (dozens of files in different folders) by accident. What is the easiest, cleanest (and safest!) way to 'undo' that commit without having to delete the files from my working directory?</p>
<p>Go to <strong>Show Log</strong> Screen, select the revision that you want to undo, right click it and select <strong>Revert changes from this revision</strong>, this will do a <a href="http://svnbook.red-bean.com/en/1.8/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.undo" rel="noreferrer">reverse-mer...
<p>You can revert your working copy to the revision prior to the commit. Once you have reverted your working copy, then simply commit the changes and you will effectively rolled back the accidental commit.</p> <p>In a case like yours specifically, I would probably check out the revision that I wanted to roll back into...
30,923
<p>How to implement a website with a recommendation system similar to stackoverflow/digg/reddit? I.e., users submit content and the website needs to calculate some sort of "hotness" according to how popular the item is. The flow is as follows:</p> <ul> <li>Users submit content</li> <li>Other users view and vote on the...
<p>You could use something similar to the <a href="http://redflavor.com/reddit.cf.algorithm.png" rel="noreferrer">Reddit algorithm</a> - the basic principle of which is you compute a value for a post based on the time it was posted and the score. What's neat about the Reddit algorithm is that you only need recompute th...
<p>I developed an social bookmarking site, <a href="http://www.sites-favoritos.com" rel="nofollow noreferrer">Sites Favoritos</a>, and used a complex algoritm:</p> <ol> <li>First, the votes are finite, an user only have a limited number of votes, and the number of votes depends on the user points. To earn points each ...
9,747
<p>I'm going to be implementing a <code>PHP/mySQL</code> setup to store credit card information.</p> <p>It seems like <code>AES_ENCRYPT/AES_DECRYPT</code> is the way to go,</p> <p><strong>but I'm still confused on one point:</strong></p> <p><strong>How do I keep the encryption key secure?</strong></p> <p>Hardwiring it ...
<p>You should think long and hard about whether you REALLY need to keep the CC#. If you don't have a great reason, DON'T! Every other week you hear about some company being compromised and CC#'s being stolen. All these companies made a fatal flaw - they kept too much information. Keep the CC# until the transaction clea...
<p>I agree, but don't the cc if you don't need too. But if you really have too, make sure the file that have it is not accessible on the web. You can write a binary that would return the key. This way it's not store in clear text. But if your server is compromise it's still easy to get it. </p>
7,947
<p>I have created a custom dialog for Visual Studio Setup Project using the steps described <a href="http://www.codeproject.com/KB/install/vsSetupCustomDialogs.aspx?fid=419622&amp;df=90&amp;mpp=25&amp;noise=3&amp;sort=Position&amp;view=Quick&amp;select=2640482&amp;fr=26" rel="nofollow noreferrer">here</a></p> <p>Now I...
<p>I've always found the custom dialogs in visual studio setup projects to be woefully limited and barely functional.</p> <p>By contrast, I normally create custom actions that display winforms gui's for any remotely difficult tasks during setup. Works really well and you can do just about anything you want by creatin...
<p>I guess you'll have to go beyond the out-of-the-box setup and deployment package and try a third party app.</p> <p>You may want to look at:</p> <ul> <li><a href="http://wix.sourceforge.net/" rel="nofollow noreferrer">Wix</a></li> <li><a href="http://nsis.sourceforge.net/Main_Page" rel="nofollow noreferrer">Nullsof...
3,256
<ol> <li>Specifically getting on Windows the "..\Documents &amp; Settings\All Users, basicaly any path that needs the front end to be dynamically derived based on the OS your software is running on. <strong>(Now I need the answer to this)</strong></li> <li>the current users My Documents dirctory <strong>(okay this has...
<p>My docs would probably best be handled by accessing:</p> <pre><code>System.getProperty("user.home"); </code></pre> <p>Look up the docs on <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html" rel="noreferrer">System.getProperty</a>.</p>
<blockquote> <p>Specifically getting on Windows the "..\Documents &amp; Settings\All Users, basicaly any path that needs the front end to be dynamically derived based on the OS your software is running on. (Now I need the answer to this)</p> </blockquote> <p>The folders below the All Users dir are variable directori...
5,788
<p>Is there anyone working solo and using fogbugz out there? I'm interested in personal experience/overhead versus paper.</p> <p>I am involved in several projects and get pretty hammered with lots of details to keep track of... Any experience welcome.</p> <p>(Yes I know Mr. Joel is on the stackoverflow team... I stil...
<p>I use it, especially since the hosted Version of FugBugz <a href="https://stackoverflow.com/questions/3180/anyone-soloing-using-fogbugz#3581">is free for up to 2 people</a>. I found it a lot nicer than paper as I'm working on multiple projects, and my paper tends to get rather messy once you start making annotations...
<p>Yea FogBugz is great for process-light, quick and easy task management. It seems especially well suited for soloing, where you don't need or want a lot of complexity in that area. </p> <p>By the way, if you want to keep track of what you're doing at the computer all day, check out TimeSprite, which integrates wit...
2,536
<p>How do you go about the requirements gathering phase? Does anyone have a good set of guidelines or tips to follow? What are some good questions to ask the stakeholders? </p> <p>I am currently working on a new project and there are a lot of unknowns. I am in the process of coming up with a list of questions to ask t...
<p>You're almost certainly missing something. A lot of things, probably. Don't worry, it's ok. Even if you remembered everything and covered all the bases stakeholders aren't going to be able to give you very good, clear requirements without any point of reference. The best way to do this sort of thing is to get wh...
<p>I recently started using the concepts, standards and templates defined by the <a href="http://www.theiiba.org" rel="nofollow noreferrer">International Institute of Business Analysts</a> organization (<a href="http://www.theiiba.org" rel="nofollow noreferrer">IIBA</a>). </p> <p>They have a pretty good BOK (Book of K...
4,878
<p>I have a table with a 'filename' column. I recently performed an insert into this column but in my haste forgot to append the file extension to all the filenames entered. Fortunately they are all '.jpg' images.</p> <p>How can I easily update the 'filename' column of these inserted fields (assuming I can select the...
<p>The solution is:</p> <pre><code>UPDATE tablename SET [filename] = RTRIM([filename]) + '.jpg' WHERE id &gt; 50 </code></pre> <p>RTRIM is required because otherwise the [filename] column in its entirety will be selected for the string concatenation i.e. if it is a varchar(20) column and filename is only 10 letters l...
<p>If the original data came from a char column or variable (before being inserted into this table), then the original data had the spaces appended before becoming a varchar.</p> <pre><code>DECLARE @Name char(10), @Name2 varchar(10) SELECT @Name = 'Bob', @Name2 = 'Bob' SELECT CASE WHEN @Name2 = @Name THEN 1 ELS...
3,822
<p>I've been programming for 10+ years now for the same employer and only source code control we've ever used is VSS. (Sorry - That's what they had when I started). There's only ever been a few of us; two right now and we usually work alone, so VSS has worked ok for us. So, I have two questions: 1) Should we switch to ...
<p>I'd probably go with Subversion, if I were you. I'm a total Git fanatic at this point, but Subversion certainly has some advantages: </p> <ul> <li>simplicity</li> <li>abundance of interoperable tools</li> <li>active and supportive community</li> <li>portable</li> <li>Has really nice Windows shell integration</li> ...
<p>I'd say stick with what works for you. Unless you are having issues with VSS, why switch? Subversion is swell, though a little sticky to begin using it. TFS is far better than VSS, though it is fairly expensive for such a small team. I have not used git so I can't really speak to it.</p>
5,158
<p>Is there a way to step through a .bat script? The thing is, I have a build script , which calls a lot of other scripts, and I would like to see what is the order in which they are called, so that I may know where exactly I have to go about and add my modifications.</p>
<p>I don't know of anyway to step through the execution of a .bat file but you can use <code>echo</code> and <code>pause</code> to help with debugging.</p> <blockquote> <p><strong>ECHO</strong><br> Will echo a message in the batch file. Such as ECHO Hello World will print Hello World on the screen when executed. H...
<p>or, open a cmd window, then call the batch from there, the output will be on the screen.</p>
20,038
<p>Our company is looking to integrate invoices into a new system we are developing.</p> <p>We require a solution to create a layout of the invoice and then convert to pdf.</p> <p>We have considered just laying out the invoice in html/css then converting to pdf. We have also considered using SVG->PDf conversion.</p>...
<p>Try this... create a blank invoice with Word (or whatever you want) and save it as a PDF.</p> <p>Then use a PDF library to modify the PDF (insert the text at particular coordinates). We do this in the Microsoft world and it is extremely easy.</p> <p>The biggest benefit is that we can use our own tools to create an...
<p>This html-2-pdf site may be a helpful starting point: <a href="http://maarten.lippmann.us/?p=101" rel="nofollow noreferrer">http://maarten.lippmann.us/?p=101</a></p> <p>A site a friend of mine built uses a script to churn HTML pages into printable PDFs, too - <a href="http://philambdaupsilon.org" rel="nofollow nor...
34,033
<p>For classes that have a long list of setters that are used frequently, I found this way very useful (although I have recently read about the <a href="http://en.wikipedia.org/wiki/Builder_pattern" rel="noreferrer">Builder pattern</a> in <em>Effective Java</em> that is kinda the same).</p> <p>Basically, all setter met...
<p>@pek<br/> Chained invocation is one of proposals for Java 7. It says that if a method return type is void, it should implicitly return <strong>this</strong>. If you're interested in this topic, there is a bunch of links and a simple example on <a href="http://tech.puredanger.com/java7#chained" rel="noreferrer">Alex ...
<p>I agree with @Bernard that method chaining like this muddles the purpose of the setters. Instead I would suggest that if you are always creating chains of setters like this that you create a custom Constructor for your class so instead of</p> <pre><code> MyClass .setInt(1) .setString("test") .setBool...
5,155
<p>After reading E-myth Revisited, I realize that I can do a better job at making my company less reliant upon me... I spend a tremendous amount of time answering silly questions (silly to me, but necessary for my developers to get the job done).</p> <p>I need to write a set of operating manuals for what to do in certa...
<p>What about a wiki - at least then other people can start to contribute.<br> Otherwise they are just going to rely on you for the manuals</p>
<p>I disagree with the wiki. As the owner of the company -- it is your responsibility to write the manuals, or delegate it in a very controlled fashion. People <em>should</em> rely on you for the manuals.</p> <p>Really though, back to the question. The obvious standards, coding, SQL, etc for your platform and progr...
20,482
<p>I need a solution to catalog a number of applications in our company (more than 100 less than 1000). </p> <p>Right now we are using a spreadsheet and for each app we fill in name, short description, contact person and maintainer (internal or vendor). The puspose is to use this list for IT planning and incident mana...
<p>This is tailor-made for a nice, simple web-app framework. Pick your favorite framework. Define your simple data model for applications. Migrate your spreadsheet. Add your other relationships (depends-on, supersedes, part-of) and evolve your application.</p> <p>Any good web-app framework will have pleasant data ...
<p>You can maybe take a look at <a href="http://www.eclipse.org/cosmos/" rel="nofollow noreferrer">COSMOS</a>, an implementation of the <a href="http://www.cmdbf.org/" rel="nofollow noreferrer">CMDBf</a> specifications</p>
25,550
<p>What code generation tools are built-in to vs.net 2008 or are officially available via Microsoft?</p> <p>I know of:</p> <ul> <li>Entity Framework</li> <li>sqlmetal</li> </ul> <p>What else is there?</p> <p>Ideally i'm looking for something that will generate from an existing database schema.</p>
<p>I'm not sure the platform you're internationalizing in. I've written an answer before on the best way to il8n an application. See <a href="https://stackoverflow.com/questions/59130/what-do-i-need-to-know-to-globalize-an-asp-net-application/59184#59184">What do I need to know to globalize an asp.net application?</a><...
<p>In Java, internationalization is accomplished by moving the strings to resource bundles ... the translation process is still long and arduous, but at least it's separated from the process of producing the software, releasing service packs etc. One thing that helps is to have a CI system that repackages everything a...
23,200
<p><code>temp2</code>, <code>temp1</code> are pointers to some struct x:</p> <pre><code>struct FunkyStruct x; struct FunkyStruct *temp1 = &amp;x, *temp2 = &amp;x; </code></pre> <p>Now, after execution of following lines:</p> <pre><code>temp2=temp1; temp1=temp1-&gt;nxt; </code></pre> <p>...Will <code>temp2</code> an...
<p>Initially, <code>temp1</code> and <code>temp2</code> both contain the memory address of <code>x</code>.</p> <p><code>temp2 = temp1</code> means "assign the value of <code>temp1</code> to <code>temp2</code>". Since they have the same value to start with, this command does nothing.</p> <p>The expression <code>temp1...
<p>x (and therefore x.nxt) will be initialised to an unspecified value, depending on the combination of compiler, compiler options and the runtime environment. temp1 and temp2 will both point to x (before and after temp1=temp2). Then temp1 will be assigned whatever value x.nxt has.</p> <p>Final answer: 0 &lt; Pr(temp1...
13,488
<p>Our logging class, when initialised, truncates the log file to 500,000 bytes. From then on, log statements are appended to the file.</p> <p>We do this to keep disk usage low, we're a commodity end-user product.</p> <p>Obviously keeping the first 500,000 bytes is not useful, so we keep the last 500,000 bytes.</p> ...
<blockquote> <p>"I would probably create a new file, seek in the old file, do a buffered read/write from old file to new file, rename the new file over the old one."</p> </blockquote> <p>I think you'd be better off simply:</p> <pre><code>#include &lt;fstream&gt; std::ifstream ifs("logfile"); //One call to start it...
<p>I don't think it is anything computer related, but how you guys have written your logging class. It sounds strange to me that you read the last 500k into a string, why would you do that?</p> <p>Just append to the logfile.</p> <pre><code> fstream myfile; myfile.open("test.txt",ios::app); </code></pre>
44,969
<p>Lucene has quite poor support for Russian language.</p> <p>RussianAnalyzer (part of lucene-contrib) is of very low quality.</p> <p>RussianStemmer module for Snowball is even worse. It does not recognize Russian text in Unicode strings, apparently assuming that some bizarre mix of Unicode and KOI8-R must be used in...
<p>If all else fails, use <a href="http://www.sphinxsearch.com/" rel="nofollow noreferrer">Sphinx</a></p>
<p>That's the beauty of open source. You have the source code, so if the current implementations don't work for you, you can always create your own or even better, extend the existing ones. A good start would be the "Lucene in Action" book.</p>
8,934
<p>I am curious on how others manage code promotion from DEV to TEST to PROD within an enterprise.</p> <p>What tools or processes do you use to manage the "red tape", entry/exit criteria side of things?</p> <p>My current organisation is half stuck between some custom online forms type functionality and paper based de...
<p>It's hard to find one that's good via google. There is a vast array of tools out there for issue management so I'll mention what we use and what we woudl like to use.</p> <p>We currently use serena products. They have worked well for us in the past. Team Track is our issue management and handles the life cycle o...
<p>There are a few different scenarios that I've experienced over the years:</p> <p>Dev -> Test : There is usually a code freeze date that stops work on new features and gets a test environment the code that has been tagged/labelled/archived that gets built. This then gets copied onto the machines and the tests go fi...
22,956
<p>I have a web application that has many faces and so far I've implemented this through creating themes. A theme is a set of html, css and images to be used with the common back end.</p> <p>Things are laid out like so:</p> <pre><code>code/ themes/theme1 themes/theme2 </code></pre> <p>And each instance of the web a...
<p>I don't have a specific recommendation. However, I strongly suggest to <strong>NOT</strong> take shortcut... Use the solution that will you will find comfortable to add a third theme or to change something next year.<br> Duplication is the enemy of maintainability.</p>
<p>Are you using Master Pages? If you need different layout and UI stuff you could just have a different set of master pages for each of your instances. If you need custom behavior then you might want to look into Dependency Injection. Spring.NET, etc.</p>
30,459
<p>I want to print HTML from a C# web service. The web browser control is overkill, and does not function well in a service environment, nor does it function well on a system with very tight security constraints. Is there any sort of free <code>.NET</code> library that will support the printing of a basic HTML page? ...
<p>You can print from the command line using the following:</p> <blockquote> <p>rundll32.exe %WINDIR%\System32\mshtml.dll,PrintHTML "%1"</p> </blockquote> <p>Where %1 is the file path of the HTML file to be printed.</p> <p>If you don't need to print from memory (or can afford to write to the disk in a temp fil...
<p>I don't know the specific tools, but there are some utilities that record / replay clicks. In other words, you could automate the "click" on the print dialog. (I know this is a hack, but when all else fails...)</p>
2,265
<p>Moments ago <a href="http://twitter.com/codinghorror/status/1051535711" rel="nofollow noreferrer">Jeff Atwood said the following on twitter</a>:</p> <blockquote> <p>Look, I love rapid new software releases, but the frequency of WordPress releases is just ridiculous.</p> </blockquote> <p>Which makes me think, <st...
<p>I would say in WordPress' specific case, <strong>they conflate "security updates" and "functionality updates"</strong>. This is bad.</p> <p>This would be like having to do an in-place reinstall of Windows every time a security bug was found, instead of simply downloading a small patch every week.</p> <p>WordPress ...
<p>Surely when you have new features/bug fixes worth releasing ?? Why have it on a schedule ?</p>
46,985
<p>I had the BLTouch (3.1) working with stock firmware on an Ender 3 v2 but wanted to get a 5x5 mesh instead of the 3x3 so I installed the TH3D firmware. With the stock firmware my Z-offset was -2.95 mm.</p> <p>After installing TH3D firmware, my Z-offset has to be in excess of -6 mm to reach the same nozzle-to-bed heig...
<p>I'm pretty sure something is wrong with the firmware I downloaded. I flashed the 3/5/21 version of Marlin firmware from <a href="https://marlin.crc.id.au/" rel="nofollow noreferrer">https://marlin.crc.id.au/</a> and it is somehow working better with the LCD firmware (which I got from TH3D), the Z offset is working a...
<p>Do you still have this issue? My Ender with a BLTouch won't respect the Z-off set setting in <strong>Motion</strong> &gt; <strong>Control</strong> &gt; <strong>ZOffset</strong>. You can change it to -10 and it will still start printing about 1 cm above the bed.</p> <p>All of this started to happen after I used <stro...
1,881
<p>I have migrated a couple of project from Subversion to git. It work really well but when I clone my repository, it's really long because I have all the history of a lot of .jar file included in the transfer.</p> <p>Is there a way to keep only the latest version of certain type of file in my main repository. I mainl...
<p>You can remove old versions with either "git rebase" -i or "git filter-branch"</p> <p><a href="http://schacon.github.com/git/git-filter-branch.html" rel="nofollow noreferrer">http://schacon.github.com/git/git-filter-branch.html</a></p> <p><a href="http://schacon.github.com/git/git-rebase.html" rel="nofollow norefe...
<p>In short, this would involve rewriting the entire git commit tree to exclude the files. Have you tried using <code>git gc</code> and <code>git pack</code> to have git compress your repository?</p>
12,235
<p>I'm working on database designs for a project management system as personal project and I've hit a snag.</p> <p>I want to implement a ticket system and I want the tickets to look like the <a href="http://trac.edgewall.org/ticket/6436" rel="noreferrer">tickets in Trac</a>. What structure would I use to replicate thi...
<p>I have implemented pure record change data using a "thin" design:</p> <pre><code>RecordID Table Column OldValue NewValue -------- ----- ------ -------- -------- </code></pre> <p>You may not want to use "Table" and "Column", but rather "Object" and "Property", and so forth, depending on your design.</p> <p...
<p>One possible solution is storing a copy of the ticket in a history table with the user that made the change. </p> <p>However, this will store alot of extra data and require alot of processing to create the view that Trac shows.</p>
17,115
<p>I came back today to an old script I had for logging into Gmail via SSL. The script worked fine last time I ran it (several months ago) but now it dies immediately with:</p> <pre><code>&lt;urlopen error The read operation timed out&gt; </code></pre> <p>If I set the timeout (no matter how long), it dies even more i...
<pre><code>import socket socket.setdefaulttimeout(30000) sock = socket.socket() sock.connect(('www.google.com', 443)) ssl = socket.ssl(sock) ssl.server() --&gt; '/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com' </code></pre> <p>It works just fine. I can't reproduce your error.</p>
<p>www.google.com is not accessible by HTTPS. It redirects to insecure HTTP. To get to mail, you should be going go <a href="https://mail.google.com" rel="nofollow noreferrer">https://mail.google.com</a></p>
11,809
<p>I need to build a little webapp but I'm not sure what is the best thing to do.</p> <p>A person that subscribe the petition is signing an email sent to <em>X</em>. This will be also saved to a db in order to show online who subscribed.</p> <p>The idea is to have a standard text message, the user submit his name and...
<p>Regardless of the whole thing being a "good" idea or not, you want to keep yourself safe. If you spoof the from field, chances are most of your email (especially for domains with SPF records) will not make it through the first level of spam filtering.</p> <p>A SPF (Sender Policy Framework) record lists the only IPs...
<p>Let me get this straight - so you want to add to the flood of armchair activism email that is already saturating the world to no good purpose, and you're asking how best to do it? I would read the following before going any further with this:</p> <p><a href="http://www.breakthechain.org/armchair.html" rel="nofollo...
23,577
<p>I've been using the YUI Components and want to begin using the Loader Utility to specify my dependencies on my page. From your experience, is the YUI Loader Utility a reliable way to load Javascript dependencies in web pages?</p>
<p>Yes, YUI Loader is reliable on all A-grade browsers. For a list of which browsers Yahoo! considers A-grade, check out the <a href="http://developer.yahoo.com/yui/articles/gbs/" rel="nofollow noreferrer">Graded Browser Support Chart</a>.</p>
<p>I use the loader a lot. It's a great way to manage dependencies and build you library around.</p> <p>I've run into 3 problems with it:</p> <ol> <li>Debugging - it's difficult to debug. Is the bug in the module's loader definition or is it in the module (script file)?</li> <li>You have to add your own 'subscibeOn...
11,526
<p>In short - How do I translate a NETBIOS domain to a FQDN ?</p> <p>Details: Assuming I'm in domain A and I have user credentials for domain B which has a trust relationship with domain A (I can authenticate the credentials). How do I get domain B's FQDN when all I have are the credentials of some authenticated user ...
<p>This probably isn't optimal, but it look like you could do a NetBIOS name query to get an IP address, and then do a reverse DNS lookup to get an FQDN from that...</p> <p><a href="http://www.protocolbase.net/protocols/protocol_NBNS.php" rel="nofollow noreferrer">http://www.protocolbase.net/protocols/protocol_NBNS.ph...
<p>Bind to the domain using the WinNT provider and filter for all user accounts. Start enumerating the user accounts.</p> <p>If the user account sAMAccount name does not contain the string "duplicate" then exit from the loop and use the NameTranslate object to look up the LDAP name of the account.</p> <p>Part of the ...
32,845
<p>Is there a way to enforce constraint checking in MSSQL only when inserting new rows? I.e. allow the constraints to be violated when removing/updating rows?</p> <p>Update: I mean FK constraint.</p>
<p>You could create an INSERT TRIGGER that checks that the conditions are met. That way all updates will go straight through.</p> <pre><code>CREATE TRIGGER employee_insupd ON employee FOR INSERT AS /* Get the range of level for this job type from the jobs table. */ DECLARE @min_lvl tinyint, @max_lvl tinyint, @em...
<p>I think your best bet is to remove the explicit constraint and add a <a href="http://msdn.microsoft.com/en-us/library/ms180169.aspx" rel="nofollow noreferrer">cursor</a> for inserts, so you can perform your checking there and raise an error if the constraint is violated.</p>
5,988
<p>How can I run background tasks on App Engine?</p>
<p>You may use the <a href="http://code.google.com/appengine/docs/python/taskqueue/" rel="noreferrer">Task Queue Python API</a>. </p>
<p>Use the Task Queue - <a href="http://code.google.com/appengine/docs/java/taskqueue/overview.html" rel="nofollow">http://code.google.com/appengine/docs/java/taskqueue/overview.html</a></p>
17,994
<p>Suppose that I have a form that contains three 10 fields: field1..field10. I store the form data in one or more database tables, probably using 10 database columns. </p> <p>Now suppose a few months later that I want to add 3 more fields. And in the future I may add/delete fields from this form based on changing...
<p>You could abstract fields to a separate table so that they are many-to-many to the Form table:</p> <h2>Form</h2> <p><strong>ID</strong><br/> Name<br/> etc.</p> <h2>Field</h2> <p><strong>ID</strong><br/> Label<br/> Value</p> <h2>FormField</h2> <p><strong>FormID</strong><br/> <strong>FieldID</strong></p>
<p>My team came up with a solution for this when I worked for Quest Computing on AIMS (www.totalaims.com). In summary we added maintenance screens that allowed the administrator to add metadata and also as a result add fields to the database in certain tables. The fields were also added to their own maintenance and ...
5,214
<p>I've just downloaded the ASP.MVC MSI package, but the installation fails with the "<strong>There is a problem with this Windows Installer Package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor.</strong>" message.</p> <p>I see that other people too ha...
<p>I removed all the bad templates and this didn't resolve the issue for me. I found that removing other Add-Ins I had installed let me install Beta 1. In my case the bad add-in preventing the install was <a href="http://www.codeplex.com/CloneDetectiveVS" rel="nofollow noreferrer">Clone Detective</a>.</p>
<p>I had this exact error message from a completely different MSI package - the DevExpress toolkit - turned out to be caused by one of the "defensive" packages installed on my machine.</p> <p>Check your anti-virus, anti-spyware, anti-intrusion, firewall, anti-xxx etc etc packages to see if any of them might be stoppin...
28,342
<p>So, I want to export all my contacts from Outlook as vcards. If I google that, I get a bunch of shareware programs, but I want something free that just works. </p> <p>If I'm to code it myself, I guess I should use the Microsoft.Office.Interop.Outlook assembly. Has anyone already code to convert ContactItems to vcar...
<p>I solved it in a non-programmatically way:</p> <ul> <li>Selected all contacts in Outlook</li> <li>Forwarded them as cards to myself</li> <li>Saved all the attachments (vcards) in a folder, <code>c:\temp</code></li> <li>Opened a command prompt and typed the command <code>copy /a *.vcf c:\allcards.vcf</code> which co...
<p>Just purchased the X8 and was about to get really really mad when I couldn't easily transfer my contacts...until I started snooping around on the phone.</p> <p>First, export all your contacts in Outlook to vCards (I found emailing them to yourself is the easiest. If you get an error message "to many attachments......
25,627
<p>The <a href="https://en.wikipedia.org/wiki/Singleton_pattern" rel="noreferrer">singleton pattern</a> is a fully paid up member of the <a href="https://en.wikipedia.org/wiki/Design_Patterns" rel="noreferrer">GoF</a>'s <a href="https://rads.stackoverflow.com/amzn/click/com/0201633612" rel="noreferrer" rel="nofollow no...
<p>Paraphrased from Brian Button:</p> <ol> <li><p>They are generally used as a global instance, why is that so bad? Because you hide the dependencies of your application in your code, instead of exposing them through the interfaces. Making something global to avoid passing it around is a <a href="https://en.wikipedia....
<p>Off the top of my head:</p> <ol> <li>They enforce tight-coupling. If your singleton resides on a different assembly than its user, the using assembly cannot ever function without the assembly containing the singleton.</li> <li>They allow for circular dependencies, e.g., Assembly A can have a singleton with a depend...
16,688
<p>Below is my (simplified) schema (in MySQL ver. 5.0.51b) and my strategy for updating it. There has got to be a better way. Inserting a new item requires 4 trips to the database and editing/updating an item takes up to <strong>7</strong>!</p> <p><strong>items</strong>: itemId, itemName <br /><strong>categories</stro...
<p>Steps 6 &amp; 7 can be combined easily enough:</p> <pre><code>DELETE categories.* FROM categories LEFT JOIN map USING (catId) WHERE map.catID IS NULL; </code></pre> <p>Steps 3 &amp; 4 can also be combined:</p> <pre><code>INSERT IGNORE INTO map (mapId, itemId, catId) SELECT CONCAT('1|', c.catId), 1, c.catID ...
<p>Steps 6 &amp; 7 can be combined easily enough:</p> <pre><code>DELETE categories.* FROM categories LEFT JOIN map USING (catId) WHERE map.catID IS NULL; </code></pre> <p>Steps 3 &amp; 4 can also be combined:</p> <pre><code>INSERT IGNORE INTO map (mapId, itemId, catId) SELECT CONCAT('1|', c.catId), 1, c.catID ...
36,824
<p>I am trying to <strong>synchronize</strong> the horizontal <strong>scroll position</strong> of 2 <strong>WPF DataGrid</strong> controls.</p> <p>I am subscribing to the <strong>ScrollChanged</strong> event of the first DataGrid:</p> <pre><code>&lt;toolkit:DataGrid x:Name="SourceGrid" ScrollViewer.ScrollChanged="Sou...
<p>According to the Microsoft product group, traversing the visual tree to find the ScrollViewer is the recommended method, as <a href="http://wpf.codeplex.com/discussions/40161" rel="nofollow noreferrer">explained in their answer on Codeplex</a>.</p>
<p>We had this same problem when using the Infragistics grid because it <em>didn't</em> (still doesn't) support frozen columns. So we had two grids side-by-side that were made to look as one. The grid on the left didn't scroll horizontally but the grid on the right did. Poor man's frozen columns.</p> <p>Anyway, we end...
37,428
<p>We are currently using Apache 2.2.3 and Tomcat 5 (Embedded in JBoss 4.2.2) using <code>mod_proxy_jk</code> as the connector.</p> <p>Can someone shed some light on the the correct way to calculate / configure the values below (as well as anything else that may be relevant). Both Apache and Tomcat are running on sep...
<p>You should consider the workload the servers might get.</p> <p>The most important factor might be the number of simultaneously connected clients at peak times. Try to determine it and tune your settings in a way where:</p> <ul> <li>there are enough processing threads in both Apache and Tomcat that they don't need ...
<p>The default settings are generally decent starting points to see what your applications is really going to need. I don't know how much traffic you're expecting, so guessing at the MaxThreads, MaxClients, and MaxServers is a bit difficult. I can tell you that most of the customers I deal with (work for a linux web ho...
13,128
<p>In a Swing app a method should continue only after user enters a correct answer. The correct answer is stored in a <code>String</code> with user answer being set by a listener to another <code>String</code>. So, the code is</p> <pre><code>while (!correctAnswer.equals(currentAnswer)) { // wait for user to click...
<p>Are you new to UI programming? The reason I ask is that your answer is predicated on a procedural style of coding, which isn't what UIs are about. It tends to be event-driven.</p> <p>In this case the solution is pretty easy: add an event listener (<code>ActionListener</code>) to the submit button and check the re...
<p>If your strings are coming from a human user at GUI rates, there's very little point in optimizing for performance. The human won't be able to enter more than perhaps one to three strings per second, and that's nothing for the machine.</p> <p>In this particular case, where you need to do stuff to get an input to te...
43,305
<p>I'm using a <code>RichTextBox</code> (.NET WinForms 3.5) and would like to override some of the standard ShortCut keys.... For example, I don't want <kbd>Ctrl</kbd>+<kbd>I</kbd> to make the text italic via the RichText method, but to instead run my own method for processing the text.</p> <p>Any ideas?</p>
<p><kbd>Ctrl</kbd>+<kbd>I</kbd> isn't one of the default shortcuts affected by the ShortcutsEnabled property.</p> <p>The following code intercepts the <kbd>Ctrl</kbd>+<kbd>I</kbd> in the KeyDown event so you can do anything you want inside the if block, just make sure to suppress the key press like I've shown.</p> <pre...
<p>Set the RichtTextBox.ShortcutsEnabled property to true and then handle the shortcuts yourself, using the KeyUp event. E.G.</p> <pre><code>using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { Initializ...
32,599
<p>I have rules set to move some email messages into different folders. I would like this to still show the envelope in the notification area but there is no option in the rules wizard to do this. It looks like I would either have to have the rule "run a script" or "perform a custom action" allowing either vba or c/c++...
<p>It sounds like you could use a Rails non active-record model. There's a good Railscast about that : </p> <p><a href="http://railscasts.com/episodes/121-non-active-record-model" rel="noreferrer">http://railscasts.com/episodes/121-non-active-record-model</a></p> <p>Hope that helps, </p>
<p>This is an area that's not well documented at present, probably because the ActiveRecord stuff is sexier?</p> <p>I went through the same process, finding my controller actions were becoming uncomfortably large and full of logic as I strove to construct my derived data from ActiveRecord-based models, which in turn s...
44,324
<p>I'm running into a problem setting up my development environment. I've been working on ColdFusion and .NET applications up until recently I haven't needed to touch IIS. Now, I have to set up a classic ASP application for some one-off work.</p> <p>I added a virtual directory in IIS and pointed it at the actual codeb...
<p>Take a look at your URL scan settings and see if .asp is an allowed file extension</p> <p>On my XP machine the relevant file is located at C:\WINDOWS\system32\inetsrv\urlscan\urlscan.ini</p>
<p>Take a look at your URL scan settings and see if .asp is an allowed file extension</p> <p>On my XP machine the relevant file is located at C:\WINDOWS\system32\inetsrv\urlscan\urlscan.ini</p>
22,259
<p>How can I dock a CControlBar derived window to the middle of a splitter window (CSplitterWnd)? I would like the bar to be repositioned whenever the splitter is moved.</p> <p>To make it a little clearer as to what I'm after, imagine the vertical ruler in the Dialog Editor in Visual Studio (MFC only). It gets repos...
<p>Alf,</p> <p>In case of VS, there's no splitter used: The resource view is a resizable ControlBar (It looks and feels like a splitter but it isn't a CSplitterWnd). The rest is a child frame (either tabbed or MDI. Go to Tools/Options/Environment/General and choose Multiple Documents to convince yourself). The ruler i...
<p>Serge, I apologize, I wasn't very clear. The splitter would be between the resource view and the ruler bar. It would looke like this:</p> <p>Resource View | Vertical ruler | View</p> <p>In any case, I found the (now obvious) answer: split the main frame into three windows:</p> <pre><code>m_wndSplitter.CreateSta...
19,828
<p>I need to use XmlRpc in C++ on a Windows platform. Despite the fact that my friends assure me that XmlRpc is a "widely available standard technology", there are not many libraries available for it. In fact I only found one library to do this on Windows, (plus another one that claims "you'll have to do a lot of wor...
<p>I've written my own C++ library. It's available at sourceforge: <a href="http://sourceforge.net/projects/xmlrpcc4win/" rel="noreferrer">xmlrpcc4win</a></p> <p>The reason I wrote it rather than using Chris Morley's was that:</p> <ul> <li>The Windows "wininet.lib" library gives you all the functionality for handlin...
<p>There are dozens of implementations of the XML-RPC <a href="http://www.xmlrpc.com/directory/1568/implementations" rel="nofollow noreferrer">implementations</a>, some in C++, but most in other languages. For example, besides XmlRpc++ there is also <a href="http://xmlrpc-c.sourceforge.net/" rel="nofollow noreferrer">X...
9,364
<p>If you have a project, that releases a library and an application, how you handle version-numbers between the two.</p> <p>Example: Your project delivers a library, that convert different file-formats into each other. The library is released for inclusion into other applications. But you also release a command-line-...
<p>Completely independent version numbers, but the command line (or any other dependent) app should say which version of the library it was compiled against in the help section or a banner. </p> <p>That way you will be able to tell which functionality will the apps have and reduce potential confusion, especially given...
<p>We built an application that uses a framework. We keep separate version numbers for both.</p> <p>This works well, especially that now the framework and application have grown large enough to be developed by different teams.</p> <p>So my opinion... keep the version numbers separate.</p>
17,295
<p>Is there a tool to automatically search through my site and test all the links? I hate running across bad urls.</p>
<p><a href="http://home.snafu.de/tilman/xenulink.html" rel="nofollow noreferrer">Xenu link sleuth</a> is excellent (and free)</p>
<p>Something like this should work: <a href="http://www.dead-links.com/" rel="nofollow noreferrer">http://www.dead-links.com/</a></p> <p>Do google searches for "404 checker" or "broken link checker"</p>
12,196
<p>MySQL 5.0.45</p> <p>What is the syntax to alter a table to allow a column to be null, alternately what's wrong with this:</p> <pre><code>ALTER mytable MODIFY mycolumn varchar(255) null; </code></pre> <p>I interpreted the manual as just run the above and it would recreate the column, this time allowing null. The ...
<p>You want the following:</p> <pre><code>ALTER TABLE mytable MODIFY mycolumn VARCHAR(255); </code></pre> <p>Columns are nullable by default. As long as the column is not declared <code>UNIQUE</code> or <code>NOT NULL</code>, there shouldn't be any problems.</p>
<p>Use: <code>ALTER TABLE mytable MODIFY mycolumn VARCHAR(255);</code></p>
26,170
<p>I need to convert HTML documents into valid XML, preferably XHTML. What's the best way to do this? Does anybody know a toolkit/library/sample/...whatever that helps me to get that task done?</p> <p>To be a bit more clear here, my application has to do the conversion automatically at runtime. I don't look for a tool...
<p><a href="http://www.ibm.com/developerworks/library/tiptidy.html" rel="nofollow noreferrer"><strong>Convert from HTML to XML with HTML Tidy</strong></a></p> <p><a href="http://tidy.sourceforge.net/#binaries" rel="nofollow noreferrer"><strong>Downloadable Binaries</strong></a></p> <p>JRoppert, For your need, i guess...
<p>The easiest way is to set your Visual Studio IDE to identify the changes you need to make. You can do this in Visual Studio 2008 by going to: Tools, Options, Text Editor, HTML, Validation and choosing the appropriate target. Possibly XHTML 1.1 or XHTML 1.0 Transitional.</p> <p>For some information on the different ...
16,780
<p>When using Slic3r I noticed that <code>Slice now</code> and <code>Export G-Code</code> do different things. While <code>Slice now</code> is nice, it does not show any tool paths etc. </p> <p>Is there an actual way to generate and visualize the G-code in Slic3r without saving the exported G-Code first? When aligning...
<p>Using Repetier Host V2.1.2 and slicing with Slic3r (or with CuraEngine), there is an "edit Gcode" button under the Print Preview tab. It is located at the top right of the screen. With that button you can access, examine and change the Gcode of the project you are working on.</p>
<p>After you use the Slice Now button (and the slicing progress bar shows completed), select the preview tab. To the right of the window you will see a pair of vertical sliders. Each slider changes the start and finish locations for the filament layers.</p> <p>You can slide the left one to the bottom, which will "empt...
943
<p>I'm trying to build an assembly with one larger part (about 50&nbsp;mm&nbsp;x&nbsp;50&nbsp;mm), two small parts (about 10&nbsp;mm&nbsp;x&nbsp;5&nbsp;mm) each, and one part that starts with two 2&nbsp;mm&nbsp;x&nbsp;2&nbsp;mm squares that eventually bridge into a sort of flap. The larger part has decent adhesion for ...
<p><em>This is a &quot;No&quot; and &quot;Yes&quot; answer, it depends on the version of Cura you are using!</em></p> <hr /> <p><strong>No</strong>, there are no options available to set the brim to some of the parts in Ultimaker Cura (at the time of writing this answer, pre Cura 4.5.0). You could however change the sm...
<p>This post is quite old, but I describe how I solved this for anyone has the same problem I had: areas moved by the nozzle as the base of some appendices are too thin and tall.</p> <p>In Cura 4.8 (I don't know since which version this feature is available) it is possible to add some custom shapes (cubes or cylinders)...
1,169
<p>I'm curious to know if there is an easy way to mock an IMAP server (a la the <code>imaplib</code> module) in Python, <em>without</em> doing a lot of work.</p> <p>Is there a pre-existing solution? Ideally I could connect to the existing IMAP server, do a dump, and have the mock server run off the real mailbox/email ...
<p>I found it quite easy to write an IMAP server in twisted last time I tried. It comes with support for writing IMAP servers and you have a huge amount of flexibility.</p>
<p>I never tried but, if I had to, I would start with the existing SMTP server.</p>
45,790
<p>What is the best way to construct a bit mask in C with <code>m</code> set bits preceded by <code>k</code> unset bits, and followed by <code>n</code> unset bits:</p> <pre><code>00..0 11..1 00..0 k m n </code></pre> <p>For example, k=1, m=4, n=3 would result in the bit mask:</p> <pre><code>01111000 </code...
<p>You can do:</p> <pre><code>~(~0 &lt;&lt; m) &lt;&lt; n </code></pre>
<p>Whilst the top answers are simple and effective they don't set the MSB for the case when <code>n=0</code> and <code>m=31</code>:</p> <p><code>~(~0 &lt;&lt; 31) &lt;&lt; 0</code> = ‭<code>0111 1111 1111 1111 1111 1111 1111 1111‬</code></p> <p><code>((1 &lt;&lt; 31)-1) &lt;&lt; 0</code> = ‭<code>0111 1111 1111 1111 1...
40,868
<p>I am trying to render a user control into a string. The application is set up to enable user to use tokens and user controls are rendered where the tokens are found.</p> <pre><code>StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); HtmlTextWriter writer = new HtmlTextWriter(sw); Contr...
<p>I've been using the following code provided by Scott Guthrie in his blog for quite some time:</p> <pre><code>public class ViewManager { public static string RenderView(string path, object data) { Page pageHolder = new Page(); UserControl viewControl = (UserControl) pageHolder.LoadControl(pat...
<p>I took Hauge's/ Scott Guthrie's method above and tweaked it so that you don't need to use reflection, or modify a UserControl to implement any special interface. The key was I added a strongly typed callback that the RenderView method above calls, instead of doing reflection.</p> <p>I blogged the helper method and...
32,325
<p>I was recently brushing up on some fundamentals and found merge sorting a linked list to be a pretty good challenge. If you have a good implementation then show it off here.</p>
<p>Wonder why it should be big challenge as it is stated here, here is a straightforward implementation in Java with out any &quot;clever tricks&quot;.</p> <pre class="lang-java prettyprint-override"><code>//The main function public static Node merge_sort(Node head) { if(head == null || head.next == null) ...
<pre class="lang-java prettyprint-override"><code>public int[] msort(int[] a) { if (a.Length &gt; 1) { int min = a.Length / 2; int max = min; int[] b = new int[min]; int[] c = new int[max]; // dividing main array into two half arrays for (int i = 0; i &lt; min; i++) { ...
2,929
<p>So, let's say I want to write a class that operates on different kinds of numbers, but I don't a priori know what kind of numbers (i.e. ints, doubles, etc.) I will be operating on.</p> <p>I would like to use generics to create a general class for this scenario. Something like:</p> <pre><code> Adder&lt;Double&gt; ...
<p>Uh oh---generics are not C++ templates. Because of type erasure, the <code>Double</code> in your example won't even show through to the runtime system.</p> <p>In your particular case, if you just want to be able to add various types together, may I suggest method overloading? e.g., <code>double add(double, double)<...
<p>If you don't know what kinds of numbers you'll be operating on, then you probably won't be using instance variables of your own. In that case, you can write static methods and never need to instantiate your class.</p> <p>If you really need your own intermediate variables, then you will likely need to define them d...
36,295
<p>So I'm been pounding on this problem all day. I've got a LinqDataSource that points to my model and a GridView that consumes it. When I attempt to do an update on the GridView, it does not update the underlying data source. I thought it might have to do with the LinqDataSource, so I added a SqlDataSource and the sam...
<p>You are missing the &lt;UpdateParameters&gt; sections of your DataSources.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linqdatasource.updateparameters.aspx" rel="nofollow noreferrer">LinqDataSource.UpdateParameters</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/sy...
<p>This is a total shot in the dark since I haven't used ASP at all.</p> <p>I've been just learning XAML and WPF, which appears to be very similar to what you've posted above and I know that for some UI controls you need to specify the binding mode to two-way in order to get updates in both directions.</p>
7,587
<p>Has anyone successfully built an Adobe Air application with Maven? If so, what are the steps to get it working?</p> <p>I have been trying to use <a href="http://code.google.com/p/flex-mojos/" rel="noreferrer">flex-mojos</a> to build an Air applications. When I set the packaging type to "aswf", as suggested in the...
<p>There is an article called <a href="https://docs.sonatype.org/display/FLEXMOJOS/Building+an+AIR+Application" rel="nofollow noreferrer">Building an AIR Application</a> on the mojos website wiki. It should be able to help you. </p>
<p>In my case I simply created a new maven project using the org.graniteds.archetypes graniteds-tide-seam-jpa-hibernate archetype and got this error. I don't know anything about flex, but simply wanted a sample project using Seam. This seemed like a good candidate. But I get </p> <p>unknown packaging type:swf</p> ...
17,657
<p>I am working on a project that requires reliable access to historic feed entries which are not necessarily available in the current feed of the website. I have found several ways to access such data, but none of them give me all the characteristics I need.</p> <p>Look at this as a brainstorm. I will tell you how mu...
<p>For queries like this it is always best to use an <code>INFORMATION_SCHEMA</code> view. These views are (mostly) standard across many different databases and rarely change from version to version.</p> <p>To check if a table exists use:</p> <pre><code>IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA....
<p>consider in one database you have a table t1. you want to run script on other Database like - if t1 exist then do nothing else create t1. To do this open visual studio and do the following:</p> <p>Right click on t1, then Script table as, then DROP and Create To, then New Query Editor </p> <p>you will find your de...
20,241
<p>What are all the common undefined behaviours that a C++ programmer should know about?</p> <p>Say, like:</p> <pre><code>a[i] = i++; </code></pre> <p></p>
<h3>Pointer</h3> <ul> <li>Dereferencing a <code>NULL</code> pointer</li> <li>Dereferencing a pointer returned by a &quot;new&quot; allocation of size zero</li> <li>Using pointers to objects whose lifetime has ended (for instance, stack allocated objects or deleted objects)</li> <li>Dereferencing a pointer that has not...
<p>The only type for which C++ guarantees a size is <code>char</code>. And the size is 1. The size of all other types is platform dependent.</p>
47,982
<p>If I press <kbd>Ctrl</kbd>+<kbd>B</kbd> that ought to give me ASCII code 2, but <kbd>Ctrl</kbd>+<kbd>C</kbd> is going to be interpreted as a Break.</p> <p>So I figure I've got to redirect a file in. How do I get these characters into a file?</p>
<p><kbd>Ctrl</kbd>-<kbd>V</kbd> escapes the next keystoke. That's how you can get a <kbd>Ctrl</kbd>-<kbd>C</kbd> out: <kbd>Ctrl</kbd>-<kbd>V</kbd> <kbd>Ctrl</kbd>-<kbd>C</kbd></p>
<pre><code>perl -e 'print "\xFF"' </code></pre> <p>where <code>FF</code> is the hex code of the ACSII code you want to print. So for ACSII code 2, it would be \x02. </p>
3,634
<p>What is the best way to multi-thread in the C language? I want something that is very efficient and not a CPU hog. Thanks.</p>
<p>The correct (standard) way to do this on C and Windows is with <a href="http://msdn.microsoft.com/en-us/library/kdzttdcb.aspx" rel="nofollow noreferrer">__beginthreadex</a>.</p> <p>This is usually preferred to calling <a href="http://msdn.microsoft.com/en-us/library/kdzttdcb.aspx" rel="nofollow noreferrer">CreateTh...
<p>Your question is a bit general to answer effectively. You might look into such things as:</p> <p>CreateThread in the windows SDK</p> <p>boost::thread</p>
6,469
<p>Is there any way to create an array-like object in JavaScript, without using the built-in array? I'm specifically concerned with behavior like this:</p> <pre><code>var sup = new Array(5); //sup.length here is 0 sup[0] = 'z3ero'; //sup.length here is 1 sup[1] = 'o3ne'; //sup.length here is 2 sup[4] = 'f3our'; ...
<p>[] operator is the native way to access to object properties. It is not available in the language to override in order to change its behaviour.</p> <p>If what you want is return computed values on the [] operator, you cannot do that in JavaScript since the language does not support the concept of computed property....
<p>Sure, you can replicate almost any data structure in JavaScript, all the basic building blocks are there. What you'll end up will be slower and less intuitive however.</p> <p>But why not just use push/pop ?</p>
47,779
<p>im using httpclient and last-modified header in order to retrieve the last updated date of an html file however when i try this on a linux box it returns yesterdays date but when i use a windows machine it returns todays date. is anyone aware of issues using this header field in linux?</p>
<p>Perhaps, linux server has its clock set differently and this way "lives in the past"?</p>
<p>If you dualboot with Windows, you must make sure your Linux system is configured to <em>not</em> think the BIOS keeps the clock in GMT (or UTC), but in local time. Otherwise your Linux system's clock will keep being off when in Linux.</p> <p>Also make sure that the /etc/localtime file is a symlink to the correct ti...
25,041
<p>I've used Excel PivotTable to analyze data from my database because it allows me to "slice and dice" very quickly. As we know what is in our database tables, we all can write SQL queries that do what PivotTable does. </p> <p>But I am wondering why PivotTable can construct the queries so fast while it knows <em>noth...
<p>Just manipulate your order and group clauses as necessary.</p> <p>Excel is fast because all the data is in memory, and it can be sorted fast and efficiently.</p>
<p>My intuitive feeling tells me that the answer would have something to do with a Pivot Table outline, which has a <em>fixed</em> number of zones, namely:</p> <pre><code>- the Page Fields zone - the Column Fields zone - the Row Fields zone and - the Data zone </code></pre> <p>In my wild guess: </p> <pre><code>...
10,936
<p>We are re-platforming for a client, and they are concerned about SEO. Their current site supports SEO friendly URLs, and so does the new platform. So for those, we are just going to create the same URL mapping. However, they have a large number of other URLs that are not SEO friendly that they want to permanently re...
<p>One approach (the one <a href="http://blog.kaeding.name/articles/2008/07/22/migrating-urls-with-apache" rel="nofollow noreferrer">I chose</a>) was to create a simple table of old urls and new ones, and then use <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html" rel="nofollow noreferrer">mod_rewrite</a> ...
<p>You could use PHP to redirect old URLs to new ones.</p> <pre><code>header("Location: /new.html",TRUE,301); </code></pre> <p>You will still need to redirect requests to this PHP script, but you may find this more flexible and easier to debug than exclusively using mod_rewrite.</p>
30,371
<p>Has anyone come across an example of a non .Net consumer of an ADO.NET Data Service? I am on the second day of looking at what Astoria is and how it can be used. I am also trying to answer why would I use this instead of a web service?</p> <p>After getting my examples running, I kind get the RESTful approach to get...
<p>Well since ADO.NET Data Services exposes itself as a RESTful service anything that can make RESTful calls to a URI can properly use the service. I think rather than looking for .NET related to X technology you should look up the technology you're using (Python, PHP, Whatever) on how to call RESTful services. Once ...
<p>To consume an ADO.NET Data Service all that is needed is the ability to make HTTP requests using the GET, POST, PUT and DELETE verbs and to set the Accept header.</p> <p>Not all programming environments offer these, e.g. Silverlight 2 and J2ME can only do GET and POST, <em>not</em> PUT and DELETE. This means that i...
34,644
<p>I have some code that uses SMO to populate a list of available SQL Servers and databases. While we no longer support SQL Server 2000, it's possible that the code could get run on a machine that SQL Server 2000 and not have the SMO library installed. I would perfer to check for SMO first and degrade the functionali...
<p>I had a look at the SharedManagementObjects.msi from the SQL2008 R2 feature pack and my Windows Registry (SQL2008 R2 Dev is installed on this machine) and I believe these are the reg keys one should use to detect SMO (All under HKLM):</p> <p>SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects\CurrentVer...
<p>Just a quick note: HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects\CurrentVersion\Version doesn't represent the current version that is installed, because there could be several versions installed.</p> <p>The registry key above is being updated when you install a version, so if you've installe...
6,391
<p>I am creating an application in java which will be the part of an external application. My application contains a viewport which shows some polygons and stuff like that. The external application needs to get the image of the viewport in gif format. For that it calls a method in an interface (implemented by my applic...
<p>A byte array could be appropriate if you expect the GIFs to be small, but you might consider using an <code>OutputStream</code> so you can stream bits more efficiently.</p> <p>Even if today you just return a fully-populated <code>ByteArrayOutputStream</code>, this would allow you to change your implementation in fu...
<p>If your 'application' is actually calling a Java method then it should understand Java return types and you should return java.awt.image.</p> <p>If you are doing this through some kind of remote procedure that can't understand Java types I would return a byte array and let the receiving app decode it.</p>
27,371
<p>I'm using GDI+ in C++. (This issue might exist in C# too). </p> <p>I notice that whenever I call Graphics::MeasureString() or Graphics::DrawString(), the string is padded with blank space on the left and right.</p> <p>For example, if I am using a Courier font, (not italic!) and I measure "P" I get 90, but "PP" gi...
<p>It's by design, that method doesn't use the actual glyphs to measure the width and so adds a little padding in the case of overhangs.</p> <p><a href="http://msdn.microsoft.com/en-us/library/6xe5hazb.aspx" rel="noreferrer">MSDN</a> suggests using a different method if you need more accuracy:</p> <blockquote> <p>T...
<p>TextRenderer was great for getting the size of the font. But in the drawing loop, using TextRenderer.DrawText was excruciatingly slow compared to graphics.DrawString().</p> <p>Since the width of a string is the problem, your much better off using a combination of TextRenderer.MeasureText and graphics.DrawString..<...
14,451
<p>Background: At my company we are developing a bunch applications that are using the same core dll's. These dll's are using Spring.net's IoC-container to wire things up (auto-wiring). All applications are using the same spring configuration file, and this configuration file points to many classes in many different dl...
<p>If none of the code from the assembly is ever used, then eventually the pages from that assembly will be moved from memory into the page file in favour of actively used pages. In which case, the overall long-term effect is likely to be minor. Although, there will be a negative effect on startup time.</p>
<p>of course loading dll's w/o using them causes slower startup time due to reading the assembly from disk and evidence/security checks. But if memory is your concern you at least can be sure, you won't waste more memory than the size of your assemblies if you really don't use any types within. Of course if those types...
9,550
<p>We have a collection of commercial MFC/C++ applications which we sell using <a href="http://www.roguewave.com/products/stingray.php" rel="nofollow noreferrer">Stingray Objective Toolkit</a>, we have source code license and have ported it in the past to Solaris/IRIX/HP-UX/AIX using <a href="http://en.wikipedia.org/wi...
<p>Yes, we haved moved away from Stingray. It depends on what Stingray components you are using. For the grid control, you can use the free MFC gridcontrol from www.codeproject.com or the commercial one from <a href="http://www.bcgsoft.com/" rel="nofollow noreferrer">http://www.bcgsoft.com/</a>. The free one is OK but ...
<p>I have been using Stingray for last eight years or so, and have looked at moving off it a couple of times. So far, I've decided against, principally because I have ported a version to Windows CE &amp; Mobile and don't see much else giving the same solution on this platform. While Stingray isn't perfect, they have ...
9,649
<p>What is the easiest cross platform widget toolkit? I'm looking for one that minimally covers Windows, OSX, and Linux with a C or C++ interface.</p>
<p>I don't know of any I've personally used with a C API, but <a href="http://www.wxwidgets.org/" rel="nofollow noreferrer">wxWidgets</a> is C++. It runs on Windows, Linux, and Mac OS X. And if you're looking for easy, <a href="http://www.wxpython.org/" rel="nofollow noreferrer">wxPython</a> is a Python wrapper around ...
<p>The easiest to write a new program in would be the one you're most familiar with.<br> The easiest to use, test or distribute would probably be the most cross-platform, most distributed or the most supported one, so GTK+/wx/Qt/Tk?</p> <p>Note that C itself isn't a particularly <em>easy</em> language, especially with...
11,700
<p>If I have two variables containing binary values, how do I append them together as one binary value? For example, if I used WMI to read the registry of two REG_BINARY value, I then want to be able to concatenate the values.</p> <p>VBScript complains of a type mismatch when you try to join with the '&amp;' operator...
<p>REG_BINARY value will be returned as an array of bytes. VBScript may reference an array of bytes in a variable and it may pass this array of bytes either as a variant to another function or as a reference to array of bytes. However VBScript itself can do nothing with the array.</p> <p>You are going to need some o...
<p>Perhaps...</p> <pre><code>result = CStr(val1) &amp; CStr(val2) </code></pre>
22,317
<p>Python frameworks always provide ways to handle URLs that convey the data of the request in an elegant way, like for example <a href="http://somewhere.overtherainbow.com/userid/123424/" rel="noreferrer">http://somewhere.overtherainbow.com/userid/123424/</a></p> <p>I want you to notice the ending path <strong>/useri...
<p>This example uses ASP.NET Routing to implement friendly URLs. </p> <p>Examples of the mappings that the application handles are: </p> <p><a href="http://samplesite/userid/1234" rel="noreferrer">http://samplesite/userid/1234</a> - <a href="http://samplesite/users.aspx?userid=1234" rel="noreferrer">http://samplesi...
<p>Also, check out ASP.NET MVC or if you're set on webforms, the new System.Web.Routing namespace in ASP.NET 3.5 SP1</p>
6,720
<p>An obscure puzzle, but it's driving me absolutely nuts:</p> <p>I'm creating a custom Information Management Policy in MOSS. I've implemented IPolicyFeature, and my policy feature happily registers itself by configuring a new SPItemEventReceiver. All new items in my library fire the events as they should, and it all...
<p>There's only a couple of things I can think of to try. First, are you developing on the box where you might be able to use Visual Studio to debug? So just stepping through it.</p> <p>Assuming that's not the case - what I'd do is fire up WinDBG and attach it to the process just before I registered the policy. Turn o...
<p>Some nice ideas there, thanks. The Visual Studio debugger wasn't showing an exception (and I've wrapped everything in try/catch blocks just in case), but I hadn't thought of trying Windbg...</p>
6,885
<p>What factors indicate that a project's solution should not be coded in a dynamic language?</p>
<p>Familiarity and willingness of the programmers to work with the language.</p> <p>Your dynamic language is probably my static language.</p>
<p>How about interop? Is it possible to call a COM component from Ruby or Python?</p>
17,192
<p>Does anybody know a "technique" to discover memory leaks caused by smart pointers? I am currently working on a large project written in <strong>C++</strong> that heavily uses smart pointers with reference counting. Obviously we have some memory leaks caused by smart pointers, that are still referenced somewhere in t...
<p>Note that one source of leaks with <strong>reference-counting smart pointers</strong> are pointers with <strong>circular dependancies</strong>. For example, A have a smart pointer to B, and B have a smart pointer to A. Neither A nor B will be destroyed. You will have to find, and then break the dependancies.</p> <p...
<p>First step could be to know what class is leaking. Once you know it, you can find who is increasing the reference: 1. put a breakpoint on the constructor of class that is wrapped by shared_ptr. 2. step in with debugger inside shared_ptr when its increasing the reference count: look at variable pn->pi_->use_count_ Ta...
9,276
<p>What references offer a good summary/tutorial for using RDF/OWL? There seem to be enough tools (Protege, Topbraid, Jena, etc.) that knowing the syntax of the markup languages is not necessary, but knowing the concepts is, of course, still critical. </p> <p>I'm working through the w3c documents (particularly the <...
<p>A very good introduction to the semantic web in comparison to object-oriented languages is this document from W3C: <a href="http://www.w3.org/TR/sw-oosd-primer/" rel="noreferrer">A Semantic Web Primer for Object-Oriented Software Developers</a>. It helped me clarify a lot of things from the beginning.</p>
<p>I've found the linkeddatatools tutorial is easy to understand the basics.</p> <p><a href="http://www.linkeddatatools.com/semantic-web-basics" rel="nofollow">http://www.linkeddatatools.com/semantic-web-basics</a></p>
18,823
<p>I would like to support keyboard shortcuts in my WPF XBAP application, such as <kbd>Ctrl</kbd>+<kbd>O</kbd> for 'Open' etc. How do I disable the browsers built-in keyboard shortcuts and replace them with my own?</p>
<p>You can't disable the browser's built-in handling of keys. It's not your place as browser content to override the browser's own shortcut keys.</p>
<p>Not an answer, but a comment. It would be nice to disable the Backspace key behavior in an XBAP, nothing more annoying than hitting the backspace key while not in an element and the browser navigates you to the previous web page.</p>
15,451
<p>Is it possible for <code>SelectNodes()</code> called on an <code>XmlDocument</code> to return null?</p> <p>My predicament is that I am trying to reach 100% unit test code coverage; ReSharper tells me that I need to guard against a null return from the <code>SelectNodes()</code> method, but I can see no way that an ...
<p>Is it necessary to reach 100% code coverage? Indeed, is it even possible under normal (i.e. controllable, testable) circumstances? </p> <p>We often find that using "syntactic sugar" constructions like the <code>using {}</code> block, there are "hidden" code paths created (most likely <code>finally {}</code> or <cod...
<p>If you are calling SelectNodes on the XmlDocument itself and it really is an XmlDocument and not a derived class than SelectNodes won't return null.</p> <p>If you create a descendant class and override the CreateNavigator(XmlNode) method then SelectNodes could return null.</p> <p>Similarly, if you call SelectNodes...
8,178
<p>I'm trying to write a windows batch file that can delete files from subdirectories. I would rather not hard code the directory structure in, so I can use this process with other projects.</p> <ul> <li>I need to delete files of X type,</li> <li>I have the parent folder <code>C:\MyProject</code>,</li> <li>There are ...
<p>Actually you can use the standard del command:</p> <pre><code>c: cd MyProject del /S *.type </code></pre> <p>Where type is the extension you want to delete and the /S parameter will check in all subfolders of MyProject.</p>
<p>If the del command didn't have the /S flag to delete recursively, I'd use AWK to do something like this (you'd need the UNIX tools for Windows):</p> <pre><code>dir MyProject\*.* /ad /s /b | gawk "{print \"del \\\"\" $0 \"\\*.type\\\"\";}" | cmd </code></pre> <p>My 2 cents, in case you ever need to do something sim...
43,799
<p>We perform updates of large text files by writing new records to a temp file, then replacing the old file with the temp file. A heavily abbreviated version:</p> <pre><code>var tpath = Path.GetTempFileName(); try { using (var sf = new StreamReader(sourcepath)) using (var tf = new StreamWriter(tpath)) { ...
<p>The normal way of avoiding the "delete then move fails problem" is:</p> <ul> <li>Write to file.new</li> <li>Move file.current to file.old</li> <li>Move file.new to file.current</li> <li>Delete file.new</li> </ul> <p>Then when you come to read, use file.new if file.current is missing, deleting file.old if you see i...
<p>I found it useful to wrap this pattern in it's own class.</p> <pre><code>class Program { static void Main( string[] args ) { using( var ft = new FileTransaction( @"C:\MyDir\MyFile.txt" ) ) using( var sw = new StreamWriter( ft.TempPath ) ) { sw.WriteLine( "Hello" ); ft.Com...
42,045
<p>I am having issues converting a png to tiff. The conversion goes fine, but the image is huge. I think the issue is that I am not doing the compression correctly? Anyone have any suggestions??</p> <p>Here is the code sample</p> <pre><code>public static void test() throws IOException { // String fileName = "...
<p><code>Writer.getDefaultWriteParam()</code> only creates an <code>ImageWriteParam</code> object, it doesn't link it back to anything else.</p> <p>I don't see any mechanism in your code for your modified <code>param</code> object to be subsequently used in the <code>ImageWriter</code>.</p> <p>I believe that instead ...
<p>I don't know Java IO, but generally you want to look at a few things</p> <ol> <li>Can you use JPEG compression instead of LZW?</li> <li>See how to set the TIFF strip size -- if small size is what you want, set it to the height of the image.</li> </ol> <p>Edit: Looks like a TiffWriteParam has the following methods<...
35,622
<p>I've been crossing things out on my TODO list. I've recently picked up Colemak. Next I wanted to learn Vim or Emacs. I was leaning towards Vim, however one of its benefits are sticking to the home row. With Colemak, the home row has been changed. I realize that I could remap the keys, but assigning the function...
<p>Glad to see another Colemak user :)</p> <p>For Emacs there really isn't a need to remap, since the initial "shortcuts" aren't designed to be close to each other. If anything, you're gonna be more comfortable using Emacs on Colemak than on Qwerty (at least I was).</p> <p>In Vim it's a lot trickier since hjkl will b...
<p>Here is a <a href="https://stackoverflow.com/questions/165231/vim-dvorak-keybindings-rebindings">previous post</a> that should help you some. There is some discussion on there, some users don't remap. Some do. </p> <p>I am going to remap over the weekend actually. I have for the past year used the default mappings,...
31,645
<p>Can someone give an example of a good time to actually use "unsafe" and "fixed" in C# code? I've played with it before, but never actually found a good use for it. </p> <p>Consider this code...</p> <pre><code>fixed (byte* pSrc = src, pDst = dst) { //Code that copies the bytes in a loop } </code></pre> <p>comp...
<p>It's useful for interop with unmanaged code. Any pointers passed to unmanaged functions need to be fixed (aka. pinned) to prevent the garbage collector from relocating the underlying memory.</p> <p>If you are using P/Invoke, then the default marshaller will pin objects for you. Sometimes it's necessary to perform...
<p>I believe unsafe code is used if you want to access something outside of the .NET runtime, ie. it is not managed code (no garbage collection and so on). This includes raw calls to the Windows API and all that jazz.</p>
11,103
<p>Just wanted to get an idea for ways (web) developers get round the short fall of (most) WYSIWYG editors, whereby the users that are editing the text aren't always HTML literate enough to produce good/great results.</p> <p>In the past we have resigned ourselves to either locking down the editor or simply not supplyi...
<p>I came up with a solution that looks pretty good. Some sample XAML that I chalked up in Blend 2.0 SP1 looks like this:</p> <pre><code>&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ScreenGlintApplication.Window...
<p>You can put a transparent panel on top like LBugnion said, but don't forget there are many ways you can do this:</p> <ol> <li>Change the visibility of the panel to Hidden. </li> <li>Change the opacity to 0.</li> <li>Change the Alpha of the color to 0.</li> </ol> <p>If you only change the Alpha it still is <em>clic...
23,183
<p>Just a random thought, and if I wasn't asking the question myself I'd probably down vote it, but... are screenshots the best way to show printer settings, or would a text version be better? </p> <p>Ok, yes, a screenshot is probably easier to do and post, and will show a familiar UI and be easy on the eye and make ...
<p>Text would probably be best because it is searchable, so things can be found faster then by just looking at the long list of settings available in any slicer/printer/device available with your own eyes.</p> <p>However, as far as I'm aware, exporting settings in text format from a slicer/printer is still wishful thi...
<p>The problem with settings is that there are so much settings, if OP's are asked to post certain settings the OP or the one that helps might miss some other parameters that would be visible in a screenshot. I was able to spot a few problems already using the screenshots.</p> <p>Another thought: "What would you gain ...
62
<p>So I was wondering if there are any major differences between the various implementations of the hash algorithms, take the SHA series of algorithms for example. All of them have 3 implementations each, 1 in managed code and 2 wrappers around different native crypto APIs, but are there any major differences between u...
<p>One difference is that the native versions (at least some of them) are FIPS-certified (i.e., approved by the US government), whereas the managed ones are not. If your code happens to be running on a Windows machine that has been configured as "FIPS only", attempts to use the managed versions will fail.</p> <p>Most ...
<p>I did a quick and dirty comparison between <code>CNG</code> and <code>managed</code> on SHA512 which is the slowest of all SHA algorithms AFAIK using the code below.</p> <pre><code> static void Main(string[] args) { int loops = 10000000; var data = Encoding.ASCII.GetBytes("123"); var hashL...
25,938
<p>I've written a VB.NET application that uses SQL CE 3.5. I'm curious if anyone has any best practice or code to help check if A) SQL CE is installed and B) If so, what version. </p> <p>I searched msdn and google for anything but I didn't find anything helpful. I was poking around the registry and found this key: ...
<p>Not sure if you are talking about SQL CE on a Windows machine or a portable device. On a PC, your best bet is to distribute the version of SQL CE with your application. You can register for the rights to do so at <a href="http://www.microsoft.com/Sqlserver/2005/en/us/compact-redistribute.aspx" rel="nofollow norefer...
<p>OK, this only answers the first part of your question, but hope it's useful anyway... This is what I currently use:</p> <pre><code>&lt;Fragment&gt; &lt;util:RegistrySearch Id='SearchForSQLCE' Variable="SQLCEInstalled" Result="exists" Root="HKLM" Key="SOFTWARE\Cl...
32,001