qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
455,659 | <p>In order to implement Logging using Spring AOP I followed these simple steps. But it seems like its not working. Any help would be useful</p>
<p>1) Created <strong>MyLoggingAspect</strong> class</p>
<pre><code> import org.aspectj.lang.ProceedingJoinPoint;
public class MyLoggingAspect
{
public MyLoggingAsp... | [
{
"answer_id": 455855,
"author": "Scott Bale",
"author_id": 2495576,
"author_profile": "https://Stackoverflow.com/users/2495576",
"pm_score": 5,
"selected": true,
"text": "<p>I'm just inspecting your code, but I have a hunch the problem is that you're not getting your <code>TixServiceImp... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325613/"
] | In order to implement Logging using Spring AOP I followed these simple steps. But it seems like its not working. Any help would be useful
1) Created **MyLoggingAspect** class
```
import org.aspectj.lang.ProceedingJoinPoint;
public class MyLoggingAspect
{
public MyLoggingAspect() {
super();
S... | I'm just inspecting your code, but I have a hunch the problem is that you're not getting your `TixServiceImpl` instance from Spring, but rather you're manually instantiating it yourself in your `TixClient`. I'm thinking your `TixService` needs to be a Spring bean, gotten from the Spring ApplicationContext, so that Spri... |
455,672 | <p>I have a form which needs to populate 2 models. Normally I use a ModelBinderAttribute on the forms post action i.e.</p>
<pre><code> [Authorize]
[AcceptVerbs("POST")]
public ActionResult Add([GigBinderAttribute]Gig gig, FormCollection formCollection)
{
///Do stuff
}
</code></pre>
<p>In my ... | [
{
"answer_id": 456028,
"author": "Odd",
"author_id": 11908,
"author_profile": "https://Stackoverflow.com/users/11908",
"pm_score": 0,
"selected": false,
"text": "<p>The UpdateModel or TryUpdateModel method can be used to do this. You can pass through the model, the model you wish to bin... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46616/"
] | I have a form which needs to populate 2 models. Normally I use a ModelBinderAttribute on the forms post action i.e.
```
[Authorize]
[AcceptVerbs("POST")]
public ActionResult Add([GigBinderAttribute]Gig gig, FormCollection formCollection)
{
///Do stuff
}
```
In my form, the fields are named... | Actually... the best way is to do this:
```
public ActionResult Add([GigBinderAttribute]Gig gig, [FileModelBinderAttribute]File file) {
```
}
You CAN use multiple attributes! |
455,687 | <p>It seems COM objects are general use objects which are governed by the OS. The objects follow a strict interface and allow you to query the objects to determine information. Is this what COM objects are?</p>
| [
{
"answer_id": 455746,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 5,
"selected": false,
"text": "<p>COM is a mechanism that was developed to allow people to distribute binaries that could be reused even if the caller was u... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It seems COM objects are general use objects which are governed by the OS. The objects follow a strict interface and allow you to query the objects to determine information. Is this what COM objects are? | [COM](http://en.wikipedia.org/wiki/Component_Object_Model) is a mechanism that allows the re-use of objects (or rather components), independently of the languages used by the programmer who implemented the component and the programmer who uses it, and independently of whether the component was implemented in the client... |
455,695 | <pre><code>BufferedReader in;
String line;
while ((line = in.readLine() != null) {
processor.doStuffWith(line);
}
</code></pre>
<p>This is how I would process a file line-by-line. In this case, however, I want to send <strong>two</strong> lines of text to the processor in every iteration. (The text file I'm proce... | [
{
"answer_id": 455707,
"author": "martinus",
"author_id": 48181,
"author_profile": "https://Stackoverflow.com/users/48181",
"pm_score": 5,
"selected": true,
"text": "<p>Why not just read two lines?</p>\n\n<pre><code>BufferedReader in;\nString line;\nwhile ((line = in.readLine() != null) ... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29173/"
] | ```
BufferedReader in;
String line;
while ((line = in.readLine() != null) {
processor.doStuffWith(line);
}
```
This is how I would process a file line-by-line. In this case, however, I want to send **two** lines of text to the processor in every iteration. (The text file I'm processing essentially stores one rec... | Why not just read two lines?
```
BufferedReader in;
String line;
while ((line = in.readLine() != null) {
processor.doStuffWith(line, in.readLine());
}
```
This assumes that you can rely on having full 2-line data sets in your input file. |
455,700 | <p>We have two PHP5 objects and would like to merge the content of one into the second. There are no notion of subclasses between them so the solutions described in the following topic cannot apply.</p>
<p><a href="https://stackoverflow.com/questions/119281/how-do-you-copy-a-php-object-into-a-different-object-type">Ho... | [
{
"answer_id": 455735,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 5,
"selected": false,
"text": "<p>You could create another object that dispatches calls to magic methods to the underlying objects. Here's how you... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11670/"
] | We have two PHP5 objects and would like to merge the content of one into the second. There are no notion of subclasses between them so the solutions described in the following topic cannot apply.
[How do you copy a PHP object into a different object type](https://stackoverflow.com/questions/119281/how-do-you-copy-a-ph... | >
> If your objects only contain fields (no methods), this works:
>
>
>
```
$obj_merged = (object) array_merge((array) $obj1, (array) $obj2);
```
This actually also works when objects have methods. (tested with PHP 5.3 and 5.6) |
455,712 | <p>The environment: I am working in a proprietary scripting language where there is no such thing as a user-defined function. I have various loops and local variables of primitive types that I can create and use.</p>
<p>I have two related arrays, "times" and "values". They both contain floating point values. I wan... | [
{
"answer_id": 455727,
"author": "martinus",
"author_id": 48181,
"author_profile": "https://Stackoverflow.com/users/48181",
"pm_score": 2,
"selected": false,
"text": "<p>Just take your favourite sorting algorithm (e.g. Quicksort or Mergesort) and use it to sort the \"values\" array. When... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404/"
] | The environment: I am working in a proprietary scripting language where there is no such thing as a user-defined function. I have various loops and local variables of primitive types that I can create and use.
I have two related arrays, "times" and "values". They both contain floating point values. I want to numerical... | **You could maintain an index table and sort the index table instead.**
This way you will not have to worry about times and values being consistent.
And whenever you need a sorted value, you can lookup on the sorted index.
And if in the future you decided there was going to be a third value, the sorting code will no... |
455,713 | <p>How can I paint in red every time I meet the letter "A" in RichTextBox?</p>
| [
{
"answer_id": 455730,
"author": "E.J. Brennan",
"author_id": 53686,
"author_profile": "https://Stackoverflow.com/users/53686",
"pm_score": 1,
"selected": false,
"text": "<p>This won't work while you are typing if that is what you are looking for, but I use this to highlight substrings:<... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43907/"
] | How can I paint in red every time I meet the letter "A" in RichTextBox? | Try this:
```
static void HighlightPhrase(RichTextBox box, string phrase, Color color) {
int pos = box.SelectionStart;
string s = box.Text;
for (int ix = 0; ; ) {
int jx = s.IndexOf(phrase, ix, StringComparison.CurrentCultureIgnoreCase);
if (jx < 0) break;
box.SelectionStart = jx;
box.SelectionLe... |
455,753 | <p>I'm using a JTextArea to display a long text</p>
<pre><code>JTextArea _definition = new JTextArea(5, 50);
</code></pre>
<p>with word-wrap</p>
<pre><code>_definition.setLineWrap(true);
_definition.setWrapStyleWord(true);
</code></pre>
<p>embedded in a JScrollPane</p>
<pre><code>add(new JScrollPane(_definition), ... | [
{
"answer_id": 455777,
"author": "Ross",
"author_id": 29173,
"author_profile": "https://Stackoverflow.com/users/29173",
"pm_score": 2,
"selected": false,
"text": "<p>Try calling <code>pack()</code> twice. JTextArea has some odd behavior <a href=\"http://bugs.sun.com/bugdatabase/view_bug.... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25320/"
] | I'm using a JTextArea to display a long text
```
JTextArea _definition = new JTextArea(5, 50);
```
with word-wrap
```
_definition.setLineWrap(true);
_definition.setWrapStyleWord(true);
```
embedded in a JScrollPane
```
add(new JScrollPane(_definition), gbc);
```
All that is part of a JPanel with the GridBagLay... | Got it to work .. Ross's answer was giving me some better terms to search for, so thanks for helping me by pointing in the right direction!
```
pack();
_definition.setSize(_definition.getPreferredSize());
pack();
```
So double-packing plus some extra ... strange behavior. |
455,766 | <p>I have a custom object that implements INotifyPropertyChanged. I have a collection of these objects where the collection is based on BindingList
I have created a binding source for the collection, and set the datasources of the bindingsource and datagridview.</p>
<p>Everything works great, except I need to update ... | [
{
"answer_id": 455784,
"author": "Jason Coyne",
"author_id": 56472,
"author_profile": "https://Stackoverflow.com/users/56472",
"pm_score": 5,
"selected": true,
"text": "<p>I found this class in a forum that works. Just use this instead of BindingList</p>\n\n<pre><code>using System;\nusin... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56472/"
] | I have a custom object that implements INotifyPropertyChanged. I have a collection of these objects where the collection is based on BindingList
I have created a binding source for the collection, and set the datasources of the bindingsource and datagridview.
Everything works great, except I need to update properties ... | I found this class in a forum that works. Just use this instead of BindingList
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Threading;
namespace Utility
{
public class ThreadedBindingList<T> : BindingList<T>
{
Sync... |
455,790 | <p>I am loading a file into a array in binary form this seems to take a while
is there a better faster more efficent way to do this.
i am using a similar method for writing back to the file.</p>
<pre><code>procedure openfile(fname:string);
var
myfile: file;
filesizevalue,i:integer;
begin
assignfile(myfile,fn... | [
{
"answer_id": 455795,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 5,
"selected": true,
"text": "<p>You generally shouldn't read files byte for byte. Use BlockRead with a larger value (512 or 1024 often are best) and u... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53915/"
] | I am loading a file into a array in binary form this seems to take a while
is there a better faster more efficent way to do this.
i am using a similar method for writing back to the file.
```
procedure openfile(fname:string);
var
myfile: file;
filesizevalue,i:integer;
begin
assignfile(myfile,fname);
filesi... | You generally shouldn't read files byte for byte. Use BlockRead with a larger value (512 or 1024 often are best) and use its return value to find out how many bytes were read.
If the size isn't too large (and your use of SetLength seems to support this), you can also use one BlockRead call reading the complete file at... |
455,793 | <p><strong>Without</strong>:</p>
<ul>
<li>MFC</li>
<li>ATL</li>
</ul>
<p>using <strong>COM</strong>, with <strong>pure C++</strong>, steps taken thus far:</p>
<pre><code>//steps above omitted
_ApplicationPtr application(__uuidof(Excel::Application));
//omitted
const BSTR wcharFileName = SysAllocString(L"...");
a... | [
{
"answer_id": 455829,
"author": "João Augusto",
"author_id": 6909,
"author_profile": "https://Stackoverflow.com/users/6909",
"pm_score": 3,
"selected": true,
"text": "<p>Try this <a href=\"http://support.microsoft.com/kb/216388/en-us\" rel=\"nofollow noreferrer\">http://support.microsof... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51078/"
] | **Without**:
* MFC
* ATL
using **COM**, with **pure C++**, steps taken thus far:
```
//steps above omitted
_ApplicationPtr application(__uuidof(Excel::Application));
//omitted
const BSTR wcharFileName = SysAllocString(L"...");
application->Workbooks->Open(wcharFileName);
application->put_Visible(10, true);
```... | Try this <http://support.microsoft.com/kb/216388/en-us> |
455,800 | <p>In javascript you can easily create objects and Arrays like so:</p>
<pre><code>var aObject = { foo:'bla', bar:2 };
var anArray = ['foo', 'bar', 2];
</code></pre>
<p>Are similar things possible in PHP?<br>
I know that you can easily create an array using the array function, that hardly is more work then the javascr... | [
{
"answer_id": 455810,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 6,
"selected": false,
"text": "<p>There was a <a href=\"http://wiki.php.net/rfc/shortsyntaxforarrays\" rel=\"noreferrer\">proposal to implement this array ... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35197/"
] | In javascript you can easily create objects and Arrays like so:
```
var aObject = { foo:'bla', bar:2 };
var anArray = ['foo', 'bar', 2];
```
Are similar things possible in PHP?
I know that you can easily create an array using the array function, that hardly is more work then the javascript syntax, but is there a ... | For simple objects, you can use the associative array syntax and casting to get an object:
```
<?php
$obj = (object)array('foo' => 'bar');
echo $obj->foo; // yields "bar"
```
But looking at that you can easily see how useless it is (you would just leave it as an associative array if your structure was that simple). |
455,801 | <p>I am trying out moq and I'm running into a problem with the following test body: </p>
<pre><code>var child = new Mock<ZooNode>();
var parent = new Mock<ZooNode>();
child.Object.Parent = parent.Object;
parent.Expect(p => p.Children.Contains(child.Object)).Returns(true);
</code></pre>
<p>which throws ... | [
{
"answer_id": 455828,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 4,
"selected": true,
"text": "<p>Your <em>Children</em> collection property needs to be virtual if you want to define expectations on it:</p>\n\n<... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48266/"
] | I am trying out moq and I'm running into a problem with the following test body:
```
var child = new Mock<ZooNode>();
var parent = new Mock<ZooNode>();
child.Object.Parent = parent.Object;
parent.Expect(p => p.Children.Contains(child.Object)).Returns(true);
```
which throws :
>
> System.ArgumentException: Invalid... | Your *Children* collection property needs to be virtual if you want to define expectations on it:
```
public abstract class ZooNode
{
public ZooNode Parent { get; set; }
public virtual IList<ZooNode> Children { get; set; }
}
``` |
455,822 | <p>I am building a class that handles NSURLConnection requests. To allow other classes to use this class, I would like to allow the main class to call a delegate when connectionDidFinishLoading is fired.</p>
<p>I've looked through lots of documentation, but I can't find anything that gives any clear examples, and the... | [
{
"answer_id": 455837,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 1,
"selected": false,
"text": "<p>You're on the right track, the way you're implementing the delegate pattern looks okay. The reason it's not be... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21804/"
] | I am building a class that handles NSURLConnection requests. To allow other classes to use this class, I would like to allow the main class to call a delegate when connectionDidFinishLoading is fired.
I've looked through lots of documentation, but I can't find anything that gives any clear examples, and the code that ... | Turns out I forgot to set the delegate:
```
[currentHandler setDelegate:self];
```
needed to go after the line that makes the initial call to the PDUrlHandler. |
455,830 | <p>I ran into an issue with something that I am probably just overlooking.</p>
<p>I want to take a picture from the surface preview of the camera, and save it to the <code>sd_card</code>. This works ALMOST perfect. I assigned it a file name, but it does not use the <code>filename</code>. </p>
<p>This is what I have b... | [
{
"answer_id": 472919,
"author": "Chrispix",
"author_id": 393258,
"author_profile": "https://Stackoverflow.com/users/393258",
"pm_score": 4,
"selected": true,
"text": "<p>This was resolved by implementing PictureCallback via a ImageCaptureCallback class, and Overriding the onPictureTaken... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/393258/"
] | I ran into an issue with something that I am probably just overlooking.
I want to take a picture from the surface preview of the camera, and save it to the `sd_card`. This works ALMOST perfect. I assigned it a file name, but it does not use the `filename`.
This is what I have been trying to do :
```
Button imagecap... | This was resolved by implementing PictureCallback via a ImageCaptureCallback class, and Overriding the onPictureTaken where the file was being written via a file output stream. All you had to do was change the fileoutput stream to the filename you want. |
455,853 | <p>Could someone explain why both tests using the latest versions of Moq and Rhino.Mocks frameworks fail complaining that Bar is not a virtual/overridable method:</p>
<pre><code>public interface IFoo
{
string Bar();
}
public class Foo : IFoo
{
public string Bar()
{
return "Bar";
}
}
[TestMeth... | [
{
"answer_id": 455870,
"author": "Krzysztof Kozmic",
"author_id": 13163,
"author_profile": "https://Stackoverflow.com/users/13163",
"pm_score": 1,
"selected": false,
"text": "<p>Because you're mocking Foo class.\nMock IFoo intefrace instead</p>\n\n<pre><code>var foo = new MockRepository(... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29407/"
] | Could someone explain why both tests using the latest versions of Moq and Rhino.Mocks frameworks fail complaining that Bar is not a virtual/overridable method:
```
public interface IFoo
{
string Bar();
}
public class Foo : IFoo
{
public string Bar()
{
return "Bar";
}
}
[TestMethod]
public voi... | Virtual is part of the class not the interface, so if you wish to override the method on the class Foo you will need to declare it as virtual.
However as Krzysztof mentions if all you need are the methods on the interface IFoo then you should mock the interface. |
455,880 | <p>I have the following structure</p>
<pre><code>public class MyClass : MyBaseClass<System.Int32>
{
}
</code></pre>
<p>In a static method and without instantiating a new MyClass instance how do I get the type of the generic parameter used to build the concrete base class? e.g in the above example System.Int32</... | [
{
"answer_id": 455890,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 0,
"selected": false,
"text": "<pre><code>Type arg = typeof(MyClass).BaseType.GetGenericArguments()[0];\n</code></pre>\n"
},
{
"answer_id"... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53541/"
] | I have the following structure
```
public class MyClass : MyBaseClass<System.Int32>
{
}
```
In a static method and without instantiating a new MyClass instance how do I get the type of the generic parameter used to build the concrete base class? e.g in the above example System.Int32 | Try this
```
public static Type GetBaseTypeGenericArgument(Type type) {
return type.BaseType.GetGenericArguments()[0];
}
...
GetBaseTypeGenericArgument(typeof(MyClass));
``` |
455,884 | <p>In <a href="https://stackoverflow.com/questions/452517/does-this-entity-repository-service-example-fit-into-domain-driven-design#452564">this answer</a> to a <a href="https://stackoverflow.com/questions/452517">recent question</a>, I was advised to <blockquote>"be wary of making every property in your domain model h... | [
{
"answer_id": 455890,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 0,
"selected": false,
"text": "<pre><code>Type arg = typeof(MyClass).BaseType.GetGenericArguments()[0];\n</code></pre>\n"
},
{
"answer_id"... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41094/"
] | In [this answer](https://stackoverflow.com/questions/452517/does-this-entity-repository-service-example-fit-into-domain-driven-design#452564) to a [recent question](https://stackoverflow.com/questions/452517), I was advised to
> "be wary of making every property in your domain model have public getters and setters. Th... | Try this
```
public static Type GetBaseTypeGenericArgument(Type type) {
return type.BaseType.GetGenericArguments()[0];
}
...
GetBaseTypeGenericArgument(typeof(MyClass));
``` |
455,895 | <p>I am writing network application for Blackberry. This code is correct on the simulator but not working on a device. When I run my application on the simulator, my server recieves the message but when I run it on a device, I get an Exception, <code>not IOException</code>, with message "<code>NULL</code>". </p>
<pre>... | [
{
"answer_id": 455996,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": -1,
"selected": false,
"text": "<p>I can think of two possibilities:</p>\n\n<ol>\n<li>UDP is <code>optional</code> in the <a href=\"http://developer... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46145/"
] | I am writing network application for Blackberry. This code is correct on the simulator but not working on a device. When I run my application on the simulator, my server recieves the message but when I run it on a device, I get an Exception, `not IOException`, with message "`NULL`".
```
try {
byte[] b = msg.getB... | Network access on the BlackBerry is far from seemless from a developer's point of view. You either have to specify how the connection should be made in the URL, or the device has to have the correct APN settings in Options > Advanced Options > TCP Settings. You could try finding those and entering them to see if it wor... |
455,904 | <p>I am using an application in c++ that uses a special dprintf function to print information, this is an example:</p>
<pre><code>dprintf(verbose, "The value is: %d", i);
</code></pre>
<p>What is doing is when I define verbose for test purposes then I print the information and when I am working in normal execution I ... | [
{
"answer_id": 455920,
"author": "Joao da Silva",
"author_id": 46329,
"author_profile": "https://Stackoverflow.com/users/46329",
"pm_score": 3,
"selected": false,
"text": "<pre><code>#ifdef DEBUG\n#define dprintf(format, ...) real_dprintf(format, __VA_ARGS__)\n#else\n#define dprintf\n#en... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39160/"
] | I am using an application in c++ that uses a special dprintf function to print information, this is an example:
```
dprintf(verbose, "The value is: %d", i);
```
What is doing is when I define verbose for test purposes then I print the information and when I am working in normal execution I do not define it and I do ... | I try to avoid using var-arg c-style functions for two main reasons:
* They are not type-safe, can't use operator<<
* They don't recognize when too few or many arguments were provided
I've made a way that works using `boost::fusion`, which is given arguments in a type-safe way. It iterates over those arguments, print... |
455,910 | <p>I have been noticing <code>__construct</code> a lot with classes. I did a little reading and surfing the web, but I couldn't find an explanation I could understand. I am just beginning with OOP.</p>
<p>I was wondering if someone could give me a general idea of what it is, and then a simple example of how it is used... | [
{
"answer_id": 455927,
"author": "Logan Serman",
"author_id": 29595,
"author_profile": "https://Stackoverflow.com/users/29595",
"pm_score": 4,
"selected": false,
"text": "<p>It's to declare the constructor.</p>\n<pre><code>class Cat\n{\n function __construct()\n {\n echo 'me... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27620/"
] | I have been noticing `__construct` a lot with classes. I did a little reading and surfing the web, but I couldn't find an explanation I could understand. I am just beginning with OOP.
I was wondering if someone could give me a general idea of what it is, and then a simple example of how it is used with PHP? | `__construct` was introduced in PHP5 and it is the right way to define your, well, constructors (in PHP4 you used the name of the class for a constructor).
You are not required to define a constructor in your class, but if you wish to pass any parameters on object construction then you need one.
An example could go li... |
455,911 | <p>There are several ways to do this, but I'm not sure which one of them is the best.</p>
<p>Here's what I can think of:</p>
<ul>
<li>Look for the process using pgrep.</li>
<li>Have the script lock itself using flock, and then check if it is locked each time it runs.</li>
<li>Create a pid file in /var/run/program_nam... | [
{
"answer_id": 455925,
"author": "Rob Wells",
"author_id": 2974,
"author_profile": "https://Stackoverflow.com/users/2974",
"pm_score": 3,
"selected": false,
"text": "<p>Do the old PID file trick.</p>\n\n<ul>\n<li>start process</li>\n<li>see if there is a file called \"myprog.PID\"</li>\n... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13523/"
] | There are several ways to do this, but I'm not sure which one of them is the best.
Here's what I can think of:
* Look for the process using pgrep.
* Have the script lock itself using flock, and then check if it is locked each time it runs.
* Create a pid file in /var/run/program\_name.pid and check for existence, and... | There are many ways to do it. PID files are the traditional way to do it. You could also hold a lock on a file, for example the program itself. This small piece of code will do the trick:
```
use Fcntl ':flock';
open my $self, '<', $0 or die "Couldn't open self: $!";
flock $self, LOCK_EX | LOCK_NB or die "This script ... |
455,912 | <p>I have a repeater control where the <code><%#DataBinder.Eval(Container.DataItem, "Display")%></code> part doesn't show up. The code that the "Display" stores is set as follows:</p>
<pre><code>item.Display = "<script type='text/javascript'>
AudioPlayer.embed('ffcedea7-4822-465f-85b6-89924f7b81fa',
... | [
{
"answer_id": 455925,
"author": "Rob Wells",
"author_id": 2974,
"author_profile": "https://Stackoverflow.com/users/2974",
"pm_score": 3,
"selected": false,
"text": "<p>Do the old PID file trick.</p>\n\n<ul>\n<li>start process</li>\n<li>see if there is a file called \"myprog.PID\"</li>\n... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] | I have a repeater control where the `<%#DataBinder.Eval(Container.DataItem, "Display")%>` part doesn't show up. The code that the "Display" stores is set as follows:
```
item.Display = "<script type='text/javascript'>
AudioPlayer.embed('ffcedea7-4822-465f-85b6-89924f7b81fa',
{soundFile: 'http://s3.amazonaws.co... | There are many ways to do it. PID files are the traditional way to do it. You could also hold a lock on a file, for example the program itself. This small piece of code will do the trick:
```
use Fcntl ':flock';
open my $self, '<', $0 or die "Couldn't open self: $!";
flock $self, LOCK_EX | LOCK_NB or die "This script ... |
455,924 | <p>If I use null as a representation of everything in a database table is that bad practice ?</p>
<p>i.e.</p>
<p>I have the tables: myTable(ID) and myRelatedTable(ID,myTableID)</p>
<p>myRelatedTable.myTableID is a FK of myTable.ID</p>
<p>What I want to accomplish is: if myRelatedTable.myTableID is null then my busi... | [
{
"answer_id": 455936,
"author": "Michael Borgwardt",
"author_id": 16883,
"author_profile": "https://Stackoverflow.com/users/16883",
"pm_score": 1,
"selected": false,
"text": "<p>Not a good idea, because then you cannot use the \"related to all entries\" fact in SQL queries at all. At so... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50970/"
] | If I use null as a representation of everything in a database table is that bad practice ?
i.e.
I have the tables: myTable(ID) and myRelatedTable(ID,myTableID)
myRelatedTable.myTableID is a FK of myTable.ID
What I want to accomplish is: if myRelatedTable.myTableID is null then my business logic will interpret that ... | I don't think NULL is the best way to do it but you might use a separate tinyInt column to indicate that the row in MyRelatedTable is related to everything in MyTable, e.g. MyRelatedTable.RelatedAll. That would make it more explicit for other that have to maintain it. Then you could do some sort of Union query e.g.
``... |
455,928 | <p>The current class library I am working on will have a base class (Field) with over 50 specific "field" types which will inherit from "Field" and nested for maintain readability. For example...</p>
<pre><code>abstract class Field
{
public int Length { get; set; }
public class FieldA : Field
{
pu... | [
{
"answer_id": 455938,
"author": "Rowland Shaw",
"author_id": 50447,
"author_profile": "https://Stackoverflow.com/users/50447",
"pm_score": 3,
"selected": true,
"text": "<p>Sounds like you wanted something like:</p>\n\n<pre><code>abstract class Field\n{\n public int Length { get; set;... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2982/"
] | The current class library I am working on will have a base class (Field) with over 50 specific "field" types which will inherit from "Field" and nested for maintain readability. For example...
```
abstract class Field
{
public int Length { get; set; }
public class FieldA : Field
{
public static vo... | Sounds like you wanted something like:
```
abstract class Field
{
public int Length { get; set; }
}
public class FieldA : Field
{
public static void DoSomething()
{
Console.WriteLine("Did something.");
}
}
```
Otherwise you're defining a base class with an inner class in it, which inheritorr... |
455,958 | <p>I have an HTML table with several columns and I need to implement a column chooser using jQuery. When a user clicks on a checkbox I want to hide/show the corresponding column in the table. I would like to do this without attaching a class to every td in the table, is there a way to select an entire column using jQ... | [
{
"answer_id": 455968,
"author": "Luis Melgratti",
"author_id": 17032,
"author_profile": "https://Stackoverflow.com/users/17032",
"pm_score": 4,
"selected": false,
"text": "<p>you could use colgroups:</p>\n\n<pre><code><table>\n <colgroup>\n <col class=\"visible_c... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43816/"
] | I have an HTML table with several columns and I need to implement a column chooser using jQuery. When a user clicks on a checkbox I want to hide/show the corresponding column in the table. I would like to do this without attaching a class to every td in the table, is there a way to select an entire column using jQuery?... | >
> I would like to do this without attaching a class to every td
>
>
>
Personally, I would go with the the class-on-each-td/th/col approach. Then you can switch columns on and off using a single write to className on the container, assuming style rules like:
```
table.hide1 .col1 { display: none; }
table.hide2 .... |
455,960 | <p>I don't truly understand some basic things in C like dynamically allocating array of arrays.
I know you can do:</p>
<pre><code>int **m;
</code></pre>
<p>in order to declare a 2 dimensional array (which subsequently would be allocated using some *alloc function). Also it can be "easily" accessed by doing <code>*(*(... | [
{
"answer_id": 455969,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 0,
"selected": false,
"text": "<p>Using <code>malloc(3)</code> for allocate the first array and putting in there pointers created by <code>malloc(3)</code... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49032/"
] | I don't truly understand some basic things in C like dynamically allocating array of arrays.
I know you can do:
```
int **m;
```
in order to declare a 2 dimensional array (which subsequently would be allocated using some \*alloc function). Also it can be "easily" accessed by doing `*(*(m + line) + column)`. But how ... | The `m[line][column] = 12` syntax is ok (provided `line` and `column` are in range).
However, you didn't write the code you use to allocate it, so it's hard to get whether it is wrong or right. It should be something along the lines of
```
m = (int**)malloc(nlines * sizeof(int*));
for(i = 0; i < nlines; i++)
m[i] ... |
455,987 | <p>I am getting a strange exception when trying to update a DataTable after flagging a row for deletion. It looks like it's validating the data in the row I'm trying to delete. I was able to save the same row successfully, why won't it let me delete it?</p>
<p>Using C# in VS 2008 and SQL Server CE.</p>
<p>The essenti... | [
{
"answer_id": 455994,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 2,
"selected": true,
"text": "<p>You need to do a trace on the app (try running it on your local copy of SQL Server and run the 'Profiler'); my gu... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16757/"
] | I am getting a strange exception when trying to update a DataTable after flagging a row for deletion. It looks like it's validating the data in the row I'm trying to delete. I was able to save the same row successfully, why won't it let me delete it?
Using C# in VS 2008 and SQL Server CE.
The essential bits (I hope) ... | You need to do a trace on the app (try running it on your local copy of SQL Server and run the 'Profiler'); my guess is when the SQL query is hitting your SQL Server, part of it isn't in the correct format. I bet you'll see the problem when you run a trace. |
455,988 | <p>I have an ASP.Net CheckBoxList control inside an Ajax UpdatePanel.</p>
<p>I will include the code (C#) along with the HTML below.</p>
<p>I have found that it is something with the CheckBoxList not persisting through the post back.</p>
<p>BTW, it is a little messy. It is a prototype.</p>
<p>This is the method us... | [
{
"answer_id": 455994,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 2,
"selected": true,
"text": "<p>You need to do a trace on the app (try running it on your local copy of SQL Server and run the 'Profiler'); my gu... | 2009/01/18 | [
"https://Stackoverflow.com/questions/455988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48943/"
] | I have an ASP.Net CheckBoxList control inside an Ajax UpdatePanel.
I will include the code (C#) along with the HTML below.
I have found that it is something with the CheckBoxList not persisting through the post back.
BTW, it is a little messy. It is a prototype.
This is the method used to populate the original Chec... | You need to do a trace on the app (try running it on your local copy of SQL Server and run the 'Profiler'); my guess is when the SQL query is hitting your SQL Server, part of it isn't in the correct format. I bet you'll see the problem when you run a trace. |
456,034 | <p>I need an idea for an efficient index/search algorithm, and/or data structure, for determining whether a time-interval overlaps zero or more time-intervals in a list, keeping in mind that a complete overlap is a special case of partial overlap . So far I've not not come up with anything fast or elegant...</p>
<p>Co... | [
{
"answer_id": 456039,
"author": "Jules",
"author_id": 40078,
"author_profile": "https://Stackoverflow.com/users/40078",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"http://en.wikipedia.org/wiki/Interval_tree\" rel=\"nofollow noreferrer\">Interval trees</a> will do:</p>\n\n<blo... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35657/"
] | I need an idea for an efficient index/search algorithm, and/or data structure, for determining whether a time-interval overlaps zero or more time-intervals in a list, keeping in mind that a complete overlap is a special case of partial overlap . So far I've not not come up with anything fast or elegant...
Consider a c... | [Interval trees](http://en.wikipedia.org/wiki/Interval_tree) will do:
>
> In [computer science](https://en.wikipedia.org/wiki/Computer_science), an **interval tree** is a [tree data structure](https://en.wikipedia.org/wiki/Tree_(data_structure)) to hold [intervals](https://en.wikipedia.org/wiki/Interval_(mathematics)... |
456,042 | <p>I am attempting to use boost::asio to read and write from a device on a serial port. Both boost::asio:read() and boost::asio::serial_port::read_some() block when there is nothing to read. Instead I would like to detect this condition and write a command to the port to kick-start the device.</p>
<p>How can I either ... | [
{
"answer_id": 754058,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>You have to use the free-function asio::async_read.</p>\n"
},
{
"answer_id": 1750916,
"author": "Brian",
"a... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1031/"
] | I am attempting to use boost::asio to read and write from a device on a serial port. Both boost::asio:read() and boost::asio::serial\_port::read\_some() block when there is nothing to read. Instead I would like to detect this condition and write a command to the port to kick-start the device.
How can I either detect t... | You have a couple of options, actually. You can either use the serial port's built-in `async_read_some` function, or you can use the stand-alone function `boost::asio::async_read` (or `async_read_some`).
You'll still run into the situation where you are effectively "blocked", since neither of these will call the callb... |
456,044 | <p>I got the image like this (it's a graph):</p>
<p><a href="https://i.stack.imgur.com/vyayH.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vyayH.gif" alt="Gold Trade Graph"></a><br>
<sub>(source: <a href="http://www.kitconet.com/charts/metals/platinum/tny_pt_en_caoz_2.gif" rel="nofollow noreferrer... | [
{
"answer_id": 456072,
"author": "Jan Hančič",
"author_id": 185527,
"author_profile": "https://Stackoverflow.com/users/185527",
"pm_score": -1,
"selected": false,
"text": "<p>I'm not aware of any ready-made functions. But I suppose you could go trough every pixel of the image and change ... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21209/"
] | I got the image like this (it's a graph):
[](https://i.stack.imgur.com/vyayH.gif)
(source: [kitconet.com](http://www.kitconet.com/charts/metals/platinum/tny_pt_en_caoz_2.gif))
I want to change the colours, so the white is black, the graph line is light blue,... | This will replace the white color with Gray
```
$imgname = "test.gif";
$im = imagecreatefromgif ($imgname);
$index = imagecolorclosest ( $im, 255,255,255 ); // get White COlor
imagecolorset($im,$index,92,92,92); // SET NEW COLOR
$imgname = "result.gif";
imagegif($im, $imgname ); // save image as gif
imagedestroy($... |
456,059 | <p>I have a form with checkboxes and then text to the right of the checkbox. There are jquery events attached to the click events of the the checkbox. What I want is to allow the user to click on the label or the checkbox and have the checkbox check/uncheck and the event to fire. Below is a simplified version of wha... | [
{
"answer_id": 456064,
"author": "Jan Hančič",
"author_id": 185527,
"author_profile": "https://Stackoverflow.com/users/185527",
"pm_score": 4,
"selected": true,
"text": "<p>Use the LABEL tag: <a href=\"http://www.w3schools.com/tags/tag_label.asp\" rel=\"noreferrer\">http://www.w3schools.... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43816/"
] | I have a form with checkboxes and then text to the right of the checkbox. There are jquery events attached to the click events of the the checkbox. What I want is to allow the user to click on the label or the checkbox and have the checkbox check/uncheck and the event to fire. Below is a simplified version of what I'm ... | Use the LABEL tag: <http://www.w3schools.com/tags/tag_label.asp> |
456,063 | <p>Is there a way to add a button control to a cell in inside a ListView in a WinForms app?</p>
| [
{
"answer_id": 533454,
"author": "Dan Byström",
"author_id": 64121,
"author_profile": "https://Stackoverflow.com/users/64121",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe this could be of interest?</p>\n\n<p><a href=\"http://www.codeproject.com/KB/list/extendedlistviews.aspx\" re... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] | Is there a way to add a button control to a cell in inside a ListView in a WinForms app? | Here is a code of a class `ListViewExtender` that you can reuse. It's not a derived class of `ListView`, basically you just declare that a specific column is displayed as buttons instead of text. The button's text is the subItem's text.
It allows big sized list views without problems, does not use p/invoke, and also w... |
456,065 | <p>I have a aspx page that seems to be loading twice when I enter the Url to the page.</p>
<p>In this page's loading event, I'm making an connection to a server to retrieve a document and then I output the downloaded bytes to the output stream of the page.</p>
<p>This is causing the page to load twice for some strang... | [
{
"answer_id": 456069,
"author": "Thomas Hansen",
"author_id": 29746,
"author_profile": "https://Stackoverflow.com/users/29746",
"pm_score": 2,
"selected": false,
"text": "<p>These kind of problems often happens due to img tags that have an empty src ...</p>\n"
},
{
"answer_id": ... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17211/"
] | I have a aspx page that seems to be loading twice when I enter the Url to the page.
In this page's loading event, I'm making an connection to a server to retrieve a document and then I output the downloaded bytes to the output stream of the page.
This is causing the page to load twice for some strange reason. If I ha... | The likely culprit is having the page directive of **AutoEventWireup="true"** in addition to OnInit() having this.Page\_Load += Page\_Load;
Auto Event Wireup does what it sounds like. If there is a method that follows the naming convention, the event is automatically wired up.
You also oftentimes see this on button h... |
456,068 | <p>When using powershell, sometimes I want to only display for example the name or fullname of a file.<br />
From what I can gather, the way to do this is by using <code>Get-ItemProperty</code> (alias of <code>gp</code>) and passing <code>-n fullname</code>, For example</p>
<pre><code>PS C:\Dev> gp . -n fullname
</c... | [
{
"answer_id": 456106,
"author": "Darren Gosbell",
"author_id": 11860,
"author_profile": "https://Stackoverflow.com/users/11860",
"pm_score": 1,
"selected": false,
"text": "<p>If you are in a foreach loop and you have a reference to the object that you are interested in, then have you tr... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234/"
] | When using powershell, sometimes I want to only display for example the name or fullname of a file.
From what I can gather, the way to do this is by using `Get-ItemProperty` (alias of `gp`) and passing `-n fullname`, For example
```
PS C:\Dev> gp . -n fullname
```
Notably I want to use this in longer scripts comb... | There are many ways. I think you were looking for Get-ChildItem:
PS > get-childitem x.txt | select fullname
```
FullName
--------
C:\WINDOWS\system32\WindowsPowerShell\v1.0\x.txt
PS > get-childitem x.txt | select name
Name
----
x.txt
PS > get-childitem x.txt | % { $_.fullname }
... |
456,084 | <p>I am learning Python and trying to figure out an efficient way to tokenize a string of numbers separated by commas into a list. Well formed cases work as I expect, but less well formed cases not so much.</p>
<p>If I have this:</p>
<pre><code>A = '1,2,3,4'
B = [int(x) for x in A.split(',')]
B results in [1, 2, 3, ... | [
{
"answer_id": 456089,
"author": "Dave Ray",
"author_id": 40310,
"author_profile": "https://Stackoverflow.com/users/40310",
"pm_score": 6,
"selected": true,
"text": "<p>How about this:</p>\n\n<pre><code>A = '1, 2,,3,4 '\nB = [int(x) for x in A.split(',') if x.strip()]\n</code></pre>\n\n... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1553/"
] | I am learning Python and trying to figure out an efficient way to tokenize a string of numbers separated by commas into a list. Well formed cases work as I expect, but less well formed cases not so much.
If I have this:
```
A = '1,2,3,4'
B = [int(x) for x in A.split(',')]
B results in [1, 2, 3, 4]
```
which is wha... | How about this:
```
A = '1, 2,,3,4 '
B = [int(x) for x in A.split(',') if x.strip()]
```
x.strip() trims whitespace from the string, which will make it empty if the string is all whitespace. An empty string is "false" in a boolean context, so it's filtered by the if part of the list comprehension. |
456,100 | <p>I'm working on an SConstruct build file for a project and I'm trying to update from Options to Variables, since Options is being deprecated. I don't understand how to use Variables though. I have 0 python experience which is probably contributing to this.</p>
<p>For example, I have this:</p>
<pre><code>opts = Vari... | [
{
"answer_id": 476395,
"author": "Ross Rogers",
"author_id": 20712,
"author_profile": "https://Stackoverflow.com/users/20712",
"pm_score": 1,
"selected": false,
"text": "<p>That specific error tells you that class <code>Variables</code> hasn't implemented python's <code>__getitem__</code... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68788/"
] | I'm working on an SConstruct build file for a project and I'm trying to update from Options to Variables, since Options is being deprecated. I don't understand how to use Variables though. I have 0 python experience which is probably contributing to this.
For example, I have this:
```
opts = Variables()
opts.Add('fcg... | Typically you would store the variables in your environment for later testing.
```
opts = Variables()
opts.Add('fcgi',0)
env = Environment(variables=opts, ...)
```
Then later you can test:
```
if env['fcgi'] == 0:
# do something
``` |
456,111 | <p>I have the following route </p>
<pre><code>routes.MapRoute(
"GigDayListings", // Route name
"gig/list/{year}/{month}/{day}", // URL with parameters
new { controller = "Gig", action = "List" },
new
{
year = @"^[0-9]+$",
month = ... | [
{
"answer_id": 456156,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 3,
"selected": false,
"text": "<p>I think your problem is that you didn't specify the route name in your call. Try to use </p>\n\n<pre><code>UrlHelp... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46616/"
] | I have the following route
```
routes.MapRoute(
"GigDayListings", // Route name
"gig/list/{year}/{month}/{day}", // URL with parameters
new { controller = "Gig", action = "List" },
new
{
year = @"^[0-9]+$",
month = @"^[0-9]+$",
... | I think your problem is that you didn't specify the route name in your call. Try to use
```
UrlHelper.RouteUrl(**"GigDayListings"**, ViewContext.RouteData.Values);
```
overload with route name.
Cheers! |
456,146 | <p>I am new to programming so i figured i'd get help from those that know it. </p>
<p>I am currently writing a Registration Application which will basically take a users input,
validates the data entered, displays a review screen (which the user must print out and mail in a copy), and then save the info entered to a d... | [
{
"answer_id": 456307,
"author": "BBetances",
"author_id": 53599,
"author_profile": "https://Stackoverflow.com/users/53599",
"pm_score": 1,
"selected": false,
"text": "<p>I notice your using ASP.NET, you should know that the Membership Provider can handle all of that grunt work for you.<... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56509/"
] | I am new to programming so i figured i'd get help from those that know it.
I am currently writing a Registration Application which will basically take a users input,
validates the data entered, displays a review screen (which the user must print out and mail in a copy), and then save the info entered to a database.
... | First if you want to simplify maintaneance, I would look at using an ORM to do the mapping. I'd look at nHibernate, Linq2Sql, Entity Framework or one of the other billion or so out there. It will remove a lot of noise from above.
Second suggestion would be to continue the refactoring you were doing. I like how you abs... |
456,155 | <p>I am trying to start an external process from a .NET Windows service. In the past I have used the <code>Process.Start()</code> overload that takes the executable path and a command line string. This works. But now I would like to start the process and have it run in the context of a particular user. So I call this v... | [
{
"answer_id": 456166,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 0,
"selected": false,
"text": "<p>Use Filemon and see if it is trying to open a config file and not finding it. I once had this error due to a malfo... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2768/"
] | I am trying to start an external process from a .NET Windows service. In the past I have used the `Process.Start()` overload that takes the executable path and a command line string. This works. But now I would like to start the process and have it run in the context of a particular user. So I call this version of `Sta... | Maybe the user has to have, "logon as a service" security right. This is done with the "local security policy" application. And/or "logon as a batch job". |
456,163 | <p>I am building a site and I have a list of status updates and I want to allow the users to write comments for each of of the items in the list</p>
<p>However I am trying to implement a UI similar to the way stack overflow works
specifically the collapsible comment form / list where a user clicks on add comment on th... | [
{
"answer_id": 456200,
"author": "Phil.Wheeler",
"author_id": 15609,
"author_profile": "https://Stackoverflow.com/users/15609",
"pm_score": 1,
"selected": false,
"text": "<p>The quick approach (for just showing / hiding the comment area) would resemble something like this:</p>\n\n<pre><c... | 2009/01/18 | [
"https://Stackoverflow.com/questions/456163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22093/"
] | I am building a site and I have a list of status updates and I want to allow the users to write comments for each of of the items in the list
However I am trying to implement a UI similar to the way stack overflow works
specifically the collapsible comment form / list where a user clicks on add comment on the specific... | To load the content you can just hook up a click event to populate a div using the load method.
For example in the view you could have something like:-
```
<%= Html.ActionLink("Comments", "CommentList", "Questions", new { Id = this.ViewData.Model.Id }, new { id = "commentLink" })%>
<div id="commentContainer" style=... |
456,172 | <p>I have a table which defines a child-parent relationship between nodes:</p>
<pre><code>CREATE TABLE node ( ' pseudo code alert
id INTEGER PRIMARY KEY,
parentID INTEGER, ' should be a valid id.
)
</code></pre>
<p>If <code>parentID</code> always points to a valid existing node, ... | [
{
"answer_id": 456221,
"author": "ChrisW",
"author_id": 49942,
"author_profile": "https://Stackoverflow.com/users/49942",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>If you have any magic books you reach for for this kind of query, I'd like to know.</p>\n</blockquote>\n... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4737/"
] | I have a table which defines a child-parent relationship between nodes:
```
CREATE TABLE node ( ' pseudo code alert
id INTEGER PRIMARY KEY,
parentID INTEGER, ' should be a valid id.
)
```
If `parentID` always points to a valid existing node, then this will naturally define a tre... | [This link](http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/) provides a tutorial on both the Adjacency List Model (as described in the question), and the Nested Set Model. It is written as part of the documentation for MySQL.
What is not discussed in that article is insertion/delection time, and m... |
456,174 | <p>I have changed the Treeview.HideSelection = false;
But how do I insure that when focus is lost that the selected item remains the original selected color?</p>
<p>EDIT:</p>
<p>I have a listview on a form that holds a list of process events. Alongside the Treeview on the same form is a series of selections that the... | [
{
"answer_id": 456352,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 1,
"selected": false,
"text": "<p>Generally, you don't. The change in color is one of the visual cues that indicate which control has the focus. Don'... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54009/"
] | I have changed the Treeview.HideSelection = false;
But how do I insure that when focus is lost that the selected item remains the original selected color?
EDIT:
I have a listview on a form that holds a list of process events. Alongside the Treeview on the same form is a series of selections that the user completes t... | Setting `ListView.HideSelection` to true means that when focus is lost, it will hide the selection. By setting `HideSelection` to false, the selected item will still have the color indicator showing which item is selected. |
456,177 | <p>What is the best way(s) to fake function overloading in Javascript? </p>
<p>I know it is not possible to overload functions in Javascript as in other languages.
If I needed a function with two uses <code>foo(x)</code> and <code>foo(x,y,z)</code> which is the best / preferred way:</p>
<ol>
<li>Using different name... | [
{
"answer_id": 456186,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 7,
"selected": false,
"text": "<p>There is no real function overloading in JavaScript since it allows to pass any number of parameters of any type. You hav... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12785/"
] | What is the best way(s) to fake function overloading in Javascript?
I know it is not possible to overload functions in Javascript as in other languages.
If I needed a function with two uses `foo(x)` and `foo(x,y,z)` which is the best / preferred way:
1. Using different names in the first place
2. Using optional arg... | The best way to do function overloading with parameters is not to check the argument length or the types; checking the types will just make your code slow and you have the fun of Arrays, nulls, Objects, etc.
What most developers do is tack on an object as the last argument to their methods. This object can hold anythi... |
456,181 | <p>Is there any way to do the following in HQL:</p>
<pre><code>SELECT
case when flag = true then SUM(col1) else SUM(col2)
FROM
myTable
</code></pre>
| [
{
"answer_id": 456197,
"author": "Henrik Paul",
"author_id": 2238,
"author_profile": "https://Stackoverflow.com/users/2238",
"pm_score": 5,
"selected": true,
"text": "<p>I guess you can (<a href=\"http://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/queryhql.html#queryhql-express... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/493/"
] | Is there any way to do the following in HQL:
```
SELECT
case when flag = true then SUM(col1) else SUM(col2)
FROM
myTable
``` | I guess you can ([3.6](http://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/queryhql.html#queryhql-expressions), [4.3](https://docs.jboss.org/hibernate/orm/4.3/devguide/en-US/html/ch11.html#d5e3280)) *[inline edit]* ...for where-clauses:
>
> "Simple" case, `case ... when ... then ... else ... end`, and "searc... |
456,191 | <p>This code will always make my aspx page load twice. And this has nothing to do with AutoEventWireup.</p>
<pre><code>Response.Clear();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "inline;filename=data.pdf");
Response.BufferOutput = true;
byte[] response = GetDocument(docloc... | [
{
"answer_id": 456234,
"author": "Codingday",
"author_id": 38242,
"author_profile": "https://Stackoverflow.com/users/38242",
"pm_score": 1,
"selected": false,
"text": "<pre><code>GetDocument(doclocation);\n</code></pre>\n\n<p>May be this method somehow returns Redirection code ? or may b... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17211/"
] | This code will always make my aspx page load twice. And this has nothing to do with AutoEventWireup.
```
Response.Clear();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "inline;filename=data.pdf");
Response.BufferOutput = true;
byte[] response = GetDocument(doclocation);
Respon... | Have you found a resolution to this yet? I having the same issue, my code is pretty much a mirror of yours. Main difference is my pdf is hosted in an IFrame.
So interesting clues I have found:
If I stream back a Word.doc it only gets loaded once, if pdf it gets loaded twice. Also, I have seen different behavior from... |
456,211 | <p>In my Android application, when I rotate the device (slide out the keyboard) then my <code>Activity</code> is restarted (<code>onCreate</code> is called). Now, this is probably how it's supposed to be, but I do a lot of initial setting up in the <code>onCreate</code> method, so I need either:</p>
<ol>
<li>Put all t... | [
{
"answer_id": 456371,
"author": "GregD",
"author_id": 38317,
"author_profile": "https://Stackoverflow.com/users/38317",
"pm_score": 6,
"selected": false,
"text": "<p>What you describe is the default behavior. You have to detect and handle these events yourself by adding:</p>\n\n<pre><c... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/764272/"
] | In my Android application, when I rotate the device (slide out the keyboard) then my `Activity` is restarted (`onCreate` is called). Now, this is probably how it's supposed to be, but I do a lot of initial setting up in the `onCreate` method, so I need either:
1. Put all the initial setting up in another function so i... | **Using the Application Class**
Depending on what you're doing in your initialization you could consider creating a new class that extends `Application` and moving your initialization code into an overridden `onCreate` method within that class.
```
public class MyApplicationClass extends Application {
@Override
p... |
456,229 | <p>I'm pretty inexperienced in Remoting. I'm trying to use it and keep receiving WinSock error 10048 when opening TcpChannel.</p>
<p>I use the simplest code from MSDN:</p>
<pre><code> TcpChannel serverChannel = new TcpChannel(9090);
ChannelServices.RegisterChannel(serverChannel);
RemotingConfiguration.Regi... | [
{
"answer_id": 456241,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Prior to asking here I've spent four days trying to solve this, and already here's an answer: it's just WinSock in Windows ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm pretty inexperienced in Remoting. I'm trying to use it and keep receiving WinSock error 10048 when opening TcpChannel.
I use the simplest code from MSDN:
```
TcpChannel serverChannel = new TcpChannel(9090);
ChannelServices.RegisterChannel(serverChannel);
RemotingConfiguration.RegisterWellKnownServiceT... | Prior to asking here I've spent four days trying to solve this, and already here's an answer: it's just WinSock in Windows XP was corrupted.
Two simple Windows commands solved the problem:
netsh int ip reset resetlog.txt
netsh winsock reset |
456,233 | <pre><code>NSMutableArray *a1 = [[NSMutableArray alloc] init];
NSMutableArray *a2 = [NSMutableArray array];
TempObj *obj = [[TempObj alloc] init]; //assume this line is repeated for each obj
[a1 addObject:obj];
[a1 addObject:obj2];
[a1 addObject:obj3];
[a1 addObject:obj4];
[obj release];
[obj2 release];
[obj3 release... | [
{
"answer_id": 456248,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 6,
"selected": true,
"text": "<p>When you add an object to an array, it calls <code>retain</code> on that object. If you don't release your pointer to that ob... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18431/"
] | ```
NSMutableArray *a1 = [[NSMutableArray alloc] init];
NSMutableArray *a2 = [NSMutableArray array];
TempObj *obj = [[TempObj alloc] init]; //assume this line is repeated for each obj
[a1 addObject:obj];
[a1 addObject:obj2];
[a1 addObject:obj3];
[a1 addObject:obj4];
[obj release];
[obj2 release];
[obj3 release];
[obj... | When you add an object to an array, it calls `retain` on that object. If you don't release your pointer to that object, it will be a leak. When you release the array, it will call `release` on all of the objects that it holds, since it called `retain` previously.
As for autorelease vs release, the only way to know for... |
456,259 | <p>I'd like to take a string such as this:</p>
<pre><code>[One, Two[A, B[i, ii, iii, iv], C], Three]
</code></pre>
<p>And convert it into a hierarchy of lists, so that if I execute code such as the following:</p>
<pre><code>Console.Write(myList[1][1][2]);
</code></pre>
<p>The output will be:</p>
<pre><code>iii
</c... | [
{
"answer_id": 456315,
"author": "Spence",
"author_id": 53771,
"author_profile": "https://Stackoverflow.com/users/53771",
"pm_score": 0,
"selected": false,
"text": "<p>Are you after arrays or lists?</p>\n\n<p>This would be extremely difficult to do with strings as you have to deal with s... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23341/"
] | I'd like to take a string such as this:
```
[One, Two[A, B[i, ii, iii, iv], C], Three]
```
And convert it into a hierarchy of lists, so that if I execute code such as the following:
```
Console.Write(myList[1][1][2]);
```
The output will be:
```
iii
```
I'm hoping that this is a common enough requirement that ... | XML or [JSON](http://www.json.org/) are excellent methods to store things like this.
As Spence said--this is a hard problem--I don't recommend rolling your own.
Scroll down to the bottom of that JSON link for implementations in most languages. |
456,263 | <p>If I do an svn copy using two urls, I get a 'cheap' copy in the repository...</p>
<pre><code>svn copy http://repo_url/trunk http://repo_url/tags/release_foo
</code></pre>
<p>But what if do the copy in the working directory and then commit it like this...</p>
<pre><code>svn copy trunk tags/release_foo
svn commit t... | [
{
"answer_id": 456282,
"author": "hacintosh",
"author_id": 50029,
"author_profile": "https://Stackoverflow.com/users/50029",
"pm_score": 2,
"selected": false,
"text": "<p>I believe that a url copy and a WC copy are pretty much the same thing when it comes to being \"cheap\". In your WC ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I do an svn copy using two urls, I get a 'cheap' copy in the repository...
```
svn copy http://repo_url/trunk http://repo_url/tags/release_foo
```
But what if do the copy in the working directory and then commit it like this...
```
svn copy trunk tags/release_foo
svn commit tags/release_foo
```
The copy create... | When you do the copy locally, you will of course incur a space and time cost from copying the files on your local machine (your local filesystem doesn't know about SVN deltas), but when you go to commit, you should see that only the root of the copied directory structure is listed as added (with history). It will thus ... |
456,276 | <pre><code>foreach (var name in parent.names)
{
if name.lastname == null)
{
Violated = true;
this.message = "lastname reqd";
}
if (!Violated)
{
Violated = !(name.firstname == null) ? false : true;
if (ruleViolated)
this.message = "firstname reqd";
}
}... | [
{
"answer_id": 456280,
"author": "configurator",
"author_id": 9536,
"author_profile": "https://Stackoverflow.com/users/9536",
"pm_score": 8,
"selected": false,
"text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/adbctzc4.aspx\" rel=\"noreferrer\"><code>break</code></a>.</p>... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
foreach (var name in parent.names)
{
if name.lastname == null)
{
Violated = true;
this.message = "lastname reqd";
}
if (!Violated)
{
Violated = !(name.firstname == null) ? false : true;
if (ruleViolated)
this.message = "firstname reqd";
}
}
```
... | Use [`break`](http://msdn.microsoft.com/en-us/library/adbctzc4.aspx).
---
Unrelated to your question, I see in your code the line:
```
Violated = !(name.firstname == null) ? false : true;
```
In this line, you take a boolean value `(name.firstname == null)`. Then, you apply the `!` operator to it. Then, if the val... |
456,303 | <p>How can I validate the user input by using scanf. Right now I have something like this, but doesn't work.</p>
<p>NOTE: I have the atoi just to validate that the scanf validation works.</p>
<pre><code>scanf("%[0987654321.-]s",buf);
i = atoi(buf);
if(i)
index = i;
</code></pre>
| [
{
"answer_id": 456305,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": -1,
"selected": false,
"text": "<p>If you're trying to read a number only, use: </p>\n\n<pre><code>int i;\nscanf( \"%d\", &i );\n</code></pre>\n\n<p>... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53797/"
] | How can I validate the user input by using scanf. Right now I have something like this, but doesn't work.
NOTE: I have the atoi just to validate that the scanf validation works.
```
scanf("%[0987654321.-]s",buf);
i = atoi(buf);
if(i)
index = i;
``` | Using `scanf()` is usually a bad idea for user input since failure leaves the `FILE` pointer at an unknown position. That's because `scanf` stands for "scan formatted" and there is little more *unformatted* than user input.
I would suggest using `fgets()` to get a line in, followed by `sscanf()` on the string to actua... |
456,321 | <p>Can someone show me the MySQL equivalent of the following statement (which works in Oracle 10g)?</p>
<pre><code>INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION)
SELECT a.a1, b.ID, b.DENOMINATION FROM (SELECT rownum a1
FROM dual
... | [
{
"answer_id": 457141,
"author": "Nick Pierpoint",
"author_id": 4003,
"author_profile": "https://Stackoverflow.com/users/4003",
"pm_score": 0,
"selected": false,
"text": "<p>The select from <code>DUAL</code> is effectively giving you a large temporary table to join with <code>BOOK</code>... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] | Can someone show me the MySQL equivalent of the following statement (which works in Oracle 10g)?
```
INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION)
SELECT a.a1, b.ID, b.DENOMINATION FROM (SELECT rownum a1
FROM dual
CONN... | The main weirdness going on here is the `SELECT ROWNUM FROM DUAL CONNECT BY...` -- a kludge that's giving you incrementing numbers starting at the value of BOOKS.START\_NUMBER; those then seem to be used as primary keys in the VOUCHER table.
Really, this is a symptom of an awful underlying data model: keeping track o... |
456,346 | <p>What is the exact SQL to assign <code>db_datareader</code> and <code>db_datawriter</code> roles to a user in SQL Server?</p>
<p>The user name is <code>MYUSER</code> and the database is <code>MYDB</code>.</p>
| [
{
"answer_id": 456365,
"author": "cmsjr",
"author_id": 23114,
"author_profile": "https://Stackoverflow.com/users/23114",
"pm_score": 8,
"selected": true,
"text": "<p>In SQL Server 2012, 2014:</p>\n\n<pre><code>USE mydb\nGO\n\nALTER ROLE db_datareader ADD MEMBER MYUSER\nGO\nALTER ROLE db_... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47570/"
] | What is the exact SQL to assign `db_datareader` and `db_datawriter` roles to a user in SQL Server?
The user name is `MYUSER` and the database is `MYDB`. | In SQL Server 2012, 2014:
```
USE mydb
GO
ALTER ROLE db_datareader ADD MEMBER MYUSER
GO
ALTER ROLE db_datawriter ADD MEMBER MYUSER
GO
```
In SQL Server 2008:
```
use mydb
go
exec sp_addrolemember db_datareader, MYUSER
go
exec sp_addrolemember db_datawriter, MYUSER
go
```
To also assign the ability to execute ... |
456,357 | <p>I want to make the line marked with // THIS LINE SHOULD BE PRINTING do its thing, which is print the int values between "synonyms" and "antonyms".</p>
<p>This is the text file:</p>
<p>dictionary.txt</p>
<pre><code>1 cute
2 hello
3 ugly
4 easy
5 difficult
6 tired
7 beautiful
synonyms
1 7
7 1
antonyms
1 3
3 1 7
4 5... | [
{
"answer_id": 456385,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 0,
"selected": false,
"text": "<p>Have you done any diagnostic printing? For example, what is <code>synsAux.size()</code>? Have you checked wh... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45963/"
] | I want to make the line marked with // THIS LINE SHOULD BE PRINTING do its thing, which is print the int values between "synonyms" and "antonyms".
This is the text file:
dictionary.txt
```
1 cute
2 hello
3 ugly
4 easy
5 difficult
6 tired
7 beautiful
synonyms
1 7
7 1
antonyms
1 3
3 1 7
4 5
5 4
7 3
#include <iostream... | The problem seems to be here:
```
in>>myId>>word;
```
On the "synonyms" line the extraction of `myId` fails and sets `failbit` on the stream, which causes the following extractions to also fail. You have to reset the error control state before extracting further elements (like the word "synonyms") from the stream:
... |
456,367 | <p>Is there in the JDK or Jakarta Commons (or anywhere else) a method that can parse the output of Arrays.toString, at least for integer arrays?</p>
<pre><code>int[] i = fromString(Arrays.toString(new int[] { 1, 2, 3} );
</code></pre>
| [
{
"answer_id": 456393,
"author": "Sam",
"author_id": 37575,
"author_profile": "https://Stackoverflow.com/users/37575",
"pm_score": 6,
"selected": true,
"text": "<p>Pretty easy to just do it yourself:</p>\n\n<pre><code>public class Test {\n public static void main(String args[]){\n in... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14955/"
] | Is there in the JDK or Jakarta Commons (or anywhere else) a method that can parse the output of Arrays.toString, at least for integer arrays?
```
int[] i = fromString(Arrays.toString(new int[] { 1, 2, 3} );
``` | Pretty easy to just do it yourself:
```
public class Test {
public static void main(String args[]){
int[] i = fromString(Arrays.toString(new int[] { 1, 2, 3} ));
}
private static int[] fromString(String string) {
String[] strings = string.replace("[", "").replace("]", "").split(", ");
int result[] =... |
456,379 | <p>When reading source code, I always want to know the full path of the file when it is loaded, is there any callback method in ruby to accomplish this, or any other way to do this? thanks in advance.</p>
<p><strong>EDIT</strong> Clarification from the comments:</p>
<p>I want to know where the loaded "somefile" is lo... | [
{
"answer_id": 456411,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "https://Stackoverflow.com/users/23071",
"pm_score": 4,
"selected": true,
"text": "<p>The best way I can think of is to patch the <code>Kernel</code> module. According to the <a href=\"http://www.rub... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44512/"
] | When reading source code, I always want to know the full path of the file when it is loaded, is there any callback method in ruby to accomplish this, or any other way to do this? thanks in advance.
**EDIT** Clarification from the comments:
I want to know where the loaded "somefile" is located while I execute this lin... | The best way I can think of is to patch the `Kernel` module. According to the [docs](http://www.ruby-doc.org/core/classes/Kernel.html#M005966) `Kernel::load` searches `$:` for the filename. We can do the same thing and print the path if we find it.
```
module Kernel
def load_and_print(string)
$:.each do |p|
... |
456,383 | <p>Is there anyone here with experience writing custom Linq providers?</p>
<p>What I'm trying to do is tell whether a MemberExpression that is a property on a business object should be included in the SQL, or treated as a constant, because its from a local variable that just happens to be a business object.</p>
<p>So... | [
{
"answer_id": 456411,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "https://Stackoverflow.com/users/23071",
"pm_score": 4,
"selected": true,
"text": "<p>The best way I can think of is to patch the <code>Kernel</code> module. According to the <a href=\"http://www.rub... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/489/"
] | Is there anyone here with experience writing custom Linq providers?
What I'm trying to do is tell whether a MemberExpression that is a property on a business object should be included in the SQL, or treated as a constant, because its from a local variable that just happens to be a business object.
So for example, if ... | The best way I can think of is to patch the `Kernel` module. According to the [docs](http://www.ruby-doc.org/core/classes/Kernel.html#M005966) `Kernel::load` searches `$:` for the filename. We can do the same thing and print the path if we find it.
```
module Kernel
def load_and_print(string)
$:.each do |p|
... |
456,388 | <p>I'm trying to get an application (a game) to start with a Java script. There is a long explanation behind why, so I'll skip that part.</p>
<p>The game won't run unless it is executed from its own directory, IE: Just telling Java to launch the EXE gives errors within the game. It must be launched from its directory.... | [
{
"answer_id": 456448,
"author": "Dave Ray",
"author_id": 40310,
"author_profile": "https://Stackoverflow.com/users/40310",
"pm_score": 3,
"selected": false,
"text": "<p>Try this instead:</p>\n\n<pre><code>String workingDir = \"F:\\\\Games\\\\COD4\\\\\";\nString cmd = workingDir + \"iw3m... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to get an application (a game) to start with a Java script. There is a long explanation behind why, so I'll skip that part.
The game won't run unless it is executed from its own directory, IE: Just telling Java to launch the EXE gives errors within the game. It must be launched from its directory.
I've Goo... | Try this instead:
```
String workingDir = "F:\\Games\\COD4\\";
String cmd = workingDir + "iw3mp.exe";
Runtime.getRuntime().exec(cmd,null,new File(workingDir));
```
iw3mp.exe probably isn't on your system path so you have to give Java an absolute path to the executable. |
456,427 | <p>So say I have a <code>products</code> table with a list of products, and one of the fields is <code>price</code>. This table also has an <code>id</code> field. When someone makes a purchase I insert a row into another table called <code>purchases</code>. This table also has a field called <code>price</code> and a <c... | [
{
"answer_id": 456436,
"author": "Michael Buen",
"author_id": 11432,
"author_profile": "https://Stackoverflow.com/users/11432",
"pm_score": 2,
"selected": false,
"text": "<p>possible:</p>\n\n<pre><code>insert into purchases(purchase_id, product_id, price) \nselect 88, product_id, current... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66475/"
] | So say I have a `products` table with a list of products, and one of the fields is `price`. This table also has an `id` field. When someone makes a purchase I insert a row into another table called `purchases`. This table also has a field called `price` and a `productid` field that maps to the products table `id` field... | Sure. In my normal practice I'd just be sending the price as part of the insert, but if you truly need to extract it from the product table at that point, you can do it with a subselect, like:
```
INSERT INTO `purchase`
SET `product_id` = $whatever,
`price` = (
SELECT `price`
FROM `product`
WHERE `id` = $w... |
456,433 | <p>I was wondering if there are any times where it's advantageous to use an IEnumerator over a foreach loop for iterating through a collection? For example, is there any time where it would be better to use either of the following code samples over the other?</p>
<pre><code>IEnumerator<MyClass> classesEnum = myC... | [
{
"answer_id": 456439,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 4,
"selected": false,
"text": "<p>In C#, <code>foreach</code> is doing exactly the same thing as the <code>IEnumerator</code> code that you posted above. The ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/493/"
] | I was wondering if there are any times where it's advantageous to use an IEnumerator over a foreach loop for iterating through a collection? For example, is there any time where it would be better to use either of the following code samples over the other?
```
IEnumerator<MyClass> classesEnum = myClasses.GetEnumerator... | First, note that one big difference in your example (between `foreach` and `GetEnumerator`) is that `foreach` guarantees to call `Dispose()` on the iterator if the iterator is `IDisposable`. This is important for many iterators (which might be consuming an external data feed, for example).
Actually, there are cases wh... |
456,446 | <p>I'm getting the following error on the line of code below: </p>
<p>Syntax error (missing operator) in query expression 'REPLACE(LTRIM(RTRIM(ATTACHMENTS)), ,'')'.</p>
<p>Any help would be awesome...</p>
<pre><code>-----------the line of code that is giving me problems--------------------------------
objConn.Execu... | [
{
"answer_id": 456453,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>I think you're missing some quotes - check before and after the StoredPath variable:</p>\n\n<p>objConn.Execute(\"UPDATE EMAI... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56327/"
] | I'm getting the following error on the line of code below:
Syntax error (missing operator) in query expression 'REPLACE(LTRIM(RTRIM(ATTACHMENTS)), ,'')'.
Any help would be awesome...
```
-----------the line of code that is giving me problems--------------------------------
objConn.Execute("UPDATE EMAIL_SEND_ATTACH... | I think you're missing some quotes - check before and after the StoredPath variable:
objConn.Execute("UPDATE EMAIL\_SEND\_ATTACHMENTS set ATTACHMENTS = REPLACE(LTRIM(RTRIM(ATTACHMENTS)), '"& StoredPath & "' ,'') WHERE EMAIL\_LETTERS\_HOLD\_ID= "& AttID & " ")
Andy. |
456,467 | <p>How can I get the underlying DataItem from a GridView row that is in edit mode and the user clicks on "Update"?</p>
<p>I have an editable GridView. I've added a CustomValidator to the Edit view of one of the columns. When the user clicks on Update I run a server validate method and need to get the underlying Data... | [
{
"answer_id": 456618,
"author": "Kosta",
"author_id": 28327,
"author_profile": "https://Stackoverflow.com/users/28327",
"pm_score": 4,
"selected": true,
"text": "<pre><code>GridView1.DataKeys[GridView1.EditIndex].Value;\n</code></pre>\n"
},
{
"answer_id": 1944211,
"author": ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32892/"
] | How can I get the underlying DataItem from a GridView row that is in edit mode and the user clicks on "Update"?
I have an editable GridView. I've added a CustomValidator to the Edit view of one of the columns. When the user clicks on Update I run a server validate method and need to get the underlying DataItem of the ... | ```
GridView1.DataKeys[GridView1.EditIndex].Value;
``` |
456,471 | <p>When debugging everything appears good. The insert commits and there is no roll back, no exceptions. I sure hope some can help with this. </p>
<p>Here is my call:</p>
<pre><code>using (ITransaction transaction = _session.BeginTransaction())
{
_session.Save(calc);
transaction.Commit();... | [
{
"answer_id": 456485,
"author": "Scott Muc",
"author_id": 1894,
"author_profile": "https://Stackoverflow.com/users/1894",
"pm_score": 0,
"selected": false,
"text": "<p>What happens if you call:</p>\n\n<pre><code>session.Flush();\n</code></pre>\n\n<p>before the transaction Commit? What i... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56256/"
] | When debugging everything appears good. The insert commits and there is no roll back, no exceptions. I sure hope some can help with this.
Here is my call:
```
using (ITransaction transaction = _session.BeginTransaction())
{
_session.Save(calc);
transaction.Commit();
}
```
Real ... | I'm a bonehead! Make sure you set your PK to a... PK..
Shheesh.. I need to take a break :) |
456,481 | <p>I can't seem to get Python to import a module in a subfolder. I get the error when I try to create an instance of the class from the imported module, but the import itself succeeds. Here is my directory structure:</p>
<pre><code>Server
-server.py
-Models
--user.py
</code></pre>
<p>Here's the conten... | [
{
"answer_id": 456491,
"author": "Dana",
"author_id": 7856,
"author_profile": "https://Stackoverflow.com/users/7856",
"pm_score": 8,
"selected": true,
"text": "<p>I believe you need to create a file called <code>__init__.py</code> in the Models directory so that python treats it as a mod... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49018/"
] | I can't seem to get Python to import a module in a subfolder. I get the error when I try to create an instance of the class from the imported module, but the import itself succeeds. Here is my directory structure:
```
Server
-server.py
-Models
--user.py
```
Here's the contents of server.py:
```
from... | I believe you need to create a file called `__init__.py` in the Models directory so that python treats it as a module.
Then you can do:
```
from Models.user import User
```
You can include code in the `__init__.py` (for instance initialization code that a few different classes need) or leave it blank. But it must b... |
456,488 | <p>I have created a delphi component which descends from TGraphicControl. Is it possible to add support for mouse wheels?<br></p>
<p>--- Edit ---</p>
<p>I've exposed the MouseWheel events as shown below but they aren't called. </p>
<pre><code>TMyComponent = class(TGraphicControl)
published
property OnMouseWheel;
... | [
{
"answer_id": 456622,
"author": "Francesca",
"author_id": 9842,
"author_profile": "https://Stackoverflow.com/users/9842",
"pm_score": 0,
"selected": false,
"text": "<p>Trap the WM_MOUSEWHEEL message.</p>\n"
},
{
"answer_id": 456625,
"author": "Rob Kennedy",
"author_id": ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51972/"
] | I have created a delphi component which descends from TGraphicControl. Is it possible to add support for mouse wheels?
--- Edit ---
I've exposed the MouseWheel events as shown below but they aren't called.
```
TMyComponent = class(TGraphicControl)
published
property OnMouseWheel;
property OnMouseWheelDown;
... | Due to several VCL constructs (whether they are deliberate implementation choices or may possibly be bugs1), I leave in the middle) only the focused control and all its parents get mouse wheel messages, as well as the control which has the mouse captured ánd has a focused parent.
At the `TControl` level, the latter co... |
456,489 | <p>I am a newbie in Wap/Wml. I have to develop a certain portion of existing php/mysql website so that people can access certain information from their mobile phone. I have the following doubts:</p>
<p>1) In which language should I deveop this mobile portion? I am guessing WML. But if I develop it in WML, will it wok ... | [
{
"answer_id": 456759,
"author": "Dror",
"author_id": 48317,
"author_profile": "https://Stackoverflow.com/users/48317",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li>There are many devices that can\nhandle XHTML - but most will also\naccept WML.</li>\n<li>See <a href=\"http://deve... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am a newbie in Wap/Wml. I have to develop a certain portion of existing php/mysql website so that people can access certain information from their mobile phone. I have the following doubts:
1) In which language should I deveop this mobile portion? I am guessing WML. But if I develop it in WML, will it wok in all mob... | I have developed a couple of applications in the past using php and wml and will share some of the things I encountered.
1) You can use wml for the interface but has limited functionality while the xhtml mobile profile allows you to do more with your wap site, before committing to wml I would say spend some time explo... |
456,508 | <p>What would be the best way to search through HTML inside a C# string variable to find a specific word/phrase and mark (or wrap) that word/phrase with a highlight?</p>
<p>Thanks,</p>
<p>Jeff</p>
| [
{
"answer_id": 456511,
"author": "Eddie Parker",
"author_id": 56349,
"author_profile": "https://Stackoverflow.com/users/56349",
"pm_score": 1,
"selected": false,
"text": "<p>Regular Expression would be my way. ;)</p>\n"
},
{
"answer_id": 456516,
"author": "Greg Leaver",
"... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12172/"
] | What would be the best way to search through HTML inside a C# string variable to find a specific word/phrase and mark (or wrap) that word/phrase with a highlight?
Thanks,
Jeff | I like using [Html Agility Pack](http://www.codeplex.com/htmlagilitypack) very easy to use, although there hasn't been much updates lately, it is still usable. For example grabbing all the links
```
HtmlWeb client = new HtmlWeb();
HtmlDocument doc = client.Load("http://yoururl.com");
HtmlNodeCollection Nod... |
456,519 | <p>How do I emulate an HTTP POST request using curl and capturing the result on a text file? I already have a script called dump.php:</p>
<pre><code><?php
$var = print_r($GLOBALS, true);
$fp = fopen('raw-post.txt','w');
fputs($fp,$var);
fclose($fp);
?>
</code></pre>
<p>I did a simple test by doing:</p>
... | [
{
"answer_id": 456536,
"author": "Evan Fosmark",
"author_id": 49701,
"author_profile": "https://Stackoverflow.com/users/49701",
"pm_score": 2,
"selected": false,
"text": "<p>You need to use <code>$_GLOBALS</code> rather than <code>$GLOBALS</code>.</p>\n\n<p>Additionally, you can do this ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56543/"
] | How do I emulate an HTTP POST request using curl and capturing the result on a text file? I already have a script called dump.php:
```
<?php
$var = print_r($GLOBALS, true);
$fp = fopen('raw-post.txt','w');
fputs($fp,$var);
fclose($fp);
?>
```
I did a simple test by doing:
```
curl -d 'echo=hello' http://loc... | You need to use `$_GLOBALS` rather than `$GLOBALS`.
Additionally, you can do this instead of using output buffering:
```
$var = print_r($_GLOBALS, true);
```
Providing the `true` as a second parameter to `print_r` will return the result rather than automatically printing it. |
456,523 | <p>I am querying information from <a href="http://en.wikipedia.org/wiki/Active_Directory" rel="nofollow noreferrer">Active Directory</a>. I have code that works, but it's really slow.</p>
<p>This is the code I currently use:</p>
<pre><code> static void Main(string[] args)
{
SearchResultCollection sResult... | [
{
"answer_id": 456548,
"author": "Handleman",
"author_id": 10309,
"author_profile": "https://Stackoverflow.com/users/10309",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure how much of your \"slowness\" will be due to the loop you're doing to find entries with particular attri... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23491/"
] | I am querying information from [Active Directory](http://en.wikipedia.org/wiki/Active_Directory). I have code that works, but it's really slow.
This is the code I currently use:
```
static void Main(string[] args)
{
SearchResultCollection sResults = null;
try
{
//modify th... | The reason why your code is slow is that your [LDAP](http://en.wikipedia.org/wiki/LDAP) query retrieves every single user object in your domain even though you're only interested in one user with a common name of "Adit":
```
dSearcher.Filter = "(&(objectClass=user))";
```
So to optimize, you need to narrow your LDAP... |
456,524 | <p>I would like to be able to programmatically emulate a shutter button press on my Casio Exilim EX-F1 digital camera.</p>
<p>It comes with a USB tethered remote control that can emulate a shutter press, so I would think there is a way to emulate that from a PC.</p>
<p>I've looked and can't find any libraries or anyt... | [
{
"answer_id": 456548,
"author": "Handleman",
"author_id": 10309,
"author_profile": "https://Stackoverflow.com/users/10309",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure how much of your \"slowness\" will be due to the loop you're doing to find entries with particular attri... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54225/"
] | I would like to be able to programmatically emulate a shutter button press on my Casio Exilim EX-F1 digital camera.
It comes with a USB tethered remote control that can emulate a shutter press, so I would think there is a way to emulate that from a PC.
I've looked and can't find any libraries or anything for controll... | The reason why your code is slow is that your [LDAP](http://en.wikipedia.org/wiki/LDAP) query retrieves every single user object in your domain even though you're only interested in one user with a common name of "Adit":
```
dSearcher.Filter = "(&(objectClass=user))";
```
So to optimize, you need to narrow your LDAP... |
456,532 | <p>I have a program that pulls a large dataset from Oracle 10g (10.2.0.3) using a fairly-straightforward query. You could almost call the query/logic an "export" of sorts in that it selects the columns from a table with a minimal where clause (i.e., it returns most of, if not all, the rows).</p>
<p>The [Java] code is... | [
{
"answer_id": 456844,
"author": "Gary Myers",
"author_id": 25714,
"author_profile": "https://Stackoverflow.com/users/25714",
"pm_score": 1,
"selected": false,
"text": "<p>Is PERSON a table or view ?</p>\n\n<p>At some point, under the covers, Java must be working out a data length for th... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54384/"
] | I have a program that pulls a large dataset from Oracle 10g (10.2.0.3) using a fairly-straightforward query. You could almost call the query/logic an "export" of sorts in that it selects the columns from a table with a minimal where clause (i.e., it returns most of, if not all, the rows).
The [Java] code is boilerplat... | Is PERSON a table or view ?
At some point, under the covers, Java must be working out a data length for the data. And I guess it is doing it wrong. Firstly, remove the columns one-by-one so you can identify which column is going wrong. Then maybe go through the data in chunks (eg 1-100000, 100001-200000 etc), to find ... |
456,546 | <p>I want to make sure a file path set via query string does not go outside of the desired subdirectory. Right now, I am checking that:</p>
<ol>
<li>The path does not start with "<code>/</code>", to prevent the user from giving an absolute path.</li>
<li>The path does not contain "<code>..</code>", to prevent the use... | [
{
"answer_id": 456558,
"author": "sth",
"author_id": 56338,
"author_profile": "https://Stackoverflow.com/users/56338",
"pm_score": 4,
"selected": true,
"text": "<p>Call</p>\n\n<pre><code>$path = realpath(\"sample/$path\");\n</code></pre>\n\n<p>Then check that the resulting path starts wi... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] | I want to make sure a file path set via query string does not go outside of the desired subdirectory. Right now, I am checking that:
1. The path does not start with "`/`", to prevent the user from giving an absolute path.
2. The path does not contain "`..`", to prevent the user from giving a path that is outside of th... | Call
```
$path = realpath("sample/$path");
```
Then check that the resulting path starts with the directory you're expecting. |
456,551 | <p>None of the guides/notes/articles that discuss <code>IDisposable</code> pattern suggest that one should set the internal members to <code>null</code> in the <code>Dispose(bool)</code> method (especially if they are memory hogging beasts).</p>
<p>I've come to realize the importance of it while debugging an internal ... | [
{
"answer_id": 456564,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 0,
"selected": false,
"text": "<p>Well, generally, it's not going to make a difference. The only place where it will make a difference is when you hav... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42913/"
] | None of the guides/notes/articles that discuss `IDisposable` pattern suggest that one should set the internal members to `null` in the `Dispose(bool)` method (especially if they are memory hogging beasts).
I've come to realize the importance of it while debugging an internal benchmark tool. What used to happen was tha... | Releasing any additional references during `Dispose` is certainly something I try to do, for two reasons:
* it allows the inner objects to be garbage collected even if the disposed object is still in scope
* if the inner objects are disposable, it means we only dispose them once even if `Dispose()` is called repeatedl... |
456,552 | <p>I'm struggling to understand something about GIT.</p>
<p>We've got a repository with a number of branches in it. I can fetch a local copy of one of those branches (git checkout -b ...), make some changes, then push them back. If I fail to tag the end of the branch, however, how do other users get the head of the br... | [
{
"answer_id": 456565,
"author": "mipadi",
"author_id": 28804,
"author_profile": "https://Stackoverflow.com/users/28804",
"pm_score": 4,
"selected": true,
"text": "<p>It <em>sounds</em> like you're doing the right thing. The name of a branch is simply a pointer to the latest commit on th... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/826/"
] | I'm struggling to understand something about GIT.
We've got a repository with a number of branches in it. I can fetch a local copy of one of those branches (git checkout -b ...), make some changes, then push them back. If I fail to tag the end of the branch, however, how do other users get the head of the branch? WHen... | It *sounds* like you're doing the right thing. The name of a branch is simply a pointer to the latest commit on the branch. Are you sure you're comming *and* pushing the changes back to the repo that everyone is pulling from? When you commit, you're only committing to *your* local repo, so to get changes, collaboration... |
456,568 | <p>Previously I've asked about <a href="https://stackoverflow.com/questions/351557/how-does-one-insert-a-column-into-a-dataset-between-two-existing-columns">inserting a column into a dataset</a>. I now have a similar question...namely merging two or more columns into a single column.</p>
<p>Lets say I have the followi... | [
{
"answer_id": 456580,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 1,
"selected": false,
"text": "<p>If the dataset is specific enough, a MergeName() method is fine. This is especially true if you don't think you'll be u... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39532/"
] | Previously I've asked about [inserting a column into a dataset](https://stackoverflow.com/questions/351557/how-does-one-insert-a-column-into-a-dataset-between-two-existing-columns). I now have a similar question...namely merging two or more columns into a single column.
Lets say I have the following data set:
```
Dat... | it seems to me that this should happen in the data layer and not the logic layer. presumably the dataset consumer knows what data it needs and could request it from the datastore explicitly, without having to manipulate datasets.
in a database scenario, i'm essentially proponing a multiple stored procedure approach an... |
456,575 | <pre><code> public class WrapperTest {
public static void main(String[] args) {
Integer i = 100;
Integer j = 100;
if(i == j)
System.out.println("same");
else
System.out.println("not same");
}
}
</code></pre>
<p>The above code gives the output of <... | [
{
"answer_id": 456578,
"author": "tunaranch",
"author_id": 27708,
"author_profile": "https://Stackoverflow.com/users/27708",
"pm_score": 2,
"selected": false,
"text": "<p>It's to do with equality and autoboxing: <a href=\"http://web.archive.org/web/20090220142800/http://davidflanagan.com... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40933/"
] | ```
public class WrapperTest {
public static void main(String[] args) {
Integer i = 100;
Integer j = 100;
if(i == j)
System.out.println("same");
else
System.out.println("not same");
}
}
```
The above code gives the output of `same` when run, how... | In Java, Integers between -128 and 127 (inclusive) are generally represented by the same Integer object instance. This is handled by the use of a inner class called IntegerCache (contained inside the Integer class, and used e.g. when Integer.valueOf() is called, or during autoboxing):
```
private static class IntegerC... |
456,596 | <p>I have a ASP.NET user control which hosts a 'HtmlImage'. The src attribute is successfully set at run-time, but adding the rendered control to another container causes a loss of the src attribute.</p>
<p>The rendered control is stored in Session (I know this is not ideal). Then a redirect is done to another page wh... | [
{
"answer_id": 456609,
"author": "Jomit",
"author_id": 49730,
"author_profile": "https://Stackoverflow.com/users/49730",
"pm_score": 0,
"selected": false,
"text": "<p>Do you have fix layout for different partners ? Or do you want the partners to choose the layouts on runtime ? </p>\n\n<p... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27765/"
] | I have a ASP.NET user control which hosts a 'HtmlImage'. The src attribute is successfully set at run-time, but adding the rendered control to another container causes a loss of the src attribute.
The rendered control is stored in Session (I know this is not ideal). Then a redirect is done to another page which uses t... | you can use CSS to position your content sections anywhere on your page. so i wouldnt worry about page locations, etc.
if it were me, i'd just dynamically load the 2 different css files into the one masterpage and based on the same logic render the different content into the placeholders. |
456,616 | <p>I am having a couple of issues deciding how best to describe a certain data structure in C# (.NET 3.5).</p>
<p>I have to create a class library that creates some text files for the input of a command line program. There are dozens of file types, but most of them have a similar header, footer and a couple of other p... | [
{
"answer_id": 457055,
"author": "ELLIOTTCABLE",
"author_id": 31897,
"author_profile": "https://Stackoverflow.com/users/31897",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not aware of a library or framework. I'd think doing so wouldn't be too hard — I'm new to Cocoa, but I'd proba... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56564/"
] | I am having a couple of issues deciding how best to describe a certain data structure in C# (.NET 3.5).
I have to create a class library that creates some text files for the input of a command line program. There are dozens of file types, but most of them have a similar header, footer and a couple of other properties.... | I've written a class (called [ANSIEscapeHelper](http://hasseg.org/ansiEscapeHelper/)) to translate between `NSStrings` that contain ANSI escape sequences and similarly formatted `NSAttributedStrings`. It's released under the MIT License. |
456,624 | <p>I wish to set an attribute on a public property in .NET, however I do not have access to the explicit property itself, as this has been code generated in another file.</p>
<p>I have this field:</p>
<pre><code>public virtual string Name { get; set; }
</code></pre>
<p>I wish to set this:</p>
<pre><code>[ValidateNo... | [
{
"answer_id": 456652,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "<p>This is a known nuisance; you simply can't add metadata to the generated members.</p>\n\n<p>There are 6 options her... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41211/"
] | I wish to set an attribute on a public property in .NET, however I do not have access to the explicit property itself, as this has been code generated in another file.
I have this field:
```
public virtual string Name { get; set; }
```
I wish to set this:
```
[ValidateNonEmpty("Name is required", ExecutionOrder = ... | This is a known nuisance; you simply can't add metadata to the generated members.
There are 6 options here (in order of increasing effort):
* if you own the attribute, make it possible to declare it against the class, for example: `[ValidateNonEmpty("Name", "Name is required", ExecutionOrder = 1)]` - then add multipl... |
456,628 | <p>I'm writing a windows service application, which will be accessed through .NET Remoting.
The problem is I can't figure out how to access service objects from remotable class.</p>
<p>For example, I've a handler class:</p>
<pre><code>class Service_console_handler
{
public int something_more = 20;
//some ... | [
{
"answer_id": 463507,
"author": "Theo Lenndorff",
"author_id": 53881,
"author_profile": "https://Stackoverflow.com/users/53881",
"pm_score": 3,
"selected": false,
"text": "<p>What you want is somehow to access the instance of <code>ServiceConsoleHandler</code> via a <code>RemoteObject</... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm writing a windows service application, which will be accessed through .NET Remoting.
The problem is I can't figure out how to access service objects from remotable class.
For example, I've a handler class:
```
class Service_console_handler
{
public int something_more = 20;
//some code...
... | What you want is somehow to access the instance of `ServiceConsoleHandler` via a `RemoteObject` instance, which is visible for the client.
For this you need to consider two things: (1) Get control over the object construction of the `RemoteObject` instance and make it accessible and (2) modify `ServiceConsoleHandler` ... |
456,633 | <p>Let's say I have a class called Store that has many Employees. My RESTful listXML method looks like this:</p>
<pre><code>def listXML = {
render Store.list() as XML
}
</code></pre>
<p>And the result looks like this:</p>
<pre><code><stores>
<store id="1">
<name>My Store</name>
&l... | [
{
"answer_id": 456637,
"author": "Rob Hruska",
"author_id": 29995,
"author_profile": "https://Stackoverflow.com/users/29995",
"pm_score": 4,
"selected": true,
"text": "<p>In your controller, you'll want to import the deep converter:</p>\n\n<pre><code>import grails.converters.deep.XML\n</... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16534/"
] | Let's say I have a class called Store that has many Employees. My RESTful listXML method looks like this:
```
def listXML = {
render Store.list() as XML
}
```
And the result looks like this:
```
<stores>
<store id="1">
<name>My Store</name>
<employees>
<employee id="1" />
</employees>
</store>... | In your controller, you'll want to import the deep converter:
```
import grails.converters.deep.XML
```
You can read about it in the first couple of paragraphs of the [Converters Reference](http://grails.org/Converters+Reference). |
456,634 | <p>When I'm debugging, I often have to deal with methods that does not use an intermediate variable to store the return value :</p>
<pre><code> private int myMethod_1()
{
return 12;
}
private int myMethod_2()
{
return someCall( someValue );
}
</code></pre>
<p>Well, in order to recreate a... | [
{
"answer_id": 456651,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": -1,
"selected": false,
"text": "<p>I think you can do it in Visual Studio but that feels dirty to me. </p>\n\n<p>My thoughts are you should really be look... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54783/"
] | When I'm debugging, I often have to deal with methods that does not use an intermediate variable to store the return value :
```
private int myMethod_1()
{
return 12;
}
private int myMethod_2()
{
return someCall( someValue );
}
```
Well, in order to recreate a bug, I often have to chan... | **For those who are looking for a solution to this in VB.NET:**
It was so simple, I can't believe I did not see it : To look at the value a function will return : just place the pointer over the function's name. The value will be shown in a tool tip.
The change the value : just click on this tool tip, change the valu... |
456,636 | <p>How do I pass parameters to a JAR file at the time of execution?</p>
| [
{
"answer_id": 456697,
"author": "Xn0vv3r",
"author_id": 42475,
"author_profile": "https://Stackoverflow.com/users/42475",
"pm_score": 5,
"selected": false,
"text": "<p>The <a href=\"https://docs.oracle.com/en/java/javase/12/tools/jar.html#GUID-51C11B76-D9F6-4BC2-A805-3C847E857867\" rel=... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I pass parameters to a JAR file at the time of execution? | To pass arguments to the jar:
```
java -jar myjar.jar one two
```
You can access them in the main() method of "Main-Class" (mentioned in the `manifest.mf` file of a JAR).
```
String one = args[0];
String two = args[1];
``` |
456,644 | <p>I tried running the following statement:</p>
<pre><code>INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION)
SELECT (a.number, b.ID, b.DENOMINATION)
FROM temp_cheques a, BOOK b
WHERE a.number BETWEEN b.START_NUMBER AND b.START_NUMBER+b.UNITS-1;
</code></pre>
<p>which, as I understand it, should insert into... | [
{
"answer_id": 456657,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 2,
"selected": false,
"text": "<p>Does B contain the UNITS column?</p>\n\n<p>What is the table structure for temp_cheques and Book?</p>\n\n<p>EDIT: A... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] | I tried running the following statement:
```
INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION)
SELECT (a.number, b.ID, b.DENOMINATION)
FROM temp_cheques a, BOOK b
WHERE a.number BETWEEN b.START_NUMBER AND b.START_NUMBER+b.UNITS-1;
```
which, as I understand it, should insert into VOUCHER each record from ... | Try removing the parenthesis from the SELECT clause. From [Microsoft TechNet](http://technet.microsoft.com/en-us/library/ms188263.aspx), the correct syntax for an INSERT statement using a SELECT clause is the following.
```
INSERT INTO MyTable (PriKey, Description)
SELECT ForeignKey, Description
FROM So... |
456,672 | <p>I'm new to Python and need some advice implementing the scenario below.</p>
<p>I have two classes for managing domains at two different registrars. Both have the same interface, e.g.</p>
<pre><code>class RegistrarA(Object):
def __init__(self, domain):
self.domain = domain
def lookup(self):
... | [
{
"answer_id": 456731,
"author": "Jeff Bauer",
"author_id": 41759,
"author_profile": "https://Stackoverflow.com/users/41759",
"pm_score": 5,
"selected": false,
"text": "<p>Assuming you need separate classes for different registrars (though it's not obvious in your example) your solution ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm new to Python and need some advice implementing the scenario below.
I have two classes for managing domains at two different registrars. Both have the same interface, e.g.
```
class RegistrarA(Object):
def __init__(self, domain):
self.domain = domain
def lookup(self):
...
def registe... | I think using a function is fine.
The more interesting question is how do you determine which registrar to load? One option is to have an abstract base Registrar class which concrete implementations subclass, then iterate over its `__subclasses__()` calling an `is_registrar_for()` class method:
```
class Registrar(ob... |
456,673 | <p>When i give wrong number of parameters in a function , i get errors.
How do I handle it?</p>
<p>I gave </p>
<pre><code>def fun_name(...):
try:
...
except TypeError:
print 'Wrong no of arg'
</code></pre>
<p>It is not working.</p>
<p>Help please.</p>
| [
{
"answer_id": 456679,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": -1,
"selected": false,
"text": "<p>If you remove the <code>try...catch</code> parts it should show you what kind of exception it is throwing.</p>\n... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46646/"
] | When i give wrong number of parameters in a function , i get errors.
How do I handle it?
I gave
```
def fun_name(...):
try:
...
except TypeError:
print 'Wrong no of arg'
```
It is not working.
Help please. | The caller triggers this exception, not the receiver.
If you want the receiving function to explicitly check argument count you'll need to use varargs:
```
def fun_name(*args):
if len(args) != 2:
raise TypeError('Two arguments required')
``` |
456,684 | <p>I wrote an Oracle SQL expression like this:</p>
<pre><code>SELECT
...
FROM mc_current_view a
JOIN account_master am USING (account_no)
JOIN account_master am_loan ON (am.account_no = am_loan.parent_account_no)
JOIN ml_client_account mca USING (account_no)
</code></pre>
<p>When I try to run it, Oracle throws an err... | [
{
"answer_id": 457090,
"author": "Nick Pierpoint",
"author_id": 4003,
"author_profile": "https://Stackoverflow.com/users/4003",
"pm_score": 3,
"selected": false,
"text": "<p>My preference is never to use <strong>USING</strong>; always use <strong>ON</strong>. I like to my SQL to be very ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10557/"
] | I wrote an Oracle SQL expression like this:
```
SELECT
...
FROM mc_current_view a
JOIN account_master am USING (account_no)
JOIN account_master am_loan ON (am.account_no = am_loan.parent_account_no)
JOIN ml_client_account mca USING (account_no)
```
When I try to run it, Oracle throws an error in the line with "ON" s... | The error message is actually (surprise!) telling you exactly what the problem is. Once you use the USING clause for a particular column, you cannot use a column qualifier/table alias for that column name in any other part of your query. The only way to resolve this is to not use the USING clause anywhere in your query... |
456,691 | <p>Imagine I have the following:</p>
<pre><code>private IEnumerable MyFunc(parameter a)
{
using(MyDataContext dc = new MyDataContext)
{
return dc.tablename.Select(row => row.parameter == a);
}
}
private void UsingFunc()
{
var result = MyFunc(new a());
foreach(var row in result)
{
//D... | [
{
"answer_id": 456698,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>I would expect that to simply not work; the <code>Select</code> is deferred, so no data has been consumed at this p... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53771/"
] | Imagine I have the following:
```
private IEnumerable MyFunc(parameter a)
{
using(MyDataContext dc = new MyDataContext)
{
return dc.tablename.Select(row => row.parameter == a);
}
}
private void UsingFunc()
{
var result = MyFunc(new a());
foreach(var row in result)
{
//Do something
}
... | I would expect that to simply not work; the `Select` is deferred, so no data has been consumed at this point. However, since you have disposed the data-context (before leaving `MyFunc`), it will never be able to get data. A better option is to pass the data-context *into* the method, so that the consumer can choose the... |
456,696 | <p>Youll need a 64bit machine if you want to see the actuall exception. I've created some dummy classes that repro's the problem.</p>
<pre><code>[StructLayout(LayoutKind.Sequential, Pack = 1)]
public class InnerType
{
char make;
char model;
UInt16 series;
}
[StructLayout(LayoutKin... | [
{
"answer_id": 456850,
"author": "Sebastian",
"author_id": 56440,
"author_profile": "https://Stackoverflow.com/users/56440",
"pm_score": -1,
"selected": false,
"text": "<p>Maybe there goes something Wrong with the Uint16 due to it's not CLS Compliant (see here: <a href=\"http://msdn.micr... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Youll need a 64bit machine if you want to see the actuall exception. I've created some dummy classes that repro's the problem.
```
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public class InnerType
{
char make;
char model;
UInt16 series;
}
[StructLayout(LayoutKind.Explicit)]
... | The part about overlapping types is misleading here. The problem is that in .Net reference types must always be aligned on pointer size boundaries. Your union works in x86 since the field offset is 4 bytes which is the pointer size for a 32 bit system but fails on x64 since there it must be offset a multiple of 8. The ... |
456,721 | <p>I'm looking for a way to write a custom .net class that would allow for nested methods.</p>
<p>For example... say I have a class X with a function Y that returns a list. Then I have another function that returns a sorted list...</p>
<p>I would like to be able to do something like x.y().z() where z would accept th... | [
{
"answer_id": 456734,
"author": "Steve Wright",
"author_id": 3256,
"author_profile": "https://Stackoverflow.com/users/3256",
"pm_score": 1,
"selected": false,
"text": "<p>Extension methods might be what you are looking for (can accept the output of y()), but that depends on the version ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm looking for a way to write a custom .net class that would allow for nested methods.
For example... say I have a class X with a function Y that returns a list. Then I have another function that returns a sorted list...
I would like to be able to do something like x.y().z() where z would accept the output of y() as... | Extension methods might be what you are looking for (can accept the output of y()), but that depends on the version of .NET you are using.
so if you wanted to create an extension method called x that takes y as a parameter, you would create a method:
```
public static object z(input as y)
{
//do your manipulation... |
456,722 | <p>I am working on a project using C. I store several records in a two-dimensional array of strings, where one string is the record name and the other string is the actual value. For example:</p>
<pre><code>myArray[0][0] = "filename1";
myArray[0][1] = "somefile.txt";
myArray[1][0] = "filename2";
myArray[1][1] = "anoth... | [
{
"answer_id": 456736,
"author": "hhafez",
"author_id": 42303,
"author_profile": "https://Stackoverflow.com/users/42303",
"pm_score": 3,
"selected": false,
"text": "<p>try if you are working with a 2d array chars (ie 1d array of strings)</p>\n\n<pre><code>your_2d_array[0] = \"file_name_1... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on a project using C. I store several records in a two-dimensional array of strings, where one string is the record name and the other string is the actual value. For example:
```
myArray[0][0] = "filename1";
myArray[0][1] = "somefile.txt";
myArray[1][0] = "filename2";
myArray[1][1] = "anotherfile.txt";
/... | try if you are working with a 2d array chars (ie 1d array of strings)
```
your_2d_array[0] = "file_name_1" /* and so on ... */
for( i = 0 ; i < num_of_file_names ; i++ )
{
printf("%s\n", your_2d_array[i]);
}
```
If you are working with a 2d array of strings (ie 3d array of chars) as the edit seems to indicated ... |
456,727 | <p>Is it possible to write a stored procedure with dynamic parameters in sql server 2005</p>
| [
{
"answer_id": 456750,
"author": "jwanagel",
"author_id": 15118,
"author_profile": "https://Stackoverflow.com/users/15118",
"pm_score": 0,
"selected": false,
"text": "<p>No, both the count and parameter types are fixed as part of the stored procedure declaration.</p>\n"
},
{
"ans... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to write a stored procedure with dynamic parameters in sql server 2005 | Technically no, but there's a workaround: temp tables. Create a temp table, then set up your stored procedure to read its configuration from the temp table.
Here's an example of how to call it:
```
CREATE TABLE #inputParams (ParamName VARCHAR(20), ParamValue VARCHAR(20))
INSERT INTO #inputParams (ParamName, ParamValu... |
456,738 | <p>I have seen some C++ classes with a destructor defined as follows:</p>
<pre><code>class someClass
{
public:
someClass();
~someClass() throw();
};
</code></pre>
<p>Is this a good idea?</p>
<p>I am well aware that destructors should never throw exceptions, but will this actually prevent me from ... | [
{
"answer_id": 456746,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>It's not an awful idea. If you throw in the dtor while no exception is being propagated, you will abort immediately which l... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33686/"
] | I have seen some C++ classes with a destructor defined as follows:
```
class someClass
{
public:
someClass();
~someClass() throw();
};
```
Is this a good idea?
I am well aware that destructors should never throw exceptions, but will this actually prevent me from throwing exceptions in my destruc... | It does not prevent you from throwing exceptions from your destructor. The compiler will still let you do it. The difference is that *if* you do allow an exception to escape from that destructor, your program will immediately call `unexpected`. That function calls whatever `unexpected_handler` points to, which by defau... |
456,742 | <p>How can I create a Java/Swing text component that is both styled and has a custom font? I want to highlight a small portion of the text in red, but at the same time use a custom (embedded via <code>Font.createFont</code>) font. JLabel accepts HTML text, which allows me to highlight a portion of the text, but it igno... | [
{
"answer_id": 456776,
"author": "jfpoilpret",
"author_id": 1440720,
"author_profile": "https://Stackoverflow.com/users/1440720",
"pm_score": 0,
"selected": false,
"text": "<p>You should try to use JEditorPane or JTextPane instead.</p>\n\n<p>They allow rich style in the content, at the p... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29173/"
] | How can I create a Java/Swing text component that is both styled and has a custom font? I want to highlight a small portion of the text in red, but at the same time use a custom (embedded via `Font.createFont`) font. JLabel accepts HTML text, which allows me to highlight a portion of the text, but it ignores font setti... | OK, I see the problem better now.
After checking some Swing source code, it is clear you cannot use the `DefaultStyledDocument` and have it use a physical font (one you created yourself with `createFont`) out of the box.
However, what I think you could do is implement your own `StyleContext` this way:
```
public cla... |
456,751 | <p>Im runing mySQL in a server where i need to drop tons of databases (after some testing with the server). All databases that i need to drop have the same prefix "Whatever_".</p>
<p>After the prefix, the names are random. So you have your Whatever_something, Whatever_232, Whatever_blabla, .... , Whatever_imthelast.</... | [
{
"answer_id": 456764,
"author": "Yuval F",
"author_id": 1702,
"author_profile": "https://Stackoverflow.com/users/1702",
"pm_score": -1,
"selected": false,
"text": "<p>You can try the <a href=\"http://datacharmer.blogspot.com/2005/12/mysql-5-general-purpose-routine.html\" rel=\"nofollow ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47846/"
] | Im runing mySQL in a server where i need to drop tons of databases (after some testing with the server). All databases that i need to drop have the same prefix "Whatever\_".
After the prefix, the names are random. So you have your Whatever\_something, Whatever\_232, Whatever\_blabla, .... , Whatever\_imthelast.
I wil... | The basic idea is to run "show tables" in your database, and use the results from that to select the
tables you want. I don't think MySQL lets you do anything with the resultset from "show tables",
but I'm probably wrong.
Here's a quick-and-dirty solution using the shell:
```
mysql -u your_user -D your_database_na... |
456,754 | <p>Is there a way to use LoadWith but specify the fields that are returned?</p>
<p>For example, if I have two tables 1) Products 2) Categories</p>
<p>and do something like</p>
<pre><code>DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith<Products>(d => d.Categories);
db.LoadOptions = dlo;
MyDataCont... | [
{
"answer_id": 456855,
"author": "Frans Bouma",
"author_id": 44991,
"author_profile": "https://Stackoverflow.com/users/44991",
"pm_score": 1,
"selected": false,
"text": "<p>No that's not possible with LoadWith. </p>\n\n<p>You could try with a nested query in the projection, though that w... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56302/"
] | Is there a way to use LoadWith but specify the fields that are returned?
For example, if I have two tables 1) Products 2) Categories
and do something like
```
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith<Products>(d => d.Categories);
db.LoadOptions = dlo;
MyDataContext db = new MyDataContext();
var res... | No that's not possible with LoadWith.
You could try with a nested query in the projection, though that will be slow: 1 query per parent (so 1 query for the related category per product loaded). |
456,786 | <p>I am creating a test program to test the functionality of program which calcultes CPU Utilization.</p>
<p>Now I want to test that program at different times when CPU utilization is 100%, 50% 0% etc.</p>
<p>My question how to make CPU to utilize to 100% or may be > 80%.</p>
<p>I think creating a while loop like w... | [
{
"answer_id": 456789,
"author": "Roger Lipscombe",
"author_id": 8446,
"author_profile": "https://Stackoverflow.com/users/8446",
"pm_score": 0,
"selected": false,
"text": "<p>Get hold of a copy of <a href=\"http://users.bigpond.net.au/CPUburn/\" rel=\"nofollow noreferrer\">CPU Burn-In</a... | 2009/01/19 | [
"https://Stackoverflow.com/questions/456786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33411/"
] | I am creating a test program to test the functionality of program which calcultes CPU Utilization.
Now I want to test that program at different times when CPU utilization is 100%, 50% 0% etc.
My question how to make CPU to utilize to 100% or may be > 80%.
I think creating a while loop like will suffice
```
while(i+... | You're right to use a loop, but:
* You've got IO
* You've got a sleep
Basically nothing in that loop is going to take very much CPU time compared with the time it's sleeping or waiting for IO.
To kill a CPU you need to give it *just* CPU stuff. The only tricky bit really is making sure the C++ compiler doesn't optim... |