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 |
|---|---|---|---|---|---|---|
437,086 | <p>I'm trying to fix a bug in a rich text editor I'm using, which causes <code><embed></code> tags to be inserted without their closing tag (which screws the output up completely). I've isolated the problem to this operation:</p>
<pre><code>// body is a <body> tag
body.innerHTML = '<embed src="http://ex... | [
{
"answer_id": 437138,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 4,
"selected": true,
"text": "<p>This might not be an answer to your problem, but <em><embed></em> was not part of any standardized version of HTML un... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20760/"
] | I'm trying to fix a bug in a rich text editor I'm using, which causes `<embed>` tags to be inserted without their closing tag (which screws the output up completely). I've isolated the problem to this operation:
```
// body is a <body> tag
body.innerHTML = '<embed src="http://example.com/whatever"></embed>';
```
No ... | This might not be an answer to your problem, but *<embed>* was not part of any standardized version of HTML until HTML5, according to [W3C](http://validator.w3.org/docs/help.html). |
437,093 | <p>Does anyone know about a free open source library (utility class) which allows you to compare two instances of one Java bean and return a list/array of properties which values are different in those two instances? Please post a small sample.</p>
<p>Cheers<br>
Tomas</p>
| [
{
"answer_id": 437205,
"author": "Fernando Miguélez",
"author_id": 34880,
"author_profile": "https://Stackoverflow.com/users/34880",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://commons.apache.org/proper/commons-beanutils/javadocs/v1.8.3/apidocs/org/apache/commons/beanu... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Does anyone know about a free open source library (utility class) which allows you to compare two instances of one Java bean and return a list/array of properties which values are different in those two instances? Please post a small sample.
Cheers
Tomas | [BeanComparator](http://commons.apache.org/proper/commons-beanutils/javadocs/v1.8.3/apidocs/org/apache/commons/beanutils/BeanComparator.html) of Apache commons is what you are looking for.
**Update**. A simple example that compares JavaBeans with one property (comparation is made agains only one property, you should c... |
437,113 | <p>I'm creating a color object using the following code.</p>
<pre><code>curView.backgroundColor = [[UIColor alloc] initWithHue:229 saturation:40 brightness:75 alpha:1];
</code></pre>
<p>How can I retrieve RGB values from the created color object?</p>
| [
{
"answer_id": 437196,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 7,
"selected": true,
"text": "<pre><code>const CGFloat *colors = CGColorGetComponents( curView.backgroundColor.CGColor );\n</code></pre>\n\n<p>These li... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54195/"
] | I'm creating a color object using the following code.
```
curView.backgroundColor = [[UIColor alloc] initWithHue:229 saturation:40 brightness:75 alpha:1];
```
How can I retrieve RGB values from the created color object? | ```
const CGFloat *colors = CGColorGetComponents( curView.backgroundColor.CGColor );
```
These links provide further details:
* [UIColor Reference](https://developer.apple.com/documentation/uikit/uicolor?language=objc)
* [CGColorGetComponents reference](https://developer.apple.com/documentation/coregraphics/1455930-... |
437,117 | <p>I hope to find a way to get the value in the Nth column of a dataset. </p>
<p>Thus, for N = 6 I want</p>
<pre><code>SELECT (Column6Value) from MyTable where MyTable.RowID = 14
</code></pre>
<p>Is there a way to do this in TSQL as implemented in SQL Server 2005? Thanks.</p>
| [
{
"answer_id": 437142,
"author": "Michael Sharek",
"author_id": 1958,
"author_profile": "https://Stackoverflow.com/users/1958",
"pm_score": 4,
"selected": true,
"text": "<p>You should be able to join with the system catalog (Information_Schema.Columns) to get the column number.</p>\n"
... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35615/"
] | I hope to find a way to get the value in the Nth column of a dataset.
Thus, for N = 6 I want
```
SELECT (Column6Value) from MyTable where MyTable.RowID = 14
```
Is there a way to do this in TSQL as implemented in SQL Server 2005? Thanks. | You should be able to join with the system catalog (Information\_Schema.Columns) to get the column number. |
437,122 | <p>For my brand new ORM (<a href="http://code.google.com/p/chibiorm/" rel="nofollow noreferrer">chibi-ORM</a>) I face a design decision.</p>
<p>I'm building the API for relationships, like:</p>
<pre><code>@interface SamplePerson : DbObject {
NSString *name;
DbObjectRelation *cities;
}
</code></pre>
<p>No... | [
{
"answer_id": 437223,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 3,
"selected": true,
"text": "<p>Using a set of class accessors/mutators around a static variable like you're currently doing is pretty reasonab... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53185/"
] | For my brand new ORM ([chibi-ORM](http://code.google.com/p/chibiorm/)) I face a design decision.
I'm building the API for relationships, like:
```
@interface SamplePerson : DbObject {
NSString *name;
DbObjectRelation *cities;
}
```
Now, for `DbObjectRelation` I have this mockup:
```
@interface DbObject... | Using a set of class accessors/mutators around a static variable like you're currently doing is pretty reasonable. Another pretty common solution if you're not going to change the database name would be to put it in a separate file, say Constants.h, along with other constant strings like dictionary and user defaults ke... |
437,137 | <p>I'm trying get values from a GridView using the following code:</p>
<pre><code>foreach (GridViewRow row in this.dgvEstudios.Rows)
{
var xy = row.Cells[1].Text;
}
</code></pre>
<p>Always get a an empty string (<code>""</code>) as the value returned from <code>.Text</code>, why does this happen? I have set <code... | [
{
"answer_id": 437155,
"author": "Jeff Martin",
"author_id": 13100,
"author_profile": "https://Stackoverflow.com/users/13100",
"pm_score": 1,
"selected": false,
"text": "<p>it could depend on many things.. Where is this code fired in relation to when the GridView is populated (Databind(... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1388553/"
] | I'm trying get values from a GridView using the following code:
```
foreach (GridViewRow row in this.dgvEstudios.Rows)
{
var xy = row.Cells[1].Text;
}
```
Always get a an empty string (`""`) as the value returned from `.Text`, why does this happen? I have set `EnableViewState` to `true` | The cell might have controls inside it (e.g. LiteralControl or an HyperLink). This is what you should be looking for.
`row.Cells[1].Controls` collection, you should look for. |
437,150 | <pre><code>template<typename T, size_t n>
size_t array_size(const T (&)[n])
{
return n;
}
</code></pre>
<p>The part that I don't get is the parameters for this template function. What happens with the array when I pass it through there that gives <code>n</code> as the number of elements in the array?</p>... | [
{
"answer_id": 437154,
"author": "MSN",
"author_id": 6210,
"author_profile": "https://Stackoverflow.com/users/6210",
"pm_score": 1,
"selected": false,
"text": "<p>Nothing happens to the array. It's an unused parameter that is used to resolve the signature of the template function.</p>\n\... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54359/"
] | ```
template<typename T, size_t n>
size_t array_size(const T (&)[n])
{
return n;
}
```
The part that I don't get is the parameters for this template function. What happens with the array when I pass it through there that gives `n` as the number of elements in the array? | Well, first you have to understand that trying to get a value out of an array can give you a pointer to its first element:
```
int a[] = {1, 2, 3};
int *ap = a; // a pointer, size is lost
int (&ar)[3] = a; // a reference to the array, size is not lost
```
References refer to objects using their exact type or their b... |
437,166 | <p>I've models for <code>Books</code>, <code>Chapters</code> and <code>Pages</code>. They are all written by a <code>User</code>:</p>
<pre><code>from django.db import models
class Book(models.Model)
author = models.ForeignKey('auth.User')
class Chapter(models.Model)
author = models.ForeignKey('auth.User')
... | [
{
"answer_id": 437251,
"author": "Sergey Golovchenko",
"author_id": 26592,
"author_profile": "https://Stackoverflow.com/users/26592",
"pm_score": 3,
"selected": false,
"text": "<p>I haven't tried it in django but python's <a href=\"http://docs.python.org/library/copy.html\" rel=\"norefer... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37522/"
] | I've models for `Books`, `Chapters` and `Pages`. They are all written by a `User`:
```
from django.db import models
class Book(models.Model)
author = models.ForeignKey('auth.User')
class Chapter(models.Model)
author = models.ForeignKey('auth.User')
book = models.ForeignKey(Book)
class Page(models.Model)... | This no longer works in Django 1.3 as CollectedObjects was removed. See [changeset 14507](http://code.djangoproject.com/changeset/14507)
[I posted my solution on Django Snippets.](http://www.djangosnippets.org/snippets/1282/) It's based heavily on the [`django.db.models.query.CollectedObject`](http://code.djangoprojec... |
437,180 | <p>I am trying to return the result that I found in my query to the ASP.net table. How do I do that? I already have the query, I am just having trouble getting the count result back. </p>
<pre><code>string configMan.ConnString["connect"].ToString();
iDB2Conn temp = new iDB2Conn
string query = "select Count(*) as to... | [
{
"answer_id": 437208,
"author": "Joe Doyle",
"author_id": 13793,
"author_profile": "https://Stackoverflow.com/users/13793",
"pm_score": 0,
"selected": false,
"text": "<p>In ADO.Net, the simplest way is to use the ExecuteScalar() method on your command which returns a single result. You... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54197/"
] | I am trying to return the result that I found in my query to the ASP.net table. How do I do that? I already have the query, I am just having trouble getting the count result back.
```
string configMan.ConnString["connect"].ToString();
iDB2Conn temp = new iDB2Conn
string query = "select Count(*) as total from test";
.... | This is where the SqlCommand object comes in handy.
```
int result = 0;
using(SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand sql = new SqlCommand("SELECT COUNT(*) FROM test", conn);
result = (int)sql.ExecuteScalar();
}
``` |
437,193 | <p>I'm using logos as just an example.</p>
<p>I'm trying to use themes/skins for the first time in ASP.NET - and just trying to figure out exactly what they will allow me to do.</p>
<p>As far as i can tell themes are primarily for changing controls like buttons, which can be modified using images. But is there a way ... | [
{
"answer_id": 437268,
"author": "Jeff Martin",
"author_id": 13100,
"author_profile": "https://Stackoverflow.com/users/13100",
"pm_score": 0,
"selected": false,
"text": "<p>using the themes you could easily set the source of an Image ASP.NET control to be different per theme. (also the s... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | I'm using logos as just an example.
I'm trying to use themes/skins for the first time in ASP.NET - and just trying to figure out exactly what they will allow me to do.
As far as i can tell themes are primarily for changing controls like buttons, which can be modified using images. But is there a way I can skin a 'log... | You can easily set an image/logo using themes/skins. E.g. if you have an image control like this:
```
<asp:Image id="imgLogo" runat="server" SkinId="logo" ... />
```
In your skin files, you can then specifiy the image to be displayed, e.g. in App\_Themes/theme1/logo.skin:
```
<asp:Image runat="server" SkinId="logo"... |
437,207 | <p>I'm running the following query in Hypersonic DB (HSQLDB):</p>
<pre><code>SELECT (CASE foo WHEN 'a' THEN 'bar' WHEN 'b' THEN 'biz' ....
ELSE 'fin' END ) FROM MyTable LIMIT 1
</code></pre>
<p>When the number of "WHEN" clauses exceeds about 1000, I get a Java <code>StackOverflowError</code> thrown by the JDB... | [
{
"answer_id": 437259,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": true,
"text": "<p>You should never get anywhere near 1000 terms in a <code>CASE</code> statement. Long before that, you should put th... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4926/"
] | I'm running the following query in Hypersonic DB (HSQLDB):
```
SELECT (CASE foo WHEN 'a' THEN 'bar' WHEN 'b' THEN 'biz' ....
ELSE 'fin' END ) FROM MyTable LIMIT 1
```
When the number of "WHEN" clauses exceeds about 1000, I get a Java `StackOverflowError` thrown by the JDBC driver in `org.hsqldb.jdbc.Util.sql... | You should never get anywhere near 1000 terms in a `CASE` statement. Long before that, you should put the other values into a separate table and pick them by joining.
```
INSERT INTO MappingTable (foo, string) VALUES
('a', 'bar'), ('b', 'biz'), ...
SELECT COALESCE(m.string, 'fin')
FROM MyTable t LEFT OUTER JOIN Map... |
437,219 | <p>I have something like this</p>
<pre><code>src/sim/simulate.cc
41d40
< #include "mem/mem-interface.h"
90,91d88
< dram_print_stats_common(curTick/500);
<
src/mem/physical.hh
52d51
< public:
55,56d53
< public:
<
58a56,57
> public:
>
61,62c60,61
< virtual boo... | [
{
"answer_id": 437241,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 6,
"selected": false,
"text": "<p>I believe that <code>diff -u oldfile newfile > a.patch</code> is used to create patch files, although some other s... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39160/"
] | I have something like this
```
src/sim/simulate.cc
41d40
< #include "mem/mem-interface.h"
90,91d88
< dram_print_stats_common(curTick/500);
<
src/mem/physical.hh
52d51
< public:
55,56d53
< public:
<
58a56,57
> public:
>
61,62c60,61
< virtual bool recvTiming(PacketPtr pkt); //baoyg
<
--... | I believe that `diff -u oldfile newfile > a.patch` is used to create patch files, although some other switched may be thrown in as well (-N?).
Edit: OK, 4 years later and finally going to explain what the switches mean:
`-u` creates a [Unified](http://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.htm... |
437,233 | <p>After doing some work with Ruby, Rails, and RSpec last summer and I learned to <a href="http://smartic.us/2008/8/15/tatft-i-feel-a-revolution-coming-on" rel="nofollow noreferrer">TATFT</a>. Now I can't write code without writing tests first.</p>
<p>I'm taking a programming course in C next year, and I would like to... | [
{
"answer_id": 437253,
"author": "MattK",
"author_id": 52734,
"author_profile": "https://Stackoverflow.com/users/52734",
"pm_score": 1,
"selected": false,
"text": "<p>There are a number of unit testing harnesses for C. Wikipedia has a much better list than I could assemble <a href=\"htt... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53589/"
] | After doing some work with Ruby, Rails, and RSpec last summer and I learned to [TATFT](http://smartic.us/2008/8/15/tatft-i-feel-a-revolution-coming-on). Now I can't write code without writing tests first.
I'm taking a programming course in C next year, and I would like to learn to write C test-driven. Is it a good ide... | >
> Is it a good idea (or even possible) to do TDD with C?
>
>
>
Yes, it obviously is a good idea, as with other languages. However, due to the procedural nature of the language, it comes with its some more difficulties.
* Static functions quickly get in the way. This can be solved by including the source file ... |
437,256 | <pre><code>if (strstr($_SERVER['REQUEST_URI'],'index.php')) {
header('HTTP/1.0 404 Not Found');
}
</code></pre>
<p>Why wont this work? I get a blank page.</p>
| [
{
"answer_id": 437282,
"author": "Bob Fanger",
"author_id": 19165,
"author_profile": "https://Stackoverflow.com/users/19165",
"pm_score": 6,
"selected": false,
"text": "<p><strong>That is correct behaviour</strong>, it's up to you to create the contents for the 404 page.<br>\nThe 404 hea... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
if (strstr($_SERVER['REQUEST_URI'],'index.php')) {
header('HTTP/1.0 404 Not Found');
}
```
Why wont this work? I get a blank page. | Your code is technically correct. If you looked at the headers of that blank page, you'd see a 404 header, and other computers/programs would be able to correctly identify the response as file not found.
Of course, your users are still SOL. Normally, 404s are handled by the web server.
* User: Hey, do you have anyth... |
437,262 | <p>I have a longish list of files opened in vim that looks like this:</p>
<pre><code>/dir1/file1
/dir2/file2
/dir2/file3
.....
</code></pre>
<p>How can I open all of them one by one the easiest way possible in the same session of vim either with split or edit?</p>
| [
{
"answer_id": 437274,
"author": "ng.",
"author_id": 21896,
"author_profile": "https://Stackoverflow.com/users/21896",
"pm_score": 3,
"selected": false,
"text": "<p>You can do the following</p>\n\n<pre><code>cat file | xargs vim\n</code></pre>\n\n<p>Where \"file\" contains your list of f... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23080/"
] | I have a longish list of files opened in vim that looks like this:
```
/dir1/file1
/dir2/file2
/dir2/file3
.....
```
How can I open all of them one by one the easiest way possible in the same session of vim either with split or edit? | I'd say with -p for tabs
```
vim -p `cat yourlistoffiles`
``` |
437,279 | <p>I looked in <a href="http://www.google.com/search?q=advanced+programming+in+the+unix+environment&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a" rel="noreferrer">Stevens</a>, and in the <a href="https://rads.stackoverflow.com/amzn/click/com/0937175730" rel="noreferrer" rel... | [
{
"answer_id": 437292,
"author": "ChrisW",
"author_id": 49942,
"author_profile": "https://Stackoverflow.com/users/49942",
"pm_score": 1,
"selected": false,
"text": "<p>In my experience, the C run time library is initialized before the run-time invokes the initializers of your static vari... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3778/"
] | I looked in [Stevens](http://www.google.com/search?q=advanced+programming+in+the+unix+environment&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a), and in the [Posix Programmer's Guide](https://rads.stackoverflow.com/amzn/click/com/0937175730), and the best I can find is
>
> An array of strings... | I think you can run your program with LD\_DEBUG set to see the exact order:
```
LD_DEBUG=all <myprogram>
```
**EDIT:**
If you look at the source code of the runtime linker (glibc 2.7), specifically in files:
* sysdeps/unix/sysv/linux/init-first.c
* sysdeps/i386/init-first.c
* csu/libc-start.c
* sysdeps/i386/elf/st... |
437,290 | <p>I am looking for a way to exclude a single column from being sorted using jQuery's tablesorter plugin. Specifically, I have a fairly large table and would like to keep a "row number" column fixed so that it is easy to see what position in the table a particular row is, after sorting.</p>
<p>For example:</p>
<pre><... | [
{
"answer_id": 437331,
"author": "Ry Biesemeyer",
"author_id": 53098,
"author_profile": "https://Stackoverflow.com/users/53098",
"pm_score": 0,
"selected": false,
"text": "<p>Hrm. From tablesorter's method of reorganizing the table, I'm pretty sure that this isn't entirely possible. Tabl... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41665/"
] | I am looking for a way to exclude a single column from being sorted using jQuery's tablesorter plugin. Specifically, I have a fairly large table and would like to keep a "row number" column fixed so that it is easy to see what position in the table a particular row is, after sorting.
For example:
```
# name
------... | Here is a widget you can use that will accomplish what you are looking for:
```
$(function() {
// add new widget called indexFirstColumn
$.tablesorter.addWidget({
// give the widget a id
id: "indexFirstColumn",
// format is called when the on init and when a sorting has finished
... |
437,298 | <p>I'm setting up a simple page that just displays the contents of an XML file and allows the user to filter by keyword.</p>
<p>I'm a serious .NET newb, but I've got an XmlDataSource set up:</p>
<pre><code><asp:XmlDataSource ID="RSSFeedDataSource" runat="server" DataFile="test.xml"
XPath="/rss/channel/ite... | [
{
"answer_id": 437331,
"author": "Ry Biesemeyer",
"author_id": 53098,
"author_profile": "https://Stackoverflow.com/users/53098",
"pm_score": 0,
"selected": false,
"text": "<p>Hrm. From tablesorter's method of reorganizing the table, I'm pretty sure that this isn't entirely possible. Tabl... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm setting up a simple page that just displays the contents of an XML file and allows the user to filter by keyword.
I'm a serious .NET newb, but I've got an XmlDataSource set up:
```
<asp:XmlDataSource ID="RSSFeedDataSource" runat="server" DataFile="test.xml"
XPath="/rss/channel/item[contains(title,"theKey... | Here is a widget you can use that will accomplish what you are looking for:
```
$(function() {
// add new widget called indexFirstColumn
$.tablesorter.addWidget({
// give the widget a id
id: "indexFirstColumn",
// format is called when the on init and when a sorting has finished
... |
437,313 | <p>I have a Web-based Perl Win32::OLE script that uses Excel on the server side. It has been working happily for years on a Win2000 server running Excel2000. We recently upgraded to Win2003/Excel2003 and I now get the following error from the script:</p>
<pre><code> Win32::OLE(0.1709) error 0x80070005: "Access is deni... | [
{
"answer_id": 554590,
"author": "Dave",
"author_id": 35229,
"author_profile": "https://Stackoverflow.com/users/35229",
"pm_score": 0,
"selected": false,
"text": "<p>Can you run the script from a command line on the server (taking the web server out of the mix)? That's the first thing I... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54381/"
] | I have a Web-based Perl Win32::OLE script that uses Excel on the server side. It has been working happily for years on a Win2000 server running Excel2000. We recently upgraded to Win2003/Excel2003 and I now get the following error from the script:
```
Win32::OLE(0.1709) error 0x80070005: "Access is denied" at create_... | Seems like the same wicked problem described in [another post](https://stackoverflow.com/questions/425092/permission-denied-opening-an-excel-file-using-excel-12-0-library-vb6), however, no solution found...
Maybe troubleshooting with Procmon will reveal where the problem lies (see <http://support.microsoft.com/kb/2861... |
437,315 | <p>Whats the best way to implement rollover 'buttons' like Stackoverflow has for 'Questions', 'Tags', 'Users' at the top.</p>
<p>It is actually implemented like this :</p>
<pre><code><div class="nav">
<ul class="primarynav">
<li class="">
<a href="/questions">Quest... | [
{
"answer_id": 437336,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 5,
"selected": true,
"text": "<p>There's no javascript needed for hover effects on links. Just use the :hover <a href=\"http://www.w3.org/TR/CSS2/s... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | Whats the best way to implement rollover 'buttons' like Stackoverflow has for 'Questions', 'Tags', 'Users' at the top.
It is actually implemented like this :
```
<div class="nav">
<ul class="primarynav">
<li class="">
<a href="/questions">Questions</a>
</li>
<li class="">
... | There's no javascript needed for hover effects on links. Just use the :hover [pseudo-class](http://www.w3.org/TR/CSS2/selector.html#dynamic-pseudo-classes):
```
a:hover {
background-color:#FF9900;
}
```
Regarding the menu, it is quite common to implement [navigation using unordered lists](http://mirificampress.... |
437,324 | <p>I am facing an application designed to import huge amounts of data into a Microsoft SQL Server 2000 database. The application seems to take an awful long time to complete and I suspect the application design is flawed. Someone asked me to dig into the application to find and fix serious bottlenecks, if any. I would ... | [
{
"answer_id": 437336,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 5,
"selected": true,
"text": "<p>There's no javascript needed for hover effects on links. Just use the :hover <a href=\"http://www.w3.org/TR/CSS2/s... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27393/"
] | I am facing an application designed to import huge amounts of data into a Microsoft SQL Server 2000 database. The application seems to take an awful long time to complete and I suspect the application design is flawed. Someone asked me to dig into the application to find and fix serious bottlenecks, if any. I would lik... | There's no javascript needed for hover effects on links. Just use the :hover [pseudo-class](http://www.w3.org/TR/CSS2/selector.html#dynamic-pseudo-classes):
```
a:hover {
background-color:#FF9900;
}
```
Regarding the menu, it is quite common to implement [navigation using unordered lists](http://mirificampress.... |
437,325 | <p>The dynamic compile-on-the fly approach seems to fall outside the capacity for the typical tools which would extract this kind of information. I know I may be better off converting to a Web Application, BUT I would like to ask how it could be done in the case of a Web Site Project.</p>
| [
{
"answer_id": 437336,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 5,
"selected": true,
"text": "<p>There's no javascript needed for hover effects on links. Just use the :hover <a href=\"http://www.w3.org/TR/CSS2/s... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] | The dynamic compile-on-the fly approach seems to fall outside the capacity for the typical tools which would extract this kind of information. I know I may be better off converting to a Web Application, BUT I would like to ask how it could be done in the case of a Web Site Project. | There's no javascript needed for hover effects on links. Just use the :hover [pseudo-class](http://www.w3.org/TR/CSS2/selector.html#dynamic-pseudo-classes):
```
a:hover {
background-color:#FF9900;
}
```
Regarding the menu, it is quite common to implement [navigation using unordered lists](http://mirificampress.... |
437,333 | <p>How can I vertically align a table in the middle of the screen with css?</p>
| [
{
"answer_id": 437366,
"author": "Mike Robinson",
"author_id": 43687,
"author_profile": "https://Stackoverflow.com/users/43687",
"pm_score": 1,
"selected": false,
"text": "<p>Generally something along the lines of this works pretty well in any block element with a defined height. </p>\n\... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16684/"
] | How can I vertically align a table in the middle of the screen with css? | Generally something along the lines of this works pretty well in any block element with a defined height.
```
table {
position: absolute;
top: 50%;
margin-top: -50%;
}
```
Centering on the page is harder since you don't have a defined height, but I think this works.
```
html {
height: 100%;
}
```
You may en... |
437,371 | <p>I want to format the number 3253454 for my website visitors.</p>
<p>If I use the inbuilt number_format function, I get: 3,253,454 which is great for UK and USA, however most other countries use 3.253.454</p>
<p>I have many international visitors.</p>
<p>Can anyone give me a pointer to the best practice here?</p>
... | [
{
"answer_id": 437380,
"author": "Karsten",
"author_id": 28144,
"author_profile": "https://Stackoverflow.com/users/28144",
"pm_score": 3,
"selected": false,
"text": "<pre><code>string number_format (float $number, int $decimals, string $dec_point, string $thousands_sep)\n</code></pre>\n\... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to format the number 3253454 for my website visitors.
If I use the inbuilt number\_format function, I get: 3,253,454 which is great for UK and USA, however most other countries use 3.253.454
I have many international visitors.
Can anyone give me a pointer to the best practice here?
Ideally I wish to get the ... | If you're deploying a localized website, you're going to want to make sure you [setlocale()](http://php.net/setlocale "setlocale()"). To riff off of yaauie's above post I'd add something like the following code snippet in your initialization code:
```
$locale = ( isset($_COOKIE['locale']) ) ?
$_COOKIE['lo... |
437,373 | <p>I have a need for methods in several classes that must always follow a specific pre and post pattern. </p>
<p>public void method(X x, Y y ) { </p>
<p>// ************Repeating Part begin ******************/ </p>
<p>AFrameworkClass aFrameworkClass = new AFrameworkClass (this.memberVariable,"SomeString"); </p>
<p>t... | [
{
"answer_id": 437410,
"author": "cliff.meyers",
"author_id": 41754,
"author_profile": "https://Stackoverflow.com/users/41754",
"pm_score": 3,
"selected": true,
"text": "<p>Absolutely it can be done with Spring's AOP support. You can apply the first part as \"before\" advice and the 2nd... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54035/"
] | I have a need for methods in several classes that must always follow a specific pre and post pattern.
public void method(X x, Y y ) {
// \*\*\*\*\*\*\*\*\*\*\*\*Repeating Part begin \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/
AFrameworkClass aFrameworkClass = new AFrameworkClass (this.memberVariable,"SomeString");
tr... | Absolutely it can be done with Spring's AOP support. You can apply the first part as "before" advice and the 2nd as "after-finally" advice or you can apply both as "around" advice and programmatically invoke the target method like so:
```
methodInvocation.invoke(); // returns Object
```
If you want to declare your a... |
437,382 | <p>So my 2009 new years resolution is to learn Java. I recently acquired "Java for Dummies" and have been following along with the demo code in the book by re-writing it using Eclipse. Anyway, every example in the book that uses a relative path does not seem to read the .txt file it's supposed to read from.</p>
<p>H... | [
{
"answer_id": 437395,
"author": "jjnguy",
"author_id": 2598,
"author_profile": "https://Stackoverflow.com/users/2598",
"pm_score": 7,
"selected": true,
"text": "<p>You need <code>\"src/Hankees.txt\"</code></p>\n\n<p>Your file is in the source folder which is not counted as the working d... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27025/"
] | So my 2009 new years resolution is to learn Java. I recently acquired "Java for Dummies" and have been following along with the demo code in the book by re-writing it using Eclipse. Anyway, every example in the book that uses a relative path does not seem to read the .txt file it's supposed to read from.
Here is the s... | You need `"src/Hankees.txt"`
Your file is in the source folder which is not counted as the working directory.\
Or you can move the file up to the root directory of your project and just use `"Hankees.txt"` |
437,389 | <p>How can you return a string minus the first character in a string in MySQL?</p>
<p>In other words, get 'ello' from 'hello'.</p>
<p>The only way I can think to do it is to use mid() with the second offset being larger than the string could possibly be:</p>
<pre><code>select mid('hello', 2, 99)
</code></pre>
<p>Bu... | [
{
"answer_id": 437406,
"author": "Rob",
"author_id": 3542,
"author_profile": "https://Stackoverflow.com/users/3542",
"pm_score": 5,
"selected": true,
"text": "<p>Use <a href=\"http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substr\" rel=\"noreferrer\"><code>SUBSTR</... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41613/"
] | How can you return a string minus the first character in a string in MySQL?
In other words, get 'ello' from 'hello'.
The only way I can think to do it is to use mid() with the second offset being larger than the string could possibly be:
```
select mid('hello', 2, 99)
```
But I'm convinced there must be a more ele... | Use [`SUBSTR`](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substr) (or `SUBSTRING`):
```
SELECT SUBSTR( 'hello', 2 );
--> 'ello'
```
*See also: [MySQL String Functions](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html)* |
437,396 | <p>I have this:</p>
<pre><code> Dim myTemp As String
myTemp = System.DateTime.Now().ToString("MMMddyyyy_HHmmss") & ".pdf"
System.IO.File.Copy(myFile, "c:\" & myTemp)
Application.DoEvents()
OpenFile(myTemp)
</code></pre>
<p>The problem is that when I call OpenFile, which is just a call to a... | [
{
"answer_id": 437421,
"author": "scottm",
"author_id": 53007,
"author_profile": "https://Stackoverflow.com/users/53007",
"pm_score": -1,
"selected": false,
"text": "<p><code>System.Threading.Thread.Sleep(1000);</code></p>\n"
},
{
"answer_id": 437435,
"author": "Tom Anderson"... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28045/"
] | I have this:
```
Dim myTemp As String
myTemp = System.DateTime.Now().ToString("MMMddyyyy_HHmmss") & ".pdf"
System.IO.File.Copy(myFile, "c:\" & myTemp)
Application.DoEvents()
OpenFile(myTemp)
```
The problem is that when I call OpenFile, which is just a call to a sub that opens a file, it cannot ... | I don't really know much VB.NET, but isn't Copy a blocking call? Are you sure you're not just trying to open the file from the wrong location (or the unescaped backslash invalidates the path)?
What about this? I've added the drive letter to OpenFile, and escaped the backslash both places.
```
Dim myTemp As String
myT... |
437,400 | <p>I don't want to type /cygdrive/c/path/to/stuff, especially when using tools that don't know anything about cygwin. Is there a way to configure cygwin to autocomplete "c:\path\to\stuff" or even "c:/path/to/stuff"?</p>
| [
{
"answer_id": 437428,
"author": "John Safranek",
"author_id": 30524,
"author_profile": "https://Stackoverflow.com/users/30524",
"pm_score": 2,
"selected": false,
"text": "<p>Autocomplete should be working after the /cygdrive/c bit. Make a symlink for \"/cygdrive/c/\" to something else,... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49237/"
] | I don't want to type /cygdrive/c/path/to/stuff, especially when using tools that don't know anything about cygwin. Is there a way to configure cygwin to autocomplete "c:\path\to\stuff" or even "c:/path/to/stuff"? | For tools that can't understand cygwin paths, you'll need to convert them to windows paths. The `cygpath` utility can do this for you:
```
notepad $(cygpath -w /cygdrive/c/path/to/stuff)
```
You can probably create aliases or wrapper scripts for commonly-used windows executables. |
437,403 | <p>I'm currently writing a C#-class in my ASP.NET (3.5) application to handle all database-queries. Some of the methods are there to make a select-query to the database. Inside the method i simply have a <code>SqlDataReader r = command.ExecuteReader();</code> to fetch the data.</p>
<p>I now want <code>r</code> to be r... | [
{
"answer_id": 437417,
"author": "scottm",
"author_id": 53007,
"author_profile": "https://Stackoverflow.com/users/53007",
"pm_score": 3,
"selected": true,
"text": "<p>You can use a datatable and SqlDataAdapter:</p>\n\n<pre><code>using(SqlDataAdapter adap = new SqlDataAdapter(cmd))\n{\n ... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39785/"
] | I'm currently writing a C#-class in my ASP.NET (3.5) application to handle all database-queries. Some of the methods are there to make a select-query to the database. Inside the method i simply have a `SqlDataReader r = command.ExecuteReader();` to fetch the data.
I now want `r` to be returned by the method, but when ... | You can use a datatable and SqlDataAdapter:
```
using(SqlDataAdapter adap = new SqlDataAdapter(cmd))
{
adap.fill(myDataTable);
}
return myDataTable;
``` |
437,419 | <p>I'm trying to execute multiple commands without create a new process each time. Basically, I want to start the DOS command shell, switch to the MySQL command shell, and execute a command. Here's how I am calling the procedure (also below). Also, how do I handle the "\"'s in the command?</p>
<pre><code>ExecuteComman... | [
{
"answer_id": 437434,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 4,
"selected": false,
"text": "<p>Couldn't you just write all the commands into a .cmd file in the temp folder and then execute that file?</p>\n"
},
{
... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to execute multiple commands without create a new process each time. Basically, I want to start the DOS command shell, switch to the MySQL command shell, and execute a command. Here's how I am calling the procedure (also below). Also, how do I handle the "\"'s in the command?
```
ExecuteCommand("mysql --use... | You can redirect standard input and use a StreamWriter to write to it:
```
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "cmd.exe";
info.RedirectStandardInput = true;
info.UseShellExecute = false;
p.StartInfo = info;
... |
437,422 | <p>I have an application that uses RequiredFieldValidator controls with a ValidationSummary and once a "Finish" button is clicked all the fields are validated. This page has several different parts of it that are made visible or invisible and I noticed that the Validators only activate for visible controls and ignore t... | [
{
"answer_id": 437521,
"author": "Jeff Martin",
"author_id": 13100,
"author_profile": "https://Stackoverflow.com/users/13100",
"pm_score": 0,
"selected": false,
"text": "<p>if the page is divided into segments and only part of the page is shown, couldn't you validate on the method that s... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52587/"
] | I have an application that uses RequiredFieldValidator controls with a ValidationSummary and once a "Finish" button is clicked all the fields are validated. This page has several different parts of it that are made visible or invisible and I noticed that the Validators only activate for visible controls and ignore the ... | If the control isn't .Visible then the html isn't there to validate against. Instead of setting Control.Visible = false, try setting a css class to hide it instead.
In your style sheet:
```
.invisible { visibility:hidden; }
```
And then instead of .Visible = false use:
```
Control.CssClass = "invisible";
``` |
437,476 | <p>I'm looking for the equivalent of a <a href="http://docs.python.org/library/urllib.html#urllib.quote_plus" rel="nofollow noreferrer">urlencode</a> for terminal output -- I need to make sure that garbage characters I (may) print from an external source don't end up doing funky things to my terminal, so a prepackaged ... | [
{
"answer_id": 437497,
"author": "ng.",
"author_id": 21896,
"author_profile": "https://Stackoverflow.com/users/21896",
"pm_score": -1,
"selected": false,
"text": "<p>You could pipe it through strings</p>\n\n<pre><code>./command | strings\n</code></pre>\n\n<p>This will strip out the non s... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | I'm looking for the equivalent of a [urlencode](http://docs.python.org/library/urllib.html#urllib.quote_plus) for terminal output -- I need to make sure that garbage characters I (may) print from an external source don't end up doing funky things to my terminal, so a prepackaged function to escape special character seq... | ```
$ ./command | cat -v
$ cat --help | grep nonprinting
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
```
Here's the same in py3k based on [android/cat.c](http://www.google.com/codesearch/p?hl=en#2wSbThBwwIw/toolbox/cat.c&q=file:%5Cbcat.c&l=-1):
```
#!/usr/bin/env python3
"""Emulate `cat ... |
437,491 | <p>I have an ant task, and within it I'd like to get the current process id (a la <code>echo $PPID</code> from command line).</p>
<p>I'm running <code>ksh</code> on Solaris, so I thought I could just do this:</p>
<pre><code><property environment="env" />
<target name="targ">
<echo message="PID is $... | [
{
"answer_id": 437793,
"author": "Brian Clapper",
"author_id": 53495,
"author_profile": "https://Stackoverflow.com/users/53495",
"pm_score": 2,
"selected": false,
"text": "<p>Why not just use the <code>tempfile</code> Ant task, instead? It does what you really want to do, while hiding al... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54373/"
] | I have an ant task, and within it I'd like to get the current process id (a la `echo $PPID` from command line).
I'm running `ksh` on Solaris, so I thought I could just do this:
```
<property environment="env" />
<target name="targ">
<echo message="PID is ${env.PPID}" />
<echo message="PID is ${env.$$}" />
</t... | You can find PID using java process monitoring tool JPS, then output stream can be filtered and if needed process can be killed. check out this tomcat pid kill script:
```
<target name="tomcat.kill" depends="tomcat.shutdown">
<exec executable="jps">
<arg value="-l"/>
<redirector outputproperty="process.pid">... |
437,504 | <p>How do I pipe the output of grep as the search pattern for another grep?</p>
<p>As an example:</p>
<pre><code>grep <Search_term> <file1> | xargs grep <file2>
</code></pre>
<p>I want the output of the first grep as the search term for the second grep. The above command is treating the output of t... | [
{
"answer_id": 437508,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 4,
"selected": true,
"text": "<p>If using Bash then you can use backticks:</p>\n\n<pre><code>> grep -e \"`grep ... ...`\" files\n</code></pre>\n\n<p>the... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I pipe the output of grep as the search pattern for another grep?
As an example:
```
grep <Search_term> <file1> | xargs grep <file2>
```
I want the output of the first grep as the search term for the second grep. The above command is treating the output of the first grep as the file name for the second grep.... | If using Bash then you can use backticks:
```
> grep -e "`grep ... ...`" files
```
the `-e` flag and the double quotes are there to ensure that any output from the initial `grep` that starts with a hyphen isn't then interpreted as an option to the second `grep`.
Note that the double quoting trick (which also ensure... |
437,511 | <p>What are the valid instanceState's for the Amazon EC2 API? It doesn't seem to be defined in the current <a href="http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/ApiReference-SOAP-DescribeInstances.html" rel="noreferrer">API doc</a>. Google doesn't turn up much. So far I know about:</p>
<ul>
<li>0: pe... | [
{
"answer_id": 3693983,
"author": "user421944",
"author_id": 421944,
"author_profile": "https://Stackoverflow.com/users/421944",
"pm_score": 1,
"selected": false,
"text": "<p>The docs seem to have been moved, and I still can't find them. Here are two more state codes</p>\n\n<ol>\n<li>64... | 2009/01/12 | [
"https://Stackoverflow.com/questions/437511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2506/"
] | What are the valid instanceState's for the Amazon EC2 API? It doesn't seem to be defined in the current [API doc](http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/ApiReference-SOAP-DescribeInstances.html). Google doesn't turn up much. So far I know about:
* 0: pending
* 16: running
* 32: shutting-down
* ... | As of posting, the current states are:
```
+--------+---------------+
| Code | State |
+--------+---------------+
| 0 | pending |
| 16 | running |
| 32 | shutting-down |
| 48 | terminated |
| 64 | stopping |
| 80 | stopped |
+--------+---------------+
`... |
437,539 | <p>I'm a newbie when it comes to LINQ...</p>
<p>I have an IEnumerable generic list that contains answers with different versions (each with an FK to the question). From this list I need to get a dictionary of latest version answers only.</p>
<p>A very simplified class diagram:</p>
<p>Question<br>
-ID<br>
-question<b... | [
{
"answer_id": 437547,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 0,
"selected": false,
"text": "<p>I would just rewrite the data model to include the current answer version ID.</p>\n"
},
{
"answer_id": 437592,
"aut... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9344/"
] | I'm a newbie when it comes to LINQ...
I have an IEnumerable generic list that contains answers with different versions (each with an FK to the question). From this list I need to get a dictionary of latest version answers only.
A very simplified class diagram:
Question
-ID
-question
- ...other properties
... | How about something like....
```
private void button1_Click(object sender, EventArgs e)
{
List<Answer> list = GetAnswers();
var dict = (from a in list
group a by a.QuestionID into grp
from g in grp
where g.Version == grp.Max(m => m.Version)
... |
437,589 | <p>I have a long-running Python server and would like to be able to upgrade a service without restarting the server. What's the best way do do this?</p>
<pre><code>if foo.py has changed:
unimport foo <-- How do I do this?
import foo
myfoo = foo.Foo()
</code></pre>
| [
{
"answer_id": 437591,
"author": "cdleary",
"author_id": 3594,
"author_profile": "https://Stackoverflow.com/users/3594",
"pm_score": 11,
"selected": true,
"text": "<p>You can reload a module when it has already been imported by using <a href=\"https://docs.python.org/3/library/importlib.... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | I have a long-running Python server and would like to be able to upgrade a service without restarting the server. What's the best way do do this?
```
if foo.py has changed:
unimport foo <-- How do I do this?
import foo
myfoo = foo.Foo()
``` | You can reload a module when it has already been imported by using [`importlib.reload()`](https://docs.python.org/3/library/importlib.html#importlib.reload):
```
from importlib import reload # Python 3.4+
import foo
while True:
# Do some things.
if is_changed(foo):
foo = reload(foo)
```
In Python 2... |
437,603 | <p>I am new to relational algebra and for my assignment I have to create two. I have written out the problem I have faced in SQL but I am unsure of how to represent such joins in relational algebra. Any help/pointers would be greatly appreciated.</p>
<pre><code>SELECT ps.FirstName AS StudentFirstName, ps.LastName AS S... | [
{
"answer_id": 437673,
"author": "rabble",
"author_id": 54404,
"author_profile": "https://Stackoverflow.com/users/54404",
"pm_score": -1,
"selected": false,
"text": "<p>I think you are going about the problem the wrong way. In the real world you'd never want to create a situation where y... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50913/"
] | I am new to relational algebra and for my assignment I have to create two. I have written out the problem I have faced in SQL but I am unsure of how to represent such joins in relational algebra. Any help/pointers would be greatly appreciated.
```
SELECT ps.FirstName AS StudentFirstName, ps.LastName AS StudentLastName... | Those left joins you're doing are referred to in relational algebra as theta-joins, sometimes more specifically specifically as equijoins. You'll want to use the symbol that looks like a bow tie and write "StudentID = PersonID" underneath it (for the second join in your example). I can't do the fancy symbols, but <http... |
437,604 | <p>I'm trying to write a C# program, where when a user enters some data into a text box and clicks on a "save" button, the information is stored in some sort of file that when the program is opened the next time around, the information is automatically loaded in.</p>
<p>I'm using Visual C# express. What's the best wa... | [
{
"answer_id": 437613,
"author": "Andrew Kennan",
"author_id": 22506,
"author_profile": "https://Stackoverflow.com/users/22506",
"pm_score": 0,
"selected": false,
"text": "<p>If it's very simple then you could place it in a plain text file. For more structured data you could consider sto... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83819/"
] | I'm trying to write a C# program, where when a user enters some data into a text box and clicks on a "save" button, the information is stored in some sort of file that when the program is opened the next time around, the information is automatically loaded in.
I'm using Visual C# express. What's the best way to do thi... | Make your user data serializable by adding the keyword:
```
[Serializable]
```
above your data structure. When you load the dialog box, load your serialized structure from disk, and when you leave the dialog, save the data structure.
From a style standpoint, you should probably not have the dialog box change data u... |
437,617 | <p>How would you reference table1 columns to 2 columns in table 2</p>
<p>I created a table '<strong>State</strong>' with 50 exact rows</p>
<p>trying to relate (weddingState,contactState) in '<strong>Wedding</strong>' table</p>
<p>This is the statement that I created but it only joins the top <strong>WeddingState</st... | [
{
"answer_id": 437645,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": true,
"text": "<p>I'd guess that you're retrieving these in PHP or something, and you're fetching the rows in a hash-array, keyed by t... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How would you reference table1 columns to 2 columns in table 2
I created a table '**State**' with 50 exact rows
trying to relate (weddingState,contactState) in '**Wedding**' table
This is the statement that I created but it only joins the top **WeddingState** correctly - seems not to care about the INNER Join below ... | I'd guess that you're retrieving these in PHP or something, and you're fetching the rows in a hash-array, keyed by the field name. Of course there can only be one element in a hash with a given key. So you need to use column aliases to make sure columns with the same name are given a distinct alias.
```
SELECT w.*, s1... |
437,649 | <p>What is the rationale behind this naming convention?</p>
<p>I don't see any benefit. The extra prefix just pollutes the API.</p>
<p>My thinking is inline with Konrad's <a href="https://stackoverflow.com/a/222502/9898">response</a> to this related <a href="https://stackoverflow.com/questions/222457">question</a>; t... | [
{
"answer_id": 437652,
"author": "scottm",
"author_id": 53007,
"author_profile": "https://Stackoverflow.com/users/53007",
"pm_score": 2,
"selected": false,
"text": "<p>It makes it easily identifiable as an interface.</p>\n"
},
{
"answer_id": 437653,
"author": "Otávio Décio",
... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9898/"
] | What is the rationale behind this naming convention?
I don't see any benefit. The extra prefix just pollutes the API.
My thinking is inline with Konrad's [response](https://stackoverflow.com/a/222502/9898) to this related [question](https://stackoverflow.com/questions/222457); the chosen [answer](https://stackoverflo... | Its the complete opposite, the naming convention clearly identifies an interface.
For example if you have:
```
public class Dog : IPet, IMammal
{
....
```
Just from reading it, I can safely assume that IPet and IMammal are probably interfaces.
The .NET CLR allows for single class inheritance. So, if I have a ... |
437,670 | <p>In Oracle, you can use the <a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions230.htm#i1129193" rel="nofollow noreferrer">XMLElement()</a> function to create an element, as in:</p>
<pre><code>XMLElement('name', 'John')
</code></pre>
<p>But how to create an element in a specific namesp... | [
{
"answer_id": 437681,
"author": "avernet",
"author_id": 5295,
"author_profile": "https://Stackoverflow.com/users/5295",
"pm_score": 2,
"selected": true,
"text": "<p>Instead of <code>XMLElement()</code> use:</p>\n\n<pre><code>XMLType('<my:name xmlns:my=\"http://www.example.com/my\">... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5295/"
] | In Oracle, you can use the [XMLElement()](http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions230.htm#i1129193) function to create an element, as in:
```
XMLElement('name', 'John')
```
But how to create an element in a specific namespace? For instance, how to create the following element:
```
<m... | Instead of `XMLElement()` use:
```
XMLType('<my:name xmlns:my="http://www.example.com/my">John</my:name>')
```
Yes, it is that simple. |
437,676 | <p>How do games with gravity handle the relationship between moving things like players, monsters, or objects and the floor? Is the player constantly "falling into" the floor and being bounced back up? </p>
<p>Two ways to react to collisions that I have found are moving the player back to his previous location befor... | [
{
"answer_id": 437690,
"author": "Crashworks",
"author_id": 53543,
"author_profile": "https://Stackoverflow.com/users/53543",
"pm_score": 1,
"selected": false,
"text": "<p>One of the most complete textbooks on this subject is <a href=\"http://www.amazon.com/exec/obidos/tg/detail/-/155860... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5922/"
] | How do games with gravity handle the relationship between moving things like players, monsters, or objects and the floor? Is the player constantly "falling into" the floor and being bounced back up?
Two ways to react to collisions that I have found are moving the player back to his previous location before the collis... | You might want to check out [GameDev.net's Gravity FAQs](https://www.gamedev.net/reference/articles/article694.asp) for some basic info.
Since you are making a game and not a highly accurate physics modeler than we can get away with doing [Euler integrations](https://en.wikipedia.org/wiki/Euler%27s_method). If your ne... |
437,683 | <p>I know how to get the System memory use using GlobalMemoryStatusEx, but that tells me the what the entire OS is using.</p>
<p>I really want my program to report how much memory it alone has allocated and is using. </p>
<p>Is there any way within my Delphi 2009 program to call either a Windows function or maybe som... | [
{
"answer_id": 437696,
"author": "Gant",
"author_id": 12460,
"author_profile": "https://Stackoverflow.com/users/12460",
"pm_score": 1,
"selected": false,
"text": "<p>For Win32 API way, you need <strong>GetProcessMemoryInfo</strong> function. Here is an example from <a href=\"http://msdn.... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30176/"
] | I know how to get the System memory use using GlobalMemoryStatusEx, but that tells me the what the entire OS is using.
I really want my program to report how much memory it alone has allocated and is using.
Is there any way within my Delphi 2009 program to call either a Windows function or maybe some FastMM function... | You can get useful memory usage information out of the Delphi runtime without using any direct Win32 calls:
```
unit X;
uses FastMM4; //include this or method will return 0.
....
function GetMemoryUsed: UInt64;
var
st: TMemoryManagerState;
sb: TSmallBlockTypeState;
begin
GetMemoryManagerState(st);
result :=... |
437,714 | <p>I use windows batch file to open files in an already-running instance of Emacs using emacsclientw.exe. However, any file opened that way is opened in server mode, which means that I have to use C-x # to kill it, instead of the usual C-x k. How do I change this behavior?</p>
| [
{
"answer_id": 437824,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 2,
"selected": false,
"text": "<p>You know, I hate to suggest workarounds instead of a real solution... but after reading the server code, I am confused a... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/207/"
] | I use windows batch file to open files in an already-running instance of Emacs using emacsclientw.exe. However, any file opened that way is opened in server mode, which means that I have to use C-x # to kill it, instead of the usual C-x k. How do I change this behavior? | use:
```
D:\> emacsclientw -n foo.txt
```
the -n says "no wait". This is in GNU Emacs 22.2.1 (i386-mingw-nt5.1.2600) of 2008-03-26 on RELEASE (and many prior versions, IIRC). |
437,716 | <p>What's the best way of converting PDF docs to Microsoft Word format in PHP? This can be either as a PHP script or calling a (Linux) executable (with proc_open()). It just needs to be relatively fast and produce quality Word documents (in 97/2000/2003 format).</p>
<p>Commercial software is OK.</p>
| [
{
"answer_id": 437863,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 0,
"selected": false,
"text": "<p>Openoffice has a <a href=\"http://wiki.services.openoffice.org/wiki/Pdf_Import_Extension\" rel=\"nofollow noreferrer\... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] | What's the best way of converting PDF docs to Microsoft Word format in PHP? This can be either as a PHP script or calling a (Linux) executable (with proc\_open()). It just needs to be relatively fast and produce quality Word documents (in 97/2000/2003 format).
Commercial software is OK. | To read **PDF** files, you will need to install the **[XPDF](http://www.foolabs.com/xpdf/about.html)** package, which includes "pdftotext." Once you have XPDF/pdftotext installed, you run the following PHP statement to get the PDF text:
```
content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -');
```
After ... |
437,728 | <p>I need to search a drive (C:, D: etc) for a partuicular file type (extension like .xml, .csv, .xls). How do I preform a recursive search to loop all directories and inner directories and return the full path of where the file(s) are? or where can I get information on this?</p>
<p>VB.NET or C# </p>
<p>Thanks</p>
<... | [
{
"answer_id": 437733,
"author": "Cristian Libardo",
"author_id": 16526,
"author_profile": "https://Stackoverflow.com/users/16526",
"pm_score": 6,
"selected": false,
"text": "<pre><code>System.IO.Directory.GetFiles(@\"c:\\\", \"*.xml\", SearchOption.AllDirectories);\n</code></pre>\n"
}... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] | I need to search a drive (C:, D: etc) for a partuicular file type (extension like .xml, .csv, .xls). How do I preform a recursive search to loop all directories and inner directories and return the full path of where the file(s) are? or where can I get information on this?
VB.NET or C#
Thanks
Edit ~ I am running in... | How about this? It avoids the exception often thrown by the in-built recursive search (i.e. you get access-denied to a single folder, and your whole search dies), and is lazily evaluated (i.e. it returns results as soon as it finds them, rather than buffering 2000 results). The lazy behaviour lets you build responsive ... |
437,751 | <p>Is there any way to call a function in C# when the user exists the application?</p>
<p>I'm using Visual C# 2008 Express edition.</p>
<p>Thanks.</p>
| [
{
"answer_id": 437754,
"author": "Cristian Libardo",
"author_id": 16526,
"author_profile": "https://Stackoverflow.com/users/16526",
"pm_score": 3,
"selected": true,
"text": "<p>It's a windows forms applications, isn't it? You can use this event:</p>\n\n<pre><code>System.Windows.Forms.App... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83819/"
] | Is there any way to call a function in C# when the user exists the application?
I'm using Visual C# 2008 Express edition.
Thanks. | It's a windows forms applications, isn't it? You can use this event:
```
System.Windows.Forms.Application.ApplicationExit += ...
``` |
437,753 | <p>I have a small database and have been adding entries through a Rails page. I "destroyed" one of the entries and now my sequence of IDs are skipping by one. For example, I now have 42 then 44, instead of the obvious: 42, 43, 44.</p>
<p>I was wondering if there was a way to edit the ID number of a new object through ... | [
{
"answer_id": 437792,
"author": "Chris Lloyd",
"author_id": 42413,
"author_profile": "https://Stackoverflow.com/users/42413",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>Would I possibly have to do this through direct SQL in sqlite?</p>\n</blockquote>\n\n<p>Yes.</p>\n\n... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1434/"
] | I have a small database and have been adding entries through a Rails page. I "destroyed" one of the entries and now my sequence of IDs are skipping by one. For example, I now have 42 then 44, instead of the obvious: 42, 43, 44.
I was wondering if there was a way to edit the ID number of a new object through the consol... | >
> Would I possibly have to do this through direct SQL in sqlite?
>
>
>
Yes.
The whole point of ActiveRecord is that is abstracts DB functions and just returns collections of data. You shouldn't be worrying about the ID of a record, that is something specific to the DB. Off the top of my head I can't think of an... |
437,756 | <p>Lots of times in Java logs I'll get something like:</p>
<pre><code>Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(jdbcStatement.java:1102)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(jdbcPreparedStatement.java:514)
at org.hibernate.jdbc.Bat... | [
{
"answer_id": 437767,
"author": "Cowan",
"author_id": 17041,
"author_profile": "https://Stackoverflow.com/users/17041",
"pm_score": 7,
"selected": true,
"text": "<p>When you see '...113 more', that means that the remaining lines of the 'caused by' exception are identical to the remainin... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1666/"
] | Lots of times in Java logs I'll get something like:
```
Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(jdbcStatement.java:1102)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(jdbcPreparedStatement.java:514)
at org.hibernate.jdbc.BatchingBatcher.d... | When you see '...113 more', that means that the remaining lines of the 'caused by' exception are identical to the remaining lines from that point on of the parent exception.
For example, you'll have
```
com.something.XyzException
at ...
at ...
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.j... |
437,760 | <p>Where does Rails store data created by saving activerecord objects during tests?</p>
<p>I thought I knew the answer to that question: obviously in the <strong>_test database</strong>. But it looks like this is <strong>not true</strong>!</p>
<p>I used this system to test what's happening to saved ActiveRecord data ... | [
{
"answer_id": 437765,
"author": "Derek P.",
"author_id": 45615,
"author_profile": "https://Stackoverflow.com/users/45615",
"pm_score": 5,
"selected": true,
"text": "<p>Items in the test database are erased by default after each test is run, by design. This is done to make sure that each... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54426/"
] | Where does Rails store data created by saving activerecord objects during tests?
I thought I knew the answer to that question: obviously in the **\_test database**. But it looks like this is **not true**!
I used this system to test what's happening to saved ActiveRecord data during rspec tests:
$ rails -d mysql test... | Items in the test database are erased by default after each test is run, by design. This is done to make sure that each of your tests has its own sandbox to play in that doesn't cause any interactions with the tests before it.
Again, this is by design. You don't want tests that are manipulating the same set of data (o... |
437,766 | <p>Is there a way to bind the child properties of an object to datagridview? Here's my code:</p>
<pre><code>public class Person
{
private string id;
private string name;
private Address homeAddr;
public string ID
{
get { return id; }
set { id = value; }
}
public string Name
... | [
{
"answer_id": 437765,
"author": "Derek P.",
"author_id": 45615,
"author_profile": "https://Stackoverflow.com/users/45615",
"pm_score": 5,
"selected": true,
"text": "<p>Items in the test database are erased by default after each test is run, by design. This is done to make sure that each... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | Is there a way to bind the child properties of an object to datagridview? Here's my code:
```
public class Person
{
private string id;
private string name;
private Address homeAddr;
public string ID
{
get { return id; }
set { id = value; }
}
public string Name
{
... | Items in the test database are erased by default after each test is run, by design. This is done to make sure that each of your tests has its own sandbox to play in that doesn't cause any interactions with the tests before it.
Again, this is by design. You don't want tests that are manipulating the same set of data (o... |
437,769 | <p>How can I make a PHP script cache-friendly to our private reverse proxy (Squid)?</p>
<p>I would like it to stay cached for the rest of the day. In other words, the page's last modification is 00:00 today and it will expire at 00:00 tomorrow.</p>
<p>What are the minimum required HTTP headers to do this reliably?</... | [
{
"answer_id": 437778,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 1,
"selected": false,
"text": "<p>I assume you mean you want to cache the <strong>output</strong> of the script, not the script itself. And you clearly w... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I make a PHP script cache-friendly to our private reverse proxy (Squid)?
I would like it to stay cached for the rest of the day. In other words, the page's last modification is 00:00 today and it will expire at 00:00 tomorrow.
What are the minimum required HTTP headers to do this reliably?
EDIT: I do not wan... | @OP:
Below is some commented code to achieve what you asked.
@cletus:
You said memcached is what the OP wants, and that this is not what Squid is designed for.
I don't know what Squid was designed for but I know what it *is* used for and there are definitely people using it as a reverse proxy to take load off dynamic... |
437,785 | <p>I'd like to create several modules that will be used in nearly all scripts and modules in my project. These could be <strong>use</strong>d in each of my scripts like so:</p>
<pre><code>#!/usr/bin/perl
use Foo::Bar;
use Foo::Baz;
use Foo::Qux;
use Foo::Quux;
# Potentially many more.
</code></pre>
<p>Is it possib... | [
{
"answer_id": 437835,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 4,
"selected": true,
"text": "<p>Something like this should work:</p>\n\n<p><a href=\"http://mail.pm.org/pipermail/chicago-talk/2008-March/004829.html\" r... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6406/"
] | I'd like to create several modules that will be used in nearly all scripts and modules in my project. These could be **use**d in each of my scripts like so:
```
#!/usr/bin/perl
use Foo::Bar;
use Foo::Baz;
use Foo::Qux;
use Foo::Quux;
# Potentially many more.
```
Is it possible to move all these **use** statements ... | Something like this should work:
<http://mail.pm.org/pipermail/chicago-talk/2008-March/004829.html>
Basically, create your package with lots of modules:
```
package Lots::Of::Modules;
use strict; # strictly optional, really
# These are the modules we want everywhere we say "use Lots::Of::Modules".
# Any exports are... |
437,791 | <p>I am writing a GAE application and am having some difficulty with the following problem.</p>
<p>I've created multiple python files (say a.py and b.py) which are both stored in the same folder. I am able to call code in a.py or b.py by mapping URL's to them (using app.yaml). What I haven't figured out how to do is ... | [
{
"answer_id": 437845,
"author": "airportyh",
"author_id": 5304,
"author_profile": "https://Stackoverflow.com/users/5304",
"pm_score": 4,
"selected": true,
"text": "<p>Have you tried importing as if you were starting at the top level? Like </p>\n\n<pre>\nimport modules.b\n</pre>\n"
},
... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26241/"
] | I am writing a GAE application and am having some difficulty with the following problem.
I've created multiple python files (say a.py and b.py) which are both stored in the same folder. I am able to call code in a.py or b.py by mapping URL's to them (using app.yaml). What I haven't figured out how to do is import the ... | Have you tried importing as if you were starting at the top level? Like
```
import modules.b
``` |
437,802 | <p>Some background: If I wanted to use for, for instance, <code>scanf()</code> to convert a string into a standard integer type, like <code>uint16_t</code>, I’d use <code>SCNu16</code> from <code><inttypes.h></code>, like this:</p>
<pre><code>#include <stdio.h>
#include <inttypes.h>
uint16_t x;
char ... | [
{
"answer_id": 437814,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 2,
"selected": false,
"text": "<p>It depends on exactly how portable you want to be. POSIX says that <code>pid_t</code> is a signed integer typ... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54435/"
] | Some background: If I wanted to use for, for instance, `scanf()` to convert a string into a standard integer type, like `uint16_t`, I’d use `SCNu16` from `<inttypes.h>`, like this:
```
#include <stdio.h>
#include <inttypes.h>
uint16_t x;
char *xs = "17";
sscanf(xs, "%" SCNu16, &x);
```
But a more uncommon integer ty... | There is one robust and portable solution, which is to use `strtoimax()` and check for overflows.
That is, I parse an `intmax_t`, check for an error from `strtoimax()`, and then also see if it "fits" in a `pid_t` by casting it and comparing it to the original `intmax_t` value.
```
#include <inttypes.h>
#include <stdi... |
437,808 | <p>We have an application which at certain times needs to execute 'tasks' in order to do some work. These tasks currently are just commands (read: dodgy VB scripts) being fired off and then monitoring the process for completion or aborting if it 'times out', however we don't have enough control over the execution.</p>
... | [
{
"answer_id": 437819,
"author": "Joe",
"author_id": 21950,
"author_profile": "https://Stackoverflow.com/users/21950",
"pm_score": 0,
"selected": false,
"text": "<p>It's not very exciting, but I'd consider using the built in script hosting support. I used to do this in Native C++ with no... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18434/"
] | We have an application which at certain times needs to execute 'tasks' in order to do some work. These tasks currently are just commands (read: dodgy VB scripts) being fired off and then monitoring the process for completion or aborting if it 'times out', however we don't have enough control over the execution.
I woul... | [Lua](http://www.lua.org) is designed exactly to be embedded in applications. it doesn't hurt that it's a really neat and efficient language. |
437,816 | <p>I've just encountered a weird problem, I'm trying to printf an integer variable, but I forgot to specify the variable name, i.e.</p>
<pre><code>printf("%d");
</code></pre>
<p>instead of</p>
<pre><code>printf("%d", integerName);
</code></pre>
<p>Surprisingly the program compiles, there is output and it is not ran... | [
{
"answer_id": 437823,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 0,
"selected": false,
"text": "<p>You found <em>one</em> behavior. It could have been <em>any</em> other behavior, including an invalid memory acces... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54440/"
] | I've just encountered a weird problem, I'm trying to printf an integer variable, but I forgot to specify the variable name, i.e.
```
printf("%d");
```
instead of
```
printf("%d", integerName);
```
Surprisingly the program compiles, there is output and it is not random. In fact, it happens to be the very integer I... | You say that "surprisingly the program compiles". Actually, it is not surprising at all. C & C++ allow for functions to have variable argument lists. The definition for printf is something like this:
```
int printf(char*, ...);
```
The "..." signifies that there are zero or more optional arguments to the function. I... |
437,827 | <p>I have this jQuery which works fine</p>
<pre><code>$("li[id^='shop_id']").click( function () {
alert("I clicked on id ??");
});
</code></pre>
<p>The above will work if any list element with an id beginging with 'shop_id' is clicked (i.e 'shop_id_1', 'shop_id_2', etc).
The problem is that I don't know how to f... | [
{
"answer_id": 437831,
"author": "bchhun",
"author_id": 48500,
"author_profile": "https://Stackoverflow.com/users/48500",
"pm_score": 4,
"selected": true,
"text": "<p>The \"this\" variable will help you out here:</p>\n\n<pre><code>$(\"li[id^='shop_id']\").click( function () {\n var cu... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54438/"
] | I have this jQuery which works fine
```
$("li[id^='shop_id']").click( function () {
alert("I clicked on id ??");
});
```
The above will work if any list element with an id beginging with 'shop\_id' is clicked (i.e 'shop\_id\_1', 'shop\_id\_2', etc).
The problem is that I don't know how to find out exactly which... | The "this" variable will help you out here:
```
$("li[id^='shop_id']").click( function () {
var current_id = $(this).attr("id");
alert(current_id);
});
``` |
437,836 | <p>The previous DBA here set up some SQL Server Reporting Services Reports to run automatically and email the report to users. When he left his accaount was disabled and now they don't work. The status on the subscription reads: </p>
<blockquote>
<p>Failure sending mail: The permissions granted to user
'OURDOMAIN\... | [
{
"answer_id": 451314,
"author": "Dustin Brooks",
"author_id": 54617,
"author_profile": "https://Stackoverflow.com/users/54617",
"pm_score": 0,
"selected": false,
"text": "<p>Can't you modify the subscription?</p>\n<p><a href=\"http://technet.microsoft.com/en-us/library/ms157343.aspx\" r... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2375/"
] | The previous DBA here set up some SQL Server Reporting Services Reports to run automatically and email the report to users. When he left his accaount was disabled and now they don't work. The status on the subscription reads:
>
> Failure sending mail: The permissions granted to user
> 'OURDOMAIN\old\_DBA\_Username'... | The solution posted [here](http://blogs.msdn.com/b/miah/archive/2008/07/10/tip-change-the-owner-of-report-server-subscription.aspx) did the trick for me. Basically you midify the subscription owner on the SSRS database directly by running the script below.
```
DECLARE @OldUserID uniqueidentifier
DECLARE @NewUserID un... |
437,854 | <p>Basically I want to do this:</p>
<pre><code>public interface A {
void a();
}
public interface B {
void b();
}
public class SomeClass {
public SomeClass(<A&B> e) { // Note the type here
e.a();
e.b();
}
}
</code></pre>
<p>What I did on the commented line is obviously illegal... | [
{
"answer_id": 437869,
"author": "Neil Coffey",
"author_id": 48933,
"author_profile": "https://Stackoverflow.com/users/48933",
"pm_score": 5,
"selected": true,
"text": "<p>You can do it with generics enabled. For example, to accept an instance of some class that implements both CharSeque... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48648/"
] | Basically I want to do this:
```
public interface A {
void a();
}
public interface B {
void b();
}
public class SomeClass {
public SomeClass(<A&B> e) { // Note the type here
e.a();
e.b();
}
}
```
What I did on the commented line is obviously illegal. I know I can just require the pass... | You can do it with generics enabled. For example, to accept an instance of some class that implements both CharSequence and Appendable:
```
public <T extends CharSequence & Appendable> void someMethod(T param) {
...
}
``` |
437,862 | <p>I found a couple of ways to handle recursion in Smarty, mostly based on including templates into themselves, which seems like ridiculous waste of resources. I found one solution, by Messju over at Smarty that seemed to be just right - but it is not supported and fails in the latest version of smarty :(</p>
<p>For p... | [
{
"answer_id": 437921,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": -1,
"selected": false,
"text": "<p>The best way is not to do it. </p>\n\n<p>Smarty is supposed to be simple. This deesn't sound it.</p>\n"
},
{
... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52075/"
] | I found a couple of ways to handle recursion in Smarty, mostly based on including templates into themselves, which seems like ridiculous waste of resources. I found one solution, by Messju over at Smarty that seemed to be just right - but it is not supported and fails in the latest version of smarty :(
For people aski... | "In order to understand recursion, you must first understand recursion..."
Just kidding. This should do what you want:
```
<?php
/*
* Smarty plugin
* ————————————————————-
* File: function.recurse_array.php
* Type: function
* Name: recurse_array
* Purpose: prints out elements of an array recursively
* ——... |
437,864 | <p>I am trying to generate a key using the .net 2.0 PasswordDeriveBytes class.</p>
<pre><code> PasswordDeriveBytes pdb = new PasswordDeriveBytes("blahblahblah",null);
byte[] iv = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 };
byte[] key = pdb.CryptDeriveKey("TripleDES", "SHA1", 128, iv);
</code></pre>
<p>The code throws... | [
{
"answer_id": 437881,
"author": "trampster",
"author_id": 78561,
"author_profile": "https://Stackoverflow.com/users/78561",
"pm_score": 2,
"selected": false,
"text": "<p>TripleDES has a key length of 192 bits try:</p>\n\n<pre><code>byte[] key = pdb.CryptDeriveKey(\"TripleDES\", \"SHA1\"... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17870/"
] | I am trying to generate a key using the .net 2.0 PasswordDeriveBytes class.
```
PasswordDeriveBytes pdb = new PasswordDeriveBytes("blahblahblah",null);
byte[] iv = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 };
byte[] key = pdb.CryptDeriveKey("TripleDES", "SHA1", 128, iv);
```
The code throws "CryptographicException: ... | According to MSDN:
*"If the keySize parameter is set to 0 bits, the default key size for the specified algorithm is used."*
[MSDN PasswordDeriveBytes.CryptDeriveKey Method](http://msdn.microsoft.com/en-us/library/system.security.cryptography.passwordderivebytes.cryptderivekey.aspx)
```
PasswordDeriveBytes pdb = new ... |
437,873 | <p>I have an NSWindow that I defined in interface builder. I want to make it so that when the user clicks a button, it opens a new instance that NSWindow. Do I have to subclass NSWindow or something?</p>
| [
{
"answer_id": 437909,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 6,
"selected": true,
"text": "<p>If you created the window in IB and it's in your main nib file, you cannot create a \"new instance\" each time you pr... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53839/"
] | I have an NSWindow that I defined in interface builder. I want to make it so that when the user clicks a button, it opens a new instance that NSWindow. Do I have to subclass NSWindow or something? | If you created the window in IB and it's in your main nib file, you cannot create a "new instance" each time you press a button. When you create an object in the nib file, an instance is actually created by IB and then archived into the nib file, so you get that instance. Assuming your window is wired to a variable nam... |
437,874 | <p>I need to do a rewrite with nginx from /blah/.../3275 to /id/3275 if the second file exists, otherwise I want to hand it off to apache. Here is my (feeble) attempt</p>
<p>(...) represents irrelevant stuff</p>
<pre><code>if ($request_filename ~^/.../([0-9]+)/$) {
if (-d /id/$1) {
... | [
{
"answer_id": 437901,
"author": "wulong",
"author_id": 52691,
"author_profile": "https://Stackoverflow.com/users/52691",
"pm_score": 1,
"selected": false,
"text": "<p>Best to do this with internal rewrites:</p>\n\n<pre><code>set $original_uri $uri;\n\nlocation /blah/irrelevant_stuff {\n... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to do a rewrite with nginx from /blah/.../3275 to /id/3275 if the second file exists, otherwise I want to hand it off to apache. Here is my (feeble) attempt
(...) represents irrelevant stuff
```
if ($request_filename ~^/.../([0-9]+)/$) {
if (-d /id/$1) {
rewrite ^/.../[0-... | Best to do this with internal rewrites:
```
set $original_uri $uri;
location /blah/irrelevant_stuff {
error_page 404 = @apache;
rewrite ^/blah/irrelevant_stuff/([0-9]+)$ /id/$1;
}
location @apache {
proxy_pass http://upstream$original_uri;
}
``` |
437,882 | <p>What is the most efficient way of testing an input string whether it contains a numeric value (or conversely Not A Number)? I guess I can use <code>Double.Parse</code> or a regex (see below) but I was wondering if there is some built in way to do this, such as javascript's <code>NaN()</code> or <code>IsNumeric()</co... | [
{
"answer_id": 437886,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 9,
"selected": true,
"text": "<p>This doesn't have the regex overhead</p>\n\n<pre><code>double myNum = 0;\nString testVar = \"Not A Number\";\n\nif (Double.T... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] | What is the most efficient way of testing an input string whether it contains a numeric value (or conversely Not A Number)? I guess I can use `Double.Parse` or a regex (see below) but I was wondering if there is some built in way to do this, such as javascript's `NaN()` or `IsNumeric()` (was that VB, I can't remember?)... | This doesn't have the regex overhead
```
double myNum = 0;
String testVar = "Not A Number";
if (Double.TryParse(testVar, out myNum)) {
// it is a number
} else {
// it is not a number
}
```
Incidentally, all of the standard data types, with the glaring exception of GUIDs, support TryParse.
**update**
secret... |
437,899 | <p>I have a SQL table like so</p>
<pre>
PV Area CouterParty
851 M010 Name1
561 M011 Name2
869 M012 Name3
...
</pre>
<p>And I need to transpost it, using T-SQL (not reporting services or anything else), so that it looks like this:</p>
<pre>
CounterParty M010 M011 M012 ....
Name1 ... | [
{
"answer_id": 437910,
"author": "TheTXI",
"author_id": 22164,
"author_profile": "https://Stackoverflow.com/users/22164",
"pm_score": 0,
"selected": false,
"text": "<p>You could do this via a cursor loop and a temporary table. </p>\n\n<p>Select all of you area codes,\nrun the cursor for ... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a SQL table like so
```
PV Area CouterParty
851 M010 Name1
561 M011 Name2
869 M012 Name3
...
```
And I need to transpost it, using T-SQL (not reporting services or anything else), so that it looks like this:
```
CounterParty M010 M011 M012 ....
Name1 851
Name2 ... | You will have to do a Dynamic CrossTab, check these articles:
* [SQLServer: Dynamic Cross-Tab](http://www.databasejournal.com/features/mssql/article.php/3657506/SQLServer-Dynamic-Cross-Tab.htm)
* [Dynamic Cross-Tabs/Pivot Tables](http://www.sqlteam.com/article/dynamic-cross-tabs-pivot-tables)
* [Crosstab Pivot-table W... |
437,908 | <p>how can i use asp.net dynamic data using EF in another dll and i dont want to put connection string in web.config or any config file.
I have this code in Global.asax</p>
<p>model.RegisterContext(() => new MyObjectContext("entityconnectionString"), new ContextConfiguration() { ScaffoldAllTables = true });</p>
<p>t... | [
{
"answer_id": 2991739,
"author": "Josh Simerman",
"author_id": 200292,
"author_profile": "https://Stackoverflow.com/users/200292",
"pm_score": 1,
"selected": false,
"text": "<p>I'm having the same problem. I have my EDMX data model file in one project called NW.DataModel. I added the co... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | how can i use asp.net dynamic data using EF in another dll and i dont want to put connection string in web.config or any config file.
I have this code in Global.asax
model.RegisterContext(() => new MyObjectContext("entityconnectionString"), new ContextConfiguration() { ScaffoldAllTables = true });
the defalut page i... | I was able to resolve this by forcing the load of the MetadataWorkspace and use an overload of the RegisterContext().
```
var context = new MyEntities(); // DataContext
context.MetadataWorkspace.LoadFromAssembly(typeof(MyEntity).Assembly); // An EF Entity
var config = new ContextConfiguration() {ScaffoldAllTables... |
437,911 | <p>CakePHP's <em><a href="http://api.cakephp.org/class/auth-component" rel="noreferrer">AuthComponent</a></em> assumes you have a Users table that contains a username and password. I'd like to find a way to override the default tablename from Users to Accounts.</p>
<p><strong><em>Background Information:</em></strong><... | [
{
"answer_id": 437992,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "<p>In app_controller.php:</p>\n\n<pre><code>function beforeFilter() {\n $this->Auth->userModel = 'Account';\n}\n</cod... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | CakePHP's *[AuthComponent](http://api.cakephp.org/class/auth-component)* assumes you have a Users table that contains a username and password. I'd like to find a way to override the default tablename from Users to Accounts.
***Background Information:***
The way I have designed my database is to have a Users table and... | In app\_controller.php:
```
function beforeFilter() {
$this->Auth->userModel = 'Account';
}
``` |
437,914 | <p>Directory.GetFiles(LocalFilePath, searchPattern);</p>
<p>MSDN Notes:</p>
<blockquote>
<p>When using the asterisk wildcard character in a searchPattern, such as "<em>.txt", the matching behavior when the extension is exactly three characters long is different than when the extension is more or less than three cha... | [
{
"answer_id": 437925,
"author": "Joshua",
"author_id": 14768,
"author_profile": "https://Stackoverflow.com/users/14768",
"pm_score": 3,
"selected": false,
"text": "<p>Not a bug, perverse but well-documented behavior. *.doc matches *.docx based on 8.3 fallback lookup.</p>\n\n<p>You will ... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20910/"
] | Directory.GetFiles(LocalFilePath, searchPattern);
MSDN Notes:
>
> When using the asterisk wildcard character in a searchPattern, such as "*.txt", the matching behavior when the extension is exactly three characters long is different than when the extension is more or less than three characters long. A searchPattern ... | Not a bug, perverse but well-documented behavior. \*.doc matches \*.docx based on 8.3 fallback lookup.
You will have to manually post-filter the results for ending in doc. |
437,915 | <p>Is creating an index for a column that is being summed is faster than no index?</p>
| [
{
"answer_id": 437918,
"author": "Spencer Ruport",
"author_id": 52551,
"author_profile": "https://Stackoverflow.com/users/52551",
"pm_score": 4,
"selected": false,
"text": "<p>No. Indexes improve searches by limiting how many checks are required. An aggregate function (count, max, min, s... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26087/"
] | Is creating an index for a column that is being summed is faster than no index? | Sorry, it is not clear what you are asking.
Are you asking, would it speed up a query such as
```
SELECT product, sum(quantity) FROM receipts
GROUP BY product
```
if you added an index on quantity?
If that is the question, then the answer is no. Generally speaking, indexes are helpful when you need to find just ... |
437,926 | <p>I have two classes:</p>
<pre><code>public class MyBase
{
public virtual void DoMe()
{
}
}
public class MyDerived:MyBase
{
public override void DoMe()
{
throw new NotImplementedException();
}
}
</code></pre>
<p>And I have the following code to instantiate MyDerived:</p>
<pre><cod... | [
{
"answer_id": 437933,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 0,
"selected": false,
"text": "<pre><code>public class MyDerived:MyBase{ \n public override void DoMe() \n { \n base.DoMe();\n }... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | I have two classes:
```
public class MyBase
{
public virtual void DoMe()
{
}
}
public class MyDerived:MyBase
{
public override void DoMe()
{
throw new NotImplementedException();
}
}
```
And I have the following code to instantiate MyDerived:
```
MyDerived myDerived=new MyD... | There's a solution, but it's ugly: use reflection to get the base-class method, and then emit the IL necessary to call it. Check out [this blog post](http://kennethxu.blogspot.com/2009/05/strong-typed-high-performance.html) which illustrates how to do this. I've successfully used this approach it to call the base class... |
437,927 | <p>I need to have PHP authenticate to an exchange server. Once able to succesfully connect to it, I'll need to write webdav requests in the PHP so I can extract data from the exchange server and use it in a web application.</p>
<p>It would be somewhat simple except that the 2003 Exchange server has Forms Based Authent... | [
{
"answer_id": 440642,
"author": "savageguy",
"author_id": 52555,
"author_profile": "https://Stackoverflow.com/users/52555",
"pm_score": 3,
"selected": true,
"text": "<p>I believe the best way to do this is via curl. (<a href=\"http://ca.php.net/curl\" rel=\"nofollow noreferrer\">http://... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54446/"
] | I need to have PHP authenticate to an exchange server. Once able to succesfully connect to it, I'll need to write webdav requests in the PHP so I can extract data from the exchange server and use it in a web application.
It would be somewhat simple except that the 2003 Exchange server has Forms Based Authentication (F... | I believe the best way to do this is via curl. (<http://ca.php.net/curl>)
On the page linked, the first example is a good class to use (I've used it to auto-login into other websites)
It should have KeepAlive (header) and Redirect on by default (`curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);` )
You'll need to en... |
437,952 | <p>Is there a library for crating/extracting zip files in php?</p>
<p>The ZipArchive class works erratically, and this is mentioned on php.net :
(for every function I checked)</p>
<p>ZipArchive::addEmptyDir
(No version information available, might be only in CVS)</p>
| [
{
"answer_id": 438120,
"author": "Irmantas",
"author_id": 43182,
"author_profile": "https://Stackoverflow.com/users/43182",
"pm_score": 2,
"selected": false,
"text": "<p>Check PEAR Archive_Zip it might help you <a href=\"http://pear.php.net/package/Archive_Zip/docs/latest/Archive_Zip/Arc... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49560/"
] | Is there a library for crating/extracting zip files in php?
The ZipArchive class works erratically, and this is mentioned on php.net :
(for every function I checked)
ZipArchive::addEmptyDir
(No version information available, might be only in CVS) | Ok, I checked <http://pear.php.net/package/Archive_Zip> as posted by Irmantas,
but it says this :
"This package is not maintained anymore and has been superseded. Package has moved to channel pecl.php.net, package zip."
Then I searched pear.php.net and stumbled upon :
<http://pear.php.net/package/File_Archive>
... |
437,955 | <p>I have a form which allows the user to create extra "rows" using JQuery (using .clone) so that they can decide how many of the same information they need to submit. My issue is that I cannot work out how to access these form items within my controller.</p>
<p>the form that is being submitted may look like this</p>
... | [
{
"answer_id": 437965,
"author": "Spencer Ruport",
"author_id": 52551,
"author_profile": "https://Stackoverflow.com/users/52551",
"pm_score": 3,
"selected": false,
"text": "<p>I believe if you have multiple fields named Amount the values will be comma delimited.</p>\n\n<p>To access each ... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17248/"
] | I have a form which allows the user to create extra "rows" using JQuery (using .clone) so that they can decide how many of the same information they need to submit. My issue is that I cannot work out how to access these form items within my controller.
the form that is being submitted may look like this
```
<input ty... | I ended up realising that (*blush*) the mechanism which JQuery uses to find the string within the cloned row (to replace) is basically regex. Thus I just needed to escape the square brackets and period. Once I did this I was able use JQuery to create form as Phil Haack's blog suggested.
Onto my next issue...! |
437,958 | <p>I have something like this:</p>
<pre><code><div class="content">
<a href="#">A</a>
</div>
<div class="content">
<a href="#">B</a>
</div>
<div class="content">
<a href="#">C</a>
</div>
</code></pre>
<p>When one of these links is cli... | [
{
"answer_id": 437979,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 10,
"selected": true,
"text": "<p>Try using the <a href=\"http://docs.jquery.com/Traversing/not\" rel=\"noreferrer\"><code>not()</code> <strong>method</s... | 2009/01/13 | [
"https://Stackoverflow.com/questions/437958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29595/"
] | I have something like this:
```
<div class="content">
<a href="#">A</a>
</div>
<div class="content">
<a href="#">B</a>
</div>
<div class="content">
<a href="#">C</a>
</div>
```
When one of these links is clicked, I want to perform the .hide() function on the links that are not clicked. I understand jQuer... | Try using the [`not()` **method**](http://docs.jquery.com/Traversing/not) instead of the [`:not()` selector](http://docs.jquery.com/Selectors/not).
```
$(".content a").click(function() {
$(".content a").not(this).hide("slow");
});
``` |
438,034 | <p>I have a command-line utility that gets quite a bit of downloads from my site. I'm trying to show the usage when a user uses the /? or /help parameters. I have a function called ShowUsage() that has nicely formatted text on the parameters available.</p>
<p>I see that ShowUsage() gets called fine from Visual Studio ... | [
{
"answer_id": 438042,
"author": "JD Conley",
"author_id": 51769,
"author_profile": "https://Stackoverflow.com/users/51769",
"pm_score": 0,
"selected": false,
"text": "<p>Are you redirecting Console.Out to somewhere else?</p>\n\n<p>Try throwing a System.Diagnostics.Debugger.Launch() in t... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12829/"
] | I have a command-line utility that gets quite a bit of downloads from my site. I'm trying to show the usage when a user uses the /? or /help parameters. I have a function called ShowUsage() that has nicely formatted text on the parameters available.
I see that ShowUsage() gets called fine from Visual Studio 2008, when... | Can you define "not working"? Simply not doing anything? Throwing an exception? I would expect the problem to be in the `Main(...)` method - i.e. `ShowUsage()` isn't being called. Another common issue is not rebuilding it in the correct configuration, so `bin/release` (or whatever) isn't updated.
**Have you built the ... |
438,044 | <p>I'd like to be able to use php search an array (or better yet, a column of a mysql table) for a particular string. However, my goal is for it to return the string it finds and the number of matching characters (in the right order) or some other way to see how reasonable the search results are, so then I can make use... | [
{
"answer_id": 438060,
"author": "Beau Simensen",
"author_id": 50453,
"author_profile": "https://Stackoverflow.com/users/50453",
"pm_score": 0,
"selected": false,
"text": "<p>This can be very complicated, and I am not personally aware of any good 3rd party libraries although I'm sure the... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46102/"
] | I'd like to be able to use php search an array (or better yet, a column of a mysql table) for a particular string. However, my goal is for it to return the string it finds and the number of matching characters (in the right order) or some other way to see how reasonable the search results are, so then I can make use of... | More searching led me to the Levenshtein distance and then to similar\_text, which proved to be the best way to do this.
```
similar_text("input string", "match against this", $pct_accuracy);
```
compares the strings and then saves the accuracy as a variable. The Levenshtein distance determines how many delete, inse... |
438,046 | <p>Any ideas as to how Apple implemented the "slide to unlock" (also, "slide to power off" is another identical example) animation?</p>
<p>I thought about some sort of animating mask - but masking is not available on the iPhone OS for performance reasons.</p>
<p>Is there some private API effect (like SuckEffect) that... | [
{
"answer_id": 438223,
"author": "bhollis",
"author_id": 11284,
"author_profile": "https://Stackoverflow.com/users/11284",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe it's just a rendered-out animation - you know, a series of stills played one after another. Not necessarily a dyn... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Any ideas as to how Apple implemented the "slide to unlock" (also, "slide to power off" is another identical example) animation?
I thought about some sort of animating mask - but masking is not available on the iPhone OS for performance reasons.
Is there some private API effect (like SuckEffect) that they might have ... | It can be easilly done by using Core Animation, animating a mask layer on the layer displaying the text.
Try this in any plain UIViewController (you can start with a new Xcode project based on the *View-based application* project template), or grab my Xcode project [here](http://dl.dropbox.com/u/713729/SlideToUnlock.z... |
438,062 | <p>I am using MySQL and PHP. I have a table that contains the columns id and quantity. I would like to retrieve the id of the row that is the last to sum quantity as it reaches the number 40 at sum. To be more specific. I have 3 rows in the database. One with quantity 10, one with quantity 30 and one with quantity 20. ... | [
{
"answer_id": 438069,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 1,
"selected": false,
"text": "<p>Have a third column with a running total. Then you can simply return the last row where the running total <= your target... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54470/"
] | I am using MySQL and PHP. I have a table that contains the columns id and quantity. I would like to retrieve the id of the row that is the last to sum quantity as it reaches the number 40 at sum. To be more specific. I have 3 rows in the database. One with quantity 10, one with quantity 30 and one with quantity 20. So ... | I don't understand your question too well. Can you try rewording it more properly? From what I interpret, here's the structure of your database:
```
ProductID ArrivalDate
1 10
2 11
3 11
4 11
5 12
6 12
```
Now you are asking, "how would I know... |
438,074 | <p>I have a dataset which is having some 28 columns Now I want to make another dataSet that will contain two dataTable having 14 columns in each table from the previous dataset.</p>
<p>Help needed.</p>
| [
{
"answer_id": 438132,
"author": "Igor Zelaya",
"author_id": 22769,
"author_profile": "https://Stackoverflow.com/users/22769",
"pm_score": 3,
"selected": true,
"text": "<p>I will asumme you have some data in it.</p>\n\n<p>Create to Datatables one with the first 14 columns(firstPart), and... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a dataset which is having some 28 columns Now I want to make another dataSet that will contain two dataTable having 14 columns in each table from the previous dataset.
Help needed. | I will asumme you have some data in it.
Create to Datatables one with the first 14 columns(firstPart), and the other with the lasts 14 columns plus the primary key(secondPart).
```
DataTable firstPart = new DataTable();
//Initialize columns here...
DataTable secondPart = new DataTable();
//Initialize... |
438,087 | <p>I have a filename that has the following format:</p>
<p>timestamp-username-1</p>
<p>This file is constantly etting written to, but before it gets too large I want to create a new file.</p>
<p>timestamp-username-2</p>
<p>How can I acheive this with using least amount of memory (ie, no or little variables)</p>
<p... | [
{
"answer_id": 438094,
"author": "Dennis C",
"author_id": 40214,
"author_profile": "https://Stackoverflow.com/users/40214",
"pm_score": 2,
"selected": false,
"text": "<p>\"least amount of memory\" is NOT equals to \"no or little variables\"</p>\n\n<p>Local variables only takes little mem... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50312/"
] | I have a filename that has the following format:
timestamp-username-1
This file is constantly etting written to, but before it gets too large I want to create a new file.
timestamp-username-2
How can I acheive this with using least amount of memory (ie, no or little variables)
here is my version:
```
priv... | I think you should just store the counter in an int. I understand that you want to save memory space but to be honest, an extra int is really in the "acceptable" category. I mean, the Int32 parser is probably wasting way much more memory. Don't forget that on x86, the memory space is spitted to 4096 byte pages so there... |
438,092 | <p>I need to create a new process with redirected standard error stream to some file. The code from which child process is being created has no console available, so there are cases when GetStdHandle(any) will return 0. Child process will try to duplicate all of its standard IO handles for some reason (source code for ... | [
{
"answer_id": 438103,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 4,
"selected": true,
"text": "<p>As originally phrased, you have already answered your own question. To open a \"nul\" file, you simply specify <code... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53481/"
] | I need to create a new process with redirected standard error stream to some file. The code from which child process is being created has no console available, so there are cases when GetStdHandle(any) will return 0. Child process will try to duplicate all of its standard IO handles for some reason (source code for chi... | As originally phrased, you have already answered your own question. To open a "nul" file, you simply specify `"nul"` when you call `CreateFile`. It only looks weird because hardly anyone ever uses that file name. (I don't see it used nearly as often as I see `/dev/null`.) It's perfectly valid, though.
But if you've fo... |
438,095 | <p>I am writing a custom Windows Workflow Foundation activity, that starts some process asynchronously, and then should wake up when an async event arrives. </p>
<p>All the samples I’ve found (e.g. <a href="http://blogs.msdn.com/kaevans/archive/2007/07/02/asynchronous-workflow-activities-implemented-asynchronous-webre... | [
{
"answer_id": 439105,
"author": "Maurice",
"author_id": 19676,
"author_profile": "https://Stackoverflow.com/users/19676",
"pm_score": 2,
"selected": true,
"text": "<p>There is a potential problem here with regard to workflow persistence.</p>\n\n<p>If you create long running worklfows th... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19880/"
] | I am writing a custom Windows Workflow Foundation activity, that starts some process asynchronously, and then should wake up when an async event arrives.
All the samples I’ve found (e.g. [this one by Kirk Evans](http://blogs.msdn.com/kaevans/archive/2007/07/02/asynchronous-workflow-activities-implemented-asynchronous... | There is a potential problem here with regard to workflow persistence.
If you create long running worklfows that are persisted in a database to the runtime will be able to restart these workflows are not reloaded into memory until there is some external event that reloads them. As there they are responsible for trigge... |
438,105 | <p>I have been stumped by CakePHP in how to query the DB in CakePHP and return things to $data only when the $data query table [id] has a matching [sub_id] in a second table</p>
<p>a standard query:</p>
<pre><code>$data = $this->Table1->findAll(array("Table1.deleted" => "0"), null, "Table1.id DESC", 25, null... | [
{
"answer_id": 438138,
"author": "Beau Simensen",
"author_id": 50453,
"author_profile": "https://Stackoverflow.com/users/50453",
"pm_score": 1,
"selected": false,
"text": "<p>If you have your relationships setup properly it should do this automatically. Can you paste your Model relations... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36076/"
] | I have been stumped by CakePHP in how to query the DB in CakePHP and return things to $data only when the $data query table [id] has a matching [sub\_id] in a second table
a standard query:
```
$data = $this->Table1->findAll(array("Table1.deleted" => "0"), null, "Table1.id DESC", 25, null, 1);
```
But I want to onl... | If you have your relationships setup properly it should do this automatically. Can you paste your Model relationship setup for Table1 and Table2? |
438,108 | <p>How do I create a link to set the user's home page to my URL?</p>
| [
{
"answer_id": 438123,
"author": "Steven Robbins",
"author_id": 26507,
"author_profile": "https://Stackoverflow.com/users/26507",
"pm_score": 0,
"selected": false,
"text": "<p>I assume you mean put a link in your page to make it the browser homepage? In IE you can do something like:</p>\... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I create a link to set the user's home page to my URL? | As some people have already answered, it used to be possible in internet explorer (prior to IE 7 I believe, could be wrong though) using something similar to
```
document.setHomePage('www.example.com');
```
I don't think any browser supports it anymore though. However, I would definitely try to convince you to do ot... |
438,116 | <p>I have a page, lets call it SourceTypes.aspx, that has a a GridView that is displaying a list of Source Types. Part of the GridView is a DataKey, SourceTypeID. If source TypeID is passed to the page via a query sting, how to I put the Gridview into Edit mode for the appropriate row based on the SourceTypeID?</p>
<p... | [
{
"answer_id": 438123,
"author": "Steven Robbins",
"author_id": 26507,
"author_profile": "https://Stackoverflow.com/users/26507",
"pm_score": 0,
"selected": false,
"text": "<p>I assume you mean put a link in your page to make it the browser homepage? In IE you can do something like:</p>\... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4665/"
] | I have a page, lets call it SourceTypes.aspx, that has a a GridView that is displaying a list of Source Types. Part of the GridView is a DataKey, SourceTypeID. If source TypeID is passed to the page via a query sting, how to I put the Gridview into Edit mode for the appropriate row based on the SourceTypeID?
The GridV... | As some people have already answered, it used to be possible in internet explorer (prior to IE 7 I believe, could be wrong though) using something similar to
```
document.setHomePage('www.example.com');
```
I don't think any browser supports it anymore though. However, I would definitely try to convince you to do ot... |
438,122 | <p>I have a file format which is similar to "IDY03101.200901110500.axf". I have about 25 similar files residing in an ftp repository and want to download all those similar files only for the current date. I have used the following code, which is not working and believe the regular expression is incorrect.</p>
<pre>
my... | [
{
"answer_id": 438130,
"author": "Beau Simensen",
"author_id": 50453,
"author_profile": "https://Stackoverflow.com/users/50453",
"pm_score": 1,
"selected": false,
"text": "<p>I do not think regexes work like that. Though it has been awhile since I did Perl, so I could be way off there. :... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53121/"
] | I have a file format which is similar to "IDY03101.200901110500.axf". I have about 25 similar files residing in an ftp repository and want to download all those similar files only for the current date. I have used the following code, which is not working and believe the regular expression is incorrect.
```
my @ymb_da... | It doesn't look like you're using any regular expression. You're trying to use the literal pattern as the filename to download.
Perhaps you want to use the `ls` method of [Net::FTP](http://search.cpan.org/dist/libnet) to get the list of files then filter them.
```
foreach my $file ( $ftp->ls ) {
next unless $fil... |
438,136 | <p>before posting the whole code, i wanted to make sure I am not missing a simple issue here.</p>
<pre><code>var dv = $(myElement);
var pos = dv.offset();
var width = dv.width();
var height = dv.height();
alert(pos);
alert(width);
alert(height);
</code></pre>
<p>here, width alerts fine, height alerts fine but offse... | [
{
"answer_id": 438140,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 3,
"selected": true,
"text": "<p>that's correct: the <code>offset()</code> function returns an object containing two properties, <code>left</code> and <code>... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49742/"
] | before posting the whole code, i wanted to make sure I am not missing a simple issue here.
```
var dv = $(myElement);
var pos = dv.offset();
var width = dv.width();
var height = dv.height();
alert(pos);
alert(width);
alert(height);
```
here, width alerts fine, height alerts fine but offset alerts [object Object] (... | that's correct: the `offset()` function returns an object containing two properties, `left` and `top`. (See [the docs](http://docs.jquery.com/CSS/offset)). "[object Object]" is how most objects are converted to strings.
I'd suggest you install Firebug to help you with debugging Javascript like this as it would give yo... |
438,150 | <p>I want to find all <code>if</code> statements and <code>for</code> statements which are not followed by curly brackets '<code>{</code>'. When you write a single line in an <code>if</code> statement you do not mostly enclose it in curly brackets, so I want to find all those <code>if</code> and <code>for</code> statem... | [
{
"answer_id": 438155,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 4,
"selected": true,
"text": "<p>Since the underlying mathematics disallow a perfect match, you could go for a good heuristic like \"find all '<code>... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40570/"
] | I want to find all `if` statements and `for` statements which are not followed by curly brackets '`{`'. When you write a single line in an `if` statement you do not mostly enclose it in curly brackets, so I want to find all those `if` and `for` statements.
Please help!
Like I want to capture this statement
```
if (c... | Since the underlying mathematics disallow a perfect match, you could go for a good heuristic like "find all '`if`' followed by a semicolon without an intervening open brace:
```
/\<if\>[^{]*;/
```
where `\<` and `\>` are begin-of-word and end-of-word as applicable to your regex dialect. Also take care to ignore all ... |
438,172 | <p>Is there a general consensus on how to use SQL 2005's full text search with SubSonic? I know that I can use the InlineQuery and get an IDataReader, but is this the only way to do this? Also, how would I incorporate paging into it? Would I have to write the paging myself in the InlineQuery?</p>
<p>What I would re... | [
{
"answer_id": 438241,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 1,
"selected": false,
"text": "<p>This is one case with SubSonic where I think it is easier to create a stored procedure and build the collection from... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] | Is there a general consensus on how to use SQL 2005's full text search with SubSonic? I know that I can use the InlineQuery and get an IDataReader, but is this the only way to do this? Also, how would I incorporate paging into it? Would I have to write the paging myself in the InlineQuery?
What I would really like to ... | This is one case with SubSonic where I think it is easier to create a stored procedure and build the collection from the result. Paging in a sproc isn't that difficult to implement (capture the sql generated by SubSonic and reuse it).
You can build a typed collection from the sproc by passing SPs.SPNameHere.GetReader(... |
438,184 | <p>Right now I am using this to export a repeater (with multiple nested repeaters) to excel:</p>
<pre><code>protected void ExportToExcel(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=finance.xls");
Response.Charset = "";
Re... | [
{
"answer_id": 438228,
"author": "Spencer Ruport",
"author_id": 52551,
"author_profile": "https://Stackoverflow.com/users/52551",
"pm_score": 5,
"selected": true,
"text": "<p>You need to enclose all of that in table tags. Excel can understand HTML table structures.</p>\n\n<p>Try:</p>\n\n... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14777/"
] | Right now I am using this to export a repeater (with multiple nested repeaters) to excel:
```
protected void ExportToExcel(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=finance.xls");
Response.Charset = "";
Response.Content... | You need to enclose all of that in table tags. Excel can understand HTML table structures.
Try:
```
Response.Write("<table>");
Response.Write(stringWrite.ToString());
Response.Write("</table>");
``` |
438,185 | <p>What is the best way to store large amounts of data in python, given one (or two) 500,000 item+ dictionary used for undirected graph searching?</p>
<p>I've been considering a few options such as storing the data as XML:</p>
<pre><code><key name="a">
<value data="1" />
<value data="2" />
&... | [
{
"answer_id": 438226,
"author": "mac",
"author_id": 53943,
"author_profile": "https://Stackoverflow.com/users/53943",
"pm_score": 2,
"selected": false,
"text": "<p>I would consider using one of the many graph libraries available for python (e.g. <a href=\"http://code.google.com/p/python... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49386/"
] | What is the best way to store large amounts of data in python, given one (or two) 500,000 item+ dictionary used for undirected graph searching?
I've been considering a few options such as storing the data as XML:
```
<key name="a">
<value data="1" />
<value data="2" />
</key>
<key name="b">
...
```
or in a ... | The Python source technique absolutely rules.
XML is slow to parse, and relatively hard to read by people. That's why companies like Altova are in business -- XML isn't pleasant to edit.
Python source `db = {"a": [1, 2], "b": ...}` is
1. Fast to parse.
2. Easy to read by people.
If you have programs that read and ... |
438,188 | <p>Is there a nice way to split a collection into <code>n</code> parts with LINQ?
Not necessarily evenly of course.</p>
<p>That is, I want to divide the collection into sub-collections, which each contains a subset of the elements, where the last collection can be ragged.</p>
| [
{
"answer_id": 438208,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 6,
"selected": false,
"text": "<p>EDIT: Okay, it looks like I misread the question. I read it as \"pieces of length n\" rather than \"n pieces\". Doh! ... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | Is there a nice way to split a collection into `n` parts with LINQ?
Not necessarily evenly of course.
That is, I want to divide the collection into sub-collections, which each contains a subset of the elements, where the last collection can be ragged. | A pure linq and the simplest solution is as shown below.
```
static class LinqExtensions
{
public static IEnumerable<IEnumerable<T>> Split<T>(this IEnumerable<T> list, int parts)
{
int i = 0;
var splits = from item in list
group item by i++ % parts into part
... |
438,189 | <p>I've got a form with a bunch of checkboxes on it, and I'd like to provide a "check all" link/button.</p>
<p>I'm using the code below, but when it runs, it picks up some radio buttons on the page, and checks/unchecks those too. How do I fix this?</p>
<pre><code>var check = 0;
function doNow()
{
void(d=document)... | [
{
"answer_id": 438194,
"author": "Rob",
"author_id": 3542,
"author_profile": "https://Stackoverflow.com/users/3542",
"pm_score": 3,
"selected": false,
"text": "<p>You're going to want to check the element's type to ensure you don't accidentally go checking the wrong kind of inputs.</p>\n... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48094/"
] | I've got a form with a bunch of checkboxes on it, and I'd like to provide a "check all" link/button.
I'm using the code below, but when it runs, it picks up some radio buttons on the page, and checks/unchecks those too. How do I fix this?
```
var check = 0;
function doNow()
{
void(d=document);
void(el=d.getEl... | You're going to want to check the element's type to ensure you don't accidentally go checking the wrong kind of inputs.
Basic example:
```
function checkAll( toggle ) {
var inputs = document.getElementsByTagName( 'input' );
for( var i = 0; i < inputs.length; i++ ) {
if( inputs[i].type == 'checkbox' ) ... |
438,192 | <p>A <em>using</em> declaration does not seem to work with an enum type:</p>
<pre><code>class Sample{
public:
enum Colour {RED, BLUE, GREEN};
}
using Sample::Colour;
</code></pre>
<p>does not work!</p>
<p>Do we need to add a <em>using</em> declaration for every enumerators of enum type? Like below:</p>
<p... | [
{
"answer_id": 438210,
"author": "Steve Lacey",
"author_id": 11077,
"author_profile": "https://Stackoverflow.com/users/11077",
"pm_score": 4,
"selected": true,
"text": "<p>A class does not define a namespace, and therefore "using" isn't applicable here.</p>\n<p>Also, you need t... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] | A *using* declaration does not seem to work with an enum type:
```
class Sample{
public:
enum Colour {RED, BLUE, GREEN};
}
using Sample::Colour;
```
does not work!
Do we need to add a *using* declaration for every enumerators of enum type? Like below:
```
using sample::Colour::RED;
``` | A class does not define a namespace, and therefore "using" isn't applicable here.
Also, you need to make the enum public.
If you're trying to use the enum within the same class, here's an example:
```
class Sample {
public:
enum Colour { RED, BLUE, GREEN };
void foo();
}
void Sample::foo() {
Colour foo = RE... |
438,199 | <p>Coming from a VB background and being forced to learn C# I have hit the first hurdle. </p>
<p>In VB i could put all the namespaces I wanted available across the entire app in the web.config file and it would be available in each code behind file without me having to add import statements. </p>
<pre><code><names... | [
{
"answer_id": 438205,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 4,
"selected": true,
"text": "<p>For C#, the namespaces entered in the web.config will be recognized in .aspx files, but not codebehind. I don't think... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23230/"
] | Coming from a VB background and being forced to learn C# I have hit the first hurdle.
In VB i could put all the namespaces I wanted available across the entire app in the web.config file and it would be available in each code behind file without me having to add import statements.
```
<namespaces>
<clear/>
<add nam... | For C#, the namespaces entered in the web.config will be recognized in .aspx files, but not codebehind. I don't think it will take you long to adjust (Ctrl-. will let you quickly add a namespace when you type a class name that doesn't have the namespace referenced). |
438,221 | <p>as I googled for problem, somehow java printing API is crippled with limitation that all pictures sent to printer must be printed in 72dpi resolution. We are using jasper report to print documents and no matter how big barcode we draw, barcode reader won't scan it.. any similar experiences? How to solve this issue?<... | [
{
"answer_id": 438274,
"author": "Fernando Miguélez",
"author_id": 34880,
"author_profile": "https://Stackoverflow.com/users/34880",
"pm_score": 3,
"selected": true,
"text": "<p>You need to specify the printer resolution by means of attribute <a href=\"http://java.sun.com/j2se/1.5.0/docs... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | as I googled for problem, somehow java printing API is crippled with limitation that all pictures sent to printer must be printed in 72dpi resolution. We are using jasper report to print documents and no matter how big barcode we draw, barcode reader won't scan it.. any similar experiences? How to solve this issue? | You need to specify the printer resolution by means of attribute [PrinterResolution](http://java.sun.com/j2se/1.5.0/docs/api/javax/print/attribute/standard/PrinterResolution.html). You should also know the source resolution so it is correctly converted such as:
```
PrinterResolution pr = new PrinterResolution(300, 300... |
438,240 | <p>Is there a way in C# or C/C++ & Win32 to monitor a certain process's network usage (Without that application being built by you obviously)? I would like to monitor just 1 process for like an hour or so, then return the bytes used by only that process, such as limewire for example.</p>
<p>Is it possible? I know ... | [
{
"answer_id": 438262,
"author": "Sam Saffron",
"author_id": 17174,
"author_profile": "https://Stackoverflow.com/users/17174",
"pm_score": 3,
"selected": false,
"text": "<p>You could use <a href=\"http://www.winpcap.org/\" rel=\"noreferrer\">WinPcap</a> for this or write your own device ... | 2009/01/13 | [
"https://Stackoverflow.com/questions/438240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36457/"
] | Is there a way in C# or C/C++ & Win32 to monitor a certain process's network usage (Without that application being built by you obviously)? I would like to monitor just 1 process for like an hour or so, then return the bytes used by only that process, such as limewire for example.
Is it possible? I know netstat -e on ... | You could use [WinPcap](http://www.winpcap.org/) for this or write your own device driver. I don't think there are any per process perfmon counters you can leverage. |