instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I would like to start a small part time business other than my full time programming job. Have you guys done that before? I know programmers who teach in evening schools after work. But then again, that is not business. What would you recommend to get another income stream going?</p>
| <p>I have a full time programming day job, and I just started a small software enterprise this year.</p>
<p>My advice would be to start small, and make sure you have the time & energy to work on something after your day job is done. If possible, choose a business in which the code you write will be different from ... | <p>I did some work on an opensource project (DotNetNuke) as a developer and made some good contacts through that and became a consultant doing DNN work for various clients.</p>
<p>You obvisouly have to make the investment to learn whatever the OSS project is that you're working on, but on the other hand, there's a goo... | 40,417 |
<p>Our graphics person uses Adobe Illustrator and we'd like to use her images inside our WPF application as paths. Is there a way to do this?</p>
| <p>You can go from AI to SVG to XAML.</p>
<ol>
<li><p>From Adobe Illustrator: File -> Save As -> *.SVG.</p>
<ul>
<li><p>SVG "Profile 1.1" seems to be sufficient.</p></li>
<li><p>Note that to preserve path/group names in XAML you should enable "Preserve Illustrator Editing Capabilities" (or at least as it's called in ... | <p>Get her to export the illustrations as some other format (recent versions of Illustrator support SVG) that you can use or convert to something that will work.</p>
| 18,568 |
<p>As far as I know, Flash has to pass info off to another external process in order to save files - POSTing to PHP or talking to an executable, right? But every once in a while I hear rumors that Flash is able to open a file, make changes, then save/write those changes, all on its own - is it possible?</p>
| <p>This will be available in Flash Player 10:</p>
<p>Reading and Writing Local Files in Flash Player 10</p>
<p><a href="http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash-player-10/" rel="noreferrer">http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash... | <p>There is something called Local Shared Object, also known as "Flash Cookie" that allows you to store a limited amount of data locally at a user's computer.</p>
<p>A little googling turned up a few links:</p>
<ul>
<li><a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html" re... | 13,319 |
<p>I could write this, but before I do, I wanted to check to see if there are existing solutions out there since it seems a lot of websites already do this, so I was wondering if there was a quick way to do this.</p>
<p>Also, I am talking about "popout" windows, not "popup" windows. All JavaScript libraries support "... | <p>Check out Cappuccino, it's more of a windowing framework than a web 2.0 framework. It's based off of Apples Cocoa, and uses a Superset of Javascript called Objective-J. Superset meaning that any JS is valid, but it extends on the language with additional syntax that is similar to Cocoa and Objetive-C.</p>
<p><a hre... | <p>I don"t know a framework to do that for you. But the JS code to do that might be simple. </p>
<p>For the in-page-popup part, just open an absolute div. If you want the div to become a real popup, open a popup window then remove your div content from the main document and append it to the popup window document (you ... | 21,104 |
<p>I am writing a program that will be emailing reports out many (~100) clients which I want to test before I spam everyone.</p>
<p>I want to do a test run against my production data and actually send the messages to a SMTP server, but I don't want the SMTP server to actually deliver the messages. I want the server t... | <p>In java you can use <a href="http://quintanasoft.com/dumbster/" rel="noreferrer">dumbster</a></p>
<p>Its easy to use and you can validate every aspect of the email you are intercepting.</p>
<p>It's a Java SMTP server implementation meant for unit testing. (Just make sure you redirect your email to the machine runn... | <p>I personally modify the e-mail addresses to test, I send them to a dummy account of mine, that way I can validate not only that they sent, but that they appear in the proper format.</p>
| 29,864 |
<p>My Ender 3 LCD display was working ok, I went to turn it on recently but is not showing any signal of life anymore...</p>
<p>I have tried unplugging and plugging again, is there a way to test if the screen still works?</p>
<p>What is the issue? Or should I just buy and install a new LCD?</p>
| <p>There are a few issues that could cause this. Roughness in your z-axis lead screw as pointed out by @TheLamestUsername is a leading contender I would say. I'd also extended that answer to include checking the belts for your X and Y axes as well as making sure that the rods the gantry slide on are smooth since the fa... | <p>The fact that the bumps were in the same spots on multiple occasions points to z-axis problems. Turn your printer off and manually turn the z-axis all the way from bottom to top. If there are any tight spots, there is some <em>z-axis binding</em>. If there are no tight spots, skip to the last paragraph.</p>
<p>Try t... | 1,689 |
<p>I have a web service that uses Python's SimpleJSON to serialize JSON, and a javascript/ client that uses Google's Visualization <a href="http://code.google.com/apis/visualization/documentation/reference.html" rel="nofollow noreferrer">API</a>. When I try to read in the JSON response using Google Data Table's Query m... | <p>Are you certain the Google API is expecting JSON? In my experience Google's APIs tend not to be massively broken in a manner you're describing -- it could be that they're actually expecting a different format that merely resembles JSON.</p>
<hr>
<p>Further poking around reveals instructions for retrieving data in ... | <p>As it turns out <strong>:mod:json</strong> would also choke at strings in single quotes. This will sort things out though:</p>
<h1>Parse JavaScript object as JSON in python:</h1>
<h2>solution:</h2>
<pre><code>>>> from re import sub
>>> import json
>>> js = "{ a: 'a' }"
>>> json... | 21,287 |
<p>I have need to select a number of 'master' rows from a table, also returning for each result a number of detail rows from another table. What is a good way of achieving this without multiple queries (one for the master rows and one per result to get the detail rows).</p>
<p>For example, with a database structure li... | <p>Normally, I'd go for the two grids approach - however, you might also want to look at FOR XML - it is fairly easy (in SQL Server 2005 and above) to shape the parent/child data as xml, and load it from there.</p>
<pre><code>SELECT parent.*,
(SELECT * FROM child
WHERE child.parentid = parent.id FOR XML ... | <p>select < columns > from master</p>
<p>select < columns > from master M join Child C on M.Id = C.MasterID</p>
| 40,936 |
<p>I have a class declared as follows:</p>
<pre><code>Public MustInherit Container(Of T As {New, BaseClass}) Inherits ArrayList(Of T)
</code></pre>
<p>I have classes that inherit this class.</p>
<p>I have another class that I must pass instances in this method:</p>
<pre><code>Public Sub LoadCollection(Of T As {Base... | <p>Sorry haven't got time to expand on this right now, but I think <a href="http://rasor.wordpress.com/2008/08/19/cast-a-generic-list-c/" rel="nofollow noreferrer">this link</a> describes your underlying problem and a solution.</p>
<p>(You might also find <a href="http://blogs.msdn.com/lucian/archive/2008/10/02/co-and... | <p>It cannot be a global variable. Container is an idea, not a thing.</p>
<p>As you have it designed, that idea is only formed into an actual thing inside LoadCollection(). You need to convey the information outside of that method.</p>
| 16,312 |
<p>This question deals with concurrency issues, for suggestions on how to display a busy icon see this question: <a href="https://stackoverflow.com/questions/205631/javascript-loadingbusy-indicator-or-transparent-div-over-page-on-event-click">Javascript - loading/busy indicator or transparent div over page on event cli... | <p>If you want the same busy indicator for all actions, then use a counter.</p>
<p>Instead of "show_busy_icon()", do a "increment_busy_count()", which calls "show_busy_icon()" if busy count goes from 0 to 1. Instead of "hide_busy_icon()", do a "decrement_busy_count()", which calls "hide_busy_icon()" if busy count goes... | <p>Please see my answer here: </p>
<p><a href="https://stackoverflow.com/questions/244183/how-to-display-a-loading-screen-while-site-content-loads#244190">How to display a loading screen while site content loads</a></p>
<p>I give a small, working JavaScript example of how to do exactly this, hope it helps.</p>
| 46,079 |
<p>Is there a way to get a detailed failure information from <code>QObjet::connect</code> in case of its failure?</p>
<p>Returned boolean value doesn't give any information about reason of failure.</p>
<p>I wish exception were so widely used in C++ as they are in Java.</p>
| <p>In addition to the other answers, you can install your own function that is called for Qt debug, warning, or fatal messages. Our program has this, and for debug builds, we pop up a dialog detailing the problem if it is a warning or fatal message. I believe most of the missed slot connections appear as warning mess... | <p>If I remember correctly, the debug build will output a more detailled error message to the debugger. Helped me more than once to fix a bug.</p>
| 21,440 |
<p>I'm just interested in people's opinions. When using nullable types in C# what is the best practice way to test for null:</p>
<pre><code>bool isNull = (i == null);
</code></pre>
<p>or</p>
<pre><code>bool isNull = !i.HasValue;
</code></pre>
<p>Also when assigning to a non-null type is this:</p>
<pre><code>long? ... | <p>Use the forms that were specially implemented for you by the C# team. If anyone objects, tell them Anders said it was okay.</p>
<p>What I'm saying, flippantly, is that a lot of work went into integrating nullable types into c# to give you a good programming experience.</p>
<p>Note that in terms of performance, bot... | <p>They're both the same, but I would use the former version on both, since it's more common in the language: comparison to null and casting to a type.</p>
| 32,419 |
<p>My co-founder is currently asking on our blog for an embeddable code widget.</p>
<p><a href="http://devver.net/blog/2008/10/someone-please-build-an-awesome-embeddable-code-widget/" rel="nofollow noreferrer">http://devver.net/blog/2008/10/someone-please-build-an-awesome-embeddable-code-widget/</a></p>
<p>Basically ... | <p>I think you want a javascript syntax highlighter</p>
<ul>
<li><p><a href="http://code.google.com/p/syntaxhighlighter/" rel="nofollow noreferrer">http://code.google.com/p/syntaxhighlighter/</a></p></li>
<li><p><a href="http://shjs.sourceforge.net/" rel="nofollow noreferrer">http://shjs.sourceforge.net/</a></p></li>
... | <p>Check out <a href="http://coderay.rubychan.de/" rel="nofollow noreferrer">CodeRay</a> and <a href="http://ultraviolet.rubyforge.org/" rel="nofollow noreferrer">UltraViolet</a>. They're both quite good and easy to use.</p>
| 31,286 |
<p>I'm writing code to generate character-based pagination. I have articles in my site that I want to split up based on length.</p>
<p>The code I have so far is working albeit two issues:</p>
<ol>
<li>It's splitting pages in the middle of words and HTML tags; I want it to
only split after a complete word, tag, or a p... | <p>Thanks, guys. I put in the fix for the 1st point and it worked beautifully.</p>
<p>Hm. I guess it is messy to do the second point. I've found some regex on-line. Will think, write, and get back to you when I make some progress.</p>
<p>Thanks again.</p>
| <pre><code>$NoOfPages = round((double)$ArticleLength / (double)$CharsPerPage);
</code></pre>
<p>That should use ceil instead of round - if you use round, 4.2 pages will only show 1-4 - you need a 5th page to show the last .2 of a page.</p>
<p>The other part is harder ... its common to use some sort of marker in the f... | 46,824 |
<p>I have data from a table in a database (string) that contain text and price. I extract the price from the data but my problem is that sometime I can Convert it to float and sometime not.</p>
<p>I have noticed that :</p>
<pre><code>Convert.ToSingle(m.Groups[1].Value);
</code></pre>
<p>It works but not always becau... | <p>You have this problem because the conversion check the language of your PC. You will need to do something like :</p>
<pre><code>Convert.ToSingle(m.Groups[1].Value, CultureInfo.InvariantCulture.NumberFormat);
</code></pre>
<p>This ways, it won't check the language of the PC. You can find more information about <a h... | <p>As others have said:</p>
<pre><code>Convert.ToSingle(m.Groups[1].Value, CultureInfo.InvariantCulture);
</code></pre>
<p>You must also make sure that you use the <code>InvariantCulture</code> when <strong>writing</strong> to the database. (It would be even better if you saved the data to a column with its native da... | 46,860 |
<p>Unlike many of the ASP.NET documentation and examples, I'm doing a gridview list on one page, and it links to a 2nd page to do the edit/update view, sending the ID for the record in the GET string.</p>
<p>On my edit/update view, I'm using an ASP:DetailsView for viewing, editing and inserting records. All of this w... | <p>I could have misunderstood your question but.... </p>
<p>I don't believe you can 'link to the insert view', but what you can do is programmatically change the mode of the DetailsView once the page has loaded. Remember to check that the passed in ID has a value first.</p>
<p>For example: </p>
<pre><code>If N... | <p>I just wanted to follow up and say that, even though I did not find a way to link to a specific page state, I did discover the dataview's DefaultMode parameter, that at least allows you to pick an initial state.</p>
<p>Thus:
DefaultMode="Insert"</p>
<p>At least lets you choose insert mode as the default.</p>
| 46,138 |
<p>I have quite a large list of words in a txt file and I'm trying to do a regex find and replace in Notepad++. I need to add a string before each line and after each line.. So that:</p>
<pre>
wordone
wordtwo
wordthree
</pre>
<p>become</p>
<pre>
able:"wordone"
able:"wordtwo"
able:"wordthree"
</pre>
<p>How can I do ... | <p>Assuming alphanumeric words, you can use:</p>
<pre><code>Search = ^([A-Za-z0-9]+)$
Replace = able:"\1"
</code></pre>
<p>Or, if you just want to highlight the lines and use "Replace All" & "In Selection" (with the same replace):</p>
<pre><code>Search = ^(.+)$
</code></pre>
<p><code>^</code> points to the sta... | <p>In visual studio code i found that simple regex as ^ worked.</p>
| 35,964 |
<p>Assuming a Cartesian printer with a belt and smooth rod design in which one axis moves another (i.e. the X-axis rails 'sit' on the Y-axis rails), what are the main considerations in sizing the rods and belts? For example, given a base design using 8 mm diameter rods and 6 mm belts (assume these are the limiting fac... | <p>8 mm rods and 6 mm GT2 belts are generally accepted as a good tradeoff between price and performance, an exact calculation is possible but might not be very relevant if another part is flexing. Also, generally speaking, the smaller the part the sooner it will wear out of specification. Thus your service interval mig... | <p>The 3D printing revolution started out with the idea/community project to build self-replicating machines:</p>
<blockquote>
<p>RepRap was the first of the low-cost 3D printers, and the RepRap Project started the open-source 3D printer revolution. It has become the most widely-used 3D printer among the global members... | 1,771 |
<p>I have a VB6 class with a method which raises an error:</p>
<pre><code>Public Sub DoSomething
...
err.Raise 12345, description:="Error message"
...
End Sub
</code></pre>
<p>This method is called from a form:</p>
<pre><code>Public Sub ErrTest()
On Error Goto err1
obj.DoSomething
Exit Sub
err1:
MsgBox... | <p>In the VB IDE, go to Tools, Option, General tab, Error trapping frame. I'm guessing you have it set to 'Break on All Errors', whereas you probably want 'Break on Unhandled Errors'.</p>
<p>Your <code>Err.Raise</code> statement gives a compile error for me; try removing the braces.</p>
<p>Also, you may want to use <... | <p>You can also change the error trapping options by right-clicking in the code window. The following options are available from the "Toggle" sub-menu:</p>
<p>Break on All Errors<br/>
Break in Class Module<br/>
Break on Unhandled Errors</p>
<p>I find this much easier than popping up the Options dialog...</p>
| 43,670 |
<p>How should I load files into my Java application?</p>
| <p><strong>The short answer</strong></p>
<p>Use one of these two methods:</p>
<ul>
<li><a href="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getResource(java.lang.String)" rel="noreferrer"><code>Class.getResource(String)</code></a></li>
<li><a href="http://java.sun.com/javase/6/docs/api/java/lang/Class.... | <pre><code>public static String loadTextFile(File f) {
try {
BufferedReader r = new BufferedReader(new FileReader(f));
StringWriter w = new StringWriter();
try {
String line = reader.readLine();
while (null != line) {
w.append(line).append("\n");
... | 2,837 |
<p>Does anyone have a copy of MSIINV.EXE (The MSI Inventory tool)? The site where it used to be available is down(<a href="http://www.huydao.net/" rel="nofollow noreferrer">http://www.huydao.net/</a>). I'm trying to uninstall some components in order to force the Visual Studio Setup to reinstall them. I apologize as th... | <p>I've created a GitHub repository with both the original source and a copy of the .exe for MsiInv.exe. I am the original author.</p>
<p><a href="https://github.com/ZisBoom/MsiInv.exe" rel="noreferrer">https://github.com/ZisBoom/MsiInv.exe</a></p>
<p>My most common usage is <code>msiinv.exe -p</code> to list all in... | <p>The tool msiinv.exe what it really does is just list the GUI of all your installed MSI packages. You can use a file as an output.</p>
<p>Then the MSI Inventory tool will provide the needed GUI in order to run "msiexec.exe /x {B3A02601-8FE9-4108-8E95-D94171A2F8C8}" and uninstall the desired package.</p>
<p>Thanks.<... | 29,601 |
<p>So I'm writing a page which does some reporting and it's pretty dynamic, the user has the ability to group data and sort columns. I've been able to get my dynamic grouping down and then the sorting except now my generated linq-to-sql sql order by statement is backwards from what I want it to be. I think I need to fi... | <p>I've used the <a href="http://sourceforge.net/project/showfiles.php?group_id=56262&package_id=63621" rel="nofollow noreferrer">PMD NetBeans plugin</a>, and <a href="http://pmd.sourceforge.net/integrations.html#netbeans" rel="nofollow noreferrer">here</a> are the installation instructions (may be a little outdate... | <p>I found the <a href="https://sqe.dev.java.net/" rel="nofollow noreferrer">SQE Plugin</a>, it integrates FindBugs, CheckStyle and PMD into one convenient Plugin. </p>
<p>CheckStyle configuration was not complete yet, but the functionality is there in full.</p>
| 34,296 |
<p>Using data binding, how do you bind a new object that uses value types? </p>
<p>Simple example:</p>
<pre><code>public class Person() {
private string _firstName;
private DateTime _birthdate;
private int _favoriteNumber;
//Properties
}
</code></pre>
<p>If I create a new Person() and bind it to a f... | <p>Perhaps you can try Nullable types?</p>
<pre><code>public class Person() {
private string? _firstName;
private DateTime? _birthdate;
private int? _favoriteNumber;
//Properties
}
</code></pre>
<p>or </p>
<pre><code>public class Person() {
private Nullable<string> _firstName;
private N... | <p>I'd rewrite the Person class to looks something more like this...</p>
<pre><code>public class Person
{
private int _favoriteNumber = 0;
public string FavoriteNumber
{
get
{
return _favoriteNumber > 0 ? _favoriteNumber.ToString() : string.Empty;
}
set
{
... | 28,972 |
<p>I'm looking for a <strong>subversion web client</strong> ala <a href="http://search.cpan.org/dist/SVN-Web/" rel="nofollow noreferrer">SVN::Web</a> but with a very specific feature I've always thought would be quite useful.</p>
<p>What I want is the ability to find <strong>which revision was responsible for a certai... | <p>I use <a href="http://websvn.tigris.org/" rel="nofollow noreferrer">WebSVN</a>, you can use <em>svn blame</em> from there, and you see who and when added or modified each line of code in a file...</p>
<p><strong>Edit:</strong> Here are a pair of screenshots, so you can get an idea: </p>
<p><img src="https://i.stac... | <p>I thought that SVN had the 'blame' function that could do something similar to that. I am taking a stab in the dark though. Hold on while I take a quick look through the interwebs.</p>
<p>You bet. Check <a href="http://svnbook.red-bean.com/en/1.0/re02.html" rel="nofollow noreferrer">this</a> out. (I use subclips... | 23,922 |
<p>I just purchased an <a href="https://www.anycubic.com/products/anycubic-photon-3d-printer" rel="nofollow noreferrer">Anycubic Photon 3S</a> LCD-based SLA 3D printer. I understand the need for cleaning and curing parts after printing. While the device is in transit, I'm looking to set up a workstation to use it with.... | <h1>Safety Gear</h1>
<p>Gloves, you want to wear them whenever handling any resin. Single-use gloves are best - dispose of them after use. Consider them contaminated after touching anything in contact with resin and toss them before handling anything that shall not get in contact with resin. That includes door handles.... | <p>I would recommend a tub for cleaning the print, some funnels to get leftover resin back into the bottel, gloves, since you really don't want to get any uncured resin on your skin and a strong UV light for finishing the curing process after the cleaning</p>
| 1,474 |
<p>I am building Windows apps for a few clients. I read Joel on Software and took the Joel Test and realized I don't quite measure up. One place I am lacking is automated builds. What should I use to have automated builds? I have Windows apps that use .NET 1.1, 2.0, and 3.5. Also, I need to be able to build my .vd... | <p>TeamCity Professional Edition from JetBrains. <a href="http://www.jetbrains.com/teamcity/" rel="noreferrer">http://www.jetbrains.com/teamcity/</a></p>
| <p>I've used both CruiseControl and TeamCity extensively. For a one man shop, TeamCity is far easier to setup and configure than CruiseControl. </p>
<p>For your build scripts, you can't go wrong with MsBuild or NAnt. I've also been considering Powershell for this but I have not attempted it yet.</p>
| 28,016 |
<p>I know you could make a helper pretty easily given the data. So, if possible, please only submit answers that also include getting the data.</p>
| <p>We are using an action filter for this. </p>
<p>...</p>
<pre><code> public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var controller = (Controller) filterContext.Controller;
Breadcrumb[] breadcrumbs = _breadcrumbManager.PushBreadcrumb(_breadcrumbLinkText);
... | <p>@Chris: something like this:</p>
<pre><code> <%
foreach (var item in ViewData.Get<Breadcrumb[]>())
{
%>
<a href="<%= Server.HtmlEncode(item.Url) %>"><%= item.LinkText %></a> &raquo;
<%
}
%>... | 9,168 |
<p>In a review for a certain filament I read that somebody recommended "<a href="https://www.amazon.de/gp/customer-reviews/RVMUN4CW9ZLKX/ref=cm_cr_arp_d_rvw_ttl?ie=UTF8&ASIN=B01080YND6" rel="nofollow noreferrer">a feeding rate of 105%</a>".</p>
<p>What does he mean, and how could I set this in Cura?</p>
<... | <h2>[Extruder] feed rate [modifier] is used synonymous to extrusion multiplier</h2>
<p>The feed rate of the extruder is the rate at which filament is pushed (fed) into the hotend. An overwrite value that modifies that rate from the normal rate is in most slicers called "extrusion multiplier".</p>
<p>It is a <... | <p>In the context of the linked source (in German <em>"Die Feeding Rate sollte mit 105 % eingestellt werden"</em>), with <em>"a feeding rate of 105 %"</em> is meant the extrusion multiplier (there is no reference in the source to Cura). This is explained in <a href="https://3dprinting.stackexchange.... | 2,211 |
<p>I'd like to use regex with Java.</p>
<p>What I want to do is find the first integer in a string.</p>
<p>Example:</p>
<pre><code>String = "the 14 dogs ate 12 bones"
</code></pre>
<p>Would return 14.</p>
<pre><code>String = "djakld;asjl14ajdka;sdj"
</code></pre>
<p>Would also return 14.</p>
<p>This is what I h... | <p>You're asking for 0 or more digits. You need to ask for 1 or more:</p>
<pre><code>"\\d+"
</code></pre>
| <p>Heres a handy one I made for C# with generics. It will match based on your regular expression and return the types you need:</p>
<pre><code>public T[] GetMatches<T>(string Input, string MatchPattern) where T : IConvertible
{
List<T> MatchedValues = new List<T>();
Regex MatchInt... | 48,643 |
<p>I have some custom SharePoint site definitions that are deployed via SharePoint wsp solution packages. They appear to work fine. I can deploy them fine via the stsadm command line, and my C# code running in some features can also deploy sites based on them. My <code>webtemp.*.xml</code> files appear to be correc... | <p>Many tasks in SharePoint are queued and then executed via timer job. An IISReset causes the web applicationt to be reloaded into memory and for configuration information for example the web.config to be reloaded. </p>
<p>To give SharePoint a "nudge" and cause jobs to execute you might try: </p>
<pre><code>stsadm... | <p>Do you have the publishing feature enabled? I read that content types can't be saved in templates, so they don't allow publishing sites to be made into templates. This is perhaps linked to why they won't show you the ones you already made. </p>
<p>Although I don't have access to a central admin to verify, this i... | 23,458 |
<p>I'm having trouble deciding if I want a project of mine to be web-based (as in a web-app), desktop-based (a desktop application), or a desktop application that can sync or connect to the cloud.</p>
<p>I don't know if anyone else would have an interest in this application, and it's only going to be for me, so I'm le... | <p>I generally ask a few questions:</p>
<ul>
<li>Can it even be done on the web? Something I did not too long ago involved an image editing component, and had to be a web app. It involved much pain to get this work, and a desktop app would have been a far better way to go.</li>
<li>Will I need to access it from anywhe... | <p>Previously you'd have written a desktop application, as tool were better for that and you'd have written it faster. People used to want web apps, but always ended up with desktop.</p>
<p>Nowadays things are different, you can write a webservice just as quickly and easily so there's no reason not to go web-based.</p... | 19,814 |
<p>I'm working on a database that tracks files and dependencies in projects. Briefly, I have two main tables; the PROJECTS table lists project names and other properties, the FILES table lists files. Every file entry points to a project as a foreign key set to CASCADE, so if I delete a project record from the database,... | <p>You can't control the order of deletion through a cascading foreign key, but you may be able to design a trigger on <code>PROJECTS</code> to delete rows in <code>FILES</code> that belong to this project and are also listed in <code>DEPENDENCIES</code> as dependent on other <code>FILES</code>. Make it a <code>BEFORE... | <p>Does the system support deferred constraints, in which the constraint check can be deferred until a commit point?</p>
<p>Maybe that's just an Oracle thing though.</p>
| 46,088 |
<p>Do you have idea how many sucessful projects used Velocity framework for developing their UI ?.The reason I am asking is Velocity is replaced in most of the cases by JSP tags, but in our product we still use Velocity frmaework.</p>
| <p>Usually it's the other way around. People replace JSPs with Velocity. (Because of a better <a href="http://en.wikipedia.org/wiki/Separation_of_concerns" rel="nofollow noreferrer">separation of concerns</a>) The list of projects using Velocity is too long to list here. A big site that I know is using velocity is <a h... | <p>This <a href="http://wiki.apache.org/velocity/PoweredByVelocity" rel="nofollow noreferrer">Powered By Velocity WIKI Page</a> should give you an idea of just a "few" projects that use Velocity in a way or another.</p>
| 42,161 |
<p>I am getting the following error in an MS Access ADP when trying to add a record on a form linked to a MS SQL Server 2000 table:</p>
<blockquote>
<p>Run-time error '31004':</p>
<p>The value of an (AutoNumber) field
cannot be retrived prior to being
saved.</p>
<p>Please save the record that contains
... | <p>First of all, if you are going to look at experts-exchange - do it in FireFox, you'll see the unblocked answers at the bottom of the page.</p>
<p>Second, do you have a subform on that form that's using the autonumber/key field on the master form? Do you require the data that's on that subform to be saved (i.e., hav... | <p>Are you trying to assign the value of an Identity field to a variable or something else before you have saved the record?</p>
<p>For whatever reason, your app is trying to read the value of the identity field before the record has been saved, which is what generates that identity field. In other words, no value ex... | 8,452 |
<p>I'm a PHP developer and I've made something I want to push live.</p>
<p>It requires memcache, and I'm expecting a fair amount of traffic, at least at launch, so I'd like it to be fast.</p>
<p>I'm really awesome at programming, but when it comes to getting hosting stuff set-up (other than run-of-the-mill shared hos... | <p><a href="http://joyent.com/accelerator/pricing/" rel="nofollow noreferrer">Joyent</a> might be a good solution for you. Honestly adding memcache to a LAMP stack is ridiculously easy and you should be able to do it with relative ease. Find a good VPS provider (linode and slicehost are so good I'll recommend them with... | <p>I'd definitely look into using a linode.</p>
| 39,643 |
<p>I'm trying to store a password in a file that I'd like to retrieve for later. Hashing is not an option as I need the password for connecting to a remote server for later.</p>
<p>The following code works well, but it creates a different output each time even though the key is the same. This is bad as when the applic... | <p>I believe that what's happening is that the crypto provider is randomly generating an IV. Specify this and it should no longer differ.</p>
<p>Edit: You can do this in your 'keyProvider' by setting the IV property.</p>
| <p>According to the docs of CreateEncryptor:</p>
<blockquote>
<p>If the current IV property is a null
reference (Nothing in Visual Basic),
the GenerateIV method is called to
create a new random IV.</p>
</blockquote>
<p>This will make the ciphertext different every time.</p>
<p>Note: a way around this is disc... | 14,438 |
<p>I've found an <a href="http://chrison.net/UACElevationInManagedCodeStartingElevatedCOMComponents.aspx" rel="noreferrer">article</a> on how to elevate a COM object written in C++ by calling
<code>CoCreateInstanceAsAdmin</code>. But what I have not been able to find or do, is a way to implement a component of my .NET... | <p>Look at <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2cd92e43-6cda-478a-9e3b-4f831e899433&DisplayLang=en" rel="noreferrer">Windows Vista UAC Demo Sample Code</a></p>
<p>(You also need the <a href="http://msdn.microsoft.com/en-us/library/ms756482.aspx" rel="noreferrer">Vista Bridge</a> sampl... | <p>The elements of elevation are processes. So, if I understand your question correctly, and you want a way to elevate a COM object in your process, than the answer is you can't. The entire point of CoCreateInstanceAsAdmin is to NOT run it in your process.</p>
| 15,461 |
<p>Can I do it with reflection or something like that?</p>
| <p>I have been searching for a while and there seems to be different approaches, here is a summary:</p>
<ol>
<li><p><strong><a href="https://github.com/ronmamo/reflections" rel="noreferrer">reflections</a></strong> library is pretty popular if u don't mind adding the dependency. It would look like this:</p>
<pre><cod... | <p>Also, if you are writing an IDE plugin (where what you are trying to do is relatively common), then the IDE typically offers you more efficient ways to access the class hierarchy of the current state of the user code. </p>
| 45,181 |
<p>I'm trying to read the contents of the clipboard using JavaScript. With Internet Explorer it's possible using the function</p>
<pre><code>window.clipboardData.getData("Text")
</code></pre>
<p>Is there a similar way of reading the clipboard in Firefox, Safari and Chrome?</p>
| <p>Safari supports reading the clipboard during <code>onpaste</code> events:</p>
<p><a href="http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/CopyAndPaste.html#//apple_ref/doc/uid/30001234-176911" rel="noreferrer">Information</a></p>
<p>You want to do something like:</p>
... | <p>I believe people use a hidden Flash element to read the clipboard data from the browsers you mentioned.</p>
| 28,929 |
<p>I am looking to automate the conversion of an excel sheet into a pdf document (I do not want to manually print the report generated in excel as a pdf document every morning). For now, I would like to create a button in excel that will run the macro to automatically generate the pdf document, but this button will ev... | <p>I think i found the answer. Here is one solution someone at work suggested (if anyone finds it useful, then great).</p>
<p>There is no available method in the AcroEXch class (or set of methods that I know of) to <i>convert</i> a non-pdf file to a pdf file. Instead, you have to use the pdf Distiller to first convert... | <p>Have you considered CuteFTP or PDFCreator, both are free. I have sucessfully used PDFCreator with VBA and I have heard that CuteFTP is good.</p>
| 27,060 |
<p>I'm looking for a variation on the <code>#save</code> method that will only save
attributes that do not have errors attached to them.
So a model can be updated without being valid overall, and this will
still prevent saving invalid data to the database.</p>
<p>By "valid attributes", I mean those attributes that ... | <p>Since OpenSSL is Apache-licensed (i.e. BSD-style), you can simply distribute it as a DLL along with your application. (Maybe build it yourself to have only the features you need and all in a single DLL.) Then use p/invoke calls to talk with this DLL.</p>
<p>(Maybe you can even link the native code straight into you... | <p>Take a look at BouncyCastle <a href="http://www.bouncycastle.org/csharp/" rel="nofollow noreferrer">http://www.bouncycastle.org/csharp/</a></p>
| 10,528 |
<p>I have been working with T-SQL in MS SQL for some time now and somehow whenever I have to insert data into a table I tend to use syntax:</p>
<pre><code>INSERT INTO myTable <something here>
</code></pre>
<p>I understand that keyword <code>INTO</code> is optional here and I do not have to use it but somehow it... | <p><code>INSERT INTO</code> is the standard. Even though <code>INTO</code> is optional in most implementations, it's required in a few, so it's a good idea to include it to ensure that your code is portable.</p>
<p>You can find links to several versions of the SQL standard <a href="http://en.wikipedia.org/wiki/SQL#St... | <p>I prefer using it. It maintains the same syntax delineation feel and readability as other parts of the SQL language, like <code>group BY</code>, <code>order BY</code>.</p>
| 28,957 |
<p>I'm new to PHP and I'm trying to do something that may be bad practise and may well be impossible. I'm basically just hacking something together to test my knowledge and see what PHP can do.</p>
<p>I have one webpage with a form that collects data. That is submited to a PHP script that does a bunch of processing - ... | <p>You could store that data in the session e.g. in the first file that handles the post</p>
<pre><code>session_start();
$_SESSION['formdata'] = $_POST; //or whatever
</code></pre>
<p>then you can read it on the next page like</p>
<pre><code>session_start();
print_r($_SESSION['formdata']);
</code></pre>
<p>or you c... | <p>I hope i got your qestion right.
You might try this:</p>
<ol>
<li>Adjust your form to look like this:</li>
</ol>
<p>
form method="POST" action="process_data.php"
</p>
<p>2.
Then you create the file process_data.php, wich surprisingly processes the data.<br>
And in this file you use header:<br>
For example:<br></p... | 40,110 |
<p>One of my goals is to be able to deploy a new version of a web application that runs side by side the old version. The catch is that everything shares a database. A database that in the new version tends to include significant refactoring to database tables. I would like to be rollout the new version of the applic... | <p>If the old version has to be maintained, the changes simply can't be breaking. That also helps when deploying a new version of a web app - if you need to roll back, it <em>really</em> helps if you can leave the database as it is.</p>
<p>Obviously this comes with significant architectural handicaps, and you will alm... | <p>Assuming only 2 versions of your client, I'd only keep one copy of the data in the new tables.</p>
<p>You can maintain the contract between the old and new apps behind views on top of the new tables.
Use before/instead of triggers to handle writes into the "old" views that actually write into the new tables.</p>
<... | 32,070 |
<p>What is the <strong>complete</strong> and correct syntax for the SQL Case expression?</p>
| <p>The <strong>complete</strong> syntax depends on the database engine you're working with:</p>
<p>For SQL Server:</p>
<pre><code>CASE case-expression
WHEN when-expression-1 THEN value-1
[ WHEN when-expression-n THEN value-n ... ]
[ ELSE else-value ]
END
</code></pre>
<p>or:</p>
<pre><code>CASE
WHEN boo... | <p>Case statement syntax in SQL SERVER:</p>
<pre><code>CASE column
WHEN value1 THEN 1
WHEN value3 THEN 2
WHEN value3 THEN 3
WHEN value1 THEN 4
ELSE ''
END
</code></pre>
<p>And we can use like below also:</p>
<pre><code>CASE
WHEN column=value1 THEN 1
WHEN column=value3 THEN 2
WHEN column=valu... | 2,661 |
<p>There are a number of other questions related to this topic:</p>
<ol>
<li><s><a href="https://stackoverflow.com/questions/5214/whats-a-good-standard-code-layout-for-a-php-application">Whats a good standard code layout for a php application</a></s> (deleted)</li>
<li><a href="https://stackoverflow.com/questions/7596... | <p>Google has a geocoding API which seems to work pretty well for most of the locations that they have Google Maps data for.</p>
<p><a href="http://googlemapsapi.blogspot.com/2006/06/geocoding-at-last.html" rel="noreferrer">http://googlemapsapi.blogspot.com/2006/06/geocoding-at-last.html</a></p>
<p>They provide onlin... | <p>The <a href="https://webgis.usc.edu" rel="nofollow noreferrer">USC WebGIS Geocoder</a> is free and offers several API's, or you can upload a database for online batch processing.</p>
| 12,384 |
<p>Some of the platforms that I develop on, don't have profiling tools. I am looking for suggestions/techniques that you have personally used to help you identify hotspots, without the use of a profiler.</p>
<p>The target language is C++.</p>
<p>I am interested in what you have personally used.</p>
| <p>I've found the following quite useful:</p>
<pre><code>#ifdef PROFILING
# define PROFILE_CALL(x) do{ \
const DWORD t1 = timeGetTime(); \
x; \
const DWORD t2 = timeGetTime(); \
std::cout << "Call to '" << #x << "' took " << (t2 - t1) << " ms.\n"; \
}while(false)
#else
#... | <p>I would use the 80/20 rule and put timers around hotspots or interesting call paths. You should have a general idea where the bottlenecks will be (or at least a majority of the execution paths) and use the appropriate platform dependent high resolution timer (QueryPerformanceCounters, gettimeofday, etc.).</p>
<p>I ... | 36,285 |
<p>Should links on a web page ALWAYS be underlined?<br />
I do not believe this should be a hard and fast RULE!<br />
I wrote a comment on my <a href="http://dotnetbob.blogspot.com/2007/11/links-and-usability.html" rel="nofollow noreferrer">blog</a> awhile back about this after another developer complained that I was ... | <p>I think all links need to be <em>distinguishable</em> from normal text, but not necessarily underlined. Menus and navigation bars are pretty standard on websites, and are usually recognisable as such, so I think they are being a little too dogmatic.</p>
| <p>I agree, I don't think that underline should be used for anything that is not a link.</p>
<p>There are certain things that need not be underlined. Page navigation, items in menus, prev/next links, especially if they have arrows are just some examples. I would still suggest that giving them an underline on hover b... | 26,937 |
<p>Does anyone know of a way to declare a date constant that is compatible with international dates?</p>
<p>I've tried:</p>
<pre><code>' not international compatible
public const ADate as Date = #12/31/04#
' breaking change if you have an optional parameter that defaults to this value
' because it isnt constant.
pub... | <p>If you look at the IL generated by the statement</p>
<pre><code>public const ADate as Date = #12/31/04#
</code></pre>
<p>You'll see this:</p>
<pre><code>.field public static initonly valuetype [mscorlib]System.DateTime ADate
.custom instance void [mscorlib]System.Runtime.CompilerServices.DateTimeConstantAttribute... | <p>OK, I am unsure what you are trying to do here:</p>
<ul>
<li>The code you are posting is <strong>NOT</strong> .NET, are you trying to port?</li>
<li>DateTime's cannot be declared as constants.</li>
<li>DateTime's are a data type, so once init'ed, the format that they were init'ed from is irrelevant.</li>
<li>If you... | 8,174 |
<p>Is there any function that converts an escaped Url string to its unescaped form? <code>System.Web.HttpUtility.UrlDecode()</code> can do that job but I don't want to add a reference to <code>System.Web.dll</code>. Since my app is not a web application, I don't want to add a dependency for only using a function in an ... | <p><strong>EDIT:</strong> Use the static method <strong><code>Uri.UnescapeDataString()</code></strong> to decode your URLs:</p>
<p><em>Encoded:</em> <code>http%3a%2f%2fwww.google.com%2fsearch%3fhl%3den%26q%3dsomething%20%2323%26btnG%3dGoogle%2bSearch%26aq%3df%26oq%3d</code></p>
<p><em>Decoded:</em> <code>http://www.g... | <p><code>System.Net.WebUtility.HtmlDecode</code> is also working on .NET 4.0 Client Profile.</p>
| 29,647 |
<p>This is driving me nuts so any advice from fellow users would be welcome. I am using Subversion, with a copy of VisualSVN 1.6.1 installed on a Windows server. On my PC I am using a combination of TortoiseSVN and the wonderful AnkhSVN Visual Studio plugin. Everything works like a dream, but now I am trying use the... | <p>It seems that the answer is just some silly quotes around the actual keywords :)</p>
<pre><code>[auto-props]
*.cpp = svn:eol-style=native;svn:keywords="Author Date Id HeadURL Revision"
</code></pre>
| <p>This seems to be an issue with AnkhSVN. I did some tests outside of Visual Studio, using TortoiseSVN to add the files, and it started working (using my user config file). I will try the latest AnkhSVN to see if this makes any difference.</p>
<p>I'd prefer to have this done at the server end, but this seems to be ... | 41,870 |
<p>Is it possible to do a <code>SELECT</code> statement with a predetermined order, ie. selecting IDs 7,2,5,9 and 8 <strong>and returning them in that order</strong>, based on nothing more than the ID field?</p>
<p>Both these statements return them in the same order: </p>
<pre><code>SELECT id FROM table WHERE id in (... | <p>I didn't think this was possible, but found a <a href="http://www.handgestrickt.biz/item/21/" rel="noreferrer">blog entry here</a> that seems to do the type of thing you're after:</p>
<pre><code>SELECT id FROM table WHERE id in (7,2,5,9,8)
ORDER BY FIND_IN_SET(id,"7,2,5,9,8");
</code></pre>
<p>will give different... | <p>Best I can think of is adding a second Column orderColumn:</p>
<pre><code>7 1
2 2
5 3
9 4
8 5
</code></pre>
<p>And then just do a ORDER BY orderColumn</p>
| 16,266 |
<p>How do I find out what directory my console app is running in with C#?</p>
| <p>To get the directory where the .exe file is:</p>
<pre><code>AppDomain.CurrentDomain.BaseDirectory
</code></pre>
<p>To get the current directory:</p>
<pre><code>Environment.CurrentDirectory
</code></pre>
| <p>Use <code>AppContext.BaseDirectory</code> for .net5.</p>
| 12,278 |
<p>In MySQL, If I have a list of date ranges (range-start and range-end). e.g.</p>
<pre><code>10/06/1983 to 14/06/1983
15/07/1983 to 16/07/1983
18/07/1983 to 18/07/1983
</code></pre>
<p>And I want to check if another date range contains ANY of the ranges already in the list, how would I do that?</p>
<p>e.g.</p>
<pr... |
<p>This is a classical problem, and it's actually easier if you reverse the logic.</p>
<p>Let me give you an example.</p>
<p>I'll post one period of time here, and all the different variations of other periods that overlap in some way.</p>
<pre class="lang-none prettyprint-override"><code> |-------------... | <pre><code>SELECT *
FROM tabla a
WHERE ( @Fini <= a.dFechaFin AND @Ffin >= a.dFechaIni )
AND ( (@Fini >= a.dFechaIni AND @Ffin <= a.dFechaFin) OR (@Fini >= a.dFechaIni AND @Ffin >= a.dFechaFin) OR (a.dFechaIni>=@Fini AND a.dFechaFin <=@Ffin) OR
(a.dFechaIni>=@Fini AND a.dFechaFin >=@Ff... | 17,328 |
<p>I need to "merge" two XML documents, overwriting the overlapsed attributes and elements. For instance if I have <strong>document1</strong>:</p>
<pre><code><mapping>
<key value="assigned">
<a/>
</key>
<whatever attribute="x">
<k/>
<j/>
... | <p>If you like XSLT, there's a nice merge script I've used before at:
<a href="http://web.archive.org/web/20160809092524/http://www2.informatik.hu-berlin.de/~obecker/XSLT/" rel="nofollow noreferrer">Oliver's XSLT page</a></p>
| <p>Unsure as to whether you want to do this programatically or not.</p>
<p>Edit: Ah, I posted that before the Edit. Don't I look like an idiot now! ;)</p>
<p>If you just want to merge two files together, IBM have an <a href="http://www.alphaworks.ibm.com/tech/xmldiffmerge" rel="nofollow noreferrer">XML Diff and Merg... | 10,607 |
<p>Recently, someone asked about an <a href="https://stackoverflow.com/questions/198199/how-do-you-reverse-a-string-in-place-in-c-or-c">algorithm for reversing a string in place in C</a>. Most of the proposed solutions had troubles when dealing with non single-byte strings. So, I was wondering what could be a good algo... | <p>I'd make one pass reversing the bytes, then a second pass that reverses the bytes in any multibyte characters (which are easily detected in UTF8) back to their correct order.</p>
<p>You can definitely handle this in line in a single pass, but I wouldn't bother unless the routine became a bottleneck.</p>
| <p>The best solution:</p>
<ol>
<li>Convert to a wide char string</li>
<li>Reverse the new string</li>
</ol>
<p>Never, never, never, never treat single bytes as characters.</p>
| 24,291 |
<p>I'm trying to do a simple erase and keep getting errors.</p>
<p>Here is the snippet of code for my erase:</p>
<pre><code>std::list<Mine*>::iterator iterMines = mines.begin();
for(int i = oldSizeOfMines; i >0 ; i--, iterMines++)
{
if(player->distanceFrom(*iterMines) < radiusOfOnScreen)
{
... | <p>The problem is you are trying to use the iterator of mines as an iterator in the onScreen list. This will not work. </p>
<p>Did you mean to call mines.erase(iterMines) instead of onScreen.erase(iterMines)?</p>
| <p>more simple method
<a href="http://zhgn.vicp.net/boke/200901071529.htm" rel="nofollow noreferrer">List.erase(p)的用法</a></p>
| 48,845 |
<p>Tip me plase, how to insert a null value into table using Trolltech Qt 4.x SQL classes? <code>QSqlQuery</code>, I guess, or something else from QtNetwork.
As analog of it, in .NET there is the <code>System.DbNull</code> class, which represents sql NULL.</p>
<p>And what type should I use for some object's property, ... | <p>From <code>QSqlQuery::addBindValue</code> documentation:</p>
<blockquote>
<p>To bind a NULL value, use a null
QVariant; for example, use
QVariant(QVariant::String) if you are
binding a string.</p>
</blockquote>
| <p>The question is for QT 4, but I think it's worth mentioning that in QT 5 you have only to pass a NULL value.</p>
| 43,988 |
<p>I am trying to make a combined image of all images added to a modell in django with inline editing and a ForeignKey. Ive got these models (simplified):</p>
<pre><code>class Modell(models.Model):
title = models.CharField('beskrivelse', max_length=200)
slug = models.SlugField()
is_public = models.BooleanF... | <p><code>Modell</code> and <code>Image</code> are two seperate models connected with a <code>ForeignKey</code>. Even though they both seem to be saved <em>together</em>, they don't. They are saved one by one (first the <code>Modell</code> or first the <code>Image</code>s).</p>
<p>Now logically <code>Image</code>s are ... | <p>I dit solve it somehow, but it is farm from optimal, I did the modell_on_save function on Image save, this works, but the bad thing that if there are 5 images related and saved to the modell, there will be 5 calls to the function, and that is bad. I would like it to only happen after the last one...</p>
| 45,109 |
<p>I have got a table in MS Access 2007 with 4 fields.</p>
<ul>
<li>Labour Cost</li>
<li>Labour Hours</li>
<li>Vat</li>
<li>Total</li>
</ul>
<p>How do I multiply 'Labour Hours' by 'Labour Cost' add the 'VAT' and display the answer in 'Total'</p>
<p>Where would I put any formulas?, in a form or query or table ?</p>
| <p>There is also the dummies (ie not SQL) way to do it:
First delete your total column from your table and for this exercise pretend that the name of your table is "Labour" .</p>
<p>Now create a new query and view it in design view, add all the fields from your Labour table (so you can check that everything is working... | <p>You could put it in as a calculated field, in the query or on the form. Wherever makes sense, is simple and has the right level of re-usability. If the calculation is specific a form or view of the data, do it there or in the query.</p>
<p>In this case, you can foresee that the total will be an oft used value and l... | 38,148 |
<p>The function below takes a python file handle, reads in packed binary data from the file, creates a Python dictionary and returns it. If I loop it endlessly, it'll continually consume RAM. What's wrong with my RefCounting?</p>
<pre><code>static PyObject* __binParse_getDBHeader(PyObject *self, PyObject *args){
Py... | <p><code>PyDict_New()</code> returns a new reference, check the <a href="http://docs.python.org/c-api/dict.html" rel="noreferrer">docs</a> for <code>PyDict</code>. So if you increase the refcount immediately after creating it, you have two references to it. One is transferred to the caller when you return it as a resul... | <p>I don't know about Python-C. However, My experience with COM reference counting says that a newly created reference-counted object has a reference count of <strong>1</strong>. So your Py_INCREF(pyDB) after PyArg_ParseTuple(args, "O", &pyDB) and PyObject *pyDBHeader = PyDict_New(); are the culprit. Their referenc... | 45,646 |
<p>I'm already using <a href="http://www.matasano.com/log/958/enough-with-the-rainbow-tables-what-you-need-to-know-about-secure-password-schemes/" rel="nofollow noreferrer">salted hashing</a> to store passwords in my database, which means that I should be immune to <a href="https://en.wikipedia.org/wiki/Rainbow_table" ... | <p>Bruce Schneier has a good response to this kind of problem.</p>
<blockquote>
<p>Cryptography is not the solution to your security problems. It might be part of the solution, or it might be part of the problem. In many situations, cryptography starts out by making the problem worse, and it isn't at all clear that ... | <p>You really have to weigh your worst case senario of someone obtaining those email addresses, the likelihood of someone obtaining them, and your extra effort/time needed to impliement the change.</p>
| 9,583 |
<p>I mistakenly added files to Git using the command:</p>
<pre><code>git add myfile.txt
</code></pre>
<p>I have not yet run <code>git commit</code>. How do I undo this so that these changes will not be included in the commit?</p>
| <p>Undo <code>git add</code> for uncommitted changes with:</p>
<pre><code>git reset <file>
</code></pre>
<p>That will remove the file from the current index (the "about to be committed" list) without changing anything else.</p>
<hr />
<p>To unstage all changes for all files:</p>
<pre><code>git reset
</c... | <p>The first time I had this problem, I found <a href="https://stackoverflow.com/questions/348170/how-do-i-undo-git-add-before-commit?page=1&tab=votes#tab-top">this post</a> here and from the first answer I learned that I should just do <code>git reset <filename></code>. It worked fine.</p>
<p>Eventually, I h... | 45,303 |
<p>I'm looking for recommendations on books about MVC on the desktop. If they use Java, that is a bonus.</p>
<p>Some background:
I'm writing a desktop application in Java. It's an audio application that has a number of views and a central model called a Library with playlists, effects lists and a folder structure to... | <p>I've had the same problem: it really takes a lot of discipline to write a (non trivial) swing app, because all the listeners and events and asynchronous processing make up really fast for a big pile of unmaintainable code. </p>
<p>I found that classic MVC isn't enough, you have to look into more specific patterns l... | <p>Don't forget the Swing Tutorials; for instance the <a href="http://java.sun.com/docs/books/tutorial/uiswing/events/index.html" rel="nofollow noreferrer">Swing Events tutorial</a>.</p>
<p>And please bear in mind the SwingWorker, or handling events in a separate worker thread. I'm no expert on Swing by any means but ... | 20,365 |
<p>Is there a catch or hidden problem in using a <a href="http://www.danrigsby.com/blog/index.php/2008/03/15/disposable-base-class/" rel="nofollow noreferrer">DisposableBase base class</a> instead of recoding the Dispose pattern on every class?</p>
<p>Why aren't everyone using such a <strong>relevant</strong> class?</... | <p>You don't need to implement Dispose() on <em>every</em> class - just those with something that needs deterministic cleanup. Re a Disposable base-class, I'm not entirely sure it provides a whole lot - <code>IDisposable</code> isn't a complex interface. The main time it might be useful is if you are handling unmanaged... | <p>As Marc Gravell said, you only need a finalizer if you are handling unmanaged objects. Introducing an unnecessary finalizer in a base class is a bad idea, as per the reasons in section 1.1.4 of the <a href="http://www.bluebytesoftware.com/blog/PermaLink.aspx?guid=88e62cdf-5919-4ac7-bc33-20c06ae539ae" rel="nofollow n... | 35,061 |
<p>I am trying to detect which web in sharepoint that the user is looking at right now. One approach could be to read the URls from the browser and try to compare them to a reference URL to the sharepoint solution. I have not yet been able to locate any solution that works in both IE and Firefox.</p>
<p>The idea is to... | <p>It is possible to do this in a very hacky and prone to breakage way using the Win32 API function FindWindow.</p>
<p>The following C++ example that finds a running instance of the windows Calculator and gets the value of the edit field in it. You should be able to do something similar in C#. Disclaimer: I haven't ... | <p>Just off the top of my head, you might consider using the built-in Firefox language (no idea what it's called). I'm sure it provides a mechanism to do exactally what you talking about. Otherwise those plugin's written for delicious, etc, wouldn't work.</p>
<p>As for IE, you're going to need to either do it in C++... | 25,335 |
<p>I'm having an issue where the first layer of my support structures isn't sticking on the edges and causing the print to (eventually) fail. Any ideas on how I can fix it?</p>
<p>I'm using Slic3r.</p>
<p><a href="https://i.stack.imgur.com/XD4AX.jpg" rel="nofollow noreferrer" title="Photograph of first printed layer... | <p>There are many things you'll need to check and/or confirm to ensure that you will have a good bond to the bed. The first is to confirm that you are using a genuine Prusa printer as it appears in the photo. Having built one recently makes it easier for me to guess that is the case.</p>
<p>Have you performed the bed ... | <p>I had a similar issue where slic3r generated supports that attach directly to the bed, but didn't put enough material around the thin supports on the first layer, so they didn't stick to the bed.</p>
<p>To solve this I added a brim, see "skirt and brim" under "print settings". This puts more material around both th... | 578 |
<p>Given an HTML page that has a complex table-based layout and many tags that are duplicated and wasteful, e.g.:</p>
<pre><code>td align="left" class="tableformat" width="65%" style="border-bottom:1px solid #ff9600; border-right:1px solid #ff9600; background-color:#FDD69E" nowrap etc.
</code></pre>
<p>Are there tool... | <p>I agree with <a href="https://stackoverflow.com/questions/151369/tools-for-refactoring-table-based-html-layouts-to-css#151466">TimB</a> in that automated tools are going to have trouble doing this, in particular making the relational jumps to combine and abstract CSS in the most efficient way.</p>
<p>If you are pre... | <p>You denigrate this approach in your question, but I'd recommend taking a screen shot of your page in the browser whose rendering you like the best, declare that to be your reference, and start trying to recreate it. It's easier than you think. I've had to take skanky old table-based layouts and turn them into CMS ... | 18,246 |
<p>I am at the point where I need to add keys to my app. What are some of the possible solutions you guys used? I've looked at an earlier <a href="https://stackoverflow.com/questions/118031/best-activation-key-software-for-net-application">post</a> so far, anything else before I decide. My 2 influential factors are:</p... | <p>If you are talking about software protection, take a minute to reconsider it.</p>
<p>Protection schemes are mostly a waste of time. If .NET is similar in this regard to Java, decompiling the code and removing any kind of protection is trivial. The only more or less robust solutions are network based- and these can ... | <p><a href="http://www.aladdin.com/" rel="nofollow noreferrer" title="Aladdin HASP">Aladdin</a></p>
<p><a href="http://www.aladdin.com/hasp/protection-keys-benefits-models.aspx" rel="nofollow noreferrer" title="Software and Hardware Comparison">Aladdin's Software and Hardware Solution Comparison Chart</a></p>
<p>We p... | 29,716 |
<p>Many people string together find and sed, or perl, or any number of other unix commands to find and replace across multiple files. But, there's a simple command that can do it for you without the hassle? </p>
<p>Edit:
The Digital Ninja points out that it's rpl. </p>
<p>However this is not a built in command but, ... | <p>I belive you are thinking of 'rpl'
<a href="http://www.linux.org/apps/AppId_2684.html" rel="nofollow noreferrer">http://www.linux.org/apps/AppId_2684.html</a></p>
| <p>I think some variation of the following would work :</p>
<pre>find . -name *.extension | perl -pi.bak -e "s/text_to_be_replaced/replacement/"</pre>
| 39,838 |
<p>So I was writing some code today that basically looks like this:</p>
<pre><code>string returnString = s.Replace("!", " ")
.Replace("@", " ")
.Replace("#", " ")
.Replace("$", " ")
.Replace("%", " ")
.Replace("^", " ")
.Replace("*", " ")
... | <p>You can use <strong>Regex.Replace()</strong>. All of the characters can be placed between square brackets, which matches any character between the square brackets. Some special characters have to be escaped with backslashes, and I use a @verbatim string here, so I don't have to double-escape them for the C# compiler... | <pre><code>s/[!@#$%^*_+=\]/ /
</code></pre>
<p>Would be the regex for it... in c# you should be able to use</p>
<pre><code>Regex.Replace(yourstring, "[!@#$%^*_+=\]", "" );
</code></pre>
<p>Though my C# is rusty..</p>
| 14,400 |
<p>I'm trying to find out the 'correct' windows API for finding out the localized name of 'special' folders, specifically the Recycle Bin. I want to be able to prompt the user with a suitably localized dialog box asking them if they want to send files to the recycle bin or delete them directly.</p>
<p>I've found lots ... | <p>Read this article for code samples and usage:</p>
<p><a href="http://www.codeproject.com/KB/winsdk/SpecialFolders.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/winsdk/SpecialFolders.aspx</a></p>
<p>Also there is an article on MSDN that helps you <a href="http://msdn.microsoft.com/en-us/library/aa14... | <p>I actually didn't find the CodeProject article terribly helpful, so I thought I'd answer this question with the actual code that I used to retrieve the localized name of the recycle bin.</p>
<p>This sample also tries to behave correctly with regard to freeing resources. Any comments are welcome, especially if you ... | 5,770 |
<p>In SQL Server 2005, we can create temp tables one of two ways:</p>
<pre><code>declare @tmp table (Col1 int, Col2 int);
</code></pre>
<p>or</p>
<pre><code>create table #tmp (Col1 int, Col2 int);
</code></pre>
<p>What are the differences between these two? I have read conflicting opinions on whether @tmp still us... | <p>There are a few differences between Temporary Tables (#tmp) and Table Variables (@tmp), although using tempdb isn't one of them, as spelt out in the MSDN link below.</p>
<p>As a rule of thumb, for small to medium volumes of data and simple usage scenarios you should use table variables. (This is an overly broad gui... | <p>In SQL the Temporary tables are stored in the TempDB and the local temporary tables are only visible in the current session and it will not be visible in another session. This can be shared between nested stored procedure calls. The Global temporary tables are visible to all other sessions and they are destroyed whe... | 4,755 |
<p>What web based interface for browsing <strong>Subversion</strong> repositories do you like the most? We have tried <strong>Viewvc</strong>, but the installation seemed too complex for us.</p>
<p>This is no poll. I'd really love to allow people at the office to be able to access the data at the repositories with the... | <p>I love Fisheye from Atlassian (née Cenqua). It might have too many functions for you taste (searching, auditing and code review support are all part of the package these days), but it has the best interface for browsing SVN (or any VC-system, actually) I have yet encountered.
On the downside, it's commercial (if you... | <p>If you are looking for simplicity, you can browse the repository by just pointing your browser to the repository URL.</p>
| 39,886 |
<p>A follow up to an earlier question, showing the part that fails when I try to get the error message from my target library:</p>
<pre><code>require 'gt4r'
@@test_environment = "INCLUDE=C:\\graphtalk\\env\\aiadev\\config\\aiadev.ini"
@@normal_user = "BMCHARGUE"
describe Gt4r do
it 'initializes' do
rv = Gt4r... | <p>Which bit fails? I'm guessing it's this:</p>
<pre><code>Gt4r.gTD_get_error_message rv, @msg
</code></pre>
<p>How is the method implemented? What's the C signature of the method? (*char)?</p>
<p>Btw: at the risk of sounding like broken record, it's MUCH easier to write a C extension than trying to shoehorn things ... | <p>Is @msg even initialized at this point: </p>
<pre><code>Gt4r.gTD_get_error_message rv, @msg
</code></pre>
<p>If @msg is nil, DL will probably cast it to a null pointer which crashes when your lib tries to dereference it.</p>
| 38,686 |
<p>Any failed ASSERT statements on Windows cause the below debug message to appear and freeze the applications execution. I realise this is expected behaviour but it is running periodically on a headless machine so prevent the unit tests from failing, instead waiting on user input indefinitely.</p>
<p>Is there s a reg... | <p>From MSDN about the ASSERT macro:</p>
<p>In an MFC ISAPI application, an assertion in debug mode will bring up a modal dialog box (ASSERT dialog boxes are now modal by default); this will interrupt or hang the execution. To suppress modal assertion dialogs, add the following lines to your project source file (proje... | <p>In a unit-test context, it is often good to convert ASSERTs (actually <code>_CrtDbgReport</code> calls) into some exception, typically a std::exception, that contains some informative text.
This tends to wend its way out to the unit test's output log as a fail.
That's just what you want: A failed ASSERT should be a ... | 19,761 |
<p>I created the setup project for the application and I can see that the later modifications of the configuration file (Application.exe.config) don't affect the application execution.</p>
<p>I am developing an application with the database file included and I want to enable users to move the database file and modify ... | <p>It should work, provided that you use the exact same connection string setting in your DB access DLL's Settings.settings file and in your application's config file.</p>
<p>An example that works well for me:</p>
<pre><code> <connectionStrings>
<add name="YourApp.Properties.Settings.DatabaseConnectionStri... | <p>did you make sure to remove the settings default values? These are compiled and fetched from the dll and not from the config file.</p>
| 29,285 |
<p>What are the pros and cons of using nested public C++ classes and enumerations? For example, suppose you have a class called <code>printer</code>, and this class also stores information on output trays, you could have:</p>
<pre><code>class printer
{
public:
std::string name_;
enum TYPE
{
TYPE_... | <h2>Nested classes</h2>
<p>There are several side effects to classes nested inside classes that I usually consider flaws (if not pure antipatterns).</p>
<p>Let's imagine the following code :</p>
<pre><code>class A
{
public :
class B { /* etc. */ } ;
// etc.
} ;
</code></pre>
<p>Or even:</p>
<pre><code>clas... | <p>Only problem with nested classes that I bumped into yet was that C++ does not let us refer to the object of the enclosing class, in the nested class functions. We cannot say "Enclosing::this"</p>
<p>(But maybe there's a way?)</p>
| 26,640 |
<p>A while back, I had worked on building a <a href="https://biber-boote.ch/yostwerks/SeaCruiser.html" rel="nofollow noreferrer">Yostwerks Sea Cruiser</a>. Now I'm thinking of trying to create a 3D printable (or 3D millable) version of the plans.</p>
<p>The original design uses cross-sections cut from a half-inch thic... | <p>According to <a href="https://omnexus.specialchem.com/polymer-properties/properties/stiffness" rel="nofollow noreferrer">the chart on this page</a> HDPE has a flexural modulus of between 0.75 and 1.575 Gpa; meanwhile PETG has a flexural modulus of 2.20 Gpa, meaning PETG is the stiffer material.</p>
<p>HDPE, by defi... | <p>Because of the inherent nature of FDM, material properties will most certainly be always lower than casted/extruded sheet material. Furthermore, your question implies to use the same geometry of the ribs, I doubt whether there will be a filament that is able to get close to your requirements regarding strength and s... | 1,080 |
<p>I finished a 3D object for 4 wheels, but something seems wrong with the final scene to me:</p>
<p>The nearer wheels (#1 and #2) appear smaller than the far one (#3 and #4), and the distance between wheel #3 an #4 seems longer than between (1) and (2), like you can see in this picture:</p>
<p><a href="https://i.sta... | <p>CAD programs uses parallel view not perspective view.
So the length of 2 objects with the same length are displayed as 2 objects with the same length on the screen.
This is better for constructing stuff. </p>
| <p>CAD programs uses parallel view not perspective view.
So the length of 2 objects with the same length are displayed as 2 objects with the same length on the screen.
This is better for constructing stuff. </p>
| 1,044 |
<p>This is a question for a WSS/SharePoint guru. </p>
<p>Consider this scenario: I have an ASP.Net web service which links our corporate CRM system and WSS-based intranet together. What I am trying to do is provision a new WSS site collection whenever a new client is added to the CRM system. In order to make this work... | <p><strong>Update</strong>
I think you have proved that the issue is not with the code.</p>
<p>SPSecurity.RunWithElevatedPrivileges: Normally the code in the SharePoint web application executes with the privileges of the user taking the action. The RunWithElevatedPrivileges runs the code in the context of the SharePoi... | <p>If you want to create a managed path (explicit) and a site collection at that path, do the following:</p>
<pre><code>using (SPSite site = new SPSite("http://dev-moss07-eric")) {
SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://dev-moss07-eric"));
if (webApp.Prefixes.... | 45,878 |
<p>What's the most appropriate type used to store the duration time information of a video in sql server?</p>
| <p>There are <a href="http://www.sqlteam.com/article/working-with-time-spans-and-durations-in-sql-server" rel="nofollow noreferrer">several options</a>, including using the builtin DateTime or Time data type with offset from a particular fixed zero (which will allow you to use the built-in date/time function to get hou... | <p>I would store it as an INT representing the number of seconds, but I suppose it all depends what you need to do with the information in your database (you wouldn't want to have to convert it to HH:MM:SS or something else in your DB)</p>
| 31,738 |
<p>I'm hand-maintaining an HTML document, and I'm looking for a way to automatically insert a link around text in a table. Let me illustrate:</p>
<pre><code><table><tr><td class="case">123456</td></tr></table>
</code></pre>
<p>I would like to automatically make every text in a TD w... | <p>Not in a manner that will work across browsers. You could, however, do that with some relatively trivial Javascript..</p>
<pre><code>function makeCasesClickable(){
var cells = document.getElementsByTagName('td')
for (var i = 0, cell; cell = cells[i]; i++){
if (cell.className != 'case') continue
... | <p>I know this is an old question, but I stumbled upon this post looking for a solution for creating hyperlinks using CSS and ended up making my own, could be of interest for someone stumbling across this question like I did:</p>
<p>Here's a php function called 'linker();'that enables a fake CSS attribute </p>
<block... | 19,953 |
<p>Some prints take a long time and, as I'm not in a workshop, I need to pause the print sometimes.</p>
<p>Are there any special considerations I should take when pausing, or can I literally just click pause, leave it for twelve hours or so, and it'll continue without any ill effects?</p>
<p>I'm using PLA at present.... | <p>If you keep the head hot during the pause, and over the print, you will melt the material already deposited.</p>
<p>If you move to X0 Y0 (like on a layer change) and pause there, you can cool off the head (or not), but will want to prime (advance) some material before resuming your print - or risk an initial void, ... | <p>It is not recommended to pause prints a considerable amount of time as the printed model will shrink and might warp during the pause. Also, layer bonding between the old and the new art after resuming will be weak, but this can be used to induce planned breaking layers.</p>
<p>On the other hand, <strong>if</strong>... | 1,136 |
<p>I have somehow misconfigured fingers. This leads to a very annoying situation.</p>
<ol>
<li>I select a block of text to copy;</li>
<li>I move the cursor the place where I want to paste the code;</li>
<li>I accidentally press Ctrl+C again instead of Ctrl+V;</li>
<li>My block of copied text is replaced by an empty bl... | <p>It's not copying an empty block, it's copying the blank line. You can change this setting in Tools > Options > Text Editor > All Languages > 'Apply Cut or Copy Commands to blank lines when there is no selection'</p>
| <p>Go to Tools > Options > Text Editor > All Languages > General</p>
<p>The option on that page is "Apply Cut or Copy commands to blank lines when there is no selection"</p>
| 9,971 |
<p>I'm using a Java socket, connected to a server.
If I send a HEADER http request, how can I measure the response time from the server? Must I use a provided java timer, or is there an easier way?</p>
<p>I'm looking for a short answer, I don't want to use other protocols etc. Obviously do I neither want to have a so... | <p>I would say it depends on what exact interval you are trying measure, the amount of time from the last byte of the request that you send until the first byte of the response that you receive? Or until the entire response is received? Or are you trying to measure the server-side time only?</p>
<p>If you're trying ... | <p>Use AOP to intercept calls to the socket and measure the response time.</p>
| 9,444 |
<p>I got the following class :</p>
<pre><code>class ConstraintFailureSet(dict, Exception) :
"""
Container for constraint failures. It act as a constraint failure itself
but can contain other constraint failures that can be accessed with a dict syntax.
"""
def __init__(self, **failures) :
... | <p>Both <code>Exception</code> and <code>dict</code> are implemented in C.</p>
<p>I think you can test this the follwing way:</p>
<pre><code>>>> class C(object): pass
...
>>> '__module__' in C.__dict__
True
>>> '__module__' in dict.__dict__
False
>>> '__module__' in Exception.__dic... | <p>I am almost certain that with 2.4 problem is caused by exceptions being old style classes.</p>
<pre><code>$ python2.4
Python 2.4.4 (#1, Feb 19 2009, 09:13:34)
>>> type(dict)
<type 'type'>
>>> type(Exception)
<type 'classobj'>
>>> type(Exception())
<type 'instance'>
$ py... | 39,829 |
<p>I've recently found out about protocol buffers and was wondering if they could be applied to my specific problem.</p>
<p>Basically I have some CSV data that I need to convert to a more compact format for storage as some of the files are several gig. </p>
<p>Each field in the CSV has a header, and there are only tw... | <p>Well, it's certainly representable. Something like:</p>
<pre><code>message CsvFile {
repeated CsvHeader header = 1;
repeated CsvRow row = 2;
}
message CsvHeader {
require string name = 1;
require ColumnType type = 2;
}
enum ColumnType {
DECIMAL = 1;
STRING = 2;
}
message CsvRow {
repe... | <p>Well, protobuf-net (my version) is based on regular .NET types, so no (since it won't cope with different schemas all the time). But Jon's version might allow dynamic types. Personally, I'd just use CSV and run it through GZipStream - I expect that will be fine for the purpose.</p>
<hr>
<p>Edit: actually, I forgot... | 48,537 |
<p>I have a repeater that is bound to some data.</p>
<p>I bind to the <strong>ItemDataBound</strong> event, and I am attempting to <strong>programmatically</strong> create a <strong>UserControl</strong>:</p>
<p>In a nutshell:</p>
<pre><code>void rptrTaskList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
... | <p>Eh, figured out one way to do it:</p>
<pre><code>ExecTaskControl foo = (ExecTaskControl)LoadControl("tasks\\ExecTaskControl.ascx");
</code></pre>
<p>It seems silly to have a file depedancy like that, but maybe thats how UserControls must be done.</p>
| <p>I think that @Craig is on the right track depending on the details of the problem you are solving. Add it to the repeater and remove it or set Visible="false" to hide it where needed. Viewstate gets tricky with dynamically created controls/user controls, so google that or check <a href="http://www.aspnet4you.com/a... | 4,874 |
<p>What is the difference between <code>ref</code> and <code>out</code> parameters in .NET? What are the situations where one can be more useful than the other? What would be a code snippet where one can be used and another can't?</p>
| <p>They're pretty much the same - the only difference is that a variable you pass as an <code>out</code> parameter doesn't need to be initialized but passing it as a <code>ref</code> parameter it has to be set to something.</p>
<pre><code>int x;
Foo(out x); // OK
int y;
Foo(ref y); // Error: y should be initialized b... | <p>ref will probably choke on null since it presumably expects to be modifying an existing object. out expects null, since it's returning a new object.</p>
| 16,378 |
<p>I'm encountering some peculiarities with LINQ to SQL.</p>
<p>With a relatively simple query, I want to select some fields, but have the date fields formatted as strings, which I first achieved like this:</p>
<pre><code> var list = dataContext.MyLists.Single(x => x.ID == myId);
var items = from i... | <p>I'd do the SQL part without doing the formatting, then do the formatting on the client side:</p>
<pre><code>var items = list.MyItems.Select(item => new { item.ID, item.Sector, item.Description,
item.CompleteDate, item.DueDate })
.AsEnumerable... | <p><code>ToShortDateString()</code> is not supported by Linq to SQL <a href="http://msdn.microsoft.com/en-us/library/bb882657.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb882657.aspx</a></p>
| 19,728 |
<p>I want to automate SVN adds using NAnt. I want to add to SVN all new files in a given directory. The NAnt script will successfully execute the add command, however it displays the Tortoise SVN add dialog and this is not acceptable because it will execute on a build server running CruiseControl. The build server is r... | <p>Don't use tortoisesvn. Get a <a href="http://www.collab.net/downloads/subversion/" rel="nofollow noreferrer">commandline svn client</a>.</p>
| <p>don't use tortoise!</p>
<p>just drop to command line svn.</p>
<pre><code>c:\>svn add ...
</code></pre>
| 30,642 |
<p>I had a look in the reference doc, and Spring seems to have pretty good support for sending mail. However, I need to login to a mail account, read the messages, and download any attachments. Is downloading mail attachments supported by the Spring mail API?</p>
<p>I know you can do this with the Java Mail API, but i... | <p>Here's the class that I use for downloading e-mails (with attachment handling). You'll have to glance by some of the stuff it's doing (like ignore the logging classes and database writes). I've also re-named some of the packages for ease of reading.</p>
<p>The general idea is that all attachments are saved as ind... | <pre><code>import java.io.IOException;
import java.io.InputStream;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamSource;
import org.springframework.mail.javamail.JavaMai... | 18,808 |
<p>I have this code</p>
<pre><code>#include <iostream>
using namespace std;
int main(int argc,char **argv) {
unsigned long long num1 = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999... | <p>Your result is larger than the long long type - you need to look at a <a href="http://mattmccutchen.net/bigint/" rel="noreferrer">BigInteger</a> or arbitrary precision library, something like <a href="http://gmplib.org/" rel="noreferrer">gmp</a></p>
| <p>unsigned int represents a system word. Today, that word will max out at either 2^32 -1 or 2^64 - 1, depending on whether your system is 32 bit or 64 bit. You're hitting the cap.</p>
<p>You have to write a bignum class or use one off the 'net.</p>
<p>Why are you doing this problem anyway?</p>
| 29,810 |
<p>Is there a platform-agnostic and filesystem-agnostic method to obtain the full path of the directory from where a program is running using C/C++? Not to be confused with the current working directory. (Please don't suggest libraries unless they're standard ones like clib or STL.)</p>
<p>(If there's no platform/file... | <p>Here's code to get the full path to the executing app:</p>
<p>Variable declarations:</p>
<pre><code>char pBuf[256];
size_t len = sizeof(pBuf);
</code></pre>
<p>Windows:</p>
<pre><code>int bytes = GetModuleFileName(NULL, pBuf, len);
return bytes ? bytes : -1;
</code></pre>
<p>Linux:</p>
<pre><code>int bytes = MIN(re... | <p>On POSIX platforms, you can use <a href="http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html" rel="nofollow noreferrer">getcwd()</a>.</p>
<p>On Windows, you may use <a href="http://msdn.microsoft.com/en-us/library/sf98bd4y(VS.80).aspx" rel="nofollow noreferrer">_getcwd()</a>, as use of <a href="http... | 17,294 |
<p>We have a requirement in project to store all the revisions(Change History) for the entities in the database. Currently we have 2 designed proposals for this:</p>
<p>e.g. for "Employee" Entity</p>
<p><strong>Design 1:</strong></p>
<pre><code>-- Holds Employee Entity
"Employees (EmployeeId, FirstName, LastName, De... | <p>I think the key question to ask here is 'Who / What is going to be using the history'?</p>
<p>If it's going to be mostly for reporting / human readable history, we've implemented this scheme in the past...</p>
<p>Create a table called 'AuditTrail' or something that has the following fields...</p>
<pre><code>[ID] ... | <p>It sounds like you want to track changes to specific entities over time, e.g. ID 3, "bob", "123 main street", then another ID 3, "bob" "234 elm st", and so on, in essence being able to puke out a revision history showing every address "bob" has been at.</p>
<p>The best way to do this is to have an "is current" fiel... | 6,033 |
<p>For my area, I get the updates from </p>
<ul>
<li>ww.asp.net</li>
<li>code.google.com</li>
<li>www.webmasterworld.com</li>
</ul>
<p>What others do you highly recommend?</p>
| <p>If you're into anything with Linux:
<a href="http://www.linux.com/feature" rel="nofollow noreferrer">http://www.linux.com/feature</a></p>
<p><a href="http://www.alistapart.com/" rel="nofollow noreferrer">A List Apart</a> has some excellent web articles</p>
<p>If you want keep up with browsers, <a href="http://www.... | <p><a href="http://ayende.com" rel="nofollow noreferrer">Ayende</a>'s (creator of <a href="http://ayende.com/projects/rhino-mocks.aspx" rel="nofollow noreferrer">Rhino Mocks</a>) blog is a great read.</p>
| 29,417 |
<p>In Ruby, is it possible to pass by reference a parameter with value-type semantics (e.g. a Fixnum)?
I'm looking for something similar to C#'s '<strong>ref</strong>' keyword.</p>
<p>Example:</p>
<pre><code>def func(x)
x += 1
end
a = 5
func(a) #this should be something like func(ref a)
puts a #should read '... | <p>You can accomplish this by explicitly passing in the current binding:</p>
<pre><code>def func(x, bdg)
eval "#{x} += 1", bdg
end
a = 5
func(:a, binding)
puts a # => 6
</code></pre>
| <p>However, it seems that composite objects, like hashes, are passed by reference:</p>
<pre><code>fp = {}
def changeit(par)
par[:abc] = 'cde'
end
changeit(fp)
p fp
</code></pre>
<p>gives</p>
<pre><code>{:abc=>"cde"}
</code></pre>
| 19,522 |
<p>What can be reasons to prevent a class from being inherited? (e.g. using sealed on a c# class)
Right now I can't think of any.</p>
| <p>Because writing classes to be substitutably extended is <em>damn hard</em> and requires you to make accurate predictions of how future users will want to extend what you've written.</p>
<p>Sealing your class forces them to use composition, which is much more robust.</p>
| <p>Because you always want to be handed a reference to the class and not to a derived one for various reasons:<br>
i. invariants that you have in some other part of your code<br>
ii. security<br>
etc</p>
<p>Also, because it's a safe bet with regards to backward compatibility - you'll never be able to close that class ... | 4,426 |
<p>I've seen a number of questions asking about a web SVN repository-browsing tool. However, of the ones I've taken a look at, they either require a specific username/password to be configured, rely on default access to the repository being available, or require a separate user database outside Subversion.</p>
<p>In ... | <p>SVN can actually be served up through Apache and allow LDAP authentication. I've set this up before.</p>
<p>There is a prepackaged windows snap-in like server that is kept current with SVN versions called VisualSVN, this is basically an SVN repository served through and apache wrapper with the LDAP modules built.</... | <p>SVN can actually be served up through Apache and allow LDAP authentication. I've set this up before.</p>
<p>There is a prepackaged windows snap-in like server that is kept current with SVN versions called VisualSVN, this is basically an SVN repository served through and apache wrapper with the LDAP modules built.</... | 29,868 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.