qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
124,647 | <p>Say I have an array that represents a set of points:</p>
<pre><code>x = [2, 5, 8, 33, 58]
</code></pre>
<p>How do I generate an array of all the pairwise distances? </p>
| [
{
"answer_id": 124734,
"author": "Lucas Oman",
"author_id": 6726,
"author_profile": "https://Stackoverflow.com/users/6726",
"pm_score": 4,
"selected": true,
"text": "x = [2, 5, 8, 33, 58]\nprint x.collect {|n| x.collect {|i| (n-i).abs}}.flatten\n"
},
{
"answer_id": 129558,
"a... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/781/"
] |
124,649 | <p>In my Silverlight application, I can't seem to bring focus to a TextBox control. On the recommendation of various posts, I've set the IsTabStop property to True and I'm using TextBox.Focus(). Though the UserControl_Loaded event is firing, the TextBox control isn't getting focus. I've included my very simple code below. What am I missing? Thanks.</p>
<p><strong><em>Page.xaml</em></strong> </p>
<pre><code><UserControl x:Class="TextboxFocusTest.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="UserControl_Loaded"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel Width="150" VerticalAlignment="Center">
<TextBox x:Name="RegularTextBox" IsTabStop="True" />
</StackPanel>
</Grid>
</UserControl>
</code></pre>
<p><strong><em>Page.xaml.cs</em></strong></p>
<pre><code>using System.Windows;
using System.Windows.Controls;
namespace PasswordTextboxTest
{
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
RegularTextBox.Focus();
}
}
}
</code></pre>
| [
{
"answer_id": 124778,
"author": "Bryant",
"author_id": 10893,
"author_profile": "https://Stackoverflow.com/users/10893",
"pm_score": 1,
"selected": false,
"text": "<StackPanel Width=\"150\" VerticalAlignment=\"Center\">\n <TextBox x:Name=\"RegularTextBox\" IsTabStop=\"True\" />\n ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4115/"
] |
124,650 | <p>I do mostly Windows development. We use <a href="http://www.mantisbt.org/" rel="noreferrer">Mantis</a> and <a href="http://subversion.tigris.org/" rel="noreferrer">Subversion</a> for our development but they aren't integrated together, in fact they are on different servers.</p>
<p>I did a little googling about integrating the two together and came across <a href="http://alt-tag.com/blog/archives/2006/11/integrating-mantis-and-subversion/" rel="noreferrer">this post</a>. It looked interesting.</p>
<p>I was wondering if anyone is doing this or has done this and what your experience has been. If you've got a different solution, I'd be interested in knowing that too!</p>
<p>Thanks!</p>
| [
{
"answer_id": 941080,
"author": "gbjbaanb",
"author_id": 13744,
"author_profile": "https://Stackoverflow.com/users/13744",
"pm_score": 3,
"selected": false,
"text": "c:\\tools\\perl c:\\tools\\mantis_urlencode.pl %1 %2 > c:\\temp\\postcommit_mantis.txt\nif %ERRORLEVEL% NEQ 0 exit /b 0\... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7862/"
] |
124,667 | <p>This is probably a really stupid newbie-sounding question to you developer type people, but I'm at a loss :( I've been trying to learn how to use Subversion for keeping the history of my code, but I'm finding it pretty confusing. I read the 'book' that comes with Subversion, but I didn't find it all that helpful. I'm using Windows, and I downloaded the TortoiseSVN GUI for it. </p>
<p>All I really want to know how to do is to create a new project, put a file in it (any old file), and then update that file, just so I can see how it works. I created a 'repository' (in svn_repository/test), and if anyone could tell me how I'm supposed to go about creating a new file/putting a file in it, and then updating that file I'd be really happy :) Knowing my luck it'll be something as simple as "drag and drop the file into the directory". Apologies for asking such a stupid question! </p>
<p>Also if anyone could tell me how to go about making it work with Zend Studio, that would be extra awesome-points. Thanks!</p>
| [
{
"answer_id": 124836,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 3,
"selected": false,
"text": "# create an empty repository\nsvnadmin create myrepos\n\n# check out a working copy of the empty repository\nsvn co f... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21442/"
] |
124,671 | <p>How do I pick a random element from a set?
I'm particularly interested in picking a random element from a
HashSet or a LinkedHashSet, in Java.
Solutions for other languages are also welcome. </p>
| [
{
"answer_id": 124687,
"author": "Swaroop C H",
"author_id": 4869,
"author_profile": "https://Stackoverflow.com/users/4869",
"pm_score": 1,
"selected": false,
"text": ">>> import random\n>>> random.choice([1,2,3,4,5,6])\n3\n>>> random.choice([1,2,3,4,5,6])\n4\n"
},
{
"answer_id":... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21445/"
] |
124,682 | <p>Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators?</p>
<p>For instance use a asp:RequiredFieldValidator leave the server side code alone but implement your own client notification using jQuery to highlight the field or background color for example.</p>
| [
{
"answer_id": 125127,
"author": "sontek",
"author_id": 17176,
"author_profile": "https://Stackoverflow.com/users/17176",
"pm_score": 1,
"selected": false,
"text": " <script type=\"text/javascript\">\n rfv.evaluationfunction = validator;\n\n function validator(sender, e) {... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] |
124,722 | <p>When writing GUIs, I've frequently come over the following problem: Assume you have a model and a controller. The controller has a widget <code>W</code> that is used to show a property <code>X</code> of the model.</p>
<p>Because the model might be changed from outside the controller (there might be other controllers using the same model, undo operations etc), the controller listens to changes on the model. The controller also listens to events on the widget <code>W</code> and updates the property <code>X</code> accordingly.</p>
<p>Now, the following happens:</p>
<ol>
<li>the value in <code>W</code> is changed</li>
<li>an event is generated, the handler in the <strong>controller</strong> is invoked</li>
<li>the <strong>controller</strong> sets the new value for <code>X</code> in the <strong>model</strong></li>
<li>the <strong>model</strong> emits events because it has been changed</li>
<li>the <strong>controller</strong> receives a change event from the <strong>model</strong></li>
<li>the <strong>controller</strong> gets the value of <code>X</code> and sets it in the widget</li>
<li>goto 1.</li>
</ol>
<p>There are several possible solutions for that:</p>
<ol>
<li>Modify the controller to set a flag when the model is updated, and not react to any events from the model if this flag is set. </li>
<li>Disconnect the controller temporarily (or tell the model not to send any events for some time)</li>
<li>Freeze any updates from the widget</li>
</ol>
<p>In the past, I usually went for option 1., because it's the simplest thing. It has the drawback of cluttering your classes with flags, but the other methods have their drawbacks, too.</p>
<p>Just for the record, I've had this problem with several GUI toolkits, including GTK+, Qt and SWT, so I think it's pretty toolkit-agnostic.</p>
<p>Any best practices? Or is the architecture I use simply wrong?</p>
<p>@Shy: That's a solution for some cases, but you still get a round of superfluous events if <code>X</code> is changed from outside the controller (for instance, when using the command pattern for undo/redo), because then the value has changed, <code>W</code> is updated and fires an event. In order to prevent another (useless) update to the model, the event generated by the widget has to be swallowed.<br>
In other cases, the model might be more complex and a simple check on what exactly has changed might not be feasible, e.g. a complex tree view.</p>
| [
{
"answer_id": 124740,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 3,
"selected": false,
"text": "valueChanged()"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/124722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9567/"
] |
124,742 | <p>Is there a documented max to the length of the string data you can use in the send method of an <code>XMLHttpRequest</code> for the major browser implementations?</p>
<p>I am running into an issue with a JavaScript <code>XMLHttpRequest</code> Post failing in FireFox 3 when the data is over approx 3k. I was assuming the Post would behave the same as a conventional Form Post.</p>
<p>The W3C docs mention the data param of the send method is a DOMString but I am not sure how the major browsers implement that.</p>
<p>Here is a simplified version of my JavaScript, if bigText is over about 3k it fails, otherwise it works...</p>
<pre><code>var xhReq = createXMLHttpRequest();
function createXMLHttpRequest() {
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
try { return new XMLHttpRequest(); } catch(e) {}
alert("XMLHttpRequest not supported");
return null;
}
function mySubmit(id, bigText) {
var url = "SubmitPost.cfm";
var params = "id=" + id + "&bigtext=" + encodeURI(bigText);
xhReq.open("POST", url, true);
//Send the header information along with the request
xhReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhReq.setRequestHeader("Content-length", params.length);
xhReq.setRequestHeader("Connection", "close");
xhReq.onreadystatechange = onPostSubmit;
xhReq.send(params);
}
function onPostSubmit() {
if (xhReq.readyState==4 || xhReq.readyState=="complete")
{
if (xhReq.status != 200)
{
alert('BadStatus');
return;
}
}
}
</code></pre>
| [
{
"answer_id": 54392713,
"author": "Yones",
"author_id": 10899806,
"author_profile": "https://Stackoverflow.com/users/10899806",
"pm_score": 0,
"selected": false,
"text": "vim /etc/nginx/nginx.conf\n"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/124742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7121/"
] |
124,764 | <p>I have seen this link: <a href="http://www.developer.com/lang/jscript/article.php/3592016" rel="noreferrer">Implementing Mutual Exclusion in JavaScript</a>.
On the other hand, I have read that there are no threads in javascript, but what exactly does that mean? </p>
<p>When events occur, where in the code can they interrupt?</p>
<p>And if there are no threads in JS, do I need to use mutexes in JS or not?</p>
<p>Specifically, I am wondering about the effects of using functions called by <code>setTimeout()</code> and <code>XmlHttpRequest</code>'s <code>onreadystatechange</code> on globally accessible variables. </p>
| [
{
"answer_id": 124832,
"author": "William",
"author_id": 9193,
"author_profile": "https://Stackoverflow.com/users/9193",
"pm_score": 8,
"selected": true,
"text": "setTimeout()"
},
{
"answer_id": 6760039,
"author": "alzclarke",
"author_id": 662049,
"author_profile": "h... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3751/"
] |
124,841 | <p>I have written the following simple test in trying to learn Castle Windsor's Fluent Interface:</p>
<pre><code>using NUnit.Framework;
using Castle.Windsor;
using System.Collections;
using Castle.MicroKernel.Registration;
namespace WindsorSample {
public class MyComponent : IMyComponent {
public MyComponent(int start_at) {
this.Value = start_at;
}
public int Value { get; private set; }
}
public interface IMyComponent {
int Value { get; }
}
[TestFixture]
public class ConcreteImplFixture {
[Test]
public void ResolvingConcreteImplShouldInitialiseValue() {
IWindsorContainer container = new WindsorContainer();
container.Register(Component.For<IMyComponent>().ImplementedBy<MyComponent>().Parameters(Parameter.ForKey("start_at").Eq("1")));
IMyComponent resolvedComp = container.Resolve<IMyComponent>();
Assert.AreEqual(resolvedComp.Value, 1);
}
}
}
</code></pre>
<p>When I execute the test through TestDriven.NET I get the following error:</p>
<pre><code>System.TypeLoadException : Could not load type 'Castle.MicroKernel.Registration.IRegistration' from assembly 'Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'.
at WindsorSample.ConcreteImplFixture.ResolvingConcreteImplShouldInitialiseValue()
</code></pre>
<p>When I execute the test through the NUnit GUI I get:</p>
<pre><code>WindsorSample.ConcreteImplFixture.ResolvingConcreteImplShouldInitialiseValue:
System.IO.FileNotFoundException : Could not load file or assembly 'Castle.Windsor, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The system cannot find the file specified.
</code></pre>
<p>If I open the Assembly that I am referencing in Reflector I can see its information is:</p>
<pre><code>Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
</code></pre>
<p>and that it definitely contains <strong>Castle.MicroKernel.Registration.IRegistration</strong></p>
<p>What could be going on? </p>
<p>I should mention that the binaries are taken from the <a href="http://builds.castleproject.org/cruise/DownloadBuild.castle?number=956" rel="noreferrer">latest build of Castle</a> though I have never worked with nant so I didn't bother re-compiling from source and just took the files in the bin directory. I should also point out that my project compiles with no problem.</p>
| [
{
"answer_id": 2531775,
"author": "Brian Moeskau",
"author_id": 108348,
"author_profile": "https://Stackoverflow.com/users/108348",
"pm_score": 4,
"selected": false,
"text": "HttpHandler"
},
{
"answer_id": 27803235,
"author": "smirkingman",
"author_id": 338101,
"autho... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
124,844 | <p>I am asking this out of a curiosity. Basically my question is when you have a database which needs a row entry to have things which act like flags, what is the best practice? A good example of this would be the badges on stack overflow, or the operating system field in bugzilla. Any subset of the flags may be set for a given entry.</p>
<p>Usually, I do c and c++ work, so my gut reaction is to use an unsigned integer field as a set of bits which can be flipped... But i know that isn't a good solution for several reasons. The most obvious of which is scale-ability, there will be a hard upper limit on how many flags I can have.</p>
<p>I can also think of a couple of other solutions which scale better but would have performance issues because they would require multiple selects to get all the information.</p>
<p>So, what is the "right" way to do this?</p>
| [
{
"answer_id": 124872,
"author": "Jeremiah Peschka",
"author_id": 11780,
"author_profile": "https://Stackoverflow.com/users/11780",
"pm_score": 5,
"selected": false,
"text": "\nCREATE TABLE Users (\n UserId INT IDENTITY(1, 1) PRIMARY KEY,\n FirstName VARCHAR(50),\n LastName VARCHAR(50... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13430/"
] |
124,854 | <p>I have an <code><img></code> in an HTML document that I would like to highlight as though the user had highlighted it using the mouse. Is there a way to do that using JavaScript?</p>
<p>I only need it to work in Mozilla, but any and all information is welcome.</p>
<p><em>EDIT: The reason I want to select the image is actually not so that it appears highlighted, but so that I can then copy the selected image to the clipboard using XPCOM. So the img actually has to be selected for this to work.</em></p>
| [
{
"answer_id": 124867,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": -1,
"selected": false,
"text": "<html>\n<body>\n<script language=\"javascript\">\nfunction swap(name) {\n document.getElementById(\"image\").src = name;\... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7441/"
] |
124,856 | <p>I'd like to ensure my RAII class is always allocated on the stack.</p>
<p>How do I prevent a class from being allocated via the 'new' operator?</p>
| [
{
"answer_id": 124857,
"author": "Kevin",
"author_id": 6386,
"author_profile": "https://Stackoverflow.com/users/6386",
"pm_score": 6,
"selected": false,
"text": "class X\n{\n private: \n // Prevent heap allocation\n void * operator new (size_t);\n void * operator new[... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6386/"
] |
124,865 | <p>At the office we are currently writing an application that will generate XML files against a schema that we were given. We have the schema in an .XSD file.</p>
<p>Are there tool or libraries that we can use for automated testing to check that the generated XML matches the schema?</p>
<p>We would prefer free tools that are appropriate for commercial use although we won't be bundling the schema checker so it only needs to be usable by devs during development.</p>
<p>Our development language is C++ if that makes any difference, although I don't think it should as we could generate the xml file and then do validation by calling a separate program in the test.</p>
| [
{
"answer_id": 124947,
"author": "Charles Duffy",
"author_id": 14122,
"author_profile": "https://Stackoverflow.com/users/14122",
"pm_score": 5,
"selected": false,
"text": "xmlstarlet val --xsd your_schema.xsd your_file.xml\n"
},
{
"answer_id": 129401,
"author": "Adrian Mouat"... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5113/"
] |
124,871 | <p>I'm a long-time Windows developer, having cut my teeth on win32 and early COM. I've been working with .NET since 2001, so I'm pretty fluent in C# and the CLR. I'd never heard of Castle Windsor until I started participating in Stack Overflow. I've read the Castle Windsor "Getting Started" guide, but it's not clicking.</p>
<p>Teach this old dog new tricks, and tell me why I should be integrating Castle Windsor into my enterprise apps.</p>
| [
{
"answer_id": 124898,
"author": "Matt Hinze",
"author_id": 2676,
"author_profile": "https://Stackoverflow.com/users/2676",
"pm_score": 10,
"selected": true,
"text": "new EmailSender().Send(emailMessage);"
},
{
"answer_id": 42655294,
"author": "Rakesh Burbure",
"author_id... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1181217/"
] |
124,880 | <p>Is it possible to prevent stack allocation of an object and only allow it to be instiated with 'new' on the heap?</p>
| [
{
"answer_id": 124903,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 4,
"selected": false,
"text": "private"
},
{
"answer_id": 124904,
"author": "Dominik Grabiec",
"author_id": 3719,
"author_profile":... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
124,886 | <p>I need to change the functionality of an application based on the executable name. Nothing huge, just changing strings that are displayed and some internal identifiers. The application is written in a mixture of native and .Net C++-CLI code. </p>
<p>Two ways that I have looked at are to parse the GetCommandLine() function in Win32 and stuffing around with the AppDomain and other things in .Net. However using GetCommandLine won't always work as when run from the debugger the command line is empty. And the .Net AppDomain stuff seems to require a lot of stuffing around.</p>
<p>So what is the nicest/simplest/most efficient way of determining the executable name in C++/CLI? (I'm kind of hoping that I've just missed something simple that is available in .Net.)</p>
<p>Edit: One thing that I should mention is that this is a Windows GUI application using C++/CLI, therefore there's no access to the traditional C style main function, it uses the Windows WinMain() function.</p>
| [
{
"answer_id": 124901,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 6,
"selected": true,
"text": "argv[0]"
},
{
"answer_id": 124908,
"author": "Community",
"author_id": -1,
"author_profile": "https://S... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3719/"
] |
124,932 | <p>I have a bit of code that basically reads an XML document using the XMLDocument.Load(uri) method which works fine, but doesn't work so well if the call is made through a proxy.</p>
<p>I was wondering if anyone knew of a way to make this call (or achieve the same effect) through a proxy?</p>
| [
{
"answer_id": 125286,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 4,
"selected": false,
"text": "WebProxy wp = new WebProxy(Settings.Default.ProxyAddress);\nwp.Credentials = new NetworkCredential(Settings.Default.ProxyUserna... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/493/"
] |
124,935 | <p>I'm using scriptaculous's Ajax.Autocompleter for a search with different filters. </p>
<p><a href="http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter" rel="nofollow noreferrer">http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter</a></p>
<p>The filters are requiring me to pass data into the autocompleter dynamically, which I've successfully learned to do from the following link. </p>
<p><a href="http://www.simpltry.com/2007/01/30/ajaxautocompleter-dynamic-parameters/" rel="nofollow noreferrer">http://www.simpltry.com/2007/01/30/ajaxautocompleter-dynamic-parameters/</a></p>
<p>Now, I have multiple filters and one search box. How do I get the autocompleter to make the request <em>without</em> typing into the input, but by clicking a new filter?</p>
<p>Here's a use case to clarify. The page loads, there are multiple filters (just links with onclicks), and one input field with the autocompleter attached. I type a query and the autocompleter request is performed. Then, I click on a different filter, and I'd like another request to be performed with the same query, but different filter. </p>
<p>Or more succinctly, how do I make the autocompleter perform the request <em>when I want</em>, instead of depending on typing to trigger it?</p>
| [
{
"answer_id": 125027,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 1,
"selected": false,
"text": "onObserverEvent()"
},
{
"answer_id": 129644,
"author": "Steve",
"author_id": 21456,
"author_profi... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21456/"
] |
124,946 | <p>My question is based off of inheriting a great deal of legacy code that I can't do very much about. Basically, I have a device that will produce a block of data. A library which will call the device to create that block of data, for some reason I don't entirely understand and cannot change even if I wanted to, writes that block of data to disk.</p>
<p>This write is not instantaneous, but can take up to 90 seconds. In that time, the user wants to get a partial view of the data that's being produced, so I want to have a consumer thread which reads the data that the other library is writing to disk.</p>
<p>Before I even touch this legacy code, I want to mimic the problem using code I entirely control. I'm using C#, ostensibly because it provides a lot of the functionality I want.</p>
<p>In the producer class, I have this code creating a random block of data:</p>
<pre><code>FileStream theFS = new FileStream(this.ScannerRawFileName,
FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
//note that I need to be able to read this elsewhere...
BinaryWriter theBinaryWriter = new BinaryWriter(theFS);
int y, x;
for (y = 0; y < imheight; y++){
ushort[] theData= new ushort[imwidth];
for(x = 0; x < imwidth;x++){
theData[x] = (ushort)(2*y+4*x);
}
byte[] theNewArray = new byte[imwidth * 2];
Buffer.BlockCopy(theImage, 0, theNewArray, 0, imwidth * 2);
theBinaryWriter.Write(theNewArray);
Thread.Sleep(mScanThreadWait); //sleep for 50 milliseconds
Progress = (float)(y-1 >= 0 ? y-1 : 0) / (float)imheight;
}
theFS.Close();
</code></pre>
<p>So far, so good. This code works. The current version (using FileStream and BinaryWriter) appears to be equivalent (though slower, because of the copy) to using File.Open with the same options and a BinaryFormatter on the ushort[] being written to disk.</p>
<p>But then I add a consumer thread:</p>
<pre><code>FileStream theFS;
if (!File.Exists(theFileName)) {
//do error handling
return;
}
else {
theFS = new FileStream(theFileName, FileMode.Open,
FileAccess.Read, FileShare.Read);
//very relaxed file opening
}
BinaryReader theReader = new BinaryReader(theFS);
//gotta do this copying in order to handle byte array swaps
//frustrating, but true.
byte[] theNewArray = theReader.ReadBytes(
(int)(imheight * imwidth * inBase.Progress) * 2);
ushort[] theData = new ushort[((int)(theNewArray.Length/2))];
Buffer.BlockCopy(theNewArray, 0, theData, 0, theNewArray.Length);
</code></pre>
<p>Now, it's possible that the declaration of theNewArray is broken, and will cause some kind of read overflow. However, this code never gets that far, because it always always always breaks on trying to open the new FileStream with a System.IO.IOException that states that another process has opened the file.</p>
<p>I'm setting the FileAccess and FileShare enumerations as stated in the FileStream documentation on MSDN, but it appears that I just can't do what I want to do (ie, write in one thread, read in another). I realize that this application is a bit unorthodox, but when I get the actual device involved, I'm going to have to do the same thing, but using MFC.</p>
<p>In any event, What am I forgetting? Is what I'm wanting to do possible, since it's specified as possible in the documentation? </p>
<p>Thanks!
mmr</p>
| [
{
"answer_id": 125059,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "FileStream theFS = new FileStream(this.ScannerRawFileName, \n FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);\n//no... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
124,958 | <p>I'm trying to display an array of files in order of date (last modified).</p>
<p>I have done this buy looping through the array and sorting it into another array, but is there an easier (more efficient) way to do this?</p>
| [
{
"answer_id": 125047,
"author": "Jay",
"author_id": 20840,
"author_profile": "https://Stackoverflow.com/users/20840",
"pm_score": 8,
"selected": true,
"text": "create_function()"
},
{
"answer_id": 3298787,
"author": "Alf Eaton",
"author_id": 145899,
"author_profile":... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/910/"
] |
124,959 | <p>Whats the available solutions for PHP to create word document in linux environment?</p>
| [
{
"answer_id": 125009,
"author": "Sergey Kornilov",
"author_id": 10969,
"author_profile": "https://Stackoverflow.com/users/10969",
"pm_score": 5,
"selected": false,
"text": "header(\"Content-type: application/vnd.ms-word\");\nheader(\"Content-Disposition: attachment; filename=document_na... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
124,966 | <p>I want something like an <a href="http://en.wikipedia.org/wiki/Map_%28C++%29" rel="nofollow noreferrer">std::map</a>, but I only want to see if the item exists or not, I don't actually need a key AND a value. What should I use?</p>
| [
{
"answer_id": 124994,
"author": "David Dibben",
"author_id": 5022,
"author_profile": "https://Stackoverflow.com/users/5022",
"pm_score": 3,
"selected": false,
"text": "std::map"
},
{
"answer_id": 125002,
"author": "Cyber Oliveira",
"author_id": 9793,
"author_profile"... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4946/"
] |
124,975 | <p>I'm looking for a free winforms component for an application I'm writing. I basicly need a textbox that contains line numbers in a side column. Being able to tabulate data within it would be a major plus too.</p>
<p>Does anyone know of a premade component that could do this?</p>
| [
{
"answer_id": 125115,
"author": "ine",
"author_id": 4965,
"author_profile": "https://Stackoverflow.com/users/4965",
"pm_score": 4,
"selected": true,
"text": "Public Sub New()\n MyBase.New()\n\n 'This call is required by the Windows Form Designer.\n InitializeComponent()\n\n ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/124975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
125,022 | <p>I am trying to install PHP onto my development box (XP SP3 / IIS 5.1) I've got PHP 5.2.6 stable downloaded (the MSI installer package) and I am getting an error "Cannot find httpd.conf". After that the install seems to breeze by quickly (more quickly than I would have expected) and when I try to execute a simple PHP script from my localhost test directory that I created, I get a slew of missing DLL errors. I have seen posts out there which indicate that its possible and has been done. I dont see any bug reports for this MSI at PHP.NET support. Any ideas?</p>
| [
{
"answer_id": 125092,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 1,
"selected": false,
"text": "c:\\Program Files\\php"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14728/"
] |
125,034 | <p>In Python, I want to make <strong>selected</strong> instance attributes of a class be readonly to code outside of the class. I want there to be no way outside code can alter the attribute, except indirectly by invoking methods on the instance. I want the syntax to be concise. What is the best way? (I give my current best answer below...)</p>
| [
{
"answer_id": 125058,
"author": "Kevin Little",
"author_id": 14028,
"author_profile": "https://Stackoverflow.com/users/14028",
"pm_score": 2,
"selected": false,
"text": "class C(object):\n\n def __init__(self):\n\n self.fullaccess = 0\n self.__readonly = 22 # almost inv... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14028/"
] |
125,050 | <p>...or are they the same thing? I notice that each has its own Wikipedia entry: <a href="http://en.wikipedia.org/wiki/Polymorphism_(computer_science)" rel="noreferrer">Polymorphism</a>, <a href="http://en.wikipedia.org/wiki/Multiple_dispatch" rel="noreferrer">Multiple Dispatch</a>, but I'm having trouble seeing how the concepts differ.</p>
<p><strong>Edit:</strong> And how does <a href="http://en.wikipedia.org/wiki/Overloaded" rel="noreferrer">Overloading</a> fit into all this?</p>
| [
{
"answer_id": 125064,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 0,
"selected": false,
"text": "this"
},
{
"answer_id": 125095,
"author": "CodeRedick",
"author_id": 17145,
"author_profile": "https:... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] |
125,094 | <p>I have a 2D character array:<br>
<code>char nm[MAX1][MAX2] = { "john", "bob", "david" };</code><br>
I want to swap two of these elements (without <code>std::swap</code>) by simply writing<br>
<code>swapPointers(nm[0], nm[1]);</code><br>
where <code>swapPointers</code> looks like this </p>
<pre><code>void swapPointers(char *&a, char *&b)
{
char *temp = a;
a = b;
b = a;
}
</code></pre>
<p>However, this does not compile (and while adding casts makes it compile, the pointers end up pointing to wrong/weird locations). </p>
<p>Can anybody help?<br>
Thanks!</p>
| [
{
"answer_id": 125103,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 0,
"selected": false,
"text": "void swapPointers(char** ppa, char** ppb)\n{\n char* ptemp = *ppa;\n *ppb = *ppa;\n *ppa = ptemp;\n}\n\nswapPoint... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21475/"
] |
125,096 | <p>I have an app that has impersonation used throughout. But when a user is logged in as an admin, a few operation require them to write to the server itself. Now if these users do not have rights on the actual server (some don't) it will not let them write. </p>
<p>What I want to do is turn off impersonation for just a couple commands.</p>
<p>Is there a way to do something like this?</p>
<pre><code>using(HostingEnvironment.Impersonate.Off())
//I know this isn't a command, but you get the idea?
</code></pre>
<p>Thank you.</p>
| [
{
"answer_id": 217452,
"author": "Maxime Rouiller",
"author_id": 24975,
"author_profile": "https://Stackoverflow.com/users/24975",
"pm_score": 6,
"selected": true,
"text": "private WindowsImpersonationContext context = null;\npublic void RevertToAppPool()\n{\n try\n {\n if (... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14777/"
] |
125,099 | <p>Anyone know the formula used to control the movement of a simple tank-like vehicle?</p>
<p>To 'steer' it, you need to alter the force applied the left and right "wheels". Eg. 1 unit of force on both wheels makes it go forward. -1 units of force on both wheels makes it go backwards. Apply more force to one wheel than the other and it turns.</p>
<p>How would you calculate the amount of force needed on both wheels to turn the tank a certain number of degrees either way?</p>
<p>Or am I thinking about this in the wrong way?</p>
<p>edit:
As William Keller mentioned I missed out the speed of the tank. Assume 1 unit of force on both wheels moves the tank forward at 1 unit per second.</p>
<p>For anyone who's interested, I just found this thread on gamedev.net:
<a href="http://66.102.9.104/search?q=cache:wSn5t58ACJwJ:www.gamedev.net/community/forums/topic.asp%3Ftopic_id%3D407491+tank+track+radius+velocity&hl=en&ct=clnk&cd=1&gl=za&client=firefox-a" rel="nofollow noreferrer">http://66.102.9.104/search?q=cache:wSn5t58ACJwJ:www.gamedev.net/community/forums/topic.asp%3Ftopic_id%3D407491+tank+track+radius+velocity&hl=en&ct=clnk&cd=1&gl=za&client=firefox-a</a></p>
<p>Another thread:
<a href="http://www.physicsforums.com/showthread.php?t=220317" rel="nofollow noreferrer">http://www.physicsforums.com/showthread.php?t=220317</a></p>
<p>It turns out the key to finding the formula was just knowing the correct terminology ("skid steer") :P</p>
| [
{
"answer_id": 125154,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 2,
"selected": false,
"text": "Change in angle (in radians/sec) = (l-r)/(radius between treads)\nVelocity = l+r\n"
},
{
"answer_id": 39111386,
... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] |
125,102 | <p>Say I have the following string:</p>
<pre><code>"I am the most foo h4ck3r ever!!"
</code></pre>
<p>I'm trying to write a makeSpecial(foo) function where the foo substring would be wrapped in a new span element, resulting in:</p>
<pre><code>"I am the most <span class="special">foo></span> h4ck3r ever!!"
</code></pre>
<p>BeautifulSoup seemed like the way to go, but I haven't been able to make it work.</p>
<p>I could also pass this to the browser and do it with javascript, but that doesn't seem like a great idea.</p>
<p>Some advice for this would be really useful, especially in python. </p>
| [
{
"answer_id": 125122,
"author": "fuentesjr",
"author_id": 10708,
"author_profile": "https://Stackoverflow.com/users/10708",
"pm_score": 3,
"selected": true,
"text": "Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on\nwin32\nType \"help\", \"copyright\", \"c... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9106/"
] |
125,109 | <p>I'm trying to bind a <code>List<T></code> to a DataGridView control, and I'm not having any luck creating custom bindings.</p>
<p>I have tried:</p>
<pre><code>gvProgramCode.DataBindings.Add(new Binding("Opcode",code,"Opcode"));
</code></pre>
<p>It throws an exception, saying that nothing was found by that property name.</p>
<p>The name of the column in question is "Opcode". The name of the property in the <code>List<T></code> is Opcode.</p>
<p><strong>ANSWER EDIT</strong>: the problem was that I did not have the bindable fields in my class as properties, just public fields...Apparently it doesn't reflect on fields, just properties.</p>
| [
{
"answer_id": 125132,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 4,
"selected": false,
"text": " class MyObject\n {\n public string Something { get; set; }\n public string Text { get; set; ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
125,113 | <p>What is the most efficient way to convert a MySQL query to CSV in PHP please?</p>
<p>It would be best to avoid temp files as this reduces portability (dir paths and setting file-system permissions required).</p>
<p>The CSV should also include one top line of field names.</p>
| [
{
"answer_id": 125118,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 2,
"selected": false,
"text": "// Export to CSV\nif($_GET['action'] == 'export') {\n\n $rsSearchResults = mysql_query($sql, $db) or die(mysql_error());\n\n ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5165/"
] |
125,117 | <p>I was looking at how some site implemented rounded corners, and the CSS had these odd tags that I've never really seen before.</p>
<pre><code>-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-bottomright: 5px;
-webkit-border-bottom-right-radius: 5px;
</code></pre>
<p>I googled it, and they seem to be Firefox specific tags? </p>
<p><b>Update</b></p>
<p>The site I was looking at was twitter, it's wierd how a site like that would alienate their IE users.</p>
| [
{
"answer_id": 125128,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 4,
"selected": true,
"text": "-moz-*"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] |
125,124 | <p>How do you pass options to an executable? Is there an easier way than making the options boolean arguments?</p>
<p>EDIT: The last two answers have suggested using arguments. I know I can code a workable solution like that, but I'd rather have them be options.</p>
<p>EDIT2: Per requests for clarification, I'll use this simple example:
It's fairly easy to handle arguments because they automatically get parsed into an array.</p>
<pre><code>./printfile file.txt 1000
</code></pre>
<p>If I want to know what the name of the file the user wants to print, I access it via argv[1].</p>
<p>Now about how this situation:</p>
<pre><code>./printfile file.txt 1000 --nolinebreaks
</code></pre>
<p>The user wants to print the file with no line breaks. This is not required for the program to be able to run (as the filename and number of lines to print are), but the user has the option of using if if s/he would like. Now I could do this using:</p>
<pre><code>./printfile file.txt 1000 true
</code></pre>
<p>The usage prompt would inform the user that the third argument is used to determine whether to print the file with line breaks or not. However, this seems rather clumsy. </p>
| [
{
"answer_id": 125225,
"author": "bk1e",
"author_id": 8090,
"author_profile": "https://Stackoverflow.com/users/8090",
"pm_score": 3,
"selected": true,
"text": "--"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7545/"
] |
125,143 | <p>I am developing a forms app (not web) for Windows Mobile, using .NET CF 3.5. I need an HTML editor control. I'm looking for something along the lines of a simple FCKEditor, but for using in a forms app (EXE).</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 125297,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 0,
"selected": false,
"text": "webBrowser1.Document.GetType().GetProperty(\"designmode\").SetValue(webBrowser1.Document, true, null);\n"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1664/"
] |
125,146 | <p>I'm trying to write an app using Ruby on Rails and I'm trying to achieve the following:</p>
<blockquote>
<p>The app needs to receive UDP messages coming in on a specific port (possibly 1 or more per second) and store them in the database so that the rest of my Rails app can access it. </p>
</blockquote>
<p>I was thinking of writing a separate daemon that would receive these messages and shell out to a ruby script on my rails app that will store the message in the database using the right model. The problem with this approach is that the ruby script will be run very often. It would be better performance-wise if I could just have a long-running ruby process that can constantly receive the UDP messages store them in the database. </p>
<p>Is this the right way to do it? Is there something in the Rails framework that can help with this?</p>
| [
{
"answer_id": 125179,
"author": "Nate",
"author_id": 12779,
"author_profile": "https://Stackoverflow.com/users/12779",
"pm_score": 3,
"selected": true,
"text": "include"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] |
125,157 | <p>Is it possible to specify a relative path reference in connectionstring, attachDbFileName property in a web.config?</p>
<p>For example, In my database is located in the App_data folder, I can easily specify the AttachDBFilename as|DataDirectory|\mydb.mdf and the |Datadirectory| will automatically resolve to the correct path.</p>
<p>Now, suppose that web.config file is located in A folder, but the database is located in B\App_data folder, where A and B folder is located in the same folder. Is there anyway to use relative path reference to resolve to the correct path?</p>
| [
{
"answer_id": 2522135,
"author": "jbandi",
"author_id": 32749,
"author_profile": "https://Stackoverflow.com/users/32749",
"pm_score": 4,
"selected": false,
"text": "<appSettings>\n <add key=\"DataDirectory\" value=\"..\\..\\..\\BookShop\\App_Data\\\"/>\n</appSettings>\n"
},
{
"... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] |
125,171 | <p>I need to pass a regex substitution as a variable:</p>
<pre><code>sub proc {
my $pattern = shift;
my $txt = "foo baz";
$txt =~ $pattern;
}
my $pattern = 's/foo/bar/';
proc($pattern);
</code></pre>
<p>This, of course, doesn't work. I tried eval'ing the substitution:</p>
<pre><code>eval("$txt =~ $pattern;");
</code></pre>
<p>but that didn't work either. What horribly obvious thing am I missing here?</p>
| [
{
"answer_id": 125212,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 3,
"selected": false,
"text": "$pattern = qr/foo/;\n\nprint \"match!\\n\" if $text =~ $pattern;\n"
},
{
"answer_id": 125240,
"author": "Jonathan... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8130/"
] |
125,192 | <p>A common pattern with STL containers is this:</p>
<pre><code>map<Key, Value> map;
for(map<Key, Value>::iterator iter = map.begin(); iter != map.end(); ++iter)
{
...
}
</code></pre>
<p>So in order to avoid writing the declaration of the template parameters we can do this somewhere:</p>
<pre><code>typedef map<Key, Value> TNiceNameForAMap;
</code></pre>
<p>But if this map is only used in a single function or for a single iteration this is an annoying overhead.</p>
<p>Is there any way around this typedef?</p>
| [
{
"answer_id": 125201,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 3,
"selected": false,
"text": "int totalSize() {\n typedef std::map<Key, Value> DeDuplicator;\n DeDuplicator everything;\n\n // Run around ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9611/"
] |
125,222 | <p>for working with MS word files in python, there is python win32 extensions, which can be used in windows. How do I do the same in linux?
Is there any library?</p>
| [
{
"answer_id": 404378,
"author": "David",
"author_id": 49460,
"author_profile": "https://Stackoverflow.com/users/49460",
"pm_score": 3,
"selected": false,
"text": "import commands\n\nexe = 'wvText ' + word_file + ' ' + output_txt_file\nout = commands.getoutput(exe)\nexe = 'cat ' + output... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21480/"
] |
125,230 | <p>What MySQL query will do a text search and replace in one particular field in a table?</p>
<p>I.e. search for <code>foo</code> and replace with <code>bar</code> so a record with a field with the value <code>hello foo</code> becomes <code>hello bar</code>.</p>
| [
{
"answer_id": 125243,
"author": "thesmallprint",
"author_id": 12765,
"author_profile": "https://Stackoverflow.com/users/12765",
"pm_score": 7,
"selected": false,
"text": "UPDATE table_name \nSET field = replace(field, 'string-to-find', 'string-that-will-replace-it');\n"
},
{
"an... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16536/"
] |
125,265 | <p>In reading about Perl 6, I see a feature being trumpeted about, where you no longer have to do:</p>
<pre><code>return "0 but true";
</code></pre>
<p>...but can instead do:</p>
<pre><code>return 0 but True;
</code></pre>
<p>If that's the case, how does truth work in Perl 6? In Perl 5, it was pretty simple: 0, "", and undef are false, everything else is true.</p>
<p>What are the rules in Perl 6 when it comes to boolean context?</p>
| [
{
"answer_id": 125881,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 4,
"selected": false,
"text": ".true"
},
{
"answer_id": 23433786,
"author": "kovacsbv",
"author_id": 1106586,
"author_profile": "https... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] |
125,268 | <p>Is it possible to chain static methods together using a static class? Say I wanted to do something like this:</p>
<pre><code>$value = TestClass::toValue(5)::add(3)::subtract(2)::add(8)::result();
</code></pre>
<p>. . . and obviously I would want $value to be assigned the number 14. Is this possible?</p>
<p><strong>Update</strong>: It doesn't work (you can't return "self" - it's not an instance!), but this is where my thoughts have taken me:</p>
<pre><code>class TestClass {
public static $currentValue;
public static function toValue($value) {
self::$currentValue = $value;
}
public static function add($value) {
self::$currentValue = self::$currentValue + $value;
return self;
}
public static function subtract($value) {
self::$currentValue = self::$currentValue - $value;
return self;
}
public static function result() {
return self::$value;
}
}
</code></pre>
<p>After working that out, I think it would just make more sense to simply work with a class instance rather than trying to chain static function calls (which doesn't look possible, unless the above example could be tweaked somehow).</p>
| [
{
"answer_id": 125299,
"author": "jW.",
"author_id": 8880,
"author_profile": "https://Stackoverflow.com/users/8880",
"pm_score": 0,
"selected": false,
"text": "::"
},
{
"answer_id": 125317,
"author": "Camilo Díaz Repka",
"author_id": 861,
"author_profile": "https://St... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] |
125,272 | <p>I'm relatively new to Mercurial and my team is trying it out right now as a replacement for Subversion. </p>
<p>How can I commit and push a single file out to another repository while leaving other modifications in my working directory uncommitted (or at least not pushed to the other repository)?</p>
<p>This happens for us with database migrations. We want to commit the migration to source control so a DBA can view and edit it while we're working on the code modifications to go along with that database migration. The changes aren't yet ready to go so we don't want to push all of them out.</p>
<p>In subversion, I'd simply do:</p>
<pre><code>svn add my_migration.sql
# commit only the migration, but not the other files I'm working on
svn commit -m "migration notes" my_mygration.sql
</code></pre>
<p>and continue working locally.</p>
<p>This doesn't work with mercurial as when I'm pushing it out to the other repository, if there are changes to it that I haven't pulled down, it wants me to pull them down, merge them, and commit that merge to the repository. Commits after a merge don't allow you to omit files so it forces you to commit everything in your local repository.</p>
<p>The easiest thing that I can figure out is to commit the file to my local repository, clone my local repository, fetch any new changes from the actual repository, merge them and commit that merge, and them push my changes out.</p>
<pre><code>hg add my_migration.sql
hg commit -m "migration notes" my_migration.sql
cd ..
hg clone project project-clone
cd project-clone
hg fetch http://hg/project
hg push http://hg/project
</code></pre>
<p>This works, but it feels like I'm missing something easier, some way to tell mercurial to ignore the files already in my working directory, just do the merge and send the files along. I suspect mercurial queues can do this, but I don't fully grok mq yet.</p>
| [
{
"answer_id": 125301,
"author": "Josh Matthews",
"author_id": 3830,
"author_profile": "https://Stackoverflow.com/users/3830",
"pm_score": 6,
"selected": true,
"text": "hg shelve"
},
{
"answer_id": 569429,
"author": "Kobold",
"author_id": 36092,
"author_profile": "htt... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8912/"
] |
125,281 | <p>Given a string file path such as <code>/foo/fizzbuzz.bar</code>, how would I use bash to extract just the <code>fizzbuzz</code> portion of said string?</p>
| [
{
"answer_id": 125287,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 8,
"selected": false,
"text": "NAME=\"$(basename /foo/fizzbuzz.bar .bar)\"\n"
},
{
"answer_id": 125292,
"author": "Vinko Vrsalovic",
"author... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] |
125,306 | <p>I'm writing an iPhone app that takes a photo and then uploads it to a server. How do I upload a photo to a server with Cocoa? I suppose I use NSUrl somewhere.</p>
<p>Thanks!</p>
| [
{
"answer_id": 136516,
"author": "Jon Gilkison",
"author_id": 22428,
"author_profile": "https://Stackoverflow.com/users/22428",
"pm_score": 6,
"selected": false,
"text": "@interface EPUploader : NSObject {\n NSURL *serverURL;\n NSString *filePath;\n id delegate;\n SEL doneSel... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
125,313 | <p>I'm running programs from Eclipse (on Windows) that eat a lot of CPU time. To avoid bogging down my whole machine, I set the priority to Low with the Task Manager. However, this is a cumbersome manual process. Is there a way Eclipse can set this priority automatically?</p>
<p>EDIT: I realized that each particular launcher (Java, Python etc) has its own configuration method, so I will restrict this question to the Java domain, which is what I need most.</p>
| [
{
"answer_id": 129536,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 2,
"selected": false,
"text": "start /low"
},
{
"answer_id": 41046469,
"author": "George Forman",
"author_id": 2069400,
"author_... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9871/"
] |
125,314 | <p>Selenium Remote Control has a method of "get_html_source", which returns the source of the current page as a string.</p>
<p>AFAIK, this method works in all cases in Firefox and Safari. But when it's invoked in Internet Explorer, it returns an incorrect source.</p>
<p>Does anyone know if this is a bug with Selenium or Internet Explorer, and if there's a fix?</p>
| [
{
"answer_id": 125361,
"author": "Alan Storm",
"author_id": 4668,
"author_profile": "https://Stackoverflow.com/users/4668",
"pm_score": 2,
"selected": false,
"text": "onload=\"var oArea = document.createElement('textarea');oArea.rows=80;oArea.cols=80;oArea.value = document.getElementsByT... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21479/"
] |
125,319 | <p>I have been running <a href="http://en.wikipedia.org/wiki/StyleCop" rel="noreferrer">StyleCop</a> over some C# code, and it keeps reporting that my <code>using</code> directives should be inside the namespace.</p>
<p>Is there a technical reason for putting the <code>using</code> directives inside instead of outside the namespace?</p>
| [
{
"answer_id": 125330,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 8,
"selected": false,
"text": "using ThisNamespace.IsImported.InAllNamespaces.Here;\n\nnamespace Namespace1\n{ \n using ThisNamespace.IsImported.InNa... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4490/"
] |
125,333 | <p>I'm looking for the simplest, most straightforward way to implement the following:</p>
<ul>
<li>The main program instantiates worker
threads to do a task.</li>
<li>Only <code>n</code> tasks can be running at once.</li>
<li>When <code>n</code> is reached, no more workers
are started until the count of
running threads drops back below <code>n</code>.</li>
</ul>
| [
{
"answer_id": 125354,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 7,
"selected": true,
"text": " Collection<YourTask> tasks = new ArrayList<YourTask>();\n YourTask yt1 = new YourTask();\n ...\n tasks.add(yt1);\n ...... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/292/"
] |
125,341 | <p>Is there a simple out of the box way to impersonate a user in .NET?</p>
<p>So far I've been using <a href="http://www.codeproject.com/KB/cs/zetaimpersonator.aspx" rel="noreferrer">this class from code project</a> for all my impersonation requirements.</p>
<p>Is there a better way to do it by using .NET Framework?</p>
<p>I have a user credential set, (username, password, domain name) which represents the identity I need to impersonate.</p>
| [
{
"answer_id": 125364,
"author": "Esteban Araya",
"author_id": 781,
"author_profile": "https://Stackoverflow.com/users/781",
"pm_score": 4,
"selected": false,
"text": "using System.Security.Principal;\nusing(WindowsIdentity.GetCurrent().Impersonate())\n{\n //your code goes here\n}\n"... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1909/"
] |
125,359 | <p>In Java, web apps are bundled in to WARs. By default, many servlet containers will use the WAR name as the context name for the application.</p>
<p>Thus myapp.war gets deployed to <a href="http://example.com/myapp" rel="noreferrer">http://example.com/myapp</a>.</p>
<p>The problem is that the webapp considers its "root" to be, well, "root", or simply "/", whereas HTML would consider the root of your application to be "/myapp".</p>
<p>The Servlet API and JSP have facilities to help manage this. For example, if, in a servlet, you do: response.sendRedirect("/mypage.jsp"), the container will prepend the context and create the url: <a href="http://example.com/myapp/mypage.jsp" rel="noreferrer">http://example.com/myapp/mypage.jsp</a>".</p>
<p>However, you can't do that with, say, the IMG tag in HTML. If you do <img src="/myimage.gif"/> you will likely get a 404, because what you really wanted was "/myapp/myimage.gif".</p>
<p>Many frameworks have JSP tags that are context aware as well, and there are different ways of making correct URLs within JSP (none particularly elegantly).</p>
<p>It's a nitty problem for coders to jump in an out of when to use an "App Relative" url, vs an absolute url.</p>
<p>Finally, there's the issue of Javascript code that needs to create URLs on the fly, and embedded URLs within CSS (for background images and the like).</p>
<p>I'm curious what techniques others use to mitigate and work around this issue. Many simply punt and hard code it, either to server root or to whatever context they happen to be using. I already know that answer, that's not what I'm looking for.</p>
<p>What do you do?</p>
| [
{
"answer_id": 125420,
"author": "Swati",
"author_id": 12682,
"author_profile": "https://Stackoverflow.com/users/12682",
"pm_score": 0,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<paths>\n <path name=\"account\" parent=\"home\">Account/</path>\n <path n... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13663/"
] |
125,367 | <p>What are the advantages and limitations of dynamic type languages compared to static type languages?</p>
<p><strong>See also</strong>: <a href="https://stackoverflow.com/questions/42934/whats-with-the-love-of-dynamic-languages">whats with the love of dynamic languages</a> (a far more argumentative thread...)</p>
| [
{
"answer_id": 125538,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 7,
"selected": false,
"text": "PersistentVector"
},
{
"answer_id": 3185924,
"author": "Zorf",
"author_id": 2281094,
"author_prof... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11034/"
] |
125,369 | <p>I come across this problem when i am writing an event handler in SharePoint. My event handler has a web reference. When i create this web reference, the URL of the web service will be added in the .config file of the assembly. If i have to change the web reference URL i just have to change the link in the config file. </p>
<p>Problem comes when I try to GAC the dll. When i GAC the DLL, the config file cannot be GACed along with the dll, and hence, there is no way for me to update the web reference. </p>
<p>One workaround i have found is to modify the constructor method Reference.cs class which is autogenerated by visual studio when i add a reference, so that the constructor reads the web service url from some other location, say a registry or an XML file in some predetermined location. But this poses a problem sometimes, as when i update the web referenc using visual studio, this Reference.cs file gets regenerated, and all my modifications would be lost.</p>
<p>Is there a better way to solve this problem?</p>
| [
{
"answer_id": 125375,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 2,
"selected": true,
"text": "public partial class WebServiceReference\n { public WebServiceReference(ExampleConfigurationClass config) \n { /* ... ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1909/"
] |
125,389 | <p>I am writing a custom maven2 MOJO. I need to access the runtime configuration of another plugin, from this MOJO.</p>
<p>What is the best way to do this?</p>
| [
{
"answer_id": 130171,
"author": "Mike Deck",
"author_id": 1247,
"author_profile": "https://Stackoverflow.com/users/1247",
"pm_score": 0,
"selected": false,
"text": "<project>\n ...\n <properties>\n <foo>value</foo>\n </properties>\n ...\n</project>\n"
},
{
"answer_id": 13... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2767300/"
] |
125,394 | <p>I've seen several question on here about <a href="https://stackoverflow.com/questions/tagged/exception?sort=votes">exceptions</a>, and some of them hint at <a href="https://stackoverflow.com/search?s=interrupt+exception">interrupts as exceptions</a>, but none make the connection clear.</p>
<ul>
<li><p>What is an interrupt?</p></li>
<li><p>What is an exception? (please explain what exceptions are for each language you know, as there are some differences)</p></li>
<li><p>When is an exception an interrupt and vice-versa?</p></li>
</ul>
| [
{
"answer_id": 125417,
"author": "Ron Savage",
"author_id": 12476,
"author_profile": "https://Stackoverflow.com/users/12476",
"pm_score": 2,
"selected": false,
"text": "Try\n {\n ... various code steps that \"throw exceptions\" on error ...\n }\ncatch (exception e)\n {\n print ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] |
125,399 | <p>I have code that references a web service, and I'd like the address of that web service to be dynamic (read from a database, config file, etc.) so that it is easily changed. One major use of this will be to deploy to multiple environments where machine names and IP addresses are different. The web service signature will be the same across all deployments, just located elsewhere.</p>
<p>Maybe I've just been spoiled by the Visual Studio "Add Web Reference" wizard - seems like this should be something relatively easy, though.</p>
| [
{
"answer_id": 17343678,
"author": "John Kocktoasten",
"author_id": 2119931,
"author_profile": "https://Stackoverflow.com/users/2119931",
"pm_score": 3,
"selected": false,
"text": "// Web Service Wrapper to override constructor to use custom ConfigSection \n// app.config values for URL/U... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7623/"
] |
125,400 | <p>Not sure if this is possible or if I'm expressing correctly what I'm looking for, but I have the following piece of code in my library repeatedly and would like to practice some DRY.
I have set of SQL Server tables that I'm querying based on a simple user-supplied search field ala Google. I'm using LINQ to compose the final query based on what's in the search string. I'm looking for a way to use generics and passed in lambda functions to create a reusable routine out of this: </p>
<pre><code>string[] arrayOfQueryTerms = getsTheArray();
var somequery = from q in dataContext.MyTable
select q;
if (arrayOfQueryTerms.Length == 1)
{
somequery = somequery.Where<MyTableEntity>(
e => e.FieldName.StartsWith(arrayOfQueryTerms[0]));
}
else
{
foreach(string queryTerm in arrayOfQueryTerms)
{
if (!String.IsNullOrEmpty(queryTerm))
{
somequery = somequery
.Where<MyTableEntity>(
e => e.FieldName.Contains(queryTerm));
}
}
}
</code></pre>
<p>I was hoping to create a generic method with signature that looks something like:</p>
<pre><code>private IQueryable<T> getQuery(
T MyTableEntity, string[] arrayOfQueryTerms, Func<T, bool> predicate)
</code></pre>
<p>I'm using the same search strategy across all my tables, so the only thing that really differs from usage to usage is the MyTable & MyTableEntity searched and the FieldName searched. Does this make sense? Is there a way with LINQ to dynamically pass in the name of the field to query in the where clause? Or can I pass in this as a predicate lambda?</p>
<pre><code>e => e.FieldName.Contains(queryTerm)
</code></pre>
<p>I realize there a million and a half ways to do this in SQL, probably easier, but I'd love to keep everything in the LINQ family for this one. Also, I feel that generics should be handy for a problem like this. Any ideas?</p>
| [
{
"answer_id": 125418,
"author": "Erik Forbes",
"author_id": 16942,
"author_profile": "https://Stackoverflow.com/users/16942",
"pm_score": 5,
"selected": true,
"text": "var query = dataSource.Where(\"CategoryID == 2 && UnitPrice > 3\")\n .OrderBy(\"SupplierID\");\n"
... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17729/"
] |
125,449 | <p>I am using Excel where certain fields are allowed for user input and other cells are to be protected. I have used Tools Protect sheet, however after doing this I am not able to change the values in the VBA script. I need to restrict the sheet to stop user input, at the same time allow the VBA code to change the cell values based on certain computations.</p>
| [
{
"answer_id": 125505,
"author": "Kevin Crumley",
"author_id": 1818,
"author_profile": "https://Stackoverflow.com/users/1818",
"pm_score": 2,
"selected": false,
"text": "wksht.Unprotect()\n"
},
{
"answer_id": 126032,
"author": "Joe",
"author_id": 13087,
"author_profil... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17266/"
] |
125,457 | <p>If I need to copy a stored procedure (SP) from one SQL Server to another I right click on the SP in SSMS and select Script Stored Procedure as > CREATE to > New Query Editor Window. I then change the connection by right clicking on that window and selecting Connection > Change Connection... and then selecting the new server and F5 to run the create on the new server.</p>
<p>So my question is "What is the T-SQL syntax to connect to another SQL Server?" so that I can just paste that in the top of the create script and F5 to run it and it would switch to the new server and run the create script.</p>
<p>While typing the question I realized that if I gave you the back ground to what I'm trying to do that you might come up with a faster and better way from me to accomplish this.</p>
| [
{
"answer_id": 125472,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 5,
"selected": false,
"text": "USE master\nGO\nEXEC sp_addlinkedserver \n 'SEATTLESales',\n N'SQL Server'\nGO\n"
},
{
"answer_id": 12549... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] |
125,463 | <p>I'm developping a small UML Class editor in Java, mainly a personal project, it might end up on SourceForge if I find the time to create a project on it.</p>
<p>The project is quite advanced : I can create classes, move them around, create interfaces, create links, etc.</p>
<p>What I'm working on is the dialog box for setting class/interface properties and creating new classes/interfaces.</p>
<p>For example, I have a class that extends JDialog. This is the main "window" for editing classes and interfaces (well, there a class for each). It contains a JTabbedPane which in turn contain JPanels.</p>
<p>This JPanel are actually custom ones. I created an abstract class that extends JPanel. This class uses components (defined by its subclasses) and add their values to a JTable (also contained in the JPanel).</p>
<p>For example, if I want to edit a class' attributes, the JPanel will contain a JTextField for entering the name of the attribute as well as another one for entering its type. There is also a set of button for processing the data entered in these fields. When I click "Save", the data I entered in the JTextFields are added into the JTable (à la Enterprise Architect). The concreted class that extends the abstract one are responsible for defining control and deciding what do to with the data when a line is added or deleted from the JTable. The JTable management is, however, the responsability of the abstract class.</p>
<p>Here is my problem : in OO, a class has methods, and an interface has methods too. I told myself : I could use the same concrete custom JPanel (AttributesPanel (which extends the abstract JPanel class I created)) to store the methods for a class or and interface.</p>
<p>However, the class needs to keep a copy (as an attribute) of the class or interface I am working on. That way, when a method is added to it, I can call editedClass.addMethod() (or editedInterface.addMethod()). The problem is that I have no way of telling whether I work on a Class or and Interface.</p>
<p>The solution I found is ugly : keep an attribute editedClass and an attribute editedInterface in the AttributesPanel class. According to whether I am editing a class or interface, one of these attributes will be null while to other will not.</p>
<p>It is quite ugly if you ask me. In fact, I can hear my software engineering teachers in my head screaming in agony while burning (well, actually, freezing) in the ninth circle of Hell.</p>
<p>The quick way to fix this design problem would be to create an interface called "ObjectWithMethods", which my Class and Interface classes will implement. That way, I will only have to put an ObjectWithMethods parameter in my AttributesPanel class.</p>
<p>But does that mean that I should create a class named "ObjectWithAttributes", or "ObjectWithBlahBlah" ? I see some good "TheDailyWTF" potential here... Besides, I don't think I should modify my domain objects (a Class, Interface, Note, Relationship (for my UML editor)) or create an new Interface just for the sake of some UI consideration....</p>
<p>What do you think?</p>
<p>I you need more clarifications (because I am very tired right now and I tend to right quite badly (especially in English - my mother tongue is French) while in this state of mind...), just ask and I'll edit this question.</p>
<p>Cheers,</p>
<p>Guillaume.</p>
| [
{
"answer_id": 6549048,
"author": "Tair",
"author_id": 808237,
"author_profile": "https://Stackoverflow.com/users/808237",
"pm_score": 0,
"selected": false,
"text": "if( .. instanceof ..)"
},
{
"answer_id": 6551031,
"author": "umlcat",
"author_id": 535724,
"author_pro... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10687/"
] |
125,467 | <p>Using Rails v2.1, lets say you have an action for a controller that is accessible from more than one location. For example, within the Rails app, you have a link to edit a user from two different views, one on the users index view, and another from another view (lets say from the nav bar on every page).</p>
<p>I'm wondering what is the best way to redirect the user back to the right spot depending on what link they clicked on. For example:</p>
<p>Example 1:</p>
<ol>
<li>List all users</li>
<li>Click "edit" on a user in the list</li>
<li>User clicks "save" on the form, the controller redirects back to 1.</li>
</ol>
<p>Example 2:</p>
<ol>
<li>The user could be on any page within the application, the nav bar shows a link to edit the current user</li>
<li>The user clicks on the link to edit</li>
<li>The user clicks "save" on the form, controller redirects back to whatever page they were on when the user clicked the "edit" link in the nav bar.</li>
</ol>
<p>I've seen it done in the past by:</p>
<ol>
<li>Placing a parameter on the original edit link with the original controller/action in which the link appeared. To make this more DRY, you could use @controller.controller_name and @controller.action_name in a helper.</li>
<li>The controller saves the parameters to a session variable.</li>
<li>Once the controller has saved the record, it redirects to the session variable.</li>
</ol>
<p>What I don't particularly like about this solution is the need to add the parameter to every applicable link in the views. I'm wondering if there's a way to build this all into the controller.</p>
<p>One better way I was thinking was to:</p>
<ol>
<li>Place a before_filter on the "edit" action to save the referrer (is this reliable enough?) into the session.</li>
<li>When "update" is hit, the controller will redirect to the session variable and then delete the session variable.</li>
</ol>
<p>Any thoughts on the best way to do this?</p>
| [
{
"answer_id": 125988,
"author": "Patrick McKenzie",
"author_id": 15046,
"author_profile": "https://Stackoverflow.com/users/15046",
"pm_score": 2,
"selected": false,
"text": "#in edit controller\n...\nflash[:page_to_redirect_to] = request.referer || \"/my/default/path\"\n...\n\n#in save ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14530/"
] |
125,468 | <p>I have a repository of files which are unrelated to each other but are common to multiple projects. Each project might only need a subset of these files. For example:</p>
<pre><code>/myRepo:
/jquery.js
/jquery.form.js
/jquery.ui.js
</code></pre>
<p>Project A requires <code>jquery.js</code> and <code>jquery.form.js</code>, whereas Project B requires <code>jquery.js</code> and <code>jquery.ui.js</code></p>
<p>I could just do a checkout of <code>myRepo</code> into both projects, but that'd add a lot of unnecessary files into both. What I'd like is some sort of way for each Project to only get the files it needs. One way I thought it might be possible is if I put just the required files into each project and then run an <code>svn update</code> on it, but somehow stop SVN from adding new files to each directory. They'd still get the modifications to the existing files, but no unnecessary files would be added.</p>
<p>Is this possible at all?</p>
| [
{
"answer_id": 125525,
"author": "Jonathan Arkell",
"author_id": 11052,
"author_profile": "https://Stackoverflow.com/users/11052",
"pm_score": 1,
"selected": false,
"text": "find . -print | grep -v '\\.svn' | xargs svn update\n"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
125,470 | <p>I need to create a configuration section, that is able to store key-value pairs in an app.config file and the key-value pairs can be added runtime regardless of their type. It is also important that the value keeps its original type. I need to extend the following interface </p>
<pre><code>public interface IPreferencesBackend
{
bool TryGet<T>(string key, out T value);
bool TrySet<T>(string key, T value);
}
</code></pre>
<p>At runtime, I can say something like: </p>
<pre><code>My.Foo.Data data = new My.Foo.Data("blabla");
Pref pref = new Preferences();
pref.TrySet("foo.data", data);
pref.Save();
My.Foo.Data date = new My.Foo.Data();
pref.TryGet("foo.data", out data);
</code></pre>
<p>I tried with System.Configuration.Configuration.AppSettings, but the problem with that that it is storing the key-value pairs in a string array. </p>
<p>What I need is to have an implementation of System.Configuration.ConfigurationSection, where I can control the how the individual setting is serialized. I noticed that the settings generated by Visual Studio kind of do this. It is using reflection to create all the setting keys. what I need is to do this runtime and dynamically. </p>
<pre><code>[System.Configuration.UserScopedSettingAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.Configuration.DefaultSettingValueAttribute("2008-09-24")]
public global::System.DateTime DateTime {
get {
return ((global::System.DateTime)(this["DateTime"]));
}
set {
this["DateTime"] = value;
}
}
</code></pre>
| [
{
"answer_id": 125490,
"author": "Ron Savage",
"author_id": 12476,
"author_profile": "https://Stackoverflow.com/users/12476",
"pm_score": 1,
"selected": false,
"text": "<key=\"myParam\" value=\"type, value\" />\n"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260/"
] |
125,496 | <p>On my rails app I have a list of items (like a task list) and for each item there is a couple of check box to set parameters.</p>
<p>When I submit the form, the checked box are stored as zero and the unchecked as null on DB. </p>
<p>the question is: Is there a way to configure it? To store the data on a more traditional 0 or 1, because I think that storing null as false and 0 as true is a bit confusing, specially if another app (like a C app) needs to read the data.</p>
| [
{
"answer_id": 127702,
"author": "Yardboy",
"author_id": 9550,
"author_profile": "https://Stackoverflow.com/users/9550",
"pm_score": 3,
"selected": true,
"text": "club_member"
},
{
"answer_id": 2599922,
"author": "Fabian ",
"author_id": 311894,
"author_profile": "http... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/440867/"
] |
125,512 | <p>In my rails app I use the validation helpers in my active record objects and they are great. When there is a problem I see the standard "3 errors prohibited this foobar from being saved" on my web page along with the individual problems. </p>
<p>Is there any way I can override this default message with my own?</p>
| [
{
"answer_id": 125563,
"author": "Toby Hede",
"author_id": 14971,
"author_profile": "https://Stackoverflow.com/users/14971",
"pm_score": 1,
"selected": false,
"text": "<% if(!@model.errors.empty?) %>\n<div id=\"error_message\"> \n <h2>\n <%= image_tag(\"error.png\", :align => ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16779/"
] |
125,523 | <p>Is it possible to use an attribute of a child to group a query?</p>
<pre><code>Post.find(:all, :include => [ :authors, :comments ], :group=>'authors.city')
</code></pre>
<p>does not work. </p>
<p>However, I am able to use <code>author.city</code> as part of the conditions.</p>
| [
{
"answer_id": 125537,
"author": "Terry G Lorber",
"author_id": 809,
"author_profile": "https://Stackoverflow.com/users/809",
"pm_score": 1,
"selected": false,
"text": "Post.find(:all, :include => [ :author, :comments ], :group=>'authors.city')\n"
},
{
"answer_id": 126677,
"a... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1227001/"
] |
125,536 | <p>I want to add a constant value onto an incoming bound integer. In fact I have several places where I want to bind to the same source value but add different constants. So the ideal solution would be something like this...</p>
<pre><code><TextBox Canvas.Top="{Binding ElementName=mySource, Path=myInt, Constant=5}"/>
<TextBox Canvas.Top="{Binding ElementName=mySource, Path=myInt, Constant=8}"/>
<TextBox Canvas.Top="{Binding ElementName=mySource, Path=myInt, Constant=24}"/>
</code></pre>
<p>(NOTE: This is an example to show the idea, my actual binding scenario is not to the canvas property of a TextBox. But this shows the idea more clearly) </p>
<p>At the moment the only solution I can think of is to expose many different source properties each of which adds on a different constant to the same internal value. So I could do something like this...</p>
<pre><code><TextBox Canvas.Top="{Binding ElementName=mySource, Path=myIntPlus5}"/>
<TextBox Canvas.Top="{Binding ElementName=mySource, Path=myIntPlus8}"/>
<TextBox Canvas.Top="{Binding ElementName=mySource, Path=myIntPlus24}"/>
</code></pre>
<p>But this is pretty grim because in the future I might need to keep adding new properties for new constants. Also if I need to change the value added I need to go an alter the source object which is pretty naff. </p>
<p>There must be a more generic way than this? Any WPF experts got any ideas?</p>
| [
{
"answer_id": 125592,
"author": "billjamesdev",
"author_id": 13824,
"author_profile": "https://Stackoverflow.com/users/13824",
"pm_score": 0,
"selected": false,
"text": "public Integer get( Integer key ) { return baseInt + key; } // or some such\n"
},
{
"answer_id": 126483,
... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6276/"
] |
125,541 | <p><a href="https://stackoverflow.com/questions/63938/how-do-i-show-data-in-the-header-of-a-sql-2005-reporting-services-report">This question</a> was very helpful, however I have a list control in my report, and when the report grows over 1 page, data in the header only shows up on the last page of the report.</p>
<p>Apparently, hidden textboxes have to be on every page of the report for header to function properly. How do I do that? The only control I have in the list is a textbox with bunch of text that grows way over 1 page.</p>
| [
{
"answer_id": 1123865,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "=Parameters!Footer.Value"
},
{
"answer_id": 6177284,
"author": "mon",
"author_id": 776379,
"author_profil... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3661/"
] |
125,557 | <p>In a tic-tac-toe implementation I guess that the challenging part is to determine the best move to be played by the machine.</p>
<p>What are the algorithms that can pursued? I'm looking into implementations from simple to complex. How would I go about tackling this part of the problem?</p>
| [
{
"answer_id": 11476076,
"author": "Kaushik",
"author_id": 1524317,
"author_profile": "https://Stackoverflow.com/users/1524317",
"pm_score": 3,
"selected": false,
"text": "board[5]=2"
},
{
"answer_id": 48128230,
"author": "Ben Carp",
"author_id": 7224430,
"author_prof... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19790/"
] |
125,570 | <p>I am actually working on SP in SQL 2005. Using SP i am creating a job and am scheduling it for a particular time. These jobs take atleast 5 to 10 min to complete as the database is very huge. But I am not aware of how to check the status of the Job. I want to know if it has got completed successfully or was there any error in execution. On exception i also return proper error code. But i am not aware of where i can check for this error code.</p>
| [
{
"answer_id": 125738,
"author": "Philip Fourie",
"author_id": 11123,
"author_profile": "https://Stackoverflow.com/users/11123",
"pm_score": 3,
"selected": true,
"text": " exec msdb.dbo.sp_help_jobactivity @job_id = (your job_id here)\n"
},
{
"answer_id": 1497976,
"author": ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20951/"
] |
125,577 | <p>I open a connection like this:</p>
<pre><code>Using conn as New OdbcConnection(connectionString)
conn.Open()
//do stuff
End Using
</code></pre>
<p>If connection pooling is enabled, the connection is not physically closed but released to the pool and will get reused. If it is disabled, it will be physically closed.</p>
<p>Is there any way of knowing <strong>programmatically</strong> <em>if</em> connection pooling is enabled or not? and the number of used and unused connections currently open in the pool?</p>
<p><strong>EDIT:</strong> I need to get this information from within the program, I can't go and check it manually on every single PC where the program will be deployed.</p>
| [
{
"answer_id": 838566,
"author": "Anand",
"author_id": 57817,
"author_profile": "https://Stackoverflow.com/users/57817",
"pm_score": 0,
"selected": false,
"text": "select db_name(dbid) , count(*) 'connections count'\n from master..sysprocesses\n where spid > 50 and spid @@spid\n group... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10786/"
] |
125,606 | <p>I'm working on a C#/ASP.NET web application, and I have a number of situations where I need to do locking. Ideally, I want the locks to act independently, since they have nothing to do with each other. I've been considering <code>[MethodImpl(MethodImplOptions.Synchronized)]</code> and a few ways of using <code>lock()</code>, but I have a few questions/concerns. </p>
<p>It seems like MethodImplOptions.Synchronized<code>will essentially do</code>lock(this)`. If that's the case, it seems like a thread entering any synchronized method would block <em>all other</em> threads from entering <em>any</em> synchronized method. Is that right? If so, this isn't granular enough. At that point, it seems like I may as well use Application.Lock. (But please correct me if I'm wrong.)</p>
<p>Concerning <code>lock()</code>, I'm trying to figure out what I should pass in. Should I create a set of objects solely for this purpose, and use each one for a different lock? Is there a better way?</p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 125622,
"author": "Hamish Smith",
"author_id": 15572,
"author_profile": "https://Stackoverflow.com/users/15572",
"pm_score": 2,
"selected": false,
"text": "private object lockForSomeResource = new object();\n"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13348/"
] |
125,610 | <p>Ok, my web application is at <strong>C:\inetpub\wwwroot\website</strong></p>
<p>The files I want to link to are in <strong>S:\someFolder</strong></p>
<p>Can I make a link in the webapp that will direct to the file in <strong>someFolder</strong>?</p>
| [
{
"answer_id": 125611,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 4,
"selected": true,
"text": "/virtdirect/somefolder/"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14777/"
] |
125,612 | <p>I have a menu running off of a sitemap which one of the SiteMapNode looks like this: </p>
<pre><code><siteMapNode title="Gear" description="" url="">
<siteMapNode title="Armor" description="" url="~/Armor.aspx" />
<siteMapNode title="Weapons" description="" url="~/Weapons.aspx" />
</siteMapNode>
</code></pre>
<p>I also have a Skin applied to the asp:menu which uses the following css definition:</p>
<pre><code>.nav-bar {
z-index: 2;
margin-top: -5%;
position: absolute;
top: 281px;
font-family: Jokewood;
font-style: italic;
}
</code></pre>
<p>When I run the website and mouseOver the Gear link, the Jokewood font is not applied to those items, how can I apply the css to the Armor and Weapons titles?</p>
<p><strong>Update</strong><br>
I should of mentioned that the font is displayed correctly on all non-nested siteMapNodes.</p>
| [
{
"answer_id": 125706,
"author": "Alexander Prokofyev",
"author_id": 11256,
"author_profile": "https://Stackoverflow.com/users/11256",
"pm_score": 1,
"selected": true,
"text": "<asp:Menu ID=\"Menu1\" runat=\"server\" >\n <StaticMenuStyle CssClass=\"nav-bar\" />\n <DynamicMenuStyle ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4298/"
] |
125,619 | <p>I'm working on an app that requires no user input, but I don't want the iPhone to enter the power saving mode.</p>
<p>Is it possible to disable power saving from an app?</p>
| [
{
"answer_id": 125645,
"author": "lajos",
"author_id": 3740,
"author_profile": "https://Stackoverflow.com/users/3740",
"pm_score": 9,
"selected": true,
"text": "[[UIApplication sharedApplication] setIdleTimerDisabled:YES];\n"
},
{
"answer_id": 29295059,
"author": "Vettiyanaka... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3740/"
] |
125,620 | <p>I'm trying to put several images together into one big image, and am looking for an algorithm which determines the placing most optimally. The images can't be rotated or resized, but the position in the resulting image is not important.</p>
<p>edit: added no resize constraint</p>
| [
{
"answer_id": 125952,
"author": "Davy Landman",
"author_id": 11098,
"author_profile": "https://Stackoverflow.com/users/11098",
"pm_score": 1,
"selected": false,
"text": "Images: array of the input images\nResultMap: 2d array of Booleans\nFinalImage: large image\n"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3197/"
] |
125,627 | <p>I want to call a web service, but I won't know the url till runtime.</p>
<p>Whats the best way to get the web reference in, without actually committing to a url.</p>
<p>What about having 1 client hit the same web service on say 10 different domains?</p>
| [
{
"answer_id": 125637,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "service = new MyWebService.MyWebService();\nservice.Url = myWebServiceUrl;\n"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1220/"
] |
125,632 | <p>When providing a link to a PDF file on a website, is it possible to include information in the URL (request parameters) which will make the PDF browser plugin (if used) jump to a particular bookmark instead of just opening at the beginning?</p>
<p>Something like: <a href="http://www.somehost.com/user-guide.pdf?bookmark=chapter3" rel="noreferrer">http://www.somehost.com/user-guide.pdf?bookmark=chapter3</a> ?</p>
<p>If not a bookmark, would it be possible to go to a particular page?</p>
<p>I'm assuming that if there is an answer it may be specific to Adobe's PDF reader plugin or something, and may have version limitations, but I'm mostly interested in whether the technique exists at all.</p>
| [
{
"answer_id": 125650,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 7,
"selected": true,
"text": "<a href=\"http://www.domain.com/file.pdf#page=3\">Link text</a>\n"
},
{
"answer_id": 38049428,
"author": "Matas Vai... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1119/"
] |
125,638 | <p>At run time I want to dynamically build grid columns (or another display layout) in a WPF ListView. I do not know the number and names of the columns before hand.</p>
<p>I want to be able to do:<br/>
MyListView.ItemSource = MyDataset;<br/>
MyListView.CreateColumns();</p>
| [
{
"answer_id": 128093,
"author": "Greg",
"author_id": 11013,
"author_profile": "https://Stackoverflow.com/users/11013",
"pm_score": 2,
"selected": true,
"text": " <Style TargetType=\"{x:Type GridViewColumnHeader}\" x:Key=\"gridViewColumnStyle\">\n <EventSetter Event=\"C... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5189/"
] |
125,663 | <p>I've been reading the legacy code,which invloves in the customized memory pooling system, then I found that the code uses _aligned_malloc. I wonder what is this function and when do I have to use it. </p>
<hr>
<p>Thanks all of you. </p>
<p>I did read MSDN but what I wanted was the answer like "An example of a reason for wanting a certain alignment is to use the data with the SSE instruction set on x86 where the data must be aligned to a multiple 16".</p>
<p>I finally understood what those code means. thanks again.</p>
| [
{
"answer_id": 125705,
"author": "Viktor",
"author_id": 17424,
"author_profile": "https://Stackoverflow.com/users/17424",
"pm_score": 4,
"selected": false,
"text": "((unsigned int)ptr) % alignment"
},
{
"answer_id": 14069095,
"author": "Community",
"author_id": -1,
"a... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15189/"
] |
125,664 | <p>How do I write a program that tells when my other program ends?</p>
| [
{
"answer_id": 125698,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 4,
"selected": false,
"text": "#include <sys/ptrace.h>\n#include <errno.h>\n#include <stdio.h>\n#include <signal.h>\n#include <unistd.h>\n#include <sys/wai... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
125,677 | <p>So I'm writing a framework on which I want to base a few apps that I'm working on (the framework is there so I have an environment to work with, and a system that will let me, for example, use a single sign-on)</p>
<p>I want to make this framework, and the apps it has use a Resource Oriented Architecture.</p>
<p>Now, I want to create a URL routing class that is expandable by APP writers (and possibly also by CMS App users, but that's WAYYYY ahead in the future) and I'm trying to figure out the best way to do it by looking at how other apps do it.</p>
| [
{
"answer_id": 125799,
"author": "Mez",
"author_id": 20010,
"author_profile": "https://Stackoverflow.com/users/20010",
"pm_score": 1,
"selected": false,
"text": "^/users/[\\w-]+/bookmarks/(.+)/$\n^/users/[\\w-]+/bookmarks/$\n^/users/[\\w-]+/$\n"
},
{
"answer_id": 127196,
"aut... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20010/"
] |
125,703 | <p>I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that?</p>
| [
{
"answer_id": 125713,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 7,
"selected": false,
"text": " with open(\"foo.txt\", \"a\") as f:\n f.write(\"new line\\n\")\n"
},
{
"answer_id": 126389,
"autho... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
125,711 | <p>I would like to know your experience when you need to take over somebody else's software project - more so when the original software developer has already resigned.</p>
| [
{
"answer_id": 126414,
"author": "Manrico Corazzi",
"author_id": 4690,
"author_profile": "https://Stackoverflow.com/users/4690",
"pm_score": 2,
"selected": false,
"text": "List<Stuff> stuff = null; \nif (LOG.isDebugEnabled())\n{\n stuff = findStuff();\n LOG.debug(\"Yeah, I'm a smar... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10923/"
] |
125,719 | <p>Is there any way to edit column names in a DataGridView?</p>
| [
{
"answer_id": 125731,
"author": "VVS",
"author_id": 21038,
"author_profile": "https://Stackoverflow.com/users/21038",
"pm_score": 2,
"selected": false,
"text": "myDataGrid.TableStyles[0].GridColumnStyles[0].HeaderText = \"My Header\"\n"
},
{
"answer_id": 125758,
"author": "m... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11137/"
] |
125,726 | <p>Has anyone any reources for learning how to implement SVG with php/mysql (and possibly with php-gtk)? I am thinking of making a top-down garden designer, with drag and drop predefined elements (such as trees/bushes) and definable areas of planting (circles/squares). Gardeners could then track over time how well planting did in a certain area.</p>
<p>I don´t really want to get into flash... </p>
| [
{
"answer_id": 125731,
"author": "VVS",
"author_id": 21038,
"author_profile": "https://Stackoverflow.com/users/21038",
"pm_score": 2,
"selected": false,
"text": "myDataGrid.TableStyles[0].GridColumnStyles[0].HeaderText = \"My Header\"\n"
},
{
"answer_id": 125758,
"author": "m... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
125,730 | <p>Why do I get following error when trying to start a ruby on rails application with <pre>mongrel_rails start</pre>?</p>
<pre>
C:\RailsTest\cookbook2>mongrel_rails start
** WARNING: Win32 does not support daemon mode.
** Daemonized, any open files are closed. Look at log/mongrel.pid and log/mongr
el.log for info.
** Starting Mongrel listening at 0.0.0.0:3000
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/../lib/mongrel/t
cphack.rb:12:in `initialize_without_backlog': Only one usage of each socket addr
ess (protocol/network address/port) is normally permitted. - bind(2) (Errno::EAD
DRINUSE)
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/../
lib/mongrel/tcphack.rb:12:in `initialize'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/../
lib/mongrel.rb:93:in `new'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/../
lib/mongrel.rb:93:in `initialize'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/../
lib/mongrel/configurator.rb:139:in `new'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/../
lib/mongrel/configurator.rb:139:in `listener'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/mon
grel_rails:99:in `cloaker_'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/../
lib/mongrel/configurator.rb:50:in `call'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/../
lib/mongrel/configurator.rb:50:in `initialize'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/mon
grel_rails:84:in `new'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/mon
grel_rails:84:in `run'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/../
lib/mongrel/command.rb:212:in `run'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/mon
grel_rails:281
from c:/ruby/bin/mongrel_rails:19:in `load'
from c:/ruby/bin/mongrel_rails:19
</pre>
| [
{
"answer_id": 126769,
"author": "Dave Nolan",
"author_id": 9474,
"author_profile": "https://Stackoverflow.com/users/9474",
"pm_score": 3,
"selected": true,
"text": "mongrel_rails start -p 3001\n"
}
] | 2008/09/24 | [
"https://Stackoverflow.com/questions/125730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14027/"
] |
125,735 | <p>I'm using the following code for setting/getting deleting cookies:</p>
<pre><code>function get_cookie(cookie_name)
{
var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
if (results)
return ( decodeURI(results[2]) );
else
return null;
}
function set_cookie(name, value, exp_y, exp_m, exp_d, path, domain, secure)
{
var cookie_string = name + "=" + encodeURI(value);
if (exp_y)
{
var expires = new Date(exp_y, exp_m, exp_d);
cookie_string += "; expires=" + expires.toGMTString();
}
if (path)
cookie_string += "; path=" + encodeURI(path);
if (domain)
cookie_string += "; domain=" + encodeURI(domain);
if (secure)
cookie_string += "; secure";
document.cookie = cookie_string;
}
function delete_cookie(cookie_name)
{
var cookie_date = new Date(); // current date & time
cookie_date.setTime(cookie_date.getTime() - 1);
document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}
</code></pre>
<p>but i am getting inconsistent results.
for example, a cookie set on the startpage (www.example.com/start) , will not always show up on a subsequent page (www.example.com/foo/thing.jsp).
i am setting a cookie "onUnload" of the page using </p>
<pre><code>set_cookie("beginrequest", (new Date()).getTime(), null, null, null, "/");
</code></pre>
<p>and retrieving + deleting it "onLoad" via </p>
<pre><code>loadDur = (new Date()).getTime() - get_cookie("beginrequest");
delete_cookie("beginrequest");
</code></pre>
<p>to measure the total amount of time the page took to load.</p>
<p>when using firebug, i often see "leftover" beginrequest-cookies and multiple instances of beginrequest with past timestamps.</p>
<p>how can i achieve to see just one beginrequest-cookie on every page?</p>
| [
{
"answer_id": 126265,
"author": "Daniel James",
"author_id": 2434,
"author_profile": "https://Stackoverflow.com/users/2434",
"pm_score": 1,
"selected": false,
"text": "var deleted_cookie = false;\nfunction delete_timestamp() {\n if(!deleted_cookie) delete_cookie(\"beginrequest\");\n ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16542/"
] |
125,756 | <p>I'm looking for a way to set the default language for visitors comming to a site built in EPiServer for the first time. Not just administrators/editors in the backend, people comming to the public site.</p>
| [
{
"answer_id": 126318,
"author": "user19264",
"author_id": 19264,
"author_profile": "https://Stackoverflow.com/users/19264",
"pm_score": 3,
"selected": true,
"text": "<sectionGroup name=\"episerver\">\n <section name=\"domainLanguageMappings\" allowDefinition=\"MachineToApplication\" al... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/452521/"
] |
125,785 | <p>I need a function written in Excel VBA that will hash passwords using a standard algorithm such as SHA-1. Something with a simple interface like:</p>
<pre><code>Public Function CreateHash(Value As String) As String
...
End Function
</code></pre>
<p>The function needs to work on an XP workstation with Excel 2003 installed, but otherwise must use no third party components. It can reference and use DLLs that are available with XP, such as CryptoAPI. </p>
<p>Does anyone know of a sample to achieve this hashing functionality?</p>
| [
{
"answer_id": 482150,
"author": "Chris",
"author_id": 59198,
"author_profile": "https://Stackoverflow.com/users/59198",
"pm_score": 6,
"selected": false,
"text": "' Based on: http://vb.wikia.com/wiki/SHA-1.bas\nOption Explicit\n\nPrivate Type FourBytes\n A As Byte\n B As Byte\n ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13087/"
] |
125,806 | <p>First, yes I know about <a href="https://stackoverflow.com/questions/50182/linuxx11-input-library-without-creating-a-window">this question</a>, but I'm looking for a bit more information that that. I have actually, a fairly similar problem, in that I need to be able to capture input for mouse/keyboard/joystick, and I'd also like to avoid SDL if at all possible. I was more or less wondering if anyone knows where I can get some decent primers on handling input from devices in Linux, perhaps even some tutorials. SDL works great for cross-platform input handling, but I'm not going to be using anything else at all from SDL, so I'd like to cut it out altogether. Suggestion, comments, and help are all appreciated. Thanks!</p>
<p>Edit for clarity:</p>
<p>The point is to capture mouse motion, keyboard press/release, mouse clicks, and potentially joystick handling for a game.</p>
| [
{
"answer_id": 125935,
"author": "skymt",
"author_id": 18370,
"author_profile": "https://Stackoverflow.com/users/18370",
"pm_score": 2,
"selected": false,
"text": "Documentation/input/input.txt"
},
{
"answer_id": 128327,
"author": "KPexEA",
"author_id": 13676,
"author... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14838/"
] |
125,812 | <p>I am investigating the design of a work queue processor where the QueueProcessor retrieves a Command Pattern object from the Queue and executes it in a new thread.</p>
<p>I am trying to get my head around a potential Queue lockup scenario where nested Commands may result in a deadlock.</p>
<p>E.G.</p>
<p>A FooCommand object is placed onto the queue which the QueueProcessor then executes in its own thread.</p>
<p>The executing FooCommand places a BarCommand onto the queue.</p>
<p>Assuming that the maximum allowed threads was only 1 thread, the QueueProcessor would be in a deadlocked state since the FooCommand is infinitely waiting for the BarCommand to complete.</p>
<p>How can this situation be managed? Is a queue object the right object for the job? Are there any checks and balances that can be put into place to resolve this issue?</p>
<p>Many thanks. ( application uses C# .NET 3.0 )</p>
| [
{
"answer_id": 125940,
"author": "mancaus",
"author_id": 13797,
"author_profile": "https://Stackoverflow.com/users/13797",
"pm_score": 1,
"selected": false,
"text": "\npublic void FooCommand()\n{\n Future<int> BarFuture = new Future<int>( () => BarCommand() );\n\n // Do Foo's Proce... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14515/"
] |
125,813 | <p>How can I tell in JavaScript what path separator is used in the OS where the script is running?</p>
| [
{
"answer_id": 15035489,
"author": "t98907",
"author_id": 1906218,
"author_profile": "https://Stackoverflow.com/users/1906218",
"pm_score": 8,
"selected": false,
"text": "path"
},
{
"answer_id": 35246221,
"author": "Decoded",
"author_id": 2030601,
"author_profile": "h... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
125,828 | <p>I'm trying to start an external application through <code>system()</code> - for example, <code>system("ls")</code>. I would like to capture its output as it happens so I can send it to another function for further processing. What's the best way to do that in C/C++?</p>
| [
{
"answer_id": 125856,
"author": "wnoise",
"author_id": 15464,
"author_profile": "https://Stackoverflow.com/users/15464",
"pm_score": 3,
"selected": false,
"text": "FILE *output = popen(\"ls\", \"r\");\n"
},
{
"answer_id": 125859,
"author": "jkramer",
"author_id": 12523,
... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10010/"
] |
125,850 | <p>I have this RewriteRule that works too well :-)</p>
<pre><code>RewriteRule ^([^/]*)/$ /script.html?id=$1 [L]
</code></pre>
<p>The bad thing about this rule is that it also matches physical directories which I don't want.</p>
<p>How can I tell the <code>mod_rewrite</code> to ignore physical directories and apply the above rule only when the directory matched does not exist?</p>
| [
{
"answer_id": 125864,
"author": "ctcherry",
"author_id": 10322,
"author_profile": "https://Stackoverflow.com/users/10322",
"pm_score": 3,
"selected": true,
"text": "RewriteCond %{REQUEST_FILENAME} !-d\nRewriteCond %{REQUEST_FILENAME} !-f\n"
},
{
"answer_id": 125886,
"author"... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
125,857 | <p>Having a problem getting a TreeView control to display node images. The code below works sometimes but fails to show any image at other times.</p>
<pre><code>
private TreeNode AddNodeForCore(TreeNode root, Core c) {
string key = GetImageKey(c);
TreeNode t = root.Nodes.Add(c.Name, c.Name, key, key);
t.Tag = c;
return t;
}
</code></pre>
<p>Note that when it fails, the TreeView fails to show any images for any node. The TreeView does have an ImageList assigned to it, and the image key is definitely in the images collection.</p>
<p>Edit:<br>
My google-fu is weak. Can't believe I didn't find that answer myself.</p>
| [
{
"answer_id": 125871,
"author": "VVS",
"author_id": 21038,
"author_profile": "https://Stackoverflow.com/users/21038",
"pm_score": 2,
"selected": false,
"text": "public partial class ThisApplication\n{\n Form1 frm;\n\n private void ThisApplication_Startup(object sender, System.Even... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1389021/"
] |
125,875 | <p>I need to change the credentials of an already existing Windows service using C#. I am aware of two different ways of doing this.</p>
<ol>
<li>ChangeServiceConfig, see <a href="http://www.pinvoke.net/default.aspx/advapi32.ChangeServiceConfig" rel="nofollow noreferrer">ChangeServiceConfig on pinvoke.net</a></li>
<li>ManagementObject.InvokeMethod using Change as the method name.</li>
</ol>
<p>Neither seems a very "friendly" way of doing this and I was wondering if I am missing another and better way to do this.</p>
| [
{
"answer_id": 126549,
"author": "Magnus Johansson",
"author_id": 3584,
"author_profile": "https://Stackoverflow.com/users/3584",
"pm_score": 3,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Management;\n\nnamespace Service... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19676/"
] |
125,877 | <p>(Not related to versioning the database schema)</p>
<p>Applications that interfaces with databases often have domain objects that are composed with data from many tables. Suppose the application were to support versioning, in the sense of CVS, for these domain objects.</p>
<p>For some arbitry domain object, how would you design a database schema to handle this requirement? Any experience to share?</p>
| [
{
"answer_id": 125900,
"author": "Jim T",
"author_id": 7298,
"author_profile": "https://Stackoverflow.com/users/7298",
"pm_score": 4,
"selected": false,
"text": "|Name|D.O.B |Telephone|From|To |\n|Fred|1 april|555-29384|1 |NULL|\n"
},
{
"answer_id": 3465824,
"author": "de... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13251/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.