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 |
|---|---|---|---|---|---|---|
182,622 | <p>I have an application that seems to throw exceptions only after the program has been closed. And it is very inconsistent. (We all know how fun inconsistent bugs are...)</p>
<p>My guess is there is an error during the clean up process. But these memory read/write errors seem to indicate something wrong in my "unsa... | [
{
"answer_id": 182704,
"author": "Aardvark",
"author_id": 3655,
"author_profile": "https://Stackoverflow.com/users/3655",
"pm_score": 1,
"selected": false,
"text": "<p>I've seen plently of errors just like this recently. My issues were releated to how the CRT (C Runtime) intereacting wit... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6721/"
] | I have an application that seems to throw exceptions only after the program has been closed. And it is very inconsistent. (We all know how fun inconsistent bugs are...)
My guess is there is an error during the clean up process. But these memory read/write errors seem to indicate something wrong in my "unsafe" code usa... | If your app is multi-threaded you could be getting errors from worker threads which aren't properly terminating and trying to access disposed objects. |
182,630 | <h2>Syntax</h2>
<ul>
<li><a href="https://stackoverflow.com/questions/182630/jquery-tips-and-tricks/2218129#2218129">Shorthand for the ready-event</a> by roosteronacid</li>
<li><a href="https://stackoverflow.com/questions/182630/jquery-tips-and-tricks/2218135#2218135">Line breaks and chainability</a> by roosteronacid<... | [
{
"answer_id": 182666,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 6,
"selected": false,
"text": "<p>I'm really not a fan of the <code>$(document).ready(fn)</code> shortcut. Sure it cuts down on the code but it also cuts way... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20946/"
] | Syntax
------
* [Shorthand for the ready-event](https://stackoverflow.com/questions/182630/jquery-tips-and-tricks/2218129#2218129) by roosteronacid
* [Line breaks and chainability](https://stackoverflow.com/questions/182630/jquery-tips-and-tricks/2218135#2218135) by roosteronacid
* [Nesting filters](https://stackoverf... | **Creating an HTML Element and keeping a reference**
```
var newDiv = $("<div />");
newDiv.attr("id", "myNewDiv").appendTo("body");
/* Now whenever I want to append the new div I created,
I can just reference it from the "newDiv" variable */
```
**Checking if an element exists**
```
if ($("#someDiv").length)
... |
182,635 | <p>I am trying to find all matches in a string that begins with <code>| |</code>. </p>
<p>I have tried: <code>if ($line =~ m/^\\\|\s\\\|/)</code> which didn't work. </p>
<p>Any ideas?</p>
| [
{
"answer_id": 182650,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 5,
"selected": false,
"text": "<p>You are escaping the pipe one time too many, effectively escaping the backslash instead.</p>\n\n<pre><code>print ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to find all matches in a string that begins with `| |`.
I have tried: `if ($line =~ m/^\\\|\s\\\|/)` which didn't work.
Any ideas? | You are escaping the pipe one time too many, effectively escaping the backslash instead.
```
print "YES!" if ($line =~ m/^\|\s\|/);
``` |
182,636 | <p>I'm creating a generic class and in one of the methods I need to know the Class of the generic type currently in use. The reason is that one of the method's I call expects this as an argument.</p>
<p>Example:</p>
<pre><code>public class MyGenericClass<T> {
public void doSomething() {
// Snip...
// ... | [
{
"answer_id": 182672,
"author": "Nicolas",
"author_id": 1730,
"author_profile": "https://Stackoverflow.com/users/1730",
"pm_score": 7,
"selected": true,
"text": "<p>Still the same problems : Generic informations are erased at runtime, it cannot be recovered. A workaround is to pass the ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26066/"
] | I'm creating a generic class and in one of the methods I need to know the Class of the generic type currently in use. The reason is that one of the method's I call expects this as an argument.
Example:
```
public class MyGenericClass<T> {
public void doSomething() {
// Snip...
// Call to a 3rd party lib
... | Still the same problems : Generic informations are erased at runtime, it cannot be recovered. A workaround is to pass the class T in parameter of a static method :
```
public class MyGenericClass<T> {
private final Class<T> clazz;
public static <U> MyGenericClass<U> createMyGeneric(Class<U> clazz) {
... |
182,675 | <p>On a server I have to take care of, errors from a vhost do not go to the standard PHP error log.</p>
<p>In the php.ini we have </p>
<pre><code>log = /var/log/file
</code></pre>
<p>and <code>phpinfo()</code> does not show any difference between the vhost and the whole server.</p>
<p>But the callback function set... | [
{
"answer_id": 182705,
"author": "Rimas Kudelis",
"author_id": 25804,
"author_profile": "https://Stackoverflow.com/users/25804",
"pm_score": 3,
"selected": true,
"text": "<p>Perhaps the errors that aren't logged <a href=\"http://php.net/error-reporting\" rel=\"nofollow noreferrer\">aren'... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8404/"
] | On a server I have to take care of, errors from a vhost do not go to the standard PHP error log.
In the php.ini we have
```
log = /var/log/file
```
and `phpinfo()` does not show any difference between the vhost and the whole server.
But the callback function set up by `set_error_handler()` catches errors which a... | Perhaps the errors that aren't logged [aren't supposed to be logged](http://php.net/error-reporting)? The [error reporting settings have no effect when set\_error\_handler is used](http://php.net/set_error_handler), hence you see more errors than are in the logfile. |
182,683 | <p>I have a very interesting problem on my LinqToSql model. On some of my tables i have a references to other tables and in LinqToSql this is represented by a EnitiyRef class, when you are trying to access the references table LinqToSql will load the reference from the database.</p>
<p>On my development machine everyt... | [
{
"answer_id": 182696,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>Have you turned the context logging on and compared the results on your dev box to those on your production box?</p>\n... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26135/"
] | I have a very interesting problem on my LinqToSql model. On some of my tables i have a references to other tables and in LinqToSql this is represented by a EnitiyRef class, when you are trying to access the references table LinqToSql will load the reference from the database.
On my development machine everything worke... | Have you turned the context logging on and compared the results on your dev box to those on your production box? |
182,721 | <p>We use Spring + Hibernate for a Webapp.</p>
<p>This Webapp will be deployed on two unrelated production sites. These two production sites will use the Webapp to generate and use Person data in parallel.</p>
<p>What I need to do, is to make sure that the Persons generated on these two unrelated production sites all... | [
{
"answer_id": 183682,
"author": "Eric R. Rath",
"author_id": 23883,
"author_profile": "https://Stackoverflow.com/users/23883",
"pm_score": 3,
"selected": true,
"text": "<p>You could use sequences on both production systems, but define them differently:</p>\n\n<p>Production System 1:\nCR... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2797/"
] | We use Spring + Hibernate for a Webapp.
This Webapp will be deployed on two unrelated production sites. These two production sites will use the Webapp to generate and use Person data in parallel.
What I need to do, is to make sure that the Persons generated on these two unrelated production sites all have distinct PK... | You could use sequences on both production systems, but define them differently:
Production System 1:
CREATE SEQUENCE sequence\_name START WITH 1 INCREMENT BY 2;
Production System 2:
CREATE SEQUENCE sequence\_name START WITH 2 INCREMENT BY 2;
The first sequence will generate only odd numbers, the second only even nu... |
182,742 | <p>Specifically MSSQL 2005.</p>
| [
{
"answer_id": 182745,
"author": "David Collie",
"author_id": 7577,
"author_profile": "https://Stackoverflow.com/users/7577",
"pm_score": 0,
"selected": false,
"text": "<p>Some links to possible answers:</p>\n\n<ul>\n<li><p><a href=\"http://www.extremeexperts.com/sql/Tips/DateTrick.aspx\... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7577/"
] | Specifically MSSQL 2005. | Here's a solution that gives you the last second of the current month. You can extract the date part or modify it to return just the day. I tested this on SQL Server 2005.
```
select dateadd( s, -1, dateadd( mm, datediff( m, 0, getdate() ) + 1, 0 ) );
```
To understand how it works we have to look at the [dateadd()]... |
182,865 | <p>I'm using Test/Unit with a standard <strong>rails 2.1</strong> project. I would like to be able to test Partial Views in isolation from any particular controller / action.</p>
<p>It seemed as though <a href="http://zentest.rubyforge.org/" rel="noreferrer">ZenTest's Test::Rails::ViewTestCase</a> would help, but I co... | [
{
"answer_id": 183980,
"author": "TonyLa",
"author_id": 1295,
"author_profile": "https://Stackoverflow.com/users/1295",
"pm_score": -1,
"selected": false,
"text": "<p>Testing a view without the controller code is a dangerous thing. Your tests might pass but your application might throw ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15965/"
] | I'm using Test/Unit with a standard **rails 2.1** project. I would like to be able to test Partial Views in isolation from any particular controller / action.
It seemed as though [ZenTest's Test::Rails::ViewTestCase](http://zentest.rubyforge.org/) would help, but I couldn't get it working, similarly with view\_test <h... | We're using [RSpec](http://rspec.info) in our Rails 2.1 project, and we can do this sort of thing:
```
describe "/posts/_form" do
before do
render :partial => "posts/form"
end
it "says hello" do
response.should match(/hello/i)
end
it "renders a form" do
response.should have_tag("form")
end
end
... |
182,872 | <p>What is the easiest way to test (using reflection), whether given method (i.e. java.lang.Method instance) has a return type, which can be safely casted to List<String>?</p>
<p>Consider this snippet:</p>
<pre><code>public static class StringList extends ArrayList<String> {}
public List<String> me... | [
{
"answer_id": 183232,
"author": "Jasper",
"author_id": 18702,
"author_profile": "https://Stackoverflow.com/users/18702",
"pm_score": 3,
"selected": false,
"text": "<p>I tried this code and it returns the actual generic type class so it seems the type info can be retrieved. However this ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7135/"
] | What is the easiest way to test (using reflection), whether given method (i.e. java.lang.Method instance) has a return type, which can be safely casted to List<String>?
Consider this snippet:
```
public static class StringList extends ArrayList<String> {}
public List<String> method1();
public ArrayList<String> metho... | Solving this in general is really not easy to do yourself using only the tools provided by Java itself. There are a lot of special cases (nested classes, type parameter bounds,...) to take care of.
That's why I wrote a library to make generic type reflection easier: [gentyref](http://code.google.com/p/gentyref/). I add... |
182,876 | <p>Often, I found OutOfMemoryException on IBM Websphere Application Server.
I think this exception occur because my application retrieve Huge data from database. So, I limit all query don't retreive data more than 1000 records and set JVM of WAS follow</p>
<pre><code>+ Verbose garbage collection
+ Maximum Heap size = ... | [
{
"answer_id": 183082,
"author": "James Schek",
"author_id": 17871,
"author_profile": "https://Stackoverflow.com/users/17871",
"pm_score": 2,
"selected": true,
"text": "<p>The answer to this is dependent on the message associated with the OutOfMemoryException. You can also try -XX:MaxPer... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24550/"
] | Often, I found OutOfMemoryException on IBM Websphere Application Server.
I think this exception occur because my application retrieve Huge data from database. So, I limit all query don't retreive data more than 1000 records and set JVM of WAS follow
```
+ Verbose garbage collection
+ Maximum Heap size = 1024 (RAM on m... | The answer to this is dependent on the message associated with the OutOfMemoryException. You can also try -XX:MaxPermSize=... and set it to something larger like 256m.
Also, if you have a recursive function somewhere, that may be causing a stack overflow.
If you can, please post the message associated with the excep... |
182,891 | <p>Does anyone have an XSLT that will take the app.config and render it into a non-techie palatable format?</p>
<p>The purpose being mainly informational, but with the nice side-effect of validating the XML (if it's been made invalid, it won't render)</p>
| [
{
"answer_id": 183060,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>What type of conversion are you looking for? Just for informational purposes? What level of detail are you lo... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6023/"
] | Does anyone have an XSLT that will take the app.config and render it into a non-techie palatable format?
The purpose being mainly informational, but with the nice side-effect of validating the XML (if it's been made invalid, it won't render) | First draft at a solution to show
* Connection Strings
* App Settings
Whack this in the app.config:
```
<?xml-stylesheet type="text/xsl" href="display-config.xslt"?>
```
And this is the contents of display-config.xslt:
```
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http:/... |
182,928 | <p>we have a template project we often copy. so we can costumize the copy and still have a common template.<br></p>
<p>To optimize the "copy & initial changes"-process, i though that i can write a little script, that does the following:</p>
<ul>
<li>copy the project-template (in svn) to another directory in the s... | [
{
"answer_id": 183031,
"author": "Sietse",
"author_id": 6400,
"author_profile": "https://Stackoverflow.com/users/6400",
"pm_score": -1,
"selected": false,
"text": "<p>Just a shell script would do.</p>\n"
},
{
"answer_id": 183056,
"author": "Jason Miesionczek",
"author_id"... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25730/"
] | we have a template project we often copy. so we can costumize the copy and still have a common template.
To optimize the "copy & initial changes"-process, i though that i can write a little script, that does the following:
* copy the project-template (in svn) to another directory in the svn
* check-out the project ... | Here is something i put together with some information i found [here](http://forums.devshed.com/unix-help-35/unix-find-and-replace-text-within-all-files-within-a-146179.html).
```
#!/bin/bash
searchterm="<ProjectName>"
replaceterm="New Project"
srcsvnrepo="file:///svnrepoaddress"
destsvnrepo="file:///data/newrepo"
du... |
182,945 | <p>I've committed changes in numerous files to a SVN repository from Eclipse.</p>
<p>I then go to website directory on the linux box where I want to update these changes from the repository to the directory there.</p>
<p>I want to say "svn update project100" which will update the directories under "project100" with a... | [
{
"answer_id": 182960,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 6,
"selected": false,
"text": "<p>You can see what will updated (without actually updating) by issuing:</p>\n\n<pre><code>svn merge --dry-run -r BASE... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | I've committed changes in numerous files to a SVN repository from Eclipse.
I then go to website directory on the linux box where I want to update these changes from the repository to the directory there.
I want to say "svn update project100" which will update the directories under "project100" with all my added and c... | Try:
```
svn status --show-updates
```
or (the same but shorter):
```
svn status -u
``` |
182,957 | <p>im trying to locate the position of the minimum value in a vector, using STL find algorithm (and the min_element algorithm), but instead of returning the postion, its just giving me the value. E.g, if the minimum value is it, is position will be returned as 8 etc. What am I doing wrong here?</p>
<pre><code>int valu... | [
{
"answer_id": 182973,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 6,
"selected": true,
"text": "<p><code>min_element</code> already gives you the iterator, no need to invoke <code>find</code> (additionally, it's in... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8768/"
] | im trying to locate the position of the minimum value in a vector, using STL find algorithm (and the min\_element algorithm), but instead of returning the postion, its just giving me the value. E.g, if the minimum value is it, is position will be returned as 8 etc. What am I doing wrong here?
```
int value = *min_elem... | `min_element` already gives you the iterator, no need to invoke `find` (additionally, it's inefficient because it's twice the work). Use `distance` or the `-` operator:
```
cout << "min value at " << min_element(v2.begin(), v2.end()) - v2.begin();
``` |
182,984 | <p>Files:</p>
<p>Website\Controls\map.ascx</p>
<p>Website\App_Code\map.cs</p>
<p>I'd like to create a strongly typed instance of map.ascx in map.cs</p>
<p>Normally, in an aspx, you would add a <%Register... tag to be able to instantiate in codebehind. Is this possible in an app_code class?
I'm using .NET 3.5/Vis... | [
{
"answer_id": 182992,
"author": "Ryan Duffield",
"author_id": 2696,
"author_profile": "https://Stackoverflow.com/users/2696",
"pm_score": 3,
"selected": true,
"text": "<p>Normally, I'd do something like this (assuming your type is \"Map\" and that you have the appropriate \"Inherits\" d... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11831/"
] | Files:
Website\Controls\map.ascx
Website\App\_Code\map.cs
I'd like to create a strongly typed instance of map.ascx in map.cs
Normally, in an aspx, you would add a <%Register... tag to be able to instantiate in codebehind. Is this possible in an app\_code class?
I'm using .NET 3.5/Visual Studio 2008
Thanks! | Normally, I'd do something like this (assuming your type is "Map" and that you have the appropriate "Inherits" declaration in your .ascx file):
```
Map map = (Map)LoadControl("~/Controls/map.ascx");
``` |
182,988 | <p>I have valid <code>HBITMAP</code> handle of <code>ARGB</code> type. How to draw it using <em>GDI+</em>?</p>
<p>I've tried method:</p>
<pre><code>graphics.DrawImage(Bitmap::FromHBITMAP(m_hBitmap, NULL), 0, 0);
</code></pre>
<p>But it doesn't use alpha channel.</p>
| [
{
"answer_id": 183029,
"author": "Jeff B",
"author_id": 25879,
"author_profile": "https://Stackoverflow.com/users/25879",
"pm_score": -1,
"selected": false,
"text": "<p>Ah... but .Net doesn't use HBITMAP and GDI+ is a C++ library atop the basic Windows GDI, so I'm assuming you're using n... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have valid `HBITMAP` handle of `ARGB` type. How to draw it using *GDI+*?
I've tried method:
```
graphics.DrawImage(Bitmap::FromHBITMAP(m_hBitmap, NULL), 0, 0);
```
But it doesn't use alpha channel. | I've got working sample:
*Get info using bitmap handle: image size, bits*
```
BITMAP bmpInfo;
::GetObject(m_hBitmap, sizeof(BITMAP), &bmpInfo);
int cxBitmap = bmpInfo.bmWidth;
int cyBitmap = bmpInfo.bmHeight;
void* bits = bmpInfo.bmBits;
```
*Create & draw new GDI+ bitmap using bits with pixel format Pixel... |
182,993 | <p>I have the following in my Global.asax.cs</p>
<pre><code>routes.MapRoute(
"Arrival",
"{partnerID}",
new { controller = "Search", action = "Index", partnerID="1000" }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
</code... | [
{
"answer_id": 183008,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 1,
"selected": false,
"text": "<p>There are a number of considerations when using virtual directories in your application. </p>\n\n<p>One is particular is t... | 2008/10/08 | [
"https://Stackoverflow.com/questions/182993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4431/"
] | I have the following in my Global.asax.cs
```
routes.MapRoute(
"Arrival",
"{partnerID}",
new { controller = "Search", action = "Index", partnerID="1000" }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
```
My SearchContr... | IIS 5.1 interprets your url such that its looking for a folder named 1000 under the folder named Test. Why is that so?
>
> This happens because IIS 6 only
> invokes ASP.NET when it sees a
> “filename extension” in the URL that’s
> mapped to aspnet\_isapi.dll (which is a
> C/C++ ISAPI filter responsible for
> inv... |
183,013 | <p>I want to compare the current value of an in-memory Hibernate entity with the value in the database:</p>
<pre><code>HibernateSession sess = HibernateSessionFactory.getSession();
MyEntity newEntity = (MyEntity)sess.load(MyEntity.class, id);
newEntity.setProperty("new value");
MyEntity oldEntity = (MyEntity)sess.load... | [
{
"answer_id": 183808,
"author": "Brian Deterling",
"author_id": 14619,
"author_profile": "https://Stackoverflow.com/users/14619",
"pm_score": 0,
"selected": false,
"text": "<p>What about using session.isDirty()? The JavaDoc says that method will answer the question \"Would any SQL be ex... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4690/"
] | I want to compare the current value of an in-memory Hibernate entity with the value in the database:
```
HibernateSession sess = HibernateSessionFactory.getSession();
MyEntity newEntity = (MyEntity)sess.load(MyEntity.class, id);
newEntity.setProperty("new value");
MyEntity oldEntity = (MyEntity)sess.load(MyEntity.clas... | Two easy options spring to mind:
1. Evict oldEntity before saving newEntity
2. Use session.merge() on oldEntity to replace the version in the session cache (newEntity) with the original (oldEntity)
**EDIT**: to elaborate a little, the problem here is that Hibernate keeps a persistence context, which is the objects be... |
183,016 | <p>I'm making a report in Access 2003 that contains a sub report of related records. Within the sub report, I want the top two records only. When I add "TOP 2" to the sub report's query, it seems to select the top two records before it filters on the link fields. How do I get the top two records of only those record... | [
{
"answer_id": 183544,
"author": "BIBD",
"author_id": 685,
"author_profile": "https://Stackoverflow.com/users/685",
"pm_score": 2,
"selected": true,
"text": "<p>I've got two suggestions:<br>\n1) Pass your master field (on the parent form) to the query as a parameter (you could reference ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7899/"
] | I'm making a report in Access 2003 that contains a sub report of related records. Within the sub report, I want the top two records only. When I add "TOP 2" to the sub report's query, it seems to select the top two records before it filters on the link fields. How do I get the top two records of only those records that... | I've got two suggestions:
1) Pass your master field (on the parent form) to the query as a parameter (you could reference a field on the parent form directly as well)
2) You could fake out rownumbers in Access and limit them to only rownum <= 2. E.g.,
```
SELECT o1.order_number, o1.order_date,
(SELECT COUNT... |
183,018 | <p>Looking into System.Data.DbType there is no SqlVariant type there. SqlDataReader, for example, provides the GetString method for reading into string variable. What is the appropriate way to retrieve data from the database field of type sql_variant, presumably into object? </p>
<p>The aim is to read data stored as <... | [
{
"answer_id": 183027,
"author": "Rob",
"author_id": 7872,
"author_profile": "https://Stackoverflow.com/users/7872",
"pm_score": 2,
"selected": false,
"text": "<p>If you want to put the data into a variable of type object then (simplified):</p>\n\n<pre><code>object result = null;\nresult... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23730/"
] | Looking into System.Data.DbType there is no SqlVariant type there. SqlDataReader, for example, provides the GetString method for reading into string variable. What is the appropriate way to retrieve data from the database field of type sql\_variant, presumably into object?
The aim is to read data stored as [sql\_vari... | If you want to put the data into a variable of type object then (simplified):
```
object result = null;
result = reader["columnNameGoesHere"];
```
Should do the trick.
There's also a good explanation of the various different methods of retrieving the contents of a given columns current record in [this DevHood tutor... |
183,032 | <p>Is it possible to send a list of IDs to a stored procedure from c#?</p>
<pre><code>UPDATE Germs
SET Mutated = ~Mutated
WHERE (GermID IN (ids))
</code></pre>
| [
{
"answer_id": 183045,
"author": "Boris Callens",
"author_id": 11333,
"author_profile": "https://Stackoverflow.com/users/11333",
"pm_score": 1,
"selected": false,
"text": "<p>According to <a href=\"http://visualstudiomagazine.com/features/article.aspx?editorialsid=2438\" rel=\"nofollow n... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to send a list of IDs to a stored procedure from c#?
```
UPDATE Germs
SET Mutated = ~Mutated
WHERE (GermID IN (ids))
``` | This may be a dirty hack, but you can create a temp table and then join to it from within your stored procedure (assuming they are accessed during the same connection). For example:
```
CREATE TABLE #ids (id int)
INSERT INTO #ids VALUES ('123') -- your C# code would generate all of the inserts
-- From within your sto... |
183,035 | <p>I have a strange bug with WPF Interop and an Excel Addin. I'm using .Net 3.5 SP1.</p>
<p>I'm using Add-in Express to create a Custom Task Pane for Excel 2003. Within that taskpane I'm using ElementHost to host a WPF UserControl. The UserControl simply contains a Grid with a TextBox and ComboBox. My problem is that ... | [
{
"answer_id": 697518,
"author": "Samuel Jack",
"author_id": 1727,
"author_profile": "https://Stackoverflow.com/users/1727",
"pm_score": 3,
"selected": true,
"text": "<p>Add-in Express looked into this for me, and it turns out to have something to do with the Window style of the Task Pan... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1727/"
] | I have a strange bug with WPF Interop and an Excel Addin. I'm using .Net 3.5 SP1.
I'm using Add-in Express to create a Custom Task Pane for Excel 2003. Within that taskpane I'm using ElementHost to host a WPF UserControl. The UserControl simply contains a Grid with a TextBox and ComboBox. My problem is that whilst eve... | Add-in Express looked into this for me, and it turns out to have something to do with the Window style of the Task Pane that gets added to Excel. If you turn off the WS\_CHILD flag in the Windows CreateParams then Combo Boxes and other popups work as expected.
They gave me this snippet of code to add to my ADXExcelTa... |
183,042 | <p>Is there a way to define a column (primary key) as a <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier" rel="noreferrer">UUID</a> in <a href="http://www.sqlalchemy.org/" rel="noreferrer">SQLAlchemy</a> if using <a href="http://www.postgresql.org/" rel="noreferrer">PostgreSQL</a> (Postgres)?</p>
| [
{
"answer_id": 188427,
"author": "Florian Bösch",
"author_id": 19435,
"author_profile": "https://Stackoverflow.com/users/19435",
"pm_score": -1,
"selected": false,
"text": "<p>You could try writing a <a href=\"http://www.sqlalchemy.org/docs/05/types.html#types_custom\" rel=\"nofollow nor... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7883/"
] | Is there a way to define a column (primary key) as a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) in [SQLAlchemy](http://www.sqlalchemy.org/) if using [PostgreSQL](http://www.postgresql.org/) (Postgres)? | The sqlalchemy postgres dialect supports UUID columns. This is easy (and the question is specifically postgres) -- I don't understand why the other answers are all so complicated.
Here is an example:
```
from sqlalchemy.dialects.postgresql import UUID
from flask_sqlalchemy import SQLAlchemy
import uuid
db = SQLAlche... |
183,062 | <p>How does one go about establishing a CSS 'schema', or hierarchy, of general element styles, nested element styles, and classed element styles. For a rank novice like me, the amount of information in stylesheets I view is completely overwhelming. What process does one follow in creating a well factored stylesheet o... | [
{
"answer_id": 183120,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 1,
"selected": false,
"text": "<p>Cop-out line of the year: it depends.</p>\n\n<p>How much do you need to be styling? Do you need to change the aspects of a... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8741/"
] | How does one go about establishing a CSS 'schema', or hierarchy, of general element styles, nested element styles, and classed element styles. For a rank novice like me, the amount of information in stylesheets I view is completely overwhelming. What process does one follow in creating a well factored stylesheet or she... | I'm a big fan of naming my CSS classes by their contents or content types, for example a <ul> containing navigational "tabs" would have class="tabs". A header containing a date could be class="date" or an ordered list containing a top 10 list could have class="chart". Similarly, for IDs, one could give the page footer ... |
183,071 | <p>My normal IDE is Visual Studio, but I'm currently doing some development in Eclipse for the first time. If you press Ctrl-X with text selected in either program, it cuts the text and puts on the clipboard exactly as you'd expect. If press Ctrl-X with no text selected in Visual Studio, it cuts the current line. In... | [
{
"answer_id": 183120,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 1,
"selected": false,
"text": "<p>Cop-out line of the year: it depends.</p>\n\n<p>How much do you need to be styling? Do you need to change the aspects of a... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9323/"
] | My normal IDE is Visual Studio, but I'm currently doing some development in Eclipse for the first time. If you press Ctrl-X with text selected in either program, it cuts the text and puts on the clipboard exactly as you'd expect. If press Ctrl-X with no text selected in Visual Studio, it cuts the current line. In Eclip... | I'm a big fan of naming my CSS classes by their contents or content types, for example a <ul> containing navigational "tabs" would have class="tabs". A header containing a date could be class="date" or an ordered list containing a top 10 list could have class="chart". Similarly, for IDs, one could give the page footer ... |
183,075 | <p>I am making numerous, minute changes to .php files in Eclipse PDT then committing them and testing on the server.</p>
<p>The repetitive six-step commit process is getting tedious:</p>
<pre><code>right-click
team
Commit...
click "choose previously selected comment"
select in list
click OK
</code></pre>
<p>Does any... | [
{
"answer_id": 183092,
"author": "Soraz",
"author_id": 24610,
"author_profile": "https://Stackoverflow.com/users/24610",
"pm_score": 1,
"selected": false,
"text": "<p>In eclipse you can choose to either commit one file or the entire project.</p>\n\n<p>To commit the entire project, right... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | I am making numerous, minute changes to .php files in Eclipse PDT then committing them and testing on the server.
The repetitive six-step commit process is getting tedious:
```
right-click
team
Commit...
click "choose previously selected comment"
select in list
click OK
```
Does anyone know of a hotkey or other pro... | The best I've been able to do is create a key binding for 'Commit' (under Preferences... General->Keys). Then you just need to click on the project and hit a key combination, which saves the whole right-click->Team->Commit... process.
If you just want to check in the file you are editing, you don't have to click anywh... |
183,078 | <p>I have data loaded and various transformations on the data complete, the problem is there is a parent/child relationship managed in the data - best explained by an example</p>
<p>each row has (column names are made up)</p>
<pre><code>row_key parent_row_key row_name parent_row_name
</code></pre>
<p>some ro... | [
{
"answer_id": 183159,
"author": "piers7",
"author_id": 26167,
"author_profile": "https://Stackoverflow.com/users/26167",
"pm_score": 2,
"selected": false,
"text": "<p>Can you not just split the data using a multicast and then do a merge-join against itself?</p>\n"
},
{
"answer_i... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10868/"
] | I have data loaded and various transformations on the data complete, the problem is there is a parent/child relationship managed in the data - best explained by an example
each row has (column names are made up)
```
row_key parent_row_key row_name parent_row_name
```
some rows have row\_key == parent\_row\_... | Can you not just split the data using a multicast and then do a merge-join against itself? |
183,083 | <p>I would like to add a BuildListener to my headless build process, which is building an Eclipse product. The docs on how to do this are, shall we say, a bit scanty. I think I need to put my custom jar in a plugin and then use the org.eclipse.ant.core.extraClasspathEntries extension point to make that jar visible to A... | [
{
"answer_id": 188700,
"author": "ILikeCoffee",
"author_id": 25270,
"author_profile": "https://Stackoverflow.com/users/25270",
"pm_score": 2,
"selected": true,
"text": "<p>I had this problem when I had two plugins providing an <code>ant.jar</code>.</p>\n\n<p>Make sure you use the <code>o... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/460599/"
] | I would like to add a BuildListener to my headless build process, which is building an Eclipse product. The docs on how to do this are, shall we say, a bit scanty. I think I need to put my custom jar in a plugin and then use the org.eclipse.ant.core.extraClasspathEntries extension point to make that jar visible to Ant.... | I had this problem when I had two plugins providing an `ant.jar`.
Make sure you use the `org.apache.ant` plugin and that there is no other plugin providing another `ant.jar`.
Another thing I just stumbled upon: The jar containing your contribution must not be in the plugins classpath (Runtime -> Classpath).
See [Ecl... |
183,093 | <p>I'm looking for ideas and opinions here, not a "real answer", I guess...</p>
<p>Back in the old VB6 days, there was this property called "Tag" in all controls, that was a useful way to store custom information related to a control. Every single control had it, and all was bliss...</p>
<p>Now, in .Net (at least for... | [
{
"answer_id": 183109,
"author": "harriyott",
"author_id": 5744,
"author_profile": "https://Stackoverflow.com/users/5744",
"pm_score": 0,
"selected": false,
"text": "<p>You can add attributes to some controls, but that seems to add some nasty HTML around the rendered control, something l... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | I'm looking for ideas and opinions here, not a "real answer", I guess...
Back in the old VB6 days, there was this property called "Tag" in all controls, that was a useful way to store custom information related to a control. Every single control had it, and all was bliss...
Now, in .Net (at least for WebForms), it's ... | No, there's no direct equivalent, but if you're using v3.5 of the Framework, you can add this functionality quite easily using an extension method. For example:
```
Imports System.Runtime.CompilerServices
Public Module Extensions
<Extension()> _
Public Sub SetTag(ByVal ctl As Control, ByVal tagValue As String)
... |
183,101 | <p>I use the MFC list control in report view with grid lines to display data in a vaguely spreadsheet manner.</p>
<p>Sometimes when the user scrolls vertically through the control, extra grid lines are drawn, which looks terrible.</p>
<p>This does not happen when the slider or the mousewheel are used to scroll, only ... | [
{
"answer_id": 183151,
"author": "Roel",
"author_id": 11449,
"author_profile": "https://Stackoverflow.com/users/11449",
"pm_score": 0,
"selected": false,
"text": "<p>Is this happening with the stock listview, or is it custom draw? I've never seen redrawing issues with the standard window... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16582/"
] | I use the MFC list control in report view with grid lines to display data in a vaguely spreadsheet manner.
Sometimes when the user scrolls vertically through the control, extra grid lines are drawn, which looks terrible.
This does not happen when the slider or the mousewheel are used to scroll, only when the little d... | To fix this bug in the MFC List Control you need to specialize the control, over-ride the method wich responds to the scroll, and force it to redraw the list completely after it has done the scroll.
interface header
```
class cSmoothListControl : public CListCtrl
{
public:
DECLARE_MESSAGE_MAP()
afx_msg void O... |
183,108 | <p>I have a C++ template class that gets instantiated with 3 different type parameters. There's a method that the class needs to have for only one of those types and that isn't ever called with the two other types.</p>
<p>Will object code for that method be generated thrice (for all types for which the template is ins... | [
{
"answer_id": 183157,
"author": "Jeff B",
"author_id": 25879,
"author_profile": "https://Stackoverflow.com/users/25879",
"pm_score": 1,
"selected": false,
"text": "<p>Usually, yes.</p>\n\n<p>All the compiler really knows is that your program can create at least one instance of each clas... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18721/"
] | I have a C++ template class that gets instantiated with 3 different type parameters. There's a method that the class needs to have for only one of those types and that isn't ever called with the two other types.
Will object code for that method be generated thrice (for all types for which the template is instantiated)... | Virtual member functions are instantiated when a class template is instantiated, but non-virtual member functions are instantiated only if they are called.
This is covered in [temp.inst] in the C++ standard (In C++11, this is §14.7.1/10. In C++14, it is §14.7.1/11, and in C++17 it is §17.7.1/9. Excerpt from C++17 belo... |
183,115 | <p>I'm writing a shell script to do some web server configuration. I need to disable all currently active virtual hosts. <code>a2dissite</code> doesn't accept multiple arguments, so I can't do</p>
<pre><code>a2dissite `ls /etc/apache2/sites-enabled`
</code></pre>
<p>Should I use <code>find</code>? Is it safe to manua... | [
{
"answer_id": 183141,
"author": "Mote",
"author_id": 24789,
"author_profile": "https://Stackoverflow.com/users/24789",
"pm_score": -1,
"selected": false,
"text": "<p>you can edit the httpd.conf and delete the include line for the virtual hosts (at the bottom of the file) </p>\n"
},
... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3757/"
] | I'm writing a shell script to do some web server configuration. I need to disable all currently active virtual hosts. `a2dissite` doesn't accept multiple arguments, so I can't do
```
a2dissite `ls /etc/apache2/sites-enabled`
```
Should I use `find`? Is it safe to manually delete the symlinks in `/etc/apache2/sites-e... | Is your script Debian only? If so, you can safely delete all the symlinks in sites-enabled, that will work as long as all sites have been written correctly, in the sites-available directory.
For example:
```
find /etc/apache2/sites-enabled/ -type l -exec rm -i "{}" \;
```
will protect you against someone who has a... |
183,118 | <p>I've got an application that is very graphics intensive and built on DirectX and Windows Forms. It has an automation and replay framework around which is built an automated testing system. Unfortunately, when the tests run unattended during a nightly build, the display is inactive or tied up with the screensaver, an... | [
{
"answer_id": 183331,
"author": "tloach",
"author_id": 14092,
"author_profile": "https://Stackoverflow.com/users/14092",
"pm_score": 0,
"selected": false,
"text": "<p>Install a VM and run the application in that. If you're running a screen saver I doubt your video card is even generati... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1382162/"
] | I've got an application that is very graphics intensive and built on DirectX and Windows Forms. It has an automation and replay framework around which is built an automated testing system. Unfortunately, when the tests run unattended during a nightly build, the display is inactive or tied up with the screensaver, and o... | Since you're mentioned rendering pipeline, so I'm assuming you're using Direct3d, if so, you can save the backbuffer of the frame. I did that when I was still using VB.Net + MDX
```
Dim tempSurface As Direct3D.Surface
tempSurface = device.GetBackBuffer(0, 0, Direct3D.BackBufferType.Mono)
Direct3D.SurfaceLoader.Save(te... |
183,124 | <p>I need to generate multiple random values under SQL Server 2005 and somehow this simply wont work</p>
<pre><code>with Random(Value) as
(
select rand() Value
union all
select rand() from Random
)select top 10 * from Random
</code></pre>
<p>Whats the preffered workaround?</p>
| [
{
"answer_id": 183138,
"author": "Torbjörn Gyllebring",
"author_id": 21182,
"author_profile": "https://Stackoverflow.com/users/21182",
"pm_score": 0,
"selected": false,
"text": "<p>I'm currently using this:</p>\n\n<pre><code>with Random(Value) as\n(\n select rand(checksum(newid())) Va... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21182/"
] | I need to generate multiple random values under SQL Server 2005 and somehow this simply wont work
```
with Random(Value) as
(
select rand() Value
union all
select rand() from Random
)select top 10 * from Random
```
Whats the preffered workaround? | have you tries something like this (found at [http://weblogs.sqlteam.com](http://weblogs.sqlteam.com/jeffs/archive/2004/11/22/2927.aspx) ) :
```
CREATE VIEW vRandNumber
AS
SELECT RAND() as RandNumber
GO
```
create a function
```
CREATE FUNCTION RandNumber()
RETURNS float
AS
BEGIN
RETURN (SELECT RandNumber F... |
183,158 | <pre><code>public void PublicMethod(FooBar fooBar)
{
if (fooBar == null)
throw new ArgumentNullException("fooBar", "fooBar cannot be null");
// log the call [added: Thanks S.Lott]
_logger.Log("PublicMethod called with fooBar class " + fooBar.Classification);
int action = DetermineAction();
... | [
{
"answer_id": 183177,
"author": "Robert Deml",
"author_id": 9516,
"author_profile": "https://Stackoverflow.com/users/9516",
"pm_score": 0,
"selected": false,
"text": "<p>At least put a comment that PrivateMethod must have a non-null FooBar and that PublicMethod checks this.</p>\n"
},
... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] | ```
public void PublicMethod(FooBar fooBar)
{
if (fooBar == null)
throw new ArgumentNullException("fooBar", "fooBar cannot be null");
// log the call [added: Thanks S.Lott]
_logger.Log("PublicMethod called with fooBar class " + fooBar.Classification);
int action = DetermineAction();
Priva... | I would say no.
While it certainly holds true that you in *this* case knows that it has already been checked for nullability, in two months time the youngest intern will come along and write
PublicMethod2 that also calls PrivateMethod, but lo and behold he forgot to check for null. |
183,161 | <p>What's the best way to break from nested loops in Javascript?</p>
<pre><code>//Write the links to the page.
for (var x = 0; x < Args.length; x++)
{
for (var Heading in Navigation.Headings)
{
for (var Item in Navigation.Headings[Heading])
{
if (Args[x] == Navigation.Headings[Heading][It... | [
{
"answer_id": 183168,
"author": "swilliams",
"author_id": 736,
"author_profile": "https://Stackoverflow.com/users/736",
"pm_score": 8,
"selected": false,
"text": "<p>Wrap that up in a function and then just <code>return</code>.</p>\n"
},
{
"answer_id": 183197,
"author": "eph... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13227/"
] | What's the best way to break from nested loops in Javascript?
```
//Write the links to the page.
for (var x = 0; x < Args.length; x++)
{
for (var Heading in Navigation.Headings)
{
for (var Item in Navigation.Headings[Heading])
{
if (Args[x] == Navigation.Headings[Heading][Item].Name)
... | Just like Perl,
```
loop1:
for (var i in set1) {
loop2:
for (var j in set2) {
loop3:
for (var k in set3) {
break loop2; // breaks out of loop3 and loop2
}
}
}
```
as defined in EMCA-262 section 12.12. [[MDN Docs]](https://developer.mozilla.org/docs/Web... |
183,179 | <p>I have a table that is created in a DataList in ASP.Net. This table has three fields of text, then a field with an edit button, and a field with a delete button. When a person clicks the delete button, it posts back, deletes the items, and then binds the DataList again. The DataList is in an UpdatePanel so the item ... | [
{
"answer_id": 183228,
"author": "Miles",
"author_id": 21828,
"author_profile": "https://Stackoverflow.com/users/21828",
"pm_score": 0,
"selected": false,
"text": "<p>have you tried looking at any of the Ajax control toolkit items? I believe there are some controls in there that will hea... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3226/"
] | I have a table that is created in a DataList in ASP.Net. This table has three fields of text, then a field with an edit button, and a field with a delete button. When a person clicks the delete button, it posts back, deletes the items, and then binds the DataList again. The DataList is in an UpdatePanel so the item smo... | You can use [page methods](http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx) in asp.net to send a request to the server without doing a postback. They are very simple to use and you can do whatever effect you like when the ajax call is completed (you get a function called on success).
If you ... |
183,185 | <p>Is it possible to make hibernate do "the right thing" for some value of "right" in this situation?</p>
<pre><code>from ClassA a, ClassB b
where a.prop = b.prop
</code></pre>
<p>The thing is that prop is a UserType with different representation in the joined tables. In table A it is represented as an integer and in... | [
{
"answer_id": 183436,
"author": "Vineet Bhatia",
"author_id": 18716,
"author_profile": "https://Stackoverflow.com/users/18716",
"pm_score": -1,
"selected": false,
"text": "<p>(1) Change data-type of columns which map to \"prop\" to be the same. This will require \"Making DBA your friend... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24243/"
] | Is it possible to make hibernate do "the right thing" for some value of "right" in this situation?
```
from ClassA a, ClassB b
where a.prop = b.prop
```
The thing is that prop is a UserType with different representation in the joined tables. In table A it is represented as an integer and in table B it is represented... | I think you can do this using a `<formula>` tag on the relationship in your mapping file.
For example:
```
<many-to-one name="myClassB" class="ClassB">
<formula>--Some SQL Expression that converts between ClassA.prop and ClassB.prop</formula>
</many-to-one>
```
I've used this to associate two tables where one use... |
183,190 | <p>I have one question maybe someone here can help me. If i do "ps aux --sort user" on linux console I have one list of users and their processes runing on the machine. My question is how do I remove the users name and print that list like this <strong>in a C program</strong>:</p>
<p>for example:</p>
<pre><code>(…)
-... | [
{
"answer_id": 183200,
"author": "bmdhacks",
"author_id": 14032,
"author_profile": "https://Stackoverflow.com/users/14032",
"pm_score": 2,
"selected": false,
"text": "<pre><code>ps aux --sort user | perl -npe 's/^(\\w+)//g; if ($user ne $1) {$user=$1; print \"user: \" . uc($user) . \"\\n... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have one question maybe someone here can help me. If i do "ps aux --sort user" on linux console I have one list of users and their processes runing on the machine. My question is how do I remove the users name and print that list like this **in a C program**:
for example:
```
(…)
-----------------------------------... | ```
ps aux --sort user | perl -npe 's/^(\w+)//g; if ($user ne $1) {$user=$1; print "user: " . uc($user) . "\n";}'
``` |
183,201 | <p>Oftentimes a developer will be faced with a choice between two possible ways to solve a problem -- one that is idiomatic and readable, and another that is less intuitive, but may perform better. For example, in C-based languages, there are two ways to multiply a number by 2:</p>
<pre><code>int SimpleMultiplyBy2(in... | [
{
"answer_id": 183215,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 6,
"selected": false,
"text": "<p>IMO the obvious readable version first, until performance is measured and a faster version is required.</p>\n"
},
{
... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1674/"
] | Oftentimes a developer will be faced with a choice between two possible ways to solve a problem -- one that is idiomatic and readable, and another that is less intuitive, but may perform better. For example, in C-based languages, there are two ways to multiply a number by 2:
```
int SimpleMultiplyBy2(int x)
{
retu... | You missed one.
First code for correctness, then for clarity (the two are often connected, of course!). Finally, and only if you have real empirical evidence that you actually need to, you can look at optimizing. Premature optimization really is evil. Optimization almost always costs you time, clarity, maintainability... |
183,209 | <p>I have unmanaged C++ calling a managed delegate via the function pointer provided by Marshal::GetFunctionPointerForDelegate. This delegate has the potential to throw an exception. I need to be able to properly handle this exception in my unmanaged C++ to ensure things like pointer cleanup, and potentially rethrow ... | [
{
"answer_id": 183241,
"author": "Bert Huijben",
"author_id": 2094,
"author_profile": "https://Stackoverflow.com/users/2094",
"pm_score": 2,
"selected": false,
"text": "<p>Catching from managed code with</p>\n\n<pre><code>try\n{\n throw gcnew InvalidOperationException();\n}\ncatch(Inval... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24965/"
] | I have unmanaged C++ calling a managed delegate via the function pointer provided by Marshal::GetFunctionPointerForDelegate. This delegate has the potential to throw an exception. I need to be able to properly handle this exception in my unmanaged C++ to ensure things like pointer cleanup, and potentially rethrow the e... | Catching from managed code with
```
try
{
throw gcnew InvalidOperationException();
}
catch(InvalidOperationException^ e)
{
// Process e
throw;
}
```
And an
```
[assembly:RuntimeCompatibility(WrapNonExceptionThrows = true)];
```
on your assembly catches managed and unmanaged exceptions |
183,214 | <p>I'm having some trouble with plain old JavaScript (no frameworks) in referencing my object in a callback function.</p>
<pre><code>function foo(id) {
this.dom = document.getElementById(id);
this.bar = 5;
var self = this;
this.dom.addEventListener("click", self.onclick, false);
}
foo.prototype = {
... | [
{
"answer_id": 183247,
"author": "Sergey Ilinsky",
"author_id": 23815,
"author_profile": "https://Stackoverflow.com/users/23815",
"pm_score": 4,
"selected": false,
"text": "<pre><code>this.dom.addEventListener(\"click\", function(event) {\n self.onclick(event)\n}, false);\n</code></pr... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18146/"
] | I'm having some trouble with plain old JavaScript (no frameworks) in referencing my object in a callback function.
```
function foo(id) {
this.dom = document.getElementById(id);
this.bar = 5;
var self = this;
this.dom.addEventListener("click", self.onclick, false);
}
foo.prototype = {
onclick : fu... | *(extracted some explanation that was hidden in comments in other answer)*
The problem lies in the following line:
```
this.dom.addEventListener("click", self.onclick, false);
```
Here, you pass a function object to be used as callback. When the event trigger, the function is called but now it has no association wi... |
183,249 | <p>.Net contains a nice control called <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.documentviewer.aspx" rel="noreferrer"><code>DocumentViewer</code></a>. it also offers a subcontrol for finding text in the loaded document (that's at least what it is supposed to do).</p>
<p>When inserting <... | [
{
"answer_id": 183748,
"author": "Artur Carvalho",
"author_id": 1013,
"author_profile": "https://Stackoverflow.com/users/1013",
"pm_score": 1,
"selected": false,
"text": "<p>I had trouble with searching text in richtextbox, it was too slow. What I did was crunch the xaml every time I wan... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20227/"
] | .Net contains a nice control called [`DocumentViewer`](http://msdn.microsoft.com/en-us/library/system.windows.controls.documentviewer.aspx). it also offers a subcontrol for finding text in the loaded document (that's at least what it is supposed to do).
When inserting [`FixedPage`](http://msdn.microsoft.com/en-us/libr... | I had this same problem with FixedDocuments. If you convert your FixedDocument to an XPS document then it works fine.
Example of creating an XPS Document in memory from a FixedDocument then displaying in a DocumentViewer.
```cs
// Add to xaml: <DocumentViewer x:Name="documentViewer" />
// Add project references to "... |
183,250 | <p>I have a c# object with a property called Gender which is declared as a char.</p>
<pre><code>private char _Gender;
public char Gender
{
get{ return _Gender; }
set{ _Gender = value; }
}
</code></pre>
<p>What string is returned/created when I call MyObject.Gender.ToString()?</p>
<p>I ask because I am calli... | [
{
"answer_id": 183260,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>The default value of char is unicode 0, so I'd expect \"\\u0000\" to be returned.</p>\n"
},
{
"answer_id": 183... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1970/"
] | I have a c# object with a property called Gender which is declared as a char.
```
private char _Gender;
public char Gender
{
get{ return _Gender; }
set{ _Gender = value; }
}
```
What string is returned/created when I call MyObject.Gender.ToString()?
I ask because I am calling a webservice (which accepts a ... | The default value of char is unicode 0, so I'd expect "\u0000" to be returned. |
183,316 | <p>How do I go about the <code>[HandleError]</code> filter in asp.net MVC Preview 5?<br>
I set the customErrors in my Web.config file</p>
<pre><code><customErrors mode="On" defaultRedirect="Error.aspx">
<error statusCode="403" redirect="NoAccess.htm"/>
<error statusCode="404" redirect="FileNotFound.... | [
{
"answer_id": 183910,
"author": "Ricky",
"author_id": 653,
"author_profile": "https://Stackoverflow.com/users/653",
"pm_score": 2,
"selected": false,
"text": "<p>You are missing Error.aspx :) In preview 5, this is located in your Views/Shared folder. Just copy it over from a new Preview... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | How do I go about the `[HandleError]` filter in asp.net MVC Preview 5?
I set the customErrors in my Web.config file
```
<customErrors mode="On" defaultRedirect="Error.aspx">
<error statusCode="403" redirect="NoAccess.htm"/>
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>
```
and put [Han... | ```
[HandleError]
```
When you provide only the HandleError attribute to your class (or to your action method for that matter), then when an unhandled exception occurs MVC will look for a corresponding View named "Error" first in the Controller's View folder. If it can't find it there then it will proceed to look in ... |
183,325 | <p>For some reason, Section 1 works but Section 2 does not. When run in the opposite order (2 before 1), Section 1 (Affiliation) is not run at all. All the data is the same.</p>
<pre><code>//Section 1
UserService.DsUserAttributes dsAffiliation = us_service.GetUserAttributeDropDown(systemId, "Affiliation"... | [
{
"answer_id": 183337,
"author": "Joachim Kerschbaumer",
"author_id": 20227,
"author_profile": "https://Stackoverflow.com/users/20227",
"pm_score": 0,
"selected": false,
"text": "<p>i guess this heavily depends on the \"Country\" and \"Affiliation\" objects...there could potentially happ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24565/"
] | For some reason, Section 1 works but Section 2 does not. When run in the opposite order (2 before 1), Section 1 (Affiliation) is not run at all. All the data is the same.
```
//Section 1
UserService.DsUserAttributes dsAffiliation = us_service.GetUserAttributeDropDown(systemId, "Affiliation");
... | It would certainly seem that either `us_service.GetUserAttributeDropDown(systemId, "Country")` or `dsCountry.tblDropDownValues` is throwing an exception. You'll need to walk through with the debugger to see which and why. |
183,338 | <p>I'm looking for something that will monitor Windows directories for size and file count over time. I'm talking about a handful of servers and a few thousand folders (millions of files).</p>
<p>Requirements:</p>
<ul>
<li>Notification on X increase in size over Y time</li>
<li>Notification on X increase in file coun... | [
{
"answer_id": 183400,
"author": "Joel",
"author_id": 21987,
"author_profile": "https://Stackoverflow.com/users/21987",
"pm_score": 2,
"selected": false,
"text": "<p>There are several solutions out there, including some free ones. Some that I have worked with include:</p>\n\n<p><a href=... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9861/"
] | I'm looking for something that will monitor Windows directories for size and file count over time. I'm talking about a handful of servers and a few thousand folders (millions of files).
Requirements:
* Notification on X increase in size over Y time
* Notification on X increase in file count over Y time
* Historical g... | You might want to take a look at [PolyMon](http://www.codeplex.com/polymon), which is an open source systems monitoring solution. It allows you to write custom monitors in any .NET language, and allows you to create custom PowerShell monitors.
It stores data on a SQL Server back end and provides graphing. For your pu... |
183,352 | <p>I want to copy text files and only text files from <code>src/</code> to <code>dst/</code></p>
<pre>
groovy:000> "cp src/*.txt dst/".execute().text
===>
groovy:000>
</pre>
<p>You can see the command executes w/out error but the file <code>src/test.txt</code> does not get copied to <code>dst/</code></p>
<p... | [
{
"answer_id": 183393,
"author": "user10392",
"author_id": 10392,
"author_profile": "https://Stackoverflow.com/users/10392",
"pm_score": 4,
"selected": true,
"text": "<p>Wildcard expansion is performed by the shell, not by cp (or groovy). Your first example is trying to copy a file name... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25820/"
] | I want to copy text files and only text files from `src/` to `dst/`
```
groovy:000> "cp src/*.txt dst/".execute().text
===>
groovy:000>
```
You can see the command executes w/out error but the file `src/test.txt` does not get copied to `dst/`
This also fails:
```
groovy:000> "cp src/* dst/".execute().t... | Wildcard expansion is performed by the shell, not by cp (or groovy). Your first example is trying to copy a file named \*. You could make your command "sh -c 'cp ...'" |
183,353 | <p>Passing an undimensioned array to the VB6's Ubound function will cause an error, so I want to check if it has been dimensioned yet before attempting to check its upper bound. How do I do this?</p>
| [
{
"answer_id": 183356,
"author": "raven",
"author_id": 4228,
"author_profile": "https://Stackoverflow.com/users/4228",
"pm_score": 4,
"selected": false,
"text": "<p>I found this:</p>\n\n<pre><code>Dim someArray() As Integer\n\nIf ((Not someArray) = -1) Then\n Debug.Print \"this array is... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4228/"
] | Passing an undimensioned array to the VB6's Ubound function will cause an error, so I want to check if it has been dimensioned yet before attempting to check its upper bound. How do I do this? | Here's what I went with. This is similar to GSerg's [answer](https://stackoverflow.com/questions/183353/how-do-i-determine-if-an-array-is-initialized-in-vb6#183668), but uses the better documented CopyMemory API function and is entirely self-contained (you can just pass the array rather than ArrPtr(array) to this funct... |
183,366 | <p>I have a SEAM app with some JPA/Hibernate entities. And I now wonder where to put my query, persistence methods.</p>
<p>The default choice seems to put them in a session bean layer with injected </p>
<pre><code>@PersistenceContext(...) @Inject EntityManager entityManager;
</code></pre>
<p>But I think I would rath... | [
{
"answer_id": 183388,
"author": "Rolf",
"author_id": 3540161,
"author_profile": "https://Stackoverflow.com/users/3540161",
"pm_score": 3,
"selected": true,
"text": "<p>I have no experience with SEAM, but from my experience with Java projects, I found it easiest to keep beans clear of pe... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8805/"
] | I have a SEAM app with some JPA/Hibernate entities. And I now wonder where to put my query, persistence methods.
The default choice seems to put them in a session bean layer with injected
```
@PersistenceContext(...) @Inject EntityManager entityManager;
```
But I think I would rather have the methods on the entiti... | I have no experience with SEAM, but from my experience with Java projects, I found it easiest to keep beans clear of persist methods. What we usually do:
* Have beans for business objects (like "User" and "Setting" for example)
* Have a DAO layer which can persist and retrieve these beans (simple CRUD)
* Have a Servic... |
183,367 | <p>Is it possible to unsubscribe an anonymous method from an event?</p>
<p>If I subscribe to an event like this:</p>
<pre><code>void MyMethod()
{
Console.WriteLine("I did it!");
}
MyEvent += MyMethod;
</code></pre>
<p>I can un-subscribe like this:</p>
<pre><code>MyEvent -= MyMethod;
</code></pre>
<p>But if I ... | [
{
"answer_id": 183380,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": false,
"text": "<p>From memory, the specification explicitly doesn't guarantee the behaviour either way when it comes to equivalence of ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2610/"
] | Is it possible to unsubscribe an anonymous method from an event?
If I subscribe to an event like this:
```
void MyMethod()
{
Console.WriteLine("I did it!");
}
MyEvent += MyMethod;
```
I can un-subscribe like this:
```
MyEvent -= MyMethod;
```
But if I subscribe using an anonymous method:
```
MyEvent += del... | ```
Action myDelegate = delegate(){Console.WriteLine("I did it!");};
MyEvent += myDelegate;
// .... later
MyEvent -= myDelegate;
```
Just keep a reference to the delegate around. |
183,391 | <p>I have a project where I am taking some particularly ugly "live" HTML and forcing it into a formal XML DOM with the HTML Agility Pack. What I would like to be able to do is then query over this with Linq to XML so that I can scrape out the bits I need. I'm using the method described <a href="http://vijay.screaming... | [
{
"answer_id": 183403,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 5,
"selected": true,
"text": "<p>Using <code>LocalName</code> should be okay. I wouldn't consider it a hack at all if you don't care what namespace it'... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24608/"
] | I have a project where I am taking some particularly ugly "live" HTML and forcing it into a formal XML DOM with the HTML Agility Pack. What I would like to be able to do is then query over this with Linq to XML so that I can scrape out the bits I need. I'm using the method described [here](http://vijay.screamingpens.co... | Using `LocalName` should be okay. I wouldn't consider it a hack at all if you don't care what namespace it's in.
If you know the namespace you want and you want to specify it, you can:
```
var ns = "{http://www.w3.org/1999/xhtml}";
var x = xDoc.Root.Descendants(ns + "div");
```
([MSDN reference](http://msdn.micro... |
183,406 | <p>How can I add a line break to text when it is being set as an attribute i.e.:</p>
<pre><code><TextBlock Text="Stuff on line1 \n Stuff on line2" />
</code></pre>
<p>Breaking it out into the exploded format isn't an option for my particular situation. What I need is some way to emulate the following:</p>
<pr... | [
{
"answer_id": 183435,
"author": "Bob King",
"author_id": 6897,
"author_profile": "https://Stackoverflow.com/users/6897",
"pm_score": 10,
"selected": true,
"text": "<pre><code><TextBlock Text=\"Stuff on line1&#x0a;Stuff on line 2\"/>\n</code></pre>\n\n<p>You can use any hexadec... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/93/"
] | How can I add a line break to text when it is being set as an attribute i.e.:
```
<TextBlock Text="Stuff on line1 \n Stuff on line2" />
```
Breaking it out into the exploded format isn't an option for my particular situation. What I need is some way to emulate the following:
```
<TextBlock>
<TextBlock.Text>
S... | ```
<TextBlock Text="Stuff on line1
Stuff on line 2"/>
```
You can use any hexadecimally encoded value to represent a literal. In this case, I used the line feed (char 10). If you want to do "classic" `vbCrLf`, then you can use `
`
By the way, note the syntax: It's the ampersand, a pound, the letter ... |
183,407 | <p>Code and preview: <img src="https://i.stack.imgur.com/3J6CX.gif" alt="what i have"></p>
<pre><code><html>
<head>
<title>Testing some CSS</title>
<style type="text/css">
.dDay {
font-size:205%
}
.dMon {
font-weight:bold;
font-variant:small-caps;
font-size:130%;
margi... | [
{
"answer_id": 183418,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "<p>use style=\"float:left\" on each DIV (either directly or via a stylesheet)</p>\n"
},
{
"answer_id": 183419... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] | Code and preview: 
```
<html>
<head>
<title>Testing some CSS</title>
<style type="text/css">
.dDay {
font-size:205%
}
.dMon {
font-weight:bold;
font-variant:small-caps;
font-size:130%;
margin-top:-.7em;
}
.detailContainer {
vertical-align:middl... | ```
<html>
<head>
<title>Testing some CSS</title>
<style type="text/css">
.dDay {
font-size:205%
}
.dMon {
font-weight:bold;
font-variant:small-caps;
font-size:130%;
margin-top:-.7em;
}
.detailContainer {
vertical-align:middle;
display:table-cell;
padding:0em 0em 0em 1em;
}
#dContainer, ... |
183,409 | <p>Let's say I have a java program that makes an HTTP request on a server using HTTP 1.1 and doesn't close the connection. I make one request, and read all data returned from the input stream I have bound to the socket. However, upon making a second request, I get no response from the server (or there's a problem with... | [
{
"answer_id": 183457,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 0,
"selected": false,
"text": "<p>Make sure you have a <code>Connection: keep-alive</code> in your request. This may be a moot point though.</p>\n\n<p... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4924/"
] | Let's say I have a java program that makes an HTTP request on a server using HTTP 1.1 and doesn't close the connection. I make one request, and read all data returned from the input stream I have bound to the socket. However, upon making a second request, I get no response from the server (or there's a problem with the... | According to your code, the only time you'll even reach the statements dealing with sending the second request is when the server closes the output stream (your input stream) after receiving/responding to the first request.
The reason for that is that your code that is supposed to read only the first response
```
whi... |
183,415 | <p>A table row is generated using an asp:Repeater:</p>
<pre><code><asp:repeater ID="announcementsRepeater" OnItemDataBound="announcementsRepeater_ItemDataBound" runat="Server">
<itemtemplate>
<tr id="announcementRow" class="announcementItem" runat="server">...</tr>
</itemtemplate... | [
{
"answer_id": 183438,
"author": "Geoff",
"author_id": 1097,
"author_profile": "https://Stackoverflow.com/users/1097",
"pm_score": 0,
"selected": false,
"text": "<p>Cast it to HtmlTableRow</p>\n\n<pre><code>HtmlTableRow row = (HtmlTableRow)e.Item.FindControl(\"announcementRow\");\n</code... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] | A table row is generated using an asp:Repeater:
```
<asp:repeater ID="announcementsRepeater" OnItemDataBound="announcementsRepeater_ItemDataBound" runat="Server">
<itemtemplate>
<tr id="announcementRow" class="announcementItem" runat="server">...</tr>
</itemtemplate>
</asp:repeater>
```
Now in the data-b... | ```
HtmlControl htmlRow = (HtmlControl)row;
htmlRow.Attributes["class"] = htmlRow.Attributes["class"] + " announcementItemUnread";
``` |
183,426 | <p>By default, cocoa progress bars are slightly fat and I want something a little slimmer, like the progress bars seen in the Finder copy dialog. However, Interface Builder locks the <code>NSProgressIndicator</code> control height to 20 pixels and my programmatic attempts to slim down aren't working, as calls to</p>
<... | [
{
"answer_id": 183890,
"author": "millenomi",
"author_id": 6061,
"author_profile": "https://Stackoverflow.com/users/6061",
"pm_score": 4,
"selected": true,
"text": "<p>Those calls should have worked. In Interface Builder, in the Geometry pane (the one whose icon is a ruler), there is an ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22147/"
] | By default, cocoa progress bars are slightly fat and I want something a little slimmer, like the progress bars seen in the Finder copy dialog. However, Interface Builder locks the `NSProgressIndicator` control height to 20 pixels and my programmatic attempts to slim down aren't working, as calls to
```
[progressBar se... | Those calls should have worked. In Interface Builder, in the Geometry pane (the one whose icon is a ruler), there is an equivalent control size selector that offers "Regular" and "Small" sizes. |
183,428 | <p>I have a batch file that uses this idiom (many times) to read a registry value into an environment variable:</p>
<pre><code>FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKLM\SOFTWARE\Path\To\Key" /v ValueName') DO SET MyVariable=%%B
</code></pre>
<p>(There's a tab character after <code>delims=</code>)</p>
<p>... | [
{
"answer_id": 183465,
"author": "agnul",
"author_id": 6069,
"author_profile": "https://Stackoverflow.com/users/6069",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>/F</code> switch needs command extensions to be turned on. Usually they are turned on by default, but I'd check t... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13012/"
] | I have a batch file that uses this idiom (many times) to read a registry value into an environment variable:
```
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKLM\SOFTWARE\Path\To\Key" /v ValueName') DO SET MyVariable=%%B
```
(There's a tab character after `delims=`)
This works fine on thousands of customer's c... | I would check:
1. The customer's role on the machine - are they an admin?
2. Where is reg.exe on the box - is there more than one copy of copy of reg.exe in the path?
3. Is there any locale difference on the customer's machine from the machines where this normally works?
Basically, enumerate everything that differs b... |
183,443 | <p>I have an <em>extremely</em> simple <code>routes.rb</code> in my Rails app:</p>
<pre><code>ActionController::Routing::Routes.draw do |map|
map.resources :tags
end
</code></pre>
<p>Starting up my app with <code>script/server</code> and pointing my browser to <code>localhost:3000/tags/</code> yields:</p>
<h3>Acti... | [
{
"answer_id": 184146,
"author": "Pete",
"author_id": 13472,
"author_profile": "https://Stackoverflow.com/users/13472",
"pm_score": 0,
"selected": false,
"text": "<p>I have seen this happen with older versions of mongrel, but 1.1.5 is not old. I have also seen some similar problems when ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I have an *extremely* simple `routes.rb` in my Rails app:
```
ActionController::Routing::Routes.draw do |map|
map.resources :tags
end
```
Starting up my app with `script/server` and pointing my browser to `localhost:3000/tags/` yields:
### ActionController::MethodNotAllowed
```
Only get and post requests are all... | 1. Check your generated routes for problems with "rake routes | grep tag"
2. Check the actual method that is being called, and the verb it is being called with by tail -f log/development.log
This should bring up any obvious problems. |
183,446 | <p>How do I fix that error once and for all? I just want to be able to do unions in MySQL. </p>
<p>(I'm looking for a shortcut, like an option to make MySQL ignore that issue or take it's best guess, not looking to change collations on 100s of tables ... at least not today)</p>
| [
{
"answer_id": 183624,
"author": "kristof",
"author_id": 3241,
"author_profile": "https://Stackoverflow.com/users/3241",
"pm_score": 4,
"selected": true,
"text": "<p>Not sure about mySQL but in MSSQL you can change the collation in the query so for example if you have 2 tables with diffe... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13009/"
] | How do I fix that error once and for all? I just want to be able to do unions in MySQL.
(I'm looking for a shortcut, like an option to make MySQL ignore that issue or take it's best guess, not looking to change collations on 100s of tables ... at least not today) | Not sure about mySQL but in MSSQL you can change the collation in the query so for example if you have 2 tables with different collation and you want to join them or as in you situation crate UNION you can do
```
select column1 from tableWithProperCollation
union all
select column1 COLLATE SQL_Latin1_General_CP1_CI_AS... |
183,459 | <p>I have an Asp.Net 2.0 (VB.Net) app and I'm trying to export a Control (ASCX) to another project. I need to know what other files that the Control needs in order to work. </p>
<p>Is there any way - using VS.Net 2005 or an external app - to recursively trace the dependencies of a page or control in a solution?</p>
<... | [
{
"answer_id": 869346,
"author": "Jon Ownbey",
"author_id": 79206,
"author_profile": "https://Stackoverflow.com/users/79206",
"pm_score": 3,
"selected": true,
"text": "<p>I've used the <a href=\"http://msdn.microsoft.com/en-us/library/ms229864(VS.80).aspx\" rel=\"nofollow noreferrer\">As... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414/"
] | I have an Asp.Net 2.0 (VB.Net) app and I'm trying to export a Control (ASCX) to another project. I need to know what other files that the Control needs in order to work.
Is there any way - using VS.Net 2005 or an external app - to recursively trace the dependencies of a page or control in a solution?
For example, fo... | I've used the [Assembly Binding Log Viewer (Fuslogvw.exe)](http://msdn.microsoft.com/en-us/library/ms229864(VS.80).aspx) or maybe ProcMon...
One of my coworkers suggested this app called Dependency Auditor. I haven't used it though and am not vouching for it necessarily. |
183,479 | <p>I have a class that creates several IDisposable objects, all of these objects are then passed to another 'manager' class in a 3rd party library. As I need some of the objects in later calls I kept a local field reference to the created objects so that I could access them at a later time. When I ran FxCop on the clas... | [
{
"answer_id": 183517,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>If you create any disposable objects, you should either dispose them yourself or make sure you're handing them off to... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11921/"
] | I have a class that creates several IDisposable objects, all of these objects are then passed to another 'manager' class in a 3rd party library. As I need some of the objects in later calls I kept a local field reference to the created objects so that I could access them at a later time. When I ran FxCop on the class i... | The class that owns the object is the one that should dispose of them... It sounds like your manager is the owner, so he should dispose of the object.
If you're trying to avoid the FXCop warning then one option is to have MyClass request the disposable object from the manager each time is needs to use it. This way you... |
183,480 | <p>Still 'diving in' to Python, and want to make sure I'm not overlooking something. I wrote a script that extracts files from several zip files, and saves the extracted files together in one directory. To prevent duplicate filenames from being over-written, I wrote this little function - and I'm just wondering if ther... | [
{
"answer_id": 183492,
"author": "Martin Beckett",
"author_id": 10897,
"author_profile": "https://Stackoverflow.com/users/10897",
"pm_score": 1,
"selected": false,
"text": "<p>If you want readable names this looks like a good solution.<br>\nThere are routines to return unique file names ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26196/"
] | Still 'diving in' to Python, and want to make sure I'm not overlooking something. I wrote a script that extracts files from several zip files, and saves the extracted files together in one directory. To prevent duplicate filenames from being over-written, I wrote this little function - and I'm just wondering if there i... | One issue is that there is a race condition in your above code, since there is a gap between testing for existance, and creating the file. There may be security implications to this (think about someone maliciously inserting a symlink to a sensitive file which they wouldn't be able to overwrite, but your program runnin... |
183,484 | <p>What is an efficient way to shrink a two dimensional array to a smaller size in C#?</p>
<p>For example:</p>
<pre><code>var bigArray = new object[100, 100];
var smallArray = new object[10, 10];
bigArray[0, 0] = 1;
bigArray[0, 1] = 2;
...
bigArray[99, 99] = 100000;
startRowIndex = 0;
startColumnIndex = 0;
endRowI... | [
{
"answer_id": 183516,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>You've got to create a new array of the desired size (in your code, you've already done this) and copy the content... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18170/"
] | What is an efficient way to shrink a two dimensional array to a smaller size in C#?
For example:
```
var bigArray = new object[100, 100];
var smallArray = new object[10, 10];
bigArray[0, 0] = 1;
bigArray[0, 1] = 2;
...
bigArray[99, 99] = 100000;
startRowIndex = 0;
startColumnIndex = 0;
endRowIndex = 9;
endColumnInd... | You've got to create a new array of the desired size (in your code, you've already done this) and copy the content. I'm not sure what the “shrinking” operation needs to do in your case. However, you cannot modify the dimensions of an existing array.
The function you proposed is defective because it can't know the dime... |
183,485 | <p>I need to convert the punycode <code>NIATO-OTABD</code> to <code>nñiñatoñ</code>.</p>
<p>I found <a href="http://0xcc.net/jsescape/" rel="noreferrer">a text converter in JavaScript</a> the other day, but the punycode conversion doesn't work if there's a dash in the middle.</p>
<p>Any suggestion to fix the "dash" i... | [
{
"answer_id": 301287,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 7,
"selected": true,
"text": "<p>I took the time to create the punycode below. It it based on the C code in RFC 3492. To use it with domain names you have t... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23520/"
] | I need to convert the punycode `NIATO-OTABD` to `nñiñatoñ`.
I found [a text converter in JavaScript](http://0xcc.net/jsescape/) the other day, but the punycode conversion doesn't work if there's a dash in the middle.
Any suggestion to fix the "dash" issue? | I took the time to create the punycode below. It it based on the C code in RFC 3492. To use it with domain names you have to remove/add `xn--` from/to the input/output to/from decode/encode.
The `utf16-class` is necessary to convert from JavaScripts internal character representation to unicode and back.
There are als... |
183,488 | <p>We are doing some performance tests on our website and we are getting the following error a lot:</p>
<pre><code>*** 'C:\inetpub\foo.plex' log message at: 2008/10/07 13:19:58
DBD::ODBC::st execute failed: [Microsoft][SQL Native Client]String data, right truncation (SQL-22001) at C:\inetpub\foo.plex line 25.
</code><... | [
{
"answer_id": 183518,
"author": "Chris Driver",
"author_id": 5217,
"author_profile": "https://Stackoverflow.com/users/5217",
"pm_score": 6,
"selected": true,
"text": "<p>Either the parameter supplied for <code>ZIP_CODE</code> is larger (in length) than <code>ZIP_CODE</code>s column widt... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] | We are doing some performance tests on our website and we are getting the following error a lot:
```
*** 'C:\inetpub\foo.plex' log message at: 2008/10/07 13:19:58
DBD::ODBC::st execute failed: [Microsoft][SQL Native Client]String data, right truncation (SQL-22001) at C:\inetpub\foo.plex line 25.
```
Line 25 is the f... | Either the parameter supplied for `ZIP_CODE` is larger (in length) than `ZIP_CODE`s column width or the parameter supplied for `CITY` is larger (in length) than `CITY`s column width.
It would be interesting to know the values supplied for the two `?` placeholders. |
183,496 | <p>I've recently come across this piece of JavaScript code:</p>
<pre><code>if (",>=,<=,<>,".indexOf("," + sCompOp + ",") != -1)
</code></pre>
<p>I was intrigued, because to write this test I would have done:</p>
<pre><code>if (/(>=|<=|<>)/.test(sCompOp))
</code></pre>
<p>Is this just a styli... | [
{
"answer_id": 183541,
"author": "sk.",
"author_id": 16399,
"author_profile": "https://Stackoverflow.com/users/16399",
"pm_score": 1,
"selected": false,
"text": "<p>Is it a really old piece of code? It may have been written before regexes were widely used in javascript. Overall it looks ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12559/"
] | I've recently come across this piece of JavaScript code:
```
if (",>=,<=,<>,".indexOf("," + sCompOp + ",") != -1)
```
I was intrigued, because to write this test I would have done:
```
if (/(>=|<=|<>)/.test(sCompOp))
```
Is this just a stylistic difference, or does the author of the other code know something abou... | I ran some tests. The first method is slightly faster, but not by enough to make any real difference even under heavy use... *except* when `sCompOp` could potentially be a very long string. Because the first method searches a fixed-length string, its execution time is very stable no matter how long `sCompOp` gets, whil... |
183,499 | <p>One of the things that always bugs me about using Readers and Streams in Java is that the <code>close()</code> method can throw an exception. Since it's a good idea to put the close method in a finally block, that necessitates a bit of an awkward situation. I usually use this construction:</p>
<pre><code>FileReader... | [
{
"answer_id": 183520,
"author": "Steve B.",
"author_id": 19479,
"author_profile": "https://Stackoverflow.com/users/19479",
"pm_score": 1,
"selected": false,
"text": "<p>The difference, as far as I can see, is that there are different exceptions and causes in play on different levels, an... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23669/"
] | One of the things that always bugs me about using Readers and Streams in Java is that the `close()` method can throw an exception. Since it's a good idea to put the close method in a finally block, that necessitates a bit of an awkward situation. I usually use this construction:
```
FileReader fr = new FileReader("Som... | I would always go for the first example.
If close were to throw an exception (in practice that will never happen for a FileReader), wouldn't the standard way of handling that be to throw an exception appropriate to the caller? The close exception almost certainly trumps any problem you had using the resource. The seco... |
183,527 | <p>I have a dtsx package with a precedence constraint that evaluates an expression and a constraint. The constraint is "success" and the expression is "@myVariable" == 3. myVariable is an int32, and when set in Visual Studio's design GUI the package executes fine. There are two other paths that check for the value t... | [
{
"answer_id": 195183,
"author": "Michael Entin",
"author_id": 19880,
"author_profile": "https://Stackoverflow.com/users/19880",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure if it causes the problem, but you are using a slightly odd syntax to set variable value, try</p>\n\n<pre... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26197/"
] | I have a dtsx package with a precedence constraint that evaluates an expression and a constraint. The constraint is "success" and the expression is "@myVariable" == 3. myVariable is an int32, and when set in Visual Studio's design GUI the package executes fine. There are two other paths that check for the value to be 1... | Sorry took me so long to get back to this thread! But `(DT_I4)@[User::myVariable] == 3` did the trick. Thanks! |
183,532 | <p>I would like to ask for some simple examples showing the uses of <code><div></code> and <code><span></code>. I've seen them both used to mark a section of a page with an <code>id</code> or <code>class</code>, but I'm interested in knowing if there are times when one is preferred over the other.</p>
| [
{
"answer_id": 183535,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 6,
"selected": false,
"text": "<p><code><div></code> is a block-level element and <code><span></code> is an inline element. </p>\n\n<p>If... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3676/"
] | I would like to ask for some simple examples showing the uses of `<div>` and `<span>`. I've seen them both used to mark a section of a page with an `id` or `class`, but I'm interested in knowing if there are times when one is preferred over the other. | * `div` is a [block element](https://en.wikipedia.org/wiki/HTML_element#Block_elements)
* `span` is an [inline element](https://en.wikipedia.org/wiki/HTML_element#Inline_elements).
This means that to use them semantically, divs should be used to wrap sections of a document, while spans should be used to wrap small por... |
183,560 | <p>I have been trying to use the Perl utility/module "prove" as a test harness for some unit tests. The unit tests are a little more "system" than "unit" as I need to fork off some background processes as part of the test, Using the following...</p>
<pre><code>sub SpinupMonitor{
my $bas... | [
{
"answer_id": 183673,
"author": "Kyle",
"author_id": 2237619,
"author_profile": "https://Stackoverflow.com/users/2237619",
"pm_score": 4,
"selected": false,
"text": "<p><p>Note that you don't test whether <code>fork()</code> failed. You need to make sure <code>$pid</code> is <a href=\"... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3720/"
] | I have been trying to use the Perl utility/module "prove" as a test harness for some unit tests. The unit tests are a little more "system" than "unit" as I need to fork off some background processes as part of the test, Using the following...
```
sub SpinupMonitor{
my $base_dir = shift;
my $config = shift;
m... | I'm assuming that all your kids have exited before you leave your test? Because otherwise, it may be hanging on to STDERR, which may confuse prove. If you could close STDERR, or at least redirect to a pipe in your parent process, that may be one issue you're having.
Besides that, I'd also point out that you don't need... |
183,567 | <p>I have a User class which may or may not have an associated Department. This is referenced through the foreign key DepartmentId, and the relevant field in the User table is set to allow nulls.</p>
<p>When I set up my "Create User" form and select no Department, I get a conflict error on SubmitChanges():</p>
<pre>... | [
{
"answer_id": 183593,
"author": "sepang",
"author_id": 25930,
"author_profile": "https://Stackoverflow.com/users/25930",
"pm_score": 0,
"selected": false,
"text": "<p>You could have an entry \"N/A\" in Department which you assign when no department is selected. Then you wouldn't get a f... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | I have a User class which may or may not have an associated Department. This is referenced through the foreign key DepartmentId, and the relevant field in the User table is set to allow nulls.
When I set up my "Create User" form and select no Department, I get a conflict error on SubmitChanges():
```
The INSERT state... | I have found a less-than-desirable solution by putting the following in my `UsersController.Create` method:
```
// Snipped UpdateModel call
if (form["User.DepartmentId"].Length == 0)
{
createdUser.DepartmentId = null;
}
Models.User.DataContext.SubmitChanges();
```
Of course, I would prefer something that is clea... |
183,578 | <p>I am trying to install newgem on my linux box (sudo gem install newgem) and i am getting the following error:</p>
<pre><code>Building native extensions. This could take a while...
ERROR: Error installing newgem:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb install newgem
extconf.rb:1:... | [
{
"answer_id": 183875,
"author": "ephemient",
"author_id": 20713,
"author_profile": "https://Stackoverflow.com/users/20713",
"pm_score": 4,
"selected": true,
"text": "<p><code>mkmf</code> is a Ruby module which generates Makefiles. It is supposed to be part of the standard Ruby install,... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18811/"
] | I am trying to install newgem on my linux box (sudo gem install newgem) and i am getting the following error:
```
Building native extensions. This could take a while...
ERROR: Error installing newgem:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb install newgem
extconf.rb:1:in `require': ... | `mkmf` is a Ruby module which generates Makefiles. It is supposed to be part of the standard Ruby install, but Debian (and derivatives) split it out into the `ruby1.8-dev` package.
If you can't find `mkmf.rb` in any of the directories outputted by `ruby -e'print $:.join("\n")'`, then you should figure out what you nee... |
183,585 | <p>I'm moving DB from MySQL (used ODBC) to MS SQL and I want to "translate" SQL queries to LINQ. Can someone help me with this (it should SUM Charge column for every location and group result by months):</p>
<pre><code>SELECT
sum(case when Location="Location1" then Charge else 0 end) as Location1,
sum(case when Locati... | [
{
"answer_id": 184032,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 4,
"selected": true,
"text": "<p>This might help.</p>\n\n<pre><code>context.log_sales\n.GroupBy(s => new {Year = OrderTime.Year, Month = OrderTime.Month})... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23280/"
] | I'm moving DB from MySQL (used ODBC) to MS SQL and I want to "translate" SQL queries to LINQ. Can someone help me with this (it should SUM Charge column for every location and group result by months):
```
SELECT
sum(case when Location="Location1" then Charge else 0 end) as Location1,
sum(case when Location="Location2"... | This might help.
```
context.log_sales
.GroupBy(s => new {Year = OrderTime.Year, Month = OrderTime.Month})
.Select
( g => new {
Date = new DateTime(g.Key.Year, g.Key.Month, 1),
Location1 = g.Where(s => s.Location == "Location1").Sum(s => s.Charge),
Location2 = g.Where(s => s.Location == "Location2").Sum(s => s.C... |
183,604 | <p>Let's say I'm writing a Library application for a publishing company who already has a People application.</p>
<p>So in my Library application I have</p>
<pre><code>class Person < ActiveResource::Base
self.site = "http://api.people.mypublisher.com/"
end
</code></pre>
<p>and now I want to store <code>Article<... | [
{
"answer_id": 183617,
"author": "James A. Rosen",
"author_id": 1190,
"author_profile": "https://Stackoverflow.com/users/1190",
"pm_score": 3,
"selected": false,
"text": "<p>I suppose one possibility for #1, assuming I can get any of it working, is to do this:</p>\n\n<pre><code>class Per... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | Let's say I'm writing a Library application for a publishing company who already has a People application.
So in my Library application I have
```
class Person < ActiveResource::Base
self.site = "http://api.people.mypublisher.com/"
end
```
and now I want to store `Article`s for each `Person`:
```
class Article ... | As you point out, you are giving up a lot because ActiveResource does not have associations in the sense that ActiveRecord does.
You have already found the answer to question #1. As for question #2, your ActiveRecord model Article should behave just fine when configured with a "belongs\_to" association to an ActiveRe... |
183,622 | <p>I need to compare strings in shell:</p>
<pre><code>var1="mtu eth0"
if [ "$var1" == "mtu *" ]
then
# do something
fi
</code></pre>
<p>But obviously the "*" doesn't work in Shell. Is there a way to do it?</p>
| [
{
"answer_id": 183647,
"author": "ephemient",
"author_id": 20713,
"author_profile": "https://Stackoverflow.com/users/20713",
"pm_score": 4,
"selected": true,
"text": "<h1><code>bash</code></h1>\n\n<p>Shortest fix:</p>\n\n<pre><code>if [[ \"$var1\" = \"mtu \"* ]]\n</code></pre>\n\n<p>Bash... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23420/"
] | I need to compare strings in shell:
```
var1="mtu eth0"
if [ "$var1" == "mtu *" ]
then
# do something
fi
```
But obviously the "\*" doesn't work in Shell. Is there a way to do it? | `bash`
======
Shortest fix:
```
if [[ "$var1" = "mtu "* ]]
```
Bash's `[[ ]]` doesn't get glob-expanded, unlike `[ ]` (which must, for historical reasons).
---
`bash --posix`
==============
Oh, I posted too fast. Bourne shell, not Bash...
```
if [ "${var1:0:4}" == "mtu " ]
```
`${var1:0:4}` means the first fo... |
183,629 | <p>It seems like most examples of JPA/Hibernate entity bean classes I've seen do no explicit synchronization. Yet, it is possible to call getters/setters on those objects in the context of building up a transaction. And it's possible for those methods to be called across multiple threads (although maybe that's unusua... | [
{
"answer_id": 183979,
"author": "anjanb",
"author_id": 11142,
"author_profile": "https://Stackoverflow.com/users/11142",
"pm_score": 2,
"selected": false,
"text": "<p>\"And it's possible for those methods to be called across multiple threads (although maybe that's unusual and weird).\"<... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7671/"
] | It seems like most examples of JPA/Hibernate entity bean classes I've seen do no explicit synchronization. Yet, it is possible to call getters/setters on those objects in the context of building up a transaction. And it's possible for those methods to be called across multiple threads (although maybe that's unusual and... | The object probably is not the same for the 2 threads. Supposing your threads use a session factory to access the db, the objects you get from the session should be viewed as 'independent' (I believe hibernate creates 'fresh' objects for each get(), unless they are in the session).
As for your stars question, it's the... |
183,636 | <p>Is there a way to select manually a node in virtualizing TreeView and then bring it into view?</p>
<p>The data model I'm using with my TreeView is implemented based on the VM-M-V model. Each TreeViewItem's IsSelected property is binded to a corresponing property in ViewModel. I've also created a listener for TreeVi... | [
{
"answer_id": 183687,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 0,
"selected": false,
"text": "<p>Here is an example taken from an <a href=\"http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/a74f22cc-5f82-4070-9f... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19982/"
] | Is there a way to select manually a node in virtualizing TreeView and then bring it into view?
The data model I'm using with my TreeView is implemented based on the VM-M-V model. Each TreeViewItem's IsSelected property is binded to a corresponing property in ViewModel. I've also created a listener for TreeView's ItemS... | The link Estifanos Kidane gave is broken. He probably meant [the "Changing selection in a virtualized TreeView" MSDN sample](http://code.msdn.microsoft.com/Changing-selection-in-a-6a6242c8/sourcecode?fileId=18862&pathId=753647475). however, this sample shows how to select a node in a tree, but using code-behind and not... |
183,638 | <p>I have this code that performs an ajax call and loads the results into two duplicate divs every time a dropdown is changed. I want the results to be faded into the div, to give a more obvious indication that something has changed, as its so seamless its sometimes hard to notice the change!</p>
<pre><code>print("$('... | [
{
"answer_id": 183644,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 7,
"selected": true,
"text": "<p>You'll have to <code>hide()</code> it before you can use <code>fadeIn()</code>.</p>\n\n<p><strong>UPDATE:</strong>... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26107/"
] | I have this code that performs an ajax call and loads the results into two duplicate divs every time a dropdown is changed. I want the results to be faded into the div, to give a more obvious indication that something has changed, as its so seamless its sometimes hard to notice the change!
```
print("$('.ajaxdropdown'... | You'll have to `hide()` it before you can use `fadeIn()`.
**UPDATE:** Here's how you'd do this by chaining:
```
$("#charges-gsm-faq").hide().html(html).fadeIn();
$("#charges-gsm-prices").hide().html(html).fadeIn();
``` |
183,642 | <pre><code>select distinct constraint_type from user_constraints;
C
-
C
P
R
U
</code></pre>
<p>Seems P means primary key and R means foreign key, correct? What are U and C? </p>
| [
{
"answer_id": 183664,
"author": "dacracot",
"author_id": 13930,
"author_profile": "https://Stackoverflow.com/users/13930",
"pm_score": 7,
"selected": true,
"text": "<pre><code>Code Description Acts On Level\n---------------------------------------------\nC Check on a t... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13930/"
] | ```
select distinct constraint_type from user_constraints;
C
-
C
P
R
U
```
Seems P means primary key and R means foreign key, correct? What are U and C? | ```
Code Description Acts On Level
---------------------------------------------
C Check on a table Column
O Read Only on a view Object
P Primary Key Object
R Referential (Foreign Key) Column
U Unique Key Column
V Check Option on a view ... |
183,675 | <p>my goal is to write a stored proc that can collect all field values from multiple rows into one single output variable (maybe varchar(some_length)). It may seem strange solution but i've quite positive its the only one i can use at that situation im in. I have not used Firebird before and stored procs look way diffe... | [
{
"answer_id": 184142,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "<p>The following procedure does what you describe:</p>\n\n<pre><code>SET TERM !!;\nCREATE PROCEDURE concat_names\n RET... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26207/"
] | my goal is to write a stored proc that can collect all field values from multiple rows into one single output variable (maybe varchar(some\_length)). It may seem strange solution but i've quite positive its the only one i can use at that situation im in. I have not used Firebird before and stored procs look way differe... | The following procedure does what you describe:
```
SET TERM !!;
CREATE PROCEDURE concat_names
RETURNS (concat VARCHAR(2000))
AS
DECLARE VARIABLE name VARCHAR(100);
BEGIN
concat = '';
FOR SELECT first_name || ' ' || last_name FROM employee INTO :name
DO BEGIN
concat = concat || name || ', ';
END
END!!
SE... |
183,686 | <p>Whenever I restore a backup of my database in SQL Server I am presented with the following error:</p>
<pre><code>Msg 3101, Level 16, State 1, Line 1
Exclusive access could not be obtained because the database is in use.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
</code></pre>
<... | [
{
"answer_id": 183734,
"author": "Bravax",
"author_id": 13911,
"author_profile": "https://Stackoverflow.com/users/13911",
"pm_score": 1,
"selected": false,
"text": "<p>I'd suggest talking to your co-worker, and asking him to leave the database. (And make him aware of the problem, because... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/648/"
] | Whenever I restore a backup of my database in SQL Server I am presented with the following error:
```
Msg 3101, Level 16, State 1, Line 1
Exclusive access could not be obtained because the database is in use.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
```
Usually to get around th... | You can force the database offline and drop connections with:
```
EXEC sp_dboption N'yourDatabase', N'offline', N'true'
```
Or you can
```
ALTER DATABASE [yourDatabase] SET OFFLINE WITH
ROLLBACK AFTER 60 SECONDS
```
Rollback specifies if anything is executing. After that period they will be rolled back. So it pro... |
183,698 | <p>I'm using DB2, although a solution using any flavor of SQL would likely be easy enough for me to convert.</p>
<p>I didn't design this database, or the application that uses the database. I haven't the power to change this application, how it works, or the data. Because it defies what I consider to be conventional... | [
{
"answer_id": 183718,
"author": "Kip",
"author_id": 18511,
"author_profile": "https://Stackoverflow.com/users/18511",
"pm_score": 2,
"selected": false,
"text": "<p>would this work:</p>\n\n<pre><code>SELECT * FROM table_name\nWHERE START_DATE < '7/1/2005' AND (END_DATE > '7/1/2005'... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4606/"
] | I'm using DB2, although a solution using any flavor of SQL would likely be easy enough for me to convert.
I didn't design this database, or the application that uses the database. I haven't the power to change this application, how it works, or the data. Because it defies what I consider to be conventional use of a st... | would this work:
```
SELECT * FROM table_name
WHERE START_DATE < '7/1/2005' AND (END_DATE > '7/1/2005' OR END_DATE IS NULL);
``` |
183,702 | <p>Something like</p>
<pre><code>var life= {
users : {
guys : function(){ this.SOMETHING.mameAndDestroy(this.girls); },
girls : function(){ this.SOMETHING.kiss(this.boys); },
},
mameAndDestroy : function(group){ },
kiss : function(group){ }
};
</code></pre>
<p... | [
{
"answer_id": 183731,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "<p>If I'm reading your question correctly, objects in general are agnostic about where they are contained. They don... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1825034/"
] | Something like
```
var life= {
users : {
guys : function(){ this.SOMETHING.mameAndDestroy(this.girls); },
girls : function(){ this.SOMETHING.kiss(this.boys); },
},
mameAndDestroy : function(group){ },
kiss : function(group){ }
};
```
this.SOMETHING is what I ... | JavaScript does not offer this functionality natively. And I doubt you could even create this type of functionality. For example:
```
var Bobby = {name: "Bobby"};
var Dad = {name: "Dad", children: [ Bobby ]};
var Mom = {name: "Mom", children: [ Bobby ]};
```
Who does Bobby belong to? |
183,773 | <p>A program receives a list of Messages (base type). Each message in the list has to be processed according to it's type (descendant type). However, different messages need different inputs in order to be processed correctly.</p>
<p>What is the following technique called? (I haven't checked this code in a compiler... | [
{
"answer_id": 183836,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 4,
"selected": true,
"text": "<p>They are both examples of the <em>factory method</em> pattern. The only difference is that the second example has the ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] | A program receives a list of Messages (base type). Each message in the list has to be processed according to it's type (descendant type). However, different messages need different inputs in order to be processed correctly.
What is the following technique called? (I haven't checked this code in a compiler)
```
abstra... | They are both examples of the *factory method* pattern. The only difference is that the second example has the method in its own static class.
This would be an example of the *abstract factory* pattern:
```
abstract class MessageProcessorFactory
{ public abstract MessageProcessor GetProcessor
... |
183,791 | <p>I have two collections which have property <code>Email</code> in both collections. I need to get a list of the items in the first list where <code>Email</code> does not exist in the second list. With SQL I would just use "not in", but I do not know the equivalent in LINQ. How is that done?</p>
<p>So far I have a jo... | [
{
"answer_id": 183804,
"author": "Robert Rouse",
"author_id": 25129,
"author_profile": "https://Stackoverflow.com/users/25129",
"pm_score": 9,
"selected": true,
"text": "<p>I don't know if this will help you but..</p>\n<pre><code>NorthwindDataContext dc = new NorthwindDataContext(); \... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10366/"
] | I have two collections which have property `Email` in both collections. I need to get a list of the items in the first list where `Email` does not exist in the second list. With SQL I would just use "not in", but I do not know the equivalent in LINQ. How is that done?
So far I have a join, like...
```
var matches = f... | I don't know if this will help you but..
```
NorthwindDataContext dc = new NorthwindDataContext();
dc.Log = Console.Out;
var query =
from c in dc.Customers
where !(from o in dc.Orders
select o.CustomerID)
.Contains(c.CustomerID)
select c;
foreach (var c in q... |
183,846 | <p><a href="http://blog.stevenlevithan.com/archives/balancing-groups" rel="nofollow noreferrer">.NET balanced group regexes</a> make my head explode. I've got this string i'm trying to match:</p>
<pre><code>other stuff blah blah....
{
stuff stuff
{ke... | [
{
"answer_id": 183876,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": -1,
"selected": false,
"text": "<p>Not to be a kill joy but what you're attempting to do with a regular expression is boggling your mind because it's si... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1670022/"
] | [.NET balanced group regexes](http://blog.stevenlevithan.com/archives/balancing-groups) make my head explode. I've got this string i'm trying to match:
```
other stuff blah blah....
{
stuff stuff
{key:
stuff
... | Have you checked what it is matching in the second case? Since you don't have any anchors, I think the engine starts the match just after the first '{'. From there, until the end, the string matches.
Try surrounding the pattern with \A and \z. |
183,853 | <p>Is there a benefit to using one over the other? In Python 2, they both seem to return the same results:</p>
<pre><code>>>> 6/3
2
>>> 6//3
2
</code></pre>
| [
{
"answer_id": 183863,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 3,
"selected": false,
"text": "<p><code>//</code> is floor division. It will always give you the integer floor of the result. The other is 'regula... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | Is there a benefit to using one over the other? In Python 2, they both seem to return the same results:
```
>>> 6/3
2
>>> 6//3
2
``` | In Python 3.x, `5 / 2` will return `2.5` and `5 // 2` will return `2`. The former is floating point division, and the latter is ***floor division***, sometimes also called ***integer division***.
In Python 2.2 or later in the 2.x line, there is no difference for integers unless you perform a `from __future__ import di... |
183,856 | <p>Is there any way to clean up this type of loop using LINQ?</p>
<pre><code> List<Car> result;
List<string> makes;
List<string> models;
for (int i = 0; i < makes.Count() && i < models.Count(); i++)
{
result.Add(new Car() { Make = makes[i], Model = models[i] });
}
</code... | [
{
"answer_id": 183891,
"author": "Bradley Grainger",
"author_id": 23633,
"author_profile": "https://Stackoverflow.com/users/23633",
"pm_score": 4,
"selected": true,
"text": "<p>You could use <code>Enumerable.Range</code>, like so:</p>\n\n<pre><code>List<Car> result = Enumerable.Ran... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] | Is there any way to clean up this type of loop using LINQ?
```
List<Car> result;
List<string> makes;
List<string> models;
for (int i = 0; i < makes.Count() && i < models.Count(); i++)
{
result.Add(new Car() { Make = makes[i], Model = models[i] });
}
```
Basically I'm looking for some way to collate ... | You could use `Enumerable.Range`, like so:
```
List<Car> result = Enumerable.Range(0, Math.Min(makes.Count, models.Count))
.Select(i => new Car { Make = makes[i], Model = models[i] }).ToList();
```
If `makes` and `models` always contain the same number of items, you can use more compact syntax:
```
List<Car> re... |
183,859 | <p>Our base Masterpage has something like the following</p>
<pre><code> <head runat="server">
<title></title>
<script type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/actions.js")%>"></script>
<script type="text/javascript" src="<%= Page.ResolveCl... | [
{
"answer_id": 183879,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 2,
"selected": false,
"text": "<p>As per <a href=\"http://weblogs.asp.net/scottgu/archive/2006/12/19/tip-trick-how-to-run-a-root-site-with-the-local-w... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439/"
] | Our base Masterpage has something like the following
```
<head runat="server">
<title></title>
<script type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/actions.js")%>"></script>
<script type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/jquery/jquery-1.2.6.min.js")%>"></... | Use the ScriptManager server control:
```
<asp:ScriptManager ID="myScriptManager" runat="server">
<Scripts>
<asp:ScriptReference Path = "~/javascript/actions.js" />
<asp:ScriptReference Path = "~/javascript/jquery/jquery-1.2.6.min.js" />
</Scripts>
</asp:ScriptManager>
``` |
183,881 | <p>I'm working on a home project that involves comparing images to a database of images (using a quadrant - or so - histogram approach). I wanted to know what my options are in regards to web cams or other image capture devices that:</p>
<ul>
<li>Are easy to work with with the
Windows SDK (particularly
<a href="http:... | [
{
"answer_id": 183879,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 2,
"selected": false,
"text": "<p>As per <a href=\"http://weblogs.asp.net/scottgu/archive/2006/12/19/tip-trick-how-to-run-a-root-site-with-the-local-w... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5645/"
] | I'm working on a home project that involves comparing images to a database of images (using a quadrant - or so - histogram approach). I wanted to know what my options are in regards to web cams or other image capture devices that:
* Are easy to work with with the
Windows SDK (particularly
[DirectShow](http://msdn.micr... | Use the ScriptManager server control:
```
<asp:ScriptManager ID="myScriptManager" runat="server">
<Scripts>
<asp:ScriptReference Path = "~/javascript/actions.js" />
<asp:ScriptReference Path = "~/javascript/jquery/jquery-1.2.6.min.js" />
</Scripts>
</asp:ScriptManager>
``` |
183,898 | <p>How do I do forward referencing / declaration in C++ to avoid circular header file references?</p>
<p>I have the #ifndef guard in the header file, yet memory tells me I need this forward referencing thing - which i've used before >< but can't remember how. </p>
| [
{
"answer_id": 183908,
"author": "antik",
"author_id": 1625,
"author_profile": "https://Stackoverflow.com/users/1625",
"pm_score": 5,
"selected": true,
"text": "<p>You predeclare the class without including it. For example:</p>\n\n<pre><code>//#include \"Foo.h\" // including Foo.h cause... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209/"
] | How do I do forward referencing / declaration in C++ to avoid circular header file references?
I have the #ifndef guard in the header file, yet memory tells me I need this forward referencing thing - which i've used before >< but can't remember how. | You predeclare the class without including it. For example:
```
//#include "Foo.h" // including Foo.h causes circular reference
class Foo;
class Bar
{
...
};
``` |
183,904 | <p>In the following code below:</p>
<pre><code>Image img = new Image();
img.Source = new BitmapImage(new Uri("http://someURL/somefilename.jpg", UriKind.Absolute));
</code></pre>
<p>how can I determine if the image successfully loaded (when there's a valid URI)? i.e., The URI is a valid format, but the file may not ex... | [
{
"answer_id": 184069,
"author": "Joel B Fant",
"author_id": 22211,
"author_profile": "https://Stackoverflow.com/users/22211",
"pm_score": 1,
"selected": false,
"text": "<p><code>Image</code> has an <code>ImageFailed</code> event.</p>\n\n<p><code>BitmapSource</code> (base for <code>Bitma... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26218/"
] | In the following code below:
```
Image img = new Image();
img.Source = new BitmapImage(new Uri("http://someURL/somefilename.jpg", UriKind.Absolute));
```
how can I determine if the image successfully loaded (when there's a valid URI)? i.e., The URI is a valid format, but the file may not exist. | `Image` has an `ImageFailed` event.
`BitmapSource` (base for `BitmapImage`) has an `IsDownloading` property, as well as `DownloadProgress`, `DownloadCompleted`, and `DownloadFailed` events. |
183,907 | <p>Say you've loaded a text file into a string, and you'd like to convert all Unicode escapes into actual Unicode characters inside of the string. </p>
<p>Example:</p>
<blockquote>
<p>"The following is the top half of an integral character in Unicode '\u2320', and this is the lower half '\U2321'."</p>
</blockquote>... | [
{
"answer_id": 183909,
"author": "jr.",
"author_id": 2415,
"author_profile": "https://Stackoverflow.com/users/2415",
"pm_score": 7,
"selected": true,
"text": "<p>The answer is simple and works well with strings up to at least several thousand characters.</p>\n\n<p>Example 1:</p>\n\n<pre>... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2415/"
] | Say you've loaded a text file into a string, and you'd like to convert all Unicode escapes into actual Unicode characters inside of the string.
Example:
>
> "The following is the top half of an integral character in Unicode '\u2320', and this is the lower half '\U2321'."
>
>
> | The answer is simple and works well with strings up to at least several thousand characters.
Example 1:
```
Regex rx = new Regex( @"\\[uU]([0-9A-F]{4})" );
result = rx.Replace( result, match => ((char) Int32.Parse(match.Value.Substring(2), NumberStyles.HexNumber)).ToString() );
```
Example 2:
```
Regex rx = new ... |
183,914 | <pre><code>echo $_POST["name"]; //returns the value a user typed into the "name" field
</code></pre>
<p>I would like to be able to also return the text of the key. In this example, I want to return the text "name". Can I do this?</p>
| [
{
"answer_id": 183917,
"author": "Matthias Winkelmann",
"author_id": 4494,
"author_profile": "https://Stackoverflow.com/users/4494",
"pm_score": 1,
"selected": false,
"text": "<pre><code>array_keys($_POST)\n</code></pre>\n\n<p><a href=\"http://de.php.net/array_keys\" rel=\"nofollow noref... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16292/"
] | ```
echo $_POST["name"]; //returns the value a user typed into the "name" field
```
I would like to be able to also return the text of the key. In this example, I want to return the text "name". Can I do this? | Check out the array\_keys() function assuming this is PHP.
<http://us2.php.net/array_keys> |
183,921 | <p>I'd like all queries like</p>
<pre><code>http://mysite.com/something/otherthing?foo=bar&x=y
</code></pre>
<p>to be rewritten as</p>
<pre><code>http://mysite.com/something/otherthing.php?foo=bar&x=y
</code></pre>
<p>In other words, just make the .php extension optional, universally.</p>
| [
{
"answer_id": 183931,
"author": "theraccoonbear",
"author_id": 7210,
"author_profile": "https://Stackoverflow.com/users/7210",
"pm_score": 0,
"selected": false,
"text": "<p>Something like...</p>\n\n<pre><code>RewriteRule /something/(.+)?(.+) /something/$1.php?$2\n</code></pre>\n\n<p>wou... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | I'd like all queries like
```
http://mysite.com/something/otherthing?foo=bar&x=y
```
to be rewritten as
```
http://mysite.com/something/otherthing.php?foo=bar&x=y
```
In other words, just make the .php extension optional, universally. | I would do it this way. Basically, if file doesn't exist, try adding .php to it.
```
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1.php [QSA,L]
``` |
183,923 | <p>I have a class that has a Generic type "G"</p>
<p>In my class model i have</p>
<pre><code>public class DetailElement : ElementDefinition
</code></pre>
<p>Let's say i have a method like this</p>
<pre><code> public void DoSomething<G>(G generic)
where G : ElementDefinition
{
... | [
{
"answer_id": 183949,
"author": "benjismith",
"author_id": 22979,
"author_profile": "https://Stackoverflow.com/users/22979",
"pm_score": 1,
"selected": false,
"text": "<p>Shouldn't your where clause be \"where G : DetailElement\"?</p>\n\n<p>In the code you've written, a DetailElement is... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20335/"
] | I have a class that has a Generic type "G"
In my class model i have
```
public class DetailElement : ElementDefinition
```
Let's say i have a method like this
```
public void DoSomething<G>(G generic)
where G : ElementDefinition
{
if (generic is DetailElement)
{
... | If `G` was constrained to be a `DetailElement` (`where G : DetailElement`) then you can go ahead and cast `G` to ElementDefinition, i.e., "`(ElementDefinition) generic`". But because `G` might be another subclass of `ElementDefinition` other than `DetailElement` at run-time it won't allow it at compile-time where the t... |
183,928 | <p>How do I create subdomain like <code>http://user.mywebsite.example</code>? Do I have to access <code>.htaccess</code> somehow? Is it actually simply possible to create it via pure PHP code or I need to use some external script-server side language?</p>
<p>To those who answered: Well, then, should I ask my hosting if... | [
{
"answer_id": 183939,
"author": "theraccoonbear",
"author_id": 7210,
"author_profile": "https://Stackoverflow.com/users/7210",
"pm_score": 2,
"selected": false,
"text": "<p>In addition to configuration changes on your WWW server to handle the new subdomain, your code would need to be ma... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21209/"
] | How do I create subdomain like `http://user.mywebsite.example`? Do I have to access `.htaccess` somehow? Is it actually simply possible to create it via pure PHP code or I need to use some external script-server side language?
To those who answered: Well, then, should I ask my hosting if they provide some sort of DNS ... | You're looking to create a custom **A record**.
I'm pretty sure that you can use wildcards when specifying A records which would let you do something like this:
```
*.mywebsite.example IN A 127.0.0.1
```
*`127.0.0.1` would be the IP address of your webserver. The method of actually adding the record wi... |
183,932 | <p>I have an app using PHP and the PayPal API. The basic way it works to get a payment is that you do a web service call to PayPal to get a token and then do a browser redirect to PayPal with that token for the user to pay. After the payment details have been confirmed, PayPal redirects back to the URL you originally s... | [
{
"answer_id": 184003,
"author": "vIceBerg",
"author_id": 17766,
"author_profile": "https://Stackoverflow.com/users/17766",
"pm_score": 1,
"selected": false,
"text": "<p>Can you do a phpinfo() and tell if session.auto_start is true?</p>\n"
},
{
"answer_id": 184429,
"author": ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6010/"
] | I have an app using PHP and the PayPal API. The basic way it works to get a payment is that you do a web service call to PayPal to get a token and then do a browser redirect to PayPal with that token for the user to pay. After the payment details have been confirmed, PayPal redirects back to the URL you originally set ... | Just an idea ...
Do you have `session.referer_check` set to your host perhaps?
The default is the empty string, but it might have been changed ... and when the page 'comes back' from PayPal, php will trash the session info.
You can check the `session.referer_check` with phpinfo(). |