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 |
|---|---|---|---|---|---|---|
104,952 | <p>I am using VS2005 VC++ for unmanaged C++. I have VSTS and am trying to use the code coverage tool to accomplish two things with regards to unit tests:</p>
<ol>
<li>See how much of my referenced code under test is getting executed</li>
<li>See how many methods of my code under test (if any) are not unit tested at al... | [
{
"answer_id": 104974,
"author": "Mark Ransom",
"author_id": 5987,
"author_profile": "https://Stackoverflow.com/users/5987",
"pm_score": 0,
"selected": false,
"text": "<p>Turn off inlining of functions. The easiest way to do this is to just compile in Debug mode.</p>\n\n<p><strong>Edit:... | 2008/09/19 | [
"https://Stackoverflow.com/questions/104952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using VS2005 VC++ for unmanaged C++. I have VSTS and am trying to use the code coverage tool to accomplish two things with regards to unit tests:
1. See how much of my referenced code under test is getting executed
2. See how many methods of my code under test (if any) are not unit tested at all
Setting up the V... | You could try adding a line of code to call the function only if some condition is true, and guarantee that that condition will never be true. Just make sure the compiler can't figure that out. For example,
```
int main(int argc, char **argv)
{
if(argv == NULL) // C runtime says this won't happen
someMethodWhi... |
104,953 | <p>I'm trying to create a horizontal 100% stacked bar graph using HTML and CSS. I'd like to create the bars using <code>DIVs</code> with background colors and percentage widths depending on the values I want to graph. I also want to have a grid lines to mark an arbitrary position along the graph.</p>
<p>In my experime... | [
{
"answer_id": 104965,
"author": "Stephen Deken",
"author_id": 7154,
"author_profile": "https://Stackoverflow.com/users/7154",
"pm_score": 4,
"selected": false,
"text": "<p>You have to explicitly set the position of the parent container along with the position of the child container. Th... | 2008/09/19 | [
"https://Stackoverflow.com/questions/104953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3488/"
] | I'm trying to create a horizontal 100% stacked bar graph using HTML and CSS. I'd like to create the bars using `DIVs` with background colors and percentage widths depending on the values I want to graph. I also want to have a grid lines to mark an arbitrary position along the graph.
In my experimentation, I've already... | You are right that CSS positioning is the way to go. Here's a quick run down:
`position: relative` will layout an element relative to *itself.* In other words, the elements is laid out in normal flow, then it is removed from normal flow and offset by whatever values you have specified (top, right, bottom, left). It's ... |
104,967 | <p>As a pet-project, I'd like to attempt to implement a basic language of my own design that can be used as a web-scripting language. It's trivial to run a C++ program as an Apache CGI, so the real work lies in how to parse an input file containing non-code (HTML/CSS markup) and server-side code.</p>
<p>In my undergra... | [
{
"answer_id": 105082,
"author": "Kris Erickson",
"author_id": 3798,
"author_profile": "https://Stackoverflow.com/users/3798",
"pm_score": 2,
"selected": false,
"text": "<p>PHP doesn't differentiate between the scanning and the Markup. It simply outputs to buffer when in Markup mode, an... | 2008/09/19 | [
"https://Stackoverflow.com/questions/104967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8636/"
] | As a pet-project, I'd like to attempt to implement a basic language of my own design that can be used as a web-scripting language. It's trivial to run a C++ program as an Apache CGI, so the real work lies in how to parse an input file containing non-code (HTML/CSS markup) and server-side code.
In my undergrad compiler... | You want to look at start conditions. For example:
```
"<?" { BEGIN (PHP); }
<PHP>[a-zA-Z]* { return PHP_TOKEN; }
<PHP>">?" { BEGIN (0); }
[a-zA-Z]* { return HTML_TOKEN; }
```
You start off in state 0, use the BEGIN macro to change states.
To match a RE only while in a particular state, prefi... |
104,971 | <p>I have a table with a "Date" column. Each Date may appear multiple times. How do I select only the dates that appear < k number of times?</p>
| [
{
"answer_id": 104984,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 3,
"selected": false,
"text": "<pre><code>SELECT * FROM [MyTable] WHERE [Date] IN\n(\n SELECT [Date] \n FROM [MyTable] \n GROUP By [Date] \n... | 2008/09/19 | [
"https://Stackoverflow.com/questions/104971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10675/"
] | I have a table with a "Date" column. Each Date may appear multiple times. How do I select only the dates that appear < k number of times? | ```
select dates
from table t
group by dates having count(dates) < k ;
```
Hopefully, it works for ORACLE.
HTH |
105,014 | <p>A while ago I came across some code that marked a member variable of a class with the <code>mutable</code> keyword. As far as I can see it simply allows you to modify a variable in a <code>const</code> method:</p>
<pre><code>class Foo
{
private:
mutable bool done_;
public:
void doSomething() cons... | [
{
"answer_id": 105038,
"author": "Frank Szczerba",
"author_id": 8964,
"author_profile": "https://Stackoverflow.com/users/8964",
"pm_score": 6,
"selected": false,
"text": "<p>Your use with boost::mutex is exactly what this keyword is intended for. Another use is for internal result cachin... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | A while ago I came across some code that marked a member variable of a class with the `mutable` keyword. As far as I can see it simply allows you to modify a variable in a `const` method:
```
class Foo
{
private:
mutable bool done_;
public:
void doSomething() const { ...; done_ = true; }
};
```
I... | It allows the differentiation of bitwise const and logical const. Logical const is when an object doesn't change in a way that is visible through the public interface, like your locking example. Another example would be a class that computes a value the first time it is requested, and caches the result.
Since c++11 `... |
105,031 | <p>Using C#, I want to get the total amount of RAM that my computer has.
With the PerformanceCounter I can get the amount of Available ram, by setting:</p>
<pre><code>counter.CategoryName = "Memory";
counter.Countername = "Available MBytes";
</code></pre>
<p>But I can't seem to find a way to get the total amount of m... | [
{
"answer_id": 105053,
"author": "DevelopingChris",
"author_id": 1220,
"author_profile": "https://Stackoverflow.com/users/1220",
"pm_score": 0,
"selected": false,
"text": "<p>.NET has a memory amount limit that it can access.\nIn Windows XP 2GB was the "hard ceiling".\nFor inst... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13713/"
] | Using C#, I want to get the total amount of RAM that my computer has.
With the PerformanceCounter I can get the amount of Available ram, by setting:
```
counter.CategoryName = "Memory";
counter.Countername = "Available MBytes";
```
But I can't seem to find a way to get the total amount of memory. How would I go abou... | The Windows API function [`GlobalMemoryStatusEx`](https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-globalmemorystatusex) can be called with p/invoke:
```
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private class MEMORYSTATUSEX
{
public uint dwLength;
public... |
105,095 | <p>If you are relying on an implementation of Python that has a Global Interpreter Lock (i.e. CPython) and writing multithreaded code, do you really need locks at all?</p>
<p>If the GIL doesn't allow multiple instructions to be executed in parallel, wouldn't shared data be unnecessary to protect?</p>
<p>sorry if this... | [
{
"answer_id": 105127,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 1,
"selected": false,
"text": "<p>You still need to use locks (your code could be interrupted at any time to execute another thread and this can cause dat... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16148/"
] | If you are relying on an implementation of Python that has a Global Interpreter Lock (i.e. CPython) and writing multithreaded code, do you really need locks at all?
If the GIL doesn't allow multiple instructions to be executed in parallel, wouldn't shared data be unnecessary to protect?
sorry if this is a dumb questi... | You will still need locks if you share state between threads. The GIL only protects the interpreter internally. You can still have inconsistent updates in your own code.
For example:
```
#!/usr/bin/env python
import threading
shared_balance = 0
class Deposit(threading.Thread):
def run(self):
for _ in xr... |
105,125 | <p>Our project uses Cruise Control to both build and hot deploy a web application to a remote server (via FTP) running Tomcat in the form of a .war file. Unfortunately, "hot" deploys don't appear to work properly, causing us to reboot Tomcat in response to each deployment. We would really like to do this auto-magical... | [
{
"answer_id": 105289,
"author": "ethyreal",
"author_id": 18159,
"author_profile": "https://Stackoverflow.com/users/18159",
"pm_score": 1,
"selected": false,
"text": "<p>if you have regularly scheduled builds you could easily put something in the cron like this</p>\n\n<pre><code>crontab ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7357/"
] | Our project uses Cruise Control to both build and hot deploy a web application to a remote server (via FTP) running Tomcat in the form of a .war file. Unfortunately, "hot" deploys don't appear to work properly, causing us to reboot Tomcat in response to each deployment. We would really like to do this auto-magically, m... | if you have regularly scheduled builds you could easily put something in the cron like this
```
crontab -e
```
then stop tomcat at say 1:30 am
```
30 1 * * * ./path_to_tamcat/bin/catalina.sh stop
```
then start it up again 2 mins later
```
32 1 * * * ./path_to_tamcat/bin/catalina.sh start
```
granted this isn'... |
105,198 | <p>I'm still a little unclear and when to wrap a <em>lock</em> around some code. My general rule-of-thumb is to wrap an operation in a lock when it reads or writes to a static variable. But when a static variable is ONLY read (e.g. it's a readonly that is set during type initialization), accessing it doesn't need to b... | [
{
"answer_id": 105218,
"author": "easeout",
"author_id": 10906,
"author_profile": "https://Stackoverflow.com/users/10906",
"pm_score": 1,
"selected": false,
"text": "<p>If you're just writing a value to a pointer, you don't need to lock, since that action is atomic. Generally, you shoul... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11574/"
] | I'm still a little unclear and when to wrap a *lock* around some code. My general rule-of-thumb is to wrap an operation in a lock when it reads or writes to a static variable. But when a static variable is ONLY read (e.g. it's a readonly that is set during type initialization), accessing it doesn't need to be wrapped i... | Since none of the code you've written modifies the static field after initialization, there is no need for any locking. Just replacing the string with a new value won't need synchronization either, unless the new value depends on the results of a read of the old value.
Static fields aren't the only things that need sy... |
105,212 | <p>Suppose I have a directory <code>/dir</code> inside which there are 3 symlinks to other directories
<code>/dir/dir11</code>, <code>/dir/dir12</code>, and <code>/dir/dir13</code>. I want to list all the files in <code>dir</code> including the ones in <code>dir11</code>, <code>dir12</code> and <code>dir13</code>.</p>... | [
{
"answer_id": 105249,
"author": "Michael Ridley",
"author_id": 4838,
"author_profile": "https://Stackoverflow.com/users/4838",
"pm_score": 9,
"selected": true,
"text": "<p>The <code>-L</code> option to <code>ls</code> will accomplish what you want. It dereferences symbolic links.</p>\n\... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18072/"
] | Suppose I have a directory `/dir` inside which there are 3 symlinks to other directories
`/dir/dir11`, `/dir/dir12`, and `/dir/dir13`. I want to list all the files in `dir` including the ones in `dir11`, `dir12` and `dir13`.
To be more generic, I want to list all files including the ones in the directories which are ... | The `-L` option to `ls` will accomplish what you want. It dereferences symbolic links.
So your command would be:
```
ls -LR
```
You can also accomplish this with
```
find -follow
```
The `-follow` option directs find to follow symbolic links to directories.
On Mac OS X use
```
find -L
```
as `-follow` has be... |
105,252 | <p>How do I convert between big-endian and little-endian values in C++?</p>
<p>For clarity, I have to translate binary data (double-precision floating point values and 32-bit and 64-bit integers) from one CPU architecture to another. This doesn't involve networking, so ntoh() and similar functions won't work here.</p>... | [
{
"answer_id": 105297,
"author": "Andrew",
"author_id": 826,
"author_profile": "https://Stackoverflow.com/users/826",
"pm_score": 3,
"selected": false,
"text": "<p>If you're doing this to transfer data between different platforms look at the ntoh and hton functions.</p>\n"
},
{
"... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19129/"
] | How do I convert between big-endian and little-endian values in C++?
For clarity, I have to translate binary data (double-precision floating point values and 32-bit and 64-bit integers) from one CPU architecture to another. This doesn't involve networking, so ntoh() and similar functions won't work here.
---
Note: T... | If you're using **Visual C++** do the following: You include intrin.h and call the following functions:
For 16 bit numbers:
```
unsigned short _byteswap_ushort(unsigned short value);
```
For 32 bit numbers:
```
unsigned long _byteswap_ulong(unsigned long value);
```
For 64 bit numbers:
```
unsigned __int64 _byt... |
105,264 | <p>I'm new to the WCSF and can't seem to find anything related to "building a custom template" for creating the views/presenters/code-behinds/etc with your own flavor ...</p>
<p>Can anyone point me in the right direction?</p>
| [
{
"answer_id": 105297,
"author": "Andrew",
"author_id": 826,
"author_profile": "https://Stackoverflow.com/users/826",
"pm_score": 3,
"selected": false,
"text": "<p>If you're doing this to transfer data between different platforms look at the ntoh and hton functions.</p>\n"
},
{
"... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2701/"
] | I'm new to the WCSF and can't seem to find anything related to "building a custom template" for creating the views/presenters/code-behinds/etc with your own flavor ...
Can anyone point me in the right direction? | If you're using **Visual C++** do the following: You include intrin.h and call the following functions:
For 16 bit numbers:
```
unsigned short _byteswap_ushort(unsigned short value);
```
For 32 bit numbers:
```
unsigned long _byteswap_ulong(unsigned long value);
```
For 64 bit numbers:
```
unsigned __int64 _byt... |
105,308 | <p>I want to take the url:
<a href="http://www.mydomain.com/signup-12345" rel="nofollow noreferrer">http://www.mydomain.com/signup-12345</a></p>
<p>And actually give them:
<a href="http://www.mydomain.com/signup/?aff=12345" rel="nofollow noreferrer">http://www.mydomain.com/signup/?aff=12345</a></p>
<p>I have NO histo... | [
{
"answer_id": 105336,
"author": "CodeRot",
"author_id": 14134,
"author_profile": "https://Stackoverflow.com/users/14134",
"pm_score": 3,
"selected": false,
"text": "<p>Try this : </p>\n\n<p>RewriteRule ^/signup-(\\d+)/$ /signup/?aff=$1 [I]</p>\n"
},
{
"answer_id": 111010,
"a... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13704/"
] | I want to take the url:
<http://www.mydomain.com/signup-12345>
And actually give them:
<http://www.mydomain.com/signup/?aff=12345>
I have NO history with mod\_rewrite, HELP! | Something that I found relatively hard to find out was how to do the reverse of what you are doing, whereby you need to find out the value of part of the query string.
So for example:
If you wanted to rewrite the Url:
<http://www.example.com/signup->**old**-script.**asp**?**aff**=12345
to:
<http://www.example.com/s... |
105,349 | <p>I am using bash in os X Terminal app, and my custom $PS1 breaks when I scroll through my history.</p>
<pre><code>PS1="${BLUE}\u${CYAN}@${RED}\h${BLUE}\w\n\[${red}\$${NC}\]"
</code></pre>
<p>also tried
PS1="${BLUE}\u${CYAN}@${RED}\h${BLUE}\w\r\n[${red}\$${NC}]" </p>
<p>The problem seems to be in the newline. ... | [
{
"answer_id": 105363,
"author": "apandit",
"author_id": 6128,
"author_profile": "https://Stackoverflow.com/users/6128",
"pm_score": 0,
"selected": false,
"text": "<p>If the problem seems to be with the newline, try putting \\r\\n instead of just \\n and see if it makes a difference.</p>... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17712/"
] | I am using bash in os X Terminal app, and my custom $PS1 breaks when I scroll through my history.
```
PS1="${BLUE}\u${CYAN}@${RED}\h${BLUE}\w\n\[${red}\$${NC}\]"
```
also tried
PS1="${BLUE}\u${CYAN}@${RED}\h${BLUE}\w\r\n[${red}\$${NC}]"
The problem seems to be in the newline. I have used this bash prompt on Slac... | You need the [ and ] arond every escape sequence; do $BLUE and the like include these? If not, they need to be bracketed with these calls. |
105,372 | <p>How can you enumerate an <code>enum</code> in C#?</p>
<p>E.g. the following code does not compile:</p>
<pre class="lang-cs prettyprint-override"><code>public enum Suit
{
Spades,
Hearts,
Clubs,
Diamonds
}
public void EnumerateAllSuitsDemoMethod()
{
foreach (Suit suit in Suit)
{
DoSo... | [
{
"answer_id": 105401,
"author": "Tom Carr",
"author_id": 14954,
"author_profile": "https://Stackoverflow.com/users/14954",
"pm_score": 6,
"selected": false,
"text": "<p>I think you can use</p>\n\n<pre><code>Enum.GetNames(Suit)\n</code></pre>\n"
},
{
"answer_id": 105402,
"aut... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] | How can you enumerate an `enum` in C#?
E.g. the following code does not compile:
```cs
public enum Suit
{
Spades,
Hearts,
Clubs,
Diamonds
}
public void EnumerateAllSuitsDemoMethod()
{
foreach (Suit suit in Suit)
{
DoSomething(suit);
}
}
```
And it gives the following compile-tim... | ```
foreach (Suit suit in (Suit[]) Enum.GetValues(typeof(Suit)))
{
}
```
**Note**: The cast to `(Suit[])` is not strictly necessary, [but it does make the code 0.5 ns faster](https://gist.github.com/bartoszkp/9e059c3edccc07a5e588#gistcomment-2625454). |
105,477 | <p>I think I've got it down to the most basic case:</p>
<pre><code>int main(int argc, char ** argv) {
int * arr;
foo(arr);
printf("car[3]=%d\n",arr[3]);
free (arr);
return 1;
}
void foo(int * arr) {
arr = (int*) malloc( sizeof(int)*25 );
arr[3] = 69;
}
</code></pre>
<p>The output is this:</p>
<pre cl... | [
{
"answer_id": 105507,
"author": "terminus",
"author_id": 9232,
"author_profile": "https://Stackoverflow.com/users/9232",
"pm_score": 3,
"selected": false,
"text": "<p>You've allocated arr in foo, but that pointers value is stored in the call stack. If you want to do this, do it like thi... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I think I've got it down to the most basic case:
```
int main(int argc, char ** argv) {
int * arr;
foo(arr);
printf("car[3]=%d\n",arr[3]);
free (arr);
return 1;
}
void foo(int * arr) {
arr = (int*) malloc( sizeof(int)*25 );
arr[3] = 69;
}
```
The output is this:
```none
> ./a.out
car[3]=-186955854... | You pass the pointer by value, not by reference, so whatever you do with arr inside foo will not make a difference outside the foo-function.
As m\_pGladiator wrote one way is to declare a reference to pointer like this (only possible in C++ btw. C does not know about references):
```
int main(int argc, char ** argv) ... |
105,499 | <p>I have a problem to connect to my WCF service if customer is using proxy with credentials. I'm unable to find the way to set credential to generated client proxy. </p>
<p>If I use the web service, then it is possible to set proxy. </p>
| [
{
"answer_id": 108530,
"author": "Toran Billups",
"author_id": 2701,
"author_profile": "https://Stackoverflow.com/users/2701",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure if this is what you are looking for but the below is a working code sample to authenticate using the clien... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19146/"
] | I have a problem to connect to my WCF service if customer is using proxy with credentials. I'm unable to find the way to set credential to generated client proxy.
If I use the web service, then it is possible to set proxy. | I'm not entirely sure if this is what you are looking for but here you go.
```
MyClient client = new MyClient();
client.ClientCredentials.UserName.UserName = "u";
client.ClientCredentials.UserName.Password = "p";
``` |
105,504 | <p>When retrieving a lookup code value from a table, some folks do this...</p>
<pre><code>Dim dtLookupCode As New LookupCodeDataTable()
Dim taLookupCode AS New LookupCodeTableAdapter()
Dim strDescription As String
dtLookupCode = taLookupCode.GetDataByCodeAndValue("EmpStatus", "FULL")
strDescription = dtLookupCode.Ite... | [
{
"answer_id": 105520,
"author": "davr",
"author_id": 14569,
"author_profile": "https://Stackoverflow.com/users/14569",
"pm_score": 2,
"selected": false,
"text": "<p>Yeah, don't say \"inline\" because that means something specific in other languages. Most likely the performance differenc... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71/"
] | When retrieving a lookup code value from a table, some folks do this...
```
Dim dtLookupCode As New LookupCodeDataTable()
Dim taLookupCode AS New LookupCodeTableAdapter()
Dim strDescription As String
dtLookupCode = taLookupCode.GetDataByCodeAndValue("EmpStatus", "FULL")
strDescription = dtLookupCode.Item(0).Meaning
... | Straying from the "inline" part of this, actually, the two sets of code won't compile out to the same thing. The issue comes in with:
```
Dim dtLookupCode As New LookupCodeDataTable()
Dim taLookupCode AS New LookupCodeTableAdapter()
```
In VB, this will create new objects with the appropriately-named references. Fo... |
105,522 | <p>OK, so things have progressed significantly with my DSL since I asked <a href="https://stackoverflow.com/questions/82776/how-do-i-reference-a-diagram-in-a-dsl-t4-template">this question</a> a few days ago.</p>
<p>As soon as I've refactored my code, I'll post my own answer to that one, but for now, I'm having anothe... | [
{
"answer_id": 149768,
"author": "Luis Filipe",
"author_id": 20335,
"author_profile": "https://Stackoverflow.com/users/20335",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe my answer is a little bit too late, but did you confirm using DSL Explorer that your compartments have items?... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5806/"
] | OK, so things have progressed significantly with my DSL since I asked [this question](https://stackoverflow.com/questions/82776/how-do-i-reference-a-diagram-in-a-dsl-t4-template) a few days ago.
As soon as I've refactored my code, I'll post my own answer to that one, but for now, I'm having another problem.
I'm dynam... | I've recently faced a related problem, and managed to make it work, so here's the story.
The task I was implementing was to load and display a domain model and an associated diagram generated by ActiveWriter's DSL package.
Here's how I've implemented the required functionality (all the methods below belong to the Fo... |
105,535 | <p>I have a VmWare virtual machine that is coming dangerously close to it's primarry HDD's limit and I need to extend it. How do I do this? I'm working with VmWare Workstation 6.0.5</p>
| [
{
"answer_id": 105547,
"author": "pkaeding",
"author_id": 4257,
"author_profile": "https://Stackoverflow.com/users/4257",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://www.seandeasy.com/expanding-a-drive-within-a-vmware-image/\" rel=\"nofollow noreferrer\">This link</a> g... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1980/"
] | I have a VmWare virtual machine that is coming dangerously close to it's primarry HDD's limit and I need to extend it. How do I do this? I'm working with VmWare Workstation 6.0.5 | [This link](http://www.seandeasy.com/expanding-a-drive-within-a-vmware-image/) gives two approaches that should help.
It looks like this is the most straightforward method:
```
vmware-vdiskmanager -x 12GB path\to\disk.vmdk
```
where 12GB is the desired size of the expanded volume. |
105,551 | <p>This exception peppers our production catalina logs on a simple 'getParameter()' call.</p>
<pre>
WARNING: Parameters: Character decoding failed. Parameter skipped.
java.io.CharConversionException: EOF
at org.apache.tomcat.util.buf.UDecoder.convert(UDecoder.java:82)
at org.apache.tomcat.util.buf.UDecoder.co... | [
{
"answer_id": 105968,
"author": "Alexander",
"author_id": 16724,
"author_profile": "https://Stackoverflow.com/users/16724",
"pm_score": 4,
"selected": true,
"text": "<p>Just hypothesizing here. Seems like the URL-decoding of parameters or their values fails (URL-encoding means encoding ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17123/"
] | This exception peppers our production catalina logs on a simple 'getParameter()' call.
```
WARNING: Parameters: Character decoding failed. Parameter skipped.
java.io.CharConversionException: EOF
at org.apache.tomcat.util.buf.UDecoder.convert(UDecoder.java:82)
at org.apache.tomcat.util.buf.UDecoder.convert(UD... | Just hypothesizing here. Seems like the URL-decoding of parameters or their values fails (URL-encoding means encoding some characters using the %XX or %XXXX notation where XX or XXXX is the hexadecimal code of the character in ISO-8859-1 or Unicode). In the first case the error might be happening because there aren't e... |
105,556 | <p>We are attempting to use a SQL Server 2003 database for our test records and want a quick way to take NUnit and NAnt output and produce SQL schema and data. Is there a simple way to generate SQL Schema using the XSD file describing these XML documents?</p>
| [
{
"answer_id": 105591,
"author": "Cyberherbalist",
"author_id": 16964,
"author_profile": "https://Stackoverflow.com/users/16964",
"pm_score": 2,
"selected": true,
"text": "<p>You could use XSD. No, I'm serious. Go to a command prompt and type xsd and press Enter.</p>\n\n<p>Here's what ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13688/"
] | We are attempting to use a SQL Server 2003 database for our test records and want a quick way to take NUnit and NAnt output and produce SQL schema and data. Is there a simple way to generate SQL Schema using the XSD file describing these XML documents? | You could use XSD. No, I'm serious. Go to a command prompt and type xsd and press Enter.
Here's what you will see (truncated):
```
I:\>xsd
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 1.0.3705.0]
Copyright (C) Microsoft Corporation 1998-2001. All rights reserved.
xsd.exe... |
105,564 | <p>The original query looks like this (MySQL):</p>
<pre><code>SELECT *
FROM books
WHERE title LIKE "%text%" OR description LIKE "%text%"
ORDER BY date
</code></pre>
<p>Would it be possible to rewrite it (without unions or procedures), so that result will look like this:</p>
<ul>
<li>list of books where title matc... | [
{
"answer_id": 105580,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": -1,
"selected": false,
"text": "<p>The union command will help you. Something along these lines:</p>\n\n<pre><code>SELECT *, 1 as order from books... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20128/"
] | The original query looks like this (MySQL):
```
SELECT *
FROM books
WHERE title LIKE "%text%" OR description LIKE "%text%"
ORDER BY date
```
Would it be possible to rewrite it (without unions or procedures), so that result will look like this:
* list of books where title matches query ordered by date, followed b... | In sql server I would do the following:
```
select * from books
where title like '%text%' or description like '%text%'
order by case when title like '%text%' then 1 else 2 end, date
```
I'm not sure if you can include columns in ORDER BY in mysql that aren't in the SELECT, but that's the principle I'd use. Otherwis... |
105,602 | <p>I have inherited a monster.</p>
<p>It is masquerading as a .NET 1.1 application processes text files that conform to Healthcare Claim Payment (ANSI 835) standards, but it's a monster. The information being processed relates to healthcare claims, EOBs, and reimbursements. These files consist of records that have a... | [
{
"answer_id": 105618,
"author": "Philip Rieck",
"author_id": 12643,
"author_profile": "https://Stackoverflow.com/users/12643",
"pm_score": 2,
"selected": false,
"text": "<p>A <a href=\"http://en.wikipedia.org/wiki/Finite_state_machine\" rel=\"nofollow noreferrer\">state machine</a> seem... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19304/"
] | I have inherited a monster.
It is masquerading as a .NET 1.1 application processes text files that conform to Healthcare Claim Payment (ANSI 835) standards, but it's a monster. The information being processed relates to healthcare claims, EOBs, and reimbursements. These files consist of records that have an identifier... | I just had some legacy code at work this week that was similar (although not as dire) as what you are describing.
There is no one thing that will get you out of this. The [state machine](http://en.wikipedia.org/wiki/Finite_state_machine) might be the final form your code takes, but thats *not* going to help you get th... |
105,604 | <p>I've just installed MediaWiki on a web server. Obviously it needs lots of privileges during installation to set up its database correctly. Now that it's installed can I safely revoke some privileges (e.g. create table, drop table?) Or might it need to create more tables later (when they are first needed?) If not... | [
{
"answer_id": 105919,
"author": "Brent",
"author_id": 10680,
"author_profile": "https://Stackoverflow.com/users/10680",
"pm_score": 0,
"selected": false,
"text": "<p>Change the user that mediawiki connects as in LocalSettings.php and then using phpMyAdmin, you can edit the privileges of... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12048/"
] | I've just installed MediaWiki on a web server. Obviously it needs lots of privileges during installation to set up its database correctly. Now that it's installed can I safely revoke some privileges (e.g. create table, drop table?) Or might it need to create more tables later (when they are first needed?) If not then I... | After the installation, MediaWiki doesn't need to create any more tables. I'd suggest giving the user insert, select, and lock permission.
```
grant select,lock tables,insert on media_wiki_db.* to 'wiki'@'localhost' identified by 'password';
``` |
105,609 | <p>I have an enum that looks as follows:</p>
<pre><code>public enum TransactionStatus { Open = 'O', Closed = 'C'};
</code></pre>
<p>and I'm pulling data from the database with a single character indicating - you guessed it - whether 'O' the transaction is open or 'C' the transaction is closed.</p>
<p>now because the... | [
{
"answer_id": 105638,
"author": "Jake Pearson",
"author_id": 632,
"author_profile": "https://Stackoverflow.com/users/632",
"pm_score": -1,
"selected": false,
"text": "<p>I would take a look at Enum.Parse. It will let you parse your char back into the proper enum. I believe it works al... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I have an enum that looks as follows:
```
public enum TransactionStatus { Open = 'O', Closed = 'C'};
```
and I'm pulling data from the database with a single character indicating - you guessed it - whether 'O' the transaction is open or 'C' the transaction is closed.
now because the data comes out of the database a... | ```
static void Main(string[] args)
{
object val = 'O';
Console.WriteLine(EnumEqual(TransactionStatus.Open, val));
val = 'R';
Console.WriteLine(EnumEqual(DirectionStatus.Left, val));
Console.ReadLine();
}
public static bool EnumEqual(Enum e, object boxedValue)
{
return... |
105,613 | <p>Is it possible to use XPath to select only the nodes that have a particular child elements? For example, from this XML I only want the elements in pets that have a child of 'bar'. So the resulting dataset would contain the <code>lizard</code> and <code>pig</code> elements from this example:</p>
<pre><code><pet... | [
{
"answer_id": 105628,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 7,
"selected": true,
"text": "<p>Here it is, in all its glory</p>\n\n<pre><code>/pets/*[bar]\n</code></pre>\n\n<p>English: Give me all children of ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10876/"
] | Is it possible to use XPath to select only the nodes that have a particular child elements? For example, from this XML I only want the elements in pets that have a child of 'bar'. So the resulting dataset would contain the `lizard` and `pig` elements from this example:
```
<pets>
<cat>
<foo>don't care about this... | Here it is, in all its glory
```
/pets/*[bar]
```
English: Give me all children of `pets` that have a child `bar` |
105,642 | <p><strong>Update</strong>: Looks like the query does not throw any timeout. The connection is timing out.</p>
<p>This is a sample code for executing a query. Sometimes, while executing time consuming queries, it throws a timeout exception.</p>
<p>I <strong>cannot</strong> use any of these techniques:
1) Increase tim... | [
{
"answer_id": 105655,
"author": "core",
"author_id": 11574,
"author_profile": "https://Stackoverflow.com/users/11574",
"pm_score": 0,
"selected": false,
"text": "<pre><code>command.CommandTimeout *= 2;\n</code></pre>\n\n<p>That will double the default time-out, which is 30 seconds.</p>\... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19306/"
] | **Update**: Looks like the query does not throw any timeout. The connection is timing out.
This is a sample code for executing a query. Sometimes, while executing time consuming queries, it throws a timeout exception.
I **cannot** use any of these techniques:
1) Increase timeout.
2) Run it asynchronously with a callb... | Since you are using ExecuteNonQuery which does not return any rows, you can try this polling based approach. It executes the query in an asyc manner (without callback)
but the application will wait (inside a while loop) until the query is complete. From [MSDN](http://msdn.microsoft.com/en-us/library/ca56w9se(VS.80).asp... |
105,645 | <p>Tackling a strange scenario here. </p>
<p>We use a proprietary workstation management application which uses mySQL to store its data. Within the application they provide number of reports, such as which user logged into which machine at what time, all the software products installed on the monitored machines, so on... | [
{
"answer_id": 105657,
"author": "Brent",
"author_id": 10680,
"author_profile": "https://Stackoverflow.com/users/10680",
"pm_score": 0,
"selected": false,
"text": "<p>Do you have access to the MySQL server in question?</p>\n\n<p>As in, what access do you have beyond what a regular user w... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16522/"
] | Tackling a strange scenario here.
We use a proprietary workstation management application which uses mySQL to store its data. Within the application they provide number of reports, such as which user logged into which machine at what time, all the software products installed on the monitored machines, so on and so fo... | You'll want to use the MySQL password recovery process. Follow [these instructions](http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html#resetting-permissions-windows), except replace the password reset query with a query to [add a new user](http://dev.mysql.com/doc/refman/5.0/en/adding-users.html). The ne... |
105,651 | <p>How can I print wstring in gdb?</p>
| [
{
"answer_id": 105900,
"author": "Jesse Beder",
"author_id": 112,
"author_profile": "https://Stackoverflow.com/users/112",
"pm_score": 1,
"selected": false,
"text": "<p>Suppose you've got a <code>std::wstring str</code>. The following should work in gdb:</p>\n\n<pre><code>call printf(\"%... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18382/"
] | How can I print wstring in gdb? | `call printf %ls` only works sometimes, but to get it to work at all in gdb 6.3 you need the `void` cast and linefeed `\n` shown here:
```
call (void)printf("\"%ls\"\n",str.c_str())
```
here is a more reliable command you can put in your .gdbinit that also shows non-ASCII code points:
```
define wc_print
echo "
set ... |
105,653 | <p>I'm having some issues with producing an int matrix without creating memory leaks. I want to be able to make a given (global) matrix into any size dynamically via read_matrix(). But then i want to be able to free the memory later on. So in my main method the second printf should result in a bus error since it should... | [
{
"answer_id": 105677,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 2,
"selected": false,
"text": "<p>You need to free each row individually:</p>\n\n<pre><code>\nvoid free_matrix(int **matrix, int size_x)\n{\n fo... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9191/"
] | I'm having some issues with producing an int matrix without creating memory leaks. I want to be able to make a given (global) matrix into any size dynamically via read\_matrix(). But then i want to be able to free the memory later on. So in my main method the second printf should result in a bus error since it should n... | Just because the memory has been free'd doesn't mean you can't access it! Of course, it's a **very bad** idea to access it after it's been free'd, but that's why it works in your example.
Note that `free( *first_matrix )` only free's `first_matrix[0]`, not the other arrays. You probably want some kind of marker to sig... |
105,671 | <p>Does any one have a preference on how to check if a value is <code>DBNull</code>? I've found these two statements give me the results I want, but just wondering if there's a preference?</p>
<p><code>if (any is System.DBNull)</code></p>
<p>same as:</p>
<p><code>if (any == System.DBNull.Value)</code></p>
<p>Thank... | [
{
"answer_id": 105678,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 3,
"selected": true,
"text": "<pre><code>if (any == System.DBNull.Value) ...\n</code></pre>\n\n<p>I prefer that one, simply because I read that as compari... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19314/"
] | Does any one have a preference on how to check if a value is `DBNull`? I've found these two statements give me the results I want, but just wondering if there's a preference?
`if (any is System.DBNull)`
same as:
`if (any == System.DBNull.Value)`
Thanks! | ```
if (any == System.DBNull.Value) ...
```
I prefer that one, simply because I read that as comparing values, not types. |
105,676 | <p>Greetings,</p>
<p>I need a way (either via C# or in a .bat file) to get a list of all the computers on a given network. Normally, I use "net view", but this tends to work (from my understanding) only within your domain. I need the names (or at least the IP Addresses) of all computers available on my network. </... | [
{
"answer_id": 105693,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 1,
"selected": false,
"text": "<p>Ping everything in the rage, then you can get netbios info from the systems that respond to identify it's name.</p>\n"
... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5021/"
] | Greetings,
I need a way (either via C# or in a .bat file) to get a list of all the computers on a given network. Normally, I use "net view", but this tends to work (from my understanding) only within your domain. I need the names (or at least the IP Addresses) of all computers available on my network.
Being able to ... | [Nmap](http://nmap.org/) is good for this - use the -O option for OS fingerprinting and -oX "filename.xml" for [output](http://nmap.org/book/man-output.html) as xml that you can then parse from c#.
A suitable commandline would be (where 192.168.0.0/24 is the subnet to scan):
```
nmap -O -oX "filename.xml" 192.168.0.0... |
105,688 | <p>I have an application with a REST style interface that takes XML documents via POST from clients. This application is written in Java and uses XML beans to process the posted message. </p>
<p>The XML schema definition for a field in the message looks like this:</p>
<pre><code><xs:element name="value" type="xs:s... | [
{
"answer_id": 105713,
"author": "aaronsw",
"author_id": 4300,
"author_profile": "https://Stackoverflow.com/users/4300",
"pm_score": 4,
"selected": false,
"text": "<p>What about <code><value xsi:nil=\"true\"></value></code>? That's what's <a href=\"http://www.w3.org/TR/xmlsch... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7222/"
] | I have an application with a REST style interface that takes XML documents via POST from clients. This application is written in Java and uses XML beans to process the posted message.
The XML schema definition for a field in the message looks like this:
```
<xs:element name="value" type="xs:string" nillable="true" /... | That's the right way of sending a nil value (assuming that the default namespace and the `xsi` namespace are set to the correct values, namely `"http://www.w3.org/2001/XMLSchema-instance"` for `xsi`.) so it looks like you might have come up against a bug in the CML parser you're using. What's the error message?
You mi... |
105,702 | <p>I'm about to put a beta version of the site I'm working on up on the web. It needs to have a beta code to restrict access. The site is written in django.</p>
<p>I don't want to change the fundamental Auth system to accommodate a beta code, and I don't care particularly that the security of the beta code is iron-cla... | [
{
"answer_id": 105756,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to add <code>@login_required</code> decorators across the board and be done with it. Unless you have... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6007/"
] | I'm about to put a beta version of the site I'm working on up on the web. It needs to have a beta code to restrict access. The site is written in django.
I don't want to change the fundamental Auth system to accommodate a beta code, and I don't care particularly that the security of the beta code is iron-clad, just th... | Start with [this Django snippet](http://www.djangosnippets.org/snippets/136/), but modify it to check `request.session['has_beta_access']`. If they don't have it, then have it return a redirect to a "enter beta code" page that, when posted to with the right code, sets that session variable to `True`.
Making it a publi... |
105,724 | <p>In this code I am debugging, I have this code snipit:</p>
<pre><code>ddlExpYear.SelectedItem.Value.Substring(2).PadLeft(2, '0');
</code></pre>
<p>What does this return? I really can't run this too much as it is part of a live credit card application. The DropDownList as you could imagine from the name contains the... | [
{
"answer_id": 105752,
"author": "RKitson",
"author_id": 16947,
"author_profile": "https://Stackoverflow.com/users/16947",
"pm_score": 0,
"selected": false,
"text": "<p>It looks like it's grabbing the substring from the 3rd character (if 0 based) to the end, then if the substring has a l... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2535/"
] | In this code I am debugging, I have this code snipit:
```
ddlExpYear.SelectedItem.Value.Substring(2).PadLeft(2, '0');
```
What does this return? I really can't run this too much as it is part of a live credit card application. The DropDownList as you could imagine from the name contains the 4-digit year.
UPDATE: Th... | It takes the last two digits of the year and pads the left side with zeroes to a maximum of 2 characters. Looks like a "just in case" for expiration years ending in 08, 07, etc., making sure that the leading zero is present. |
105,725 | <p>I have seen a lot of C/C++ based solutions to this problem where we have to write a program that upon execution prints its own source. </p>
<p>some solutions --</p>
<p><a href="http://www.cprogramming.com/challenges/solutions/self_print.html" rel="noreferrer">http://www.cprogramming.com/challenges/solutions/self_p... | [
{
"answer_id": 105745,
"author": "Roland",
"author_id": 15965,
"author_profile": "https://Stackoverflow.com/users/15965",
"pm_score": -1,
"selected": false,
"text": "<p>In ruby:</p>\n\n<p>puts File.read(_ _ FILE _ _)</p>\n"
},
{
"answer_id": 105755,
"author": "aaronsw",
"... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8786/"
] | I have seen a lot of C/C++ based solutions to this problem where we have to write a program that upon execution prints its own source.
some solutions --
<http://www.cprogramming.com/challenges/solutions/self_print.html>
**[Quine Page solution in many languages](http://www.nyx.net/~gthompso/quine.htm)**
There are m... | Aside from cheating¹ there is no difference between compiled and interpreted languages.
The generic approach to quines is quite easy. First, whatever the program looks like, at some point it has to print something:
```
print ...
```
However, what should it print? Itself. So it needs to print the "print" command:
... |
105,731 | <p>How do I use the softkeys with a CDialog based application in windows mobile 6 via MFC?</p>
<p>I have a CDialog based Windows Mobile 6 (touchscreen) Professional app that I am workign on.</p>
<p>The default behavior of a CDialog based app in WM6 Professional is to not use any softkeys by default... I want to map t... | [
{
"answer_id": 106421,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 3,
"selected": true,
"text": "<p>What's \"not working\" with the CCommandBar for you? You should be able to add a CCommandBar member to your dialog class... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3494/"
] | How do I use the softkeys with a CDialog based application in windows mobile 6 via MFC?
I have a CDialog based Windows Mobile 6 (touchscreen) Professional app that I am workign on.
The default behavior of a CDialog based app in WM6 Professional is to not use any softkeys by default... I want to map the softkeys to "C... | What's "not working" with the CCommandBar for you? You should be able to add a CCommandBar member to your dialog class, then in teh DIalog's InitDialog you call Create and InsertMenuBar on the command bar - something like this:
```
m_cmdBar.Create(this);
m_cmdBar.InsertMenuBar(IDR_MENU_RESRC_ID);
```
Your menu resou... |
105,754 | <p>We are currently using Apache 2.2.3 and Tomcat 5 (Embedded in JBoss 4.2.2) using <code>mod_proxy_jk</code> as the connector.</p>
<p>Can someone shed some light on the the correct way to calculate / configure the values below (as well as anything else that may be relevant). Both Apache and Tomcat are running on sep... | [
{
"answer_id": 105928,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 3,
"selected": false,
"text": "<h3>MaxClients</h3>\n\n<p>This is the fundamental cap of parallel client connections your apache should handle at once... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4419/"
] | We are currently using Apache 2.2.3 and Tomcat 5 (Embedded in JBoss 4.2.2) using `mod_proxy_jk` as the connector.
Can someone shed some light on the the correct way to calculate / configure the values below (as well as anything else that may be relevant). Both Apache and Tomcat are running on separate machines and hav... | You should consider the workload the servers might get.
The most important factor might be the number of simultaneously connected clients at peak times. Try to determine it and tune your settings in a way where:
* there are enough processing threads in both Apache and Tomcat that they don't need to spawn new threads ... |
105,770 | <p>I want to add a comma in the thousands place for a number.</p>
<p>Would <code>String.Format()</code> be the correct path to take? What format would I use?</p>
| [
{
"answer_id": 105793,
"author": "Seibar",
"author_id": 357,
"author_profile": "https://Stackoverflow.com/users/357",
"pm_score": 12,
"selected": true,
"text": "<pre><code>String.Format(\"{0:n}\", 1234); // Output: 1,234.00\nString.Format(\"{0:n0}\", 9876); // No digits after the decima... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/357/"
] | I want to add a comma in the thousands place for a number.
Would `String.Format()` be the correct path to take? What format would I use? | ```
String.Format("{0:n}", 1234); // Output: 1,234.00
String.Format("{0:n0}", 9876); // No digits after the decimal point. Output: 9,876
``` |
105,776 | <p>I was given a MySQL database file that I need to restore as a database on my Windows Server 2008 machine.</p>
<p>I tried using MySQL Administrator, but I got the following error:</p>
<blockquote>
<p>The selected file was generated by
mysqldump and cannot be restored by
this application.</p>
</blockquote>
<p... | [
{
"answer_id": 105798,
"author": "Justin Bennett",
"author_id": 271,
"author_profile": "https://Stackoverflow.com/users/271",
"pm_score": 10,
"selected": true,
"text": "<p>It should be as simple as running this: </p>\n\n<pre><code>mysql -u <user> -p < db_backup.dump\n</code></pr... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I was given a MySQL database file that I need to restore as a database on my Windows Server 2008 machine.
I tried using MySQL Administrator, but I got the following error:
>
> The selected file was generated by
> mysqldump and cannot be restored by
> this application.
>
>
>
How do I get this working? | It should be as simple as running this:
```
mysql -u <user> -p < db_backup.dump
```
If the dump is of a single database you may have to add a line at the top of the file:
```
USE <database-name-here>;
```
If it was a dump of many databases, the use statements are already in there.
To run these commands, open up... |
105,777 | <p>I've an issue with the same piece of code running fine on my live website but not on my local development server.</p>
<p>I've an Ajax function that updates a div. The following code works on the live site:</p>
<pre>self.xmlHttpReq.open("POST", PageURL, true);
self.xmlHttpReq.setRequestHeader("Content-type", "appli... | [
{
"answer_id": 105828,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 1,
"selected": false,
"text": "<p>Is there a reason you're explicitly setting the <code>Content-Length</code> header in the first example? You... <em>shouldn't... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've an issue with the same piece of code running fine on my live website but not on my local development server.
I've an Ajax function that updates a div. The following code works on the live site:
```
self.xmlHttpReq.open("POST", PageURL, true);
self.xmlHttpReq.setRequestHeader("Content-type", "application/x-www-fo... | Is there a reason you're explicitly setting the `Content-Length` header in the first example? You... *shouldn't* need to do this, and i wouldn't be surprised to find it causing problems.
Oh, and check your encoding routine. The rules are not *quite* the same for querystrings and POSTed form data. |
105,810 | <p>Part of our app parses RTF documents and we've come across a special character that is not translating well. When viewed in Word the character is an elipsis (...), and it's encoded in the RTF as ('85).</p>
<p>In our vb code we converted the hex (85) to int(133) and then did Chr(133) to return (...)</p>
<p>Here's ... | [
{
"answer_id": 105823,
"author": "core",
"author_id": 11574,
"author_profile": "https://Stackoverflow.com/users/11574",
"pm_score": 0,
"selected": false,
"text": "<pre><code>private static int HexStringToInt(string hexString)\n{\n try\n {\n return Convert.ToChar(hexString);\... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19327/"
] | Part of our app parses RTF documents and we've come across a special character that is not translating well. When viewed in Word the character is an elipsis (...), and it's encoded in the RTF as ('85).
In our vb code we converted the hex (85) to int(133) and then did Chr(133) to return (...)
Here's the code in C# - p... | This looks like a character encoding issue to me. Unicode doesn't include any characters with numbers in the upper-ASCII 128-255 range, so trying to convert character 133 will fail.
Need to convert it first to a character using the proper decoding, Convert.toChar appears to be using UTF-16.
Sometimes there's a manual... |
105,816 | <p>I'm mocking about with plt-scheme's ffi and I have a C-function that returns a char ** (array of strings). If I declare my function as <code>(_fun _pointer -> _pointer)</code>, how do I convert the result to a list of strings in scheme?</p>
<p>Here are the relevant C-declarations:</p>
<pre><code>typedef char **... | [
{
"answer_id": 105938,
"author": "Jonathan Arkell",
"author_id": 11052,
"author_profile": "https://Stackoverflow.com/users/11052",
"pm_score": 0,
"selected": false,
"text": "<p>I know it's not exactly what you are looking for, but it might help a little bit. I've done some work on a bas... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18180/"
] | I'm mocking about with plt-scheme's ffi and I have a C-function that returns a char \*\* (array of strings). If I declare my function as `(_fun _pointer -> _pointer)`, how do I convert the result to a list of strings in scheme?
Here are the relevant C-declarations:
```
typedef char **MYSQL_ROW; /* return data as ar... | I *think* that what you want is the cvector:
<http://docs.plt-scheme.org/foreign/Derived_Utilities.html#(part._foreign~3acvector)>
A cvector of \_string/utf-8 or whichever encoding you need seems reasanable.
But that's from a quick survey of the docs - I haven't tried this myself. Please let me know if it works! |
105,852 | <p>After reading "<a href="http://web.archive.org/web/20090117062700/http://stackoverflow.com:80/questions/20702/whats-youra-good-limit-for-cyclomatic-complexity" rel="noreferrer">What’s your/a good limit for cyclomatic complexity?</a>", I realize many of my colleagues were quite annoyed with this new <a href="http://e... | [
{
"answer_id": 105876,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 2,
"selected": false,
"text": "<p>In C or C++ I'd use the preprocessor instead of the if statements for the conditional logging.</p>\n"
},
{
"an... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6309/"
] | After reading "[What’s your/a good limit for cyclomatic complexity?](http://web.archive.org/web/20090117062700/http://stackoverflow.com:80/questions/20702/whats-youra-good-limit-for-cyclomatic-complexity)", I realize many of my colleagues were quite annoyed with this new [QA](http://en.wikipedia.org/wiki/Quality_assura... | In Python you pass the formatted values as parameters to the logging function. String formatting is only applied if logging is enabled. There's still the overhead of a function call, but that's minuscule compared to formatting.
```
log.info ("a = %s, b = %s", a, b)
```
You can do something like this for any language... |
105,884 | <p>I have an .Net MVC application which runs fine if I use the build in Visual Studio Webserver. If I use the projects property pages to switch to IIS as the webserver and create a virtual directory for my project, any request I send to the server results in a "Directory listing denied" failure.</p>
<p>Does anyone kno... | [
{
"answer_id": 105876,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 2,
"selected": false,
"text": "<p>In C or C++ I'd use the preprocessor instead of the if statements for the conditional logging.</p>\n"
},
{
"an... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16440/"
] | I have an .Net MVC application which runs fine if I use the build in Visual Studio Webserver. If I use the projects property pages to switch to IIS as the webserver and create a virtual directory for my project, any request I send to the server results in a "Directory listing denied" failure.
Does anyone know a soluti... | In Python you pass the formatted values as parameters to the logging function. String formatting is only applied if logging is enabled. There's still the overhead of a function call, but that's minuscule compared to formatting.
```
log.info ("a = %s, b = %s", a, b)
```
You can do something like this for any language... |
105,932 | <p>It seems like a standard requirement: next time the user launches the application, open the window in the same position and state as it was before. Here's my wish list:</p>
<ul>
<li>Window position same as it was
<ul>
<li>Unless the screen has resized and the old position is now off screen.</li>
</ul></li>
<li>Spl... | [
{
"answer_id": 105969,
"author": "Don Kirkby",
"author_id": 4794,
"author_profile": "https://Stackoverflow.com/users/4794",
"pm_score": 3,
"selected": false,
"text": "<p>The simplest solution I've found is to use data binding with the application settings. I bind the location and clientS... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4794/"
] | It seems like a standard requirement: next time the user launches the application, open the window in the same position and state as it was before. Here's my wish list:
* Window position same as it was
+ Unless the screen has resized and the old position is now off screen.
* Splitters should retain their position
* T... | My other option is to write more custom code around the application settings and execute it on formLoad and formClosed. This doesn't use data binding.
Drawbacks:
* More code to write.
* Very fiddly. The order you set the properties on formLoad is confusing. For example, you have to make sure you've set the window siz... |
105,935 | <p>This request is based in MS Access VBA. I would like to know what the most efficient way is, to see if an item exists in a listbox control.</p>
| [
{
"answer_id": 106125,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": 1,
"selected": false,
"text": "<p>Unfortunately there is no more efficient way than a linear search, unless you know that your listbox is sorted or indexed... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3155/"
] | This request is based in MS Access VBA. I would like to know what the most efficient way is, to see if an item exists in a listbox control. | Here is a sample function that might be adapted to suit.
```
Function CheckForItem(strItem, ListB As ListBox) As Boolean
Dim rs As DAO.Recordset
Dim db As Database
Dim tdf As TableDef
Set db = CurrentDb
CheckForItem = False
Select Case ListB.RowSourceType
Case "Value List"
CheckForIt... |
105,950 | <p>I can't seem to figure out how to set the default database in Sql Server from code. This can be either .Net code or T-Sql (T-Sql would be nice since it would be easy to use in any language). I searched Google and could only find how to do it in Sql Server Management Studio.</p>
| [
{
"answer_id": 105965,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 5,
"selected": true,
"text": "<p>from: <a href=\"http://doc.ddart.net/mssql/sql70/sp_da-di_6.htm\" rel=\"noreferrer\">http://doc.ddart.net/mssql/s... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/320/"
] | I can't seem to figure out how to set the default database in Sql Server from code. This can be either .Net code or T-Sql (T-Sql would be nice since it would be easy to use in any language). I searched Google and could only find how to do it in Sql Server Management Studio. | from: <http://doc.ddart.net/mssql/sql70/sp_da-di_6.htm>
```
sp_defaultdb [@loginame =] 'login' , [@defdb =] 'database'
``` |
105,971 | <p>I am working on a bash script where I need to conditionally execute some things if a particular file exists. This is happening multiple times, so I abstracted the following function:</p>
<pre><code>function conditional-do {
if [ -f $1 ]
then
echo "Doing stuff"
$2
else
echo "File... | [
{
"answer_id": 105982,
"author": "Alex Gartrell",
"author_id": 10307,
"author_profile": "https://Stackoverflow.com/users/10307",
"pm_score": 0,
"selected": false,
"text": "<p>One (possibly-hack) solution is to store the separate functions as separate scripts altogether.</p>\n"
},
{
... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I am working on a bash script where I need to conditionally execute some things if a particular file exists. This is happening multiple times, so I abstracted the following function:
```
function conditional-do {
if [ -f $1 ]
then
echo "Doing stuff"
$2
else
echo "File doesn't exist!... | This should be readable to most C programmers:
```
function file_exists {
if ( [ -e $1 ] ) then
echo "Doing stuff"
else
echo "File $1 doesn't exist"
false
fi
}
file_exists filename && (
echo "Do your stuff..."
)
```
or the one-liner
```
file_exists filename && echo "Do your stuff..."
```
No... |
105,996 | <ul>
<li>I want to obtain maximum performance out of a process with many variables, many of which cannot be controlled. </li>
<li>I cannot run thousands of experiments, so it'd be nice if I could run hundreds of experiments and
<ul>
<li>vary many controllable parameters</li>
<li>collect data on many parameters indicat... | [
{
"answer_id": 106013,
"author": "Jon Ericson",
"author_id": 1438,
"author_profile": "https://Stackoverflow.com/users/1438",
"pm_score": 3,
"selected": true,
"text": "<p>It sounds like you want to do some <a href=\"http://en.wikipedia.org/wiki/Regression_analysis\" rel=\"nofollow norefer... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] | * I want to obtain maximum performance out of a process with many variables, many of which cannot be controlled.
* I cannot run thousands of experiments, so it'd be nice if I could run hundreds of experiments and
+ vary many controllable parameters
+ collect data on many parameters indicating performance
+ 'correct,... | It sounds like you want to do some [regression analysis](http://en.wikipedia.org/wiki/Regression_analysis). You certainly have plenty of data!
---
Regression analysis is an extremely common modeling technique in statistics and science. (It could be argued that statistics is the art and science of regression analysis.... |
105,998 | <p>According to what I have found so far, I can use the following code:</p>
<pre>
LocalSessionFactoryBean sessionFactory = (LocalSessionFactoryBean)super.getApplicationContext().getBean("&sessionFactory");
System.out.println(sessionFactory.getConfiguration().buildSettings().getJdbcBatchSize());
</pre>
<p>but ... | [
{
"answer_id": 106165,
"author": "Matt Solnit",
"author_id": 6198,
"author_profile": "https://Stackoverflow.com/users/6198",
"pm_score": 3,
"selected": true,
"text": "<p>Try the following (I can't test it since I don't use Spring):</p>\n\n<pre><code>System.out.println(sessionFactory.getC... | 2008/09/19 | [
"https://Stackoverflow.com/questions/105998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14068/"
] | According to what I have found so far, I can use the following code:
```
LocalSessionFactoryBean sessionFactory = (LocalSessionFactoryBean)super.getApplicationContext().getBean("&sessionFactory");
System.out.println(sessionFactory.getConfiguration().buildSettings().getJdbcBatchSize());
```
but then I get a ... | Try the following (I can't test it since I don't use Spring):
```
System.out.println(sessionFactory.getConfiguration().getProperty("hibernate.jdbc.batch_size"))
``` |
106,000 | <p>I have been tasked with coming up with a compatibility guide for SharePoint 2007 comparing Office 2003 and Office 2007. Does anyone know where to find such a list?</p>
<p>I have been searching for awhile but I cannot seem to find a comprehensive list.</p>
<p>Thanks :)</p>
| [
{
"answer_id": 106165,
"author": "Matt Solnit",
"author_id": 6198,
"author_profile": "https://Stackoverflow.com/users/6198",
"pm_score": 3,
"selected": true,
"text": "<p>Try the following (I can't test it since I don't use Spring):</p>\n\n<pre><code>System.out.println(sessionFactory.getC... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14281/"
] | I have been tasked with coming up with a compatibility guide for SharePoint 2007 comparing Office 2003 and Office 2007. Does anyone know where to find such a list?
I have been searching for awhile but I cannot seem to find a comprehensive list.
Thanks :) | Try the following (I can't test it since I don't use Spring):
```
System.out.println(sessionFactory.getConfiguration().getProperty("hibernate.jdbc.batch_size"))
``` |
106,001 | <p>I have some code which utilizes parameterized queries to prevent against injection, but I also need to be able to dynamically construct the query regardless of the structure of the table. What is the proper way to do this?</p>
<p>Here's an example, say I have a table with columns Name, Address, Telephone. I have ... | [
{
"answer_id": 106014,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 4,
"selected": true,
"text": "<p>Instead of passing the column names, just pass an identifier that you code will translate to a column name using a hardcode... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2581/"
] | I have some code which utilizes parameterized queries to prevent against injection, but I also need to be able to dynamically construct the query regardless of the structure of the table. What is the proper way to do this?
Here's an example, say I have a table with columns Name, Address, Telephone. I have a web page w... | Instead of passing the column names, just pass an identifier that you code will translate to a column name using a hardcoded table. This means you don't need to worry about malicious data being passed, since all the data is either translated legally, or is known to be invalid. Psudoish code:
```
@columns = qw/Name Add... |
106,033 | <p>Suppose I am writing an application in C++ and C#. I want to write the low level parts in C++ and write the high level logic in C#. How can I load a .NET assembly from my C++ program and start calling methods and accessing the properties of my C# classes?</p>
| [
{
"answer_id": 106050,
"author": "QBziZ",
"author_id": 11572,
"author_profile": "https://Stackoverflow.com/users/11572",
"pm_score": 0,
"selected": false,
"text": "<p>You can wrap the .NET component in a COM component - which is quite easy with the .NET tools - and call it via COM.</p>\n... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4828/"
] | Suppose I am writing an application in C++ and C#. I want to write the low level parts in C++ and write the high level logic in C#. How can I load a .NET assembly from my C++ program and start calling methods and accessing the properties of my C# classes? | ```
[Guid("123565C4-C5FA-4512-A560-1D47F9FDFA20")]
public interface IConfig
{
[DispId(1)]
string Destination{ get; }
[DispId(2)]
void Unserialize();
[DispId(3)]
void Serialize();
}
[ComVisible(true)]
[Guid("12AC8095-BD27-4de8-A30B-991940666927")]
[ClassInterface(ClassInterfaceType.None)]
publ... |
106,053 | <p>I already know the obvious answer to this question: "just download <insert favorite windows grep or grep-like tool here>". However, I work in an environment with strict controls by the local IT staff as to what we're allowed to have on our computers. Suffice it to say: I have access to Perl on Windows XP. H... | [
{
"answer_id": 106099,
"author": "Ray Hayes",
"author_id": 7093,
"author_profile": "https://Stackoverflow.com/users/7093",
"pm_score": 5,
"selected": false,
"text": "<p>Most of the power of grep is already available on your machine in the Windows application FindStr.exe which is part of ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13140/"
] | I already know the obvious answer to this question: "just download <insert favorite windows grep or grep-like tool here>". However, I work in an environment with strict controls by the local IT staff as to what we're allowed to have on our computers. Suffice it to say: I have access to Perl on Windows XP. Here's a quic... | I wrote this a while back:
```
@rem = '--*-Perl-*--
@echo off
perl -x -S %0 %*
goto endofperl
@rem -- BEGIN PERL -- ';
#!d:/Perl/bin/perl.exe -w
#line 10
use strict;
#use Test::Setup;
use Getopt::Long;
Getopt::Long::Configure ("bundling");
my $ignore_case = 0;
my $number_line = 0;
my $invert_results = 0;
my ... |
106,058 | <p>Someone is trying to sell Lisp to me, as a super powerful language that can do everything ever, and then some.</p>
<p>Is there a <em>practical</em> code example of Lisp's power?<br/>(Preferably alongside equivalent logic coded in a regular language.)</p>
| [
{
"answer_id": 106075,
"author": "William Keller",
"author_id": 17095,
"author_profile": "https://Stackoverflow.com/users/17095",
"pm_score": 3,
"selected": false,
"text": "<p>Have you taken a look at <a href=\"https://web.archive.org/web/20170702100142/http://www.weitz.de/macros.lisp\" ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9360/"
] | Someone is trying to sell Lisp to me, as a super powerful language that can do everything ever, and then some.
Is there a *practical* code example of Lisp's power?
(Preferably alongside equivalent logic coded in a regular language.) | I like macros.
Here's code to stuff away attributes for people from LDAP. I just happened to have that code lying around and fiigured it'd be useful for others.
Some people are confused over a supposed runtime penalty of macros, so I've added an attempt at clarifying things at the end.
In The Beginning, There Was Du... |
106,067 | <p>In java, which regular expression can be used to replace these,
for example:</p>
<p>before:
aaabbb
after:
ab</p>
<p>before:
14442345
after:
142345</p>
<p>thanks!</p>
| [
{
"answer_id": 106096,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 6,
"selected": true,
"text": "<p>In perl</p>\n\n<pre><code>s/(.)\\1+/$1/g;\n</code></pre>\n\n<p>Does the trick, I assume if java has perl compatible regexps it s... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18300/"
] | In java, which regular expression can be used to replace these,
for example:
before:
aaabbb
after:
ab
before:
14442345
after:
142345
thanks! | In perl
```
s/(.)\1+/$1/g;
```
Does the trick, I assume if java has perl compatible regexps it should work too.
Edit: Here is what it means
```
s {
(.) # match any charater ( and capture it )
\1 # if it is followed by itself
+ # One or more times
}{$1}gx; # And replace the whole things by the f... |
106,095 | <p>Using ASP.NET 2.0, I have a web app where I am trying to use JavaScript to make one tab in a tab-container the active tab.</p>
<p>The recommendations have been based on:</p>
<pre><code>var mX=document.getElementById('<%= tc1.ClientID%>')
$find('<%= tc1.ClientID%>').set_activeTabIndex(1);
</code></pre... | [
{
"answer_id": 106139,
"author": "harpo",
"author_id": 4525,
"author_profile": "https://Stackoverflow.com/users/4525",
"pm_score": 0,
"selected": false,
"text": "<p>It looks and sounds like the code snippets are not themselves offensive, but some <em>other</em> code that was modifying th... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Using ASP.NET 2.0, I have a web app where I am trying to use JavaScript to make one tab in a tab-container the active tab.
The recommendations have been based on:
```
var mX=document.getElementById('<%= tc1.ClientID%>')
$find('<%= tc1.ClientID%>').set_activeTabIndex(1);
```
Which both produce the error:
```
The ... | I've actually run into that before. **Here's an explanation: <http://west-wind.com/WebLog/posts/6148.aspx>**
For example, if your markup looks like:
```
<asp:Panel id="whatever" runat="server">
<script type="text/javascript">
var mX=document.getElementById('<%= tc1.ClientID%>');
//and so on...
... |
106,117 | <p>Please bear with me, I'm just learning C++. </p>
<p>I'm trying to write my header file (for class) and I'm running into an odd error.</p>
<pre><code>cards.h:21: error: expected unqualified-id before ')' token
cards.h:22: error: expected `)' before "str"
cards.h:23: error: expected `)' before "r"
</code></pre>
<p>... | [
{
"answer_id": 106126,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 0,
"selected": false,
"text": "<p>Remove the <strong>#define Card</strong>.</p>\n"
},
{
"answer_id": 106127,
"author": "John Millikin",
... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16204/"
] | Please bear with me, I'm just learning C++.
I'm trying to write my header file (for class) and I'm running into an odd error.
```
cards.h:21: error: expected unqualified-id before ')' token
cards.h:22: error: expected `)' before "str"
cards.h:23: error: expected `)' before "r"
```
What does "expected unqualified-i... | Your issue is your `#define`. You did `#define Card`, so now everywhere `Card` is seen as a token, it will be replaced.
Usually a `#define Token` with no additional token, as in `#define Token Replace` will use the value `1`.
Remove the `#define Card`, it's making line 22 read: `1();` or `();`, which is causing the c... |
106,137 | <p>When you want to add whitespace between HTML elements (using CSS), to which element do you attach it?</p>
<p>I'm regularly in situations along these lines:</p>
<pre><code><body>
<h1>This is the heading</h1>
<p>This is a paragraph</p>
<h1>Here's another heading</h1>
... | [
{
"answer_id": 106153,
"author": "Pavling",
"author_id": 18197,
"author_profile": "https://Stackoverflow.com/users/18197",
"pm_score": 4,
"selected": true,
"text": "<p>I tend to use a bottom margin on elements when I want them to have space before the next element, and then to use a \".l... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3488/"
] | When you want to add whitespace between HTML elements (using CSS), to which element do you attach it?
I'm regularly in situations along these lines:
```
<body>
<h1>This is the heading</h1>
<p>This is a paragraph</p>
<h1>Here's another heading</h1>
<div>This is a footer</div>
</body>
```
Now, say I wanted 1e... | I tend to use a bottom margin on elements when I want them to have space before the next element, and then to use a ".last" class in the css to remove the margin from the last element.
```
<body>
<h1>This is the heading</h1>
<p>This is a paragraph</p>
<h1>Here's another heading</h1>
<div class="last">This is a... |
106,175 | <p><a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET" rel="nofollow noreferrer">VB.NET</a> has a very handy "with" statement, but it also lets you use it on an unnamed variable, like this:</p>
<pre><code>With New FancyClass()
.Level = "SuperSpiffy"
.Style = Slimming
.Execute()
End With
</code></pre>
... | [
{
"answer_id": 106284,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 1,
"selected": false,
"text": "<p>What's wrong with defining a variable on one line and using it in a with-statement on the next? I realise it keeps the vari... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15127/"
] | [VB.NET](http://en.wikipedia.org/wiki/Visual_Basic_.NET) has a very handy "with" statement, but it also lets you use it on an unnamed variable, like this:
```
With New FancyClass()
.Level = "SuperSpiffy"
.Style = Slimming
.Execute()
End With
```
Is there a way to get at the "hidden" instance, so I can vi... | As answered, the simple answer is "no".
But isn't another way to do it: instead of declaring and then cleaning up the variable is to use the "Using".
```
Using fc as new FancyClass()
With fc
.Level = "SuperSpiffy"
.Style = Slimming
.Execute()
End With
End Using
```
Then you can use fc in... |
106,179 | <p>Does anyone have a regular expression handy that will match any legal DNS hostname or IP address?</p>
<p>It's easy to write one that works 95% of the time, but I'm hoping to get something that's well tested to exactly match the latest RFC specs for DNS hostnames.</p>
| [
{
"answer_id": 106223,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 10,
"selected": true,
"text": "<p>You can use the following regular expressions separately or by combining them in a joint OR expression.</p>\n<pre>... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10452/"
] | Does anyone have a regular expression handy that will match any legal DNS hostname or IP address?
It's easy to write one that works 95% of the time, but I'm hoping to get something that's well tested to exactly match the latest RFC specs for DNS hostnames. | You can use the following regular expressions separately or by combining them in a joint OR expression.
```
ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
ValidHostnameRegex = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*(... |
106,201 | <p>In the spirit of being helpful, this is a problem I had and solved, so I will answer the question here. </p>
<p><strong>Problem</strong></p>
<p>I have:</p>
<p>An application that has to be installed on on Redhat or SuSE enterprise. </p>
<p>It has huge system requirements and requires OpenGL.</p>
<p>It is part o... | [
{
"answer_id": 106218,
"author": "scubabbl",
"author_id": 9450,
"author_profile": "https://Stackoverflow.com/users/9450",
"pm_score": 5,
"selected": true,
"text": "<p><strong>Solution</strong></p>\n\n<p>I installed two pieces of software:</p>\n\n<p><a href=\"http://www.chiark.greenend.or... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9450/"
] | In the spirit of being helpful, this is a problem I had and solved, so I will answer the question here.
**Problem**
I have:
An application that has to be installed on on Redhat or SuSE enterprise.
It has huge system requirements and requires OpenGL.
It is part of a suite of tools that need to operate together on... | **Solution**
I installed two pieces of software:
[PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/)
[XMing-mesa](http://www.straightrunning.com/XmingNotes/) The mesa part is important.
**PuTTY configuration**
```
Connection->Seconds Between Keepalives: 30
Connection->Enable TCP Keepalives: Yes
Connection... |
106,206 | <p>I'm writing an import utility that is using phone numbers as a unique key within the import.</p>
<p>I need to check that the phone number does not already exist in my DB. The problem is that phone numbers in the DB could have things like dashes and parenthesis and possibly other things. I wrote a function to remo... | [
{
"answer_id": 106217,
"author": "Dan Williams",
"author_id": 4230,
"author_profile": "https://Stackoverflow.com/users/4230",
"pm_score": 1,
"selected": false,
"text": "<p>can you remove them in a nightly process, storing them in a separate field, then do an update on changed records rig... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] | I'm writing an import utility that is using phone numbers as a unique key within the import.
I need to check that the phone number does not already exist in my DB. The problem is that phone numbers in the DB could have things like dashes and parenthesis and possibly other things. I wrote a function to remove these thi... | I may misunderstand, but you've got two sets of data to remove the strings from one for current data in the database and then a new set whenever you import.
For updating the existing records, I would just use SQL, that only has to happen once.
However, SQL isn't optimized for this sort of operation, since you said yo... |
106,234 | <p>lsof is an increadibly powerful command-line utility for unix systems. It lists open files, displaying information about them. And since most everything is a file on unix systems, lsof can give sysadmins a ton of useful diagnostic data.</p>
<p>What are some of the most common and useful ways of using lsof, and whic... | [
{
"answer_id": 106249,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 4,
"selected": false,
"text": "<p><code>lsof -i</code> will provide a list of open network sockets. The <code>-n</code> option will prevent DNS looku... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8683/"
] | lsof is an increadibly powerful command-line utility for unix systems. It lists open files, displaying information about them. And since most everything is a file on unix systems, lsof can give sysadmins a ton of useful diagnostic data.
What are some of the most common and useful ways of using lsof, and which command-... | To show all networking related to a given `port`:
```
lsof -iTCP -i :port
lsof -i :22
```
To show connections to a specific host, use `@host`
```
lsof -i@192.168.1.5
```
Show connections based on the host and the port using `@host:port`
lsof -i@192.168.1.5:22
`grep`ping for `LISTEN` shows what ports your system... |
106,251 | <p>In my model I have:</p>
<pre><code>validate :my_custom_validation
def my_custom_validation
errors.add_to_base("error message") if condition.exists?
end
</code></pre>
<p>I would like to add some parameters to mycustomer vaildation like so:</p>
<pre><code>validate :my_custom_validation, :parameter1 => x, :para... | [
{
"answer_id": 106267,
"author": "Bill Turner",
"author_id": 17773,
"author_profile": "https://Stackoverflow.com/users/17773",
"pm_score": 1,
"selected": false,
"text": "<p>You can just do something like this:</p>\n\n<pre><code>def validate\n errors.add('That particular field', 'can not... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1396/"
] | In my model I have:
```
validate :my_custom_validation
def my_custom_validation
errors.add_to_base("error message") if condition.exists?
end
```
I would like to add some parameters to mycustomer vaildation like so:
```
validate :my_custom_validation, :parameter1 => x, :parameter2 => y
```
How do I write the myc... | Validators usualy have an array parameter indicating, first, the fields to validate and lastly (if it exists) a hash with the options. In your example:
```
:my_custom_validation, parameter1: x, parameter2: y
```
:my\_custom\_validation would be a field name, while parameter1: x, parameter2: y would be a hash:
```
{... |
106,275 | <p>If I have a table field named 'description', what would be the SQL (using MS SQL) to get a list of records of all distinct words used in this field.</p>
<p>For example:</p>
<p>If the table contains the following for the 'description' field:</p>
<pre><code>Record1 "The dog jumped over the fence."
Record2 "The gian... | [
{
"answer_id": 106280,
"author": "Jeremy",
"author_id": 8557,
"author_profile": "https://Stackoverflow.com/users/8557",
"pm_score": 0,
"selected": false,
"text": "<p>it'd be a messy stored procedure with a temp table and a SELECT DISTINCT at the end.</p>\n\n<p>if you had the words alread... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/889/"
] | If I have a table field named 'description', what would be the SQL (using MS SQL) to get a list of records of all distinct words used in this field.
For example:
If the table contains the following for the 'description' field:
```
Record1 "The dog jumped over the fence."
Record2 "The giant tripped on the fence."
...... | I do not think you can do this with a SELECT. The best chance is to write a user defined function that returns a table with all the words and then do SELECT DISTINCT on it.
---
**Disclaimer:** Function **dbo.Split** is from <http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648>
```
CREATE TABLE test
(
id int i... |
106,298 | <p>You may think that this is a coincidence that the topic of my question is similar to the name of the forum but I actually got here by googling the term "stack overflow".</p>
<p>I use the OPNET network simulator in which I program using C. I think I am having a problem with big array sizes. It seems that I am hittin... | [
{
"answer_id": 106306,
"author": "Andrew Johnson",
"author_id": 5109,
"author_profile": "https://Stackoverflow.com/users/5109",
"pm_score": 3,
"selected": false,
"text": "<p>It may help if you post some code. Edit the question to include the problem function and the error.</p>\n\n<p>Mea... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You may think that this is a coincidence that the topic of my question is similar to the name of the forum but I actually got here by googling the term "stack overflow".
I use the OPNET network simulator in which I program using C. I think I am having a problem with big array sizes. It seems that I am hitting some sor... | It may help if you post some code. Edit the question to include the problem function and the error.
Meanwhile, here's a very generic answer:
The two principal causes of a stack overflow are 1) a recursive function, or 2) the allocation of a large number of local variables.
**Recursion**
if your function calls itsel... |
106,323 | <p>Anyone have a good set of sqlplus configuration directives to help transform a given sql query into nicely tab separated output for pulling into a spreadsheet or further processing?</p>
| [
{
"answer_id": 106398,
"author": "Eddie Awad",
"author_id": 17273,
"author_profile": "https://Stackoverflow.com/users/17273",
"pm_score": -1,
"selected": true,
"text": "<p>Check out the Oracle documentation:</p>\n\n<ul>\n<li><a href=\"http://68.142.116.68/docs/cd/B19306_01/server.102/b14... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19387/"
] | Anyone have a good set of sqlplus configuration directives to help transform a given sql query into nicely tab separated output for pulling into a spreadsheet or further processing? | Check out the Oracle documentation:
* [Formatting SQLPlus Reports](http://68.142.116.68/docs/cd/B19306_01/server.102/b14357/ch6.htm#i1081008)
* [Generating HTML Reports from SQLPlus](http://68.142.116.68/docs/cd/B19306_01/server.102/b14357/ch7.htm#sthref1452)
You can generate a tab in Oracle by using the tab's ASCII ... |
106,324 | <p>With the advent of new features like lambda expressions (inline code), does it mean we dont have to use delegates or anonymous methods anymore? In almost all the samples I have seen, it is for rewriting using the new syntax.</p>
<p>Any place where we still have to use delegates and lambda expressions won't work?</p... | [
{
"answer_id": 106348,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 3,
"selected": false,
"text": "<p>lambda is shortcut for anonymous delegate, but you will always be using delegates. the delegate specifies the methods sig... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19306/"
] | With the advent of new features like lambda expressions (inline code), does it mean we dont have to use delegates or anonymous methods anymore? In almost all the samples I have seen, it is for rewriting using the new syntax.
Any place where we still have to use delegates and lambda expressions won't work? | Yes there are places where directly using anonymous delegates and lambda expressions won't work.
If a method takes an untyped Delegate then the compiler doesn't know what to resolve the anonymous delegate/lambda expression to and you will get a compiler error.
```
public static void Invoke(Delegate d)
{
d.DynamicIn... |
106,336 | <p>I have a ArrayList made up of different elements imported from a db, made up of strings, numbers, doubles and ints. Is there a way to use a reflection type technique to find out what each type of data each element holds? </p>
<p>FYI: The reason that there is so many types of data is that this is a piece of java co... | [
{
"answer_id": 106350,
"author": "skiphoppy",
"author_id": 18103,
"author_profile": "https://Stackoverflow.com/users/18103",
"pm_score": 2,
"selected": false,
"text": "<p>Just call <code>.getClass()</code> on each <code>Object</code> in a loop.</p>\n\n<p>Unfortunately, Java doesn't have ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13491/"
] | I have a ArrayList made up of different elements imported from a db, made up of strings, numbers, doubles and ints. Is there a way to use a reflection type technique to find out what each type of data each element holds?
FYI: The reason that there is so many types of data is that this is a piece of java code being wr... | In C#:
Fixed with recommendation from [Mike](https://stackoverflow.com/users/14359/mike-brown)
```
ArrayList list = ...;
// List<object> list = ...;
foreach (object o in list) {
if (o is int) {
HandleInt((int)o);
}
else if (o is string) {
HandleString((string)o);
}
...
}
```
In ... |
106,367 | <p>What is the best way to add <strong>non-ASCII</strong> file names to a <strong>zip file</strong> using <strong>Java</strong>, in such a way that the files can be properly read in both <strong>Windows</strong> and <strong>Linux?</strong></p>
<p>Here is one attempt, adapted from <a href="https://truezip.dev.java.net/... | [
{
"answer_id": 106384,
"author": "stephbu",
"author_id": 12702,
"author_profile": "https://Stackoverflow.com/users/12702",
"pm_score": 0,
"selected": false,
"text": "<p>Did it actually fail or was just a font issue? (e.g. font having different glyphs for those charcodes) I've seen simi... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19392/"
] | What is the best way to add **non-ASCII** file names to a **zip file** using **Java**, in such a way that the files can be properly read in both **Windows** and **Linux?**
Here is one attempt, adapted from <https://truezip.dev.java.net/tutorial-6.html#Example>, which works in Windows Vista but fails in Ubuntu Hardy. I... | The encoding for the File-Entries in ZIP is originally specified as IBM Code Page 437. Many characters used in other languages are impossible to use that way.
The [PKWARE-specification](http://www.pkware.com/documents/casestudies/APPNOTE.TXT) refers to the problem and adds a bit. But that is a later addition (from 200... |
106,383 | <p>Suppose I have BaseClass with public methods A and B, and I create DerivedClass through inheritance.</p>
<p>e.g.</p>
<pre><code>public DerivedClass : BaseClass {}
</code></pre>
<p>Now I want to develop a method C in DerivedClass that uses A and B. Is there a way I can override methods A and B to be private in De... | [
{
"answer_id": 106392,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 0,
"selected": false,
"text": "<p>If they're defined public in the original class, you cannot override them to be private in your derived class. ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16866/"
] | Suppose I have BaseClass with public methods A and B, and I create DerivedClass through inheritance.
e.g.
```
public DerivedClass : BaseClass {}
```
Now I want to develop a method C in DerivedClass that uses A and B. Is there a way I can override methods A and B to be private in DerivedClass so that only method C i... | **It's not possible, why?**
In C#, it is forced upon you that if you inherit public methods, you must make them public. Otherwise they expect you not to derive from the class in the first place.
Instead of using the is-a relationship, you would have to use the has-a relationship.
The language designers don't allow ... |
106,387 | <p>I am writing a bash script to deal with some installations in an automated way... I have the possibility of getting one such program in 32 or 64 bit binary... is it possible to detect the machine architecture from bash so I can select the correct binary?</p>
<p>This will be for Ubuntu machines.</p>
| [
{
"answer_id": 106399,
"author": "shoover",
"author_id": 18356,
"author_profile": "https://Stackoverflow.com/users/18356",
"pm_score": 7,
"selected": true,
"text": "<p>Does</p>\n\n<pre><code>uname -a\n</code></pre>\n\n<p>give you anything you can use? I don't have a 64-bit machine to te... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I am writing a bash script to deal with some installations in an automated way... I have the possibility of getting one such program in 32 or 64 bit binary... is it possible to detect the machine architecture from bash so I can select the correct binary?
This will be for Ubuntu machines. | Does
```
uname -a
```
give you anything you can use? I don't have a 64-bit machine to test on.
---
**Note from Mike Stone:** This works, though specifically
```
uname -m
```
Will give "x86\_64" for 64 bit, and something else for other 32 bit types (in my 32 bit VM, it's "i686"). |
106,400 | <p>I have a list of ranked users, and would like to select the top 50. I also want to make sure one particular user is in this result set, even if they aren't in the top 50. Is there a sensible way to do this in a single mysql query? Or should I just check the results for the particular user and fetch him separately, i... | [
{
"answer_id": 106424,
"author": "Mariano",
"author_id": 2542,
"author_profile": "https://Stackoverflow.com/users/2542",
"pm_score": 2,
"selected": false,
"text": "<p>If I understand correctly, you could do:</p>\n\n<pre><code>select * from users order by max(rank) desc limit 0, 49 \nuni... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13636/"
] | I have a list of ranked users, and would like to select the top 50. I also want to make sure one particular user is in this result set, even if they aren't in the top 50. Is there a sensible way to do this in a single mysql query? Or should I just check the results for the particular user and fetch him separately, if n... | If I understand correctly, you could do:
```
select * from users order by max(rank) desc limit 0, 49
union
select * from users where user = x
```
This way you get 49 top users plus your particular user. |
106,401 | <p>The built-in <code>PHP</code> extension for <code>SOAP</code> doesn't validate everything in the incoming <code>SOAP</code> request against the <code>XML Schema</code> in the <code>WSDL</code>. It does check for the existence of basic entities, but when you have something complicated like <code>simpleType</code> res... | [
{
"answer_id": 108525,
"author": "user11087",
"author_id": 11087,
"author_profile": "https://Stackoverflow.com/users/11087",
"pm_score": 2,
"selected": false,
"text": "<p>Typically one doesn't validate against the WSDL. If the WSDL is designed properly there should be an underlying xml ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5726/"
] | The built-in `PHP` extension for `SOAP` doesn't validate everything in the incoming `SOAP` request against the `XML Schema` in the `WSDL`. It does check for the existence of basic entities, but when you have something complicated like `simpleType` restrictions the extension pretty much ignores their existence.
What is... | Been digging around on this matter a view hours.
Neither the native PHP SoapServer nore the NuSOAP Library does any Validation.
PHP SoapServer simply makes a type cast.
For Example if you define
```
<xsd:element name="SomeParameter" type="xsd:boolean" />
```
and submit
```
<get:SomeParameter>dfgdfg</get:SomeParam... |
106,425 | <p>How can I load an external JavaScript file using a bookmarklet? This would overcome the URL length limitations of IE and generally keep things cleaner.</p>
| [
{
"answer_id": 106438,
"author": "Miguel Ventura",
"author_id": 19401,
"author_profile": "https://Stackoverflow.com/users/19401",
"pm_score": 8,
"selected": true,
"text": "<h3>2015 Update</h3>\n\n<p><a href=\"https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Introducing_Content_S... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/401774/"
] | How can I load an external JavaScript file using a bookmarklet? This would overcome the URL length limitations of IE and generally keep things cleaner. | ### 2015 Update
[Content security policy](https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Introducing_Content_Security_Policy) will prevent this from working in many sites now. For example, the code below won't work on Facebook.
### 2008 answer
Use a bookmarklet that creates a script tag which includes you... |
106,437 | <p>I have a stateless bean something like:</p>
<pre><code>@Stateless
public class MyStatelessBean implements MyStatelessLocal, MyStatelessRemote {
@PersistenceContext(unitName="myPC")
private EntityManager mgr;
@TransationAttribute(TransactionAttributeType.SUPPORTED)
public void processObjects(List<... | [
{
"answer_id": 106483,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 0,
"selected": false,
"text": "<p>I think has to do with the <em>@TransationAttribute(TransactionAttributeType.Never)</em> on method <strong>process... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1458/"
] | I have a stateless bean something like:
```
@Stateless
public class MyStatelessBean implements MyStatelessLocal, MyStatelessRemote {
@PersistenceContext(unitName="myPC")
private EntityManager mgr;
@TransationAttribute(TransactionAttributeType.SUPPORTED)
public void processObjects(List<Object> objs) {
... | Another way to do it is actually having both methods on the same bean - and having an `@EJB` reference to itself! Something like that:
```
// supposing processObjects defined on MyStatelessRemote1 and process defined on MyStatelessLocal1
@Stateless
@TransationAttribute(TransactionAttributeType.NOT_SUPPORTED)
public cl... |
106,453 | <p>I've been working on an embedded C/C++ project recently using the shell in Tornado 2 as a way of debugging what's going on in our kit. The only problem with this approach is that it's a complicated system and as a result, has a fair bit of output. Tornado 'helpfully' scrolls the window every time some new informatio... | [
{
"answer_id": 106589,
"author": "Benoit",
"author_id": 10703,
"author_profile": "https://Stackoverflow.com/users/10703",
"pm_score": 1,
"selected": false,
"text": "<p>I am making the assumption that you are using the host shell to perform this.</p>\n\n<p>If you are running a test by lau... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15369/"
] | I've been working on an embedded C/C++ project recently using the shell in Tornado 2 as a way of debugging what's going on in our kit. The only problem with this approach is that it's a complicated system and as a result, has a fair bit of output. Tornado 'helpfully' scrolls the window every time some new information a... | here is another potential way:
```
-> saveFd = open("myfile.txt",0x102, 0777 )
-> oldFd = ioGlobalStdGet(1)
-> ioGlobalStdSet(1, saveFd)
-> runmytest()
...
-> ioGlobalStdSet(1, oldFd)
```
this will redirect **all** stdout activity to the file you opened.
You might have to play around with the file name of the open ... |
106,476 | <p>I have a setup executable that I need to install. When I run it, it launches a msi to do the actual install and then dies immediately. The side effect of this is it will return control back to any console you call it from before the install finishes. Depending on what machine I run it on, it can take from three to t... | [
{
"answer_id": 106601,
"author": "Jim Olsen",
"author_id": 15603,
"author_profile": "https://Stackoverflow.com/users/15603",
"pm_score": 2,
"selected": true,
"text": "<p>Would doing a WMI lookup of processes that have the initial setup as the parent process do the trick? For example, if... | 2008/09/19 | [
"https://Stackoverflow.com/questions/106476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a setup executable that I need to install. When I run it, it launches a msi to do the actual install and then dies immediately. The side effect of this is it will return control back to any console you call it from before the install finishes. Depending on what machine I run it on, it can take from three to ten ... | Would doing a WMI lookup of processes that have the initial setup as the parent process do the trick? For example, if I launch an MSI from a command prompt with process id 4000, I can execute the following command line to find information about msiexec process:
```
c:\>wmic PROCESS WHERE ParentProcessId=4000 GET Comma... |
106,481 | <p>I have this line in a javascript block in a page:</p>
<pre><code>res = foo('<%= @ruby_var %>');
</code></pre>
<p>What is the best way to handle the case where <code>@ruby_var</code> has a single-quote in it? Else it will break the JavaScript code.</p>
| [
{
"answer_id": 106518,
"author": "Max Cantor",
"author_id": 16034,
"author_profile": "https://Stackoverflow.com/users/16034",
"pm_score": 2,
"selected": false,
"text": "<pre><code>@ruby_var.gsub(/[']/, '\\\\\\\\\\'')\n</code></pre>\n\n<p>That will escape the single quote with an apostrop... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19409/"
] | I have this line in a javascript block in a page:
```
res = foo('<%= @ruby_var %>');
```
What is the best way to handle the case where `@ruby_var` has a single-quote in it? Else it will break the JavaScript code. | I think I'd use a ruby [JSON](http://json.org) library on @ruby\_var to get proper js syntax for the string and get rid of the '', fex.:
```
res = foo(<%= @ruby_var.to_json %>)
```
(after require "json"'ing, not entirely sure how to do that in the page or if the above syntax is correct as I havn't used that templati... |
106,508 | <p>What is a smart pointer and when should I use one?</p>
| [
{
"answer_id": 106515,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://en.wikipedia.org/wiki/Smart_pointer\" rel=\"noreferrer\">http://en.wikipedia.org/wiki/Smart_point... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19410/"
] | What is a smart pointer and when should I use one? | **UPDATE**
This answer is rather old, and so describes what was 'good' at the time, which was smart pointers provided by the Boost library. Since C++11, the standard library has provided sufficient smart pointers types, and so you should favour the use of [`std::unique_ptr`](http://en.cppreference.com/w/cpp/memory/uni... |
106,509 | <p>I have a button that I would like to disable when the form submits to prevent the user submitting multiple times.</p>
<p>I have tried naively disabling the button with javascript onclick but then if a client side validation that fails the button remains disabled.</p>
<p>How do I disable the button when the form su... | [
{
"answer_id": 106522,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 2,
"selected": false,
"text": "<p>Disable the button at the very end of your submit handler. If the validation fails, it should return false before that.</p>\... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6600/"
] | I have a button that I would like to disable when the form submits to prevent the user submitting multiple times.
I have tried naively disabling the button with javascript onclick but then if a client side validation that fails the button remains disabled.
How do I disable the button when the form successfully submit... | Give this a whirl:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Id... |
106,534 | <p>The default rails XML builder escapes all HTML, so something like:</p>
<pre class="lang-ruby prettyprint-override"><code>atom_feed do |feed|
@stories.each do |story|
feed.entry story do |entry|
entry.title story.title
entry.content "<b>foo</b>"
end
end
end
</code></pre... | [
{
"answer_id": 106616,
"author": "Shalmanese",
"author_id": 14559,
"author_profile": "https://Stackoverflow.com/users/14559",
"pm_score": 4,
"selected": true,
"text": "<p>turns out you need to do </p>\n\n<pre><code>entry.content \"<b>foo</b>\", :type => \"html\"\n</code></... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14559/"
] | The default rails XML builder escapes all HTML, so something like:
```ruby
atom_feed do |feed|
@stories.each do |story|
feed.entry story do |entry|
entry.title story.title
entry.content "<b>foo</b>"
end
end
end
```
will produce the text:
```html
<b>foo</b>
```
instead of: **foo*... | turns out you need to do
```
entry.content "<b>foo</b>", :type => "html"
```
althought wrapping it in a CDATA stops it working. |
106,544 | <p>I get the following error when trying to run the latest Cygwin version of rsync in Windows XP SP2. The error occurs for attempts at both local syncs (that is: source and destination on the local harddisk only) and remote syncs (using "-e ssh" from the openssh package). Any advice on how to fix/workaround it?</p>
<p... | [
{
"answer_id": 106736,
"author": "Niall",
"author_id": 6049,
"author_profile": "https://Stackoverflow.com/users/6049",
"pm_score": 1,
"selected": true,
"text": "<p>Not really an answer to your question, but I've found <a href=\"http://www.aboutmyip.com/AboutMyXApp/DeltaCopy.jsp\" rel=\"n... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19417/"
] | I get the following error when trying to run the latest Cygwin version of rsync in Windows XP SP2. The error occurs for attempts at both local syncs (that is: source and destination on the local harddisk only) and remote syncs (using "-e ssh" from the openssh package). Any advice on how to fix/workaround it?
```
bash... | Not really an answer to your question, but I've found [Delta Copy](http://www.aboutmyip.com/AboutMyXApp/DeltaCopy.jsp) to be a much better option than messing around with Cygwin. It connects to regular rsync daemons too. |
106,554 | <p>I use this code in my Windows Service to be notified of USB disk drives being inserted and removed:</p>
<pre><code>WqlEventQuery query = new WqlEventQuery("__InstanceOperationEvent",
"TargetInstance ISA 'Win32_LogicalDisk' AND TargetInstance.DriveType=2");
query.WithinInterval = TimeSpan.FromSeconds(1);
_devic... | [
{
"answer_id": 106775,
"author": "Andrew Queisser",
"author_id": 18321,
"author_profile": "https://Stackoverflow.com/users/18321",
"pm_score": 2,
"selected": false,
"text": "<p>Not sure if this applies to your case but we've been using RegisterDeviceNotification in our C# code (which I c... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14842/"
] | I use this code in my Windows Service to be notified of USB disk drives being inserted and removed:
```
WqlEventQuery query = new WqlEventQuery("__InstanceOperationEvent",
"TargetInstance ISA 'Win32_LogicalDisk' AND TargetInstance.DriveType=2");
query.WithinInterval = TimeSpan.FromSeconds(1);
_deviceWatcher = new... | Not sure if this applies to your case but we've been using RegisterDeviceNotification in our C# code (which I can't post here) to detect when USB devices are plugged in. There's a handful of native functions you have to import but it generally works well. Easiest to make it work in C++ first and then see what you have ... |
106,555 | <p>I have a Perl script where I maintain a very simple cache using a hash table. I would like to clear the hash once it occupies more than n bytes, to avoid Perl (32-bit) running out of memory and crashing. </p>
<p>I can do a check on the number of keys-value pairs:</p>
<pre><code>if (scalar keys %cache > $maxSize... | [
{
"answer_id": 106565,
"author": "mbac32768",
"author_id": 18446,
"author_profile": "https://Stackoverflow.com/users/18446",
"pm_score": 4,
"selected": false,
"text": "<p>You're looking for <a href=\"http://search.cpan.org/perldoc?Devel::Size\" rel=\"nofollow noreferrer\">Devel::Size</a>... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5734/"
] | I have a Perl script where I maintain a very simple cache using a hash table. I would like to clear the hash once it occupies more than n bytes, to avoid Perl (32-bit) running out of memory and crashing.
I can do a check on the number of keys-value pairs:
```
if (scalar keys %cache > $maxSize)
{
%cache = ();
}
`... | [Devel::Size](http://search.cpan.org/perldoc?Devel::Size) is the answer to your question. (Note that Devel::Size will temporarily allocate a significant amount of memory when processing a large data structure, so it's not really well suited to this purpose.)
However, [Cache::SizeAwareMemoryCache](http://search.cpan.or... |
106,563 | <p>I'd like to log the output of a command to <code>stdout</code> as well as to a log file. I've got Cygwin installed and I'm trying to use the <code>tee</code> command to accomplish this.</p>
<pre><code>devenv mysolution.sln /build myproject "Release|Win32" | tee build.log
</code></pre>
<p>Trouble is that <code>tee<... | [
{
"answer_id": 106575,
"author": "Sam Reynolds",
"author_id": 9192,
"author_profile": "https://Stackoverflow.com/users/9192",
"pm_score": 2,
"selected": false,
"text": "<p>You can output to the file and tail -f the file.</p>\n\n<p>devenv mysolution.sln /build myproject \"Release|Win32\" ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4790/"
] | I'd like to log the output of a command to `stdout` as well as to a log file. I've got Cygwin installed and I'm trying to use the `tee` command to accomplish this.
```
devenv mysolution.sln /build myproject "Release|Win32" | tee build.log
```
Trouble is that `tee` seems to insist on waiting for the end of file befor... | >
> tee seems to insist on waiting for the
> end of file before outputting anything
> to either stdout or the log file.
>
>
>
This should definitely not be happening - it would render tee nearly useless. Here's a simple test that I wrote that puts this to the test, and it's definitely not waiting for eof.
```
... |
106,622 | <p>I'm trying to run the Tomcat with JBoss Embedded jpa booking example. I run the build and deploy the war. I then get the following error:</p>
<pre>
ERROR [catalina.core.ContainerBase.[Catalina].[localhost].[/jboss-seam-jpa]] Error configuring application listener of class com.sun.faces.config.ConfigureListener
ja... | [
{
"answer_id": 107003,
"author": "user17163",
"author_id": 17163,
"author_profile": "https://Stackoverflow.com/users/17163",
"pm_score": 0,
"selected": false,
"text": "<p>have you looked at the docs, there's also some pretty good info on the forums at www.seamframework.org and also the o... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5917/"
] | I'm trying to run the Tomcat with JBoss Embedded jpa booking example. I run the build and deploy the war. I then get the following error:
```
ERROR [catalina.core.ContainerBase.[Catalina].[localhost].[/jboss-seam-jpa]] Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.No... | I got this to work. I ran ant tomcat55 under the seam/examples/jpa example. This included the el-*.jars needed. I then ran 'ant clean' and 'ant jboss-embeded' and manually copied in all of the el-*.jars from the tomcat55 make. This got past my problem above. Now I'm able to start tomcat 5.5.9 with embedded JBoss. I can... |
106,630 | <p>I start by creating a string variable with some <strong>non-ascii</strong> <em>utf-8</em> encoded data on it:</p>
<pre><code>>>> text = 'á'
>>> text
'\xc3\xa1'
>>> text.decode('utf-8')
u'\xe1'
</code></pre>
<p>Using <code>unicode()</code> on it raises errors...</p>
<pre><code>>>&g... | [
{
"answer_id": 106640,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 3,
"selected": false,
"text": "<p><code>unicode</code> does not guess the encoding of your text. If your object can print itself as <code>unicode</co... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17160/"
] | I start by creating a string variable with some **non-ascii** *utf-8* encoded data on it:
```
>>> text = 'á'
>>> text
'\xc3\xa1'
>>> text.decode('utf-8')
u'\xe1'
```
Using `unicode()` on it raises errors...
```
>>> unicode(text)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeE... | The behaviour does seem confusing, but intensional. I reproduce here the entirety of the unicode documentation from the [Python Built-In Functions documentation](http://docs.python.org/lib/built-in-funcs.html) (for version 2.5.2, as I write this):
>
> **unicode([object[, encoding [, errors]]])**
>
>
> Return the Un... |
106,646 | <p>I am looking for a CSS-based web page template where the main content <code>div</code> occupies the full height of the view port (minus header and footer heights) when its content has few lines. The footer should be at the bottom of the viewport, rather than right below content, where it's more in the middle of the ... | [
{
"answer_id": 106689,
"author": "Ross Martin",
"author_id": 19433,
"author_profile": "https://Stackoverflow.com/users/19433",
"pm_score": 3,
"selected": true,
"text": "<p>Example here:\n<a href=\"http://www.rossdmartin.com/aitp/index.htm\" rel=\"nofollow noreferrer\">http://www.rossdmar... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5232/"
] | I am looking for a CSS-based web page template where the main content `div` occupies the full height of the view port (minus header and footer heights) when its content has few lines. The footer should be at the bottom of the viewport, rather than right below content, where it's more in the middle of the viewport. Cont... | Example here:
<http://www.rossdmartin.com/aitp/index.htm>
More in-depth resources:
* <http://www.themaninblue.com/experiment/footerStickAlt/>
* <http://ryanfait.com/sticky-footer/> |
106,711 | <p>Here's a simplified version of what I'm trying to do :</p>
<ol>
<li>Before any other actions are performed, present the user with a form to retrieve a string.</li>
<li>Input the string, and then redirect to the default controller action (e.g. index). The string only needs to exist, no other validations are necessa... | [
{
"answer_id": 106757,
"author": "Toby Hede",
"author_id": 14971,
"author_profile": "https://Stackoverflow.com/users/14971",
"pm_score": 3,
"selected": true,
"text": "<p>Part of the problem is that you aren't setting @string. You don't really need the before_filter for this at all, and s... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17046/"
] | Here's a simplified version of what I'm trying to do :
1. Before any other actions are performed, present the user with a form to retrieve a string.
2. Input the string, and then redirect to the default controller action (e.g. index). The string only needs to exist, no other validations are necessary.
3. The string mu... | Part of the problem is that you aren't setting @string. You don't really need the before\_filter for this at all, and should just be able to use:
```
def get_string
@string = params[:string] || session[:string]
respond_to do |format|
if @string
format.html {redirect_to(accounts_url)} # authenticate.ht... |
106,712 | <p>I have a VB.NET Windows Forms project that at one point paints text directly to onto the form at runtime. Before I paint with the font though, I want to make sure that the font and font-size exists on the user's machine. If they don't, I'll try a few other similar fonts, eventually defaulting with Arial or something... | [
{
"answer_id": 106724,
"author": "Charlie",
"author_id": 18529,
"author_profile": "https://Stackoverflow.com/users/18529",
"pm_score": 4,
"selected": true,
"text": "<p>From an MSDN article titled \"How To: Enumerate Installed Fonts\", I found this code:</p>\n\n<pre>\n<code>\n\nInstalledF... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5473/"
] | I have a VB.NET Windows Forms project that at one point paints text directly to onto the form at runtime. Before I paint with the font though, I want to make sure that the font and font-size exists on the user's machine. If they don't, I'll try a few other similar fonts, eventually defaulting with Arial or something.
... | From an MSDN article titled "How To: Enumerate Installed Fonts", I found this code:
```
InstalledFontCollection installedFontCollection = new InstalledFontCollection();
// Get the array of FontFamily objects.
FontFamily[] fontFamilies = installedFontCollection.Families;
``` |
106,800 | <p>Does anyone know of where to find unit testing guidelines and recommendations? I'd like to have something which addresses the following types of topics (for example):</p>
<ul>
<li>Should tests be in the same project as application logic?</li>
<li>Should I have test classes to mirror my logic classes or should I ha... | [
{
"answer_id": 106806,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 1,
"selected": false,
"text": "<p>I insistently recommend you to read <a href=\"https://rads.stackoverflow.com/amzn/click/com/0321146530\" rel=\"nofollow noref... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19421/"
] | Does anyone know of where to find unit testing guidelines and recommendations? I'd like to have something which addresses the following types of topics (for example):
* Should tests be in the same project as application logic?
* Should I have test classes to mirror my logic classes or should I have only as many test c... | I would recommend [Kent Beck's](https://rads.stackoverflow.com/amzn/click/com/0321146530) book on TDD.
Also, you need to go to [Martin Fowler's](http://martinfowler.com/articles/mocksArentStubs.html) site. He has a lot of good information about testing as well.
We are pretty big on TDD so I will answer the questions ... |
106,828 | <p>I need to display a bunch of images on a web page using AJAX. All of them have different dimensions, so I want to adjust their size before displaying them. Is there any way to do this in JavaScript?</p>
<p>Using PHP's <code>getimagesize()</code> for each image causes an unnecessary performance hit since there will ... | [
{
"answer_id": 106833,
"author": "Dori",
"author_id": 10936,
"author_profile": "https://Stackoverflow.com/users/10936",
"pm_score": 0,
"selected": false,
"text": "<p>Do you want to adjust the images themselves, or just the way they display? If the former, you want something on the server... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to display a bunch of images on a web page using AJAX. All of them have different dimensions, so I want to adjust their size before displaying them. Is there any way to do this in JavaScript?
Using PHP's `getimagesize()` for each image causes an unnecessary performance hit since there will be many images. | I was searching a solution to get height and width of an image using JavaScript. I found many, but all those solutions only worked when the image was present in browser cache.
Finally I found a solution to get the image height and width even if the image does not exist in the browser cache:
```
<script type="text/jav... |
106,880 | <p>I am trying to use the <code>InternalsVisibleTo</code> assembly attribute to make my internal classes in a .NET class library visible to my unit test project. For some reason, I keep getting an error message that says:</p>
<blockquote>
<p>'MyClassName' is inaccessible due to its protection level</p>
</blockquote... | [
{
"answer_id": 106921,
"author": "Ash",
"author_id": 5023,
"author_profile": "https://Stackoverflow.com/users/5023",
"pm_score": 2,
"selected": false,
"text": "<p>You need to use the /out: compiler switch when compiling the friend assembly (the assembly that\ndoes not contain the Interna... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14101/"
] | I am trying to use the `InternalsVisibleTo` assembly attribute to make my internal classes in a .NET class library visible to my unit test project. For some reason, I keep getting an error message that says:
>
> 'MyClassName' is inaccessible due to its protection level
>
>
>
Both assemblies are signed and I have ... | Are you absolutely sure you have the correct public key specified in the attribute?
Note that you need to specify the full public key, not just the public key token. It looks something like:
```
[assembly: InternalsVisibleTo("MyFriendAssembly,
PublicKey=0024000004800000940000000602000000240000525341310004000001000100F... |
106,896 | <p>I'm used to the Java model where you can have one public class per file. Python doesn't have this restriction, and I'm wondering what's the best practice for organizing classes.</p>
| [
{
"answer_id": 106903,
"author": "Jason Baker",
"author_id": 2147,
"author_profile": "https://Stackoverflow.com/users/2147",
"pm_score": 3,
"selected": false,
"text": "<p>I would say to put as many classes as can be logically grouped in that file without making it too big and complex.</p... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14139/"
] | I'm used to the Java model where you can have one public class per file. Python doesn't have this restriction, and I'm wondering what's the best practice for organizing classes. | A Python file is called a "module" and it's one way to organize your software so that it makes "sense". Another is a directory, called a "package".
A module is a distinct thing that may have one or two dozen closely-related classes. The trick is that a module is something you'll import, and you need that import to be ... |
106,907 | <p>We put all of our unit tests in their own projects. We find that we have to make certain classes public instead of internal just for the unit tests. Is there anyway to avoid having to do this. What are the memory implication by making classes public instead of sealed?</p>
| [
{
"answer_id": 106933,
"author": "TraumaPony",
"author_id": 18658,
"author_profile": "https://Stackoverflow.com/users/18658",
"pm_score": -1,
"selected": false,
"text": "<p>Classes can be both public AND sealed.</p>\n\n<p>But, don't do that.</p>\n\n<p>You can create a tool to reflect ove... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | We put all of our unit tests in their own projects. We find that we have to make certain classes public instead of internal just for the unit tests. Is there anyway to avoid having to do this. What are the memory implication by making classes public instead of sealed? | If you're using .NET, the [InternalsVisibleTo](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx) assembly attribute allows you to create "friend" assemblies. These are specific strongly named assemblies that are allowed to access internal classes and members of th... |
106,912 | <p>How do you draw a custom button next to the minimize, maximize and close buttons within the Titlebar of the Form?</p>
<p>I know you need to use Win32 API calls and override the WndProc procedure, but I haven't been able to figure out a solution that works right.</p>
<p>Does anyone know how to do this? More specifi... | [
{
"answer_id": 107195,
"author": "Matthew Scharley",
"author_id": 15537,
"author_profile": "https://Stackoverflow.com/users/15537",
"pm_score": 1,
"selected": false,
"text": "<p>Drawing seems to be the easy part, the following will do that:</p>\n\n<p>[Edit: Code removed, see my other ans... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7831/"
] | How do you draw a custom button next to the minimize, maximize and close buttons within the Titlebar of the Form?
I know you need to use Win32 API calls and override the WndProc procedure, but I haven't been able to figure out a solution that works right.
Does anyone know how to do this? More specifically, does anyon... | The following will work in XP, I have no Vista machine handy to test it, but I think your issues are steming from an incorrect hWnd somehow. Anyway, on with the poorly commented code.
```
// The state of our little button
ButtonState _buttState = ButtonState.Normal;
Rectangle _buttPosition = new Rectangle();
[DllImpo... |