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 |
|---|---|---|---|---|---|---|
444,322 | <p>What does it mean to call a class like this:</p>
<pre><code>class Example
{
public:
Example(void);
~Example(void);
}
int main(void)
{
Example ex(); // <<<<<< what is it called to call it like this?
return(0);
}
</code></pre>
<p>Like it appears that it isn't calling the default construct... | [
{
"answer_id": 444342,
"author": "Nemanja Trifunovic",
"author_id": 8899,
"author_profile": "https://Stackoverflow.com/users/8899",
"pm_score": 2,
"selected": false,
"text": "<p>Does it even compile? Anyway, see <a href=\"https://stackoverflow.com/questions/180172/ctor-with-no-arguments\... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55133/"
] | What does it mean to call a class like this:
```
class Example
{
public:
Example(void);
~Example(void);
}
int main(void)
{
Example ex(); // <<<<<< what is it called to call it like this?
return(0);
}
```
Like it appears that it isn't calling the default constructor in that case. Can someone give a reason w... | Currently you are trying to call the default constructor like so.
```
Example ex();
```
This is not actually calling the default constructor. Instead you are defining a function prototype with return type Example and taking no parameters. In order to call the default constructor, omit the ()'s
```
Example ex;
``` |
444,331 | <p>I am binding an Image.Source property to the result of the property shown below. </p>
<pre><code>public BitmapSource MyImageSource
{
get
{
BitmapSource source = null;
PngBitmapDecoder decoder;
using (var stream = new FileStream(@"C:\Temp\logo.png", FileMode.Open, FileAccess.Read, Fi... | [
{
"answer_id": 444459,
"author": "Adrian",
"author_id": 55160,
"author_profile": "https://Stackoverflow.com/users/55160",
"pm_score": 0,
"selected": false,
"text": "<p>Are you positive it's a PNG and not just a renamed Bitmap or Jpeg? If you create a new Bitmap image and then just rename... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38309/"
] | I am binding an Image.Source property to the result of the property shown below.
```
public BitmapSource MyImageSource
{
get
{
BitmapSource source = null;
PngBitmapDecoder decoder;
using (var stream = new FileStream(@"C:\Temp\logo.png", FileMode.Open, FileAccess.Read, FileShare.Read))... | The problem was the BitmapCacheOption option, changing to BitmapCacheOption.OnLoad works.
With BitmapCacheOption.None the BitmapSource isn’t decoded until the image is rendered, but the stream with the png in it is already disposed at that point. If you cache OnLoad, it’ll decode right away and cache the results, rat... |
444,356 | <p>I have a application and several plugins in DLL files. The plugins use symbols from the
application via a export library. The application links in several static libraries and this is where most of the symbols come from. This works fine as long as the application uses a symbol. If the symbol is not used there, I get... | [
{
"answer_id": 445740,
"author": "Greg Domjan",
"author_id": 37558,
"author_profile": "https://Stackoverflow.com/users/37558",
"pm_score": 2,
"selected": false,
"text": "<p>You probably want to look at __declspec(export/import)</p>\n\n<pre><code>#ifdef DLL_EXPORTING\n#define WHDLL __decl... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55132/"
] | I have a application and several plugins in DLL files. The plugins use symbols from the
application via a export library. The application links in several static libraries and this is where most of the symbols come from. This works fine as long as the application uses a symbol. If the symbol is not used there, I get li... | You probably want to look at \_\_declspec(export/import)
```
#ifdef DLL_EXPORTING
#define WHDLL __declspec(dllexport)
#else
#define WHDLL __declspec(dllimport)
#endif
```
When linking static module into a dll it will only bring in the code that is used. I've never imported stuff from a static lib to simply re export... |
444,372 | <p>New to PHP and web development in general. I am trying to get information from an HTML form to appear in a table on another web page after clicking submit. So I installed Apache and then PHP on my local PC and expected to be able to test a PHP script locally however it does not return the information I was expecting... | [
{
"answer_id": 444379,
"author": "ryeguy",
"author_id": 49018,
"author_profile": "https://Stackoverflow.com/users/49018",
"pm_score": 3,
"selected": false,
"text": "<p>Check out <a href=\"http://www.apachefriends.org/en/xampp.html\" rel=\"noreferrer\">xampp</a>. It installs Apache, Mysql... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | New to PHP and web development in general. I am trying to get information from an HTML form to appear in a table on another web page after clicking submit. So I installed Apache and then PHP on my local PC and expected to be able to test a PHP script locally however it does not return the information I was expecting.
... | Check out [xampp](http://www.apachefriends.org/en/xampp.html). It installs Apache, Mysql, Perl, and PHP on your machine so you can test your entire site locally. It's a one shot installer and comes with a nifty control panel to enable/disable each service as needed. |
444,376 | <p><strong>Duplicate of: <a href="https://stackoverflow.com/questions/50499/in-python-how-do-i-get-the-path-and-name-of-the-file-that-is-currently-executing">In Python, how do I get the path and name of the file that is currently executing?</a></strong></p>
<p>I would like to find out the path to the currently executi... | [
{
"answer_id": 444392,
"author": "Epitaph",
"author_id": 48725,
"author_profile": "https://Stackoverflow.com/users/48725",
"pm_score": 1,
"selected": false,
"text": "<p>How about using sys.path[0] </p>\n\n<p>You can do something like<br>\n'print os.path.join(sys.path[0], sys.argv[0])... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32933/"
] | **Duplicate of: [In Python, how do I get the path and name of the file that is currently executing?](https://stackoverflow.com/questions/50499/in-python-how-do-i-get-the-path-and-name-of-the-file-that-is-currently-executing)**
I would like to find out the path to the currently executing script.
I have tried os.getcwd(... | In Python, `__file__` identifies the current Python file. Thus:
```
print "I'm inside Python file %s" % __file__
```
will print the current Python file. Note that this works in imported Python modules, as well as scripts. |
444,388 | <p>How can one pass command line arguments via file association in Vista 64?</p>
<p>I recently built a PC running Vista Ultimate 64-bit. I noticed several of the Perl scripts I transferred failed due to command-line arguments not being passed. As a simple test, I wrote the following (foo.pl):</p>
<pre><code>#!/usr/... | [
{
"answer_id": 444452,
"author": "devio",
"author_id": 21336,
"author_profile": "https://Stackoverflow.com/users/21336",
"pm_score": 3,
"selected": false,
"text": "<p>Don't know about Vista and 64bits, but under \"classic\" versions of Windows you can edit the registry:</p>\n\n<pre><code... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15286/"
] | How can one pass command line arguments via file association in Vista 64?
I recently built a PC running Vista Ultimate 64-bit. I noticed several of the Perl scripts I transferred failed due to command-line arguments not being passed. As a simple test, I wrote the following (foo.pl):
```
#!/usr/bin/perl -w
use strict;... | I just tried ActivePerl-5.10.0.1004-MSWin32-x64-287188.msi on my Vista 64 Ultimate and it worked.
```
F:\prog\perl>foo.pl 1 2 3
3 arguments read
C:\Perl64\bin\perl.exe
```
That means [devio is right](https://stackoverflow.com/questions/444388/how-can-one-pass-command-line-arguments-via-file-association-in-vista-64#4... |
444,401 | <p>I have this method:</p>
<pre><code> private delegate void watcherReader(StreamReader sr);
private void watchProc(StreamReader sr) {
while (true) {
string line = sr.ReadLine();
while (line != null) {
if (stop) {
return;
}
... | [
{
"answer_id": 444425,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 4,
"selected": true,
"text": "<p>Whenever you have a <code>while(true)</code> loop in your code you're going to peg your cpu (or at least one core) a... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | I have this method:
```
private delegate void watcherReader(StreamReader sr);
private void watchProc(StreamReader sr) {
while (true) {
string line = sr.ReadLine();
while (line != null) {
if (stop) {
return;
}
//... | Whenever you have a `while(true)` loop in your code you're going to peg your cpu (or at least one core) at 100%, unless you also have a way to break out of the loop. In your case, you do have a `return` statement, but at no point in the loop do you ever do anything to the `stop` variable guarding it. |
444,405 | <p>Is there a SQL command that could be used in a query, stored procedure, function, that would work against a Binary Type similar to the following C# code?</p>
<pre><code>if (someBinaryArray[index] == 0) {
...
</code></pre>
<p>I'm wanting to check if an index of a position in the binary is a certain value instead o... | [
{
"answer_id": 444418,
"author": "bobwienholt",
"author_id": 24257,
"author_profile": "https://Stackoverflow.com/users/24257",
"pm_score": 2,
"selected": true,
"text": "<p>You can use Substring(), according to the documentation it works with binary columns:</p>\n\n<pre><code>SELECT *\nFR... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17091/"
] | Is there a SQL command that could be used in a query, stored procedure, function, that would work against a Binary Type similar to the following C# code?
```
if (someBinaryArray[index] == 0) {
...
```
I'm wanting to check if an index of a position in the binary is a certain value instead of pulling the entire array... | You can use Substring(), according to the documentation it works with binary columns:
```
SELECT *
FROM Table
WHERE Substring(column, index, length) = 'blah'
```
If you really wanted to check for a null (as in your example)... you could do this:
```
SELECT *
FROM table
WHERE SUBSTRING(column, 3, 1) = CHAR(0)
``` |
444,426 | <p>In our infrastructure, we have lots of little Java projects built by Maven2. Each project has its own pom.xml that ultimately inherits from our one company "master" parent pom.</p>
<p>We've recently started adding small profiles to our parent pom, disabled by default, that, when enabled, execute a single plugin in ... | [
{
"answer_id": 444501,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 1,
"selected": false,
"text": "<p>The problem with this solution is that you may be creating a \"pick and choose\" model which is a bit un-mavenesque.... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1557/"
] | In our infrastructure, we have lots of little Java projects built by Maven2. Each project has its own pom.xml that ultimately inherits from our one company "master" parent pom.
We've recently started adding small profiles to our parent pom, disabled by default, that, when enabled, execute a single plugin in a conventi... | You seem slightly suspicious towards that approach, but you're not really sure why - after all, it is quite convenient. Anyway, that's what I feel about it: I don't really know why, but it seems somewhat odd.
Let's consider these two questions:
a) what are profiles meant for?
b) what are the alternative approaches we ... |
444,430 | <p>I have an application which may only have one instance of itself open at a time. To enforce this, I use this code:</p>
<pre><code>System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();
System.Diagnostics.Process me = System.Diagnostics.Process.GetCurrentProcess();
foreach (System.Diagn... | [
{
"answer_id": 444457,
"author": "cmsjr",
"author_id": 23114,
"author_profile": "https://Stackoverflow.com/users/23114",
"pm_score": 2,
"selected": false,
"text": "<p>I believe you will want to use <a href=\"http://msdn.microsoft.com/en-us/library/ms633539(VS.85).aspx\" rel=\"nofollow no... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1388/"
] | I have an application which may only have one instance of itself open at a time. To enforce this, I use this code:
```
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();
System.Diagnostics.Process me = System.Diagnostics.Process.GetCurrentProcess();
foreach (System.Diagnostics.Proces... | I had the same problem and [SwitchToThisWindow()](http://msdn.microsoft.com/en-us/library/ms633553.aspx) worked the best for me. The only limitation is that you must have XP sp1 installed. I played with SetForegroundWindow, ShowWindow, and they both had problems pulling the window into view. |
444,443 | <p>In Delphi, you can use compiler directives to disable specific warnings, such as</p>
<pre><code>{$WARN USE_BEFORE_DEF OFF}
</code></pre>
<p>But when I tried to do that with a specific hint, whose underscore_style_name I got out of the helpfile, the compiler said it doesn't know what {$HINT} is. So is there any wa... | [
{
"answer_id": 444472,
"author": "JosephStyons",
"author_id": 672,
"author_profile": "https://Stackoverflow.com/users/672",
"pm_score": 2,
"selected": false,
"text": "<p>Best I can think of is to surround the subject of the hint with a conditional define, and use the same conditional def... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32914/"
] | In Delphi, you can use compiler directives to disable specific warnings, such as
```
{$WARN USE_BEFORE_DEF OFF}
```
But when I tried to do that with a specific hint, whose underscore\_style\_name I got out of the helpfile, the compiler said it doesn't know what {$HINT} is. So is there any way to do this? | No specific hints, but you can disable them all.
```
{$HINTS OFF}
procedure MyProc;
var
i : integer;
begin
DoSomething;
end;
{$HINTS ON}
``` |
444,467 | <pre>
SELECT * FROM table1, table2
WHERE table1.user_id = table2.id
AND table1.content = news
AND table1.content_id = 1
</pre>
<p>that wont work. cant u have two "AND" in a sql statement??</p>
<p>//Tomek</p>
| [
{
"answer_id": 444476,
"author": "user54650",
"author_id": 54650,
"author_profile": "https://Stackoverflow.com/users/54650",
"pm_score": 4,
"selected": false,
"text": "<p>you probably want to quote 'news' as a string... \nYou also probably want to use an inner join instead (much more eff... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
SELECT * FROM table1, table2
WHERE table1.user_id = table2.id
AND table1.content = news
AND table1.content_id = 1
```
that wont work. cant u have two "AND" in a sql statement??
//Tomek | you probably want to quote 'news' as a string...
You also probably want to use an inner join instead (much more efficient)
```
SELECT * FROM table1
INNER JOIN table2 ON table1.user_id = table2.id
WHERE table1.content = 'news'
AND table1.content_id = 1
``` |
444,468 | <p>I've been thrown into an ASP.NET project and I've got a page which contains a control that is fetched via AJAX.</p>
<p>The Page_Load function of the control does a little bit of logic necessary to get the correct values from the Query string.</p>
<p>The problem is that the Page_Load function isn't called in IE.</p... | [
{
"answer_id": 444493,
"author": "Jeff Martin",
"author_id": 13100,
"author_profile": "https://Stackoverflow.com/users/13100",
"pm_score": 0,
"selected": false,
"text": "<p>i'd try to use the <a href=\"http://www.microsoft.com/en-us/download/details.aspx?id=18359\" rel=\"nofollow norefer... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55162/"
] | I've been thrown into an ASP.NET project and I've got a page which contains a control that is fetched via AJAX.
The Page\_Load function of the control does a little bit of logic necessary to get the correct values from the Query string.
The problem is that the Page\_Load function isn't called in IE.
If I put a break... | It seems like it was a caching issue, solved by doing something like this:
```
protected override void OnLoad(EventArgs e)
{
Response.Cache.SetNoStore();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now);
Response.Cache.SetLastModified(DateTime.Now);
... |
444,475 | <p>I have sequence of IDs I want to retrieve. It's simple:</p>
<pre><code>session.query(Record).filter(Record.id.in_(seq)).all()
</code></pre>
<p>Is there a better way to do it?</p>
| [
{
"answer_id": 444524,
"author": "iny",
"author_id": 27067,
"author_profile": "https://Stackoverflow.com/users/27067",
"pm_score": 1,
"selected": false,
"text": "<p>I'd recommend to take a look at the SQL it produces. You can just print str(query) to see it.</p>\n\n<p>I'm not aware of an... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21711/"
] | I have sequence of IDs I want to retrieve. It's simple:
```
session.query(Record).filter(Record.id.in_(seq)).all()
```
Is there a better way to do it? | Your code is absolutety fine.
`IN` is like a bunch of `X=Y` joined with `OR` and is pretty fast in contemporary databases.
However, if your list of IDs is long, you could make the query a bit more efficient by passing a sub-query returning the list of IDs. |
444,509 | <p>I've seen a couple of Python IDE's (e.g. PyDev Extensions, WingIDE) that provide a debug console - an interactive terminal that runs in the context of the method where the breakpoint is. This lets you print members, call other methods and see the results, and redefine methods to try to fix bugs. Cool.</p>
<p>Can an... | [
{
"answer_id": 444918,
"author": "John Fouhy",
"author_id": 15154,
"author_profile": "https://Stackoverflow.com/users/15154",
"pm_score": 3,
"selected": false,
"text": "<p>You could try looking at the python debugger pdb. It's like gdb in how you use it, but implemented in pure python. ... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55155/"
] | I've seen a couple of Python IDE's (e.g. PyDev Extensions, WingIDE) that provide a debug console - an interactive terminal that runs in the context of the method where the breakpoint is. This lets you print members, call other methods and see the results, and redefine methods to try to fix bugs. Cool.
Can anyone tell ... | Right, I'm ashamed to admit it's actually in the documentation for InteractiveConsole after all. You can make it run in the local context by passing in the result of the locals() function to the InteractiveConsole constructor. I couldn't find a way to close the InteractiveConsole without killing the application, so I'v... |
444,517 | <p>I am using the ShowWindow method from User32 to hide a window (cmd.exe) from the user (mainly to prevent them from closing it). When the user opens the form, the process is started, and hid, then when the form is closing the process is killed. However, when the form is opened again, it doesn't hide the window (and s... | [
{
"answer_id": 444527,
"author": "scottm",
"author_id": 53007,
"author_profile": "https://Stackoverflow.com/users/53007",
"pm_score": 3,
"selected": true,
"text": "<p>It would be MUCH easier to this:</p>\n\n<pre><code>public ConsoleForm(Process p) {\n this.p = p;\n p.StartI... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | I am using the ShowWindow method from User32 to hide a window (cmd.exe) from the user (mainly to prevent them from closing it). When the user opens the form, the process is started, and hid, then when the form is closing the process is killed. However, when the form is opened again, it doesn't hide the window (and some... | It would be MUCH easier to this:
```
public ConsoleForm(Process p) {
this.p = p;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.CreateNoWindow = true;
p.Start();
this.inStream = p.StandardInput;
this.outStream = p.StandardOutput;
this.errorStre... |
444,523 | <p><em>Nearly identical to <a href="https://stackoverflow.com/questions/85978/query-a-tables-foreign-key-relationships">Query a Table's Foreign Key relationships</a>, but for SQL Server 2000</em></p>
<p>For a given table 'foo', I need a query to generate a set of tables that have foreign keys that point to foo.</p... | [
{
"answer_id": 444536,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": 1,
"selected": false,
"text": "<p>Start here</p>\n\n<pre><code> SELECT cons.TABLE_NAME\n , cons.CONSTRAINT_NAME PK_NAME\n , cols.COLUMN_NAME \nFRO... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1446/"
] | *Nearly identical to [Query a Table's Foreign Key relationships](https://stackoverflow.com/questions/85978/query-a-tables-foreign-key-relationships), but for SQL Server 2000*
For a given table 'foo', I need a query to generate a set of tables that have foreign keys that point to foo. | ```
SELECT o2.name
FROM sysobjects o
INNER JOIN sysforeignkeys fk on o.id = fk.rkeyid
INNER JOIN sysobjects o2 on fk.fkeyid = o2.id
WHERE o.name = 'foo'
``` |
444,544 | <p>I have a <code>date</code> and <code>time</code> column in my mysql table called <code>start_date</code> and <code>start_time</code> respectively. I want my users the ability to set reminders for themselves to be sent X hours before <code>start_time</code>, min. 1 hour and max 24 hours.</p>
<p>I'll be running a CRO... | [
{
"answer_id": 444559,
"author": "Sampson",
"author_id": 54680,
"author_profile": "https://Stackoverflow.com/users/54680",
"pm_score": 3,
"selected": true,
"text": "<p>Something like this:</p>\n\n<pre class=\"lang-sql prettyprint-override\"><code>SELECT col1, col2, col3 \nFROM records \n... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | I have a `date` and `time` column in my mysql table called `start_date` and `start_time` respectively. I want my users the ability to set reminders for themselves to be sent X hours before `start_time`, min. 1 hour and max 24 hours.
I'll be running a CRON script to send these reminders. Right now I do:
```
SELECT * F... | Something like this:
```sql
SELECT col1, col2, col3
FROM records
WHERE (records.startDate BETWEEN NOW() AND ADDDATE(NOW(), INTERVAL 9 HOUR))
AND (records.status = '0');
``` |
444,545 | <p>Let's say I have I have an online store with a "shopping cart" feature and I want to implement an "empty cart" link in a RESTful way.</p>
<p>For simplicity, let's say my resources are a Cart that contains CartItems, each of which has a Product. My URIs might be:</p>
<pre>
# add a product to the current user's Cart... | [
{
"answer_id": 444578,
"author": "Crescent Fresh",
"author_id": 45433,
"author_profile": "https://Stackoverflow.com/users/45433",
"pm_score": 5,
"selected": true,
"text": "<p>Don't do the second approach. Funneling different <code>actions</code> through one endpoint does not feel RESTful... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54426/"
] | Let's say I have I have an online store with a "shopping cart" feature and I want to implement an "empty cart" link in a RESTful way.
For simplicity, let's say my resources are a Cart that contains CartItems, each of which has a Product. My URIs might be:
```
# add a product to the current user's Cart
POST /products... | Don't do the second approach. Funneling different `actions` through one endpoint does not feel RESTful IMO.
You have `DELETE /cart_items/cart_item_id/` that removes `cart_item_id` from their cart. What about `DELETE /cart_items/` to clear the cart itself? |
444,591 | <p>How can I convert a string of bytes into an int in python? </p>
<p>Say like this: <code>'y\xcc\xa6\xbb'</code></p>
<p>I came up with a clever/stupid way of doing it:</p>
<pre><code>sum(ord(c) << (i * 8) for i, c in enumerate('y\xcc\xa6\xbb'[::-1]))
</code></pre>
<p>I know there has to be something builtin ... | [
{
"answer_id": 444610,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 8,
"selected": true,
"text": "<p>You can also use the <a href=\"https://docs.python.org/3.6/library/struct.html\" rel=\"noreferrer\">struct</a> module t... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41613/"
] | How can I convert a string of bytes into an int in python?
Say like this: `'y\xcc\xa6\xbb'`
I came up with a clever/stupid way of doing it:
```
sum(ord(c) << (i * 8) for i, c in enumerate('y\xcc\xa6\xbb'[::-1]))
```
I know there has to be something builtin or in the standard library that does this more simply...
... | You can also use the [struct](https://docs.python.org/3.6/library/struct.html) module to do this:
```
>>> struct.unpack("<L", "y\xcc\xa6\xbb")[0]
3148270713L
``` |
444,595 | <p>I am currently trying out this code:</p>
<pre><code>NSString *path = [[NSBundle mainBundle] pathForResource:@"dream" ofType:@"m4a"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
</code></pre>
<p>Howev... | [
{
"answer_id": 444604,
"author": "Noah Witherspoon",
"author_id": 30618,
"author_profile": "https://Stackoverflow.com/users/30618",
"pm_score": 4,
"selected": true,
"text": "<p>You need to add <code><AVAudioPlayerDelegate></code> to the end of your controller's class declaration, a... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53677/"
] | I am currently trying out this code:
```
NSString *path = [[NSBundle mainBundle] pathForResource:@"dream" ofType:@"m4a"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
```
However, the SDK says that the ... | You need to add `<AVAudioPlayerDelegate>` to the end of your controller's class declaration, along these lines:
```
@interface MyViewController : UIViewController <AVAudioPlayerDelegate>
```
This'll probably generate some more warnings about delegate methods you need to implement - follow those and you'll be good t... |
444,602 | <p>I'm trying to create a Regex to block all <code><</code> and <code>></code> in a String except when used with <code><select>.</code> Can anyone suggest a Regex for that? I'll be using it with <code>javax.util.Pattern</code>.</p>
<p>I'm trying to write a solution to block the injection attack and XSS at... | [
{
"answer_id": 444635,
"author": "finnw",
"author_id": 12048,
"author_profile": "https://Stackoverflow.com/users/12048",
"pm_score": 1,
"selected": false,
"text": "<p>I suspect it can be done with a single regex but it may be easier to split it into stages, e.g.:</p>\n\n<ol>\n<li><code>\... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55176/"
] | I'm trying to create a Regex to block all `<` and `>` in a String except when used with `<select>.` Can anyone suggest a Regex for that? I'll be using it with `javax.util.Pattern`.
I'm trying to write a solution to block the injection attack and XSS attempts through request and URL. For that, I'll be blocking the spec... | ```
Pattern p = Pattern.compile(
"(?<!\\<select)>|<(?!\s*select\s*>)",
Pattern.CASE_INSENSITIVE);
```
This will find > not preceded by <select and < not followed by select> allowing it to be case-insensitive.
Now normally I'd check for (legal) white-space around the element ("`< select >`" is valid) but the look... |
444,623 | <p>When I call <code>getBean(name)</code> on a <code>BeanFactory</code>, I get back an instance of the bean defined in the application context. However, when I call <code>getBean(name)</code> again (with the same name,) I get the same instance of the bean back. I understand how this would be desirable in some (many?)... | [
{
"answer_id": 444636,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 4,
"selected": false,
"text": "<p>The default <a href=\"http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-scopes-sin... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44757/"
] | When I call `getBean(name)` on a `BeanFactory`, I get back an instance of the bean defined in the application context. However, when I call `getBean(name)` again (with the same name,) I get the same instance of the bean back. I understand how this would be desirable in some (many?) cases, but how do I tell the `BeanFac... | You need to tell spring that you want a prototype bean rather than a singleton bean
```
<bean id="beanA" class="misc.BeanClass" scope="prototype"/>
```
This will get you a new instance with each request. |
444,627 | <p>Alright...I've given the site a fair search and have read over many posts about this topic. I found this question: <a href="https://stackoverflow.com/questions/435668/code-for-a-simple-thread-pool-in-c">Code for a simple thread pool in C#</a> especially helpful.</p>
<p>However, as it always seems, what I need varie... | [
{
"answer_id": 444659,
"author": "jalf",
"author_id": 33213,
"author_profile": "https://Stackoverflow.com/users/33213",
"pm_score": 0,
"selected": false,
"text": "<p>It's a static class like any other, which means that anything you do with it affects every other thread in the current pro... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50947/"
] | Alright...I've given the site a fair search and have read over many posts about this topic. I found this question: [Code for a simple thread pool in C#](https://stackoverflow.com/questions/435668/code-for-a-simple-thread-pool-in-c) especially helpful.
However, as it always seems, what I need varies slightly.
I have l... | Note: if you are limiting this to "3" just so you don't overwhelm the machine running your app, I'd make sure this is a problem first. The threadpool is supposed to manage this for you. On the other hand, if you don't want to overwhelm some other resource, then read on!
---
You can't manage the size of the threadpool... |
444,638 | <p>I am attempting to troubleshoot an intermittent failure that appears to be related to removing an object from a HashMap and then putting that same object back using a new key. My HashMap is created as follows:</p>
<pre><code>transactions = new HashMap<Short, TransactionBase>();
</code></pre>
<p>The code tha... | [
{
"answer_id": 444653,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 1,
"selected": false,
"text": "<p>So you know <code>HashMap</code>'s not thread safe. Are you sure it's being accessed by only one thread? After all, inter... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19674/"
] | I am attempting to troubleshoot an intermittent failure that appears to be related to removing an object from a HashMap and then putting that same object back using a new key. My HashMap is created as follows:
```
transactions = new HashMap<Short, TransactionBase>();
```
The code that does the re-assignment is as fo... | There are no "asynchronous" effects in the HashMap class. As soon as you put something in there, it's there. You should double- and triple- check to make sure that there are no threading issues.
The only other thing I can think of is that you're making a copy of the HashMap somewhere. The copy obviously won't be affec... |
444,654 | <p>My question is pretty vague :o) - But here is an example :</p>
<p>When I was writing C code, I was able to log counter's value when something failed :</p>
<pre><code> <...>
for ( int i = 0 ; i < n ; i++ )
if ( SUCCESS != myCall())
Log( "Failure, i = %d", i );
<...>
</code></pr... | [
{
"answer_id": 444679,
"author": "EvilTeach",
"author_id": 7734,
"author_profile": "https://Stackoverflow.com/users/7734",
"pm_score": 2,
"selected": false,
"text": "<p>It can be more elegant, if the object that you throw, can hold the context information that tells you something about t... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54783/"
] | My question is pretty vague :o) - But here is an example :
When I was writing C code, I was able to log counter's value when something failed :
```
<...>
for ( int i = 0 ; i < n ; i++ )
if ( SUCCESS != myCall())
Log( "Failure, i = %d", i );
<...>
```
Now, using exceptions, I get this :
```
... | how about:
```
for(int i = 0; i < n; i++)
{
try
{
myCall();
}
catch(Exception e)
{
Log(String.Format("Problem with {0}", i));
}
}
``` |
444,662 | <p>I have been looking at Reflection.Emit recently. I wrote a simple program that generates a DynamicMethod which simple calls another method with the same parameters</p>
<pre><code>class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.Test();
}
public delegate... | [
{
"answer_id": 444965,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 4,
"selected": true,
"text": "<p>The problem you are having is that you are invoking a dynamic method, not a static one. Your generated method does... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38686/"
] | I have been looking at Reflection.Emit recently. I wrote a simple program that generates a DynamicMethod which simple calls another method with the same parameters
```
class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.Test();
}
public delegate void TestHand... | The problem you are having is that you are invoking a dynamic method, not a static one. Your generated method does not have a reference to the the instance of the Program class.
Also note you are pushing 7 parameters onto the stack for a 6 parameter method.
The first parameter should be a reference to the object you... |
444,663 | <p>What are the most common reasons that I would be getting this error from running a Perl script:</p>
<pre><code>Memory fault(coredump)
</code></pre>
<p>I am running two SQL commands beforehand that only store ~1500 rows each with 6 fields. The SQL works fine out of the script, so I don't think I'm getting the error... | [
{
"answer_id": 444674,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 2,
"selected": false,
"text": "<p>You're tickling a bug in the Perl interpreter or one of its C modules. If your Perl binary doesn't have debugging s... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42229/"
] | What are the most common reasons that I would be getting this error from running a Perl script:
```
Memory fault(coredump)
```
I am running two SQL commands beforehand that only store ~1500 rows each with 6 fields. The SQL works fine out of the script, so I don't think I'm getting the error from that. And half of my... | Before the code change, you called GetCharValue after checking if $i was as value you wanted. After the change, you call it even if it's not 1,2,10,12. Is it possible that the values for $i other than those 4 is causing the issue? |
444,673 | <p>I'm doing a probability calculation. I have a query to calculate the total number of times an event occurs. From these events, I want to get the number of times a sub-event occurs. The query to get the total events is 25 lines long and I don't want to just copy + paste it twice. </p>
<p>I want to do two things to t... | [
{
"answer_id": 444704,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 2,
"selected": true,
"text": "<pre><code>SELECT COUNT(*) as totaloccurs, COUNT(@conditions@) as suboccurs\nFROM (@total@ as t1)\n</code></pre>\n"
},... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | I'm doing a probability calculation. I have a query to calculate the total number of times an event occurs. From these events, I want to get the number of times a sub-event occurs. The query to get the total events is 25 lines long and I don't want to just copy + paste it twice.
I want to do two things to this query:... | ```
SELECT COUNT(*) as totaloccurs, COUNT(@conditions@) as suboccurs
FROM (@total@ as t1)
``` |
444,705 | <p>I am teaching my friend how to make websites. I would like to keep the websites static, so that he does not [yet] have to learn PHP, worry about testing on his Windows machine, worry about the server configuration, security etc. The bad thing is that without some tool support he would have to repeat a lot of code, f... | [
{
"answer_id": 444724,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 0,
"selected": false,
"text": "<p>Is there something wrong with good old copy and paste to get the common elements from one page to another? Or better yet,... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17279/"
] | I am teaching my friend how to make websites. I would like to keep the websites static, so that he does not [yet] have to learn PHP, worry about testing on his Windows machine, worry about the server configuration, security etc. The bad thing is that without some tool support he would have to repeat a lot of code, for ... | The easiest would probably be (although it requires a little bit of set up) a web server with server-side includes. It's the easiest form of templates that I can think of, and if you don't want to "build" the html files from some kind of source, then you need something which is actively serving requests.
I don't know ... |
444,727 | <p>I have a reporting module which creates PDF reports from ListViews.</p>
<p>Now, I have a ListView in Virtual mode and therefore I cannot loop over the Items collection.</p>
<p>How do I loop over all elements in the list view from the reporting module?</p>
<p>I can get the <code>VirtualListSize</code> property, so... | [
{
"answer_id": 444737,
"author": "Tim Jarvis",
"author_id": 10387,
"author_profile": "https://Stackoverflow.com/users/10387",
"pm_score": 2,
"selected": false,
"text": "<p>So, a listview in virtual mode is just a visualization of your underlying list, correct? </p>\n\n<p>Perhaps report s... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55187/"
] | I have a reporting module which creates PDF reports from ListViews.
Now, I have a ListView in Virtual mode and therefore I cannot loop over the Items collection.
How do I loop over all elements in the list view from the reporting module?
I can get the `VirtualListSize` property, so I know how many elements there are... | In a virtual ListView, you cannot iterate the `Items`, but you can still access them by their index:
```
for (int i = 0; i < theVirtualListView.VirtualListSize; i++) {
this.DoSomething(theVirtualListView.Items[i]);
}
``` |
444,730 | <p>I have a div that has a bunch of thumbnails showing horizontally (with a horizontal scrollbar). Is there a way to lazy load these thumbnails and only show them once the user horizontally scrolls to their position? All the examples I've seen check the browser window, not a div.</p>
<p>This is for contest entries so ... | [
{
"answer_id": 444745,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 1,
"selected": false,
"text": "<p>See my question where I encountered a similar problem. <a href=\"https://stackoverflow.com/users/179... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18234/"
] | I have a div that has a bunch of thumbnails showing horizontally (with a horizontal scrollbar). Is there a way to lazy load these thumbnails and only show them once the user horizontally scrolls to their position? All the examples I've seen check the browser window, not a div.
This is for contest entries so sometimes ... | ~~I forked the [lazy load plugin](http://plugins.jquery.com/project/lazyload) for jQuery and added support for lazy-loading images in a container div.~~ The [lazy load plugin](http://plugins.jquery.com/project/lazyload) for jQuery now supports this directly. It shouldn't be too hard to remove the dependency on jQuery o... |
444,741 | <p>We recently changed physical DB's, new servers, new locations, same database schema and data and since the change over, whenever we try to connect directly to the DB in our own desktop type applications about half of the time we get this error:</p>
<pre><code>SQL*Loader-704: Internal error: ulconnect: OCIServerAttac... | [
{
"answer_id": 445227,
"author": "Karl",
"author_id": 51881,
"author_profile": "https://Stackoverflow.com/users/51881",
"pm_score": 0,
"selected": false,
"text": "<p>Ah, gotta love the intermittent problems :)\n(In the following I have had to replace the underscore character as I don't k... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12662/"
] | We recently changed physical DB's, new servers, new locations, same database schema and data and since the change over, whenever we try to connect directly to the DB in our own desktop type applications about half of the time we get this error:
```
SQL*Loader-704: Internal error: ulconnect: OCIServerAttach[0]
ORA-1254... | We recently had a similar issue with our application. The application would sometimes connect to the Oracle RAC and sometimes it would complain with ORA-12545.
In short the issue was that the server had a real name while we were using virtual IP addresses in TNSNAMES.ORA. Once we added the mapping of the server name to... |
444,746 | <p>In C++, arrays cannot be passed simply as parameters. Meaning if I create a function like so:</p>
<pre><code>void doSomething(char charArray[])
{
// if I want the array size
int size = sizeof(charArray);
// NO GOOD, will always get 4 (as in 4 bytes in the pointer)
}
</code></pre>
<p>I have no way of kn... | [
{
"answer_id": 444755,
"author": "Reunanen",
"author_id": 19254,
"author_profile": "https://Stackoverflow.com/users/19254",
"pm_score": 6,
"selected": true,
"text": "<p>Without changing the signature? Append a sentinel element. For char arrays specifically, it could be the null-terminati... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24545/"
] | In C++, arrays cannot be passed simply as parameters. Meaning if I create a function like so:
```
void doSomething(char charArray[])
{
// if I want the array size
int size = sizeof(charArray);
// NO GOOD, will always get 4 (as in 4 bytes in the pointer)
}
```
I have no way of knowing how big the array is... | Without changing the signature? Append a sentinel element. For char arrays specifically, it could be the null-terminating `'\0'` which is used for standard C strings.
```
void doSomething(char charArray[])
{
char* p = charArray;
for (; *p != '\0'; ++p)
{
// if '\0' happens to be valid data for yo... |
444,750 | <p>I have an application which is connected to a database through a spring.net AdoTemplate. I am charged with creating a restore database method which keeps the app running but drops the network connections so as to drop the old database and bring up the new one. My question is how do I drop all the current connectio... | [
{
"answer_id": 444915,
"author": "Erich Eichinger",
"author_id": 51264,
"author_profile": "https://Stackoverflow.com/users/51264",
"pm_score": 1,
"selected": false,
"text": "<p>there is no physical \"connection\" between AdoTemplate and the SQL database. Leaving transactions aside, AdoTe... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51841/"
] | I have an application which is connected to a database through a spring.net AdoTemplate. I am charged with creating a restore database method which keeps the app running but drops the network connections so as to drop the old database and bring up the new one. My question is how do I drop all the current connections th... | What ended up working great was:
```
SqlConnection.ClearAllPools();
// if any connections were being used at the time of the clear, hopefully waiting
// 3 seconds will give them time to be released and we can now close them as well
Thread.Sleep(3000);
//clear again
SqlConnection.ClearAllPools();
``` |
444,753 | <p>I have a NewsFeed object mapped as such:</p>
<pre><code><class name="NewsFeed">
<id name="NewsFeedId">
<generator class="guid"/>
</id>
<property name="FeedName" not-null="true" />
<property name="FeedURL" not-null="true" />
<property name="FeedIsPu... | [
{
"answer_id": 444774,
"author": "Matt Briggs",
"author_id": 10771,
"author_profile": "https://Stackoverflow.com/users/10771",
"pm_score": 0,
"selected": false,
"text": "<p>change</p>\n\n<pre><code>cascade=\"all\"\n</code></pre>\n\n<p>to </p>\n\n<pre><code>cascade=\"all-delete-orphan\"\n... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2285/"
] | I have a NewsFeed object mapped as such:
```
<class name="NewsFeed">
<id name="NewsFeedId">
<generator class="guid"/>
</id>
<property name="FeedName" not-null="true" />
<property name="FeedURL" not-null="true" />
<property name="FeedIsPublished" not-null="true" />
</class>
```
And Users ... | JMCD
Your second approach:
>
> Another alternative is to break the
> many-to-many relationship with a join
> class in the middle which nHiberate
> would be able to determine
> parent-child relationships and the
> cascade should work.
>
>
>
is actually what the nHibernate folks recommend in their documentati... |
444,754 | <p>I have a simple object that get's geocoding data from the Google Maps API and I'd like it to dispatch a set of custom events depending on the response from Google. However, I don't have the addEventListener() and dispatchEvent() methods on this class because it doesn't extend UIComponent. Is there a way to create ... | [
{
"answer_id": 444775,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 2,
"selected": false,
"text": "<p>Extend the EventDispatcher class, or implement the IEventDispatcher interface from the flash.events package.</p>\n"
},
... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] | I have a simple object that get's geocoding data from the Google Maps API and I'd like it to dispatch a set of custom events depending on the response from Google. However, I don't have the addEventListener() and dispatchEvent() methods on this class because it doesn't extend UIComponent. Is there a way to create custo... | Absolutely yes. To take advantage of event handling, your custom object should extend EventDispatcher:
```
public class MyClass extends EventDispatcher
{
// ...
public function myFunction():void
{
dispatchEvent(new Event("myEvent"));
}
}
```
This takes care of dispatching events.
Then as we... |
444,763 | <p>Long title, I know but I searched all over and couldn't find that error message coming from that function call so I thought this might be more useful.</p>
<p>This is the code snippet:</p>
<pre><code>string hql = " from LabRequest r where 1 = 1 ";
hql += " and 0 < (select count(rs) ";
hql += " from r.... | [
{
"answer_id": 444775,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 2,
"selected": false,
"text": "<p>Extend the EventDispatcher class, or implement the IEventDispatcher interface from the flash.events package.</p>\n"
},
... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40814/"
] | Long title, I know but I searched all over and couldn't find that error message coming from that function call so I thought this might be more useful.
This is the code snippet:
```
string hql = " from LabRequest r where 1 = 1 ";
hql += " and 0 < (select count(rs) ";
hql += " from r.Statuses rs ";
hql += " ... | Absolutely yes. To take advantage of event handling, your custom object should extend EventDispatcher:
```
public class MyClass extends EventDispatcher
{
// ...
public function myFunction():void
{
dispatchEvent(new Event("myEvent"));
}
}
```
This takes care of dispatching events.
Then as we... |
444,764 | <p>Is there any way to broadcast a RoutedEvent to all of my children in WPF? </p>
<p>For example lets say I have a Window that has 4 children. 2 of them know about the RoutedEvent 'DisplayYourself' and are listening for it. How can I raise this event from the window and have it sent to all children?</p>
<p>I looked a... | [
{
"answer_id": 444793,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": -1,
"selected": false,
"text": "<p>If you create a routed event like \"MyWindow.MyRoutedEvent\" you just created an event handler on your children that lis... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1514/"
] | Is there any way to broadcast a RoutedEvent to all of my children in WPF?
For example lets say I have a Window that has 4 children. 2 of them know about the RoutedEvent 'DisplayYourself' and are listening for it. How can I raise this event from the window and have it sent to all children?
I looked at [RoutingStrateg... | I think the problem is that you don't want a routed event. Just put a regular old public clr event on the static class and attach anything you want to it. |
444,781 | <p>In .NET 3.5, I'd like to create a singleton interface:</p>
<pre><code>interface ISingleton <T>
{
public static T Instance {get;}
}
</code></pre>
<p>Of course that doesn't work but is what I'd like. Any suggestions?</p>
<p>EDIT: I just want it to be known that all singeltons will have a static property na... | [
{
"answer_id": 444794,
"author": "Matthew Brubaker",
"author_id": 21311,
"author_profile": "https://Stackoverflow.com/users/21311",
"pm_score": 5,
"selected": true,
"text": "<p>An Interface can't, to my knowledge, be a Singleton since it doesn't actually exist. An Interface is a Contrac... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40106/"
] | In .NET 3.5, I'd like to create a singleton interface:
```
interface ISingleton <T>
{
public static T Instance {get;}
}
```
Of course that doesn't work but is what I'd like. Any suggestions?
EDIT: I just want it to be known that all singeltons will have a static property named Instance of the class type. It is al... | An Interface can't, to my knowledge, be a Singleton since it doesn't actually exist. An Interface is a Contract that an implementation must follow. As such, the implementation can be a singleton, but the Interface can not. |
444,787 | <p>I wrote a multi-threaded windows application where thread: <br>
A – is a windows form that handles user interaction and process the data from B. <br>
B – occasionally generates data and passes it two A. </p>
<p>A thread safe queue is used to pass the data from thread B to A. The enqueue and dequeue function... | [
{
"answer_id": 444861,
"author": "scottm",
"author_id": 53007,
"author_profile": "https://Stackoverflow.com/users/53007",
"pm_score": -1,
"selected": false,
"text": "<p>Could there be a second instance unknowingly running and eating the messages, marking them as handled?</p>\n"
},
{
... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13054/"
] | I wrote a multi-threaded windows application where thread:
A – is a windows form that handles user interaction and process the data from B.
B – occasionally generates data and passes it two A.
A thread safe queue is used to pass the data from thread B to A. The enqueue and dequeue functions are guarded usin... | Is `FCount` also protected by `FQueueLock`? If not, then your problem lies with `FCount` being incremented after the posted message is already processed.
Here's what might be happening:
1. B enters critical section
2. B calls `PostMessage`
3. A receives the message but doesn't do anything since `FCount` is `0`
4. B i... |
444,798 | <p>Is there a way to make the following return true?</p>
<pre><code>string title = "ASTRINGTOTEST";
title.Contains("string");
</code></pre>
<p>There doesn't seem to be an overload that allows me to set the case sensitivity. Currently I UPPERCASE them both, but that's just silly (by which I am referr... | [
{
"answer_id": 444813,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 7,
"selected": false,
"text": "<p>You could always just up or downcase the strings first. </p>\n\n<pre><code>string title = \"string\":\ntitle.ToUpper().Con... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | Is there a way to make the following return true?
```
string title = "ASTRINGTOTEST";
title.Contains("string");
```
There doesn't seem to be an overload that allows me to set the case sensitivity. Currently I UPPERCASE them both, but that's just silly (by which I am referring to the [i18n](http://en.wikipedia.org/wi... | To test if the string `paragraph` contains the string `word` (thanks @QuarterMeister)
```
culture.CompareInfo.IndexOf(paragraph, word, CompareOptions.IgnoreCase) >= 0
```
Where `culture` is the instance of [`CultureInfo`](http://msdn.microsoft.com/en-gb/library/system.globalization.cultureinfo(v=vs.110).aspx) descri... |
444,801 | <p>I'm trying to move X number of rows down in a table using jQuery...</p>
<p>I can do the following and it works.... </p>
<pre><code>/* Now let's move next 3 times to arrive at the foo account */
for (var rowCount = 1; rowCount <=3; rowCount++) {
foobarRow = $(foobarRow).next('tr');
}
</code></pre>
<p>I re... | [
{
"answer_id": 444817,
"author": "Sampson",
"author_id": 54680,
"author_profile": "https://Stackoverflow.com/users/54680",
"pm_score": 4,
"selected": true,
"text": "<p>You can match elements by their index <a href=\"https://api.jquery.com/eq-selector/\" rel=\"nofollow noreferrer\"><code>... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4232/"
] | I'm trying to move X number of rows down in a table using jQuery...
I can do the following and it works....
```
/* Now let's move next 3 times to arrive at the foo account */
for (var rowCount = 1; rowCount <=3; rowCount++) {
foobarRow = $(foobarRow).next('tr');
}
```
I realize I could go
```
foobarRow = ... | You can match elements by their index [`:eq(index)`](https://api.jquery.com/eq-selector/).
`$("tr:eq(2)")` selects the third `<tr>`. Note, this is a zero-based index. |
444,820 | <p>I'm using a SQL query that is similar to the following form:</p>
<pre><code>SELECT col1, col2
FROM table1
LEFT OUTER JOIN table2
ON table1.person_uid = table2.person_uid
AND table1.period = table2.period
</code></pre>
<p>And it's either way too slow or something's deadlocking because it takes at least 4 minutes to... | [
{
"answer_id": 444835,
"author": "Andrew Rollings",
"author_id": 40410,
"author_profile": "https://Stackoverflow.com/users/40410",
"pm_score": 2,
"selected": false,
"text": "<p>Do you have covering indexes on <code>person_uid</code> and <code>period</code> for both tables?</p>\n\n<p>If n... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | I'm using a SQL query that is similar to the following form:
```
SELECT col1, col2
FROM table1
LEFT OUTER JOIN table2
ON table1.person_uid = table2.person_uid
AND table1.period = table2.period
```
And it's either way too slow or something's deadlocking because it takes at least 4 minutes to return. If I were to chan... | Bear in mind that statements 2 and 3 are different to the first one.
How? Well, you're doing a left outer join and your WHERE clause isn't taking that into account (like the ON clause does). At a minimum, try:
```
SELECT col1, col2
FROM table1, table2
WHERE table1.person_uid = table2.person_uid (+)
AND table1.period ... |
444,842 | <p>Does anyone have any pointers how to to fix the styling issue presented when using jquery ui's datepicker along side blueprint css framework? Specifically the table with the dates appears larger (wider) than the container it sits in. </p>
| [
{
"answer_id": 444886,
"author": "IaCoder",
"author_id": 17337,
"author_profile": "https://Stackoverflow.com/users/17337",
"pm_score": 1,
"selected": false,
"text": "<p>Added the following CSS to solve the problem:</p>\n\n<pre><code>.ui-datepicker-calendar table{\n margin: 0; }\n.ui-dat... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17337/"
] | Does anyone have any pointers how to to fix the styling issue presented when using jquery ui's datepicker along side blueprint css framework? Specifically the table with the dates appears larger (wider) than the container it sits in. | I tried the other answers, but they didn't do it for me. After playing around with the problem for a few hours I came up with a solution that works for me (Blueprint 1.0, Jquery UI 1.8.5, tested with Smoothness, Redmond and Dark Hive themes in Chrome and IE):
```
/* remove blue backgrounds - separate for TH to work in... |
444,844 | <p><b>UPDATE:</b> Rephrasing the question to ask, 'are there too many' static methods (I realize that right now there are only 4 but I originally started with 2) in this class structure? If so, any suggestions on how to refactor these classes to use some sort of Finder class so that I can remove the static functions fr... | [
{
"answer_id": 444872,
"author": "Matthew Brubaker",
"author_id": 21311,
"author_profile": "https://Stackoverflow.com/users/21311",
"pm_score": 2,
"selected": false,
"text": "<p>The first indicator I use when determining if I have to many static methods is if the methods functionality is... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20178/"
] | **UPDATE:** Rephrasing the question to ask, 'are there too many' static methods (I realize that right now there are only 4 but I originally started with 2) in this class structure? If so, any suggestions on how to refactor these classes to use some sort of Finder class so that I can remove the static functions from the... | Personally I find that any number of static methods are a sign of trouble. If your class has instance methods and static methods, then most likely you could split the class into two separate entities and change the static methods to instance methods.
Think of a class as a special kind of object, with the distinctive p... |
444,845 | <p>I've always found the eclipse's automatic close quotes and parenthesis features to be useless. For example hitting on a single " will lead to</p>
<pre><code>"<cursor>"
</code></pre>
<p>I don't need the second quote. It's annoying to remove afterward. How to turn this feature off?</p>
<p><strong>Update:</s... | [
{
"answer_id": 444866,
"author": "Allethrin",
"author_id": 52347,
"author_profile": "https://Stackoverflow.com/users/52347",
"pm_score": 8,
"selected": true,
"text": "<p>Try Window -> Preferences -> Java -> Editor -> Typing and uncheck the \"Strings\" checkbox in the \"Automatically clos... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45066/"
] | I've always found the eclipse's automatic close quotes and parenthesis features to be useless. For example hitting on a single " will lead to
```
"<cursor>"
```
I don't need the second quote. It's annoying to remove afterward. How to turn this feature off?
**Update:** I now kept the setting on. If you type another ... | Try Window -> Preferences -> Java -> Editor -> Typing and uncheck the "Strings" checkbox in the "Automatically close" group. |
444,890 | <p>I have a piece of jQuery code which invokes several <code>getJSON()</code> calls in quick succession:</p>
<pre><code>var table = $("table#output");
for (var i in items) {
var thisItem = items[i];
$.getJSON("myService", { "itemID": thisItem }, function(json) {
var str = "<tr>";
str += "... | [
{
"answer_id": 444902,
"author": "Crescent Fresh",
"author_id": 45433,
"author_profile": "https://Stackoverflow.com/users/45433",
"pm_score": 5,
"selected": true,
"text": "<p>Seems like a scoping issue due to the loop. Try this:</p>\n\n<pre><code>var table = $(\"table#output\");\nfor (va... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7512/"
] | I have a piece of jQuery code which invokes several `getJSON()` calls in quick succession:
```
var table = $("table#output");
for (var i in items) {
var thisItem = items[i];
$.getJSON("myService", { "itemID": thisItem }, function(json) {
var str = "<tr>";
str += "<td>" + thisItem + "</td>";
... | Seems like a scoping issue due to the loop. Try this:
```
var table = $("table#output");
for (var i in items) {
var thisItem = items[i];
$.getJSON("myService", { "itemID": thisItem }, (function(thisItem) {
return function(json) {
var str = "<tr>";
str += "<td>" + thisItem + "</t... |
444,892 | <p>This is my first stackoverflow question, so try to be nice. ;-D</p>
<p>My issue is this, I am refactoring some existing javascript code and using jQuery to do it. In several places I've come across javascript code similar to the following:</p>
<pre><code>// some js code working with the customAttribute value
javas... | [
{
"answer_id": 444926,
"author": "ScottyDont",
"author_id": 13718,
"author_profile": "https://Stackoverflow.com/users/13718",
"pm_score": 2,
"selected": false,
"text": "<p>What are you trying to accomplish?</p>\n\n<p>If the goal is to remove the value in the name/value pair, you might as... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53777/"
] | This is my first stackoverflow question, so try to be nice. ;-D
My issue is this, I am refactoring some existing javascript code and using jQuery to do it. In several places I've come across javascript code similar to the following:
```
// some js code working with the customAttribute value
javascriptElementObject.cu... | jQuery likes to overload its methods so:
```
obj.attr( name ) //retrieves the attribute value
obj.attr( name, value ) //sets the attribute
obj.attr( name, void(0) ) == obj.attr( name, null ) == obj.attr( name ) //i.e retrieving the attribute
```
You might want to try the following if you want to set an empty attrib... |
444,916 | <p>I think this function isn't as efficient as it should be. I'd appreciate some suggestions on how I can structure it to be faster and take less memory. This is what the code does:</p>
<ol>
<li>checks to see if the image was uploaded</li>
<li>add details about it (tags, name, details) to the database</li>
<li>if th... | [
{
"answer_id": 444958,
"author": "MrChrister",
"author_id": 24229,
"author_profile": "https://Stackoverflow.com/users/24229",
"pm_score": 0,
"selected": false,
"text": "<p>You could store your configs elsewhere per <a href=\"http://codeigniter.com/user_guide/libraries/config.html\" rel=\... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I think this function isn't as efficient as it should be. I'd appreciate some suggestions on how I can structure it to be faster and take less memory. This is what the code does:
1. checks to see if the image was uploaded
2. add details about it (tags, name, details) to the database
3. if the variable $orientation was... | For all the work required to do your image manipulation using the objects that code igniter exposes for you, you may want to look into doing this yourself strictly with the gd functions in php. I have not used code igniter, but I've done a lot of stuff with image manipulation in php, and it's not terribly difficult.
J... |
444,927 | <p>I am having a dilemma in the logic of this particular issue. Forgive me if this is quite newbie question but I'd rather have a solid bg on it.</p>
<p>There are a lot of examples of this all around the web where you click on an element to display another element. such case may be a menu that when you hover your mous... | [
{
"answer_id": 444937,
"author": "Jobo",
"author_id": 51915,
"author_profile": "https://Stackoverflow.com/users/51915",
"pm_score": 0,
"selected": false,
"text": "<p>That is one way to do it. </p>\n\n<p>You could also write a method that traps (hooks into) all 'click' events regardless o... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49742/"
] | I am having a dilemma in the logic of this particular issue. Forgive me if this is quite newbie question but I'd rather have a solid bg on it.
There are a lot of examples of this all around the web where you click on an element to display another element. such case may be a menu that when you hover your mouse on it (o... | ```
$('#target').bind('click', function(event)
{
var $element = $('#element');
$element.show();
$(document).one('click', function()
{
$element.hide();
});
// If you don't stop the event, it will bubble up to the document
// and trigger the click event we just bound.
// This wil... |
444,932 | <p>I have the following JPA entity classes (example case). A House belongs on a single Street. A Street has many Houses.</p>
<pre><code>@Entity
public class House {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public Integer id;
public String name
@ManyToOne
public Street street;... | [
{
"answer_id": 445001,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 5,
"selected": true,
"text": "<p>Standard SQL specifies this optional syntax for <code>INSERT</code>:</p>\n\n<pre><code>INSERT INTO <Table Name>... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | I have the following JPA entity classes (example case). A House belongs on a single Street. A Street has many Houses.
```
@Entity
public class House {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public Integer id;
public String name
@ManyToOne
public Street street;
}
@Entity
pu... | Standard SQL specifies this optional syntax for `INSERT`:
```
INSERT INTO <Table Name> DEFAULT VALUES
```
This is legal SQL syntax, supported, for example, by [Microsoft SQL Server](http://msdn.microsoft.com/en-us/library/ms174335(SQL.90).aspx), [PostgreSQL](http://www.postgresql.org/docs/current/static/dml-insert.h... |
444,951 | <p>In <a href="http://www.zsh.org/" rel="noreferrer">zsh</a>, how can I set up the line editor such that <code>backward-kill-word</code> stops on a directory separator? Currently in my bash setup, if I type</p>
<pre><code>cd ~/devel/sandbox
</code></pre>
<p>and then hit <code>C-w</code> point will be right after <code... | [
{
"answer_id": 444968,
"author": "James Van Huis",
"author_id": 31828,
"author_profile": "https://Stackoverflow.com/users/31828",
"pm_score": -1,
"selected": true,
"text": "<p>A quick google reveals:</p>\n\n<p><a href=\"http://www.zsh.org/mla/users/2001/msg00870.html\" rel=\"nofollow nor... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456/"
] | In [zsh](http://www.zsh.org/), how can I set up the line editor such that `backward-kill-word` stops on a directory separator? Currently in my bash setup, if I type
```
cd ~/devel/sandbox
```
and then hit `C-w` point will be right after `devel/`. In my zsh setup, point would be after `cd` . I'd like to set up zsh so... | A quick google reveals:
[Backward Kill](http://www.zsh.org/mla/users/2001/msg00870.html)
Or, perhaps a better fix:
[Bash Style Backward Kill](http://www.zsh.org/mla/users/2001/msg00868.html) |
444,966 | <p>After searching around somewhat thoroughly, I noticed a slight lack of functions in PHP for handling <a href="http://en.wikipedia.org/wiki/IPv6" rel="nofollow noreferrer">IPv6</a>. For my own personal satisfaction I created a few functions to help the transition.</p>
<p>The <code>IPv6ToLong()</code> function is a te... | [
{
"answer_id": 455675,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 1,
"selected": false,
"text": "<p>PHP.net's <a href=\"http://www.php.net/manual/en/filter.php\" rel=\"nofollow noreferrer\">Filter extension</a> contains <a h... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51021/"
] | After searching around somewhat thoroughly, I noticed a slight lack of functions in PHP for handling [IPv6](http://en.wikipedia.org/wiki/IPv6). For my own personal satisfaction I created a few functions to help the transition.
The `IPv6ToLong()` function is a temporary solution to that brought up here: [How to store I... | How about [`inet_ntop()`](http://php.net/inet_ntop)? Then instead of chopping things into integers, you just use a `varbinary(16)` to store it. |
444,976 | <p>In SQL/Transact SQL, I am trying to update a temp table to take the latest date from 3 different date columns (in that temp table), and put that MAX date into a "latest date" column.</p>
<p>What is the best way to do this, using an update statement?</p>
| [
{
"answer_id": 444990,
"author": "Jason Punyon",
"author_id": 6212,
"author_profile": "https://Stackoverflow.com/users/6212",
"pm_score": 2,
"selected": false,
"text": "<p>I think you need to normalize your database from </p>\n\n<p>RecordID, Column1, Column2, Column3</p>\n\n<p>to </p>\n\... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24126/"
] | In SQL/Transact SQL, I am trying to update a temp table to take the latest date from 3 different date columns (in that temp table), and put that MAX date into a "latest date" column.
What is the best way to do this, using an update statement? | With only three it's not so hard... This is definitely not extensible to an arbitrary number of datetime columns !
```
Select Case When DT1 > DT2 And DT1 > DT3 Then DT1
When DT2 > Dt3 Then Dt2 Else DT3 End
From TableName
``` |
444,988 | <p>Background:<br/>
We are running a web application where each user has a login to the system. The application login is mapped to an actual SQL Server 2005 login (which we needed to create). Our development and disaster recovery sites are simply copies of this setup. On a nightly basis, the production database is b... | [
{
"answer_id": 444990,
"author": "Jason Punyon",
"author_id": 6212,
"author_profile": "https://Stackoverflow.com/users/6212",
"pm_score": 2,
"selected": false,
"text": "<p>I think you need to normalize your database from </p>\n\n<p>RecordID, Column1, Column2, Column3</p>\n\n<p>to </p>\n\... | 2009/01/14 | [
"https://Stackoverflow.com/questions/444988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/807/"
] | Background:
We are running a web application where each user has a login to the system. The application login is mapped to an actual SQL Server 2005 login (which we needed to create). Our development and disaster recovery sites are simply copies of this setup. On a nightly basis, the production database is backed up... | With only three it's not so hard... This is definitely not extensible to an arbitrary number of datetime columns !
```
Select Case When DT1 > DT2 And DT1 > DT3 Then DT1
When DT2 > Dt3 Then Dt2 Else DT3 End
From TableName
``` |
445,002 | <pre><code>$('#images_upload_add').click(function(){
$('.images_upload:last').after($('.images_upload:last').clone().find('input[type=file]').val('').end());
});
</code></pre>
<p>using this code to append file input's does not upload the file in firefox.</p>
<p>also</p>
<pre><code>$('#image_server_add inp... | [
{
"answer_id": 445032,
"author": "meouw",
"author_id": 12161,
"author_profile": "https://Stackoverflow.com/users/12161",
"pm_score": 0,
"selected": false,
"text": "<p>Wow! Sometimes jQuery can actually be too dense to read. Would also help if we could see your markup.<br>\nStab in the da... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
$('#images_upload_add').click(function(){
$('.images_upload:last').after($('.images_upload:last').clone().find('input[type=file]').val('').end());
});
```
using this code to append file input's does not upload the file in firefox.
also
```
$('#image_server_add input[type=button]').click(function(){
... | Bottom line the markup on the page was mangled.
The form was in a table based layout, not by my choice, and the form declaration was inside a tr.
I moved the form declaration to a parent td of the form inputs and now it works.
This is an interesting result considering the rendering engine will correctly submit input... |
445,033 | <p>G'day everyone.</p>
<p>I'm still learning LINQ so forgive me if this is naive. When you're dealing with SQL directly, you can generate update commands with conditionals, without running a select statement.</p>
<p>When I work with linq I seem to follow the pattern of:</p>
<ol>
<li>Select entities</li>
<li>Modify ... | [
{
"answer_id": 445069,
"author": "Pop Catalin",
"author_id": 4685,
"author_profile": "https://Stackoverflow.com/users/4685",
"pm_score": 2,
"selected": false,
"text": "<p>Linq 2 SQL doesn't have direct insert/update/delete equivalents of SQL. In V1 the only updates you can do using linq ... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53771/"
] | G'day everyone.
I'm still learning LINQ so forgive me if this is naive. When you're dealing with SQL directly, you can generate update commands with conditionals, without running a select statement.
When I work with linq I seem to follow the pattern of:
1. Select entities
2. Modify entities
3. Submit changes
What I... | No, neither LINQ nor LINQ to SQL has set-based update capabilities.
In LINQ to SQL, you must query for the object you wish to update, update the fields/properties as necessary, then call SubmitChanges(). For example:
```
var qry = from product in dc.Products where Product.Name=='Foobar' select product;
var item = qr... |
445,034 | <p>Ok, so I have an object named "Business" (I know, I know, "Business Business Object")
When it saved its foreign keys are getting lost somehow. Everything else is saving. I have stepped through the code and followed the object up until the </p>
<p>session.SaveOrUpdate(businessObject);</p>
<p>method. The object at t... | [
{
"answer_id": 445058,
"author": "rball",
"author_id": 50711,
"author_profile": "https://Stackoverflow.com/users/50711",
"pm_score": 0,
"selected": false,
"text": "<p>Did you mean business._SubCategory.SubCategoryId</p>\n\n<p>and not sure what GetCurrentUser returns but if Id as well...<... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4140/"
] | Ok, so I have an object named "Business" (I know, I know, "Business Business Object")
When it saved its foreign keys are getting lost somehow. Everything else is saving. I have stepped through the code and followed the object up until the
session.SaveOrUpdate(businessObject);
method. The object at that point is inta... | Set the insert update properties to true or remove them. |
445,037 | <p>I've got a wx.Toolbar and I'd like to make the buttons larger. I've searched and can't seem to find any concrete documentation on how to do this.</p>
<p>I'm also wondering how well this will translate across platforms; what will happen to the buttons and icons on OSX?</p>
| [
{
"answer_id": 446014,
"author": "Mapad",
"author_id": 28165,
"author_profile": "https://Stackoverflow.com/users/28165",
"pm_score": 2,
"selected": false,
"text": "<p>Doesn't the size of the toolbar adapts itself automatically to the size of the bitmap icons? I think if you want a bigger... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46914/"
] | I've got a wx.Toolbar and I'd like to make the buttons larger. I've searched and can't seem to find any concrete documentation on how to do this.
I'm also wondering how well this will translate across platforms; what will happen to the buttons and icons on OSX? | It depends on what you want to change: is it the size of the buttons or the size of the icons ?
To change the size of the buttons, use [SetToolBitmapSize](http://docs.wxwidgets.org/2.6/wx_wxtoolbar.html#wxtoolbarsettoolbitmapsize) (24x24 for instance):
```
toolbar.SetToolBitmapSize((24, 24))
```
This will only chan... |
445,041 | <p>On occasion, I'll end up checking in a file to our TFS db that I didn't intend to.
Reverting to the prior version is quite tedious with my current approach.</p>
<p>If there a fast way to revert a file to a prior version in TFS? I'm open to command line, powertool, or UI approaches.</p>
| [
{
"answer_id": 446014,
"author": "Mapad",
"author_id": 28165,
"author_profile": "https://Stackoverflow.com/users/28165",
"pm_score": 2,
"selected": false,
"text": "<p>Doesn't the size of the toolbar adapts itself automatically to the size of the bitmap icons? I think if you want a bigger... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25201/"
] | On occasion, I'll end up checking in a file to our TFS db that I didn't intend to.
Reverting to the prior version is quite tedious with my current approach.
If there a fast way to revert a file to a prior version in TFS? I'm open to command line, powertool, or UI approaches. | It depends on what you want to change: is it the size of the buttons or the size of the icons ?
To change the size of the buttons, use [SetToolBitmapSize](http://docs.wxwidgets.org/2.6/wx_wxtoolbar.html#wxtoolbarsettoolbitmapsize) (24x24 for instance):
```
toolbar.SetToolBitmapSize((24, 24))
```
This will only chan... |
445,050 | <p>I'd like to cache objects in ASP.NET MVC. I have a <code>BaseController</code> that I want all Controllers to inherit from. In the BaseController there is a <code>User</code> property that will simply grab the User data from the database so that I can use it within the controller, or pass it to the views.</p>
<p>I... | [
{
"answer_id": 445060,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": false,
"text": "<p>If you don't need specific invalidation features of ASP.NET caching, static fields are pretty good, lightweight and easy to... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50711/"
] | I'd like to cache objects in ASP.NET MVC. I have a `BaseController` that I want all Controllers to inherit from. In the BaseController there is a `User` property that will simply grab the User data from the database so that I can use it within the controller, or pass it to the views.
I'd like to cache this information... | You can still use the cache (shared among all responses) and session (unique per user) for storage.
I like the following "try get from cache/create and store" pattern (c#-like pseudocode):
```
public static class CacheExtensions
{
public static T GetOrStore<T>(this Cache cache, string key, Func<T> generator)
{
... |
445,059 | <p>So earlier I answered my own question on thinking in vectors in R. But now I have another problem which I can't 'vectorize.' I know vectors are faster and loops slower, but I can't figure out how to do this in a vector method:</p>
<p>I have a data frame (which for sentimental reasons I like to call my.data) which I... | [
{
"answer_id": 451800,
"author": "Wil Doane",
"author_id": 54904,
"author_profile": "https://Stackoverflow.com/users/54904",
"pm_score": 0,
"selected": false,
"text": "<p>This is no answer, but I wonder if any insight lies in this direction:</p>\n\n<pre><code>> tapply((my.data$item[my... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37751/"
] | So earlier I answered my own question on thinking in vectors in R. But now I have another problem which I can't 'vectorize.' I know vectors are faster and loops slower, but I can't figure out how to do this in a vector method:
I have a data frame (which for sentimental reasons I like to call my.data) which I want to d... | Here's what seems like another very R-type way to generate the sums. Generate a vector that is as long as your input vector, containing nothing but the repeated sum of n elements. Then, subtract your original vector from the sums vector. The result: a vector (isums) where each entry is your original vector less the ith... |
445,070 | <p>For my university assignment I have to make a networkable version of pacman. I thought I would best approach this problem with making a local copy of pacman first and then extend this functionality for network play. </p>
<p>I would have to say that I am relatively new to java GUI development and utilizing such feat... | [
{
"answer_id": 445084,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 1,
"selected": false,
"text": "<p>Wow, that's a pretty tough problem to give someone just learning Java.</p>\n\n<p>My advice? Think in terms of objects.... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50913/"
] | For my university assignment I have to make a networkable version of pacman. I thought I would best approach this problem with making a local copy of pacman first and then extend this functionality for network play.
I would have to say that I am relatively new to java GUI development and utilizing such features withi... | It looks like your call to Thread.sleep doesn't do what you intended, but I don't think it's the source of your trouble. You have:
`Thread.sleep(Math.max(0, startTime - System.currentTimeMillis()));`
startTime will always be less than System.currentTimeMillis(), so startTime - System.currentTimeMillis() will always b... |
445,082 | <p>My main window has spawned a child window that's positioned on top to look like part of the main. I would like to move the child window in sync with the main but I'm not sure how. </p>
<p>My main window has my own title bar which event MouseLeftButtonDown calls this function:</p>
<pre><code>public void DragWindow... | [
{
"answer_id": 445277,
"author": "George Sealy",
"author_id": 10086,
"author_profile": "https://Stackoverflow.com/users/10086",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the window's Left and Top properties to place the secondary window. Here's a rough bit of code as an ... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36234/"
] | My main window has spawned a child window that's positioned on top to look like part of the main. I would like to move the child window in sync with the main but I'm not sure how.
My main window has my own title bar which event MouseLeftButtonDown calls this function:
```
public void DragWindow(object sender, MouseB... | AH HAH!
My Main window has an event LocationChanged which I've tied to my UpdateChildWindowPosition(). LocationChange fires when (duh) the location changes so it's continuously firing as I move the window when DragMove() is being executed in my DragWindow posted above. |
445,093 | <p>I'm trying to come up with a simple, easy to use design pattern for error handling in a .net wcf service (specifically a silverlight enabled wcf service). If an exception gets thrown in the service method the silverlight application will see a CommunicationException stating "The remote server returned an error: NotF... | [
{
"answer_id": 446247,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 3,
"selected": false,
"text": "<p>I would suggest you to centralize the error handling of your WCF service instead of putting try/catch on every m... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] | I'm trying to come up with a simple, easy to use design pattern for error handling in a .net wcf service (specifically a silverlight enabled wcf service). If an exception gets thrown in the service method the silverlight application will see a CommunicationException stating "The remote server returned an error: NotFoun... | Ok, I looked into the IErrorHandler idea. I had no idea you could do it this way, and it's perfect because it lets you avoid try catches for every method. Can you do this in standard web services too? I implemented it the following way:
```
/// <summary>
/// Services can intercept errors, perform processing, and affec... |
445,109 | <p>What would be the best approach to finding the set of coordinates, from say
about 5,00, which lie within a path of points, given a specified width.
eg an aircraft following several waypoints.</p>
<p>Is there a good way to also sort them in the same order as the route.</p>
<p>Calculation speed would be more impor... | [
{
"answer_id": 445241,
"author": "Andrei Krotkov",
"author_id": 54648,
"author_profile": "https://Stackoverflow.com/users/54648",
"pm_score": 1,
"selected": false,
"text": "<p>I assume you know how to calculate the distance between the points and the path. Latitude/Longitude is simple (x... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What would be the best approach to finding the set of coordinates, from say
about 5,00, which lie within a path of points, given a specified width.
eg an aircraft following several waypoints.
Is there a good way to also sort them in the same order as the route.
Calculation speed would be more important than accuracy... | There are many optimisations that you can do:
* Split your points into fixed sized tiles so you don't have to check every point (first determine which tile you're in, so you can skip all points in other tiles).
* When calculating the distance to each point, you'd normally use pythagoras to get the distance. But if you... |
445,113 | <p>Suppose you have a list of floating point numbers that are <strong>approximately</strong> multiples of a common quantity, for example </p>
<p>2.468, 3.700, 6.1699</p>
<p>which are approximately all multiples of 1.234. How would you characterize this "approximate gcd", and how would you proceed to compute or estima... | [
{
"answer_id": 445161,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": 4,
"selected": false,
"text": "<p>Express your measurements as multiples of the lowest one. Thus your list becomes 1.00000, 1.49919, 2.49996. The fractio... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18770/"
] | Suppose you have a list of floating point numbers that are **approximately** multiples of a common quantity, for example
2.468, 3.700, 6.1699
which are approximately all multiples of 1.234. How would you characterize this "approximate gcd", and how would you proceed to compute or estimate it?
Strictly related to my... | You can run Euclid's gcd algorithm with anything smaller then 0.01 (or a small number of your choice) being a pseudo 0. With your numbers:
```
3.700 = 1 * 2.468 + 1.232,
2.468 = 2 * 1.232 + 0.004.
```
So the pseudo gcd of the first two numbers is 1.232. Now you take the gcd of this with your last number:
```
6.169... |
445,114 | <p>I have a path I've created in Illustrator and saved as an SVG.</p>
<p>Now I want to programmatically place it at different sizes and coordinates on a large canvas.</p>
<p>Say I've got this image:</p>
<p><a href="https://i.stack.imgur.com/fXbIG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fXb... | [
{
"answer_id": 445161,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": 4,
"selected": false,
"text": "<p>Express your measurements as multiples of the lowest one. Thus your list becomes 1.00000, 1.49919, 2.49996. The fractio... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/242241/"
] | I have a path I've created in Illustrator and saved as an SVG.
Now I want to programmatically place it at different sizes and coordinates on a large canvas.
Say I've got this image:
[](https://i.stack.imgur.com/fXbIG.png)
(source: [omgtldr.com](http://omgtldr.... | You can run Euclid's gcd algorithm with anything smaller then 0.01 (or a small number of your choice) being a pseudo 0. With your numbers:
```
3.700 = 1 * 2.468 + 1.232,
2.468 = 2 * 1.232 + 0.004.
```
So the pseudo gcd of the first two numbers is 1.232. Now you take the gcd of this with your last number:
```
6.169... |
445,121 | <pre><code>var WshShell = new ActiveXObject("WScript.Shell");
var commandLine = "svnadmin dump " + repoFullPath + " > " + repoName + ".dumpfile";
WshShell.Exec(commandLine)
</code></pre>
<p>I am trying to run above cscript in Windows but it seems like, it's doing nothing. It doesn't create the dump file.</p>
<p>An... | [
{
"answer_id": 445341,
"author": "D'Arcy Rittich",
"author_id": 39430,
"author_profile": "https://Stackoverflow.com/users/39430",
"pm_score": 1,
"selected": false,
"text": "<p>You have not assigned values to repoFullPath or repoName. Before the Exec line, put </p>\n\n<pre><code>WScript.E... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2701560/"
] | ```
var WshShell = new ActiveXObject("WScript.Shell");
var commandLine = "svnadmin dump " + repoFullPath + " > " + repoName + ".dumpfile";
WshShell.Exec(commandLine)
```
I am trying to run above cscript in Windows but it seems like, it's doing nothing. It doesn't create the dump file.
Any mistake that I am doing? | You have not assigned values to repoFullPath or repoName. Before the Exec line, put
```
WScript.Echo(commandLine);
```
so that you can see what the script is trying to run. |
445,127 | <p>Can I pass "this" to a function as a pointer, from within the class constructor, and use it to point at the object's members before the constructor returns?</p>
<p>Is it safe to do this, so long as the accessed members are properly initialized before the function call?</p>
<p>As an example:</p>
<p><pre><code>#inc... | [
{
"answer_id": 445135,
"author": "MattK",
"author_id": 52734,
"author_profile": "https://Stackoverflow.com/users/52734",
"pm_score": 6,
"selected": true,
"text": "<p>When you instantiate an object in C++, the code in the constructor is the last thing executed. All other initialization, ... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can I pass "this" to a function as a pointer, from within the class constructor, and use it to point at the object's members before the constructor returns?
Is it safe to do this, so long as the accessed members are properly initialized before the function call?
As an example:
```
#include <iostream>
class Stuff
{
... | When you instantiate an object in C++, the code in the constructor is the last thing executed. All other initialization, including superclass initialization, superclass constructor execution, and memory allocation happens beforehand. The code in the constructor is really just to perform additional initialization once t... |
445,129 | <p>I have a library, and I want to migrate it from an old system to a new optimized one.</p>
<p>The old library was built using MS Access (mdb files), where each book is a file by itself. Each book consists of two tables, one for chapters titles and the second for contents. There is also one mdb file that contains all... | [
{
"answer_id": 445166,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "<p>None of the above. There's no reason you have to separate chapter titles from chapter content. But you need one ta... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44100/"
] | I have a library, and I want to migrate it from an old system to a new optimized one.
The old library was built using MS Access (mdb files), where each book is a file by itself. Each book consists of two tables, one for chapters titles and the second for contents. There is also one mdb file that contains all books nam... | None of the above. There's no reason you have to separate chapter titles from chapter content. But you need one table for the book titles themselves. Here's a suggested table structure:
```
CREATE TABLE books (
book_id SERIAL PRIMARY KEY,
title VARCHAR(100) NOT NULL,
published DATE NOT NULL,
isbn ... |
445,136 | <p>In my database, I have a few columns in one of my tables that are bit (boolean) values. They are allowed to be NULL since the fields are not always going to contain data.</p>
<p>I've gone through the process of creating an XSD DataSet using the table and made sure that the AllowDBNull field is set to True.</p>
<p>... | [
{
"answer_id": 445150,
"author": "Iain Holder",
"author_id": 1122,
"author_profile": "https://Stackoverflow.com/users/1122",
"pm_score": 2,
"selected": true,
"text": "<p>IMHO you shouldn't allow nulls in a bit/boolean field.</p>\n\n<p>Mike Hadlow has a good post on this here:</p>\n\n<p><... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71/"
] | In my database, I have a few columns in one of my tables that are bit (boolean) values. They are allowed to be NULL since the fields are not always going to contain data.
I've gone through the process of creating an XSD DataSet using the table and made sure that the AllowDBNull field is set to True.
However, when I p... | IMHO you shouldn't allow nulls in a bit/boolean field.
Mike Hadlow has a good post on this here:
<http://mikehadlow.blogspot.com/2006/10/nullability-voodoo.html>
Boolean is by definition a bi-state type. By making it nullable, you are adding a third state. It will come back to haunt you at some point. |
445,138 | <p>I wrote a script in Ruby. I'd like to run it every day at a certain time. How do you do that on a Windows XP system?</p>
<p>I poked around on the machine and discovered the "scheduled tasks" control panel, but it doesn't seem to have anything to do with running scripts, as far as I can tell from the options offered... | [
{
"answer_id": 445141,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 2,
"selected": false,
"text": "<p>You can do it with scheduled tasks, just browse for the program or script you want to run if it isn't listed (in th... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42595/"
] | I wrote a script in Ruby. I'd like to run it every day at a certain time. How do you do that on a Windows XP system?
I poked around on the machine and discovered the "scheduled tasks" control panel, but it doesn't seem to have anything to do with running scripts, as far as I can tell from the options offered by the "w... | Scheduled Tasks. Sometimes, you have to make a batch file call the script, and schedule the batch.
say you have "script.vbs" you want to run, you will have to create this batch:
```
cscript script.vbs
```
cscript is the windows script host which interprets the vbs script. I'm sure ruby has something similar. |
445,139 | <p>I need to get the path to the native (rather than the WOW) program files directory from a 32bit WOW process.</p>
<p>When I pass CSIDL_PROGRAM_FILES (or CSIDL_PROGRAM_FILESX86) into SHGetSpecialFolderPath it returns the WOW (Program Files (x86)) folder path.</p>
<p>I'd prefer to avoid using an environment variable ... | [
{
"answer_id": 445218,
"author": "Tamas Czinege",
"author_id": 8954,
"author_profile": "https://Stackoverflow.com/users/8954",
"pm_score": 4,
"selected": false,
"text": "<p>Let me quote <strong>Raymond Chen</strong>'s <a href=\"http://blogs.msdn.com/oldnewthing/archive/2008/12/22/9244582... | 2009/01/14 | [
"https://Stackoverflow.com/questions/445139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20911/"
] | I need to get the path to the native (rather than the WOW) program files directory from a 32bit WOW process.
When I pass CSIDL\_PROGRAM\_FILES (or CSIDL\_PROGRAM\_FILESX86) into SHGetSpecialFolderPath it returns the WOW (Program Files (x86)) folder path.
I'd prefer to avoid using an environment variable if possible.
... | I appreciate all the help and, especially, the warnings in this thread. However, I really do need this path and this is how I got it in the end:
(error checking removed for clarity, use at your own risk, etc)
```
WCHAR szNativeProgramFilesFolder[MAX_PATH];
ExpandEnvironmentStrings(L"%ProgramW6432%",
... |
445,167 | <p>I need to use a REG QUERY command to view the value of a key and set the result into a variable with this command:</p>
<pre><code>FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "KeyName" /v ValueName') DO SET Variable=%%B
</code></pre>
<p>But if the key doesnt exists i get an error shown in the console. I need ... | [
{
"answer_id": 445323,
"author": "Patrick Cuff",
"author_id": 7903,
"author_profile": "https://Stackoverflow.com/users/7903",
"pm_score": 6,
"selected": false,
"text": "<p>This works for me:</p>\n\n<pre><code>@echo OFF\n\nsetlocal ENABLEEXTENSIONS\nset KEY_NAME=\"HKEY_CURRENT_USER\\Softw... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to use a REG QUERY command to view the value of a key and set the result into a variable with this command:
```
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "KeyName" /v ValueName') DO SET Variable=%%B
```
But if the key doesnt exists i get an error shown in the console. I need to hide this error! I trie... | This works for me:
```
@echo OFF
setlocal ENABLEEXTENSIONS
set KEY_NAME="HKEY_CURRENT_USER\Software\Microsoft\Command Processor"
set VALUE_NAME=DefaultColor
FOR /F "usebackq skip=4 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName=%%A
set ValueType=%%B
set ValueValue=%... |
445,178 | <p>For example, would like 5 checks boxes to have their own submit button and the other 5 to have their own submit. Should be independednt of each other but they are not grouped together in the html page.<br>
Do I nest the other form? Do I put them under the same name and if so how do I distinct the submit? Submit see... | [
{
"answer_id": 445189,
"author": "alex",
"author_id": 31671,
"author_profile": "https://Stackoverflow.com/users/31671",
"pm_score": 0,
"selected": false,
"text": "<p>I'd use the button element. Try this link: <a href=\"http://particletree.com/features/rediscovering-the-button-element/\" ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52256/"
] | For example, would like 5 checks boxes to have their own submit button and the other 5 to have their own submit. Should be independednt of each other but they are not grouped together in the html page.
Do I nest the other form? Do I put them under the same name and if so how do I distinct the submit? Submit seems to... | [Your clarification](https://stackoverflow.com/questions/445178/multiple-forms/445208#445208) doesn't make too much sense from a user standpoint. Perhaps you want something like this:
```
<form action="/cgi-bin/Lib.exe" method="post" name="checks" id="Form1">
<input type="checkbox" name="user" value="'$NAME'" id="Ch... |
445,182 | <p>I'm refurbishing a simple web-app that our field techs use. One of my goals is to make it Blackberry-friendly, as all of the techs are now using those. This app accepts basic information about a job and stores it. Among that info are times, telephone numbers, and a street address. </p>
<p>I have the time fields and... | [
{
"answer_id": 445233,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": 2,
"selected": true,
"text": "<p>Have you considered a \"Street Number\" field followed by a separate \"Street Name\" field? There is no way to have a var... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9867/"
] | I'm refurbishing a simple web-app that our field techs use. One of my goals is to make it Blackberry-friendly, as all of the techs are now using those. This app accepts basic information about a job and stores it. Among that info are times, telephone numbers, and a street address.
I have the time fields and telephone... | Have you considered a "Street Number" field followed by a separate "Street Name" field? There is no way to have a variable number of digits at the start of this sort WAP input field without using JavaScript. |
445,222 | <p>I have a site that uses a couple DropDownLists that are databound. I was also doing the traditional if (!IsPostBack) {list.Databind();} and relied on viewstate to keep the lists filled during a post back. I recently converted the site to ASP.NET 3.5 and noticed that the lists are empty during postback (as if ViewSta... | [
{
"answer_id": 445612,
"author": "Ria",
"author_id": 53218,
"author_profile": "https://Stackoverflow.com/users/53218",
"pm_score": 3,
"selected": true,
"text": "<p>I have definitely seen similar problems (though mine were with visibility). Try to ensure that the ViewState is explicitly e... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36695/"
] | I have a site that uses a couple DropDownLists that are databound. I was also doing the traditional if (!IsPostBack) {list.Databind();} and relied on viewstate to keep the lists filled during a post back. I recently converted the site to ASP.NET 3.5 and noticed that the lists are empty during postback (as if ViewState ... | I have definitely seen similar problems (though mine were with visibility). Try to ensure that the ViewState is explicitly enabled on the whole control hierarchy down to the dropdown.
e.g.
```
‹asp:Page EnableViewState="True" ...›
...
‹asp:Panel EnableViewState="True"...›
...
‹asp:DropDow... |
445,225 | <p>I often want to make a multiline function call and reduce it down to one line. For example, convert...</p>
<pre><code>function_call(
'first_arg',
'second')
</code></pre>
<p>to</p>
<pre><code>function_call('first_arg', 'second')
</code></pre>
<p>Does emacs have some commands to help with this. Specifica... | [
{
"answer_id": 445240,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>Alt-space will reduce a string of whitespace to a single space character, but it won't delete the newline. Still, that sho... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680/"
] | I often want to make a multiline function call and reduce it down to one line. For example, convert...
```
function_call(
'first_arg',
'second')
```
to
```
function_call('first_arg', 'second')
```
Does emacs have some commands to help with this. Specifically, is there a command that will delete all whit... | You might try `delete-indentation`, my favorite command for joining multiple lines into one line. In your example, put the cursor on the line with "second" and hit `M-^` twice. Here are the docs:
>
> `M-^` runs the command `delete-indentation`, which is an interactive compiled Lisp function in `simple.el`.
>
>
> It... |
445,235 | <p>I know how to generate a random number in PHP but lets say I want a random number between 1-10 but I want more 3,4,5's then 8,9,10's. How is this possible? I would post what I have tried but honestly, I don't even know where to start.</p>
| [
{
"answer_id": 445265,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 5,
"selected": false,
"text": "<p>There's a <a href=\"http://www.perlmonks.org/?node_id=242751\" rel=\"noreferrer\">pretty good tutorial for you</a>... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7487/"
] | I know how to generate a random number in PHP but lets say I want a random number between 1-10 but I want more 3,4,5's then 8,9,10's. How is this possible? I would post what I have tried but honestly, I don't even know where to start. | Based on @Allain's [answer](https://stackoverflow.com/a/445265/362536)/[link](http://www.perlmonks.org/?node_id=242751), I worked up this quick function in PHP. You will have to modify it if you want to use non-integer weighting.
```
/**
* getRandomWeightedElement()
* Utility function for getting random values... |
445,276 | <p>Is there an attribute I can use on a method so that when stepping through some code in Debug mode the Debugger stays on the outside of the method?</p>
| [
{
"answer_id": 445278,
"author": "Andrew Rollings",
"author_id": 40410,
"author_profile": "https://Stackoverflow.com/users/40410",
"pm_score": 9,
"selected": true,
"text": "<pre><code> [DebuggerStepThrough]\n</code></pre>\n\n<p>(<a href=\"https://learn.microsoft.com/en-us/dotnet/api/syst... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | Is there an attribute I can use on a method so that when stepping through some code in Debug mode the Debugger stays on the outside of the method? | ```
[DebuggerStepThrough]
```
([docs](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.debuggerstepthroughattribute?view=netframework-4.7)) |
445,281 | <p>I have a bunch of documents in a MarkLogic xml database. One document has:</p>
<pre><code><colors>
<color>red</color>
<color>red</color>
</colors>
</code></pre>
<p>Having multiple colors is not a problem. Having multiple colors that are both red is a problem. How do I find t... | [
{
"answer_id": 446214,
"author": "Oliver Hallam",
"author_id": 19995,
"author_profile": "https://Stackoverflow.com/users/19995",
"pm_score": 2,
"selected": false,
"text": "<p>This should do the trick. I am not too familiar with MarkLogic, so the first line to get the set of documents may... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1681/"
] | I have a bunch of documents in a MarkLogic xml database. One document has:
```
<colors>
<color>red</color>
<color>red</color>
</colors>
```
Having multiple colors is not a problem. Having multiple colors that are both red is a problem. How do I find the documents that have duplicate data? | Everything MarkLogic returns is just a sequence of nodes, so we can count the sequence size of the whole and compare it to the count of the sequence of distinct values. If they're not distinct, they're duplicate, and you have your subset.
```xquery
for $c in doc()//colors
where fn:count($c/color) != fn:count(fn:distin... |
445,282 | <p>I realize that a whole lot of code cannot fit here, but I am asking for general direction or pointer.</p>
<p>I have .NET user controls nested six deep for an interactive gadget with (outer to inner) of : wrapper, tabs, panels, lists, rows, items.</p>
<p>I am trying to get a reference to an ancestor control from a... | [
{
"answer_id": 445288,
"author": "Thomas Hansen",
"author_id": 29746,
"author_profile": "https://Stackoverflow.com/users/29746",
"pm_score": -1,
"selected": false,
"text": "<p>Howdy, you could use the WebControl selector which is actually an independant project (license == LGPL) but stil... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35615/"
] | I realize that a whole lot of code cannot fit here, but I am asking for general direction or pointer.
I have .NET user controls nested six deep for an interactive gadget with (outer to inner) of : wrapper, tabs, panels, lists, rows, items.
I am trying to get a reference to an ancestor control from a nested control.
... | Remember that components are best made ignorant. You never want any control to have any knowledge of anything above itself in the hierarchy and to have interface-only knowledge of controls below itself in the hierarchy. This architectural approach will save you much pain and suffering in the long run and will avoid sit... |
445,283 | <p>Greetings!</p>
<p>I'd like to build an apache web server, running on debian lenny.</p>
<p>It will primarily be used for hosting a web-shop, so it should have some light db i/o and lots of image serving (item previews/thumbs/etc...).</p>
<p>It's tough to put a finger on the exact number of concurrent requests that... | [
{
"answer_id": 445305,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 2,
"selected": true,
"text": "<p>On the one hand you say you don't need that much performance but on the another you are talking about adding as man... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18058/"
] | Greetings!
I'd like to build an apache web server, running on debian lenny.
It will primarily be used for hosting a web-shop, so it should have some light db i/o and lots of image serving (item previews/thumbs/etc...).
It's tough to put a finger on the exact number of concurrent requests that I'll get hit with, but ... | On the one hand you say you don't need that much performance but on the another you are talking about adding as many cores as you can. A quad core CPU of either AMD or Intel will be more than sufficient. It gets into the category of "religious war" but i prefer the Intel chips; I usually buy Xeon processors. As far as ... |
445,286 | <p>This most likely has a very simple answer, but I can't figure it out.</p>
<p>I'm trying to refactor some code that looks like this:</p>
<pre><code>SAFEARRAY* psa;
long* count;
HRESULT hr = pSomeInterface->ListSomething(&psa, &count);
if (SUCCEEDED(hr))
{
CComSafeArray<BSTR> sa;
if (*count ... | [
{
"answer_id": 445876,
"author": "Aamir",
"author_id": 30341,
"author_profile": "https://Stackoverflow.com/users/30341",
"pm_score": 1,
"selected": false,
"text": "<p>I don't see any such problem in your code. If you can share the code of ListSomething(..) method, then we might be able t... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23974/"
] | This most likely has a very simple answer, but I can't figure it out.
I'm trying to refactor some code that looks like this:
```
SAFEARRAY* psa;
long* count;
HRESULT hr = pSomeInterface->ListSomething(&psa, &count);
if (SUCCEEDED(hr))
{
CComSafeArray<BSTR> sa;
if (*count > 0)
{
sa.Attach(psa);
... | I don't see any such problem in your code. If you can share the code of ListSomething(..) method, then we might be able to find something but a similar code like this works perfectly with me.
```
void MyMethod(SAFEARRAY** pArray)
{
int i = (*pArray)->cbElements;
return;
}
CComSafeArray<BSTR> myArray;
my... |
445,293 | <p>Using Ruby on Rails I want a confirmation page before creating an ActiveRecord object. The user will see a preview of the item they are creating before submitting and the object being saved in the database</p>
<p>A common pattern;</p>
<ul>
<li>User visits /entry/new</li>
<li>User enters details and clicks submit <... | [
{
"answer_id": 445355,
"author": "Rob Elsner",
"author_id": 50360,
"author_profile": "https://Stackoverflow.com/users/50360",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure how to do this (RoR is new to me) but you could just specify the action for /new as /confirm, and then ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51872/"
] | Using Ruby on Rails I want a confirmation page before creating an ActiveRecord object. The user will see a preview of the item they are creating before submitting and the object being saved in the database
A common pattern;
* User visits /entry/new
* User enters details and clicks submit
* User is redirected to /entr... | Another option to solve this issue adding by a virtual confirmation attribute to your model. This way, there is no need to create a separate action for this:
```
class MyRecord < ActiveRecord::Base
attr_accessor :confirmation
validates_acceptance_of :confirmation, :on => :create
end
```
Now, your new object wil... |
445,295 | <pre><code>#include "cv.h"
#include "highgui.h"
#include <stdio.h>
int main(int argc, char* argv[]){
cvNamedWindow("Window1", CV_WINDOW_AUTOSIZE);
IplImage* image = 0;
->->image = cvLoadImage(argv[1]);<-<-
if(!image) printf("Unable to load image!");
cvShowImage("Window1", image);... | [
{
"answer_id": 445328,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "<p>Are you certain \"247.png\" is in the current working directory when you have the name hardcoded?</p>\n\n<p>Run th... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54287/"
] | ```
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
int main(int argc, char* argv[]){
cvNamedWindow("Window1", CV_WINDOW_AUTOSIZE);
IplImage* image = 0;
->->image = cvLoadImage(argv[1]);<-<-
if(!image) printf("Unable to load image!");
cvShowImage("Window1", image);
char c = cvWaitKey(0)... | Under Project->Properties->Configuration Properties->Debugging there is a field "Working Directory". Set that to the directory you want to execute in and that should fix the problem. |
445,297 | <p>I have two versions of an almost identical database. Below I have created an Example table to demonstrate the basic differences, namely the ID column has changed from an Integer Identity to a GUID and various properties have been updated, in the Example archived has been replaced with readOnly and hidden:</p>
<p>L... | [
{
"answer_id": 445664,
"author": "mkchandler",
"author_id": 54727,
"author_profile": "https://Stackoverflow.com/users/54727",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe I'm not understanding your question correctly, but it sounds to me like you need to implement something like t... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55255/"
] | I have two versions of an almost identical database. Below I have created an Example table to demonstrate the basic differences, namely the ID column has changed from an Integer Identity to a GUID and various properties have been updated, in the Example archived has been replaced with readOnly and hidden:
Legacy versi... | Why not abstract your data provider, implementing 2 versions (one with nhibernate mappings for the legacy data item, and one for the new data item).
To paraphrase your code slightly (simplified for clarity):
```
public abstract class AbstractData
{
public abstract string SomeValue { get; set; }
public abstrac... |
445,299 | <p>I have a cube in SSAS 2005 that calculates running sums over millions of records. The current implementation is using a PeriodsToDate sum function in MDX and it is horribly slow, taking 15 minutes or more to return results in some cases. There are a huge number of solutions to this problem so I am hoping someone e... | [
{
"answer_id": 448556,
"author": "Shane Delmore",
"author_id": 50031,
"author_profile": "https://Stackoverflow.com/users/50031",
"pm_score": 0,
"selected": false,
"text": "<p>The MDX I am currently using is very slow, here it is.</p>\n\n<pre><code>\nSum\n(\nPeriodsToDate([Date of Transac... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50031/"
] | I have a cube in SSAS 2005 that calculates running sums over millions of records. The current implementation is using a PeriodsToDate sum function in MDX and it is horribly slow, taking 15 minutes or more to return results in some cases. There are a huge number of solutions to this problem so I am hoping someone else h... | Took me little while to figure this out where it would work with and without a hierarchy on the time dimension. Based on my data and my cube structure, here's what I put together:
```
with member [Measures].[RunningTotal] as
'sum({[Deferred Revenue Date].[Standard Calendar].CurrentMember.Level.Item(0):[Deferred Reven... |
445,300 | <p>I've got a problem on a <em>WebForms</em> application where a user selects some criteria from drop downs on the page and hits a button on the page which calls this method:</p>
<pre><code>protected void btnSearch_Click(object sender, EventArgs e)
</code></pre>
<p>They then click on button to download a zip file bas... | [
{
"answer_id": 445309,
"author": "Greg Dean",
"author_id": 1200558,
"author_profile": "https://Stackoverflow.com/users/1200558",
"pm_score": 0,
"selected": false,
"text": "<p>Are you using the Content-Disposition header?</p>\n\n<pre><code>Response.AddHeader(\"Content-Disposition\", \"att... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2849/"
] | I've got a problem on a *WebForms* application where a user selects some criteria from drop downs on the page and hits a button on the page which calls this method:
```
protected void btnSearch_Click(object sender, EventArgs e)
```
They then click on button to download a zip file based on the criteria which calls th... | When they click the download button, do a Redirect to the ZIP file handler (page?) to download the file. i.e. use the Post-Redirect-Get pattern: <http://en.wikipedia.org/wiki/Post/Redirect/Get> |
445,313 | <p>I want to set the <strong><em>enabled</em></strong> property on a button based on the return value of a function that has one or more parameters. How can I do this?</p>
<pre><code>private function isUserAllowed (userName:Boolean):Boolean {
if (userName == 'Tom')
return true;
if (userName == 'Bill')
... | [
{
"answer_id": 445368,
"author": "ForYourOwnGood",
"author_id": 48728,
"author_profile": "https://Stackoverflow.com/users/48728",
"pm_score": 0,
"selected": false,
"text": "<pre><code><mx:Script>\n <![CDATA[\n [Bindable]\n private var userName : String = \"Tom\"... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5592/"
] | I want to set the ***enabled*** property on a button based on the return value of a function that has one or more parameters. How can I do this?
```
private function isUserAllowed (userName:Boolean):Boolean {
if (userName == 'Tom')
return true;
if (userName == 'Bill')
return false;
}
<mx:Button labe... | ```
<mx:Button
enabled = "{this.myFunction(this.myVariable)}"
>
```
or inline:
```
<mx:Button
enabled = "{(function(arg:Object):Boolean{ ... })(this.myVariable)}"
>
``` |
445,329 | <p>I have object1 as a child of a Canvas. object1 has a MouseLeftButtonDown event handler which captures the object. </p>
<pre><code>object1.CaptureMouse();
</code></pre>
<p>While still holding down the left mouse button, I move the mouse over object2. In code, how do I find out if the mouse is actually over object... | [
{
"answer_id": 445354,
"author": "Jesse Taber",
"author_id": 1680,
"author_profile": "https://Stackoverflow.com/users/1680",
"pm_score": 0,
"selected": false,
"text": "<p>You're right in that the 'CaptureMouse()' call is going to prevent other mouse events from happening.</p>\n\n<p>If yo... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have object1 as a child of a Canvas. object1 has a MouseLeftButtonDown event handler which captures the object.
```
object1.CaptureMouse();
```
While still holding down the left mouse button, I move the mouse over object2. In code, how do I find out if the mouse is actually over object2 (or determine whichever ... | You will want to use the **System.Windows.VisualTreeHelper**:
**VisualTreeHelper.FindElementsInHostCoordinates** will "Retrieves a set of objects that are located within a specified point of an object's coordinate space."
there are two overloads of the function, one that takes a Point and one that takes a Rect. |
445,381 | <p>I'm trying to return a record from LINQ2SQL as a JsonResult to update my view page via jquery ajax. I'll post my code below. When I follow it through the debugger my function in the controller is being called and it is returning a record. I think there might be something wrong with my Jquery to retrieve the JSONR... | [
{
"answer_id": 445408,
"author": "JD Conley",
"author_id": 51769,
"author_profile": "https://Stackoverflow.com/users/51769",
"pm_score": 2,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>$(\"#Title\").text(data.Title);\n</code></pre>\n\n<p>or </p>\n\n<pre><code>$(\"#Title\").html(... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47895/"
] | I'm trying to return a record from LINQ2SQL as a JsonResult to update my view page via jquery ajax. I'll post my code below. When I follow it through the debugger my function in the controller is being called and it is returning a record. I think there might be something wrong with my Jquery to retrieve the JSONResult.... | The result of your query is an IEnumerable which is probably serialized as an array of Project objects even though there is only one. My VB syntax is probably bad but select the First() of the objects chosen by the selection.
```
return JsonResult( person.First() );
```
You'll need @JD Conley's fix as well, I think. |
445,382 | <p>Is there a C/C++ library, and documentation about how to collect system and process information on Solaris?</p>
<p>Although I could parse command-line tools, I'd rather use a library that makes the task easier to do.</p>
<p>Thanks</p>
<p><strong>Edit:</strong> It has been suggested to use the /proc virtual direct... | [
{
"answer_id": 445461,
"author": "vinc456",
"author_id": 45620,
"author_profile": "https://Stackoverflow.com/users/45620",
"pm_score": 0,
"selected": false,
"text": "<p>I'm definately not an expert on the subject, but I did something very similar for an assignment last semester when we w... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] | Is there a C/C++ library, and documentation about how to collect system and process information on Solaris?
Although I could parse command-line tools, I'd rather use a library that makes the task easier to do.
Thanks
**Edit:** It has been suggested to use the /proc virtual directory to collect information, however i... | You can get this kind of information with [kstat API](http://developers.sun.com/solaris/articles/kstatc.html).
```
man -s 3KSTAT kstat
```
You can see how it is used in OpenSolaris [vmstat](http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/stat/vmstat/) and [iostat](http://cvs.opensolaris.org/sourc... |
445,383 | <p>Is it a good practice to develop web-service and web-site in two different languages, on two different servers? E.g. right now I create a Java web-service running on Glassfish and Ruby on Rails presentation layer running in the same server.</p>
<p>I'd like to leave web-service on the same server but use Ruby 1.9, r... | [
{
"answer_id": 445461,
"author": "vinc456",
"author_id": 45620,
"author_profile": "https://Stackoverflow.com/users/45620",
"pm_score": 0,
"selected": false,
"text": "<p>I'm definately not an expert on the subject, but I did something very similar for an assignment last semester when we w... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47937/"
] | Is it a good practice to develop web-service and web-site in two different languages, on two different servers? E.g. right now I create a Java web-service running on Glassfish and Ruby on Rails presentation layer running in the same server.
I'd like to leave web-service on the same server but use Ruby 1.9, running in ... | You can get this kind of information with [kstat API](http://developers.sun.com/solaris/articles/kstatc.html).
```
man -s 3KSTAT kstat
```
You can see how it is used in OpenSolaris [vmstat](http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/stat/vmstat/) and [iostat](http://cvs.opensolaris.org/sourc... |
445,399 | <p>I'm fairly new to the Zend Framework and MVC and I'm a bit confused by Zend_DB and the proper way to interact with the database.</p>
<p>I'm using the PDO MySQL adapter and have created some classes to extend the abstract classes:</p>
<pre><code>class Users extends Zend_Db_Table_Abstract {
protected $_name = 'u... | [
{
"answer_id": 445445,
"author": "Brian Fisher",
"author_id": 43816,
"author_profile": "https://Stackoverflow.com/users/43816",
"pm_score": 4,
"selected": true,
"text": "<p>Using Zend_Db you probably don't want to get into the details of prepared statements and the like. You just want t... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6305/"
] | I'm fairly new to the Zend Framework and MVC and I'm a bit confused by Zend\_DB and the proper way to interact with the database.
I'm using the PDO MySQL adapter and have created some classes to extend the abstract classes:
```
class Users extends Zend_Db_Table_Abstract {
protected $_name = 'users';
protected... | Using Zend\_Db you probably don't want to get into the details of prepared statements and the like. You just want to use the model objects to do basic CRUD (Create, Read, Update and Delete). I know the [Programmer's Reference Guide](http://framework.zend.com/manual/en/zend.db.html) is extensive, but its a great introdu... |
445,401 | <p>This is different than the simple 2 column layout.</p>
<p>I need to have this html:</p>
<pre><code><div class="menu">
<div class="right">One</div>
<div>Three</div>
<div>Four</div>
<div class="right">Two</div>
<div class="right">Two<... | [
{
"answer_id": 445415,
"author": "Tamas Czinege",
"author_id": 8954,
"author_profile": "https://Stackoverflow.com/users/8954",
"pm_score": 0,
"selected": false,
"text": "<p>I can't seem to figure out what you are trying to achieve. Could you please create some basic sketch in MS Paint or... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50394/"
] | This is different than the simple 2 column layout.
I need to have this html:
```
<div class="menu">
<div class="right">One</div>
<div>Three</div>
<div>Four</div>
<div class="right">Two</div>
<div class="right">Two</div>
<div>Four</div>
<div class="right">Two</div>
</div>
```
The div clas... | Try:
```
div.menu div {
float: left;
clear: left;
}
div.menu div.right {
float: right;
clear: right;
}
``` |
445,407 | <p>I'm starting up a new web-site, and I'm having difficulties enforcing my desired file/folder organization:</p>
<p>For argument's sake, let's say that my website will be hosted at:
<a href="http://mywebsite.com/" rel="nofollow noreferrer">http://mywebsite.com/</a></p>
<p>I'd like (have set up) Apache's Virtual Host... | [
{
"answer_id": 445419,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 1,
"selected": false,
"text": "<p>Can you use symlinks?</p>\n\n<pre><code>ln -s /fileserver/files/mywebsite_com/stuff/robots.txt /fileserver/files/mywebs... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18058/"
] | I'm starting up a new web-site, and I'm having difficulties enforcing my desired file/folder organization:
For argument's sake, let's say that my website will be hosted at:
<http://mywebsite.com/>
I'd like (have set up) Apache's Virtual Host to map <http://mywebsite.com/> to the /fileserver/mywebsite\_com/www folder.... | It seems you are set to using a RewriteRule. However, I suggest you use an Alias:
```
Alias /robots.txt /fileserver/files/mywebsite_com/stuff/robots.txt
```
Additionally, you will have to tell Apache about the restrictions on that file. If you have more than one file treated this way, do it for the complete director... |
445,411 | <p>I'm trying to send a WOL package on all interfaces in order to wake up the gateway(which is the DHCP server, so the machine won't have an IP yet).</p>
<p>And it seems that I can only bind sockets to IP and port pairs...</p>
<p>So the question is: How can a create a socket(or something else) that is bound to a NIC ... | [
{
"answer_id": 445416,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 2,
"selected": false,
"text": "<p>WOL is done by MAC, not IP. <a href=\"http://blog.opennetcf.com/ctacke/2006/12/06/WakeonLANWOLFromC.aspx\" rel=\"nofoll... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55267/"
] | I'm trying to send a WOL package on all interfaces in order to wake up the gateway(which is the DHCP server, so the machine won't have an IP yet).
And it seems that I can only bind sockets to IP and port pairs...
So the question is: How can a create a socket(or something else) that is bound to a NIC that has no IP?
(... | It seems that I have found a solution. One can use winpcap to inject packets to any interface.
And there is good wrapper for .net: <http://www.tamirgal.com/home/dev.aspx?Item=SharpPcap>
(I would have prefered a solution which requires no extra libraries to be installed...)
**UPDATE:** Here is what I came up for sendi... |