instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I can create a literal long by appending an L to the value; why can't I create a literal short or byte in some similar way? Why do I need to use an int literal with a cast?</p>
<p>And if the answer is "Because there was no short literal in C", then why are there no short literals in C?</p>
<p>This doesn't actually... | <p>In C, <code>int</code> at least was meant to have the "natural" word size of the CPU and <code>long</code> was probably meant to be the "larger natural" word size (not sure in that last part, but it would also explain why <code>int</code> and <code>long</code> have the same size on x86).</p>
<p>Now, my guess is: fo... | <p>Another reason might be that the JVM doesn't know about short and byte. All calculations and storing is done with ints, longs, floats and doubles inside the JVM.</p>
| 41,060 |
<p>This is from an example accompanying the agsXMPP .Net assembly. I've read up on delegates, but am not sure how that fits in with this line of code (which waits for the logon to occur, and then sends a message. I guess what I'm looking for is an understanding of why <code>delegate(0)</code> accomplishes this, in th... | <p>It's exactly the same as</p>
<pre><code>xmpp.OnLogin += EventHandler(MyMethod);
</code></pre>
<p>Where MyMethod is</p>
<pre><code>public void MyMethod(object o)
{
xmpp.Send(new Message(new Jid(JID_RECEIVER), MessageType.chat, "Hello, how are you?"));
}
</code></pre>
| <p>That is creating an anonymous function. This feature was introduced in C# 2.0</p>
| 9,865 |
<p>Most developers understand the concept of <a href="http://en.wikipedia.org/wiki/Wicked_problem" rel="nofollow noreferrer">wicked problems</a>. What's a good analogy to use when explaining this concept to project managers?</p>
| <p>If you want an analogy, I would go with the timeline of NASA. Still technical based, but you do not need any coding skills to understand the difficulty involved. I'm also using the <a href="http://www.codinghorror.com/blog/archives/000071.html" rel="nofollow noreferrer">Coding Horror</a> definition of a wicked pro... | <p>Try getting them to read the article with "I wanted to know your thoughts on this article..."</p>
<p>Really, your project managers should know this stuff though.</p>
| 30,461 |
<p>Thinking about getting into .net technology project management</p>
<p>I've had plenty of experience with PHP projects: I'm aware of most of the existing frameworks and libraries, and I've written specs and case studies based on this knowledge.</p>
<p>What should I know about .net?
Which top resources would you rec... | <p>Start with the basics before you get to the higher level stuff like web services (though that is important too). The most important things you need to learn, as a project manager, are the things you're going to be questioning your underlings about later. For example, my PM (also a PHP guy) has absolutely no knowledg... | <p>The biggest thing you'll probably want to learn is the differences between Windows and non-Windows programmers. They approach fundamental things differently. Knowing the difference will be key to successfully managing the project. If you listen to the stack overflow podcast, and Jeff and Joel have multiple discus... | 4,037 |
<p>I've thrown myself headfirst into C# and .Net 2.0 using Linq, and I'm having a few problems debugging some of the problems, namely the following:</p>
<p>I have a ComboBox control (<code>cmbObjects</code>) I want to populate with a set of objects retrieved using Linq. I've written a helper method to populate a <code... | <p>Okay, it seems the <code>DataSource</code> becomes invalid if you try to add a <code>null</code> value. The solution was to just add the items via a simple <code>foreach</code> loop with an empty string at the start instead of assigning the <code>List<></code>.</p>
| <p>Okay, it seems the <code>DataSource</code> becomes invalid if you try to add a <code>null</code> value. The solution was to just add the items via a simple <code>foreach</code> loop with an empty string at the start instead of assigning the <code>List<></code>.</p>
| 48,452 |
<p>Using a macro I have consolidated info from several workbooks into one sheet in new workbook.</p>
<p>In one column I have created a named range called ColRange. That column has numbers ranging from -350 to 500.</p>
<p>How do I change the color of the cells based on the value of the text in the cell.<br>
red(0-50... | <p>Have a look at <a href="http://www.wikihow.com/Apply-Conditional-Formatting-in-Excel" rel="nofollow noreferrer">conditional formatting</a>. You may not even need VBA to do this.</p>
<p>That being said, the VBA code would look something like this:</p>
<pre><code>Public Sub colorit()
Dim colRange As Range
Di... | <p>Assume that value is the number stored in the column then:</p>
<pre><code>If value >= 0 AND value <= 500 Then
ColRange.Interior.Color = RGB(255,0,0)
ElseIf value >= -5 Then
ColRange.Interior.Color = RGB(255,255,200)
Else
ColRange.Interior.Color = RGB(0,255,0)
End If
</code></pre>
<p>And assum... | 41,500 |
<p>In CSS, with:</p>
<pre><code>@page { @top-right { content: "Page " counter(page) " of " counter(pages); } }
</code></pre>
<p>I can have page numbers displayed at the top of every page when the page is printed. This works great. But now, how can I make it so the page number starts with 2 instead of 1? Can I do that... | <p>If you are using Flying Saucer (which was my case), use the following CSS:</p>
<blockquote>
<p>table { -fs-table-paginate: paginate; }</p>
</blockquote>
<p>It works like a charm. And Flying Saucer rocks :). Really highly recommended.</p>
| <p>Don't know if this works, but why don't you try <code>counter(page+1)</code>?</p>
| 33,161 |
<p>I am trying to match floating-point decimal numbers with a regular expression. There may or may not be a number before the decimal, and the decimal may or may not be present, and if it is present it may or may not have digits after it. (For this application, a leading +/- or a trailing "E123" is not allowed). I h... | <p>I think this will do what you want. It either starts with a digit, in which case the decimal point and digits after it are optional, or it starts with a decimal point, in which case at least one digit is mandatory after it. </p>
<pre><code>/^\d+(\.\d*)?|\.\d+$/
</code></pre>
| <p>Create a regular expression for each case and OR them. Then you only need test if the expression matches.</p>
<pre><code>/^(\d+(\.\d*)?)|(\d*\.\d+)$/
</code></pre>
| 21,015 |
<p>Emacs does not recognize my correct Python path. I think it is a general problem with Emacs not recognizing my environment variables. I have GNU Emacs 22.1.1 (i386-apple-darwin8.9.1, Carbon Version 1.6.0) of 2007-06-17 installed.</p>
<p>I have set <code>PYTHONPATH</code> in my <code>~/.bashrc</code>. Maybe I should... | <p><code>.bashrc</code> only gets read when a shell starts; it won't affect Carbon Emacs. Instead, use <code>setenv</code> in your <code>.emacs</code>:</p>
<pre><code>(setenv "PYTHONPATH" "PATH_STRING_HERE")
</code></pre>
<p>You can set <code>PYTHONPATH</code> for the entire Mac OS session, by adding it to <code>~/.M... | <p>In order not to manually copy paste:</p>
<pre><code>(setenv "PYTHONPATH" (shell-command-to-string "$SHELL --login -c 'echo -n $PYTHONPATH'"))
</code></pre>
| 30,103 |
<p>Ok let me make an example:</p>
<pre><code><head>
<script type="text/javascript">
$(document).ready(function(){
$("#options_2").hide();
$("#options_3").hide();
});
</script>
</head>
<body>
<div id="options_1">option 1</div>
<div id="options_2">option 2</di... | <p>First of all give your links a class or Id (I've used a class), which will make it easier to do the swap in</p>
<pre><code><div id="options_1" class="tab" >option 1</div>
<div id="options_2" class="tab">option 2</div>
<div id="options_3" class="tab">option 3</div>
$(document).re... | <p>You can help yourself if you add IDs to your links in form 'options_1_select' and a class 'opener'. Then you can assign a single event handler to all of your links:</p>
<pre><code>$('a.opener').click(function() {
// mark current link as selected and unmark all others
$(this)
.addClass('selected')
.sibli... | 28,959 |
<p>I search for "nurple" in a file. I found it, great. But now, every occurrence of "nurple" is rendered in sick black on yellow. Forever.</p>
<p>Forever, that is, until I search for something I know won't be found, such as "asdhfalsdflajdflakjdf" simply so it clears the previous search highlighting.</p>
<p>Can't I j... | <p><code>:noh</code> (short for <code>nohighlight</code>) will temporarily clear the search highlight. The next search will still be highlighted.</p>
| <p>I add the following mapping to my ~/.vimrc</p>
<pre><code>map e/ /sdfdskfxxxxy
</code></pre>
<p>And in ESC mode, I press <code>e/</code></p>
| 12,441 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects-in-c-sharp">How to properly clean up Excel interop objects in C#</a> </p>
</blockquote>
<p>I've read many of the other threads here about managing COM refer... | <p>I have done a similar thing. I create an Excel file or open an existing. I delete all the sheets and add my own. here is the code I use to ensure all references are closed:</p>
<pre><code> workbook.Close(true, null, null);
excelApp.Quit();
if (newSheet != null)
{
... | <p>Not very constructive I know but I tested the code exactly as shown above and my Excel process exits as expected, my C:\addtest.xls is sitting with 8 new sheets and no Excel process is running.<br />Could the interop version be the cause I wonder? I tested with 11 & 12.</p>
| 45,617 |
<p>I need to programatically find the users name using C#. Specifically, I want to get the system/network user attached to the current process. I'm writing a web application that uses windows integrated security.</p>
| <p>The abstracted view of identity is often the <code>IPrincipal</code>/<code>IIdentity</code>:</p>
<pre><code>IPrincipal principal = Thread.CurrentPrincipal;
IIdentity identity = principal == null ? null : principal.Identity;
string name = identity == null ? "" : identity.Name;
</code></pre>
<p>This allows the same ... | <pre><code>string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name ;
</code></pre>
| 45,754 |
<p>I run an ASP.NET website solution with a few other projects in it. I've known that MSBuild projects are capable of this, but is it the best way? Are they easy to create? Is nAnt, CruiseControl.NET or any other solution better?</p>
<p>When I build the site (using <a href="http://msdn.microsoft.com/en-us/asp.net/aa33... | <p>Here's an example of a Web Deployment Project scripting this sort of task in the .wdproj file:</p>
<pre><code> <Target Name="AfterBuild">
<!-- ============================ Script Compression============================ -->
<MakeDir Directories="$(OutputPath)\compressed" />
<Exec Co... | <p>CruiseControl.NET solves a different problem (continuous integration) ... however, I've had great success with NAnt for specifically what you're asking. There's a learning curve, but once you get proficient you'll wonder how you ever got along w/o it.</p>
| 3,659 |
<p>I have an iPhone app that compiles and runs fine in the Simulator on my laptop. Now, I try to build and run the same code in the Simulator on an iMac, and it starts up and lets me click a button, but then I get an assertion failure.</p>
<p>Here is what is in the console:</p>
<pre><code>*** Assertion failure in -[... | <p>If you've got UILabels in your xib file, they may be somehow corrupt, or you may have set a font to them that doesn't exist on both your machines (you can use command-T when editing a UILabel to bring up the font picker; not sure it's possible to set a non-iPhone font, but it may be). Otherwise, try removing UILabel... | <p>Not all are available in the iphone, only certain fonts.</p>
| 24,908 |
<p>I want to stress test a web service method by calling it several thousand times in quick succession. The method has a single string parameter that I will vary on each call.</p>
<p>I'm planning on writing a Powershell script to loop and call this method a number of times.</p>
<p>Is there a better way to do this?</p... | <p>If you run call after call - it's not going to help you too much, as it will not show you how the service behaves under a heavy load of many simultaneous connections.</p>
<p>Go with some multi-threaded solution (I do not know if powershell has this).</p>
<p>Some opensource testing tools are listed <a href="http://... | <p>Personally, I'd use something like <a href="http://www.opensta.org/"openSTA"" rel="nofollow noreferrer">openSTA</a>.</p>
<p>This allows a session with a web site to be recorded and then played back via a relatively simple script language.</p>
<p>You can also easily test web services and write your own sc... | 38,044 |
<p>I'm downloading an entire directory from a web server. It works OK, but I can't figure how to get the file size before download to compare if it was updated on the server or not. Can this be done as if I was downloading the file from a FTP server?</p>
<pre><code>import urllib
import re
url = "http://www.someurl.co... | <p>I have reproduced what you are seeing:</p>
<pre><code>import urllib, os
link = "http://python.org"
print "opening url:", link
site = urllib.urlopen(link)
meta = site.info()
print "Content-Length:", meta.getheaders("Content-Length")[0]
f = open("out.txt", "r")
print "File on disk:",len(f.read())
f.close()
f = ope... | <p>@PabloG Regarding the local/server filesize difference</p>
<p>Following is high-level illustrative explanation of why it may occur:</p>
<p>The size on disk sometimes is different from the actual size of the data.
It depends on the underlying file-system and how it operates on data.
As you may have seen in Windows wh... | 2,778 |
<p>I got a problem like this (this is html/css menu):</p>
<p>Eshop | Another eshop | Another eshop</p>
<p>Client wants it work like this:</p>
<p>User comes to website, clicks on Eshop. Eshop changes to red color with red box outline. User decides to visit Another eshop, so Eshop will go back to normaln color without... | <p>The same that Joe Skora has written but more specific:</p>
<pre><code>.red {
outline-color:red;
outline-width:10px;
}
</code></pre>
<p>Now you could use Javascript (in this example using <a href="http://jquery.com" rel="nofollow noreferrer">jQuery</a>) in the click-event-handler:</p>
<pre><code>$('.red').... | <p>As far as I know you can do this only by generating different code for every page (setting a different class for the current page) or by using JavaScript to change the menu after the page is loaded.</p>
| 23,760 |
<p>It would be a shame if it doesn't, because it will make for more attractive looking Android applications.</p>
| <p>Not right now, and it would be a nontrivial task to make it work. Android doesn't have all the libraries that the typical desktop JRE does. Although since Android is open source and it will run anything that can be compiled to Dalvik byte code, it's not impossible.</p>
<p>Really, I don't really think JavaFX will ma... | <p>Perhaps it's not so important the attractiveness. I think portability matters a lot nowadays, and this kind of tech makes it very portable.</p>
| 29,769 |
<p>I have a simple type that explicitly implemets an Interface.</p>
<pre><code>public interface IMessageHeader
{
string FromAddress { get; set; }
string ToAddress { get; set; }
}
[Serializable]
public class MessageHeader:IMessageHeader
{
private string from;
private string to;
[XmlAttribute("From")]
... | <p>You cannot serialize IMessageHeader because you can't do Activator.CreateInstance(typeof(IMessageHeader)) which is what serialization is going to do under the covers. You need a concrete type.</p>
<p>You can do typeof(MessageHeader) or you could say, have an instance of MessageHeader and do </p>
<pre><code>XmlSeri... | <p>You can create an abstract base class the implements IMessageHeader and also inherits MarshalByRefObject</p>
| 8,476 |
<p>I'd like to be able to call a function exposed by a VSTO addin from a cell in an excel worksheet. More specifically, if I have a VSTO function Foo() that returns "bar" I'd like to be able to write =Foo() in A1 which evaluates to "bar" on calculation.</p>
<p>Is this possible? What are the key steps I'd need to take?... | <p>I don't believe you can do so directly, though you can use a VBA wrapper, see for example <a href="http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx" rel="nofollow noreferrer"><a href="http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/pstubbs/arc... | <p>I think you can make use of COM Interop.. here is a webpage where I've seen the process described.</p>
<p><a href="http://www.cpearson.com/excel/creatingnetfunctionlib.aspx" rel="nofollow noreferrer">http://www.cpearson.com/excel/creatingnetfunctionlib.aspx</a></p>
| 45,702 |
<p>What's the best way to handle a visitor constructing their own URL and replacing what we expect to be an ID with anything they like?</p>
<p>For example:</p>
<p><a href="https://stackoverflow.com/questions/236349">ASP.Net MVC - handling bad URL parameters</a></p>
<p>But the user could just as easily replace the UR... | <p>Here's an example of a route like yours, with a constraint on the number:</p>
<pre><code>routes.MapRoute(
"Question",
"questions/{questionID}",
new { controller = "StackOverflow", action = "Question" },
new { questionID = @"\d+" } //Regex constraint specifying that it must be a number.
);
</code></p... | <p>The problem with that approach is that they still might pass an integer which doesn't map to a page. Just return a 404 if they do that, just as you would with "foo". It's not something to worry about unless you have clear security implications.</p>
| 29,248 |
<p>I am looking for a text editor that will be able to load a 4+ Gigabyte file into it. Textpad doesn't work. I own a copy of it and have been to its support site, it just doesn't do it. Maybe I need new hardware, but that's a different question. The editor needs to be free OR, if its going to cost me, then no mor... | <p>glogg could also be considered, for a different usage:</p>
<p><img src="https://i.stack.imgur.com/2GUaT.png" alt="glogg screenshot"></p>
<p>Caveat (reported by <a href="https://stackoverflow.com/users/216440/simon-tewsi">Simon Tewsi</a> in <a href="https://stackoverflow.com/questions/102829/best-free-text-editor-s... | <p><a href="http://www.gnu.org/software/emacs/" rel="nofollow noreferrer">Emacs</a> can handle <a href="http://www.freelists.org/archives/glug_t/03-2005/msg00032.html" rel="nofollow noreferrer">huge file sizes</a> and you can use it on Windows or *nix.</p>
| 12,841 |
<p>I'm working on a windows client written in WPF with C# on .Net 3.5 Sp1, where a requirement is that data from emails received by clients can be stored in the database. Right now the easiest way to handle this is to copy and paste the text, subject, contact information and time received manually using an arthritis-in... | <p>I found a great <a href="http://www.codeproject.com/KB/office/outlook_drag_drop_in_cs.aspx" rel="noreferrer">article</a> that should do exactly what you need to. </p>
<p><strong>UPDATE</strong></p>
<p>I was able to get the code in that article working in WPF with a little tweaking, below are the changes you need t... | <p>I think <a href="http://blogs.msdn.com/adamroot/pages/shell-style-drag-and-drop-in-net-wpf-and-winforms.aspx" rel="nofollow noreferrer">Shell Style Drag and Drop in .NET (WPF and WinForms)</a> can help you. Once you can respond to drag drop using the COM Interfaces, you should be able to get the data out of outlook.... | 40,925 |
<p>I haven't used regular expressions at all, so I'm having difficulty troubleshooting. I want the regex to match only when the contained string is all numbers; but with the two examples below it is matching a string that contains all numbers plus an equals sign like "1234=4321". I'm sure there's a way to change this b... | <p>Use the beginning and end anchors.</p>
<pre><code>Regex regex = new Regex(@"^\d$");
</code></pre>
<p>Use <code>"^\d+$"</code> if you need to match more than one digit.</p>
<hr>
<p>Note that <code>"\d"</code> will match <code>[0-9]</code> and other digit characters like the Eastern Arabic numerals <code>٠١٢٣٤٥٦٧٨... | <p>Regex regex = new Regex ("^[0-9]{1,4}=[0-9]{1,4]$")</p>
| 34,398 |
<p>I am trying to design a location lookup in which the user can specify a location to any desired level of accuracy. eg. one of Country, State, City, Borough etc,</p>
<p>I have a used a common location table, which will then be used in a lookup with the table name selected dynamically, but was wondering if there is a... | <p>You might consider something like:</p>
<pre><code>locations
id int
parentId int
name varchar(45)
</code></pre>
<p>From this perspective you could load any type of location with any level depth. </p>
| <p>I see some problems with this design as (as I do not know your requirements fully):
1. You wouldn't be able to use simple joins.
2. Queries cannot be optimized as there cannot be indexes</p>
<p>Alternate#
Have you considered having a locationid in location table and having a link (one-to-many) to State & City t... | 37,198 |
<p>Am looking for checkpointing library for C#. Any ideas ?</p>
<p>see <a href="http://en.wikipedia.org/wiki/Application_checkpointing" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Application_checkpointing</a></p>
| <p>This should be possible to implement using transactions (commit/rollback) or undo. If you design your classes and operations correctly it will work, it will require some hard work and discipline using the classes of course. You'll also need to be careful about exceptions.</p>
<p>The <a href="http://msdn.microsoft.c... | <p>Given the link from wikipedia, I can tell you .NET/CLR does not support this. What makes this impossible is due to the fact that .NET does not allow you to inspect of modify the application stack which in turn is not possible due to builtin security in .NET.</p>
| 42,645 |
<p>How would I change the initial templates created by Xcode when creating a new Cocoa Class.</p>
<p>I am referring to the comments and class name created when using Xcode's new class wizard.</p>
| <p>You wouldn't change the existing templates. In other words, don't <em>modify</em> anything under the <code>/Developer</code> hierarchy (or wherever you installed your developer tools).</p>
<p>Instead, clone the templates you want to have customized variants of. Then change their names and the information in them.... | <p>In XCode 4.5 right click on project, click Show File Inspector, then change Organization name in the file inspector's second tab (Project Document group)</p>
| 5,378 |
<p>When working on some code, I add extra debug logging of some kind to make it easier for me to trace the state and values that I care about for this particular fix.</p>
<p>But if I would check this in into the source code repository, my colleagues would get angry on me for polluting the Log output and polluting the ... | <p>If the only objetive of the debugging code you are having problems with is to trace the values of some varibles I think that what you really need is a <strong>debugger</strong>. With a debugger you can watch the state of any variable in any moment.</p>
<p>If you cannot use a debugger, then you can add some code to ... | <p>IMHO, you should avoid the #if solution. That is the C/C++ way of doing conditional debugging routines. Instead attribute all of logging/debugging functions with the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.conditionalattribute.aspx" rel="nofollow noreferrer">ConditionalAttribute</a>. T... | 25,659 |
<p>What is the best way to import a website into a Visual Sourcesafe 2005 database?</p>
<p>I tried opening a the VSS database and drag-n-drop the folder but it started prompting me for a comment on each folder. Is there a better way or someway to have it only ask onces for any files or folders that are being processed... | <p>I'm assuming your using ASP.NET for your website, if not Im sorry but you dont specify in your question. There is an <a href="http://msdn.microsoft.com/en-us/library/ms972977.aspx#vssstarttofinish_topic4" rel="nofollow noreferrer">MSDN article here</a> describing how to work with ASP.NET websites in VSS, hope this h... | <p>If you have Visual Studio (03/05/08) with the VSS source control plug-in installed, it's pretty easy to right-click on an existing solution or project and choose "Add X to SourceSafe".</p>
| 14,446 |
<p>I wrote an O(n!) sort for my amusement that can't be trivially optimized to run faster without replacing it entirely. [And no, I didn't just randomize the items until they were sorted]. </p>
<p>How might I write an even worse Big-O sort, without just adding extraneous junk that could be pulled out to reduce the t... | <p>There's a (proven!) worst sorting algorithm called <a href="http://c2.com/cgi/wiki?SlowSort" rel="noreferrer">slow sort</a> that uses the “multiply and surrender” paradigm and runs in exponential time.</p>
<p>While your algorithm is slower, it doesn't progress steadily but instead performs random jumps. Additionall... | <p>One way that I can think of would be to calculated the post position of each element through a function that vary gradually moved the large elements to the end and the small ones to the beginning. If you used a trig based function, you could make the elements osculate through the list instead of going directly towar... | 4,520 |
<p>I'm not very experienced with builds - this may be really easy! I have a simple application with a simple deployment project. I went to the directory where the release-compiled versions of the DLLs are, signed all of them (verisign), and then went to the deployment project, chose Build (not REbuild), and it recomp... | <p>I haven't tried, but... Don't make the deployment project depend on the application project. Instead, manually add the output of the application to the deployment. As a consequence, no automatic build should be triggered.</p>
| <p>I haven't tried, but... Don't make the deployment project depend on the application project. Instead, manually add the output of the application to the deployment. As a consequence, no automatic build should be triggered.</p>
| 38,505 |
<p>I have a small JS function that does Ajax for me and another like it that adds in POST data to the request. With Ajax being such a big topic with so many libraries about it, what am I missing from my function, is it insecure or something else worrying?</p>
<pre><code>function loadPage(pagePath, displayElement)
{
... | <p>I strongly recommend you not roll your own Ajax code. Instead, use a framework such as Prototype, Dojo, or any of the others. They've taken care of handling all the ReadyStates you're not handling (2 means it's been sent, 3 means it's in process, etc.), and they should escape the reponse you're getting so you don't ... | <p>If you really want to see what you are missing, read the jQuery or Prototype source code for their ajax routines. If there are bug numbers in the comments, look those up as well.</p>
| 5,471 |
<p>I need to <code>ShellExecute</code> something as another user, currently I start a helper process with <code>CreateProcessAsUser</code> that calls <code>ShellExecute</code>, but that seems like too much of a hack (Wrong parent process etc.) Is there a better way to do this?</p>
<p>@PabloG: ImpersonateLoggedOnUser d... | <p>The solution really depends on what your needs are, and can be pretty complex (Thanks fully to Windows Vista). This is probably going to be beyond your need, but this will help others that find this page via search.</p>
<ol>
<li>If you do not need the process to run with a GUI and you do not require elevation</li>... | <p>You can wrap the ShellExecute between ImpersonateLoggedOnUser / RevertToSelf</p>
<p>links:
ImpersonateLoggedOnUser: <a href="http://msdn.microsoft.com/en-us/library/aa378612(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa378612(VS.85).aspx</a>
RevertToSelf: <a href="http://msdn.mi... | 5,368 |
<p>I'm building small web shop with asp.net mvc and Structuremap ioc/di. My Basket class uses session object for persistence, and I want use SM to create my basket object through IBasket interface. My basket implementation need HttpSessionStateBase (session state wrapper from mvc) in constructor, which is available ins... | <p>If you absolutely have to have your StoreBasketService use the session, I'd be tempted to define an interface and wrapper around HttpSessionState instead of using HttpSessionStateBase so that you can register it with StructureMap as well.The wrapper would get the session state from the current context. Register the... | <p>I just started with StructureMap, and I do not get the results you are describing.
I performed a simple test using a simple class, configuring Structuremap to cacheby HttpContext, and from what I can see, CacheBy.HttpContext means within the same request you will get the same instance... not within the same Session<... | 32,054 |
<p>I have a an HTML form which contains the YAHOO rich text editor on it.</p>
<p>When I display the form I want the YAHOO editor to have focus so that the cursor is ready to accept input without the user having to click on it or tab into it</p>
| <p>I got this from the documenation over at the <a href="http://developer.yahoo.com/yui" rel="nofollow noreferrer">YUI library</a>. Specifically at a sample titled <a href="http://developer.yahoo.com/yui/examples/editor/editor_adv_editor.html" rel="nofollow noreferrer">Editor - Basic Buttons</a></p>
<blockquote>
<p... | <p>I haven't employed the YAHOO rich text editor, but wouldn't it work, if you use a window.onload event ?-)</p>
| 19,925 |
<p>I'm wondering how (un)common it is to encapsulate an algorithm into a class? More concretely, instead of having a number of separate functions that forward common parameters between each other:</p>
<pre><code>void f(int common1, int param1, int *out1);
void g(int common1, int common2, int param1, int *out2)
{
f(c... | <p>It's not a bad strategy at all. In fact, if you have the ability in your language (which you do in C++) to define some type of abstract superclass which defines an opaque interface to the underlying functionality, you can swap different algorithms in and out at runtime (think sorting algorithms, for example). If you... | <p>If you would ever need to call both methods with the constructor parameters then i would do it.</p>
<p>If you would never need to call both methods with the same parameters then I wouldn't.</p>
| 18,601 |
<p>The company I work for sells a J2EE application that runs on Tomcat, WebSphere, or WebLogic. We have a customer that is trying to decide between Tomcat and WebSphere. They're leaning towards WebSphere because they're concerned that Tomcat has more security holes.</p>
<p>After searching around on the web, I've bee... | <p>I'd say use tomcat over WebSphere if at all possible.</p>
<p>I think 99% of security is how you set it all up.</p>
<p>Are you also evaluating the security implications of Apache HTTP Server, IBM HTTP Server, and IIS?</p>
<p>Security involves so much more than just what application server you choose to run your we... | <p>I can't say whether one is better than the other as I have never used Tomcat, and you really haven't defined what your security requirements are. Security can be a rather large beast and involve varying levels. So you will need well defined requirements to even determine what Security features are required.</p>
<... | 47,335 |
<p>There are many different styles of variable names that I've come across over the years.</p>
<p>The current wikipedia entry on naming conventions is fairly light... </p>
<p>I'd love to see a concise catalog of variable naming-conventions, identifying it by a name/description, and some examples. </p>
<p>If a conv... | <p>The best naming convention set that I've seen is in the book "<a href="https://rads.stackoverflow.com/amzn/click/com/0735619670" rel="nofollow noreferrer" rel="nofollow noreferrer">Code Complete</a>" Steve McConnell has a great section in there about naming conventions and lots of examples. His examples run through ... | <p>There is, the <a href="http://phrasebook.nr.no" rel="nofollow noreferrer">"Java Programmers Phrasebook"</a> by Einar Hoest. </p>
<p>He analysed the grammatical structure of method names together with the structure of the method bodies, and collected information such as: </p>
<blockquote>
<p><strong>add-[noun]-*<... | 29,168 |
<p>I was wondering if there is an open source library or algorithm that can expand a non-numeric range. For example, if you have <code>1A</code> to <code>9A</code> you should get </p>
<pre><code>1A, 2A, 3A, 4A, 5A, 6A, 7A, 8A, 9A.
</code></pre>
<p>I've tried Googling for this and the best I could come up with were R... | <p>As noted by others, it would be useful to be more specific. I don't think you can expect there to be a library that will generate ranges according to any arbitrary order on string you can come up with.</p>
<p>If you can simply define what the successor of any given string is, then the solutions is quite easy. That ... | <p>I was trying to leave it somewhat open because the number of possibilities is staggering. I believe this one of those questions that could not be answered 100% here without going through a lot of technical detail about is considered a "good" or "bad" range. I'm just trying to find a jumping point for ideas on how ... | 6,762 |
<p>I have a simple database table called "Entries":</p>
<pre><code>class CreateEntries < ActiveRecord::Migration
def self.up
create_table :entries do |t|
t.string :firstName
t.string :lastName
#etc.
t.timestamps
end
end
def self.down
drop_table :entries
end
end
</code></... | <p>There is a plugin called FasterCSV that handles this wonderfully.</p>
| <p>Take a look at the CSV Shaper gem.</p>
<p><a href="http://github.com/paulspringett/csv_shaper" rel="nofollow">https://github.com/paulspringett/csv_shaper</a></p>
<p>It has a nice DSL and works really well with Rails models. It also handles the response headers and allows filename customisation.</p>
| 12,011 |
<p>When setting the size of fonts in CSS, should I be using a percent value (<code>%</code>) or <code>em</code>? Can you explain the advantage?</p>
| <p>There's a really good article on web typography on <a href="http://alistapart.com/articles/howtosizetextincss" rel="noreferrer">A List Apart</a>.</p>
<p>Their conclusion:</p>
<blockquote>
<p>Sizing text and line-height in ems,
with a percentage specified on the
body (and an optional caveat for
Safari 2), w... | <p><a href="http://developer.yahoo.com/yui/" rel="nofollow noreferrer">Yahoo User Interface library (<a href="http://developer.yahoo.com/yui/" rel="nofollow noreferrer">http://developer.yahoo.com/yui/</a>)</a> has a nice set of base css classes used to "reset" the browser specific settings so that the basis for display... | 16,084 |
<p>I'm building a custom web part for SharePoint and I'm trying to use the default styles so when people theme the site, it will theme with it.</p>
<p>I've found a couple of decent sites that show the different styles like:
<a href="http://www.sharepointcustomization.com/resources/tipstricks/wss_cssguide.htm" rel="nof... | <p><a href="http://www.heathersolomon.com/content/sp07cssreference.htm" rel="nofollow noreferrer">Heather Solomon's blog is the multimate reference</a> for Sharepoint 2007 CSS (the link you posted is for SharePoint 2003). You can also use <a href="http://addons.mozilla.org/en-US/firefox/addon/60" rel="nofollow noreferr... | <p>If you are doing a custom webpart, consider SPGridView for your tables, I believe it will use the standard sharepoint List table styles: <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spgridview.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/microsoft.share... | 40,792 |
<p>I'm currently running Vista and I would like to manually complete the same operations as my Windows Service. Since the Windows Service is running under the Local System Account, I would like to emulate this same behavior. Basically, I would like to run CMD.EXE under the Local System Account.</p>
<p>I found informat... | <p>Though I haven't personally tested, I have good reason to believe that the above stated AT COMMAND solution will work for XP, 2000 and Server 2003. Per my and Bryant's testing, we've identified that the same approach does not work with Vista or Windows Server 2008 -- most probably due to added security and the /inte... | <p>i used Paul Harris recommendation and created a batch file .cmd or .bat with what ever command i needed to run under system and used the schedule task run one time.
than trigger it as needed. and updated the batch as needed. so any command i need to run under system i just update the batch.</p>
| 10,301 |
<p>In a C program (p1), how to launch a dynamically constructed command (and its arguments) that reads its standard input from p1's standard output?</p>
<p>Note that: </p>
<ol>
<li><p>A method other than this stdout -->
stdin piping is also OK <strong>provided</strong>
it is <strong>PORTABLE</strong> across Windows a... | <p>It's not 100% clear to me what you're trying to achieve exactly to be honest.</p>
<p>But as I understand it, you could take a look at <a href="http://www.netbsd.org/~jmmv/process/" rel="nofollow noreferrer">Boost.Process</a></p>
<p>You can do things like</p>
<pre><code> bp::child cs = p.start();
bp::postream&... | <p>The linked anser (which you reject) refers to POSIX pipes. POSIX is an extension to C, which adds features missing from standard C. POSIX pipes are a good example of such a feature: they were added to POSIX because standard C does not have that functionality.</p>
| 28,427 |
<p>What is the difference between <code>UNION</code> and <code>UNION ALL</code>?</p>
| <p><code>UNION</code> removes duplicate records (where all columns in the results are the same), <code>UNION ALL</code> does not.</p>
<p>There is a performance hit when using <code>UNION</code> instead of <code>UNION ALL</code>, since the database server must do additional work to remove the duplicate rows, but usually... | <p><code>UNION ALL</code> also works on more data types as well. For example when trying to union spatial data types. For example: </p>
<pre><code>select a.SHAPE from tableA a
union
select b.SHAPE from tableB b
</code></pre>
<p>will throw</p>
<p><code>The data type geometry cannot be used as an operand to the UNION,... | 7,253 |
<p>I am trying to generate an Entity Relationship Diagram from an existing MS SQLServer 2005 database. What tools are available? Specifically,I am not only interested in ERD's more directly I am looking for a tool to help quickly learning and analysing a medium size (schema wise not really row wise) database structure.... | <p>I can see that this post is quite old and <strong>MS SQL Server Management Studio</strong> might have not had this feature back then! Though as far as I know with <strong>SQL Server 2012</strong> you can generate the ER diagrams by taking a few simple steps listed below:</p>
<ol>
<li>MS SQL Server management Studio... | <p>You can also generate an ERD from Microsoft Visual Studio 2005.</p>
| 36,747 |
<p>Note, I realize that this has been addressed <a href="https://stackoverflow.com/questions/944/unhandled-exception-handler-in-net-11">here</a>. That post discusses exception handling in .NET 1.1 while implying that there is a better solution for >.NET 2.0 so this question is specifically about the more recent .NET v... | <p>caveat: not familiar with 3.5 yet, there may be a better answer ...</p>
<p>...but my understanding is that by the time the event gets to the unhandled exception handler, the app is probably going to die - and if it doesn't die, it may be so corrupted that it should die anyway</p>
<p>if you are already handling a d... | <p>A pretty in-depth explanation of unhandled exceptions in the latest MSDN issue:
<a href="http://msdn.microsoft.com/en-us/magazine/cc793966.aspx" rel="nofollow noreferrer">September 2008</a></p>
| 18,690 |
<p>I got myself reading a article regarding changing the existing bad code into a good one.
For reference, this is the link to the article <a href="http://www.javaworld.com/jw-03-2001/jw-0323-badcode.html?page=1" rel="nofollow noreferrer">http://www.javaworld.com/jw-03-2001/jw-0323-badcode.html?page=1</a></p>
<p>It br... | <p>Before doing any refactoring, ensure you have a suite of regression tests that you can run on the code. It's no good refactoring your code base if you then introduce thousands of regression bugs due to missing a slight nuance to what the original 'bad' code was actually doing (and missing it out in the refactoring).... | <p>Ask yourself why you are refactoring the code. Does the code need to be touched? It is easy to break fragile code by improving it. </p>
<p>If you decide that the code needs to be changed, having a suite of tests, as others have mentioned, will help a lot.</p>
<p>Look at the revision history for the file(s) you are... | 23,160 |
<p>I am creating a plugin for Eclipse 3.4. I created a plug-in development project using the application with a view. Now I am trying to create a <code>TextViewer</code> the documentation says that it is located in <code>org.eclipse.jface.text.TextViewer</code>. But, this whole package is missing and eclipse cannot ... | <pre><code>Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jface.text
</code></pre>
<p>Add <em>org.eclipse.jface.text</em> as a dependency in your plugin manifest. You can use 3rd party tools (like IBM's <a href="https://www.alphaworks.ibm.com/tech/jarclassfinder/requirements" rel="noreferrer">... | <p>in 3.4 i have it inside</p>
<p>eclipse-jee-ganymede-win32\plugins\org.eclipse.jface.text_3.4.0.v20080603-2000.jar</p>
| 31,519 |
<p>How do I map numbers, linearly, between a and b to go between c and d.</p>
<p>That is, I want numbers between 2 and 6 to map to numbers between 10 and 20... but I need the generalized case.</p>
<p>My brain is fried.</p>
| <p>If your number X falls between A and B, and you would like Y to fall between C and D, you can apply the following linear transform:</p>
<pre><code>Y = (X-A)/(B-A) * (D-C) + C
</code></pre>
<p>That should give you what you want, although your question is a little ambiguous, since you could also map the interval in ... | <pre><code>int srcMin = 2, srcMax = 6;
int tgtMin = 10, tgtMax = 20;
int nb = srcMax - srcMin;
int range = tgtMax - tgtMin;
float rate = (float) range / (float) nb;
println(srcMin + " > " + tgtMin);
float stepF = tgtMin;
for (int i = 1; i < nb; i++)
{
stepF += rate;
println((srcMin + i) + " > " + (int) (... | 44,912 |
<p>I'm developing an application in C++ that's partially driven by touch-screen on Windows XP Embedded. Some text entry will be necessary for the user. So far we've been using the standard Windows On-Screen Keyboard (osk.exe), but there are two main problems:</p>
<ol>
<li>It's rather small on a higher resolution scr... | <p>We are using <a href="http://www.lakefolks.org/cnt/" rel="nofollow noreferrer">Click-N-Type</a> for our systems. It is completely resizable. It has some customization possibilities, but I never tried them. We use it on "normal" Windows XP, but it should work on Windows XP embedded also.</p>
| <p>Why not write your own keyboard UI? This would (should) be relatively trivial and give you complete control over its look and feel.</p>
| 42,793 |
<p>I'm looking for some help and it goes like this:
I'm a fairly green software developer, and focus mainly on the web (python/PHP) but am pretty well experienced with Java applications and as an electrical engineering student, looking forward to dive into some c/c++. I've pretty much grown up on Windows machine, but h... | <p>In my personal experience with Ubuntu, the two places that I consistently found help were <a href="http://ubuntuforums.org/" rel="nofollow noreferrer">Ubuntu Forums</a> and <a href="https://wiki.ubuntu.com/" rel="nofollow noreferrer">Ubuntu Wiki</a>. These two sites demonstrate just how helpful, organized, and motiv... | <p>The other advice here is excellent. As somebody who made the same leap at the end of 2005, I just wanted to add my own two penneth. </p>
<ol>
<li><p>Expect a steep learning curve. I'd been using Unix / Linux type servers for best part of 13 years when I switched. Not the same. When I switched is when I started lear... | 23,621 |
<p>This is something that has bugged me for some time. I learnt Haskell before I learnt Python, so I've always been fond of thinking of many computations as a mapping onto a list. This is beautifully expressed by a list comprehension (I'm giving the pythonic version here):</p>
<pre><code>result = [ f(x) for x in list ... | <p>You can easily do function composition in Python. </p>
<p>Here's a demonstrates of a way to create a new function which is a composition of existing functions.</p>
<pre><code>>>> def comp( a, b ):
def compose( args ):
return a( b( args ) )
return compose
>>> def times2(x): retur... | <p>There are cases where it's best to go back to the for-loop, yes, but more often I prefer one of these approaches:</p>
<p>Use appropriate line breaks and indentation to keep it readable:</p>
<pre><code>result = [blah(blah(blah(x)))
for x in list]
</code></pre>
<p>Or extract (enough of) the logic into ano... | 45,847 |
<p>I have apache web server installed as frontend and I have j2ee SAP Netweaver Application Server installed in Intranet server. How can I configure apache to forward requests and response to/from j2ee app server.
for example, external apache server's ip is 9.20.1.1:80.
internal sap server's address is 192.168.0.1/sap... | <p>You mentioned load balancing- so presumably you want to be able to add more Application Servers that are served through a single address. I hope they are stateless or storing session information in a database. You can use Apache to serve as a reverse proxy load balancer with <code>mod_proxy_balancer</code>. Docs ar... | <p>Assuming you have mod_proxy enabled, add to you're sites-available:</p>
<pre><code> ProxyRequests Off
<Location "/sapserver">
ProxyPass http://192.168.0.1
ProxyPassReverse http://192.168.0.1
</Location>
</code></pre>
<p>Be careful though as this does expose your internal site to... | 24,194 |
<p>I am working on a course leaflet system for the college I work at, leaflets are stored in a database with primary key course_code. I would like the leaflets ideally to get indexed by google how would I achieve this assuming i develop the system in asp.net 2.0. </p>
<p>I understand part of getting it indexed is to p... | <p>Look into <a href="http://www.google.com/webmasters/tools/" rel="nofollow noreferrer">Google's Webmaster tools</a></p>
| <p>If the Google bot is able to crawl your page and get everywhere on your site just by following links, without filling in any forms or running any JavaScript, you should be good to go.</p>
<p>(Disclaimer: Although I work for Google, I haven't looked at what the crawler does, and know little beyond public knowledge.)... | 44,431 |
<p>I want to dynamically hide/show some of the columns in a NSTableView, based on the data that is going to be displayed - basically, if a column is empty I'd like the column to be hidden. I'm currently populating the table with a controller class as the delegate for the table.</p>
<p>Any ideas? I see that I can set t... | <p>In Mac OS X v10.5 and later, there is the <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSTableColumn_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTableColumn/setHidden:" rel="noreferrer"><code>setHidden:</code> selector</a> for NSTableColumn.</p>
<... | <p>There is no one time all the data is populated. NSTableView does not store data, it dynamically asks for it from its data source (or bound-to objects if you're using bindings). It just draws using data it gets from the data source and ditches it. You shouldn't see the table ask for data for anything that isn't vi... | 9,434 |
<p>In a recent question on stubbing, many answers suggested C# interfaces or delegates for implementing stubs, but <a href="https://stackoverflow.com/questions/43711/whats-a-good-way-to-overwrite-datetimenow-during-testing#43718">one answer</a> suggested using conditional compilation, retaining static binding in the pr... | <p>Try to keep production code separate from test code. Maintain different folder hierarchies.. different solutions/projects. </p>
<p><strong>Unless</strong>.. you're in the world of legacy C++ Code. Here anything goes.. if conditional blocks help you get some of the code testable and you see a benefit.. By all means ... | <p>It might be useful as a tool to lean on as you refactor to testability in a large code base. I can see how you might use such techniques to enable smaller changes and avoid a "big bang" refactoring. However I would worry about leaning too hard on such a technique and would try to ensure that such tricks didn't liv... | 12,258 |
<p>I'm a pretty new C# and .NET developer. I recently created an MMC snapin using C# and was gratified by how easy it was to do, especially after hearing a lot of horror stories by some other developers in my organisation about how hard it is to do in C++.</p>
<p>I pretty much went through the whole project at some poi... | <p>I believe in blackboxes where possible. As a programmer, I want a well defined blackbox which I can easily drop into my systems, and have it work. I give it values, call the appropriate methods, and then get my results back out of it. </p>
<p>To that end, give me only the functionality that the class needs to expos... | <p>Do not choose a "default". Pick what best fits the visibility needs for that particular class. When you choose a new class in Visual Studio, the template is created as:</p>
<pre><code>class Class1
{
}
</code></pre>
<p>Which is private (since no scope is specified). It is up to you to specify scope for the ... | 13,251 |
<p>I have two webapplication, one is a simple authenticationsite which can authenticate the logged in user and <strong>redirects</strong> him then to another site.</p>
<p>Therefore I have to pass ther userId (GUID) to the second application. Currently this is done via the URL but i would like to hide this id.</p>
<p>... | <p>This sounds like a tricky situation.
There are however several options you can use but it all depends on what your application does.</p>
<p>Let's call WebApp1 your authenticate site, and WebApp2 your distination site once authenticated.</p>
<p>Can WebApp2 not call WebApp1 behind the scenes? (Services)</p>
<p>THe ... | <p>Use session variables or HTTP POST instead of HTTP GET. </p>
| 12,569 |
<p>I'm taking the leap: my PHP scripts will ALL fail gracefully!</p>
<p>At least, that's what I'm hoping for...`</p>
<p>I don't want to wrap (practically) every single line in <code>try...catch</code> statements, so I think my best bet is to make a custom error handler for the beginning of my files.</p>
<p>I'm testi... | <p><code>set_error_handler</code> is designed to handle errors with codes of: <code>E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE</code>. This is because <code>set_error_handler</code> is meant to be a method of reporting errors thrown by the <em>user</em> error function <code>trigger_error</code>.</p>
<p>However, I d... | <p>Very interesting thing that I've discovered today as I was facing the similar problem. If you use the following - it will catch the error with your custom error handler function / method:</p>
<pre><code>ini_set('display_errors', 'Off');
error_reporting(-1);
set_error_handler(array("Cmd\Exception\Handler", "getErro... | 5,723 |
<p>I just added printing capability to a web site using a style sheet (ie. @media print, etc.) and was wondering if I could use a similar method for adding support for mobile devices.</p>
<p>If not, how do I detect a mobile device? My pages are C# (.aspx) and I'd like to scale back the pages for ease of use on a mobi... | <p>I'm not sure how the IPhone/iPod Touch declare themselves when requesting the stylesheet, but for most, using </p>
<pre><code><style type="text/css">
@media handheld
{
/* handheld styles */
}
</style>
</code></pre>
<p>should do the trick. It works in the same way @media print does (or... | <p>The best way of doing all of this is to do it at a server level.</p>
<p>Use a web service to check whether the visitor is a mobile and deliver your output based on this. Use the same URL and perform the same business logic on your application - just change the view layer of your app.</p>
<p>A great option is Wappl... | 34,424 |
<p>I am interested in writing separate program modules that run as independent threads that I could hook together with pipes. The motivation would be that I could write and test each module completely independently, perhaps even write them in different languages, or run the different modules on different machines. Th... | <p>Might be something <a href="http://www.mail-archive.com/ironruby-core@rubyforge.org/msg02138.html" rel="nofollow noreferrer">here</a> wherein saving the file in BOM-less UTF-8 is suggested.</p>
| <p>I had similar problems, but saving in Unix format made it work for me.</p>
<p>Though, another problem seems to be that the packaged .exe somehow caches the code to execute. If I change the source code, run packager to recreate the exe, and then starts the exe again, nothing seems to have happened to it. Even deleti... | 47,421 |
<p>I am using Moq to mock my Repository layer so I can unit test.</p>
<p>My repository layer Insert methods update the Id property of my entities when a successful db insert occurs.</p>
<p>How do I configure moq to update the Id property of the entity when the Insert method is called? </p>
<p>Repository code:-</p>
... | <p>You can use the Callback method to mock side-effects. Something like:</p>
<pre><code>accountRepository
.Expect(r => r.InsertAccount(account))
.Callback(() => account.ID = 1);
</code></pre>
<p>That's untested but it's along the right lines.</p>
| <p>I'm not sure how that will work because account is created inside the method, so it's not the instance I'll be referring to when I set the value of ID to 1.</p>
<p>Perhaps there's a flaw in my design and I should be checking for ID > 0 inside the IAccountRepository.InsertAccount implementation and then returning a ... | 21,962 |
<p>I'm looking for an XML editor that lets me type and copy and paste arbitrary text into an XML element or attribute without requiring me to go back through and escape any characters that must use reserved XML entities (ampersands, angle brackets, or quote marks). XMLSpy came up short.</p>
| <p><strike>Do you really expect the editor to know that when you paste <code>a<b</code> it should escape the <code><</code> , but when you paste <code>a<b/></code> it shouldn't? Seems like a tall order...</strike></p>
<p>Having thought about this for a bit, I think that what you want can be achieved, eithe... | <p>You could use <a href="http://notepad-plus.sourceforge.net/uk/site.htm" rel="nofollow noreferrer">Notepad++</a> and the <a href="http://notepad-plus.sourceforge.net/commun/pluginsBin/NPPTextFX27-v0.24Release-NPP34.zip" rel="nofollow noreferrer">TextFX plugin</a> for it.</p>
<p>Notepad++ is a decent free programmer'... | 44,061 |
<p>I have a j2me client that would post some chunked encoded data to a webserver. I'd like to process the data in python. The script is being run as a CGI one, but apparently apache will refuse a chunked encoded post request to a CGI script. As far as I could see mod_python, WSGI and FastCGI are no go too.</p>
<p>I'd ... | <p>I had the exact same problem a year ago with a J2ME client talking to a Python/Ruby backend. The only solution I found which <em>doesn't</em> require application or infrastructure level changes was to use a relatively unknown feature of mod_proxy.</p>
<p>Mod_proxy has the ability to buffer incoming (chunked) reques... | <p>Maybe it is a configuration issue? Django can be fronted with Apache by mod_python, WSGI and FastCGI and it can accept file uploads. </p>
| 36,128 |
<p>Are ColdFusion objects (i.e. CFCs invoked via cfobject) normally passed by reference or by value (copied in memory)? And is it possible to force ColdFusion to pass an object in either manner?</p>
| <p>ColdFusion objects are passed by reference. There's not really a way to pass an object by value, but you can create a copy using the duplicate() function. </p>
| <p>FWIW, arrays are also passed by reference in the Railo CFML engine, as many developers believe they should. Railo 3.1 is also expected to offer an administrative setting to allow you to choose the default behavior, for optional compatibility with Adobe CF.</p>
| 27,027 |
<p>The test form generated by ASMX is pretty handy for testing operations. However, there is no apparent way to include SOAP headers.</p>
<p>How can you test your headers without programming a client to use the service?</p>
| <p>If you care about interop, don't use .net client apps to test .net web services. Use a proper tool like SOAPUI to test your web service. <a href="http://www.soapui.org" rel="nofollow noreferrer">www.soapui.org</a></p>
<p>The tool is written in Java, but it is free and darn handy for testing any kind of web service.... | <p>Instead of directly accessing the headers, provide an abstraction that your code accesses instead. For example, if you have a header called "Customer", you might provide a context class you can access like so:</p>
<p>string customer = MyContext.Current.Customer;</p>
<p>Now, all you have to do is swap in a mock imp... | 26,158 |
<p>After I discontinued programming in C++ while entering into web authoring I was spoilt by PHP's high level constructs like hash tables or its dynamic, weak typing. I remembered the angst of C/C++ pointers and the maze of low-level Win32 API handles and message loops and that prevented me from utilizing environments ... | <p><a href="http://www.wxpython.org/" rel="noreferrer">wxPython</a></p>
| <p>You might use Lua with wxLua or the lightweight IUP libraries. Both being portable.</p>
<p>For quick/small prototype/throw away scripts, I also use AutoHotkey: the language is quite awful for a seasoned programmers (newbies seem to like it...), but its high-level GUI is easy and fast to use. And it is rather small ... | 17,241 |
<p>I have a web service (WCF or ASMX doesn't matter)... I have made a Console application, right-clicked, added service referrence. So far, so good.</p>
<p>However, I cannot for the life of me pass "security" credentials across to my service. This is my client code:</p>
<pre><code>var client = new MyClient();
client... | <p>Yes I have, and apparently if you don't use SSL, .Net throws an exception. So apparently you <strong>can't</strong> do what I want without SSL.</p>
| <p>Have you configured the UserName (message security) or Basic (transport security) client credential type on the endpoint binding?</p>
| 48,681 |
<p>VS.net creates a template when you create a WCF project.</p>
<p>It adds a class to the iService1.cs file:</p>
<pre><code>// Use a data contract as illustrated in the sample below to
// add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string strin... | <p>The DataContract is just a formal definition of a type that can be understood on both sides of the service boundary.</p>
<p>If you return, as in your example, a "MyUserCollection" object, the consumers of your service will need to reference the innards of your service/system, which is a violation of the SOA tenet o... | <p>Perhaps not often used, we could use [DataContract] to pass through private variables. The DataContractSerializer will serialize/deserialize only publicly visible types if [DataContract] attribute is not used.</p>
<pre><code>[DataContract]
public class SampleClass
{
[DataMember]
private int MyPrivatePro... | 38,925 |
<p>Does Linux/Unix/Posix provide an API to user-space applications to access a monotonically increasing clock, with centisecond to millisecond accuracy?</p>
<p>On Linux, /proc/uptime provides a string-based representation of a floating point number of the number of seconds the system has been up.</p>
<p>gettimeofday(... | <p>Use the POSIX <code>clock_gettime()</code> function with <code>CLOCK_MONOTONIC</code>. See the <a href="http://linux.die.net/man/3/clock_gettime" rel="noreferrer">man page</a> for details.</p>
| <p>There is clock_gettime:</p>
<pre><code>struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp);
</code></pre>
| 25,922 |
<p>I am having problems using <a href="http://code.google.com/p/django-tagging/" rel="nofollow noreferrer">django-tagging</a>. I try to follow the <a href="http://code.google.com/p/django-tagging/source/browse/trunk/docs/overview.txt" rel="nofollow noreferrer">documentation</a> but it fails at the second step</p>
<blo... | <p><a href="http://code.djangoproject.com/ticket/7680" rel="nofollow noreferrer">http://code.djangoproject.com/ticket/7680</a></p>
<p>parse_lookup has been removed. Not sure how this will affect tagging. Might want to do some searching. </p>
<p>Update: apparently it's been fixed in the trunk version of tagging. Down... | <p>I had the same bug me recently. I checked out the trunk release which seems to work fine. </p>
<pre><code>In [1]: import tagging; tagging.VERSION
Out[1]: (0, 3, 'pre')
</code></pre>
| 45,077 |
<p>Why do database guys go on about normalisation? </p>
<p>What is it? How does it help? </p>
<p>Does it apply to anything outside of databases? </p>
| <p>Normalization is basically to design a database schema such that duplicate and redundant data is avoided. If the same information is repeated in multiple places in the database, there is the risk that it is updated in one place but not the other, leading to data corruption.</p>
<p>There is a number of normalization ... | <p>Normalization is one of the basic concepts. It means that two things do not influence on each other.</p>
<p>In databases specifically means that two (or more) tables do not contain the same data, i.e. do not have any redundancy.</p>
<p>On the first sight that is really good because your chances to make some synchr... | 30,624 |
<p>Currently, I've got images (max. 6MB) stored as BLOB in a InnoDB table.
As the size of the data is growing, the nightly backup is growing slower and slower hindering normal performance.</p>
<p>So, the binary data needs to go to the file system. (pointers to the files will be kept in the DB.)</p>
<p>The data has a ... | <p>Just split your userid from behind. e.g.</p>
<pre><code>UserID = 6435624
Path = /images/24/56/6435624
</code></pre>
<p>As for the backup you could use MySQL Replication and backup the slave
database to avoid problems (e.g. locks) while backuping.</p>
| <p>I'm using this strategy given a unique picture ID</p>
<ul>
<li>reverse the string</li>
<li>zerofill it with leading zero if there's an odd number of digits</li>
<li>chunk the string into two-digits substrings</li>
<li><p>build the path as below</p>
<pre><code>17 >> 71 >> /71.jpg
163 >> 0361 >&... | 23,305 |
<p>My custom 3D printer prints everything inverted. I guess this is a homing problem as the motor moves in correct direction.</p>
<p>In Pronterface,</p>
<ul>
<li>if I press -Y — bed moves forward (towards the Y endstop)</li>
<li>if I press +Y — bed moves backward (away from Y endstop)</li>
<li>if I press -X — hotend mo... | <h1>Heater polarity doesn't matter</h1>
<p>The heater cartridges are just large resistors and so polarity is irrelevant. Either can be positive or negative.</p>
<p>You can extend the leads by cutting and splicing in ~20 gauge wires* to a two pin JST connector line you suggest.</p>
<hr />
<p>*<sup>At 24 volts and 30 wat... | <p>1 meter puts you far enough away from the heater than you don't need high temperature wiring to extend it. The larger the guage(e.g. 20 guage) the less resistance you will add to the heater circuit. This doesn't matter as long as you can still achieve your maximum temperature (if you can still achieve the same cur... | 1,919 |
<p>Does anyone have tips on improving build plate adhesion in DLP printers? I've heard a thin layer of resin or UV glue applied to the plate will help, but we're not sure if we leave the resin/glue wet, or cure it before we start the print. Apologies for the ignorance here, but I'm just trying to avoid gluing my build ... | <p>You do not need to use any glue or any other adhesion modifier to increase your build plate adhesion.
Take these steps instead:</p>
<ol>
<li>Make sure your <strong>build plate is level</strong></li>
<li>Use proper attachment layer (<strong>raft</strong>) - see <a href="https://ameralabs.com/blog/attachment-layer-nee... | <p>I have heard that adding a few pieces of masking tape to the print surface improves adhesion.</p>
| 1,370 |
<p>Let's say I'm running a simple server and have <code>accept()</code>ed a connection from a client.</p>
<p>What is the best way to tell when the client has disconnected? Normally, a client is supposed to send a close command, but what if it disconnects manually or loses network connection altogether? How can the ser... | <p>In TCP there is only one way to detect an orderly disconnect, and that is by getting zero as a return value from <code>read()/recv()/recvXXX()</code> when reading.</p>
<p>There is also only one reliable way to detect a broken connection: by writing to it. After enough writes to a broken connection, TCP will have do... | <p>select (with the read mask set) will return with the handle signalled, but when you use ioctl* to check the number of bytes pending to be read, it will be zero. This is a sign that the socket has been disconnected.</p>
<p>This is a great discussion on the various methods of checking that the client has disconnected... | 35,918 |
<p>I want to do a <code>Response.Redirect("MyPage.aspx")</code> but have it open in a new browser window. I've done this before without using the JavaScript register script method. I just can't remember how?</p>
| <p>I just found the answer and it works :)</p>
<p>You need to add the following to your server side link/button:</p>
<pre><code>OnClientClick="aspnetForm.target ='_blank';"
</code></pre>
<p>My entire button code looks something like:</p>
<pre><code><asp:LinkButton ID="myButton" runat="server" Text="Click Me!"
... | <p>You may want to use the Page.RegisterStartupScript to ensure that the javascript fires on page load.</p>
| 13,022 |
<p>I'm considering developing a website similar to stackoverflow, but the answers may also consist of drawings (schematics, in this case). I want to have an area in the answer form where they can make this schematic without requiring special plugins, etc. </p>
<ol>
<li>Are we to the point where SVG has or should hav... | <p>Unfortunately, I don't have an answer, but I do have three pointers to projects that you could look at.</p>
<p>The first is the <a href="http://Research.Sun.Com/projects/lively/" rel="noreferrer" title="Lively Kernel">Lively Kernel</a> by Dan Ingalls (yes, <em>the</em> Dan Ingalls) at Sun Labs. It is an implementat... | <p>1/ probably never - if IE wanted to add it, then I would have though it would have done so by now; but there are workarounds using <a href="http://www.intertwingly.net/blog/2007/05/04/Inline-SVG-in-MSIE" rel="nofollow noreferrer">SilverLight</a> and <a href="http://starkravingfinkle.org/blog/2006/03/svg-in-ie-update... | 5,339 |
<p>I have a class</p>
<pre><code>public class Broker
{
public Broker(string[] hosts, string endPoint, string port, Type remoteType)
{
}
}
</code></pre>
<p>Which I want to configure using Unity XML Configuration, I can configure it using code in C# as follows already, where "container" is my Unity containe... | <p>Have you defined the type in the configuration file:</p>
<pre><code><unity>
<typeAliases>
<typeAlias alias="IMyBrokeredObject" type="MyAssembly.IMyBrokeredObject, MyAssembly" />
</typeAliases>
<containers>
<container>
<types>
<!-- Views -->
... | <p>But my problem is that there is no implementation available for the IMyBrokeredObject, what is actually happening in the background of this is that the broker provides remote objects given an interface, the actual implementation is somewhere else.</p>
<p>In code I can get the container to provide an broker by givin... | 48,482 |
<p>I'm toying with the idea of volumetric particles. By 'volumetric' I don't mean actually 3D model per particle - usually it's more expensive and harder to blend with other particles. What I mean is 2D particles that will look as close as possible to be volumetric.
Right now what I/we have tried is particles with a... | <p>It sounds like you are asking for information on techniques for the simulation of <a href="http://www.cescg.org/CESCG-2000/SMaierhofer/node6.html" rel="nofollow noreferrer">participating media</a>: "Participating media may absorb, emit and/or scatter light. The simplest participating medium only absorbs light. That ... | <p>See <a href="http://en.wikipedia.org/wiki/Volume_rendering" rel="nofollow noreferrer">Volume Rendering</a> and <a href="http://en.wikipedia.org/wiki/Voxel" rel="nofollow noreferrer">Voxel</a>.</p>
| 10,922 |
<p>I have just bought my own 3D printer. However, I am now reading that there may be some safety risks to 3D printing. I will be taking some precautions, such as buying an enclosed 3D printer (the FlashForge Adventurer 3), using PLA instead of ABS, and putting my 3D printer in my garage. However, I am still concerned a... | <p>Technically, you should never leave your printer running unattended. Printer fires are rare, but it can happen, especially with cheap printers with poor quality control. Personally, I would just make sure that there is a fire alarm near by, so you'd be alerted if there was a fire.</p>
<p>Also, the fumes concern is v... | <p>Install an overhead vent, like those you would have above your stove, to direct fumes and micro-filaments away from the area. You could alternatively use a box fan with a thin air filter attached to it, but the idea is to draw those fumes away from the room.</p>
| 1,893 |
<p>I know mime_content_type() is deprecated, but it seemed to me the alternative is worse at the moment. <code>Finfo</code> seems to require adding files and changing ini directions on windows; I don't want to require this for the script I am making.</p>
<p>I need to find the mimetype of files, but when calling <code>... | <p>This may be related to <a href="http://bugs.php.net/bug.php?id=38235" rel="nofollow noreferrer">this bug report</a>. Do you have any errors in your error log when you call the script along the lines of <code>'FOO' is not a valid mimetype, entry skipped</code>?</p>
<p>Unfortunately the final response in that particul... | <blockquote>
<p>Finfo seems to require adding files and changing ini directions on windows; I don't want to require this for the script I am making.</p>
</blockquote>
<p>Have you tried <a href="http://docs.php.net/manual/en/function.finfo-buffer.php" rel="nofollow noreferrer"><code>finfo_buffer</code></a>? That allo... | 24,036 |
<p>I've been looking for a decent guide to Haskell for some time, but haven't been able to find one that seems interesting enough to read through and/or makes sense.</p>
<p>I've had prior exposure to Haskell a few years back, but I can't remember much about it. I remember the "Aha!"-feeling was incredible when I final... | <p>Some good places to start are:</p>
<ul>
<li><a href="http://www.cs.auckland.ac.nz/references/haskell/haskell-intro-html/intro.html" rel="noreferrer">The Gentle Introduction To Haskell</a></li>
<li><a href="http://www.cs.kent.ac.uk/people/staff/sjt/Haskell_craft/probSolving.html" rel="noreferrer">Problem Solving in ... | <p>This is where I started.
<a href="http://www.haskell.org/haskellwiki/Category:Tutorials" rel="nofollow noreferrer">haskell.org</a></p>
| 3,760 |
<p>What's the difference between eruby and erb? What considerations would drive me to choose one or the other?</p>
<p>My application is generating config files for network devices (routers, load balancers, firewalls, etc.). My plan is to template the config files, using embedded ruby (via either eruby or erb) within... | <p>Doesn't really matter, they're both the same. erb is pure ruby, eruby is written in C so it's a bit faster.</p>
<p>erubis (a third one) is pure ruby, and faster than both the ones listed above. But I doubt the speed of that is the bottleneck for you, so just use erb. It's part of Ruby Standard Library.</p>
| <p>I'm doing something similar using erb, and the performance is fine for me.</p>
<p>As Jordi said though, it depends what context you want to run this in - if you're literally going to use templates like the one you listed, eruby would probably work better, but I'd guess you're actually going to be passing variables ... | 10,040 |
<p>I'm looking for an <a href="http://en.wikipedia.org/wiki/Earley_algorithm" rel="nofollow noreferrer">Earley parser</a> generator that is able to generate Java output code,
i.e. that generates Java code for the lexer and parser, and allows to include actions
(realised as Java code) that are performed for the grammar ... | <p>If I understood your question, by "embed actions in the grammar" you mean inserting semantic actions within the grammar so they are executed "inline" (e.g. during the parsing phase, as the input is being parsed).</p>
<p>Earley parsers are not suitable for this because they allow <strong>any</stro... | <p>Not sure if this is an answer, but one of the scanner generators I regularly use is <a href="http://www.jflex.de" rel="nofollow noreferrer">JFlex</a>, which outputs Java code.</p>
<p>It works closely with <a href="http://www2.cs.tum.edu/projects/cup/manual.html" rel="nofollow noreferrer">CUP</a>, which is a bit clo... | 43,782 |
<p>Is there any open source Object Database available? I would like to have a look at the source code and see how stuffs are implemented.</p>
| <p><a href="http://www.zope.org/Wikis/ZODB" rel="nofollow noreferrer">http://www.zope.org/Wikis/ZODB</a> is the first coming to mind, but here's a list of both commercial and open source object databases:</p>
<p><a href="http://www.odbms.org/vendors.html" rel="nofollow noreferrer">http://www.odbms.org/vendors.html</a>... | <p><a href="http://incubator.apache.org/couchdb/" rel="nofollow noreferrer">CouchDB</a> is a document database, much the same thing as an object one.</p>
| 36,436 |
<p>I developed a program in a mobile device (Pocket PC 2003) to access a web service, the web service is installed on a Windows XP SP2 PC with IIS, the PC has the IP 192.168.5.2. </p>
<p>The device obtains from the wireless network the IP 192.168.5.118 and the program works OK, it calls the method from the web service... | <p>This looks like a network issue, unless there's an odd bug in .Net CF that doesn't allow you to traverse subnets in certain situations (I can find no evidence of such a thing from googling).</p>
<p>Can you get any support from the network/IT team? Also, have you tried it from a different subnet? I.e. not the same a... | <p>Not an expert with this stuff but it looks like the first 3 parts of the address are being masked out. Is it possible that the mobile device is being given a network mask of:</p>
<pre><code>255.255.255.0
</code></pre>
<p>As to reach beyond the range of the first 3 parts you need the mask to be:</p>
<pre><code>255... | 5,122 |
<p>I am trying to do positioning in JavaScript. I am using a cumulative position function based on the <a href="http://www.quirksmode.org/js/findpos.html" rel="noreferrer" title="Find position">classic quirksmode function</a> that sums <code>offsetTop</code> and <code>offsetLeft</code> for each <code>offsetParent</cod... | <p>I have made <a href="http://jsfiddle.net/XEHZV/3/">a test of 2,304 divs</a> with unique combinations of values for <code>position</code>, <code>display</code>, and <code>visibility</code>, nested inside unique combinations of each of those values, and determined that:</p>
<p>an otherwise-valid element<br>
that is a... | <p>I have run into this problem when the sibling just to the left of the element is hidden:</p>
<pre><code><div id="parent">
<div id="element1">some stuff</div>
<div id="element2" style="display: none">some hidden stuff</div>
<div id="element3">child whose offset we want</d... | 39,404 |
<p>I'm trying to dynamically add some textboxes (input type=text) to a page in javascript and prefill them. The textboxes are coming up, but they are coming up empty. What is the proper way to pre-fill a textbox. Ideally I'd love to use the trick of creating a child div, setting the innerhtml property, and then addi... | <pre><code>txtEmail.value = 'my text'
</code></pre>
<p>Does not work?</p>
| <p>I've encountered problems similar to this in the past, and while my memory is a bit fuzzy on why it was happening exactly, I think you may need to make sure the element is actually added to the DOM before modifying its value. e.g:</p>
<pre>
<code>
var txtEmail=document.createElement('input');
document.getElementBy... | 28,938 |
<p>In a latin-1 database i have '<code>\222\222\223\225</code>', when I try to pull this field from the django models I get back <code>u'\u2019\u2019\u201c\u2022'</code>.</p>
<pre><code>from django.db import connection ... | <p>A little browsing of already-asked questions would have led you to <a href="https://stackoverflow.com/questions/274361/utf-8-latin-1-conversion-issues-python-django">UTF-8 latin-1 conversion issues</a>, which was asked and answered yesterday.</p>
<p>BTW, I couldn't remember the exact title, so I just googled on dja... | <p>Django uses UTF-8, unless you define DEFAULT_CHARSET being something other. Be aware that defining other charset will require you to encode all your templates in this charset and this charset will pop from here to there, like email encoding, in sitemaps and feeds and so on. So, IMO, the best you can do is to go UTF-... | 34,730 |
<p>I'm looking for a simple protocol to control remote processes from one managing application. The remote processes will run on Windows and Linux (x86).</p>
<p>Is there a simple protocol for managing remote processes, for which I could find daemons that run on both Windows and Linux?</p>
| <p>I consider ssh to be the "Swiss-army knife" of remote administration. A custom script communicating over ssh can then do the process management. On Windows, I install ssh as part of <a href="http://www.cygwin.com/" rel="nofollow noreferrer">Cygwin</a>.</p>
| <p>On windows you can use shutdown.exe \\remote_name [/y] [/c]</p>
<p><a href="http://support.microsoft.com/kb/317371" rel="nofollow noreferrer">http://support.microsoft.com/kb/317371</a></p>
| 44,003 |
<p>When working with my .Net 2.0 code base ReSharper continually recommends applying the latest c# 3.0 language features, most notably; convert simple properties into auto-implement properties or declaring local variables as var. Amongst others.</p>
<p>When a new language feature arrives do you go back and religiousl... | <p>If it ain't broke, don't fix it. Of course, if you have confidence in your unit tests, you can give it a whirl, but you shouldn't really go randomly changing code "just because".</p>
<p>Of course - in some cases, simplifying code is a valid reason to make a change - but even something as innocent as switching to an... | <p>I leave it be. Besides the fact that it would be alot of work, there's also the issue of is the code really the same or are there side effects of the new feature.</p>
<p>In the specific case of var, the compiler puts the correct type in at compile time anyway, so there's really no benefit.</p>
<p>EDIT: Actually I'... | 32,297 |
<p>I would like to have the same editor available on all of the platforms I frequent.</p>
<p>Emacs and Vi are not desired solutions.</p>
| <p>From <a href="http://help.eclipse.org/help21/topic/org.eclipse.platform.doc.user/tasks/running_eclipse.htm" rel="noreferrer">http://help.eclipse.org/help21/topic/org.eclipse.platform.doc.user/tasks/running_eclipse.htm</a>:</p>
<p>Use the following command-line argument:</p>
<pre><code>-data your_workspace_location... | <p>I wish people would give an actual example, i learn better with examples rather than syntax.
so here it goes...</p>
<pre><code>"C:\MyEclipse Blue Edition\MyEclipse Blue Edition 10\myeclipse-blue.exe" -showlocation -data "C:\EclipseWork\WorkSpace"
</code></pre>
<p>this command will open eclipse with the specified w... | 25,751 |
<p>I need a way to compute the nth root of a long integer in Python. </p>
<p>I tried <code>pow(m, 1.0/n)</code>, but it doesn't work:</p>
<blockquote>
<p>OverflowError: long int too large to convert to float</p>
</blockquote>
<p>Any ideas?</p>
<p>By long integer I mean REALLY long integers like:</p>
<blockquote>... | <p>If it's a REALLY big number. You could use a binary search.</p>
<pre><code>def find_invpow(x,n):
"""Finds the integer component of the n'th root of x,
an integer such that y ** n <= x < (y + 1) ** n.
"""
high = 1
while high ** n <= x:
high *= 2
low = high/2
while low <... | <p>Try converting the exponent to a floating number, as the default behaviour of / in Python is integer division</p>
<p>n**(1/float(3))</p>
| 46,427 |
<p>In Delphi, why does the Assigned() function still return True after I call the destructor?</p>
<p>The below example code will write "sl is still assigned" to the console.</p>
<p>However, I can call FreeAndNil(sl); and it won't be assigned.</p>
<p>I've been programming in Delphi for a while, but this never made se... | <p>If you use sl.Free, the object is freed but the variable sl still points to the now invalid memory.</p>
<p>Use FreeAndNil(sl) to both free the object and clear the pointer.</p>
<p>By the way, if you do:</p>
<pre><code>var
sl1, sl2: TStringList;
begin
sl1 := TStringList.Create;
sl2 := sl1;
FreeAndNil(sl1);... | <p>We have simple rules:</p>
<ol>
<li><p>If you want to use <code>Assigned()</code> to check if an object <code>Obj</code> is already created or not,
then make sure you use <code>FreeAndNil(Obj)</code> to free it.</p></li>
<li><p><code>Assigned()</code> only says if an address is assigned or not.</p></li>
<li><p>The l... | 29,089 |
<p>I'm doing some research into using log4net, and I found the <em>IObjectRenderer</em> interface interesting. It would allow us to control how types are logged and provide a different, possibly more user-friendly <code>ToString()</code> implementation. I just started looking at log4net though, and can't seem to find... | <p>I poked around with it some while writing the question and came up with this:</p>
<pre><code>using System.IO;
using log4net;
using log4net.Config;
using log4net.ObjectRenderer;
using log4net.Util;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
... | <p>You can also add this line to the root of your log4net if you don't want to register your renderer programatically </p>
<pre><code><renderer renderingClass="ConsoleApplication1.FooRenderer" renderedClass="ConsoleApplication1.Foo" />
</code></pre>
| 21,113 |
<p>How can I, in Java or using some other programming language, add a new program group in the applications menu in both KDE and Gnome? </p>
<p>I am testing with Ubuntu and Kubuntu 8. Putting a simple .menu file in ~/.config/menus/applications-merged worked in Kubuntu, but the same procedure does nothing in Ubuntu.</p... | <p>Maybe xdg-desktop-menu does that? See <code>man xdg-desktop-menu</code> or <a href="http://manpages.ubuntu.com/manpages/hardy/en/man1/xdg-desktop-menu.html" rel="nofollow noreferrer">http://manpages.ubuntu.com/manpages/hardy/en/man1/xdg-desktop-menu.html</a> .</p>
| <p>In Gnome use System -> Settings -> Menu then just choose New Menu or New Entry.</p>
| 20,974 |
<p>I love <a href="https://en.wikipedia.org/wiki/WinSCP" rel="noreferrer">WinSCP</a> for Windows. What is the best equivalent software for Linux?</p>
<p>I tried to use sshfs to mount the remote file system on my local machine, but it is not as user friendly as simply launching a GUI, plus it seems to require root acce... | <p>If you're using <a href="https://en.wikipedia.org/wiki/GNOME" rel="noreferrer">GNOME</a>, you can go to: <em>Places</em> → <em>Connect to Server</em> in <a href="https://en.wikipedia.org/wiki/GNOME_Files" rel="noreferrer">Nautilus</a> and choose SSH. If you have an SSH agent running and configured, no password will ... | <p>Just use <a href="https://en.wikipedia.org/wiki/GNOME" rel="nofollow noreferrer">GNOME</a>. Just type in the address and away you go!</p>
| 38,355 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.