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 |
|---|---|---|---|---|---|---|
258,988 | <p>I'm <a href="http://channel9.msdn.com/shows/Going+Deep/Inside-C-40-dynamic-type-optional-parameters-more-COM-friendly/" rel="noreferrer">listening to a talk</a> about <strong>C#4</strong>'s <code>dynamic</code> keyword and I'm wondering... Will this feature be orthogonal to other .NET features, for example will it s... | [
{
"answer_id": 258999,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "<p>From the <a href=\"http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=csharpfuture&Down... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3848/"
] | I'm [listening to a talk](http://channel9.msdn.com/shows/Going+Deep/Inside-C-40-dynamic-type-optional-parameters-more-COM-friendly/) about **C#4**'s `dynamic` keyword and I'm wondering... Will this feature be orthogonal to other .NET features, for example will it support extension methods?
```
public static class StrE... | From the ["New Features in C# 4" word doc](http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=csharpfuture&DownloadId=3550):
>
> Dynamic lookup will not be able to
> find extension methods. Whether
> extension methods apply or not depends
> on the static context of the call
> (i.e. whic... |
259,000 | <p>I have a system which is using phone numbers as unique identifiers. For this reason, I want to format all phone numbers as they come in using a normalized format. Because I have no control over my source data, I need to parse out these numbers myself and format them before adding them to my DB.</p>
<p>I'm about to ... | [
{
"answer_id": 259016,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p>Just strip out any non-digits, possibly using a RegEx: <code>[^\\d]</code></p>\n\n<p>The only exception might be if... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] | I have a system which is using phone numbers as unique identifiers. For this reason, I want to format all phone numbers as they come in using a normalized format. Because I have no control over my source data, I need to parse out these numbers myself and format them before adding them to my DB.
I'm about to write a pa... | You could use `libphonenumber` from Google. Here's a blog post:
<http://blog.appharbor.com/2012/02/03/net-phone-number-validation-with-google-libphonenumber>
Parsing numbers is as easy as installing the [NuGet package](http://nuget.org/packages/libphonenumber-csharp) and then doing this:
```
var util = PhoneNumberU... |
259,014 | <p>I'm reading up on event-driven design. I am having trouble getting my head around some of it in practice. I'm considering using this for a windows service that monitors, parses, and handles information coming from a 3rd party TCP stream. Is the following a decent approach, or am I missing something? </p>
<p>My p... | [
{
"answer_id": 259016,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p>Just strip out any non-digits, possibly using a RegEx: <code>[^\\d]</code></p>\n\n<p>The only exception might be if... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm reading up on event-driven design. I am having trouble getting my head around some of it in practice. I'm considering using this for a windows service that monitors, parses, and handles information coming from a 3rd party TCP stream. Is the following a decent approach, or am I missing something?
My plan is to hav... | You could use `libphonenumber` from Google. Here's a blog post:
<http://blog.appharbor.com/2012/02/03/net-phone-number-validation-with-google-libphonenumber>
Parsing numbers is as easy as installing the [NuGet package](http://nuget.org/packages/libphonenumber-csharp) and then doing this:
```
var util = PhoneNumberU... |
259,015 | <p>Can every possible value of a <code>float</code> variable can be represented exactly in a <code>double</code> variable?</p>
<p>In other words, for all possible values <code>X</code> will the following be successful:</p>
<pre><code>float f1 = X;
double d = f1;
float f2 = (float)d;
if(f1 == f2)
System.out.println... | [
{
"answer_id": 259029,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 3,
"selected": false,
"text": "<p>In theory, there is not such a value, so \"yes\", every float should be representable as a double.. Converting fr... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] | Can every possible value of a `float` variable can be represented exactly in a `double` variable?
In other words, for all possible values `X` will the following be successful:
```
float f1 = X;
double d = f1;
float f2 = (float)d;
if(f1 == f2)
System.out.println("Success!");
else
System.out.println("Failure!");
... | Yes.
Proof by enumeration of all possible cases:
```
public class TestDoubleFloat {
public static void main(String[] args) {
for (long i = Integer.MIN_VALUE; i <= Integer.MAX_VALUE; i++) {
float f1 = Float.intBitsToFloat((int) i);
double d = (double) f1;
float f2 = (fl... |
259,018 | <p>This is what I have written:</p>
<pre><code>if ((lstProperty[i].PropertyIdentifier as string).CompareTo("Name") == 0)
</code></pre>
<p>Resharper put me an error (I am new with ReSharper... I am trying it) and it suggests me :</p>
<pre><code> if (((string) lstProperty[i].PropertyIdentifier).CompareTo("Name") == 0... | [
{
"answer_id": 259062,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 4,
"selected": true,
"text": "<p>The 'as' operator will return null if the cast cannot be executed, while a C-style cast will throw an exception if it can't... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] | This is what I have written:
```
if ((lstProperty[i].PropertyIdentifier as string).CompareTo("Name") == 0)
```
Resharper put me an error (I am new with ReSharper... I am trying it) and it suggests me :
```
if (((string) lstProperty[i].PropertyIdentifier).CompareTo("Name") == 0)
```
Why is the second is NullExce... | The 'as' operator will return null if the cast cannot be executed, while a C-style cast will throw an exception if it can't cast.
I suggest breaking this out into multiple statements:
```
string propertyIdentifier = lstProperty[u].PropertyIdentifier as string;
if(propertyIdentifier != null && propertyIdentifier.Compa... |
259,024 | <p>I am trying to use WScript.Shell SendKeys method to emulate sending a key press from the Number Pad.</p>
<p>I have an application that I am writing automated testing for using QTP. It is a Web Browser based application and the input is into a Java App within the web page. The input only accepts key presses from th... | [
{
"answer_id": 259298,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure that this can be answered with the information that you have provided so far. My gut feeling would be that you s... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26950/"
] | I am trying to use WScript.Shell SendKeys method to emulate sending a key press from the Number Pad.
I have an application that I am writing automated testing for using QTP. It is a Web Browser based application and the input is into a Java App within the web page. The input only accepts key presses from the Number Pa... | I would choose PowerShell over WMI for the following reasons:
1. Writing a cmdlet is only adding a .NET Class.
2. The PowerShell runtime provides command line parsing built in.
3. Writing your management interface in PowerShell allows administrators the ability to integrate management of your application with that of ... |
259,026 | <p>Why was C# designed this way?</p>
<p>As I understand it, an interface only describes behaviour, and serves the purpose of describing a contractual obligation for classes implementing the interface that certain behaviour is implemented.</p>
<p>If classes wish to implement that behavour in a shared method, why shoul... | [
{
"answer_id": 259033,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>Because interfaces are in inheritance structure, and static methods don't inherit well.</p>\n"
},
{
"answer... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11514/"
] | Why was C# designed this way?
As I understand it, an interface only describes behaviour, and serves the purpose of describing a contractual obligation for classes implementing the interface that certain behaviour is implemented.
If classes wish to implement that behavour in a shared method, why shouldn't they?
Here ... | Assuming you are asking why you can't do this:
```
public interface IFoo {
void Bar();
}
public class Foo: IFoo {
public static void Bar() {}
}
```
This doesn't make sense to me, semantically. Methods specified on an interface should be there to specify the contract for interacting with an object. Static me... |
259,031 | <p>Consider that I have a transaction:</p>
<pre><code>BEGIN TRANSACTION
DECLARE MONEY @amount
SELECT Amount AS @amount
FROM Deposits
WHERE UserId = 123
UPDATE Deposits
SET Amount = @amount + 100.0
WHERE UserId = 123
COMMIT
</code></pre>
<p>And it gets executed on 2 threads, in the order:</p>
<ol>
<li>thread ... | [
{
"answer_id": 259097,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>I believe that you would want to use Repeatable read, which would lock the records, the first select would get ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6176/"
] | Consider that I have a transaction:
```
BEGIN TRANSACTION
DECLARE MONEY @amount
SELECT Amount AS @amount
FROM Deposits
WHERE UserId = 123
UPDATE Deposits
SET Amount = @amount + 100.0
WHERE UserId = 123
COMMIT
```
And it gets executed on 2 threads, in the order:
1. thread 1 - select
2. thread 2 - select
3. t... | Nice well stated scenario. I decided to test it.
Here's my setup script:
```
CREATE TABLE Deposits(Amount Money, UserID int)
INSERT INTO Deposits (Amount, UserID)
SELECT 0.0, 123
--Reset
UPDATE Deposits
SET Amount = 0.00
WHERE UserID = 123
```
Here's my test script.
```
SET TRANSACTION ISOLATION LEVEL Serializable... |
259,038 | <p>I am trying to fetch an RTSP stream over HTTP using a proxy. The behavior of the Real client seems to be a bit hectic: it tries all the possible ports, methods and protocols at once. The only thing that should work is HTTP GET over port 80. Such a request is indeed issued, and is received on the server. Here's how t... | [
{
"answer_id": 260232,
"author": "Alexander",
"author_id": 16724,
"author_profile": "https://Stackoverflow.com/users/16724",
"pm_score": 0,
"selected": false,
"text": "<ol>\n<li>See whether issuing the same request but bypassing the proxy (e.g., replay the request you posted above using ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29402/"
] | I am trying to fetch an RTSP stream over HTTP using a proxy. The behavior of the Real client seems to be a bit hectic: it tries all the possible ports, methods and protocols at once. The only thing that should work is HTTP GET over port 80. Such a request is indeed issued, and is received on the server. Here's how the ... | First, you might want to read this:
<http://developer.apple.com/quicktime/icefloe/dispatch028.html>
Second, the HTTP requests (both GET and POST) need to be formatted so that they get proxied properly. I've seen proxies that insist on caching too much of the POST request, preventing it from reaching the server. Those... |
259,063 | <h3>Problem</h3>
<p>I've got a collection of <code>IThing</code>s and I'd like to create a <code>HierarchicalDataTemplate</code> for a <code>TreeView</code>. The straightforward <code>DataType={x:Type local:IThing}</code> of course doesn't work, probably because the WPF creators didn't want to handle the possible ambi... | [
{
"answer_id": 371948,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>The reason for this is that the default template selector supports only concrete types, not interfaces. You need to create a... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4918/"
] | ### Problem
I've got a collection of `IThing`s and I'd like to create a `HierarchicalDataTemplate` for a `TreeView`. The straightforward `DataType={x:Type local:IThing}` of course doesn't work, probably because the WPF creators didn't want to handle the possible ambiguities.
Since this should handle `IThing`s from di... | The reason for this is that the default template selector supports only concrete types, not interfaces. You need to create a custom DataTemplateSelector and apply it to the ItemTemplateSelector property of the TreeView. I can't find the URL where I found an example of it, but hopefully with this info, you can Google it... |
259,111 | <p>I'm running in a strange issue.
My controller calls a drb object</p>
<pre><code>@request_handler = DRbObject.new(nil, url)
availability_result = @request_handler.fetch_availability(request, @reservation_search, params[:selected_room_rates])
</code></pre>
<p>and this Drb object is making some searches.</p>
<p>but... | [
{
"answer_id": 299258,
"author": "Max Caceres",
"author_id": 4842,
"author_profile": "https://Stackoverflow.com/users/4842",
"pm_score": 0,
"selected": false,
"text": "<p>Is it possible you are calling DRb.start_service more than once in the server?</p>\n"
},
{
"answer_id": 36739... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22083/"
] | I'm running in a strange issue.
My controller calls a drb object
```
@request_handler = DRbObject.new(nil, url)
availability_result = @request_handler.fetch_availability(request, @reservation_search, params[:selected_room_rates])
```
and this Drb object is making some searches.
but sometimes, in a linux environmen... | The error means that you're trying to serve an object that's been garbage collected, which usually happens because the object went out of scope on the **server**.
Your safest bet is figuring out why the object was prematurely garbage-collected in the first place. Alternatively, you could disable the server's GC by cal... |
259,123 | <p>My app has a DataGridView object and a List of type MousePos. MousePos is a custom class that holds mouse X,Y coordinates (of type "Point") and a running count of this position. I have a thread (System.Timers.Timer) that raises an event once every second, checks the mouse position, adds and/or updates the count of t... | [
{
"answer_id": 259133,
"author": "Grzenio",
"author_id": 5363,
"author_profile": "https://Stackoverflow.com/users/5363",
"pm_score": 3,
"selected": false,
"text": "<p>You have to update the grid on the main UI thread, like all the other controls. See control.Invoke or Control.BeginInvoke... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21244/"
] | My app has a DataGridView object and a List of type MousePos. MousePos is a custom class that holds mouse X,Y coordinates (of type "Point") and a running count of this position. I have a thread (System.Timers.Timer) that raises an event once every second, checks the mouse position, adds and/or updates the count of the ... | **UPDATE!** -- I *partially* figured out the answer to **part #1** in the book "Pro .NET 2.0 Windows Forms and Customer Controls in C#"
I had originally thought that **Refresh()** wasn't doing anything and that I needed to call the **Invalidate()** method, to tell Windows to repaint my control at it's leisure. (which ... |
259,126 | <p>Is there any way to change the entire width of the horizontal scroll bar on a scrolling div (including the nudge arrows and the handle).</p>
<p>EDIT: I only need an IE7 solution - it's for a scrolling DIV on a touch screen terminal</p>
<p>Thanks</p>
<p>Matt</p>
| [
{
"answer_id": 259270,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 3,
"selected": true,
"text": "<p>Actually, I revise my statement... <strong>in IE7</strong>, you <strong>CAN</strong> do some scaling.</p>\n\n<pre><code>... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5185/"
] | Is there any way to change the entire width of the horizontal scroll bar on a scrolling div (including the nudge arrows and the handle).
EDIT: I only need an IE7 solution - it's for a scrolling DIV on a touch screen terminal
Thanks
Matt | Actually, I revise my statement... **in IE7**, you **CAN** do some scaling.
```
<div style="zoom:5;font-size:20%;overflow-x:auto;">
Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World!
</div>
```
zoom tells IE to scale up the contents by 500... |
259,139 | <p>Use case:</p>
<ol>
<li>A does something on his box and gots stuck. He asks B (remote) for support.</li>
<li>B logs into the session of A, sees all windows, A was seeing and is able to manipulate the GUI.</li>
</ol>
<p>If A uses Windows it is very convenient to log into a running session e.g. via VNC. But if A uses... | [
{
"answer_id": 259270,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 3,
"selected": true,
"text": "<p>Actually, I revise my statement... <strong>in IE7</strong>, you <strong>CAN</strong> do some scaling.</p>\n\n<pre><code>... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11344/"
] | Use case:
1. A does something on his box and gots stuck. He asks B (remote) for support.
2. B logs into the session of A, sees all windows, A was seeing and is able to manipulate the GUI.
If A uses Windows it is very convenient to log into a running session e.g. via VNC. But if A uses Linux, AFAIK, this is not possib... | Actually, I revise my statement... **in IE7**, you **CAN** do some scaling.
```
<div style="zoom:5;font-size:20%;overflow-x:auto;">
Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World!
</div>
```
zoom tells IE to scale up the contents by 500... |
259,140 | <p>How do I search the whole classpath for an annotated class?</p>
<p>I'm doing a library and I want to allow the users to annotate their classes, so when the Web application starts I need to scan the whole classpath for certain annotation.</p>
<p>I'm thinking about something like the new functionality for Java EE 5 We... | [
{
"answer_id": 259351,
"author": "mfx",
"author_id": 8015,
"author_profile": "https://Stackoverflow.com/users/8015",
"pm_score": 2,
"selected": false,
"text": "<p>The Classloader API doesn't have an \"enumerate\" method, because class loading is an \"on-demand\" activity -- you usually h... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2937/"
] | How do I search the whole classpath for an annotated class?
I'm doing a library and I want to allow the users to annotate their classes, so when the Web application starts I need to scan the whole classpath for certain annotation.
I'm thinking about something like the new functionality for Java EE 5 Web Services or E... | Use [org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider](http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.html)
API
>
> A component provider that scans the classpath from a base package. It then ap... |
259,147 | <p>I'm using <a href="http://urlrewriter.net/" rel="nofollow noreferrer">http://urlrewriter.net/</a> to rewrite urls at my website. For example, I'm rewriting:</p>
<blockquote>
<p><a href="http://www.example.com/schedule.aspx?state=ca" rel="nofollow noreferrer">http://www.example.com/schedule.aspx?state=ca</a></p>
<... | [
{
"answer_id": 259175,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 2,
"selected": false,
"text": "<p>If you need to do this you can probably do something like:</p>\n\n<pre><code><add header=\"X-WasRewritten\" value=\"tru... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28260/"
] | I'm using <http://urlrewriter.net/> to rewrite urls at my website. For example, I'm rewriting:
>
> <http://www.example.com/schedule.aspx?state=ca>
>
>
>
to
>
> <http://www.example.com/california.aspx>
>
>
>
What I'm trying to do (for SEO purposes) to to dynamically add the meta tag:
```
<meta name="robots"... | personally, I would 301 redirect from the un-rewritten one to the re-written one, and only use the single copy of the page. It is easier for users, and from an SEO perspective, you have 1 copy of the content. |
259,150 | <p>I have an incoming soap message wich form is TStream (Delphi7), server that send this soap is in development mode and adds a html header to the message for debugging purposes. Now i need to cut out the html header part from it before i can pass it to soap converter. It starts from the beginning with 'pre' tag and en... | [
{
"answer_id": 259216,
"author": "Lars Truijens",
"author_id": 1242,
"author_profile": "https://Stackoverflow.com/users/1242",
"pm_score": 1,
"selected": false,
"text": "<p>Make a new TStream (use TMemoryStream) and move any stuff you want to keep over from one stream to the other with T... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26207/"
] | I have an incoming soap message wich form is TStream (Delphi7), server that send this soap is in development mode and adds a html header to the message for debugging purposes. Now i need to cut out the html header part from it before i can pass it to soap converter. It starts from the beginning with 'pre' tag and ends ... | I think the following code would do what you want, assuming you only have one <pre> block in your document.
```
function DepreStream(Stm : tStream):tStream;
var
sTemp : String;
oStrStm : tStringStream;
i : integer;
begin
oStrStm := tStringStream.create('');
try
Stm.Seek(0,soFromBeginning);
oStrStm.co... |
259,180 | <p>I am trying to get my development environment up and running, and I am having trouble with Tomcat trying to load JSF classes for some reason. My application does not use JSF; in fact, I haven't even deployed my application to tomcat yet. I am getting a number of stack traces in the startup logs and I cannot load t... | [
{
"answer_id": 259250,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 3,
"selected": true,
"text": "<p>Is your tomcat installation totally clean, or is it one you have inherited?</p>\n\n<p>Check if the webapps contains existi... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4257/"
] | I am trying to get my development environment up and running, and I am having trouble with Tomcat trying to load JSF classes for some reason. My application does not use JSF; in fact, I haven't even deployed my application to tomcat yet. I am getting a number of stack traces in the startup logs and I cannot load the de... | Is your tomcat installation totally clean, or is it one you have inherited?
Check if the webapps contains existing wars/directories which may be referencing JSF classes?
UPDATE: Ah -- I see you found this was the case :-)
Not sure why tomcat doesn't include all its dependencies. Perhaps you downloaded a developer re... |
259,212 | <p>I am trying to find an algorithm to count from 0 to 2<sup>n</sup>-1 but their bit pattern reversed. I care about only n LSB of a word. As you may have guessed I failed.</p>
<p>For n=3: </p>
<pre><code>000 -> 0
100 -> 4
010 -> 2
110 -> 6
001 -> 1
101 -> 5
011 -> 3
111 -> 7
</code></pre>
<p>... | [
{
"answer_id": 259246,
"author": "Bill K",
"author_id": 12943,
"author_profile": "https://Stackoverflow.com/users/12943",
"pm_score": 2,
"selected": false,
"text": "<p>This solution was originally in binary and converted to conventional math as the requester specified.</p>\n\n<p>It would... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7988/"
] | I am trying to find an algorithm to count from 0 to 2n-1 but their bit pattern reversed. I care about only n LSB of a word. As you may have guessed I failed.
For n=3:
```
000 -> 0
100 -> 4
010 -> 2
110 -> 6
001 -> 1
101 -> 5
011 -> 3
111 -> 7
```
You get the idea.
Answers in pseudo-code is great. Code fragments i... | This is, I think easiest with bit operations, even though you said this wasn't preferred
Assuming 32 bit ints, here's a nifty chunk of code that can reverse *all* of the bits without doing it in 32 steps:
```
unsigned int i;
i = (i & 0x55555555) << 1 | (i & 0xaaaaaaaa) >> 1;
i = (i & 0x33333333) << 2 | (i & 0xc... |
259,234 | <p>How do I run a function on a loop so all the results go straight into a list and is there a way to run a function which acts on all the values in a list?</p>
| [
{
"answer_id": 259259,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 0,
"selected": false,
"text": "<p>This example shows how to do it (run it in an interpreter)</p>\n\n<pre><code>>>> def square(x):\n... re... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33061/"
] | How do I run a function on a loop so all the results go straight into a list and is there a way to run a function which acts on all the values in a list? | Theres a couple ways to run a function on a loop like that - You can either use a list comprehension
```
test = list('asdf')
[function(x) for x in test]
```
and use that result
Or you could use the map function
```
test = list('asdf')
map(function, test)
```
The first answer is more "pythonic", while the second ... |
259,240 | <p>I'm just getting back into C++ after a couple of years of doing a lot of C#, and recently Objective C.</p>
<p>One thing I've done before is to roll my own iterator adapter for std::map that will deref to just the value part, rather than the key-value pair. This is quite a common and natural thing to do. C# provides... | [
{
"answer_id": 259377,
"author": "David Nehme",
"author_id": 14167,
"author_profile": "https://Stackoverflow.com/users/14167",
"pm_score": 5,
"selected": true,
"text": "<p>I don't think there's anything out of the box. You can use boost::make_transform.</p>\n\n<pre><code>template<typ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32136/"
] | I'm just getting back into C++ after a couple of years of doing a lot of C#, and recently Objective C.
One thing I've done before is to roll my own iterator adapter for std::map that will deref to just the value part, rather than the key-value pair. This is quite a common and natural thing to do. C# provides this faci... | I don't think there's anything out of the box. You can use boost::make\_transform.
```
template<typename T1, typename T2> T2& take_second(const std::pair<T1, T2> &a_pair)
{
return a_pair.second;
}
void run_map_value()
{
map<int,string> a_map;
a_map[0] = "zero";
a_map[1] = "one";
a_map[2] = "two";
copy( b... |
259,248 | <p>I would like to include a different file depending on the version of GCC. More precisely I want to write:</p>
<pre><code>#if GCC_VERSION >= 4.2
# include <unordered_map>
# define EXT std
#elif GCC_VERSION >= 4
# include <tr1/unordered_map>
# define EXT std
#else
# include <ext/hash_map>... | [
{
"answer_id": 259277,
"author": "luke",
"author_id": 16434,
"author_profile": "https://Stackoverflow.com/users/16434",
"pm_score": 6,
"selected": false,
"text": "<p>There are a number of macros that should be defined for your needs:</p>\n\n<pre><code>__GNUC__ // major\n__GN... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7136/"
] | I would like to include a different file depending on the version of GCC. More precisely I want to write:
```
#if GCC_VERSION >= 4.2
# include <unordered_map>
# define EXT std
#elif GCC_VERSION >= 4
# include <tr1/unordered_map>
# define EXT std
#else
# include <ext/hash_map>
# define unordered_map __gnu_cxx::ha... | Ok, after more searches, it one possible way of doing it is using `__GNUC_PREREQ` defined in `features.h`.
```
#ifdef __GNUC__
# include <features.h>
# if __GNUC_PREREQ(4,0)
// If gcc_version >= 4.0
# elif __GNUC_PREREQ(3,2)
// If gcc_version >= 3.2
# else
// Else
# endif
#else
// If not gcc
... |
259,269 | <p>I have a loop that reads each line in a file using <code>getline()</code>:</p>
<pre><code>istream is;
string line;
while (!getline(is, line).eof())
{
// ...
}
</code></pre>
<p>I noticed that calling <code>getline()</code> like this also seems to work:</p>
<pre><code>while (getline(is, line))
</code></pre>
<p... | [
{
"answer_id": 259284,
"author": "Todd Gamblin",
"author_id": 9122,
"author_profile": "https://Stackoverflow.com/users/9122",
"pm_score": 3,
"selected": false,
"text": "<p><strong>Updated:</strong></p>\n\n<p>I had mistakenly pointed to the <a href=\"http://www.unc.edu/depts/case/pgi/pgC+... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4086/"
] | I have a loop that reads each line in a file using `getline()`:
```
istream is;
string line;
while (!getline(is, line).eof())
{
// ...
}
```
I noticed that calling `getline()` like this also seems to work:
```
while (getline(is, line))
```
What's going on here? `getline()` returns a stream reference. Is it be... | The `istream` returned by `getline()` is having its operator `void*()` method implicitly called, which returns whether the stream has run into an error. As such it's making more checks than a call to `eof()`. |
259,290 | <p><a href="http://biochrom.fivesite.co.uk/catalogue4.asp" rel="nofollow noreferrer">http://biochrom.fivesite.co.uk/catalogue4.asp</a></p>
<p>On the page above there is an image floated to the left. To the right of it is a list, titled "features". The list items have a background image, however, it isn't appearing. Li... | [
{
"answer_id": 259305,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 3,
"selected": true,
"text": "<p>Your image has a float:left property. The list items are therefore rendered \"behind\" the image.</p>\n\n<pre><co... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10023/"
] | <http://biochrom.fivesite.co.uk/catalogue4.asp>
On the page above there is an image floated to the left. To the right of it is a list, titled "features". The list items have a background image, however, it isn't appearing. List 2 shows how the background image looks.
Does anyone know how I can make the bullets visibl... | Your image has a float:left property. The list items are therefore rendered "behind" the image.
```
margin-left:200px;
```
on the UL element will solve your problem.
Alternatively, you can apply a float:left on your UL-element. This will make it float right to the image, but will make the following content appear o... |
259,297 | <p>I have an array of values that is passed to my function from a different part of the program that I need to store for later processing. Since I don't know how many times my function will be called before it is time to process the data, I need a dynamic storage structure, so I chose a <code>std::vector</code>. I do... | [
{
"answer_id": 259307,
"author": "luke",
"author_id": 16434,
"author_profile": "https://Stackoverflow.com/users/16434",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"http://www.cppreference.com/wiki/stl/algorithm/copy\" rel=\"noreferrer\">std::copy</a> is what you're looking fo... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23504/"
] | I have an array of values that is passed to my function from a different part of the program that I need to store for later processing. Since I don't know how many times my function will be called before it is time to process the data, I need a dynamic storage structure, so I chose a `std::vector`. I don't want to have... | If you can construct the vector after you've gotten the array and array size, you can just say:
```
std::vector<ValueType> vec(a, a + n);
```
...assuming `a` is your array and `n` is the number of elements it contains. Otherwise, `std::copy()` w/`resize()` will do the trick.
I'd stay away from `memcpy()` unless you... |
259,309 | <p>Is there a way using JSF to group two or more columns under a single parent column in JSF? I have a dataTableEx with hx:columnEx columns inside of it. What I want is something like this:</p>
<pre><code> [MAIN HEADER FOR COL1+2 ][Header for Col 3+4]
[ COL1 Header][COL2 Header][COL3 ][COL 4 ]
Data ... | [
{
"answer_id": 259348,
"author": "Elie",
"author_id": 23249,
"author_profile": "https://Stackoverflow.com/users/23249",
"pm_score": 0,
"selected": false,
"text": "<p>Your best bet is likely to use nested tables for the first header (first header in the outer table, and your second header... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32812/"
] | Is there a way using JSF to group two or more columns under a single parent column in JSF? I have a dataTableEx with hx:columnEx columns inside of it. What I want is something like this:
```
[MAIN HEADER FOR COL1+2 ][Header for Col 3+4]
[ COL1 Header][COL2 Header][COL3 ][COL 4 ]
Data Data ... | You can probably achieve what you want with the table header, a panelGrid and a little CSS.
```
<style type="text/css">
.colstyle {
width: 25%
}
</style>
</head>
<body>
<f:view>
<h:dataTable border="1" value="#{columnsBean.rows}" var="row"
columnClasses="colstyle">
<f:facet name="header">
... |
259,311 | <p>I am working in Visual Studio 2008 on an ASP.NET application, which has been deployed to a test server. I would like to make a build without debug information to place in production, but the configuration manager only shows "Debug" in the configuration dropdown for my project.</p>
<p>My other Visual Studio project... | [
{
"answer_id": 260921,
"author": "sliderhouserules",
"author_id": 31385,
"author_profile": "https://Stackoverflow.com/users/31385",
"pm_score": 0,
"selected": false,
"text": "<p>The Configuration Manager for the Solution allows you to delete either (or both) of these default build config... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21253/"
] | I am working in Visual Studio 2008 on an ASP.NET application, which has been deployed to a test server. I would like to make a build without debug information to place in production, but the configuration manager only shows "Debug" in the configuration dropdown for my project.
My other Visual Studio projects show "Deb... | ASP.NET web sites do not use the configuration manager to determine if debug information is included in the compile. You must set it in the `web.config` file. Visual Studio will never change debug to "false" for you automactially, as far as I know.
Find this section in your `web.config` file and change it to "false":
... |
259,314 | <p>Hey I have a windows server running python CGI scripts and I'm having a little trouble with smtplib. The server is running python 2.1 (unfortunately and I can not upgrade it). Anyway I have the following code:</p>
<pre><code>session = smtplib.SMTP("smtp-auth.ourhosting.com", 587)
session.login(smtpuser, sm... | [
{
"answer_id": 259324,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>Do it whatever way is expected by the libsmtp in python 2.1</p>\n</blockquote>\n"
},
{
"ans... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2908/"
] | Hey I have a windows server running python CGI scripts and I'm having a little trouble with smtplib. The server is running python 2.1 (unfortunately and I can not upgrade it). Anyway I have the following code:
```
session = smtplib.SMTP("smtp-auth.ourhosting.com", 587)
session.login(smtpuser, smtppass)
```
and it's ... | login() was introduced in Python 2.2, unluckily for you! The only way to do it in Python 2.1's own smtplib would be to issue the AUTH commands manually, which wouldn't be much fun.
I haven't tested it fully but it seems Python 2.2's smtplib should more or less work on 2.1 if you copy it across as you describe (perhaps... |
259,320 | <p>I'm still learning Grails and seem to have hit a stumbling block.</p>
<p><strong>Here are the 2 domain classes:</strong></p>
<pre><code>class Photo {
byte[] file
static belongsTo = Profile
}
class Profile {
String fullName
Set photos
static hasMany = [photos:Photo]
}
</code></pre>
<p... | [
{
"answer_id": 259361,
"author": "Hates_",
"author_id": 3410,
"author_profile": "https://Stackoverflow.com/users/3410",
"pm_score": 3,
"selected": true,
"text": "<p>As it is a Set, if you want the first element, you will have to go:</p>\n\n<pre><code>profileInstance.photos.toArray()[0].i... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27163/"
] | I'm still learning Grails and seem to have hit a stumbling block.
**Here are the 2 domain classes:**
```
class Photo {
byte[] file
static belongsTo = Profile
}
class Profile {
String fullName
Set photos
static hasMany = [photos:Photo]
}
```
**The relevant controller snippet:**
```
cla... | As it is a Set, if you want the first element, you will have to go:
```
profileInstance.photos.toArray()[0].id
```
or
```
profileInstance.photos.iterator().next()
``` |
259,343 | <p>Is there any way to reboot the JVM? As in don't actually exit, but close and reload all classes, and run main from the top?</p>
| [
{
"answer_id": 259450,
"author": "Miguel Ping",
"author_id": 22992,
"author_profile": "https://Stackoverflow.com/users/22992",
"pm_score": 0,
"selected": false,
"text": "<p>AFAIK there is no such way. </p>\n\n<p>Notice that if there were a way to do that, it would highly depend on the cu... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/420/"
] | Is there any way to reboot the JVM? As in don't actually exit, but close and reload all classes, and run main from the top? | Your best bet is probably to run the java interpreter within a loop, and just exit. For example:
```
#!/bin/sh
while true
do
java MainClass
done
```
If you want the ability to reboot or shutdown entirely, you could test the exit status:
```
#!/bin/sh
STATUS=0
while [ $STATUS -eq 0 ]
do
java MainClass
ST... |
259,354 | <p>Is there a substitute in emacs for the vi "gf" command?
meaning try to open the file which is under the cursor right now
if a real file name is in fact there.</p>
<p>Thanks</p>
| [
{
"answer_id": 259376,
"author": "cjm",
"author_id": 8355,
"author_profile": "https://Stackoverflow.com/users/8355",
"pm_score": 7,
"selected": true,
"text": "<p>You want the <code>find-file-at-point</code> function (which is also aliased to <code>ffap</code>). It's not bound to a key b... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33707/"
] | Is there a substitute in emacs for the vi "gf" command?
meaning try to open the file which is under the cursor right now
if a real file name is in fact there.
Thanks | You want the `find-file-at-point` function (which is also aliased to `ffap`). It's not bound to a key by default, but you can use
```
M-x ffap
```
Or, you can put in your `.emacs` file:
```
(ffap-bindings)
```
This will replace many of the normal `find-file` key bindings (like `C-x C-f`) with `ffap`-based version... |
259,355 | <blockquote>
<p>It turns out this whole misunderstanding of the open() versus fopen() stems from a buggy I2C driver in the Linux 2.6.14 kernel on an ARM. Backporting a working bit bashed driver solved the root cause of the problem I was trying to address here.</p>
</blockquote>
<p>I'm trying to figure out an issue ... | [
{
"answer_id": 259370,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 6,
"selected": true,
"text": "<p>You have two choices:</p>\n\n<ol>\n<li><p>Use <code>fileno()</code> to obtain the file descriptor associated with the <cod... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32836/"
] | >
> It turns out this whole misunderstanding of the open() versus fopen() stems from a buggy I2C driver in the Linux 2.6.14 kernel on an ARM. Backporting a working bit bashed driver solved the root cause of the problem I was trying to address here.
>
>
>
I'm trying to figure out an issue with a serial device drive... | You have two choices:
1. Use `fileno()` to obtain the file descriptor associated with the `stdio` stream pointer
2. Don't use `<stdio.h>` at all, that way you don't need to worry about flush either - all writes will go to the device immediately, and for character devices the `write()` call won't even return until the ... |
259,364 | <p>I'm using Emacs with <a href="http://mfgames.com/linux/csharp-mode" rel="nofollow noreferrer">C# Mode</a> and when I turn on the speedbar, no files show up by default. I can choose "show all files" on the speedbar mode, but then every .cs file shows up with a '[?]' next to the name. How do I properly configure s... | [
{
"answer_id": 261279,
"author": "Vagmi Mudumbai",
"author_id": 617,
"author_profile": "https://Stackoverflow.com/users/617",
"pm_score": 2,
"selected": false,
"text": "<p>I used speedbar earlier and got really irritated. I now use <a href=\"http://ecb.sourceforge.net/\" rel=\"nofollow n... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180/"
] | I'm using Emacs with [C# Mode](http://mfgames.com/linux/csharp-mode) and when I turn on the speedbar, no files show up by default. I can choose "show all files" on the speedbar mode, but then every .cs file shows up with a '[?]' next to the name. How do I properly configure speedbar so it shows up with .cs files by def... | I think ECB with CEDET is simply too bloated. I use speedbar alone with emacs and I use the original parser for C/C++. Just add this line to your .emacs and you'll be ok:
```
(speedbar-add-supported-extension ".cs")
(add-to-list 'speedbar-fetch-etags-parse-list
'("\\.cs" . speedbar-parse-c-or-c++tag)... |
259,369 | <p>I want to be able to rewrite a URL from:</p>
<pre><code>// examples
http://example.com/location/New York, NY -->
http://example.com/location/index.html?location=New York, NY
http://example.com/location/90210 -->
http://example.com/location/index.html?location=90210
http://example.com/location/Texas -->... | [
{
"answer_id": 259406,
"author": "Piskvor left the building",
"author_id": 19746,
"author_profile": "https://Stackoverflow.com/users/19746",
"pm_score": 2,
"selected": false,
"text": "<p>Your last example should work; I'd also check the condition to be case-insensitive (to avoid /LoCatio... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33554/"
] | I want to be able to rewrite a URL from:
```
// examples
http://example.com/location/New York, NY -->
http://example.com/location/index.html?location=New York, NY
http://example.com/location/90210 -->
http://example.com/location/index.html?location=90210
http://example.com/location/Texas -->
http://example.com/lo... | Your last example should work; I'd also check the condition to be case-insensitive (to avoid /LoCation/indeX.htmL from being parsed), terminate rewrite with [L] (to prevent infinite loops) and add QSA (for appending queries):
```
RewriteEngine on
RewriteCond %{REQUEST_URI} !location/index.html [NC]
RewriteRule ^locati... |
259,389 | <p>On a Linux box, the common interface names look like eth0, eth1, etc. I know how to find at least one IP address using <code>gethostbyname</code> or similar functions, but I don't know any way to specify which named interface I want the IP address of. I could use ifconfig and parse the output, but shelling out for t... | [
{
"answer_id": 259422,
"author": "Paweł Hajdan",
"author_id": 9403,
"author_profile": "https://Stackoverflow.com/users/9403",
"pm_score": 2,
"selected": false,
"text": "<p><strong>edit:</strong> I saw you don't like shelling. Then you can look at how ifconfig does its job (it extracts at... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26286/"
] | On a Linux box, the common interface names look like eth0, eth1, etc. I know how to find at least one IP address using `gethostbyname` or similar functions, but I don't know any way to specify which named interface I want the IP address of. I could use ifconfig and parse the output, but shelling out for this informatio... | ```c
// Originally from http://www.tlug.org.za/wiki/index.php/Obtaining_your_own_IP_address
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
/**
* getIPv4()
*
* This fu... |
259,415 | <p>When I changed the rankdir of my graph from LR to TD, my record nodes also changed their layout direction so they no longer look like a 'record'. I tried applying a separate rankdir to the nodes, but this had no effect.</p>
<p>How does one keep the record nodes with the correct layout?</p>
<pre><code>digraph sampl... | [
{
"answer_id": 259535,
"author": "ADEpt",
"author_id": 10105,
"author_profile": "https://Stackoverflow.com/users/10105",
"pm_score": 5,
"selected": true,
"text": "<p>Taking into account that rankdir effectively replaces the notion of \"top\" and \"bottom\" for the given graph, that's not... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32973/"
] | When I changed the rankdir of my graph from LR to TD, my record nodes also changed their layout direction so they no longer look like a 'record'. I tried applying a separate rankdir to the nodes, but this had no effect.
How does one keep the record nodes with the correct layout?
```
digraph sample {
graph [rankdir... | Taking into account that rankdir effectively replaces the notion of "top" and "bottom" for the given graph, that's not surprising.
I am afraid that there is no easy remedy for this, save hacking the source (and that would not be easy at all). You can surround your labels in "{}" with some kind of mass search-replace ... |
259,435 | <p>I'm trying to create a jqgrid, but the table is empty. The table renders, but the data doesn't show.</p>
<p>The data I'm getting back from the php call is:</p>
<pre><code>{
"page":"1",
"total":1,
"records":"10",
"rows":[
{"id":"2:1","cell":["1","image","Chief Scout","Highest Award test","0"]},
{"id":"2:2","cell":... | [
{
"answer_id": 260059,
"author": "jgreep",
"author_id": 16345,
"author_profile": "https://Stackoverflow.com/users/16345",
"pm_score": 5,
"selected": true,
"text": "<p>I got it to work!</p>\n\n<p>The <strong>dataType</strong> field should be <strong>datatype</strong>. It's case sensitive... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16345/"
] | I'm trying to create a jqgrid, but the table is empty. The table renders, but the data doesn't show.
The data I'm getting back from the php call is:
```
{
"page":"1",
"total":1,
"records":"10",
"rows":[
{"id":"2:1","cell":["1","image","Chief Scout","Highest Award test","0"]},
{"id":"2:2","cell":["2","image","Link Bad... | I got it to work!
The **dataType** field should be **datatype**. It's case sensitive. |
259,451 | <p>I want to record sound (voice) using PortAudio (PyAudio) and output the corresponding sound wave on the screen. Hopeless as I am, I am unable to extract the frequency information from the audio stream so that I can draw it in Hz/time form.</p>
<hr>
<p>Here's an example code snippet that records and plays recorded ... | [
{
"answer_id": 259521,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 3,
"selected": true,
"text": "<p>What you want is probably the Fourier transform of the audio data. There is several packages that can calculate ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to record sound (voice) using PortAudio (PyAudio) and output the corresponding sound wave on the screen. Hopeless as I am, I am unable to extract the frequency information from the audio stream so that I can draw it in Hz/time form.
---
Here's an example code snippet that records and plays recorded audio for f... | What you want is probably the Fourier transform of the audio data. There is several packages that can calculate that for you. `scipy` and `numpy` is two of them. It is often named "Fast Fourier Transform" (FFT), but that is just the name of the algorithm.
Here is an example of it's usage: <https://svn.enthought.com/en... |
259,455 | <p>In the following code, both the INPUT and TEXTAREA elements render wider than they should. How can I limit them to 100% of the usable area within the div?</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="h... | [
{
"answer_id": 259479,
"author": "Jaime Garcia",
"author_id": 32812,
"author_profile": "https://Stackoverflow.com/users/32812",
"pm_score": 0,
"selected": false,
"text": "<p>You could try using this DOCTYPE instead</p>\n\n<pre><code><!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] | In the following code, both the INPUT and TEXTAREA elements render wider than they should. How can I limit them to 100% of the usable area within the div?
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xh... | Inputs and textareas both have borders by default
```
<style>
.mywidth{
width:100%;
border:0;
}
</style>
```
will render all the elements within your container.
**Update**
IE also has left and right padding on each element and the following css fits all the elements within the container in FF3, ... |
259,456 | <p>I am working on implementing Zend Framework within an existing project that has a public marketing area, a private members area, an administration site, and a marketing campaign management site. Currently these are poorly organized with the controller scripts for the marketing area and the members area all being und... | [
{
"answer_id": 259489,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "<p>What I do is keep common classes in a \"library\" directory outside of the modules hierarchy. Then set my <code>INC... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20178/"
] | I am working on implementing Zend Framework within an existing project that has a public marketing area, a private members area, an administration site, and a marketing campaign management site. Currently these are poorly organized with the controller scripts for the marketing area and the members area all being under ... | What I do is keep common classes in a "library" directory outside of the modules hierarchy. Then set my `INCLUDE_PATH` to use the "models" directory of the respective module, plus the common "library" directory.
```
docroot/
index.php
application/
library/ <-- common classes go here
default/
con... |
259,457 | <p>If I've got an array of values that are basically zerofilled string representations of various numbers and another array of integers, will <code>array_intersect()</code> still match elements of different types?</p>
<p>For example, would this work:</p>
<pre><code>$arrayOne = array('0003', '0004', '0005');
$arrayTwo... | [
{
"answer_id": 259467,
"author": "Zak",
"author_id": 2112692,
"author_profile": "https://Stackoverflow.com/users/2112692",
"pm_score": 3,
"selected": true,
"text": "<p>$ cat > test.php</p>\n\n<pre><code><?php\n$arrayOne = array('0003', '0004', '0005');\n$arrayTwo = array(4, 5, 6);\n\n... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | If I've got an array of values that are basically zerofilled string representations of various numbers and another array of integers, will `array_intersect()` still match elements of different types?
For example, would this work:
```
$arrayOne = array('0003', '0004', '0005');
$arrayTwo = array(4, 5, 6);
$intersect =... | $ cat > test.php
```
<?php
$arrayOne = array('0003', '0004', '0005');
$arrayTwo = array(4, 5, 6);
$intersect = array_intersect($arrayOne, $arrayTwo);
print_r($intersect );
?>
```
$ php test.php
Array
(
)
$
So no, it will not. But if you add
```
foreach($arrayOne as $key => $value)
{
$arrayOne[$key] = int... |
259,480 | <p>I'm just interested in people's opinions. When using nullable types in C# what is the best practice way to test for null:</p>
<pre><code>bool isNull = (i == null);
</code></pre>
<p>or</p>
<pre><code>bool isNull = !i.HasValue;
</code></pre>
<p>Also when assigning to a non-null type is this:</p>
<pre><code>long? ... | [
{
"answer_id": 259490,
"author": "philsquared",
"author_id": 32136,
"author_profile": "https://Stackoverflow.com/users/32136",
"pm_score": 3,
"selected": false,
"text": "<p>I would always use the (i==null) form. It expresses what you are doing.</p>\n\n<p>WRT the second question, I think ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20553/"
] | I'm just interested in people's opinions. When using nullable types in C# what is the best practice way to test for null:
```
bool isNull = (i == null);
```
or
```
bool isNull = !i.HasValue;
```
Also when assigning to a non-null type is this:
```
long? i = 1;
long j = (long)i;
```
better than:
```
long? i = 1... | Use the forms that were specially implemented for you by the C# team. If anyone objects, tell them Anders said it was okay.
What I'm saying, flippantly, is that a lot of work went into integrating nullable types into c# to give you a good programming experience.
Note that in terms of performance, both forms compile d... |
259,486 | <p>SQL Server 2005.</p>
<p>I'm adding Foreign Key constraints to the database of an application that allegedly didn't need them. Naturally, the data has become unreliable and there are orphaned entries in the foreign key field.</p>
<p>Setup:<br/>
Two tables, TableUser and TableOrder.
TableUser has Primary Key 'UserI... | [
{
"answer_id": 259498,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": true,
"text": "<p>Here's one way:</p>\n\n<pre><code>select * from TableOrder where UserID not in (select UserID from TableUser);\n</code>... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26508/"
] | SQL Server 2005.
I'm adding Foreign Key constraints to the database of an application that allegedly didn't need them. Naturally, the data has become unreliable and there are orphaned entries in the foreign key field.
Setup:
Two tables, TableUser and TableOrder.
TableUser has Primary Key 'UserID', and TableOrder h... | Here's one way:
```
select * from TableOrder where UserID not in (select UserID from TableUser);
```
There are many different ways to write this sort of query. |
259,524 | <p>I have started using Linq to SQL in a (bit DDD like) system which looks (overly simplified) like this:</p>
<pre><code>public class SomeEntity // Imagine this is a fully mapped linq2sql class.
{
public Guid SomeEntityId { get; set; }
public AnotherEntity Relation { get; set; }
}
public class AnotherEntity /... | [
{
"answer_id": 259570,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>Specifying DataLoadOptions to fetch related elements. As I want my Business Logic Layer to just reply with... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11963/"
] | I have started using Linq to SQL in a (bit DDD like) system which looks (overly simplified) like this:
```
public class SomeEntity // Imagine this is a fully mapped linq2sql class.
{
public Guid SomeEntityId { get; set; }
public AnotherEntity Relation { get; set; }
}
public class AnotherEntity // Imagine this... | Rick Strahl has a nice article about DataContext lifecycle management here: <http://www.west-wind.com/weblog/posts/246222.aspx>.
Basically, the atomic action approach is nice in theory but you're going to need to keep your DataContext around to be able to track changes (and fetch children) in your data objects.
See a... |
259,532 | <p>I'm getting something pretty strange going on when trying to read some data using the MySql .net connector. Here's the code:</p>
<pre><code>IDataReader reader = null;
using (MySqlConnection connection = new MySqlConnection(this.ConnectionString))
{
String getSearch = "select * from organization";
MySqlComm... | [
{
"answer_id": 259548,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>Since a datareader reads in information, your using block closes the connection to the reader just after assign... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33721/"
] | I'm getting something pretty strange going on when trying to read some data using the MySql .net connector. Here's the code:
```
IDataReader reader = null;
using (MySqlConnection connection = new MySqlConnection(this.ConnectionString))
{
String getSearch = "select * from organization";
MySqlCommand cmd = new ... | from what I understand the SqlDataReader is intended to be used for a one-time enumeration of the data you've returned. Once you've cycled through the results once, the object has done its duty. Here are a couple ideas for working around this, one or the other of which may solve this for you depending on your needs:
1... |
259,534 | <p>Thanks for going to answer my question. I have the folowing pages.</p>
<ul>
<li>login.aspx</li>
<li>default.aspx</li>
<li>xxx.aspx</li>
</ul>
<p>After logging into application default.aspx will be displayed. Now if the user is trying to open <a href="http://server/" rel="nofollow noreferrer">http://server/</a><str... | [
{
"answer_id": 259541,
"author": "Markus Nigbur",
"author_id": 33231,
"author_profile": "https://Stackoverflow.com/users/33231",
"pm_score": 0,
"selected": false,
"text": "<pre><code>Response.Redirect(Request.UrlReferrer.ToString());\n</code></pre>\n"
},
{
"answer_id": 259579,
... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33722/"
] | Thanks for going to answer my question. I have the folowing pages.
* login.aspx
* default.aspx
* xxx.aspx
After logging into application default.aspx will be displayed. Now if the user is trying to open <http://server/>**xxx.aspx**?Id=1234 by specifying its URL directly in a browser, the login screen is displayed and... | Are you using Forms Authentication or doing this directly in the application? If you do something like this in your web.config it will handle all the redirecting for you.
```
<authentication mode="Forms">
<forms name="FwLoginCookie" loginUrl="Login.aspx"
protection="All"
path="/" >
... |
259,536 | <p>Does anyone has a good solution for a C# version of the C++ __FUNCTION__ macro? The compiler does not seem to like it.</p>
| [
{
"answer_id": 259544,
"author": "Eoin Campbell",
"author_id": 30155,
"author_profile": "https://Stackoverflow.com/users/30155",
"pm_score": 6,
"selected": true,
"text": "<p>Try using this instead. </p>\n\n<pre><code>System.Reflection.MethodBase.GetCurrentMethod().Name\n</code></pre>\n\n... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21704/"
] | Does anyone has a good solution for a C# version of the C++ \_\_FUNCTION\_\_ macro? The compiler does not seem to like it. | Try using this instead.
```
System.Reflection.MethodBase.GetCurrentMethod().Name
```
C# doesn't have `__LINE__` or `__FUNCTION__` macros like C++ but there are equivalents |
259,540 | <p>It seems that the following piece of HTML is ignored in IE7 but works ok in IE6/FF. It supposes to override all the html links to be opened in the desired frame</p>
<pre><code><HEAD>
<title>LeftPane</title>
<base target="rightFrame">
</HEAD>
</code></pre>
<p>The above code i... | [
{
"answer_id": 259549,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>href=\"\"</code> attibute is <a href=\"http://www.w3schools.com/TAGS/tag_base.asp\" rel=\"nofollow noreferrer\">... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14440/"
] | It seems that the following piece of HTML is ignored in IE7 but works ok in IE6/FF. It supposes to override all the html links to be opened in the desired frame
```
<HEAD>
<title>LeftPane</title>
<base target="rightFrame">
</HEAD>
```
The above code is the header of a left frame that holds an Infragistics ... | i dont know what was the issue because i test the base target in pure HTML and it works, wondering if ASP.net has to do something with it. but here is a piece of javascript code that add the target attribute to all link elements that doesnt have one
```
<script language="javascript">
var tags=document.getElements... |
259,542 | <p>I have installed Phusion Passenger 2.0.3 on Apache 2.2.3 on Centos 2.6.18-92.el5 #1 SMP and I am getting the following on the httpd error log</p>
<pre><code>Cannot initialize Passenger in an Apache child process: Could not connect to the ApplicationPool server: Broken pipe (32)
</code></pre>
<p>I have removed the ... | [
{
"answer_id": 2942793,
"author": "Spasm",
"author_id": 180935,
"author_profile": "https://Stackoverflow.com/users/180935",
"pm_score": 1,
"selected": false,
"text": "<p>Please take a look at the following tutorial for setting up Passenger correctly:\n<a href=\"http://www.modrails.com/do... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have installed Phusion Passenger 2.0.3 on Apache 2.2.3 on Centos 2.6.18-92.el5 #1 SMP and I am getting the following on the httpd error log
```
Cannot initialize Passenger in an Apache child process: Could not connect to the ApplicationPool server: Broken pipe (32)
```
I have removed the modules that Passenger con... | Please take a look at the following tutorial for setting up Passenger correctly:
[Deploying to a virtual host](http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_to_a_virtual_host_8217_s_root)
I had the same issue with Enterprise Ruby and Passenger |
259,547 | <p>If I have a table like this:</p>
<pre><code>CREATE TABLE sizes (
name ENUM('small', 'medium', 'large')
);
</code></pre>
<p>Is MySQL going to store those strings in every row, or internally will it use something smaller like integers to know which enum value to refer to?</p>
<p>I want to use an enum in a table... | [
{
"answer_id": 259561,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 6,
"selected": true,
"text": "<p>It converts them to integers on INSERT / UPDATE and back to strings on SELECT so the internal storage is as integers but yo... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13009/"
] | If I have a table like this:
```
CREATE TABLE sizes (
name ENUM('small', 'medium', 'large')
);
```
Is MySQL going to store those strings in every row, or internally will it use something smaller like integers to know which enum value to refer to?
I want to use an enum in a table but I'm worried if it's as waste... | It converts them to integers on INSERT / UPDATE and back to strings on SELECT so the internal storage is as integers but you don't get exposed to that.
You can retrieve the integer like `SELECT mycolumn + 0`.
See [ENUMs in MySQL 5](http://dev.mysql.com/doc/refman/5.0/en/enum.html) |
259,562 | <p>I'm an old hand at embedded programming but new to CE and having a lot of trouble doing reasonably simple things, because I am not familiar with the API and struggling to understand the obscure MSDN docs.</p>
<p>All I want to do is minimize and maximise two separate applications that are running from one of the app... | [
{
"answer_id": 259582,
"author": "Craig Nicholson",
"author_id": 28305,
"author_profile": "https://Stackoverflow.com/users/28305",
"pm_score": 1,
"selected": false,
"text": "<p>Firstly you will need to locate the window handle (hwnd) using the <a href=\"http://msdn.microsoft.com/en-us/li... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33720/"
] | I'm an old hand at embedded programming but new to CE and having a lot of trouble doing reasonably simple things, because I am not familiar with the API and struggling to understand the obscure MSDN docs.
All I want to do is minimize and maximise two separate applications that are running from one of the applications.... | Firstly you will need to locate the window handle (hwnd) using the [FindWindow](http://msdn.microsoft.com/en-us/library/aa453070.aspx) API function or some alternate means. Next use the [ShowWindow](http://msdn.microsoft.com/en-us/library/aa453731.aspx) API function specifying either **SW\_HIDE** or **SW\_SHOW** to hid... |
259,575 | <p>I am writing a java program that needs a file open dialog. The file open dialog isn't difficult, I'm hoping to use a <code>JFileChooser</code>. My problem is that I would like to have a dual pane <code>JFrame</code> (consisting of 2 <code>JPanels</code>). The left panel would have a <code>JList</code>, and the ri... | [
{
"answer_id": 259583,
"author": "Steve Kuo",
"author_id": 24396,
"author_profile": "https://Stackoverflow.com/users/24396",
"pm_score": 5,
"selected": true,
"text": "<p>JFileChooser extends JComponent and Component so you should be able to add it directly to your frame.</p>\n\n<pre><cod... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33725/"
] | I am writing a java program that needs a file open dialog. The file open dialog isn't difficult, I'm hoping to use a `JFileChooser`. My problem is that I would like to have a dual pane `JFrame` (consisting of 2 `JPanels`). The left panel would have a `JList`, and the right panel would have a file open dialog.
When I ... | JFileChooser extends JComponent and Component so you should be able to add it directly to your frame.
```
JFileChooser fc = ...
JPanel panel ...
panel.add(fc);
``` |
259,587 | <p>We have 3 applications using 3 different spring configuration files. But we have one database and one datasource, so one session factory.Hhow can we import the session factory bean into the 3 different spring config files?</p>
| [
{
"answer_id": 259599,
"author": "Paul Croarkin",
"author_id": 18995,
"author_profile": "https://Stackoverflow.com/users/18995",
"pm_score": 2,
"selected": false,
"text": "<p>If you are using XML configuration:</p>\n\n<p>Put your database settings in a Spring configuration called \"datab... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We have 3 applications using 3 different spring configuration files. But we have one database and one datasource, so one session factory.Hhow can we import the session factory bean into the 3 different spring config files? | If you are using XML configuration:
Put your database settings in a Spring configuration called "database-config.xml" and import it in the other configuration files.
```
<import resource="database-config.xml"/>
```
As to how you share it among three applications is more of a Configuration Management issue. You coul... |
259,589 | <p>I am developing a page view counter to track the amount of views a page is having on our site and displaying it to the user. (I asked an intro question before: <a href="https://stackoverflow.com/questions/246919/page-view-counter-like-on-stackoverflow">Page View Counter like on StackOverFlow</a>).</p>
<p>Using the ... | [
{
"answer_id": 259619,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>I would go with the logging method referenced in the other page, unless you need to track specific time/date of... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32372/"
] | I am developing a page view counter to track the amount of views a page is having on our site and displaying it to the user. (I asked an intro question before: [Page View Counter like on StackOverFlow](https://stackoverflow.com/questions/246919/page-view-counter-like-on-stackoverflow)).
Using the recommendations, I de... | interesting questions! Like a lot of other performance-tuning questions, there are some tradeoffs.
1. Possibly. It may be a better idea to load this handler inside an IMG href="", setting the sizes to 0 so it is invisible to the user.
2. With heavy load this would be preferable, that way your handler can return immedi... |
259,600 | <p>I've read quite a bit of the Red Bean Software SVN Book, and some of the questions here on SO, but I want to make sure I'm going about this in the right way the first time around step-by-step before I begin using it. Is this correct?</p>
<ol>
<li>Install SVN.</li>
<li><p>Create SVN repository at /usr/local/svn. Dir... | [
{
"answer_id": 259628,
"author": "Davide Gualano",
"author_id": 28582,
"author_profile": "https://Stackoverflow.com/users/28582",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>Create folders through command line for repository organization (including projects and vendors).... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've read quite a bit of the Red Bean Software SVN Book, and some of the questions here on SO, but I want to make sure I'm going about this in the right way the first time around step-by-step before I begin using it. Is this correct?
1. Install SVN.
2. Create SVN repository at /usr/local/svn. Directory structure looks... | >
> Create folders through command line for repository organization (including projects and vendors).
>
>
>
Do you mean creating the repository structure by making directories inside the subversion intallation directory? That's very wrong.
You have to create the necessary folders via the `svn mkdir` command and n... |
259,634 | <p>ok so basically I am asking the question of their name
I want this to be one input rather than Forename and Surname.</p>
<p>Now is there any way of splitting this name? and taking just the last word from the "Sentence" e.g.</p>
<pre><code>name = "Thomas Winter"
print name.split()
</code></pre>
<p>and what would ... | [
{
"answer_id": 259638,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 2,
"selected": false,
"text": "<p>Like this:</p>\n\n<pre><code>print name.split()[-1]\n</code></pre>\n"
},
{
"answer_id": 259639,
"author": "... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ok so basically I am asking the question of their name
I want this to be one input rather than Forename and Surname.
Now is there any way of splitting this name? and taking just the last word from the "Sentence" e.g.
```
name = "Thomas Winter"
print name.split()
```
and what would be output is just "Winter" | You'll find that your key problem with this approach isn't a technical one, but a human one - different people write their names in different ways.
In fact, the terminology of "forename" and "surname" is itself flawed.
While many blended families use a hyphenated family name, such as Smith-Jones, there are some who j... |
259,656 | <p>I'm running through an XML document, selecting all the elements, and creating links based on the ancestor which is usually two nodes up in the tree, but occasionally 3 or 4 nodes up. For the majority of the elements, using <code><xsl:value-of select="translate(../../@name,$uc,$lc)" /></code> works just fin... | [
{
"answer_id": 259664,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 3,
"selected": true,
"text": "<p>Your problem is probably namespace related. You haven't included those in the sample tree - can you be a bit more... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26257/"
] | I'm running through an XML document, selecting all the elements, and creating links based on the ancestor which is usually two nodes up in the tree, but occasionally 3 or 4 nodes up. For the majority of the elements, using `<xsl:value-of select="translate(../../@name,$uc,$lc)" />` works just fine, but for the cases whe... | Your problem is probably namespace related. You haven't included those in the sample tree - can you be a bit more precise in what you've pasted? Assuming the package node is in the same namespace as the token node, try:
```
<xsl:value-of select="translate(ancestor::s4:package/@name,$uc,$lc)" />
```
You can also test... |
259,709 | <p>I the following styles:</p>
<pre><code>a.button {
background-color: orange;
margin: .2cm;
padding: .2cm;
color: black;
font-family: sans-serif;
text-decoration: none;
font-weight: bold;
border: solid #000000;
}
a.buttonMouseover {
background-color: darkGoldenRod;
margin: .2c... | [
{
"answer_id": 259712,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 4,
"selected": true,
"text": "<p>Depending on your target browsers, you could use the <code>hover</code> pseudo tag.</p>\n\n<pre><code>a.button {\n back... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2598/"
] | I the following styles:
```
a.button {
background-color: orange;
margin: .2cm;
padding: .2cm;
color: black;
font-family: sans-serif;
text-decoration: none;
font-weight: bold;
border: solid #000000;
}
a.buttonMouseover {
background-color: darkGoldenRod;
margin: .2cm;
padding... | Depending on your target browsers, you could use the `hover` pseudo tag.
```
a.button {
background-color: orange;
margin: .2cm;
padding: .2cm;
color: black;
font-family: sans-serif;
text-decoration: none;
font-weight: bold;
border: solid #000000;
}
a.button:hover {
background-color... |
259,719 | <p>I'm building an XML document with PHP's SimpleXML extension, and I'm adding a token to the file:</p>
<pre><code>$doc->addChild('myToken');
</code></pre>
<p>This generates (what I know as) a self-closing or single tag:</p>
<pre><code><myToken/>
</code></pre>
<p>However, the aging web-service I'm communic... | [
{
"answer_id": 259754,
"author": "Piskvor left the building",
"author_id": 19746,
"author_profile": "https://Stackoverflow.com/users/19746",
"pm_score": 3,
"selected": true,
"text": "<p>From the documentation at <a href=\"http://www.php.net/manual/en/function.simplexml-element-construct.... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33739/"
] | I'm building an XML document with PHP's SimpleXML extension, and I'm adding a token to the file:
```
$doc->addChild('myToken');
```
This generates (what I know as) a self-closing or single tag:
```
<myToken/>
```
However, the aging web-service I'm communicating with is tripping all over self-closing tags, so I ne... | From the documentation at [SimpleXMLElement->\_\_construct](http://www.php.net/manual/en/function.simplexml-element-construct.php) and [LibXML Predefined Constants](http://cz2.php.net/manual/en/libxml.constants.php), I think this should work:
```
<?php
$sxe = new SimpleXMLElement($someData, LIBXML_NOEMPTYTAG);
// som... |
259,726 | <p>I am using XmlSerializer to write and read an object to xml in C#. I currently use the attributes <code>XmlElement</code> and <code>XmlIgnore</code> to manipulate the serialization of the object.</p>
<p>If my xml file is missing an xml element that I require, my object still deserializes (xml -> object) just fine.... | [
{
"answer_id": 259732,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>I've got an answer for the second part: <a href=\"http://msdn.microsoft.com/en-us/library/83y7df3e(VS.71).aspx\" rel=\... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180/"
] | I am using XmlSerializer to write and read an object to xml in C#. I currently use the attributes `XmlElement` and `XmlIgnore` to manipulate the serialization of the object.
If my xml file is missing an xml element that I require, my object still deserializes (xml -> object) just fine. How do I indicate (preferably vi... | I've got an answer for the second part: ["Attributes that control XML serialization"](http://msdn.microsoft.com/en-us/library/83y7df3e(VS.71).aspx).
Still investigating the first part...
EDIT: I strongly suspect you can't do this through XML deserialization itself. I've just run xsd.exe on a sample schema which inclu... |
259,730 | <p>I have two vb.net class:</p>
<pre><code>Public MustInherit Class Class1
Private m_sProperty1 As String = ""
Public Property sProperty1() As String
Get
Return m_sProperty1
End Get
Set(ByVal value As String)
m_sProperty1 = value
End Set
End Property
... | [
{
"answer_id": 546498,
"author": "Toby Allen",
"author_id": 6244,
"author_profile": "https://Stackoverflow.com/users/6244",
"pm_score": 0,
"selected": false,
"text": "<p>I'll take a guess as I'm not up to speed on .NET</p>\n\n<p>I would imagine your declaration is taking your public meth... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have two vb.net class:
```
Public MustInherit Class Class1
Private m_sProperty1 As String = ""
Public Property sProperty1() As String
Get
Return m_sProperty1
End Get
Set(ByVal value As String)
m_sProperty1 = value
End Set
End Property
End Class
<Co... | This seems to answer your question:
**Exporting Inheritance Hierarchies**
Managed class hierarchies flatten out when exposed as COM objects. For example, if you define a base class with a member, and then inherit the base class in a derived class that is exposed as a COM object, clients that use the derived class in ... |
259,751 | <p>Need a function like: </p>
<pre><code>function isGoogleURL(url) { ... }
</code></pre>
<p>that returns true iff URL belongs to Google. No false positives; no false negatives.</p>
<p>Luckily there's <a href="http://www.google.com/supported_domains" rel="nofollow noreferrer">this</a> as a reference:</p>
<blockquote... | [
{
"answer_id": 259768,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>Do you count other Google properties as \"belonging to Google\"? FeedBurner, Blogger etc?</p>\n\n<p>Can I ask what th... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11208/"
] | Need a function like:
```
function isGoogleURL(url) { ... }
```
that returns true iff URL belongs to Google. No false positives; no false negatives.
Luckily there's [this](http://www.google.com/supported_domains) as a reference:
>
> .google.com .google.ad .google.ae .google.com.af .google.com.ag .google.com.ai .... | Here is an updated version of Prestaul's answer which solves the two problems I mentioned in the comment there.
```
var GOOGLE_DOMAINS = ([
'.google.com',
'.google.ad',
'.google.ae',
'.google.com.af',
'.google.com.ag',
'.google.com.ai',
'.google.am',
'.google.it.ao',
'.google.com.ar... |
259,753 | <p>I can't get the inner div (with Hello World) to fit inside the "box" div in this code example (also at <a href="http://www.toad-software.com/test.html" rel="nofollow noreferrer">http://www.toad-software.com/test.html</a>).</p>
<p>Despite the body being set to 100%, the inner div will not be contained! This is a tes... | [
{
"answer_id": 259761,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 4,
"selected": false,
"text": "<p>add <code>overflow:hidden;</code> to the container <code><div></code></p>\n"
},
{
"answer_id": 260792,
... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335036/"
] | I can't get the inner div (with Hello World) to fit inside the "box" div in this code example (also at <http://www.toad-software.com/test.html>).
Despite the body being set to 100%, the inner div will not be contained! This is a test case for a larger project in which a variable-width table exceeds the boundaries of i... | The 100% width on the body element is in relation to the view port, which is why you're background color is cutting when you scroll. Either set a width to your body at 1520px to encompase the contained div or add another div and do the following:
```
div.box { width: 100px; overflow: auto; }
```
However, as a word o... |
259,759 | <p>I am using JQuery to post with AJAX to another ASP page. Do I need this ASP page to return a full html page. Or can I just have it send back a value ( I just need a status ) . Here is my function.</p>
<pre><code> $.ajax({
url: "X.asp",
cache: false,
type: "POST",
data: queryString,
... | [
{
"answer_id": 259790,
"author": "Berzemus",
"author_id": 2452,
"author_profile": "https://Stackoverflow.com/users/2452",
"pm_score": 5,
"selected": true,
"text": "<p>If it's just a simple value you need, I'd simple use Json (JQuery has a dedicated method for that : <a href=\"http://docs... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] | I am using JQuery to post with AJAX to another ASP page. Do I need this ASP page to return a full html page. Or can I just have it send back a value ( I just need a status ) . Here is my function.
```
$.ajax({
url: "X.asp",
cache: false,
type: "POST",
data: queryString,
success: fun... | If it's just a simple value you need, I'd simple use Json (JQuery has a dedicated method for that : [$.getJSON()](http://docs.jquery.com/Ajax/jQuery.getJSON)).
So no, you don't need your ASP page to return a full html page, just the value in simple JSON notation. |
259,763 | <p>Ok, so I'm binding a DataGridView to a BindingSource in a background thread while a little, "Please Wait" model window keeps the user entertained. No problem. </p>
<p>However, I need to change some of the rows background colors based on the row's databounditem type. Like this:</p>
<pre><code>for (int i = 0; i <... | [
{
"answer_id": 259790,
"author": "Berzemus",
"author_id": 2452,
"author_profile": "https://Stackoverflow.com/users/2452",
"pm_score": 5,
"selected": true,
"text": "<p>If it's just a simple value you need, I'd simple use Json (JQuery has a dedicated method for that : <a href=\"http://docs... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12862/"
] | Ok, so I'm binding a DataGridView to a BindingSource in a background thread while a little, "Please Wait" model window keeps the user entertained. No problem.
However, I need to change some of the rows background colors based on the row's databounditem type. Like this:
```
for (int i = 0; i < dgItemMaster.Rows.Count... | If it's just a simple value you need, I'd simple use Json (JQuery has a dedicated method for that : [$.getJSON()](http://docs.jquery.com/Ajax/jQuery.getJSON)).
So no, you don't need your ASP page to return a full html page, just the value in simple JSON notation. |
259,784 | <p>Compiling a program on Linux that calls POSIX timer functions (eg: timer_create, timer_settime) returns errors such as:</p>
<pre>
In function `foo':
timer.c:(.text+0xbb): undefined reference to `timer_create'
timer.c:(.text+0x187): undefined reference to `timer_settime'
collect2: ld returned 1 exit status
</pre>
<... | [
{
"answer_id": 259789,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>This should be documented in the man page. Given it isn't add <code>-lrt</code>.</p>\n"
},
{
"answer_id": 552654,
... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Compiling a program on Linux that calls POSIX timer functions (eg: timer\_create, timer\_settime) returns errors such as:
```
In function `foo':
timer.c:(.text+0xbb): undefined reference to `timer_create'
timer.c:(.text+0x187): undefined reference to `timer_settime'
collect2: ld returned 1 exit status
```
Which lib... | Compile it with `-lrt` option. It will get compiled. |
259,798 | <p>I've got a (SQL Server 2005) database where I'd like to create views on-the-fly. In my code, I'm building a CREATE VIEW statement, but the only way I can get it to work is by building the entire query string and running it bare. I'd like to use parameters, but this:</p>
<pre><code>SqlCommand cmd = new SqlCommand(... | [
{
"answer_id": 259808,
"author": "friol",
"author_id": 23034,
"author_profile": "https://Stackoverflow.com/users/23034",
"pm_score": 2,
"selected": true,
"text": "<p>Maybe I've not understood it correctly, but what prevents you to do:</p>\n\n<pre><code>viewname=\"foo\";\nviewwhere=\"* fr... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26286/"
] | I've got a (SQL Server 2005) database where I'd like to create views on-the-fly. In my code, I'm building a CREATE VIEW statement, but the only way I can get it to work is by building the entire query string and running it bare. I'd like to use parameters, but this:
```
SqlCommand cmd = new SqlCommand("CREATE VIEW @na... | Maybe I've not understood it correctly, but what prevents you to do:
```
viewname="foo";
viewwhere="* from bar";
SqlCommand cmd = new SqlCommand("CREATE VIEW "+viewname+" AS SELECT "+viewwhere);
``` |
259,803 | <p>Let's say I have a simple stored procedure that looks like this (note: this is just an example, not a practical procedure):</p>
<pre><code>CREATE PROCEDURE incrementCounter AS
DECLARE @current int
SET @current = (select CounterColumn from MyTable) + 1
UPDATE
MyTable
SET
CounterColumn = current
GO
</code><... | [
{
"answer_id": 259827,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 5,
"selected": true,
"text": "<p>This is for SQL Server.</p>\n\n<p>Each statement is atomic, but if you want the stored procedure to be atomic (or any seq... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30006/"
] | Let's say I have a simple stored procedure that looks like this (note: this is just an example, not a practical procedure):
```
CREATE PROCEDURE incrementCounter AS
DECLARE @current int
SET @current = (select CounterColumn from MyTable) + 1
UPDATE
MyTable
SET
CounterColumn = current
GO
```
We're assuming I... | This is for SQL Server.
Each statement is atomic, but if you want the stored procedure to be atomic (or any sequence of statements in general), you need to explicitly surround the statements with
BEGIN TRANSACTION
Statement ...
Statement ...
COMMIT TRANSACTION
(It's common to use BEGIN TRAN and END TRAN fo... |
259,819 | <p>I want to create a view that consists solely of a <code>UITextView</code>. When the view is first shown, by default, I'd like the keyboard to be visible and ready for text entry. This way, the user does not have to touch the <code>UITextView</code> first in order to begin editing.</p>
<p>Is this possible? I see the... | [
{
"answer_id": 259842,
"author": "Adam Alexander",
"author_id": 33164,
"author_profile": "https://Stackoverflow.com/users/33164",
"pm_score": 7,
"selected": true,
"text": "<p>to accomplish that just send the becomeFirstResponder message to your UITextField, as follows (assuming you have ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/543/"
] | I want to create a view that consists solely of a `UITextView`. When the view is first shown, by default, I'd like the keyboard to be visible and ready for text entry. This way, the user does not have to touch the `UITextView` first in order to begin editing.
Is this possible? I see the class has a notification called... | to accomplish that just send the becomeFirstResponder message to your UITextField, as follows (assuming you have an outlet called textField, pointing to the field in question):
```
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[textField becomeFirstResponder];
}
``` |
259,836 | <p>What is the best way to convert an array of bytes declared as TBytes to a unicode string in Delphi 2009? In my particular case, the TBytes array has UTF-16 encoded data already (2 bytes for each char).</p>
<p>Since TBytes doesn't store a null terminator, the following will only work if the array happens to have #0 ... | [
{
"answer_id": 259904,
"author": "Bruce McGee",
"author_id": 19183,
"author_profile": "https://Stackoverflow.com/users/19183",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"http://docwiki.embarcadero.com/Libraries/Rio/en/System.SysUtils.StringOf\" rel=\"nofollow noreferrer\">St... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7893/"
] | What is the best way to convert an array of bytes declared as TBytes to a unicode string in Delphi 2009? In my particular case, the TBytes array has UTF-16 encoded data already (2 bytes for each char).
Since TBytes doesn't store a null terminator, the following will only work if the array happens to have #0 in the mem... | I ended up using
```
TEncoding.Unicode.GetString( MyByteArray );
``` |
259,841 | <p>The company I work for writes a lot smallish Perl and Bash scripts to massage data into something usable for our software. These scripts, like any code, can change. I provided them CVS because of the file versioning rather than repository versioning. Anyway, I am thinking out a deploy tool to get the scripts from... | [
{
"answer_id": 259899,
"author": "Ilya",
"author_id": 6807,
"author_profile": "https://Stackoverflow.com/users/6807",
"pm_score": 2,
"selected": true,
"text": "<p>if you going to write some kind of distribution script it should be relatively simple </p>\n\n<p>1) The script should be comm... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28714/"
] | The company I work for writes a lot smallish Perl and Bash scripts to massage data into something usable for our software. These scripts, like any code, can change. I provided them CVS because of the file versioning rather than repository versioning. Anyway, I am thinking out a deploy tool to get the scripts from devel... | if you going to write some kind of distribution script it should be relatively simple
1) The script should be committed in your cvs repository
2) I advice to call the script from your makefile (or any build system you use)
something like this
```
make dist
```
and the dist rule will call your script.
3) scr... |
259,850 | <p>I am performing two validations on the client side on the samve event.
I have defined my validations as shown below</p>
<pre><code>btnSearch.Attributes["OnClick"] = "javascript:return prepareSave(); return prepareSearch();"
</code></pre>
<p>Pseudo code for </p>
<pre><code>prepareSave():
{
if (bPendingchanges)
... | [
{
"answer_id": 259869,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 1,
"selected": true,
"text": "<p>Your second <code>return</code> statement will never be reached. Execution stops after <code>javascript:return prepareSave(... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13370/"
] | I am performing two validations on the client side on the samve event.
I have defined my validations as shown below
```
btnSearch.Attributes["OnClick"] = "javascript:return prepareSave(); return prepareSearch();"
```
Pseudo code for
```
prepareSave():
{
if (bPendingchanges)
{
return confirm('Need to sav... | Your second `return` statement will never be reached. Execution stops after `javascript:return prepareSave()`.
Looks like you want to return true if both functions return true - therefore, do:
```
btnSearch.Attributes["OnClick"] = javascript: return prepareSave() && prepareSearch();
``` |
259,853 | <p>As Scott Myers wrote, you can take advantage of a relaxation in C++'s type-system to declare clone() to return a pointer to the actual type being declared:</p>
<pre><code>class Base
{
virtual Base* clone() const = 0;
};
class Derived : public Base
{
virtual Derived* clone() const
};
</code></pre>
<p>The c... | [
{
"answer_id": 259946,
"author": "coppro",
"author_id": 16855,
"author_profile": "https://Stackoverflow.com/users/16855",
"pm_score": 4,
"selected": true,
"text": "<p>It depends on your use case. If you ever think you will need to call <code>clone</code> on a derived object whose dynamic... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1674/"
] | As Scott Myers wrote, you can take advantage of a relaxation in C++'s type-system to declare clone() to return a pointer to the actual type being declared:
```
class Base
{
virtual Base* clone() const = 0;
};
class Derived : public Base
{
virtual Derived* clone() const
};
```
The compiler detects that clone... | It depends on your use case. If you ever think you will need to call `clone` on a derived object whose dynamic type you know (remember, the whole point of `clone` is to allow copying *without* knowing the dynamic type), then you should probably return a dumb pointer and load that into a smart pointer in the calling cod... |
259,883 | <p>I'd like to strip out occurrences of a specific tag, leaving the inner XML intact. I'd like to do this with one pass (rather than searching, replacing, and starting from scratch again). For instance, from the source:</p>
<pre><code><element>
<RemovalTarget Attribute="Something">
Content Here... | [
{
"answer_id": 259895,
"author": "Andrew Bullock",
"author_id": 28543,
"author_profile": "https://Stackoverflow.com/users/28543",
"pm_score": 2,
"selected": false,
"text": "<p>Have you considered using XSLT? Seems like the perfect soution, as you are doing exactly what XSLT is meant for,... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1807/"
] | I'd like to strip out occurrences of a specific tag, leaving the inner XML intact. I'd like to do this with one pass (rather than searching, replacing, and starting from scratch again). For instance, from the source:
```
<element>
<RemovalTarget Attribute="Something">
Content Here
</RemovalTarget>
</elem... | You'll have to skip the deferred execution with a call to ToList, which probably won't hurt your performance in large documents as you're just going to be iterating and replacing at a much lower big-O than the original search. As @jacob\_c pointed out, I should be using element.Nodes() to replace it properly, and as @P... |
259,884 | <p>I have a very standard <code>Gridview</code>, with Edit and Delete buttons auto-generated.
It is bound to a <code>tableadapter</code> which is linked to my <code>RelationshipTypes</code> table.</p>
<pre><code>dbo.RelationshipTypes:
ID, Name, OriginConfigTypeID, DestinationConfigTypeID
</code></pre>
<p>I wish to us... | [
{
"answer_id": 259895,
"author": "Andrew Bullock",
"author_id": 28543,
"author_profile": "https://Stackoverflow.com/users/28543",
"pm_score": 2,
"selected": false,
"text": "<p>Have you considered using XSLT? Seems like the perfect soution, as you are doing exactly what XSLT is meant for,... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13959/"
] | I have a very standard `Gridview`, with Edit and Delete buttons auto-generated.
It is bound to a `tableadapter` which is linked to my `RelationshipTypes` table.
```
dbo.RelationshipTypes:
ID, Name, OriginConfigTypeID, DestinationConfigTypeID
```
I wish to use a label that will pull the name from the `ConfigTypes` ta... | You'll have to skip the deferred execution with a call to ToList, which probably won't hurt your performance in large documents as you're just going to be iterating and replacing at a much lower big-O than the original search. As @jacob\_c pointed out, I should be using element.Nodes() to replace it properly, and as @P... |
259,886 | <p>I want to assign a resource I already have a second name, similar to using the BasedOn property of Styles. Specifically I have a brush that I use for a group of elements called ForegroundColor and I would like to use it in a control template (a ComboBox) calling it MouseOverBackgroundBrush. I would like to do someth... | [
{
"answer_id": 259976,
"author": "Amanda Mitchell",
"author_id": 26628,
"author_profile": "https://Stackoverflow.com/users/26628",
"pm_score": 3,
"selected": true,
"text": "<p>This is a feature that doesn't have very good support in XAML. I believe that you'll either need to repeat yours... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21186/"
] | I want to assign a resource I already have a second name, similar to using the BasedOn property of Styles. Specifically I have a brush that I use for a group of elements called ForegroundColor and I would like to use it in a control template (a ComboBox) calling it MouseOverBackgroundBrush. I would like to do something... | This is a feature that doesn't have very good support in XAML. I believe that you'll either need to repeat yourself (and change both locations anytime you need to change the brush) *or* if you don't mind a bit of code behind, you can accomplish the duplication like this:
```
Resources["MouseOverBackgroundBrush"] = Res... |
259,887 | <p>In writing the code that throws the exception I asked about <a href="https://stackoverflow.com/questions/259800/is-there-a-built-in-net-exception-that-indicates-an-illegal-object-state">here</a>, I came to the end of my message, and paused at the punctuation. I realized that nearly every exception message I've ever... | [
{
"answer_id": 259894,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 2,
"selected": false,
"text": "<p>Taking responsibility, even when it really was the user's fault, is the best option I've seen.</p>\n\n<p>Things along the ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96/"
] | In writing the code that throws the exception I asked about [here](https://stackoverflow.com/questions/259800/is-there-a-built-in-net-exception-that-indicates-an-illegal-object-state), I came to the end of my message, and paused at the punctuation. I realized that nearly every exception message I've ever thrown probabl... | A conversational tone in system messages makes the software look unprofessional and sloppy. Exclamation points, insults, and slang don't really have a place in polished exception messages.
Also, I tend to use different styles in Java for runtime exceptions and checked exceptions, since runtime exceptions are addressed... |
259,889 | <p>If I have a button like the one in this image :</p>
<p><strong><a href="http://www.freeimagehosting.net/image.php?4cd775814c.png" rel="nofollow noreferrer">http://www.freeimagehosting.net/image.php?4cd775814c.png</a></strong></p>
<p>how could I make the text display itself vertically ? As in </p>
<pre>
j
B
u
t
t
... | [
{
"answer_id": 259928,
"author": "asalamon74",
"author_id": 21348,
"author_profile": "https://Stackoverflow.com/users/21348",
"pm_score": 4,
"selected": true,
"text": "<p>You can use HTML for JButton or JLabel. So </p>\n\n<pre><code>button = new JButton(\"<html>J<br>b<br&g... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] | If I have a button like the one in this image :
**<http://www.freeimagehosting.net/image.php?4cd775814c.png>**
how could I make the text display itself vertically ? As in
```
j
B
u
t
t
o
n
1
```
I would like to know how to do the same thing for JLabel . I'm sure there has to be a better way than to create as man... | You can use HTML for JButton or JLabel. So
```
button = new JButton("<html>J<br>b<br>u<br>t<br>t<br>o<br>n<br>1</html>");
```
should do the trick. |
259,890 | <p>How do you draw the following dynamic <strong>3D</strong> array with OpenGL <strong>glDrawPixels()</strong>?
You can find the documentation here: <a href="http://opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/drawpixels.html" rel="nofollow noreferrer">http://opengl.org/documentation/specs/man_pages/har... | [
{
"answer_id": 261776,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 3,
"selected": true,
"text": "<p>Uh ... Since you're allocating <i>each single pixel</i> with a separate <code>malloc()</code>, you will have to draw each... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13937/"
] | How do you draw the following dynamic **3D** array with OpenGL **glDrawPixels()**?
You can find the documentation here: <http://opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/drawpixels.html>
```
float ***array3d;
void InitScreenArray()
{
int i, j;
int screenX = scene.camera.vres;
int scree... | Uh ... Since you're allocating *each single pixel* with a separate `malloc()`, you will have to draw each pixel with a separate call to `glDrawPixels()`, too. This is (obviously) insane; the idea of bitmapped graphics is that the pixels are stored in an adjacent, compact, format, so that it is quick and fast (*O(1)*) t... |
259,900 | <p>Check it out: this little .NET Console Program yields interesting results...notice how I'm converting a float to an integer in two different ways:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CastVsConvert
{
class Program
{
static vo... | [
{
"answer_id": 259905,
"author": "Dan Goldstein",
"author_id": 23427,
"author_profile": "https://Stackoverflow.com/users/23427",
"pm_score": 3,
"selected": false,
"text": "<p>The cast is chopping off the portion of the number after the decimal point while the conversion is rounding.</p>\... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33754/"
] | Check it out: this little .NET Console Program yields interesting results...notice how I'm converting a float to an integer in two different ways:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CastVsConvert
{
class Program
{
static void Main(string... | Its not a bug, `cast` truncates, `convert` rounds.
See [this](https://stackoverflow.com/questions/104063/systemconverttoint-vs-int) |
259,902 | <p>I have the following solution project structure:</p>
<blockquote>
<p>Application.Core.Entities</p>
<p>Application.Xtend.CustomerName.Entities</p>
</blockquote>
<p>In the Core project I have an entity <strong>Customer</strong> defiend. In the XTend project, I have an entity defined that subclasses Customer named <str... | [
{
"answer_id": 261820,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 2,
"selected": false,
"text": "<p>You need to map using the <code>extends</code> attribute of the <code><class></code> element (AFAIK, this is n... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303/"
] | I have the following solution project structure:
>
> Application.Core.Entities
>
>
> Application.Xtend.CustomerName.Entities
>
>
>
In the Core project I have an entity **Customer** defiend. In the XTend project, I have an entity defined that subclasses Customer named **xCustomer** (for lack of a better name at ... | I asked this same question on the NHibernate Users mailing list and the solution was so obvious that I am somewhat embarrassed that I couldn't see it.
The hibernate-mapping attributes assembly and namespace are convenient short cuts that allow you to not have to fully qualify your class names. This lets you have the ... |
259,929 | <p>In C#4.0 we're going to get dynamic types, or objects whose "static type is dynamic", according to Anders. This will allow any method invocation resolution to happen at runtime rather than compile time. But will there be facility to bind the dynamic object to some sort of contract (and thereby also get full intellis... | [
{
"answer_id": 259985,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not aware of anything really resembling duck typing, I'm afraid. I've <a href=\"http://msmvps.com/blogs/jon_skeet/... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32577/"
] | In C#4.0 we're going to get dynamic types, or objects whose "static type is dynamic", according to Anders. This will allow any method invocation resolution to happen at runtime rather than compile time. But will there be facility to bind the dynamic object to some sort of contract (and thereby also get full intellisens... | I'm not aware of anything really resembling duck typing, I'm afraid. I've [blogged about the idea](http://msmvps.com/blogs/jon_skeet/archive/2008/10/30/c-4-0-dynamic-lt-t-gt.aspx), but I don't expect any support. It probably wouldn't be too hard to use Reflection.Emit to make a class which will generate an implementati... |
259,941 | <p>Wondering if my approach is ok or could be improved:</p>
<pre><code>Public Class Company
private _id as Integer
private _name as String
private _location as String
Public Function LoadMultipleByLocation(Byval searchStr as String) as List(Of Company)
'sql etc here to build the list
End Function
End... | [
{
"answer_id": 259964,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 1,
"selected": false,
"text": "<p>In this case, you would create an instance of Company, and then use it to return a List of Companies?</p>\n\n<p>Some peop... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Wondering if my approach is ok or could be improved:
```
Public Class Company
private _id as Integer
private _name as String
private _location as String
Public Function LoadMultipleByLocation(Byval searchStr as String) as List(Of Company)
'sql etc here to build the list
End Function
End Classs
```
... | In this case, you would create an instance of Company, and then use it to return a List of Companies?
Some people do this, but I prefer to seperate my data object into a dumb data container:
```
public class Company : EntityBase
{
private int _id;
private string _name;
private string _location;
}
```
... |
259,956 | <p>What is the best way to tokenize/split a NSString in Objective-C?</p>
| [
{
"answer_id": 259966,
"author": "Adam Alexander",
"author_id": 33164,
"author_profile": "https://Stackoverflow.com/users/33164",
"pm_score": 9,
"selected": true,
"text": "<p>Found answer <a href=\"http://borkware.com/quickies/one?topic=NSString\" rel=\"nofollow noreferrer\">here</a>:</p... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What is the best way to tokenize/split a NSString in Objective-C? | Found answer [here](http://borkware.com/quickies/one?topic=NSString):
```
NSString *string = @"oop:ack:bork:greeble:ponies";
NSArray *chunks = [string componentsSeparatedByString: @":"];
``` |
259,968 | <p>Consider the following file</p>
<pre><code>var1 var2 variable3
1 2 3
11 22 33
</code></pre>
<p>I would like to load the numbers into a matrix, and the column titles into a variable that would be equivalent to:</p>
<pre><code>variable_names = char('var1', 'var2', 'variable3');
</code></pre>
<p>I don't... | [
{
"answer_id": 260016,
"author": "Robert Van Hoose",
"author_id": 460599,
"author_profile": "https://Stackoverflow.com/users/460599",
"pm_score": 1,
"selected": false,
"text": "<p>Just use textscan with different format specifiers.</p>\n\n<pre><code>fid = fopen(filename,'r');\nheading = ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/259968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17523/"
] | Consider the following file
```
var1 var2 variable3
1 2 3
11 22 33
```
I would like to load the numbers into a matrix, and the column titles into a variable that would be equivalent to:
```
variable_names = char('var1', 'var2', 'variable3');
```
I don't mind to split the names and the numbers in two f... | I suggest **importdata** for operations like this:
```
d = importdata('filename.txt');
```
The return is a struct with the numerical fields in a member called 'data', and the column headers in a field called 'colheaders'.
Another useful interface for importing manipulating data like these is the 'dataset' class ava... |
260,010 | <p>If I have a query to return all matching entries in a DB that have "news" in the searchable column (i.e. <code>SELECT * FROM table WHERE column LIKE %news%</code>), and one particular row has an entry starting with "In recent World news, Somalia was invaded by ...", can I return a specific "chunk" of an SQL entry? K... | [
{
"answer_id": 260023,
"author": "Rockcoder",
"author_id": 5290,
"author_profile": "https://Stackoverflow.com/users/5290",
"pm_score": 2,
"selected": false,
"text": "<p>You can use substring function in a SELECT part. Something like:</p>\n\n<pre><code>SELECT SUBSTRING(column, 1,20) FROM ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] | If I have a query to return all matching entries in a DB that have "news" in the searchable column (i.e. `SELECT * FROM table WHERE column LIKE %news%`), and one particular row has an entry starting with "In recent World news, Somalia was invaded by ...", can I return a specific "chunk" of an SQL entry? Kind of like a ... | ```
select substring(column,
CHARINDEX ('news',lower(column))-10,
20)
FROM table
WHERE column LIKE %news%
```
basically substring the column starting 10 characters before where the word 'news' is and continuing for 20.
Edit: You'll need to make sure that 'news' isn't in the first 1... |
260,040 | <p>I want to make a transparent dialog. I capture the OnCtlColor message in a CDialog derived class...this is the code:</p>
<pre><code>HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(bSetBkTransparent_)
{
pDC->SetBkMode(... | [
{
"answer_id": 269817,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "<p>You have two options.</p>\n\n<p>You can not use Common Controls v6 (the XP-Styled controls), which will make your app lose t... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14053/"
] | I want to make a transparent dialog. I capture the OnCtlColor message in a CDialog derived class...this is the code:
```
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(bSetBkTransparent_)
{
pDC->SetBkMode(TRANSPARENT);
... | You have two options.
You can not use Common Controls v6 (the XP-Styled controls), which will make your app lose the fanciness of newer windows versions. However IIRC the groupbox will respect the CTLCOLOR issue. If you are not using that anyway, and it is still not respecting your color, then you only have one option... |
260,056 | <p>I'm trying to figure out if there's a reasonably efficient way to perform a lookup in a dictionary (or a hash, or a map, or whatever your favorite language calls it) where the keys are regular expressions and strings are looked up against the set of keys. For example (in Python syntax):</p>
<pre><code>>>>... | [
{
"answer_id": 260075,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 0,
"selected": false,
"text": "<p>The fundamental assumption is flawed, I think. you can't map hashes to regular expressions. </p>\n"
},
{
"answer_id... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33775/"
] | I'm trying to figure out if there's a reasonably efficient way to perform a lookup in a dictionary (or a hash, or a map, or whatever your favorite language calls it) where the keys are regular expressions and strings are looked up against the set of keys. For example (in Python syntax):
```
>>> regex_dict = { re.compi... | What you want to do is very similar to what is supported by xrdb. They only support a fairly minimal notion of globbing however.
Internally you can implement a larger family of regular languages than theirs by storing your regular expressions as a character trie.
* single characters just become trie nodes.
* .'s bec... |
260,064 | <p>Published Date returned from Twitter Search API Atom Feed as 2008-11-03T21:30:06Z which needs to be converted to "X seconds/minutes/hours/days ago" for showing how long ago twitter messages were posted.</p>
<p>Think this can be done with php date() function using DATE_ATOM value?</p>
| [
{
"answer_id": 260092,
"author": "Dave Marshall",
"author_id": 1248,
"author_profile": "https://Stackoverflow.com/users/1248",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://uk3.php.net/strtotime\" rel=\"nofollow noreferrer\">strtotime</a> will handle that date format, gi... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Published Date returned from Twitter Search API Atom Feed as 2008-11-03T21:30:06Z which needs to be converted to "X seconds/minutes/hours/days ago" for showing how long ago twitter messages were posted.
Think this can be done with php date() function using DATE\_ATOM value? | ```
function time_since($your_timestamp) {
$unix_timestamp = strtotime($your_timestamp);
$seconds = time() - $unix_timestamp;
$minutes = 0;
$hours = 0;
$days = 0;
$weeks = 0;
$months = 0;
$years = 0;
if ( $seconds == 0 ) $seconds = 1;
if ( $seconds> 60 ) {
$minutes = $se... |
260,094 | <p>I've been developing a few JSF applications lately and am disturbed with the inconsistency in the web component APIs. </p>
<p>I've noticed that there is extremely unpredictable behavior when calling .getValue() or .getSubmittedValue() on a JSF component object in server side code. Sometimes when I call .getValue() ... | [
{
"answer_id": 260438,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 3,
"selected": false,
"text": "<p>To quote the documentation on <a href=\"http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/javax/faces/component/Edit... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/318/"
] | I've been developing a few JSF applications lately and am disturbed with the inconsistency in the web component APIs.
I've noticed that there is extremely unpredictable behavior when calling .getValue() or .getSubmittedValue() on a JSF component object in server side code. Sometimes when I call .getValue() on a drop ... | Since this is the #1 result in Google for searching on getValue vs. getSubmittedValue I'd just like to add that the difference between these is critical in validation (i.e. when writing a custom validator)
To quote the API documentation for getSubmittedValue():
>
> This is non-null only between decode
> and validat... |
260,122 | <p>I am trying to add a "title" element but am getting a NO_MODIFICATION_ALLOWED_ERR error...</p>
<pre><code>private static void saveDoc(String f) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(f)... | [
{
"answer_id": 260178,
"author": "Bogdan",
"author_id": 24022,
"author_profile": "https://Stackoverflow.com/users/24022",
"pm_score": 0,
"selected": false,
"text": "<p>For some reason, the parent node seems to be read-only.\nClone the document by using:</p>\n\n<pre><code>Document newDoc ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5653/"
] | I am trying to add a "title" element but am getting a NO\_MODIFICATION\_ALLOWED\_ERR error...
```
private static void saveDoc(String f) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(f);
// c... | Not sure if that's the reason, but check if your DOM implementation validates all the changes to the DOM. Because in you code,
```
nextNode.appendChild(doc.createTextNode("title"));
```
will attempt to create a text node as the child of `map` element and DITA Map doesn't allow that. Instead, try
```
Element title =... |
260,150 | <p>I am trying to use an XML-RPC server on my Drupal (PHP) backend to make it easier for my Perl backend to talk to it. However, I've run into an issue and I'm not sure which parts, if any, are bugs. Essentially, some of the variables I need to pass to Drupal are strings that sometimes are strings full of numbers and... | [
{
"answer_id": 260283,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 1,
"selected": false,
"text": "<p>The number <code>9876352345</code> is too big to fit in a 32bit integer. That might cause the problem.</p>\n"
}... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31240/"
] | I am trying to use an XML-RPC server on my Drupal (PHP) backend to make it easier for my Perl backend to talk to it. However, I've run into an issue and I'm not sure which parts, if any, are bugs. Essentially, some of the variables I need to pass to Drupal are strings that sometimes are strings full of numbers and the ... | I don't have any experience with the XML::RPC package, but I'm the author of the [RPC::XML](http://search.cpan.org/dist/RPC-XML) CPAN module. As with the Frontier package, I provide a way to force a value into a specific type when it would otherwise default to something else.
If I had to guess, I would say that the pa... |
260,165 | <p>A colleague is looking to generate UML class diagrams from heaps of Python source code.
He's primarily interested in the inheritance relationships, and mildly interested in compositional relationships, and doesn't care much about class attributes that are just Python primitives.</p>
<p>The source code is pretty st... | [
{
"answer_id": 260183,
"author": "David Arcos",
"author_id": 30300,
"author_profile": "https://Stackoverflow.com/users/30300",
"pm_score": 3,
"selected": false,
"text": "<p>If you use Eclipse, maybe <a href=\"http://sourceforge.net/projects/eclipse-pyuml\" rel=\"nofollow noreferrer\">PyU... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16056/"
] | A colleague is looking to generate UML class diagrams from heaps of Python source code.
He's primarily interested in the inheritance relationships, and mildly interested in compositional relationships, and doesn't care much about class attributes that are just Python primitives.
The source code is pretty straightforw... | You may have heard of [Pylint](http://www.pylint.org/) that helps statically checking Python code. Few people know that it comes with a tool named [Pyreverse](http://www.logilab.org/blogentry/6883) that draws UML diagrams from the Python code it reads. Pyreverse uses Graphviz as a backend.
It is used like this:
```no... |
260,192 | <p>I'm trying to use <code>mtrace</code> to detect memory leaks in a fortran program. I'm using the gfortran compiler. See the wikipedia entry for a (working) C example of mtrace: <a href="http://en.wikipedia.org/wiki/Mtrace" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Mtrace</a> </p>
<p>I tried both ways, ... | [
{
"answer_id": 260189,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": true,
"text": "<p>First find out what is really the problem and that the server is properly tuned for the queries you are running. I... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25891/"
] | I'm trying to use `mtrace` to detect memory leaks in a fortran program. I'm using the gfortran compiler. See the wikipedia entry for a (working) C example of mtrace: <http://en.wikipedia.org/wiki/Mtrace>
I tried both ways, i.e. wrapping the mtrace() and muntrace() and call them from the fortran program, as well as cr... | First find out what is really the problem and that the server is properly tuned for the queries you are running. It's very sad to waste the money on RAM to find out you are I/O bound.
After you gather data about the cause of the timeouts you should be able to convince the pencil wielders easily.
Some tuning/monitorin... |
260,195 | <p>I have a query in which I am pulling the runtime of an executable. The database contains its start time and its end time. I would like to get the total time for the run.
So far I have:</p>
<pre><code>SELECT startTime, endTime,
cast(datediff(hh,starttime,endtime) as varchar)
+':'
+cast(datediff(mi,starttime,endtime)... | [
{
"answer_id": 260209,
"author": "DOK",
"author_id": 27637,
"author_profile": "https://Stackoverflow.com/users/27637",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://www.sqlservercurry.com/2008/04/find-hours-minutes-and-seconds-in.html\" rel=\"nofollow noreferrer\">Here's... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33727/"
] | I have a query in which I am pulling the runtime of an executable. The database contains its start time and its end time. I would like to get the total time for the run.
So far I have:
```
SELECT startTime, endTime,
cast(datediff(hh,starttime,endtime) as varchar)
+':'
+cast(datediff(mi,starttime,endtime)-60*datediff(h... | Try these
Assuming 2 declared dates.
```
declare @start datetime
set @start = '2008-11-02 15:59:59.790'
declare @end datetime
set @end = '2008-11-02 19:05:41.857'
```
This will return the hours / mins / seconds
```
select
(datediff(ss, @start, @end) / 3600),
(datediff(ss, @start, @end) / 60) % 60,
(... |
260,210 | <p>I'm using jQuery and wanting to target the nth <li> in a list after clicking the nth link.</p>
<pre><code><ul id="targetedArea">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<div id="clickedItems">
<a></a>
<a><... | [
{
"answer_id": 260242,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 3,
"selected": true,
"text": "<p>how about something like this:</p>\n\n<pre><code>$('#clickedItems a').click(function() {\n// figure out what position this el... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16124/"
] | I'm using jQuery and wanting to target the nth <li> in a list after clicking the nth link.
```
<ul id="targetedArea">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<div id="clickedItems">
<a></a>
<a></a>
<a></a>
<a></a>
</div>
```
I can target them individually, but I know there must be a faster way ... | how about something like this:
```
$('#clickedItems a').click(function() {
// figure out what position this element is in
var n = $('#clickedItems a').index($(this) );
// update the targetedArea
$('#targetedArea li:eq('+n+')').html('updated!');
return false;
});
```
assuming a 1:1 relationship between your ... |
260,217 | <p>How can i draw a dotted line in .NET/WinForms/GDI+?</p>
<pre><code>Pen p = new Pen (Color.Black)
</code></pre>
<p>gives me only solid line pen. </p>
<p>I am trying to have a dotted (or dashed) lines; can't seem to be able to google it up successfully.</p>
<p>Will much appreciate any help on this one.</p>
| [
{
"answer_id": 260221,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 6,
"selected": true,
"text": "<pre><code>p.DashStyle = DashStyle.Dash;\n</code></pre>\n\n<p>I believe.</p>\n"
},
{
"answer_id": 260224,
"author... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19584/"
] | How can i draw a dotted line in .NET/WinForms/GDI+?
```
Pen p = new Pen (Color.Black)
```
gives me only solid line pen.
I am trying to have a dotted (or dashed) lines; can't seem to be able to google it up successfully.
Will much appreciate any help on this one. | ```
p.DashStyle = DashStyle.Dash;
```
I believe. |
260,229 | <p>I want to select records that are 1 month old or newer.</p>
<p>The query is: SELECT * FROM foobar WHERE created_at > DATE_SUB(curdate(), INTERVAL 1 MONTH)</p>
<p>Using Propel in Symfony, I do:</p>
<blockquote>
<p>$c = new Criteria<br>
$c->add(FoobarPeer::CREATED_AT, "DATE_SUB(curdate(), INTERVAL 1 MONTH)", Cr... | [
{
"answer_id": 260263,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 3,
"selected": true,
"text": "<p>I think there is no option more than using Criteria::CUSTOM or doing a custom SQL query like this:</p>\n\n<pr... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2706/"
] | I want to select records that are 1 month old or newer.
The query is: SELECT \* FROM foobar WHERE created\_at > DATE\_SUB(curdate(), INTERVAL 1 MONTH)
Using Propel in Symfony, I do:
>
> $c = new Criteria
>
> $c->add(FoobarPeer::CREATED\_AT, "DATE\_SUB(curdate(), INTERVAL 1 MONTH)", Criteria::GREATER\_THAN);
> ... | I think there is no option more than using Criteria::CUSTOM or doing a custom SQL query like this:
```
$con = Propel::getConnection(DATABASE_NAME);
$sql = "SELECT foobar.* FROM foobar WHERE created_at > DATE_SUB(curdate(), INTERVAL 1 MONTH)";
$stmt = $con->prepare($sql);
$stmt->execute();
$books = FoobarPeer::popu... |
260,233 | <p>I've created a Visual Basic WPF Application project that contains Toy.edmx, an ADO.NET Entity Data Model generated from a database called Toy.</p>
<p>Its <em>Window1.xaml.vb</em> file looks like this:</p>
<pre>
1 Class Window1
2
3 Private Sub Window1_Loaded( _
4 ByVal sender As System.Object, _
5 ... | [
{
"answer_id": 260340,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 1,
"selected": false,
"text": "<p>What type is Client class?</p>\n\n<p>You might need to add namespace (same as that in which Client \"Entity classs\... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I've created a Visual Basic WPF Application project that contains Toy.edmx, an ADO.NET Entity Data Model generated from a database called Toy.
Its *Window1.xaml.vb* file looks like this:
```
1 Class Window1
2
3 Private Sub Window1_Loaded( _
4 ByVal sender As System.Object, _
5 ByVal e As Syste... | The problem is that you're writing code, and expecting the Entity Framework to translate that into SQL... it can't do that. Just like LINQ to SQL can't do that.
Imagine if your property read a file from the "C:\" drive... how do you think it would handle that? - not possible. |
260,235 | <p>Consider the following simple C program that read a file into a buffer and displays that buffer to the console:</p>
<pre><code>#include<stdio.h>
main()
{
FILE *file;
char *buffer;
unsigned long fileLen;
//Open file
file = fopen("HelloWorld.txt", "rb");
if (!file)
{
fprintf(s... | [
{
"answer_id": 260243,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 6,
"selected": true,
"text": "<p>You need to NUL-terminate your string. Add</p>\n\n<pre><code>buffer[fileLen] = 0;\n</code></pre>\n\n<p>before printing i... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5640/"
] | Consider the following simple C program that read a file into a buffer and displays that buffer to the console:
```
#include<stdio.h>
main()
{
FILE *file;
char *buffer;
unsigned long fileLen;
//Open file
file = fopen("HelloWorld.txt", "rb");
if (!file)
{
fprintf(stderr, "Unable to op... | You need to NUL-terminate your string. Add
```
buffer[fileLen] = 0;
```
before printing it. |